/* ============================================================
   LASTRO · Gestão de Precatórios
   Estética: registro institucional — tinta verde-escura, latão e papel.
   ============================================================ */

:root {
  --ink-0: #0b110e;
  --ink-1: #0e1512;
  --ink-2: #131c17;
  --ink-3: #18241e;
  --ink-4: #1f2e26;
  --line: #27362d;
  --line-soft: #1d2a23;
  --paper: #ece4d2;
  --paper-dim: #b7b0a0;
  --paper-faint: #837e72;
  --brass: #c9a86a;
  --brass-bright: #e3c98f;
  --brass-dim: rgba(201, 168, 106, 0.14);
  --green: #5fbe85;
  --green-dim: rgba(95, 190, 133, 0.14);
  --red: #e07856;
  --red-dim: rgba(224, 120, 86, 0.13);
  --amber: #e0b556;
  --amber-dim: rgba(224, 181, 86, 0.13);
  --blue: #6fa8c9;
  --blue-dim: rgba(111, 168, 201, 0.13);

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Archivo", -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --sidebar-w: 232px;
}

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

html { color-scheme: dark; }

body {
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(201, 168, 106, 0.06), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(95, 190, 133, 0.05), transparent 55%),
    var(--ink-1);
  color: var(--paper);
  font-size: 14.5px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* textura sutil de grão */
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

#app { position: relative; z-index: 1; }

a { color: var(--brass-bright); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: rgba(201, 168, 106, 0.3); }

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: 0.01em; }

.mono { font-family: var(--font-mono); font-size: 0.92em; }
.muted { color: var(--paper-dim); }
.faint { color: var(--paper-faint); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, var(--ink-0), var(--ink-1));
  border-right: 1px solid var(--line-soft);
  padding: 22px 14px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}

.brand {
  display: flex; align-items: baseline; gap: 8px;
  padding: 2px 10px 18px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 14px;
}
.brand .logo {
  font-family: var(--font-display);
  font-size: 26px; font-weight: 700; color: var(--paper);
  letter-spacing: 0.02em;
}
.brand .logo span { color: var(--brass); }
.brand .tag { font-size: 10px; text-transform: uppercase; letter-spacing: 0.18em; color: var(--paper-faint); }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--paper-dim); font-weight: 500; font-size: 13.5px;
  cursor: pointer; border: 1px solid transparent;
  transition: all 0.15s ease;
}
.nav-item svg { width: 17px; height: 17px; opacity: 0.75; flex: none; }
.nav-item:hover { color: var(--paper); background: var(--ink-3); text-decoration: none; }
.nav-item.active {
  color: var(--brass-bright); background: var(--brass-dim);
  border-color: rgba(201, 168, 106, 0.25);
}
.nav-item.active svg { opacity: 1; }

.sidebar .spacer { flex: 1; }
.userbox {
  border-top: 1px solid var(--line-soft);
  padding: 12px 10px 2px; font-size: 12.5px;
}
.userbox .nome { color: var(--paper); font-weight: 600; }
.userbox button {
  margin-top: 8px; width: 100%;
}

.main { padding: 26px 32px 60px; max-width: 1280px; width: 100%; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-head h1 { font-size: 27px; }
.page-head .sub { color: var(--paper-dim); margin-top: 3px; font-size: 13px; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Cartões ---------- */
.card {
  background: linear-gradient(180deg, var(--ink-2), var(--ink-1));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.card + .card { margin-top: 16px; }
.card h3 { font-size: 16px; margin-bottom: 12px; color: var(--paper); }
.card .hint { font-size: 12px; color: var(--paper-faint); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: linear-gradient(180deg, var(--ink-2), var(--ink-1));
  border: 1px solid var(--line-soft); border-radius: var(--radius-lg);
  padding: 16px 18px; position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, var(--brass), transparent 70%);
  opacity: 0.6;
}
.kpi .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--paper-faint); }
.kpi .value { font-family: var(--font-display); font-size: 25px; font-weight: 600; margin-top: 5px; color: var(--paper); }
.kpi .value.mono-v { font-family: var(--font-mono); font-size: 20px; font-weight: 600; }
.kpi .sub { font-size: 12px; color: var(--paper-dim); margin-top: 3px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 1100px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line-soft); border-radius: var(--radius-lg); background: var(--ink-2); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.13em;
  color: var(--paper-faint); font-weight: 600;
  padding: 11px 14px; border-bottom: 1px solid var(--line);
  background: var(--ink-3);
  white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; transition: background 0.12s; }
