/* Fontes locais (sem chamada externa). Caminho relativo a este CSS. */
@font-face { font-family: "Chakra Petch"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/chakra-petch-500-latin.woff2") format("woff2"); }
@font-face { font-family: "Chakra Petch"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/chakra-petch-600-latin.woff2") format("woff2"); }
@font-face { font-family: "Chakra Petch"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/chakra-petch-700-latin.woff2") format("woff2"); }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 200 900; font-display: swap; src: url("../fonts/source-sans-3-latin-var.woff2") format("woff2"); }

/* Tema CNT (identidade do painel admin do cntoficial).
   Carregado DEPOIS de tokens/base/layout/components: só remapeia tokens e refina componentes existentes.
   Mapeamento: --cnt-fundo->--bg, --cnt-superficie->--surface, --ad-borda/--ad-linha->--line, --cnt-texto->--text,
   --ad-suave->--text-dim, --ad-fraco->--text-faint, --cnt-ouro-claro->--accent, --cnt-ouro-escuro->--accent-dim,
   --cnt-azul-claro->--blue, --ad-ok/aviso/erro->--green/--amber/--red, --cnt-degrade-ouro-forte->--grad-gold. */

:root {
  --bg: #002a3f; --surface: #00324a; --surface-2: #003a57; --line: rgba(82, 177, 224, .22);
  --text: #f7f3e8; --text-dim: #9fb3c0; --text-faint: #52b1e0;
  --accent: #f8dd9a; --accent-dim: #a8813c; --accent-ink: #00304a;
  --blue: #52b1e0; --red: #ff8078; --green: #5fd49a; --amber: #f2c14e;
  --grad-gold: linear-gradient(115deg, #f8dd9a 0%, #e9cd8e 45%, #f8dd9a 75%, #e9cd8e 100%);
  --shadow-1: 0 12px 32px -12px rgba(0, 10, 20, .65), 0 2px 8px -2px rgba(168, 129, 60, .25);
  --shadow-2: 0 30px 70px -20px #000;
  --overlay: rgba(0, 10, 18, .62);
  --font-title: "Chakra Petch", system-ui, sans-serif;
  --font-body: "Source Sans 3", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  /* tokens novos do tema */
  --painel: rgba(0, 54, 79, .42); --input-bg: rgba(0, 20, 32, .55); --thead-bg: rgba(0, 36, 54, .95);
  --pop-bg: #00324a; --gold-line: hsla(40, 44%, 58%, .22); --gold: #c4a466;
  --grad-bg: linear-gradient(160deg, #001c2c 0%, #002a3f 45%, #00415f 100%);
  --sidebar-bg: linear-gradient(180deg, rgba(0, 28, 44, .96), rgba(0, 36, 54, .96));
  --topbar-bg: rgba(0, 28, 44, .72);
  --scroll-thumb: rgba(196, 164, 102, .55); --scroll-track: rgba(0, 20, 32, .35);
  --r2: 10px; --r3: 14px; --r4: 16px;
  --sidebar-w: 252px; --topbar-h: 68px; --ease-shell: cubic-bezier(.22, 1, .36, 1);
  color-scheme: dark;
}
/* Claro: mesma família azul/ouro, ouro só como destaque escuro (contraste AA sobre branco). */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eaf1f5; --surface: #fff; --surface-2: #e3edf2; --line: #c3d3dd;
    --text: #06283a; --text-dim: #3d5a6c; --text-faint: #4d6b7d;
    --accent: #7a5214; --accent-dim: #8a5d12; --accent-ink: #00304a;
    --blue: #004466; --red: #a53a33; --green: #2f7a4c; --amber: #8a5d12;
    --shadow-1: 0 1px 2px rgba(0, 40, 70, .08), 0 6px 18px -8px rgba(0, 40, 70, .18);
    --shadow-2: 0 24px 60px -20px rgba(0, 40, 70, .35);
    --overlay: rgba(6, 40, 58, .45);
    --painel: #fff; --input-bg: #fff; --thead-bg: #e3edf2; --pop-bg: #fff; --gold-line: #d9c9a3; --gold: #9a6a1c;
    --grad-bg: linear-gradient(160deg, #f6f9fb 0%, #e9f0f4 55%, #dae6ee 100%);
    --topbar-bg: rgba(255, 255, 255, .82);
    --scroll-thumb: rgba(122, 82, 20, .5); --scroll-track: rgba(0, 68, 102, .08);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #eaf1f5; --surface: #fff; --surface-2: #e3edf2; --line: #c3d3dd;
  --text: #06283a; --text-dim: #3d5a6c; --text-faint: #4d6b7d;
  --accent: #7a5214; --accent-dim: #8a5d12; --accent-ink: #00304a;
  --blue: #004466; --red: #a53a33; --green: #2f7a4c; --amber: #8a5d12;
  --shadow-1: 0 1px 2px rgba(0, 40, 70, .08), 0 6px 18px -8px rgba(0, 40, 70, .18);
  --shadow-2: 0 24px 60px -20px rgba(0, 40, 70, .35);
  --overlay: rgba(6, 40, 58, .45);
  --painel: #fff; --input-bg: #fff; --thead-bg: #e3edf2; --pop-bg: #fff; --gold-line: #d9c9a3; --gold: #9a6a1c;
  --grad-bg: linear-gradient(160deg, #f6f9fb 0%, #e9f0f4 55%, #dae6ee 100%);
  --topbar-bg: rgba(255, 255, 255, .82);
  --scroll-thumb: rgba(122, 82, 20, .5); --scroll-track: rgba(0, 68, 102, .08);
  color-scheme: light;
}
/* Menu lateral acompanha o tema. Escuro: fundo azul-petroleo e texto branco. Claro: fundo claro e texto escuro. */
.sidebar { --text: #ffffff; --text-dim: rgba(255, 255, 255, .78); --text-faint: #8fd0ee; --accent: #f8dd9a; color: var(--text); }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .sidebar {
    --sidebar-bg: linear-gradient(180deg, #f6fafc, #e5eef4); --gold-line: rgba(122, 82, 20, .28);
    --surface: #f6fafc; --surface-2: rgba(0, 68, 102, .08); --line: rgba(0, 68, 102, .16);
    --text: #06283a; --text-dim: #2f4f61; --text-faint: #3f6378; --accent: #7a5214; color: var(--text);
  }
}
:root[data-theme="light"] .sidebar {
  --sidebar-bg: linear-gradient(180deg, #f6fafc, #e5eef4); --gold-line: rgba(122, 82, 20, .28);
  --surface: #f6fafc; --surface-2: rgba(0, 68, 102, .08); --line: rgba(0, 68, 102, .16);
  --text: #06283a; --text-dim: #2f4f61; --text-faint: #3f6378; --accent: #7a5214; color: var(--text);
}
/* Claro: hover e item ativo do menu em tons claros (o topo do menu acompanha o tema, com logo escuro). */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .sidebar .nav a:hover { background: rgba(0, 68, 102, .1); }
  :root:not([data-theme="dark"]) .sidebar .nav a[aria-current="page"] { background: linear-gradient(90deg, rgba(122, 82, 20, .16), rgba(122, 82, 20, .03)); }
}
:root[data-theme="light"] .sidebar .nav a:hover { background: rgba(0, 68, 102, .1); }
:root[data-theme="light"] .sidebar .nav a[aria-current="page"] { background: linear-gradient(90deg, rgba(122, 82, 20, .16), rgba(122, 82, 20, .03)); }
/* Logo: versao dourada no escuro, versao azul-petroleo no claro (troca junto com o tema). */
.logo-claro-tema { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .logo-escuro-tema { display: none; }
  :root:not([data-theme="dark"]) .logo-claro-tema { display: block; }
}
:root[data-theme="light"] .logo-escuro-tema { display: none; }
:root[data-theme="light"] .logo-claro-tema { display: block; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .sidebar .sb-toggle { background: rgba(0, 68, 102, .08); border-color: rgba(122, 82, 20, .35); } }
:root[data-theme="light"] .sidebar .sb-toggle { background: rgba(0, 68, 102, .08); border-color: rgba(122, 82, 20, .35); }
.sidebar .nav-group { color: var(--text-dim); }
.sidebar .nav a > svg { color: var(--text-dim); }
.sidebar .nav a:hover > svg { color: var(--accent); }

/* ---- Base ---- */
body { background: var(--grad-bg) fixed; font-size: 14px; }
h1, h2, h3, h4 { font-family: var(--font-title); }
h1 { font-size: 28px; font-weight: 700; letter-spacing: .01em; line-height: 1.1; }
h2 { font-size: 22px; font-weight: 600; letter-spacing: .02em; }
h3 { font-size: 17px; font-weight: 600; letter-spacing: .02em; }
.eyebrow { font: 600 10px/1 var(--font-title); letter-spacing: .24em; color: var(--text-faint); }
.page-head .eyebrow { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) var(--scroll-track); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--scroll-track); }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border: 2px solid var(--scroll-track); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }

/* ---- Menu lateral ---- */
.sidebar { background: var(--sidebar-bg); border-right: 1px solid var(--gold-line); }
.sidebar::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--grad-gold); opacity: .9; }
.brand { border-bottom: 1px solid var(--line); height: var(--topbar-h); }
.brand-mark { border-radius: 9px; background: var(--grad-gold); color: #00304a; font: 700 17px var(--font-title); }
.brand-name { font: 700 18px var(--font-title); letter-spacing: .06em; }
.nav { scrollbar-width: thin; }
.nav-group { margin: 16px 10px 6px; }
.nav a { position: relative; min-height: 38px; border-left: 0; border-radius: 10px; font-weight: 500; transition: background .2s, color .2s; }
.nav a:hover { background: rgba(0, 68, 102, .4); color: var(--text); }
.nav a[aria-current="page"] { background: linear-gradient(90deg, rgba(196, 164, 102, .18), rgba(196, 164, 102, .02)); color: var(--accent); }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--grad-gold); box-shadow: 0 0 10px var(--gold); }

