/* ============================================================
   BOLZONARO ADVOCACIA — Sistema Jurisprudencial
   Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700;900&family=Cormorant+Garamond:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

/* ---------- Tokens ---------- */
:root {
  /* Cores — base navy */
  --navy-900: #0a1929;
  --navy-800: #0e2238;
  --navy-700: #143049;
  --navy-600: #1d4060;
  --navy-500: #2a557d;

  /* Dourado / brass */
  --gold-600: #b8923a;
  --gold-500: #c9a24b;
  --gold-400: #dab863;
  --gold-300: #e8d29a;

  /* Neutros */
  --parchment: #f6f3ec;
  --paper: #ffffff;
  --ink-900: #16202b;
  --ink-700: #2d3a48;
  --ink-500: #5e6b7a;
  --ink-400: #8693a1;
  --line: #e3ddd0;
  --line-soft: #efeadf;

  /* Estados */
  --green: #2e7d52;
  --green-soft: #e6f3ec;
  --red: #c0392b;
  --red-soft: #fbeae8;
  --amber: #b9821f;
  --amber-soft: #fcf3e2;

  /* Tipografia */
  --font-serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Espaçamento */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;

  /* Raio */
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-xl: 24px; --r-full: 999px;

  /* Sombras */
  --sh-sm: 0 1px 2px rgba(16,34,56,.06), 0 1px 3px rgba(16,34,56,.08);
  --sh-md: 0 4px 12px rgba(16,34,56,.08), 0 2px 4px rgba(16,34,56,.06);
  --sh-lg: 0 12px 32px rgba(16,34,56,.12), 0 4px 8px rgba(16,34,56,.06);
  --sh-gold: 0 6px 20px rgba(184,146,58,.25);

  --ease: cubic-bezier(.22,.61,.36,1);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--parchment);
  color: var(--ink-900);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--gold-300); color: var(--navy-900); }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cdc6b6; border-radius: var(--r-full); border: 3px solid var(--parchment); }
::-webkit-scrollbar-thumb:hover { background: var(--gold-500); }

/* ============================================================
   WORDMARK / LOGO
   ============================================================ */
.wordmark { display: inline-flex; flex-direction: column; align-items: center; line-height: 1; }
.wordmark__name {
  font-family: 'Montserrat', var(--font-sans);
  font-weight: 900;
  letter-spacing: .04em;
  color: var(--paper);
  text-transform: uppercase;
}
.wordmark__rule { display: none; }
.wordmark__sub {
  font-family: 'Montserrat', var(--font-sans);
  font-weight: 600;
  letter-spacing: .28em;
  font-size: .78rem;
  color: var(--paper);
  white-space: nowrap;
  text-transform: uppercase;
}

/* Crest (logo placeholder em SVG; trocável por imagem) */
.crest { display: flex; justify-content: center; }
.crest__img { display: none; width: 76px; height: 76px; object-fit: contain; margin: 0 auto; }
.crest.has-img .crest__svg { display: none; }
.crest.has-img .crest__img { display: block; }

/* No splash, o escudo branco do leão aparece maior (já é claro — sem filtro) */
.splash .crest__img {
  width: 140px;
  height: 140px;
}

/* ============================================================
   SPLASH
   ============================================================ */
.splash {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: var(--navy-900);
  overflow: hidden;
  transition: opacity .6s var(--ease), visibility .6s;
}
.splash.hidden { opacity: 0; visibility: hidden; }

.splash__bg {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  filter: saturate(.7);
  opacity: .28;
  transform: scale(1.05);
  animation: slowZoom 18s ease-out forwards;
}
@keyframes slowZoom { to { transform: scale(1.14); } }

.splash__overlay {
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 90% at 50% 30%, rgba(20,48,73,.35), transparent 60%),
    linear-gradient(180deg, rgba(10,25,41,.85) 0%, rgba(10,25,41,.7) 45%, rgba(10,25,41,.95) 100%);
}