tbody tr.clickable:hover { background: rgba(201, 168, 106, 0.05); }
td .title { font-weight: 600; color: var(--paper); }
td .sub { font-size: 12px; color: var(--paper-faint); }

.empty {
  padding: 36px 20px; text-align: center; color: var(--paper-faint); font-size: 13.5px;
}
.empty .big { font-family: var(--font-display); font-size: 17px; color: var(--paper-dim); margin-bottom: 4px; }

/* ---------- Botões ---------- */
button, .btn {
  font-family: var(--font-body);
  font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--ink-3); color: var(--paper);
  cursor: pointer; transition: all 0.15s ease;
  display: inline-flex; align-items: center; gap: 7px; line-height: 1.2;
}
button:hover, .btn:hover { border-color: var(--brass); color: var(--brass-bright); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:disabled:hover { border-color: var(--line); color: var(--paper); }

.btn-primary {
  background: linear-gradient(180deg, var(--brass-bright), var(--brass));
  border-color: var(--brass);
  color: #1a140a;
}
.btn-primary:hover { color: #000; filter: brightness(1.06); border-color: var(--brass-bright); }

.btn-danger { border-color: rgba(224, 120, 86, 0.4); color: var(--red); background: transparent; }
.btn-danger:hover { background: var(--red-dim); border-color: var(--red); color: var(--red); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--paper-dim); padding: 6px 9px; }
.btn-ghost:hover { color: var(--paper); border-color: var(--line); }

.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-lg { padding: 11px 20px; font-size: 14px; }

/* ---------- Formulários ---------- */
label.field { display: block; font-size: 12px; }
label.field > span {
  display: block; margin-bottom: 5px;
  text-transform: uppercase; letter-spacing: 0.1em; font-size: 10.5px;
  color: var(--paper-faint); font-weight: 600;
}
input, select, textarea {
  font-family: var(--font-body); font-size: 13.5px;
  width: 100%;
  background: var(--ink-1);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--paper);
  padding: 9px 11px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="date"] { color-scheme: dark; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(201, 168, 106, 0.12);
}
textarea { resize: vertical; min-height: 90px; }
input::placeholder, textarea::placeholder { color: var(--paper-faint); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 13px 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid .span-2 { grid-column: span 1; } }

fieldset.section {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 16px 18px 18px;
  margin-bottom: 16px;
  background: rgba(255,255,255,0.012);
}
fieldset.section legend {
  font-family: var(--font-display); font-size: 14.5px; font-weight: 600;
  color: var(--brass-bright); padding: 0 8px;
}

.check {
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; color: var(--paper-dim); cursor: pointer;
  padding: 7px 10px; border: 1px solid var(--line-soft); border-radius: 8px;
  background: var(--ink-1);
}
.check input { width: 15px; height: 15px; accent-color: var(--brass); }
.check.on { color: var(--red); border-color: rgba(224,120,86,0.35); background: var(--red-dim); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 150px; }
.filters input[type="search"] { min-width: 230px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--paper-dim);
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.8; }