/* ---- Topo ---- */
.topbar { background: var(--topbar-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.avatar { background: var(--grad-gold); color: #00304a; border: 0; border-radius: 9px; font-family: var(--font-title); font-weight: 700; }
.content { max-width: 1400px; animation: tema-entra .35s var(--ease); }
@keyframes tema-entra { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- Auth ---- */
.auth { background: radial-gradient(900px 500px at 15% 0%, color-mix(in srgb, var(--gold) 20%, transparent), transparent 60%),
  radial-gradient(800px 500px at 100% 100%, color-mix(in srgb, var(--blue) 24%, transparent), transparent 60%), var(--grad-bg); }
.auth-card { background: var(--surface); border-color: var(--gold-line); position: relative; overflow: hidden; }
.auth-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--grad-gold); }

/* ---- Cartões e KPIs ---- */
.card { background: var(--painel); border-color: var(--line); border-radius: var(--r3); }
.card-head { padding: 16px 18px; }
.card-head h2, .card-head h3 { font: 600 15px/1.2 var(--font-title); letter-spacing: .02em; }
.stat .label { font: 600 11px/1 var(--font-title); letter-spacing: .2em; color: var(--text-faint); }
.stat .value { font: 700 34px/1 var(--font-title); font-variant-numeric: tabular-nums; }
.stat .value.mono { font-family: var(--font-title); font-size: 26px; }
.placeholder-bar, .state .spinner + * { border-radius: 6px; }
.placeholder-bar { background: linear-gradient(90deg, rgba(82, 177, 224, .08), rgba(196, 164, 102, .16), rgba(82, 177, 224, .08)); background-size: 200% 100%; animation: tema-skel 1.6s ease-in-out infinite; }
@keyframes tema-skel { to { background-position: -200% 0; } }

/* ---- Botões ---- */
.btn { min-height: 38px; padding: 0 14px; border-radius: 10px; font: 600 13px var(--font-body); background: color-mix(in srgb, var(--surface) 70%, transparent); border-color: var(--gold-line); transition: transform .15s, box-shadow .2s, background .2s, border-color .2s, color .2s; }
.btn:hover:not(:disabled) { filter: none; border-color: var(--gold); color: var(--accent); }
.btn.primary { background: var(--grad-gold); color: #00304a; border-color: transparent; box-shadow: 0 8px 22px -12px rgba(196, 164, 102, .8); }
.btn.primary:hover:not(:disabled) { color: #00304a; transform: translateY(-1px); box-shadow: 0 12px 26px -10px rgba(196, 164, 102, .9); border-color: transparent; }
.btn.danger { background: color-mix(in srgb, var(--red) 14%, transparent); border-color: color-mix(in srgb, var(--red) 45%, transparent); color: var(--red); }
.btn.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--red) 22%, transparent); color: var(--red); border-color: var(--red); }
.btn.ghost { background: none; border-color: transparent; color: var(--text-dim); }
.btn.ghost:hover:not(:disabled) { background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--text); border-color: transparent; }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.icon { padding: 0 9px; }