.splash__content {
  position: relative; z-index: 2;
  text-align: center;
  padding: var(--sp-6);
  max-width: 640px;
  animation: fadeUp 1s var(--ease) both;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

.splash .crest { margin: 0 auto var(--sp-6); }
.splash .crest__img {
  filter: drop-shadow(0 8px 24px rgba(0,0,0,.55)) drop-shadow(0 2px 6px rgba(0,0,0,.4));
}
.splash .wordmark__name { font-size: 2.7rem; }
.splash .wordmark__sub { font-size: .82rem; margin-top: var(--sp-3); }

.splash__tagline {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-style: italic;
  color: var(--gold-300);
  margin-top: var(--sp-5);
  font-weight: 500;
}

.splash__status {
  margin-top: var(--sp-6);
  display: flex; gap: var(--sp-4); justify-content: center; flex-wrap: wrap;
  min-height: 28px;
}
.splash__dot {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-size: .75rem; letter-spacing: .04em;
  color: rgba(255,255,255,.78);
}
.splash__dot i { width: 8px; height: 8px; border-radius: var(--r-full); background: var(--ink-400); }
.splash__dot.on i { background: var(--green); box-shadow: 0 0 0 3px rgba(46,125,82,.25); }
.splash__dot.off i { background: var(--red); box-shadow: 0 0 0 3px rgba(192,57,43,.25); }

.splash__alert {
  margin-top: var(--sp-5);
  display: none;
  align-items: center; gap: var(--sp-2);
  background: rgba(192,57,43,.16);
  border: 1px solid rgba(192,57,43,.4);
  color: #ffd3cc;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  font-size: .82rem;
}
.splash__alert.show { display: inline-flex; }

.splash__enter {
  margin-top: var(--sp-7);
  display: inline-flex; align-items: center; gap: var(--sp-3);
  background: linear-gradient(135deg, var(--gold-500), var(--gold-600));
  color: var(--navy-900);
  font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  font-size: .78rem;
  padding: 15px 38px;
  border-radius: var(--r-full);
  box-shadow: var(--sh-gold);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.splash__enter:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(184,146,58,.4); }
.splash__enter:active { transform: translateY(0); }

/* ============================================================
   APP SHELL
   ============================================================ */
.app { display: none; min-height: 100vh; flex-direction: column; }
.app.show { display: flex; animation: fadeIn .5s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--sp-5);
  padding: 0 var(--sp-6);
  height: 64px;
  background: var(--navy-800);
  border-bottom: 1px solid rgba(201,162,75,.22);
  box-shadow: var(--sh-md);
}
.topbar__brand { display: flex; align-items: center; gap: var(--sp-3); }
.topbar__brand .crest__svg, .topbar__brand .crest__img { width: 34px; height: 34px; }
.topbar__brand .crest__img { width: 34px; height: 34px; }
.topbar__name {
  font-family: 'Montserrat', var(--font-sans);
  font-weight: 900; letter-spacing: .08em; color: var(--paper); font-size: 1.05rem;
  text-transform: uppercase;
}
.topbar__name b { color: var(--gold-400); font-weight: 700; }

.nav { display: flex; gap: var(--sp-1); margin-left: var(--sp-5); }
.nav__item {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 8px 16px; border-radius: var(--r-full);
  color: rgba(255,255,255,.7);
  font-size: .86rem; font-weight: 500;
  transition: background .2s, color .2s;
}
.nav__item:hover { color: var(--paper); background: rgba(255,255,255,.06); }
.nav__item.active { color: var(--navy-900); background: var(--gold-500); }
.nav__item svg { width: 16px; height: 16px; }

.topbar__spacer { flex: 1; }
.topbar__mode {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: .72rem; color: rgba(255,255,255,.6);
  padding: 6px 12px; border-radius: var(--r-full);
  border: 1px solid rgba(255,255,255,.12);
  background: none; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.topbar__mode:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.85); }
.topbar__mode--local {
  background: rgba(var(--gold-rgb, 180,140,60),.15);
  border-color: var(--gold-400);
  color: var(--gold-400);
}
.topbar__mode i { width: 7px; height: 7px; border-radius: var(--r-full); background: var(--gold-400); }
.topbar__mode.semantica i { background: var(--green); }
.topbar__mode--local i { background: var(--gold-400); }

/* ---------- Views ---------- */
.main { flex: 1; }
.view { display: none; }
.view.active { display: block; animation: viewIn .4s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.container { max-width: 1120px; margin: 0 auto; padding: var(--sp-7) var(--sp-6); }

/* ---------- Section heading ---------- */
.section-head { margin-bottom: var(--sp-6); }
.section-head h1 {
  font-family: var(--font-serif); font-weight: 600;
  font-size: 2.2rem; color: var(--navy-800); line-height: 1.1;
}
.section-head p { color: var(--ink-500); margin-top: var(--sp-2); font-size: .96rem; }
.eyebrow {
  display: inline-block; font-size: .72rem; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase; color: var(--gold-600);
  margin-bottom: var(--sp-2);
}

/* ============================================================
   DASHBOARD
   ============================================================ */
.dash-hero {
  background: linear-gradient(135deg, var(--navy-800), var(--navy-700));
  border-radius: var(--r-lg);
  padding: var(--sp-7);
  color: var(--paper);
  position: relative; overflow: hidden;
  box-shadow: var(--sh-lg);
}
.dash-hero::after {
  content: ''; position: absolute; right: -60px; top: -60px;
  width: 280px; height: 280px; border-radius: 50%;
  background: radial-gradient(circle, rgba(201,162,75,.18), transparent 70%);
}
.dash-hero h2 { font-family: var(--font-sans); font-size: 2rem; font-weight: 600; }
.dash-hero p { color: rgba(255,255,255,.72); margin-top: var(--sp-2); max-width: 520px; }
.dash-hero__cta { margin-top: var(--sp-5); }

.grid { display: grid; gap: var(--sp-5); }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-top: var(--sp-6); }
.grid--tribunais { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-top: var(--sp-5); }