.st-prospeccao { color: var(--blue); border-color: rgba(111,168,201,0.35); background: var(--blue-dim); }
.st-analise, .st-due_diligence { color: var(--amber); border-color: rgba(224,181,86,0.35); background: var(--amber-dim); }
.st-proposta, .st-negociacao { color: var(--brass-bright); border-color: rgba(201,168,106,0.4); background: var(--brass-dim); }
.st-cessao_assinada, .st-habilitacao, .st-aguardando_pagamento { color: #9ecf8e; border-color: rgba(158,207,142,0.3); background: rgba(158,207,142,0.1); }
.st-recebido { color: var(--green); border-color: rgba(95,190,133,0.4); background: var(--green-dim); }
.st-reprovado, .st-cancelado { color: var(--red); border-color: rgba(224,120,86,0.35); background: var(--red-dim); }

/* Vocabulário oficial = Situação na Carteira */
.st-em_analise { color: var(--amber); border-color: rgba(224,181,86,0.35); background: var(--amber-dim); }
.st-ag_aprovacao { color: var(--blue); border-color: rgba(111,168,201,0.35); background: var(--blue-dim); }
.st-aprovado { color: var(--brass-bright); border-color: rgba(201,168,106,0.4); background: var(--brass-dim); }
.st-adquirido { color: var(--green); border-color: rgba(95,190,133,0.4); background: var(--green-dim); }
.st-recusado { color: var(--red); border-color: rgba(224,120,86,0.35); background: var(--red-dim); }

.nv-MUITO_ALTO { color: var(--green); border-color: rgba(95,190,133,0.45); background: var(--green-dim); }
.nv-ALTO { color: #9ecf8e; border-color: rgba(158,207,142,0.35); background: rgba(158,207,142,0.1); }
.nv-MEDIO { color: var(--amber); border-color: rgba(224,181,86,0.4); background: var(--amber-dim); }
.nv-BAIXO { color: #e09a56; border-color: rgba(224,154,86,0.4); background: rgba(224,154,86,0.12); }
.nv-MUITO_BAIXO { color: var(--red); border-color: rgba(224,120,86,0.45); background: var(--red-dim); }
.nv-INDEFINIDO { color: var(--paper-faint); }

.rec-APROVAR { color: var(--green); }
.rec-APROVAR_COM_RESSALVAS { color: #9ecf8e; }
.rec-SOLICITAR_DILIGENCIAS { color: var(--amber); }
.rec-REPROVAR { color: var(--red); }

/* ---------- Barras (dashboard) ---------- */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 110px; gap: 10px; align-items: center; font-size: 12.5px; }
.bar-row .lbl { color: var(--paper-dim); text-align: right; }
.bar-track { height: 9px; background: var(--ink-4); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brass), var(--brass-bright)); min-width: 2px; }
.bar-row .num { font-family: var(--font-mono); font-size: 12px; color: var(--paper-dim); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  padding: 9px 15px; font-size: 13px; font-weight: 600;
  color: var(--paper-dim); cursor: pointer;
  border: none; background: none; border-bottom: 2px solid transparent;
  border-radius: 0; margin-bottom: -1px;
}
.tab:hover { color: var(--paper); border-color: transparent; }
.tab.active { color: var(--brass-bright); border-bottom-color: var(--brass); }
.tab .count { font-family: var(--font-mono); font-size: 11px; color: var(--paper-faint); margin-left: 5px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 8, 6, 0.72); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 18px; overflow-y: auto;
  animation: fadeIn 0.15s ease;
}
.modal {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  width: 100%; max-width: 880px;
  animation: slideUp 0.2s ease;
}
.modal.modal-sm { max-width: 520px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--line-soft);
}
.modal-head h2 { font-size: 19px; }
.modal-body { padding: 20px 22px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 22px; border-top: 1px solid var(--line-soft);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- Toasts ---------- */
#toasts { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 9px; }
.toast {
  background: var(--ink-3); border: 1px solid var(--line);
  border-left: 3px solid var(--brass);
  border-radius: 10px; padding: 11px 15px;
  font-size: 13px; max-width: 380px;
  box-shadow: var(--shadow);
  animation: slideUp 0.2s ease;
}
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background:
    radial-gradient(900px 500px at 70% 20%, rgba(201,168,106,0.08), transparent 60%),
    var(--ink-0);
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--ink-2); border: 1px solid var(--line);
  border-radius: 18px; padding: 38px 34px;
  box-shadow: var(--shadow);
}
.login-card .logo { font-family: var(--font-display); font-size: 36px; font-weight: 700; text-align: center; }
.login-card .logo span { color: var(--brass); }
.login-card .tag { text-align: center; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.22em; color: var(--paper-faint); margin: 4px 0 28px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }

/* ---------- Dropzone ---------- */
.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-lg);
  padding: 26px; text-align: center;
  color: var(--paper-dim); cursor: pointer;
  transition: all 0.15s; font-size: 13.5px;
  background: rgba(255,255,255,0.012);
}
.dropzone:hover, .dropzone.drag { border-color: var(--brass); background: var(--brass-dim); color: var(--brass-bright); }
.dropzone .icon { font-size: 24px; display: block; margin-bottom: 6px; }

