:root {
  --bg: #0f1420;
  --bg2: #171e2e;
  --bg3: #1e2740;
  --line: #2b3550;
  --text: #e6ebf5;
  --muted: #93a1bd;
  --accent: #38bdf8;
  --accent2: #22d3ee;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --radius: 10px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

/* Apenas leitores de tela / SEO (invisível visualmente) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- Barra de rolagem com as cores da página ---------- */
html {
  scrollbar-width: thin;
  scrollbar-color: var(--line) var(--bg2);
}
*::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}
*::-webkit-scrollbar-track {
  background: var(--bg2);
}
*::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 7px;
  border: 2px solid var(--bg2);
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}
*::-webkit-scrollbar-corner {
  background: var(--bg2);
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

button { font: inherit; }

/* ---------- Topo ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 22px;
  background: linear-gradient(135deg, #101b2e, #0c1320);
  border-bottom: 1px solid var(--line);
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.3px;
}

.brand h1 .light { color: var(--muted); font-weight: 500; }

.subtitle { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }

.conn { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Botões de ícone no topo + tooltip ---------- */
.icon-wrap { display: inline-flex; }
.icon-btn {
  appearance: none;
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg3);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn .ms { margin: 0; font-size: 20px; vertical-align: 0; }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn.btn-accent { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; color: #04121f; }
.icon-btn.btn-accent:hover:not(:disabled) { filter: brightness(1.08); }

/* Botão de idioma */
.lang-btn {
  appearance: none;
  cursor: pointer;
  height: 40px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg3);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  font-size: 12px;
  transition: 0.15s;
}
.lang-btn .ms { font-size: 18px; margin: 0; }
.lang-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Tooltip fixo (não estoura a janela, quebra em linhas) */
.tooltip {
  position: fixed;
  z-index: 200;
  background: #0a0f1a;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 7px 11px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  max-width: 240px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  white-space: normal;
}

.badge {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--line);
}
.badge.ok { color: var(--green); border-color: var(--green); background: rgba(52, 211, 153, 0.08); }
.badge.off { color: var(--muted); }

/* ---------- Botões ---------- */
.btn {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--bg3);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  transition: 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); background: #263452; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #04121f; font-weight: 700; }
.btn-primary:hover:not(:disabled) { background: #7dd3fc; border-color: #7dd3fc; }
.btn-primary.connected {
  border-color: var(--green);
  background: rgba(52, 211, 153, 0.12);
  color: var(--green);
}
.btn-accent { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; color: #04121f; font-weight: 700; }
.btn-accent:hover:not(:disabled) { filter: brightness(1.08); }
.btn-small { padding: 5px 10px; font-size: 12.5px; }

/* ---------- Aviso / ajuda ---------- */
.banner {
  margin: 12px 22px 0;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid var(--amber);
  color: var(--amber);
}

/* ---------- Progresso (aparece só durante leitura/gravação) ---------- */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 22px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
}
#progress { flex: 1; height: 10px; accent-color: var(--accent); }
#progress-label { color: var(--muted); font-size: 12.5px; white-space: nowrap; }

.chk-inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; user-select: none; }

/* ---------- Layout ---------- */
.layout {
  padding: 16px 22px;
}

/* ---------- Aba de configurações ---------- */
.config-view {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
  align-items: start;
}
.config-view .cfg-section {
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 0;
}
.config-view .cfg-section h3 { margin-top: 0; }

.cfg-section { margin-bottom: 0; }
.cfg-section h3 {
  margin: 14px 0 8px;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent);
  border-bottom: 1px solid var(--line);
  padding-bottom: 5px;
}
.cfg-section summary { cursor: pointer; color: var(--accent); font-weight: 600; }

.hint { color: var(--muted); font-size: 12px; margin: 2px 0 8px; }

.cfg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}
.field-full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { color: var(--muted); font-size: 12px; }
.field .value { font-weight: 600; }

/* Espaço extra entre Key Lock e o seletor acima */
.key-lock-field { margin-top: 14px; }

/* Stepper (Volume / Squelch) */
.stepper { display: flex; align-items: center; gap: 6px; }
.step-btn {
  appearance: none;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg3);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: 0.15s;
}
.step-btn:hover { border-color: var(--accent); color: var(--accent); }
.step-btn .ms { font-size: 16px; margin: 0; }
.step-value {
  min-width: 30px;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 3px 6px;
  font-variant-numeric: tabular-nums;
}

select, input[type="text"], input[type="range"] {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 8px;
}
select:focus, input[type="text"]:focus { outline: 1px solid var(--accent); }
input[type="range"] { padding: 0; accent-color: var(--accent); }

/* Chips (bancos / faixas cc) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* Pílulas de checkbox (bandas do Close Call e alertas) */
.pill-chk {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  padding: 6px 13px;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  max-width: 100%;
  width: fit-content;
  align-self: flex-start;
  transition: 0.15s;
}
.pill-chk:hover { border-color: var(--accent); color: var(--text); }
.pill-chk:has(input:checked) {
  background: rgba(52, 211, 153, 0.12);
  border-color: var(--green);
  color: var(--green);
  font-weight: 600;
}
#cc-bands {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  margin-top: 14px;
}
.chip {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--bg3);
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  transition: 0.15s;
}
.chip.on { background: rgba(52, 211, 153, 0.12); border-color: var(--green); color: var(--green); font-weight: 600; }
.chip:hover { border-color: var(--accent); }