/* ---- Formulários ---- */
.field > .lbl { font-weight: 600; font-size: 13px; color: var(--text-dim); }
.input, .select, .textarea { background: var(--input-bg); border-color: var(--line); border-radius: 10px; min-height: 38px; font: 14px var(--font-body); }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); opacity: .75; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.lbl.check input { accent-color: var(--gold); }

/* ---- Avisos e badges ---- */
.notice, .error-note { border-radius: 12px; }
.notice { background: linear-gradient(90deg, color-mix(in srgb, var(--blue) 12%, transparent), color-mix(in srgb, var(--blue) 3%, transparent)); border-color: color-mix(in srgb, var(--blue) 35%, transparent); }
.error-note { background: linear-gradient(90deg, color-mix(in srgb, var(--red) 12%, transparent), color-mix(in srgb, var(--red) 3%, transparent)); border-color: color-mix(in srgb, var(--red) 40%, transparent); }
.badge { height: 22px; padding: 0 9px; font: 600 12px/1 var(--font-body); text-transform: none; letter-spacing: 0; border-color: color-mix(in srgb, currentColor 30%, transparent); background: color-mix(in srgb, currentColor 10%, transparent); white-space: nowrap; }
.badge.neutral { color: var(--text-dim); }

/* ---- Tabelas ---- */
.table-tools { border-bottom-color: var(--line); }
.data th { font: 600 11px/1 var(--font-title); letter-spacing: .14em; color: var(--text-faint); background: var(--thead-bg); padding: 13px 16px; }
.data td { padding: 12px 16px; border-bottom-color: var(--line); }
.data tbody tr { transition: background .15s; }
.data tbody tr:hover { background: color-mix(in srgb, var(--blue) 10%, transparent); }
.data .num { font-family: var(--font-body); font-variant-numeric: tabular-nums; }
.data tfoot th { background: var(--thead-bg); }
.table-foot { border-top: 1px solid var(--line); color: var(--text-faint); }
.state { color: var(--text-dim); }

