/* =========================================================================
   SigmaOne Intelligence — sistema de design
   Marinho institucional, superfícies brancas, cor só onde ela significa
   alguma coisa: variação, alerta, ação.
   ========================================================================= */

:root {
  --navy-950: #060f1c;
  --navy-900: #0b1f2e;
  --navy-800: #12314a;
  --navy-700: #1a4266;

  --brand-50: #eef4ff;
  --brand-100: #dbe6fe;
  --brand-500: #2f6fe0;
  --brand-600: #1d5fd0;
  --brand-700: #1749a3;

  --positive-50: #e8f7f1;
  --positive-600: #0e9f6e;
  --positive-700: #077a53;
  --warning-50: #fdf5e6;
  --warning-600: #c77700;
  --critical-50: #fdeceb;
  --critical-600: #d33b32;

  --surface: #ffffff;
  --surface-muted: #f5f7fa;
  --surface-sunken: #eef1f6;
  --border: #e3e8ef;
  --text-strong: #0b1f2e;
  --text-body: #384456;
  --text-muted: #6b7887;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(11, 31, 46, .04), 0 1px 3px rgba(11, 31, 46, .03);

  --font-display: "Manrope", ui-sans-serif, system-ui, sans-serif;
  --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
}

html[data-theme="dark"] {
  --surface: #101826;
  --surface-muted: #0a111c;
  --surface-sunken: #16202f;
  --border: #26334a;
  --text-strong: #f1f5fb;
  --text-body: #c3cddc;
  --text-muted: #8593a6;
  --positive-50: rgba(14, 159, 110, .14);
  --positive-700: #34d399;
  --warning-50: rgba(199, 119, 0, .16);
  --warning-600: #f0b429;
  --critical-50: rgba(211, 59, 50, .16);
  --critical-600: #f87171;
  --brand-50: rgba(29, 95, 208, .16);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background: var(--surface-muted);
  color: var(--text-body);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--text-strong);
  letter-spacing: -.015em;
  line-height: 1.25;
}

a { color: var(--brand-600); }

/* Números alinham na vertical. Não é firula: comparar 6.053,01 com 4.904,47
   de relance depende disso. */
.tabular { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

:focus-visible {
  outline: 2px solid var(--brand-600);
  outline-offset: 2px;
  border-radius: 3px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -9999px; top: 8px; z-index: 100;
  background: var(--brand-600); color: #fff; padding: 8px 12px;
  border-radius: 8px; font-weight: 600;
}
.skip-link:focus { left: 8px; }

/* ---------- estrutura ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px; flex-shrink: 0; background: var(--navy-900);
  color: #cbd5e1; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  height: 64px; padding: 0 16px; flex-shrink: 0;
}
.sidebar__mark {
  width: 32px; height: 32px; border-radius: 9px; background: var(--brand-600);
  display: grid; place-items: center; flex-shrink: 0;
  color: #fff; font-weight: 800; font-size: 13px; font-family: var(--font-display);
}
.sidebar__name {
  font-family: var(--font-display); font-weight: 800; font-size: 13px;
  color: #fff; letter-spacing: -.02em; white-space: nowrap;
}
.sidebar__name span { font-weight: 500; color: #94a3b8; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 8px; }
.nav-group__label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: #64748b; padding: 10px 12px 6px;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 9px; color: inherit;
  text-decoration: none; font-size: 13.5px; white-space: nowrap;
  border: 0; background: none; width: 100%; cursor: pointer;
  font-family: inherit; text-align: left;
}
.nav-link:hover { background: var(--navy-800); color: #fff; }
.nav-link[aria-current="page"] { background: var(--brand-600); color: #fff; font-weight: 600; }
.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar__footer { padding: 8px; flex-shrink: 0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.header {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.header__titles { flex: 1; min-width: 140px; }
.breadcrumb { font-size: 11.5px; color: var(--text-muted); display: flex; gap: 5px; align-items: center; }
.header__title { font-size: 17px; font-weight: 700; }
.header__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.content { flex: 1; padding: 20px; }

/* ---------- controles ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 9px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-body); cursor: pointer; font-family: inherit;
  text-decoration: none;
}
.btn:hover { background: var(--surface-sunken); }
.btn svg { width: 15px; height: 15px; }
.btn--primary { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn--primary:hover { background: var(--brand-700); }
.btn--icon { padding: 8px; }
.btn--ghost { border-color: transparent; background: none; }
.btn--ghost:hover { background: var(--surface-sunken); }

.select {
  padding: 8px 10px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-body); font-size: 13px;
  font-family: inherit; font-weight: 500; cursor: pointer; max-width: 190px;
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field__label { font-size: 12px; font-weight: 600; color: var(--text-strong); }
textarea, input[type="text"] {
  width: 100%; padding: 9px 11px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-body); font-family: inherit; font-size: 13.5px;
  resize: vertical;
}

/* ---------- cards ---------- */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card__pad { padding: 18px; }
.card__head { padding: 16px 18px 0; }
.card__title { font-size: 13.5px; font-weight: 700; }
.card__sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

.grid { display: grid; gap: 14px; }
.grid--kpi { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.section { margin-bottom: 22px; }
.section__title { font-size: 15px; font-weight: 700; margin-bottom: 10px; }

/* ---------- KPI ---------- */

.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 9px; }
.kpi__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.kpi__label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-muted);
  display: flex; align-items: center; gap: 5px;
}
.kpi__info { cursor: help; color: var(--text-muted); display: inline-flex; }
.kpi__info svg { width: 13px; height: 13px; }
.kpi__mid { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.kpi__value { font-size: 23px; font-weight: 800; color: var(--text-strong); font-family: var(--font-display); }
.kpi__prev { font-size: 11.5px; color: var(--text-muted); }
.kpi__prev b { color: var(--text-body); font-weight: 600; }
.kpi__note { font-size: 11px; color: var(--text-muted); font-style: italic; }
.kpi__spark { width: 92px; height: 30px; flex-shrink: 0; }

/* ---------- variação ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 6px; border-radius: 6px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.badge svg { width: 13px; height: 13px; }
.badge--good { background: var(--positive-50); color: var(--positive-700); }
.badge--bad { background: var(--critical-50); color: var(--critical-600); }
.badge--warning { background: var(--warning-50); color: var(--warning-600); }
.badge--neutral { background: var(--surface-sunken); color: var(--text-muted); }

/* ---------- tabelas ---------- */

.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 520px; }
thead tr { background: var(--surface-sunken); }
th {
  text-align: left; padding: 9px 14px; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 9px 14px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.strong { color: var(--text-strong); font-weight: 600; }

/* ---------- gráficos ---------- */

.chart-box { padding: 14px 18px 18px; height: 250px; position: relative; }

/* ---------- avisos ---------- */

.notice {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 16px;
}
.notice svg { width: 16px; height: 16px; flex-shrink: 0; }
.notice--demo {
  background: var(--warning-50); color: var(--warning-600);
  border: 1px solid color-mix(in srgb, var(--warning-600) 30%, transparent);
}
.notice--error {
  background: var(--critical-50); color: var(--critical-600);
  border: 1px solid color-mix(in srgb, var(--critical-600) 30%, transparent);
}
.notice--ok {
  background: var(--positive-50); color: var(--positive-700);
  border: 1px solid color-mix(in srgb, var(--positive-600) 30%, transparent);
}
.notice b { font-weight: 700; }
.notice__spacer { margin-left: auto; }

.empty {
  padding: 44px 20px; text-align: center; color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.empty svg { width: 28px; height: 28px; }
.empty h3 { font-size: 15px; }
.empty p { font-size: 13px; max-width: 380px; }

/* ---------- importação ---------- */

.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 36px 20px; text-align: center; background: var(--surface);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone--over { border-color: var(--brand-600); background: var(--brand-50); }
.dropzone svg { width: 30px; height: 30px; color: var(--brand-600); }
.dropzone h3 { font-size: 15px; margin: 8px 0 3px; }
.dropzone p { font-size: 12.5px; color: var(--text-muted); }

.meta-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.meta-item__label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-muted);
}
.meta-item__value { font-size: 13.5px; color: var(--text-strong); font-weight: 600; margin-top: 2px; }

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  background: var(--surface-sunken); color: var(--text-body); margin: 2px 3px 2px 0;
}
.pill--ok { background: var(--positive-50); color: var(--positive-700); }
.pill--warn { background: var(--warning-50); color: var(--warning-600); }
.pill--bad { background: var(--critical-50); color: var(--critical-600); }