.stat-card {
  background: var(--paper); border-radius: var(--r-md);
  padding: var(--sp-5); border: 1px solid var(--line-soft);
  box-shadow: var(--sh-sm);
  position: relative; overflow: hidden;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.stat-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--gold-400), var(--gold-600));
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--sh-md); }
.stat-card__value { font-family: var(--font-serif); font-size: 2.6rem; font-weight: 700; color: var(--navy-800); line-height: 1; }
.stat-card__label { color: var(--ink-500); font-size: .82rem; font-weight: 500; margin-top: var(--sp-2); letter-spacing: .02em; }

/* Tribunal status card */
.trib-card {
  background: var(--paper); border-radius: var(--r-md);
  padding: var(--sp-5); border: 1px solid var(--line-soft);
  box-shadow: var(--sh-sm);
  display: flex; align-items: center; gap: var(--sp-4);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.trib-card:hover { transform: translateY(-2px); box-shadow: var(--sh-md); }
.trib-card__badge {
  width: 46px; height: 46px; border-radius: var(--r-md);
  display: grid; place-items: center; flex-shrink: 0;
  font-weight: 700; font-size: .82rem; color: var(--paper);
  letter-spacing: .02em;
}
.trib-card__info { flex: 1; min-width: 0; }
.trib-card__name { font-weight: 600; color: var(--ink-900); }
.trib-card__meta { font-size: .78rem; color: var(--ink-500); margin-top: 2px; }
.trib-status { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 600; }
.trib-status i { width: 8px; height: 8px; border-radius: var(--r-full); }
.trib-status.on { color: var(--green); }
.trib-status.on i { background: var(--green); animation: pulse 2s infinite; }
.trib-status.off { color: var(--red); }
.trib-status.off i { background: var(--red); }
.trib-status.unknown { color: var(--ink-400); }
.trib-status.unknown i { background: var(--ink-400); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(46,125,82,.4); } 50% { box-shadow: 0 0 0 5px rgba(46,125,82,0); } }