/* ---------- Score ring (veredito) ---------- */
.veredito-card {
  border: 1px solid rgba(201,168,106,0.35);
  background:
    radial-gradient(500px 200px at 0% 0%, rgba(201,168,106,0.1), transparent 60%),
    linear-gradient(180deg, var(--ink-2), var(--ink-1));
  border-radius: 16px; padding: 22px;
}
.veredito-grid { display: grid; grid-template-columns: 150px 1fr; gap: 22px; align-items: start; }
@media (max-width: 760px) { .veredito-grid { grid-template-columns: 1fr; } }
.ring { width: 130px; height: 130px; border-radius: 50%; display: grid; place-items: center; position: relative; margin: 0 auto; }
.ring::before {
  content: ""; position: absolute; inset: 9px; border-radius: 50%;
  background: var(--ink-1); border: 1px solid var(--line-soft);
}
.ring .inner { position: relative; text-align: center; }
.ring .score { font-family: var(--font-display); font-size: 33px; font-weight: 700; line-height: 1; }
.ring .of { font-size: 10px; color: var(--paper-faint); letter-spacing: 0.1em; }
.v-lists { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
@media (max-width: 760px) { .v-lists { grid-template-columns: 1fr; } }
.v-list h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.13em; color: var(--paper-faint); margin-bottom: 7px; }
.v-list ul { list-style: none; }
.v-list li { font-size: 13px; padding: 4px 0 4px 16px; position: relative; color: var(--paper-dim); }
.v-list li::before { content: "•"; position: absolute; left: 2px; color: var(--brass); }
.v-list.neg li::before { color: var(--red); }

/* ---------- Pareceres / acordeão ---------- */
.accordion { border: 1px solid var(--line-soft); border-radius: var(--radius-lg); overflow: hidden; }
.acc-item + .acc-item { border-top: 1px solid var(--line-soft); }
.acc-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 16px; cursor: pointer; background: var(--ink-2);
  font-weight: 600; font-size: 13.5px;
}
.acc-head:hover { background: var(--ink-3); }
.acc-head .meta { font-size: 11.5px; color: var(--paper-faint); font-weight: 400; }
.acc-body { padding: 16px 18px; background: var(--ink-1); display: none; }
.acc-item.open .acc-body { display: block; }
.acc-item.open .chev { transform: rotate(180deg); }
.chev { transition: transform 0.15s; color: var(--paper-faint); }

.parecer-texto { white-space: pre-wrap; font-size: 13.5px; color: var(--paper-dim); line-height: 1.65; }
.parecer-texto strong, .parecer-texto b { color: var(--paper); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 1px; background: var(--line); }
.timeline li { position: relative; padding: 0 0 16px 8px; }
.timeline li::before {
  content: ""; position: absolute; left: -20px; top: 5px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--ink-2); border: 2px solid var(--brass);
}
.timeline .quando { font-family: var(--font-mono); font-size: 11px; color: var(--paper-faint); }
.timeline .oque { font-size: 13.5px; color: var(--paper); font-weight: 500; }
.timeline .det { font-size: 12.5px; color: var(--paper-dim); }

/* ---------- Documentos ---------- */
.doc-row { display: flex; align-items: center; gap: 12px; }
.doc-ico {
  width: 36px; height: 36px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  background: var(--brass-dim); color: var(--brass-bright);
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  border: 1px solid rgba(201,168,106,0.25);
}

/* ---------- Due diligence ---------- */
.dd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 860px) { .dd-grid { grid-template-columns: 1fr; } }
.dd-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 13px; border: 1px solid var(--line-soft); border-radius: 9px;
  background: var(--ink-1); font-size: 13px;
}
.dd-item .seg { display: flex; gap: 3px; }
.dd-item .seg button { padding: 3px 9px; font-size: 11px; border-radius: 6px; }
.dd-item .seg button.sel-ok { background: var(--green-dim); border-color: rgba(95,190,133,0.5); color: var(--green); }
.dd-item .seg button.sel-pendente { background: var(--amber-dim); border-color: rgba(224,181,86,0.5); color: var(--amber); }
.dd-item .seg button.sel-na { background: var(--ink-4); color: var(--paper-dim); }

/* ---------- Progresso IA ---------- */
.ia-progress { display: flex; flex-direction: column; gap: 10px; padding: 6px 2px; }
.ia-step { display: flex; align-items: center; gap: 11px; font-size: 13.5px; color: var(--paper-faint); }
.ia-step.doing { color: var(--brass-bright); }
.ia-step.done { color: var(--green); }
.ia-step .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); flex: none; }
.ia-step.doing .dot { background: var(--brass); animation: pulse 1.1s infinite; }
.ia-step.done .dot { background: var(--green); }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1);} 50% { opacity: 0.45; transform: scale(0.8);} }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--brass);
  animation: spin 0.8s linear infinite; display: inline-block; vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Pequenos ---------- */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.mt { margin-top: 14px; } .mt-lg { margin-top: 22px; } .mb { margin-bottom: 14px; }