/* ---------- consistência ---------- */

.check-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 13px;
}
.check-row:last-child { border-bottom: 0; }
.check-row svg { width: 15px; height: 15px; flex-shrink: 0; }
.check-row__note { font-size: 11.5px; color: var(--text-muted); }
.check-row__result { margin-left: auto; font-size: 11.5px; font-weight: 600; }

/* ---------- abas internas ---------- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab {
  padding: 8px 14px; border: 0; background: none; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 600; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab[aria-selected="true"] { color: var(--brand-600); border-bottom-color: var(--brand-600); }

/* ---------- melhor post ---------- */

.best-post {
  padding: 18px; display: flex; flex-direction: column; gap: 8px;
  border-left: 3px solid var(--brand-600);
}
.best-post__eyebrow {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--brand-600);
}
.best-post__title { font-size: 14.5px; font-weight: 700; color: var(--text-strong); }
.best-post__meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); }
.best-post__meta b { display: block; color: var(--text-strong); font-size: 15px; font-weight: 700; }

/* ---------- mobile ---------- */

.mobile-toggle { display: none; }
.backdrop {
  position: fixed; inset: 0; background: rgba(6, 15, 28, .55); z-index: 40;
}

@media (max-width: 1023px) {
  .sidebar {
    position: fixed; z-index: 50; transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .sidebar--open { transform: translateX(0); }
  .mobile-toggle { display: inline-flex; }
  .content { padding: 14px; }
  .header { padding: 10px 14px; }
  .kpi__spark { display: none; }
  .grid--kpi { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- impressão ---------- */

@media print {
  @page { margin: 14mm; }
  .no-print, .sidebar, .header__actions, .backdrop { display: none !important; }
  body { background: #fff; font-size: 11px; }
  .shell { display: block; }
  .header { position: static; border: 0; padding: 0 0 10px; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #d5dbe4; break-inside: avoid; }
  .section { break-inside: avoid; }
  .print-break { break-before: page; }
  .chart-box { height: 190px; }
  .print-only { display: block !important; }
  .grid--kpi { grid-template-columns: repeat(3, 1fr); }
  .table-wrap { overflow: visible; }
  table { min-width: 0; }
}
.print-only { display: none; }