/* Badge colors por tribunal */
.b-stf   { background: linear-gradient(135deg,#5b3a6e,#3f2750); }
.b-stj   { background: linear-gradient(135deg,#2a557d,#143049); }
.b-tst   { background: linear-gradient(135deg,#1a6b4a,#0d4a32); }
.b-tjsp  { background: linear-gradient(135deg,#b8923a,#8a6d27); }
.b-trt15 { background: linear-gradient(135deg,#2e7d52,#1f5638); }
.b-bauru { background: linear-gradient(135deg,#a8443a,#7d2f28); }

.alert-banner {
  display: none; align-items: center; gap: var(--sp-3);
  background: var(--red-soft); border: 1px solid #f0c5be;
  color: var(--red); padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r-md); margin-top: var(--sp-5);
  font-size: .88rem; font-weight: 500;
}
.alert-banner.show { display: flex; }
.alert-banner svg { width: 20px; height: 20px; flex-shrink: 0; }

/* ============================================================
   BUSCA
   ============================================================ */
.search-panel {
  background: var(--paper); border-radius: var(--r-lg);
  padding: var(--sp-6); box-shadow: var(--sh-md);
  border: 1px solid var(--line-soft);
}
.search-box { position: relative; }
.search-box svg.ic {
  position: absolute; left: 20px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; color: var(--ink-400); pointer-events: none;
}
.search-box textarea {
  width: 100%; resize: none;
  padding: 18px 20px 18px 56px;
  border: 2px solid var(--line); border-radius: var(--r-md);
  background: var(--parchment);
  font-size: 1.02rem; line-height: 1.5;
  min-height: 60px;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.search-box textarea:focus {
  outline: none; border-color: var(--gold-500); background: var(--paper);
  box-shadow: 0 0 0 4px rgba(201,162,75,.14);
}
.search-box textarea::placeholder { color: var(--ink-400); }

.search-actions { display: flex; align-items: center; gap: var(--sp-3); margin-top: var(--sp-4); flex-wrap: wrap; }
.search-hint { margin-top: var(--sp-3); font-size: .82rem; color: var(--ink-500); line-height: 1.5; }
.search-hint b { color: var(--navy-700); font-weight: 600; }

.filters-toggle {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  color: var(--ink-500); font-size: .86rem; font-weight: 500;
  padding: 8px 14px; border-radius: var(--r-full);
  border: 1px solid var(--line); transition: all .2s;
}
.filters-toggle:hover { border-color: var(--gold-500); color: var(--gold-600); }
.filters-toggle svg { width: 16px; height: 16px; transition: transform .25s; }
.filters-toggle.open svg.chev { transform: rotate(180deg); }

.filters {
  display: none; gap: var(--sp-4);
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: var(--sp-5); padding-top: var(--sp-5);
  border-top: 1px dashed var(--line);
}
.filters.open { display: grid; animation: viewIn .3s var(--ease); }
.field label { display: block; font-size: .76rem; font-weight: 600; color: var(--ink-500); margin-bottom: 6px; letter-spacing: .04em; text-transform: uppercase; }
.field input, .field select {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--line); border-radius: var(--r-sm);
  background: var(--paper); transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--gold-500); box-shadow: 0 0 0 3px rgba(201,162,75,.12); }
.field-row { display: flex; gap: var(--sp-2); }
.field--wide { grid-column: 1 / -1; }
.field-hint { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--ink-400); font-size: .72rem; }

/* Multi-seleção de tribunais (chips com checkbox) */
.chk-group { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chk {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border: 1.5px solid var(--line); border-radius: var(--r-full);
  background: var(--paper); cursor: pointer; user-select: none;
  font-size: .85rem; font-weight: 600; color: var(--ink-700);
  transition: border-color .18s, background .18s, color .18s;
}
.chk:hover { border-color: var(--gold-500); }
.chk input { width: 15px; height: 15px; accent-color: var(--gold-600); cursor: pointer; margin: 0; }
.chk:has(input:checked) { border-color: var(--gold-500); background: rgba(201,162,75,.1); color: var(--navy-800); }

/* Barra de filtros do Acervo */
.acervo-bar {
  display: flex; flex-wrap: wrap; gap: var(--sp-4); align-items: center;
  margin-bottom: var(--sp-5); padding-bottom: var(--sp-5);
  border-bottom: 1px solid var(--line);
}
.acervo-search {
  flex: 1; min-width: 200px;
}
.acervo-input {
  width: 100%; padding: 9px 14px; border: 1.5px solid var(--line); border-radius: var(--r-sm);
  background: var(--paper); font-size: .95rem; color: var(--ink-700); font-family: var(--font-sans);
}
.acervo-input:focus { outline: none; border-color: var(--gold-500); box-shadow: 0 0 0 3px rgba(201,162,75,.12); }
.acervo-input::placeholder { color: var(--ink-400); }
.acervo-select {
  padding: 9px 14px; border: 1.5px solid var(--line); border-radius: var(--r-sm);
  background: var(--paper); font-weight: 600; color: var(--ink-700); cursor: pointer;
}
.acervo-select:focus { outline: none; border-color: var(--gold-500); box-shadow: 0 0 0 3px rgba(201,162,75,.12); }
.result-card__area-tag {
  font-size: .78rem; font-weight: 600; color: var(--ink-500);
  background: var(--line-soft); padding: 3px 10px; border-radius: var(--r-full);
}

/* ===== BIBLIOTECA ===== */
.bib-tabs { display: flex; gap: var(--sp-2); margin: var(--sp-5) 0 var(--sp-4); border-bottom: 1px solid var(--line-soft); }
.bib-tab {
  background: none; border: none; cursor: pointer; padding: 10px 18px;
  font-size: .95rem; font-weight: 600; color: var(--ink-500);
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .15s;
}
.bib-tab:hover { color: var(--navy-700); }
.bib-tab.active { color: var(--navy-800); border-bottom-color: var(--gold-500); }

.bib-card__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin: var(--sp-2) 0; }
.bib-sub {
  font-size: .82rem; font-weight: 700; color: var(--navy-700);
  background: rgba(201,162,75,.12); padding: 3px 11px; border-radius: var(--r-full);
}
.res-badge {
  font-size: .76rem; font-weight: 700; padding: 3px 11px; border-radius: var(--r-full);
  text-transform: uppercase; letter-spacing: .03em;
}
.res-badge.r-proc { background: var(--green-soft); color: var(--green); }
.res-badge.r-improc { background: var(--red-soft); color: var(--red); }
.res-badge.r-parcial { background: var(--amber-soft); color: var(--amber); }
.res-badge.r-neutro { background: var(--line-soft); color: var(--ink-500); }
.val-badge {
  font-size: .78rem; font-weight: 700; color: var(--navy-800);
  background: var(--gold-300); padding: 3px 11px; border-radius: var(--r-full);
}
.kw-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--sp-2); }
.kw-chip {
  font-size: .74rem; color: var(--ink-700); background: var(--line-soft);
  padding: 2px 9px; border-radius: var(--r-sm);
}

/* Súmulas */
.sum-badge {
  font-size: .72rem; font-weight: 700; padding: 2px 10px; border-radius: var(--r-full);
  text-transform: uppercase; letter-spacing: .03em;
}
.sum-badge.s-criada { background: var(--green-soft); color: var(--green); }
.sum-badge.s-alterada { background: var(--amber-soft); color: var(--amber); }
.sum-badge.s-cancelada { background: var(--red-soft); color: var(--red); }
.sum-badge.s-neutro { background: var(--line-soft); color: var(--ink-500); }
.sum-obs { font-size: .85rem; color: var(--ink-500); margin-top: var(--sp-2); font-style: italic; }

/* Filtros em grade (não quebram o layout) */
.bib-filtros {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--sp-3); margin-bottom: var(--sp-5);
  background: var(--parchment); border: 1px solid var(--line-soft);
  border-radius: var(--r-md); padding: var(--sp-4);
}
.bib-filtro { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.bib-filtro > label { font-size: .76rem; font-weight: 600; color: var(--ink-500); letter-spacing: .02em; }
.bib-filtro .muted { font-weight: 400; }
.bib-filtro .acervo-select, .bib-filtro .acervo-input { width: 100%; }
.bib-filtro--busca { grid-column: 1 / -1; }
@media (min-width: 720px) { .bib-filtro--busca { grid-column: auto; } }
.bib-filtro--acoes {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.bib-filtro-total { font-size: .82rem; color: var(--ink-500); }

/* Gráfico interativo área → temas */
.bib-chart-card {
  background: var(--color-surface, #fff); background: #fff; border: 1px solid var(--line-soft);
  border-radius: var(--r-lg); padding: var(--sp-5); margin-bottom: var(--sp-5);
}
.bib-chart-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: var(--sp-4); flex-wrap: wrap; gap: var(--sp-2); }
.bib-chart-head h3 { font-family: var(--font-serif); font-size: 1.3rem; color: var(--navy-800); }
.bib-chart-hint { font-size: .82rem; color: var(--ink-400); }
.chart-row { border-bottom: 1px solid var(--line-soft); }
.chart-row:last-child { border-bottom: none; }
.chart-bar-btn {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  background: none; border: none; cursor: pointer; padding: 9px 0; text-align: left;
}
.chart-bar-btn:hover .chart-area-name { color: var(--gold-600); }
.chart-area-name { flex: 0 0 165px; font-size: .9rem; font-weight: 600; color: var(--navy-800); }
.chart-bar { flex: 1; height: 16px; background: var(--line-soft); border-radius: var(--r-full); overflow: hidden; }
.chart-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-400), var(--gold-600)); border-radius: var(--r-full); }
.chart-area-total { flex: 0 0 56px; text-align: right; font-size: .85rem; font-weight: 700; color: var(--ink-700); }
.chart-row.aberta .chart-area-name { color: var(--gold-600); }
.chart-subs { padding: 4px 0 14px 165px; display: flex; flex-direction: column; gap: 6px; }
.chart-sub { display: flex; align-items: center; gap: var(--sp-3); background: none; border: none; cursor: pointer; padding: 2px 0; text-align: left; }
.chart-sub:hover .chart-sub-name { color: var(--gold-600); text-decoration: underline; }
.chart-sub-name { flex: 0 0 200px; font-size: .82rem; color: var(--ink-700); }
.chart-sub-bar { flex: 1; height: 9px; background: var(--line-soft); border-radius: var(--r-full); overflow: hidden; }
.chart-sub-bar > i { display: block; height: 100%; background: var(--navy-500); border-radius: var(--r-full); }
.chart-sub-total { flex: 0 0 40px; text-align: right; font-size: .8rem; font-weight: 600; color: var(--ink-500); }

/* Tipificação no modal */
.tipif-box { background: var(--parchment); border: 1px solid var(--line-soft); border-radius: var(--r-md); padding: var(--sp-4); }
.tipif-tag {
  font-size: .68rem; font-weight: 600; color: var(--gold-600); background: rgba(201,162,75,.14);
  padding: 2px 8px; border-radius: var(--r-full); margin-left: var(--sp-2); text-transform: uppercase; letter-spacing: .05em;
}
.tipif-item { display: flex; align-items: baseline; gap: var(--sp-3); margin-top: var(--sp-2); flex-wrap: wrap; }
.tipif-k { min-width: 110px; font-size: .8rem; font-weight: 600; color: var(--ink-500); }
.tipif-v { font-size: .9rem; color: var(--ink-900); flex: 1; }

/* ===== PROCESSOS ===== */
.proc-import { display: flex; gap: var(--sp-3); margin-bottom: var(--sp-2); }
.proc-import .acervo-input { flex: 1; }
.proc-card .result-card__materia { margin-top: var(--sp-1); }
.parte-row { display: flex; gap: var(--sp-3); padding: 4px 0; font-size: .92rem; border-bottom: 1px solid var(--line-soft); }
.parte-papel { min-width: 70px; font-weight: 600; color: var(--gold-600); }

.peca-resumo { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--sp-4); }
.peca-timeline { display: flex; flex-direction: column; gap: var(--sp-2); }
.peca-item { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3); background: var(--parchment); border: 1px solid var(--line-soft); border-radius: var(--r-md); }
.peca-ord {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: var(--r-full);
  background: var(--navy-800); color: var(--gold-300); font-size: .78rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.peca-body { flex: 1; min-width: 0; }
.peca-head { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.peca-tipo { font-weight: 700; color: var(--navy-800); font-size: .95rem; }
.peca-data { font-size: .82rem; color: var(--ink-400); }
.peca-doc { font-size: .8rem; color: var(--gold-600); font-weight: 600; }
.peca-teor { font-size: .86rem; color: var(--ink-500); margin-top: 4px; line-height: 1.55; max-height: 4.7em; overflow: hidden; }
.peca-section-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--sp-2); }
.peca-curadoria { display: flex; align-items: center; gap: var(--sp-3); }
.curado-badge { font-size: .72rem; font-weight: 700; padding: 2px 10px; border-radius: var(--r-full); text-transform: uppercase; letter-spacing: .03em; }
.curado-badge.c-ia { background: rgba(201,162,75,.16); color: var(--gold-600); }
.curado-badge.c-regex { background: var(--line-soft); color: var(--ink-500); }
.btn--sm { padding: 5px 12px; font-size: .82rem; }

/* Nota da consulta curada (texto livre → busca técnica) */
.query-note {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-bottom: var(--sp-4); padding: 10px 14px;
  background: var(--green-soft); border: 1px solid rgba(46,125,82,.25);
  border-radius: var(--r-sm); font-size: .85rem; color: var(--ink-700);
}
.query-note svg { width: 16px; height: 16px; color: var(--green); flex-shrink: 0; }
.query-note b { color: var(--navy-800); font-weight: 700; }
.query-note__tag {
  font-style: normal; font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--green); background: var(--paper);
  padding: 2px 7px; border-radius: var(--r-full); margin-left: 4px;
}

/* Aviso de "resumo" no inteiro teor (consulta pública traz só excerto) */
.teor-aviso {
  display: flex; align-items: flex-start; gap: var(--sp-2);
  margin-bottom: var(--sp-3); padding: 10px 14px;
  background: var(--amber-soft); border: 1px solid rgba(185,130,31,.3);
  border-radius: var(--r-sm); font-size: .85rem; color: var(--ink-700);
}
.teor-aviso svg { width: 16px; height: 16px; color: var(--amber); flex-shrink: 0; margin-top: 2px; }
.teor-aviso a { color: var(--gold-600); font-weight: 700; text-decoration: underline; }

/* Aviso honesto de baixa relevância (piso do motor) */
.rel-warn {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-bottom: var(--sp-4); padding: 11px 15px;
  background: var(--amber-soft); border: 1px solid rgba(185,130,31,.3);
  border-radius: var(--r-sm); font-size: .86rem; color: var(--ink-700);
}
.rel-warn svg { width: 17px; height: 17px; color: var(--amber); flex-shrink: 0; }
.rel-tag-baixa {
  font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--amber); background: var(--amber-soft); border: 1px solid rgba(185,130,31,.3);
  padding: 2px 8px; border-radius: var(--r-full); margin-left: auto;
}
.result-card.is-baixa { opacity: .82; }
.result-card.is-baixa .rel-bar i { background: var(--amber); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 12px 26px; border-radius: var(--r-full);
  font-weight: 600; font-size: .88rem; letter-spacing: .02em;
  transition: transform .2s var(--ease), box-shadow .2s, background .2s, color .2s;
  white-space: nowrap;
}
.btn svg { width: 17px; height: 17px; }
.btn--primary { background: linear-gradient(135deg, var(--gold-500), var(--gold-600)); color: var(--navy-900); box-shadow: var(--sh-gold); }
.btn--primary:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(184,146,58,.36); }
.btn--navy { background: var(--navy-800); color: var(--paper); }
.btn--navy:hover { background: var(--navy-700); transform: translateY(-2px); box-shadow: var(--sh-md); }
.btn--ghost { background: var(--paper); color: var(--ink-700); border: 1.5px solid var(--line); }
.btn--ghost:hover { border-color: var(--gold-500); color: var(--gold-600); }
.btn--gold { background: linear-gradient(135deg, var(--gold-500), var(--gold-600)); color: var(--navy-900); font-weight: 700; box-shadow: var(--sh-gold); }
.btn--gold:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(184,146,58,.36); }
.btn--sm { padding: 8px 16px; font-size: .8rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ============================================================
   RESULTADOS
   ============================================================ */
.results-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: var(--sp-6) 0 var(--sp-4); flex-wrap: wrap; gap: var(--sp-3);
}
.results-head__count { color: var(--ink-500); font-size: .9rem; }
.results-head__count b { color: var(--navy-800); }
.mode-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .72rem; font-weight: 600; padding: 5px 12px;
  border-radius: var(--r-full); letter-spacing: .03em;
}
.mode-pill.semantica { background: var(--green-soft); color: var(--green); }
.mode-pill.local { background: var(--amber-soft); color: var(--amber); }