/* ---- Modal, toast, ajuda ---- */
.modal-back { backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal { background: var(--pop-bg); border-color: var(--gold-line); border-radius: 14px; }
.modal-head h2, .modal-head h3 { font-family: var(--font-title); }
.toast { background: var(--pop-bg); border-color: var(--line); border-radius: 12px; }
.help-btn { border-color: var(--gold); color: var(--accent); }
.help-btn:hover, .help-btn[aria-expanded="true"] { background: var(--grad-gold); color: #00304a; border-color: transparent; }
.help-pop { background: var(--pop-bg); border-color: var(--gold-line); }
.help-pop h4 { font: 600 16px var(--font-title); }
.help-pop dt { font: 600 10px var(--font-title); letter-spacing: .18em; color: var(--accent); }

/* ---- Abas, listas, barras ---- */
.tabs a { font-weight: 600; }
.tabs a[aria-current="page"] { color: var(--accent); border-bottom: 0; position: relative; }
.tabs a[aria-current="page"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 2px; border-radius: 2px; background: var(--grad-gold); }
.kv dt { font: 600 11px/1 var(--font-title); letter-spacing: .14em; color: var(--text-faint); }
.bar-row .track { background: color-mix(in srgb, var(--bg) 70%, transparent); border-radius: 99px; }
.bar-row .fill { border-radius: 99px; }
.quote-total { font: 700 24px var(--font-title); font-variant-numeric: tabular-nums; }
pre.doc, .secret-box { background: var(--input-bg); }
.secret-box { border-color: var(--gold); }

@media (max-width: 860px) {
  .content { padding: var(--s4); }
  .sidebar::before { display: none; }
}
@media (max-width: 700px) {
  table.data tr { background: var(--painel); border-color: var(--line); }
  table.data td::before { font-family: var(--font-title); letter-spacing: .12em; }
}
@media (prefers-reduced-motion: reduce) { .content, .placeholder-bar { animation: none !important; } .btn.primary:hover:not(:disabled) { transform: none; } }

/* ================= Layout do shell (reproduz o admin do cntoficial) ================= */
.shell { transition: grid-template-columns .35s var(--ease-shell); }
.sidebar { min-width: 0; overflow: hidden; }
.brand { justify-content: space-between; padding: 0 14px 0 18px; gap: 8px; }
.brand-link { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; color: var(--text); }
.brand-logo { width: 80px; height: 29px; flex: none; }
.brand-icon { display: none; width: 28px; height: 28px; flex: none; }
.brand-sub { font: 600 10px/1 var(--font-title); letter-spacing: .22em; text-transform: uppercase; color: var(--accent); white-space: nowrap; }
.brand-auth { flex-direction: column; justify-content: center; gap: 8px; padding: 0 0 var(--s5); height: auto; border: 0; }
.brand-logo-auth { width: 160px; height: auto; }
.sb-toggle { width: 30px; height: 30px; display: grid; place-items: center; flex: none; border-radius: 8px; border: 1px solid var(--gold-line); background: rgba(0, 54, 79, .5); color: var(--accent); cursor: pointer; transition: transform .35s var(--ease-shell), border-color .2s; }
.sb-toggle:hover { border-color: var(--gold); }
.nav a { gap: 12px; white-space: nowrap; }
.nav a > svg { color: var(--text-faint); transition: color .2s; }
.nav a:hover > svg { color: var(--gold); }
.nav a[aria-current="page"] > svg { color: var(--accent); }
.nav-label { overflow: hidden; text-overflow: ellipsis; }
.topbar { gap: 16px; padding: 0 28px; }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold) 20%, var(--gold) 80%, transparent); opacity: .45; pointer-events: none; }
.topbar .btn svg, .topbar .menu-btn svg { flex: none; }
.content { padding: 28px 32px 40px; }
.btn > svg { flex: none; }
.error-note, .notice { display: flex; gap: 10px; align-items: flex-start; }
.error-note > svg { margin-top: 2px; flex: none; }
.state-ic { width: 56px; height: 56px; margin: 0 auto var(--s3); border-radius: 16px; display: grid; place-items: center; background: color-mix(in srgb, var(--blue) 12%, transparent); border: 1px solid var(--gold-line); color: var(--gold); }