/* Faixas customizadas */
.ranges { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.range-row { display: grid; grid-template-columns: auto 1fr 84px auto 84px; gap: 6px; align-items: center; }
.range-row input[type="text"] { width: 100%; font-size: 12.5px; padding: 4px 7px; }
.range-row .mini { color: var(--muted); font-size: 12px; white-space: nowrap; }
.range-row .sep { color: var(--muted); }

/* Serviços */
.services { display: flex; flex-direction: column; gap: 4px; }
.svc-row { display: grid; grid-template-columns: 1fr 74px 96px; gap: 6px; align-items: center; }
.svc-name { font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.svc-row select { padding: 3px 6px; font-size: 12px; }

.gl-list { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 12.5px; }
.gl-list .empty { list-style: none; margin-left: -18px; }

/* ---------- Painel de bancos ---------- */
.banks-panel {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
}

/* ---------- Abas principais estilo planilha (Excel) no topo ---------- */
.sheet-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 14px 0;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
}
.sheet-tab {
  appearance: none;
  cursor: pointer;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 9px 9px 0 0;
  padding: 8px 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  transition: 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sheet-tab:hover { border-color: var(--accent); color: var(--text); }
.sheet-tab.active {
  background: var(--bg2);
  border-color: var(--line);
  border-bottom-color: var(--bg2);
  color: var(--text);
  font-weight: 700;
  position: relative;
  top: 1px;
  margin-bottom: -1px;
}

/* ---------- Sub-abas dos bancos (dentro da aba Bancos) ---------- */
.bank-toolbar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 12px 0;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

/* Linha de controles do banco (Scan + Limpar), acima dos títulos da tabela */
.bank-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.sub-tabs { display: flex; gap: 4px; flex-wrap: wrap; align-items: flex-end; }
.sub-tab {
  appearance: none;
  cursor: pointer;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 7px 7px 0 0;
  min-width: 34px;
  text-align: center;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.sub-tab:hover { border-color: var(--accent); color: var(--text); }
.sub-tab.active {
  background: var(--bg2);
  color: var(--text);
  font-weight: 700;
  border-color: var(--line);
  border-bottom: none;
  position: relative;
  top: 1px;
  margin-bottom: -1px;
}
.sub-tab.off { opacity: 0.45; }
.sub-tab.off.active { opacity: 1; }
.sub-tab.off:hover { opacity: 0.8; }

.bank-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-left: auto; }

.ch-table { width: 100%; border-collapse: collapse; }
.ch-table th {
  background: var(--bg3);
  color: var(--muted);
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.ch-table td { padding: 3px 10px; border-bottom: 1px solid rgba(43, 53, 80, 0.4); }
.ch-table tr:hover td { background: rgba(56, 189, 248, 0.05); }
.ch-num { width: 48px; color: var(--muted); font-variant-numeric: tabular-nums; }

.freq-input {
  width: 130px;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
.freq-input.invalid { border-color: var(--red); color: var(--red); }

input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* ---------- Ícones Material Symbols ---------- */
.ms {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 18px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 20;
  vertical-align: -4px;
}
.btn .ms, .sheet-tab .ms, .banner .ms { margin-right: 6px; vertical-align: -5px; }
.btn-small .ms { font-size: 16px; margin-right: 4px; vertical-align: -4px; }
.brand h1 .ms { font-size: 24px; vertical-align: -5px; margin-right: 4px; color: var(--accent); }
.cfg-section summary .ms { margin-right: 4px; color: var(--accent); }

/* ---------- Modal de gravação ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 16, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 16px;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 14px;
  max-width: 480px;
  width: 100%;
  padding: 20px 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.modal h3 { margin: 0 0 8px; font-size: 17px; }
.modal-desc { color: var(--muted); margin: 0 0 14px; }
.modal-option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
}
.modal-option input { margin-top: 2px; width: 16px; height: 16px; flex: none; }
.modal-option b { display: block; }
.modal-option small { color: var(--muted); display: block; margin-top: 3px; line-height: 1.45; }
.modal-option small b { display: inline; color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal h3 .ms { vertical-align: -5px; margin-right: 6px; color: var(--accent); }

/* Modal de colar frequências */
.modal textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  padding: 10px 12px;
  resize: vertical;
  min-height: 140px;
}
.modal textarea:focus { outline: none; border-color: var(--accent); }
.paste-start {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}
.paste-start input {
  width: 64px;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  padding: 6px 8px;
  font: inherit;
  font-variant-numeric: tabular-nums;
}
.paste-start input:focus { outline: none; border-color: var(--accent); }

/* Ajuda (Como usar) */
.help-steps { margin: 6px 0 0; padding-left: 20px; color: var(--muted); }
.help-steps li { margin: 5px 0; }
.help-steps code { background: var(--bg3); padding: 1px 5px; border-radius: 5px; color: var(--accent2); }
.help-note {
  color: var(--muted);
  font-size: 12.5px;
  margin: 14px 0 0;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

/* ---------- Rodapé (minimalista) ---------- */
.seo-about {
  padding: 12px 22px 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  max-width: 980px;
  margin: 0 auto;
  text-align: center;
}
.seo-about p { margin: 0 0 8px; }

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 22px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
}
.site-footer a {
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
}
.site-footer a:hover { text-decoration: underline; }
.site-footer .ms { font-size: 14px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg3);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  z-index: 100;
  max-width: 90vw;
}
.toast.error { border-color: var(--red); color: var(--red); }
.toast.info { border-color: var(--accent); }

/* Tela larga: Configurações e Bancos de memória lado a lado */
@media (min-width: 1200px) {
  .banks-panel {
    display: grid;
    grid-template-columns: minmax(360px, 38%) 1fr;
  }
  .sheet-tabs { display: none; }
  #view-config { border-right: 1px solid var(--line); }
}