.result-list { display: flex; flex-direction: column; gap: var(--sp-4); }

.result-card {
  background: var(--paper); border-radius: var(--r-md);
  border: 1px solid var(--line-soft);
  padding: var(--sp-5); box-shadow: var(--sh-sm);
  cursor: pointer;
  transition: transform .22s var(--ease), box-shadow .22s var(--ease), border-color .22s;
  position: relative; overflow: hidden;
}
.result-card:hover { transform: translateY(-3px); box-shadow: var(--sh-lg); border-color: var(--gold-300); }
.result-card__top { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.trib-tag {
  font-size: .68rem; font-weight: 700; letter-spacing: .06em;
  padding: 4px 10px; border-radius: var(--r-sm); color: var(--paper);
}
.result-card__num { font-family: var(--font-sans); font-weight: 600; color: var(--navy-700); font-size: .9rem; }
.result-card__sep { color: var(--line); }
.result-card__meta { color: var(--ink-500); font-size: .8rem; }

.result-card__materia { font-family: var(--font-serif); font-size: 1.28rem; font-weight: 600; color: var(--navy-800); margin-bottom: var(--sp-2); }
.result-card__ementa {
  color: var(--ink-700); font-size: .92rem; line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.result-card__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); margin-top: var(--sp-4); flex-wrap: wrap; }