/* Recolhido (só desktop): 252px -> 72px, ícones com title/tooltip nativo */
@media (min-width: 861px) {
  .shell[data-recolhida="true"] { --sidebar-w: 72px; }
  .shell[data-recolhida="true"] .brand { flex-direction: column; justify-content: center; gap: 6px; padding: 0; height: 84px; }
  .shell[data-recolhida="true"] .brand-logo, .shell[data-recolhida="true"] .brand-sub { display: none; }
  .shell[data-recolhida="true"] .brand-icon { display: block; }
  .shell[data-recolhida="true"] .sb-toggle { transform: rotate(180deg); width: 26px; height: 22px; }
  .shell[data-recolhida="true"] .nav { padding-inline: 10px; }
  .shell[data-recolhida="true"] .nav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .shell[data-recolhida="true"] .nav-group { height: 1px; margin: 10px 8px; padding: 0; overflow: hidden; font-size: 0; background: var(--line); }
  .shell[data-recolhida="true"] .nav a { justify-content: center; padding: 0; }
  .shell[data-recolhida="true"] .nav a[aria-current="page"]::before { left: -10px; }
}
/* Mobile: gaveta (comportamento anterior); o botão de recolher não se aplica */
@media (max-width: 860px) {
  .sb-toggle { display: none; }
  .sidebar { transition: transform .35s var(--ease-shell); }
  .topbar { padding: 0 var(--s4); gap: var(--s2); }
  .theme-label { display: none; }
  .content { padding: var(--s4); }
}
/* Claro: o logo é dourado; no cartão branco do login ganha fundo azul escuro */
@media (prefers-reduced-motion: reduce) { .shell, .sidebar, .sb-toggle { transition: none !important; } }

/* Cabecalho e celulas numericas alinhados a direita (a regra .data th {text-align:left} vencia .right pela especificidade). */
.data th.right, .data td.right, .data th.num, .data tfoot th.right { text-align: right; }
