/* Identidade ASF Advogados (preto + dourado) com tipografia técnica Geist / Geist Mono.
 * Espaçamentos e proporções seguem a razão áurea: 5 · 8 · 13 · 21 · 34 · 55 · 89 e colunas 1,618 : 1. */
:root {
  --bg: #f3f3f2;
  --surface: #ffffff;
  --surface-2: #fafaf9;
  --surface-3: #ececea;
  --line: #e4e4e1;
  --line-strong: #d2d2ce;
  --ink: #0b0b0c;
  --ink-2: #3c3d42;
  --ink-3: #75767b;
  --gold: #d4a853;
  --gold-light: #f5ce72;
  --gold-deep: #a88040;
  --gold-metal: linear-gradient(135deg, #f5ce72 0%, #d4a853 48%, #a88040 100%);
  --brand: #d4a853;
  --brand-hover: #c59a45;
  --brand-ink: #0b0b0c;
  --brand-soft: rgba(212, 168, 83, 0.14);
  --pos: #2f6b4f;
  --pos-soft: #e4efe8;
  --neg: #a63d2c;
  --neg-soft: #f6e6e2;
  --warn: #8f5e0e;
  --warn-soft: #f6eddb;
  --chart-in: #c9a04c;
  --chart-out: #cfcfcb;
  --chart-line: #a88040;
  --focus: 0 0 0 3px rgba(212, 168, 83, 0.35);
  --shadow-pop: 0 12px 32px -8px rgba(11, 11, 12, 0.2), 0 2px 6px rgba(11, 11, 12, 0.06);
  --shadow-drawer: -16px 0 40px -12px rgba(11, 11, 12, 0.22);
  --scrim: rgba(11, 11, 12, 0.36);

  /* Barra lateral: sempre escura, como o site da ASF */
  --side-bg: #0b0b0c;
  --side-ink: rgba(255, 255, 255, 0.86);
  --side-ink-2: rgba(255, 255, 255, 0.58);
  --side-ink-3: rgba(255, 255, 255, 0.38);
  --side-line: rgba(255, 255, 255, 0.09);
  --side-hover: rgba(255, 255, 255, 0.05);
  --side-active: rgba(212, 168, 83, 0.1);

  --font-ui: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Geist', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;

  /* Escala áurea (Fibonacci) */
  --s1: 5px; --s2: 8px; --s3: 13px; --s4: 21px; --s5: 34px; --s6: 55px; --s7: 89px;
  /* Tipografia em passos de √φ ≈ 1,272 */
  --t-xs: 11px; --t-sm: 12.5px; --t-base: 14px; --t-md: 17px; --t-lg: 22px; --t-xl: 28px; --t-2xl: 36px; --t-3xl: 46px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --shadow-card: 0 1px 2px rgba(11, 11, 12, 0.04), 0 8px 21px -13px rgba(11, 11, 12, 0.14);
  --shadow-card-hover: 0 2px 5px rgba(11, 11, 12, 0.05), 0 21px 34px -21px rgba(11, 11, 12, 0.24);

  --r-sm: 5px;
  --r: 8px;
  --r-lg: 13px;
  --sidebar: 233px;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #070707;
  --surface: #111112;
  --surface-2: #151517;
  --surface-3: #1c1c1e;
  --line: #232326;
  --line-strong: #313134;
  --ink: #efeeea;
  --ink-2: #b8b7b2;
  --ink-3: #85858a;
  --brand: #d4a853;
  --brand-hover: #f0c76a;
  --brand-ink: #0b0b0c;
  --brand-soft: rgba(212, 168, 83, 0.12);
  --pos: #7cc39c;
  --pos-soft: rgba(124, 195, 156, 0.12);
  --neg: #e8907d;
  --neg-soft: rgba(232, 144, 125, 0.12);
  --warn: #e2b064;
  --warn-soft: rgba(226, 176, 100, 0.12);
  --chart-in: #d4a853;
  --chart-out: #3a3a3d;
  --chart-line: #f5ce72;
  --focus: 0 0 0 3px rgba(212, 168, 83, 0.35);
  --shadow-pop: 0 16px 40px -8px rgba(0, 0, 0, 0.7), 0 0 0 1px var(--line);
  --shadow-drawer: -16px 0 48px -12px rgba(0, 0, 0, 0.7);
  --scrim: rgba(0, 0, 0, 0.6);
  --side-bg: #0b0b0c;
  --side-line: rgba(255, 255, 255, 0.07);
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.02) inset, 0 8px 21px -13px rgba(0, 0, 0, 0.6);
  --shadow-card-hover: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 21px 34px -21px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--font-ui);
  font-feature-settings: 'kern', 'ss01';
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
svg { display: block; flex-shrink: 0; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
::selection { background: var(--brand-soft); }

.num { font-family: var(--font-mono); font-size: 0.93em; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }
.muted { color: var(--ink-3); }
.ink-2 { color: var(--ink-2); }
.serif { font-family: var(--font-display); }
.only-sm { display: none; }
@media (max-width: 860px) { .only-sm { display: inline; } .hide-sm { display: none; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Estrutura ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 22px 12px 16px;
  background: var(--side-bg); color: var(--side-ink);
  border-right: 1px solid var(--side-line);
}
.brand { padding: 2px 10px 18px; margin-bottom: 14px; border-bottom: 1px solid var(--side-line); }
.brand img { display: block; width: 100%; max-width: 196px; height: auto; }
.brand-sub { font: 500 10px/1 var(--font-mono); letter-spacing: 0.2em; text-transform: uppercase; color: var(--side-ink-3); margin-top: var(--s3); }

.search-trigger {
  display: flex; align-items: center; gap: 8px; width: 100%;
  height: 34px; padding: 0 10px; margin-bottom: 18px;
  border: 1px solid var(--side-line); border-radius: var(--r);
  background: rgba(255, 255, 255, 0.03); color: var(--side-ink-3); font-size: 13px; text-align: left; white-space: nowrap;
}
.search-trigger:hover { border-color: rgba(212, 168, 83, 0.4); color: var(--side-ink-2); }
.search-trigger kbd { margin-left: auto; background: transparent; border-color: var(--side-line); color: var(--side-ink-3); }

.nav-group { margin-bottom: 18px; }
.nav-label { font: 500 10px/1 var(--font-mono); color: var(--side-ink-3); padding: 0 10px var(--s2); letter-spacing: 0.14em; text-transform: uppercase; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 10px;
  height: 34px; padding: 0 10px; border-radius: var(--r);
  color: var(--side-ink-2); text-decoration: none; font-size: 13.5px;
  transition: background-color .18s var(--ease), color .18s var(--ease);
}
.nav-item svg { transition: transform .25s var(--ease-spring), color .18s; }
.nav-item:hover svg { transform: translateX(2px); }
.nav-item svg { color: var(--side-ink-3); }
.nav-item:hover { background: var(--side-hover); color: var(--side-ink); }
.nav-item.active { background: var(--side-active); color: #fff; }
.nav-item.active::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 2px; border-radius: 0 2px 2px 0; background: var(--gold-metal); }
.nav-item.active svg { color: var(--gold); }
.nav-count { margin-left: auto; font-size: 12px; color: #f0a08f; font-variant-numeric: tabular-nums; }
.sidebar :focus-visible { box-shadow: 0 0 0 2px rgba(212, 168, 83, 0.6); }

.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--side-line); display: grid; gap: 2px; }
.backup-hint { font-size: 12px; color: var(--side-ink-3); padding: 6px 10px 0; line-height: 1.4; }
.backup-hint.stale { color: #e2b064; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px 4px; font-size: 13px; color: var(--side-ink-2); min-width: 0; }
.user-chip .av { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: rgba(212, 168, 83, 0.14); color: var(--gold-light); font-size: 12px; font-weight: 500; }
.user-chip .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .nm small { display: block; font-size: 11.5px; color: var(--side-ink-3); }

.main { min-width: 0; }
.page { max-width: 1320px; margin: 0 auto; padding: var(--s5) var(--s6) var(--s7); }
.page:focus, .page:focus-visible { outline: none; box-shadow: none; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4);
  margin-bottom: var(--s5); padding-bottom: var(--s4); border-bottom: 1px solid var(--line);
}
.eyebrow { display: flex; align-items: center; gap: var(--s2); font: 500 var(--t-xs)/1 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold-deep); margin-bottom: var(--s3); }
.eyebrow::before { content: ''; width: 13px; height: 1px; background: var(--gold-metal); }
.page-title { font: 600 var(--t-2xl)/1.05 var(--font-display); letter-spacing: -0.035em; }
.page-sub { color: var(--ink-3); font-size: var(--t-base); margin-top: var(--s2); }
.page-actions { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }

.section { margin-top: var(--s5); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.section-title { font-size: var(--t-md); font-weight: 600; letter-spacing: -0.02em; }
.section-note { font-size: var(--t-sm); color: var(--ink-3); }

/* Grades áureas: 1,618 : 1 */
.grid-2, .golden { display: grid; grid-template-columns: minmax(0, 1.618fr) minmax(0, 1fr); gap: var(--s4); align-items: start; }
.golden-rev { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.618fr); gap: var(--s4); align-items: start; }
.stack { display: grid; gap: var(--s4); align-content: start; }

/* Barra inferior (mobile) */
.tabbar { display: none; }

@media (max-width: 1080px) {
  .grid-2, .golden, .golden-rev { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .page { padding: var(--s4) var(--s3) 96px; }
  .page-head { flex-direction: column; align-items: stretch; margin-bottom: 20px; }
  .page-title { font-size: var(--t-xl); }
  .page-actions .btn { flex: 1; justify-content: center; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; inset: auto 0 0 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 0; font-size: 11px; color: var(--ink-3); text-decoration: none;
    background: none; border: 0;
  }
  .tab.active { color: var(--brand); }
}