.result-card__rel { display: flex; align-items: center; gap: var(--sp-3); flex: 1; min-width: 160px; }
.rel-label { font-size: .72rem; color: var(--ink-400); font-weight: 600; letter-spacing: .04em; white-space: nowrap; }
.rel-bar { flex: 1; height: 6px; background: var(--line-soft); border-radius: var(--r-full); overflow: hidden; max-width: 180px; }
.rel-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-400), var(--gold-600)); border-radius: var(--r-full); }
.rel-pct { font-size: .8rem; font-weight: 700; color: var(--gold-600); white-space: nowrap; min-width: 34px; }
.result-card__open { display: inline-flex; align-items: center; gap: 6px; color: var(--gold-600); font-weight: 600; font-size: .82rem; }
.result-card__open svg { width: 15px; height: 15px; transition: transform .2s; }
.result-card:hover .result-card__open svg { transform: translateX(3px); }

/* ---------- Paginação ---------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: var(--sp-2); margin-top: var(--sp-7); }
.page-btn {
  min-width: 40px; height: 40px; padding: 0 12px;
  border-radius: var(--r-sm); border: 1.5px solid var(--line);
  background: var(--paper); color: var(--ink-700); font-weight: 600; font-size: .86rem;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .2s;
}
.page-btn:hover:not(:disabled) { border-color: var(--gold-500); color: var(--gold-600); }
.page-btn.active { background: var(--navy-800); color: var(--paper); border-color: var(--navy-800); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ============================================================
   ESTADOS (loading / vazio)
   ============================================================ */