.divider { height: 1px; background: var(--line-soft); margin: 16px 0; }
.tag-cat {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em;
  padding: 2px 8px; border-radius: 6px;
  background: var(--ink-4); color: var(--paper-dim);
  border: 1px solid var(--line-soft);
}
.alert-flags { display: flex; gap: 6px; flex-wrap: wrap; }
.flag-pill {
  font-size: 11px; padding: 3px 9px; border-radius: 99px;
  background: var(--red-dim); color: var(--red);
  border: 1px solid rgba(224,120,86,0.35); font-weight: 600;
}

.pagination { display: flex; align-items: center; justify-content: space-between; margin-top: 13px; font-size: 12.5px; color: var(--paper-dim); }

/* ============================================================
   RESPONSIVO / MOBILE
   ============================================================ */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  /* Sidebar vira barra superior; navegação rola na horizontal sem quebrar */
  .sidebar {
    position: sticky; top: 0; z-index: 40; height: auto;
    flex-direction: row; align-items: center; gap: 8px;
    padding: 8px 10px; border-right: none; border-bottom: 1px solid var(--line);
    overflow: visible;
  }
  .brand { border: none; margin: 0; padding: 0 6px 0 2px; flex: none; }
  .brand .tag { display: none; }
  .sidebar .nav {
    flex-direction: row; gap: 4px; flex: 1; min-width: 0;
    overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px;
  }
  .sidebar .nav::-webkit-scrollbar { display: none; }
  .nav-item { white-space: nowrap; padding: 8px 12px; }
  .sidebar .spacer { display: none; }
  /* userbox compacto à direita: só ícones essenciais (conta, tema, sair) — logout SEMPRE acessível */
  .userbox {
    display: flex; flex-direction: row; align-items: center; gap: 4px;
    border: none; margin: 0; padding: 0; flex: none; background: none;
  }
  .userbox .nome, .userbox .hint { display: none; }
  .userbox a.nav-item span, .userbox button span:not(.ico-on):not(.ico-off) { display: none; }
  .userbox a.nav-item, .userbox button {
    padding: 8px 10px; margin: 0; width: auto; min-width: 40px; justify-content: center;
  }
  .theme-toggle .ico-on, .theme-toggle .ico-off { font-size: 0; }
  .theme-toggle svg { font-size: initial; }

  .main { padding: 16px 14px 64px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-head h1 { font-size: 22px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn, .page-head .actions button, .page-head .actions a { flex: 1 1 auto; justify-content: center; }

  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }

  /* Filtros empilham e ocupam a largura toda */
  .filters { gap: 8px; }
  .filters input, .filters select, .filters input[type="search"] { min-width: 0; width: 100%; flex: 1 1 100%; }
  .filters .btn, .filters button { flex: 1 1 auto; }

  /* Abas rolam na horizontal em vez de quebrar em várias linhas */
  .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 2px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a, .tabs button { white-space: nowrap; }

  /* Modais em tela cheia */
  .modal-overlay { padding: 0; align-items: stretch; }
  .modal, .modal.modal-sm { max-width: 100%; width: 100%; max-height: 100%; height: 100%; border-radius: 0; }
  .modal-body { padding: 16px; }

  /* Alvos de toque maiores */
  .btn, button.btn, .btn-primary, .btn-sm { min-height: 40px; }
  .seg button { min-height: 36px; padding: 6px 10px; }
}