.state { text-align: center; padding: var(--sp-8) var(--sp-5); color: var(--ink-500); }
.state svg { width: 56px; height: 56px; color: var(--line); margin-bottom: var(--sp-4); }
.state h3 { font-family: var(--font-serif); font-size: 1.5rem; color: var(--navy-700); margin-bottom: var(--sp-2); }

.spinner {
  width: 44px; height: 44px; margin: 0 auto var(--sp-4);
  border: 3px solid var(--line-soft); border-top-color: var(--gold-500);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton-card {
  background: var(--paper); border-radius: var(--r-md);
  border: 1px solid var(--line-soft); padding: var(--sp-5); box-shadow: var(--sh-sm);
}
.sk { background: linear-gradient(90deg, var(--line-soft) 25%, #f4efe4 50%, var(--line-soft) 75%); background-size: 200% 100%; border-radius: var(--r-sm); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.sk-line { height: 12px; margin-bottom: 10px; }

/* Aviso de busca ao vivo nos tribunais */
.live-notice {
  display: flex; align-items: center; gap: var(--sp-3);
  background: linear-gradient(135deg, var(--navy-800), var(--navy-700));
  color: var(--gold-300);
  border-radius: var(--r-md); padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-4); font-weight: 500;
  box-shadow: var(--sh-md);
}
.live-notice .spinner { border-top-color: var(--gold-400); border-right-color: var(--gold-400); }

/* ============================================================
   MODAL / VISUALIZADOR
   ============================================================ */
.modal { position: fixed; inset: 0; z-index: 60; display: none; }
.modal.open { display: block; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(10,25,41,.55); backdrop-filter: blur(3px); animation: fadeIn .3s; }
.modal__panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(720px, 100%);
  background: var(--parchment);
  box-shadow: -8px 0 40px rgba(10,25,41,.3);
  display: flex; flex-direction: column;
  animation: slideIn .4s var(--ease);
}
@keyframes slideIn { from { transform: translateX(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal__head {
  background: var(--navy-800); color: var(--paper);
  padding: var(--sp-5) var(--sp-6); display: flex; align-items: flex-start; gap: var(--sp-4);
}
.modal__head .trib-tag { margin-top: 4px; }
.modal__head h2 { font-family: var(--font-serif); font-size: 1.5rem; font-weight: 600; flex: 1; }
.modal__close {
  width: 38px; height: 38px; border-radius: var(--r-full);
  display: grid; place-items: center; color: rgba(255,255,255,.8);
  background: rgba(255,255,255,.08); transition: background .2s, transform .2s; flex-shrink: 0;
}
.modal__close:hover { background: rgba(255,255,255,.18); transform: rotate(90deg); }
.modal__close svg { width: 20px; height: 20px; }
.modal__body { flex: 1; overflow-y: auto; padding: var(--sp-6); }

.doc-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-6); }
.doc-meta__item { background: var(--paper); border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: var(--sp-3) var(--sp-4); }
.doc-meta__k { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-400); font-weight: 600; }
.doc-meta__v { color: var(--ink-900); font-weight: 500; margin-top: 3px; font-size: .9rem; }

.doc-section h4 {
  font-family: var(--font-sans); font-size: .76rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: var(--gold-600);
  margin-bottom: var(--sp-3); padding-bottom: var(--sp-2); border-bottom: 1px solid var(--line);
}
.doc-ementa {
  font-family: var(--font-serif); font-size: 1.12rem; line-height: 1.7;
  color: var(--ink-900); background: var(--paper);
  padding: var(--sp-5); border-radius: var(--r-md); border-left: 3px solid var(--gold-500);
  margin-bottom: var(--sp-6); box-shadow: var(--sh-sm);
}
.doc-teor { white-space: pre-wrap; color: var(--ink-700); font-size: .9rem; line-height: 1.75; }
.modal__foot { padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--line); display: flex; gap: var(--sp-3); justify-content: flex-end; background: var(--paper); }