/* Lista de precatórios: vira CARTÕES no celular (sem scroll horizontal) */
@media (max-width: 640px) {
  .proc-wrap { overflow: visible; border: none; background: none; }
  .proc-table thead { position: absolute; left: -9999px; }
  .proc-table, .proc-table tbody, .proc-table tr, .proc-table td { display: block; width: auto; }
  .proc-table tr.rowlink {
    border: 1px solid var(--line); border-radius: 12px;
    margin-bottom: 10px; padding: 12px 14px; background: var(--ink-2);
  }
  .proc-table.sla-critico td, .proc-table tr.sla-critico { background: transparent; }
  .proc-table tr.sla-critico { border-color: rgba(224,120,86,0.55); box-shadow: inset 3px 0 0 var(--red); }
  .proc-table tr.aprov-completo { box-shadow: inset 3px 0 0 var(--green); }
  .proc-table td { padding: 4px 0; border: none; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
  .proc-table td::before {
    content: attr(data-label); color: var(--paper-faint); font-size: 11px;
    text-transform: uppercase; letter-spacing: 0.04em; flex: none;
  }
  .proc-table td .ell { max-width: 60vw; text-align: right; }
  /* Número do precatório como título do cartão */
  .proc-table td.cell-prec {
    box-shadow: none !important; display: block; padding: 0 0 8px;
    margin-bottom: 6px; border-bottom: 1px solid var(--line-soft);
  }
  .proc-table td.cell-prec::before { display: none; }
  .proc-table td.cell-prec strong { font-size: 13px; white-space: normal; }
  .proc-table td.num { font-family: var(--font-mono); }
  .proc-table td.sel-cell { display: none; }
  .proc-table.sel-mode td.sel-cell { display: flex; justify-content: flex-start; padding-bottom: 8px; }
  .proc-table.sel-mode td.sel-cell::before { content: "Selecionar"; }
  .pagination { flex-direction: column; gap: 10px; align-items: stretch; text-align: center; }
}

/* ============================================================
   Tema claro — ativado via [data-theme="light"] no <html>
   Override apenas das CSS vars + alguns pontos com cores rgba hardcoded.
   ============================================================ */
[data-theme="light"] {
  --ink-0: #ede6d4;
  --ink-1: #f4eedd;
  --ink-2: #fcf8ec;
  --ink-3: #f7f1e0;
  --ink-4: #ffffff;
  --line: #d6cdb4;
  --line-soft: #e7dfc8;
  --paper: #1a2520;
  --paper-dim: #4a544c;
  --paper-faint: #7a7f76;
  --brass: #9d7a35;
  --brass-bright: #b58a3f;
  --brass-dim: rgba(157, 122, 53, 0.10);
  --green: #2e8c4d;
  --green-dim: rgba(46, 140, 77, 0.10);
  --red: #c14b2a;
  --red-dim: rgba(193, 75, 42, 0.10);
  --amber: #a87a1c;
  --amber-dim: rgba(168, 122, 28, 0.10);
  --blue: #3b7090;
  --blue-dim: rgba(59, 112, 144, 0.10);
  --shadow: 0 6px 20px rgba(35, 40, 30, 0.10);
  color-scheme: light;
}

[data-theme="light"] body {
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(157, 122, 53, 0.05), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(46, 140, 77, 0.04), transparent 55%),
    var(--ink-1);
}

[data-theme="light"] ::selection { background: rgba(157, 122, 53, 0.25); color: var(--paper); }
[data-theme="light"] tbody tr.clickable:hover,
[data-theme="light"] tbody tr.rowlink:hover { background: rgba(157, 122, 53, 0.07); }