/* ============================================================
   CONFIGURAÇÕES
   ============================================================ */
.config-grid { display: grid; gap: var(--sp-5); grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.config-card {
  background: var(--paper); border-radius: var(--r-md);
  border: 1px solid var(--line-soft); box-shadow: var(--sh-sm);
  padding: var(--sp-6); overflow: hidden;
}
.config-card h3 { font-family: var(--font-serif); font-size: 1.35rem; color: var(--navy-800); margin-bottom: var(--sp-2); display: flex; align-items: center; gap: var(--sp-3); }
.config-card h3 svg { width: 22px; height: 22px; color: var(--gold-600); }
.config-card p.muted { color: var(--ink-500); font-size: .86rem; margin-bottom: var(--sp-5); }

.auth-row { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-3) 0; border-bottom: 1px solid var(--line-soft); }
.auth-row:last-child { border-bottom: none; }
.auth-row__name { font-weight: 600; display: flex; align-items: center; gap: var(--sp-3); }

.sched-info { display: flex; flex-direction: column; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.sched-info__row { display: flex; align-items: center; gap: var(--sp-3); font-size: .9rem; }
.sched-info__row svg { width: 18px; height: 18px; color: var(--gold-600); flex-shrink: 0; }
.sched-info__row b { color: var(--navy-800); }

.kv-status {
  display: inline-flex; align-items: center; gap: 6px; font-size: .76rem; font-weight: 600;
  padding: 4px 10px; border-radius: var(--r-full);
}
.kv-status.on { background: var(--green-soft); color: var(--green); }
.kv-status.off { background: var(--red-soft); color: var(--red); }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; bottom: var(--sp-6); right: var(--sp-6); z-index: 80; display: flex; flex-direction: column; gap: var(--sp-3); }
.toast {
  background: var(--navy-800); color: var(--paper);
  padding: var(--sp-4) var(--sp-5); border-radius: var(--r-md);
  box-shadow: var(--sh-lg); display: flex; align-items: center; gap: var(--sp-3);
  font-size: .88rem; min-width: 280px; max-width: 380px;
  animation: toastIn .35s var(--ease); border-left: 3px solid var(--gold-500);
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
.toast svg { width: 20px; height: 20px; flex-shrink: 0; }
@keyframes toastIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============================================================
   MONITORAMENTO / DASHBOARD CONFIG
   ============================================================ */
.monitor-section { margin-bottom: var(--sp-7); }
.monitor-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--sp-4); margin: var(--sp-5) 0;
}
.monitor-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--sp-5); text-align: center;
}
.monitor-card__label { font-size: .78rem; color: var(--ink-400); text-transform: uppercase; letter-spacing: .04em; margin-bottom: var(--sp-2); }
.monitor-card__value { font-family: var(--font-serif); font-size: 1.8rem; font-weight: 700; color: var(--navy-800); }
.monitor-card__value--sm { font-size: 1.1rem; font-family: var(--font-sans); font-weight: 600; }

.monitor-tribunais, .monitor-areas { margin-top: var(--sp-4); }
.monitor-tribunais h4, .monitor-areas h4 { font-size: .85rem; color: var(--ink-500); margin-bottom: var(--sp-3); }
.monitor-bar-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.monitor-bar-item {
  display: flex; align-items: center; gap: var(--sp-3); font-size: .85rem;
}
.monitor-bar-item__label { width: 100px; flex-shrink: 0; color: var(--ink-700); font-weight: 500; }
.monitor-bar-item__bar { flex: 1; height: 20px; background: var(--parchment); border-radius: var(--r-sm); overflow: hidden; }
.monitor-bar-item__bar i { display: block; height: 100%; background: var(--gold-500); border-radius: var(--r-sm); transition: width .4s var(--ease); }
.monitor-bar-item__count { width: 50px; text-align: right; font-weight: 600; color: var(--navy-800); font-size: .82rem; }

.config-card--wide { grid-column: 1 / -1; }
.coleta-controls {
  display: grid; grid-template-columns: 1fr 1fr 140px; gap: var(--sp-4); align-items: start; margin: var(--sp-4) 0;
}
.coleta-controls .field label { font-size: .78rem; color: var(--ink-500); margin-bottom: var(--sp-1); display: block; }
.coleta-controls .chk-group { flex-wrap: wrap; }

@media (max-width: 720px) {
  .coleta-controls { grid-template-columns: 1fr; }
}

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 720px) {
  .container { padding: var(--sp-5) var(--sp-4); }
  .topbar { padding: 0 var(--sp-4); gap: var(--sp-3); }
  .topbar__name { display: none; }
  .nav { margin-left: 0; }
  .nav__item span { display: none; }
  .nav__item { padding: 8px 12px; }
  .splash .wordmark__name { font-size: 1.9rem; }
  .section-head h1 { font-size: 1.7rem; }
  .modal__panel { width: 100%; }
}