/* Badges de status — fundos um pouco mais saturados sobre claro */
[data-theme="light"] .st-cessao_assinada,
[data-theme="light"] .st-habilitacao,
[data-theme="light"] .st-aguardando_pagamento { color: #2e8c4d; border-color: rgba(46,140,77,0.35); background: rgba(46,140,77,0.10); }
[data-theme="light"] .st-adquirido { color: #2e8c4d; border-color: rgba(46,140,77,0.35); background: rgba(46,140,77,0.10); }
[data-theme="light"] .st-aprovado { color: #9d7a35; border-color: rgba(157,122,53,0.4); background: rgba(157,122,53,0.10); }
[data-theme="light"] .nv-ALTO { color: #2e8c4d; border-color: rgba(46,140,77,0.4); background: rgba(46,140,77,0.10); }
[data-theme="light"] .nv-BAIXO { color: #b86b2c; border-color: rgba(184,107,44,0.4); background: rgba(184,107,44,0.10); }
[data-theme="light"] .rec-APROVAR_COM_RESSALVAS { color: #2e8c4d; }

/* Sidebar com sutil contraste no claro */
[data-theme="light"] .sidebar { background: var(--ink-2); border-right: 1px solid var(--line); }

/* Botão de toggle do tema */
.theme-toggle {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 7px 10px; margin-top: 6px;
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  color: var(--paper-dim); font-family: var(--font-body); font-size: 12.5px;
  cursor: pointer; transition: all 0.15s;
}
.theme-toggle:hover { color: var(--brass-bright); border-color: var(--brass-dim); background: var(--brass-dim); }
.theme-toggle .ico-on { display: inline-flex; }
.theme-toggle .ico-off { display: none; }
[data-theme="light"] .theme-toggle .ico-on { display: none; }
[data-theme="light"] .theme-toggle .ico-off { display: inline-flex; }

/* ===== SLA ===== */
.sla-critico td { background: rgba(224, 120, 86, 0.10) !important; }
[data-theme="light"] .sla-critico td { background: rgba(196, 74, 42, 0.09) !important; }
@keyframes slaPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.badge.sla-alerta { animation: slaPulse 1.6s ease-in-out infinite; font-weight: 700; }

/* ===== Aprovação completa ===== */
.aprov-completo td { background: rgba(95, 190, 133, 0.09) !important; }
[data-theme="light"] .aprov-completo td { background: rgba(46, 140, 77, 0.08) !important; }
.sla-critico td { background: rgba(224, 120, 86, 0.10) !important; }
[data-theme="light"] .sla-critico td { background: rgba(196, 74, 42, 0.09) !important; }

/* ===== Lista de precatórios compacta ===== */
.proc-table td { padding: 9px 10px; font-size: 13px; vertical-align: top; line-height: 1.45; }
.proc-table th { padding: 8px 10px; font-size: 11px; }
.proc-table .badge { font-size: 10px; padding: 2px 8px; }
.proc-table .cell-prec strong {
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  white-space: nowrap; letter-spacing: -0.2px;
}
.proc-table .cell-prec .muted { font-family: var(--font-mono); font-size: 11px; white-space: nowrap; }
.proc-table .ell {
  display: block; max-width: 200px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.proc-table td.num { white-space: nowrap; }

/* ===== Timeline de status ===== */
.status-timeline { display: flex; align-items: flex-start; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-soft); overflow-x: auto; }
.tl-step { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 110px; text-align: center; }
.tl-dot {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  border: 2px solid var(--line); color: var(--paper-faint); background: transparent;
}
.tl-label { font-size: 11.5px; font-weight: 600; letter-spacing: 0.2px; }
.tl-date { font-size: 11px; font-family: var(--font-mono); color: var(--paper-faint); }
.tl-line { flex: 1; height: 2px; background: var(--line); margin-top: 13px; min-width: 24px; }
.tl-done .tl-dot { background: var(--green-dim); border-color: var(--green); color: var(--green); }
.tl-done .tl-label { color: var(--green); }
.tl-atual .tl-dot { background: var(--brass-dim); border-color: var(--brass-bright); color: var(--brass-bright); box-shadow: 0 0 0 4px rgba(201,168,106,0.15); }
.tl-atual .tl-label { color: var(--brass-bright); }
.tl-futuro .tl-label, .tl-futuro .tl-date { color: var(--paper-faint); opacity: 0.55; }
.tl-recusado .tl-dot { background: var(--red-dim); border-color: var(--red); color: var(--red); }
.tl-recusado .tl-label { color: var(--red); }
[data-theme="light"] .tl-done .tl-dot { background: rgba(46,140,77,0.10); border-color: #2e8c4d; color: #2e8c4d; }
[data-theme="light"] .tl-done .tl-label { color: #2e8c4d; }

/* ===== Banner de aviso (senha fraca) ===== */
.banner-aviso {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: rgba(224, 181, 86, 0.12); border: 1px solid rgba(224, 181, 86, 0.45);
  color: var(--amber); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px;
  font-size: 13.5px;
}
.banner-aviso a { color: var(--brass-bright); font-weight: 700; }
.banner-aviso button { margin-left: auto; }
[data-theme="light"] .banner-aviso { background: rgba(157, 122, 53, 0.08); color: #7a5c1e; }

/* ===== KPIs editáveis (aba Valores) ===== */
.kpi-editavel { position: relative; }
.kpi-editavel .edit-flag { color: var(--brass-bright); font-size: 11px; opacity: 0.7; }
.kpi-editavel .value { display: flex; align-items: baseline; gap: 6px; }
.kpi-prefix { font-size: 14px; color: var(--paper-faint); font-family: var(--font-mono); }
.kpi-input {
  width: 100%; min-width: 0; background: transparent; border: none;
  border-bottom: 1px dashed var(--line); border-radius: 0;
  font-family: var(--font-mono); font-size: 21px; font-weight: 600;
  color: var(--ink); padding: 0 0 2px; outline: none;
  -moz-appearance: textfield; appearance: textfield;
}
.kpi-input::-webkit-outer-spin-button, .kpi-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.kpi-input:focus { border-bottom-color: var(--brass-bright); }
.kpi-editavel:hover { box-shadow: 0 0 0 1px rgba(201, 168, 106, 0.35) inset; }

/* ===== Operações (vínculos) ===== */
.grupo-panel {
  margin-top: 14px; padding: 12px 14px; border: 1px solid rgba(201, 168, 106, 0.4);
  border-radius: 12px; background: rgba(201, 168, 106, 0.05);
}
.grupo-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.grupo-chip {
  display: flex; flex-direction: column; gap: 1px; min-width: 150px;
  padding: 8px 11px; border: 1px solid var(--line); border-radius: 10px;
  text-decoration: none; color: var(--ink); font-size: 12px; background: var(--card);
  transition: border-color 0.15s;
}
.grupo-chip:hover { border-color: var(--brass-bright); }
.grupo-chip.atual { border-color: var(--brass-bright); box-shadow: 0 0 0 1px var(--brass-bright) inset; }
.grupo-chip strong { font-family: var(--font-mono); font-size: 11.5px; }
.grupo-chip .papel { color: var(--brass-bright); font-size: 10.5px; font-weight: 600; }
.grupo-chip .mono-v { font-size: 12px; }

/* ===== Seleção para vincular na lista ===== */
.proc-table .sel-cell { display: none; width: 30px; padding: 9px 4px 9px 10px; }
.proc-table.sel-mode .sel-cell { display: table-cell; }
.proc-table.sel-mode tr.rowlink { cursor: copy; }
.sel-proc { width: 16px; height: 16px; accent-color: var(--brass-bright); cursor: pointer; }
.grupo-chip .papel-sel {
  margin-top: 4px; font-size: 10.5px; padding: 2px 4px;
  background: transparent; color: var(--brass-bright);
  border: 1px solid var(--line); border-radius: 6px; max-width: 100%;
}

/* ===== Visão de pastas (Documentos) ===== */
details.doc-folder { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
details.doc-folder summary {
  cursor: pointer; font-weight: 700; font-size: 13.5px; color: var(--brass-bright);
  list-style: none; user-select: none;
}
details.doc-folder summary::-webkit-details-marker { display: none; }
details.doc-folder summary::before { content: '▸ '; color: var(--paper-faint); }
details.doc-folder[open] summary::before { content: '▾ '; }
details.doc-folder .doc-folder-body { padding-left: 14px; }

/* ===== Editor de experts de IA (Auditoria) ===== */
.exp-card {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; margin-bottom: 12px; background: var(--ink-2);
}
.exp-card .exp-tit { background: var(--ink-3); }
.exp-card textarea.exp-persona { background: var(--ink-4); border: 1px solid var(--line); border-radius: 8px; padding: 10px; color: var(--paper); }
.exp-card code { font-family: var(--font-mono); font-size: 11px; color: var(--brass-bright); }

/* ===== Assistente de prompt (editor de experts) ===== */
.exp-assist { border-top: 1px dashed var(--line); padding-top: 10px; }
.exp-assist .exp-instr { background: var(--ink-3); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; color: var(--paper); }

/* ===== Evidência do checklist (documento que deu o OK) ===== */
.dd-item .dd-lab { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dd-evid { font-size: 11.5px; color: var(--brass-bright); text-decoration: none; max-width: 42ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-evid:hover { text-decoration: underline; }

/* ===== Alertas de risco ===== */
.alerta-card { background: var(--ink-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }

/* ===== Dica abaixo de campos do formulário ===== */
.field-hint { display: block; margin-top: 4px; font-size: 11px; color: var(--paper-dim); line-height: 1.4; }

/* ===== Comprovante na aba Dados ===== */
.comprov-box { border: 1px dashed var(--line); border-radius: 10px; padding: 10px; background: var(--ink-2); }

/* ===== Calculadora de base de aquisição ===== */
.aq-calc { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--ink-2); }
.aq-line { display: flex; justify-content: space-between; gap: 16px; font-size: 13px; padding: 3px 0; }
.aq-line span { color: var(--paper-dim); }

/* ===== Composição do crédito (aba Valores) ===== */
.comp-grid { display: flex; flex-direction: column; gap: 2px; }
.comp-line { display: flex; justify-content: space-between; gap: 16px; font-size: 13.5px; padding: 5px 2px; }
.comp-line span { color: var(--paper-dim); }
.comp-line.comp-strong { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 9px 2px; font-size: 15px; }
.comp-line.comp-strong span { color: var(--paper); }
.comp-line.comp-suc { font-style: italic; opacity: .9; }
