:root {
  --bg0: #0c1218;
  --bg1: #141c26;
  --ink: #e8ece8;
  --muted: #93a09a;
  --line: rgba(232, 236, 232, 0.12);
  --line-strong: rgba(232, 236, 232, 0.22);
  --panel: rgba(20, 28, 38, 0.72);
  --panel-solid: #171f2a;
  --accent: #3d9b84;
  --accent-2: #c4a574;
  --accent-ink: #06120f;
  --danger: #d9897a;
  --paper: #eef1ec;
  --paper-ink: #1a2220;
  --radius: 14px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --font-ui: "Manrope", system-ui, sans-serif;
  --font-display: "Instrument Serif", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font-ui);
  background: var(--bg0);
}

body {
  overflow-x: hidden;
}

.ambiance {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(61, 155, 132, 0.22), transparent 55%),
    radial-gradient(700px 420px at 90% 8%, rgba(196, 165, 116, 0.14), transparent 50%),
    linear-gradient(165deg, #0c1218 0%, #101820 45%, #0a1016 100%);
}

.ambiance::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  min-height: 100vh;
  max-width: 1440px;
  margin: 0 auto;
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px 20px 20px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(12, 18, 24, 0.55), rgba(12, 18, 24, 0.2));
  backdrop-filter: blur(10px);
  animation: rise 0.7s ease both;
}

.brand-logo {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 0 4px;
  border-radius: 12px;
  background: #000;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 4vw, 3.2rem);
  font-weight: 400;
  line-height: 0.95;
  letter-spacing: -0.02em;
}

.brand-mark {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.brand-sub {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.dropzone {
  display: grid;
  gap: 4px;
  padding: 18px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(61, 155, 132, 0.06);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s, background 0.2s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(61, 155, 132, 0.14);
  transform: translateY(-1px);
}

.dropzone strong { font-size: 14px; }
.dropzone span { color: var(--muted); font-size: 12px; line-height: 1.35; }
.dropzone input { display: none; }

.drop-icon {
  width: 28px;
  height: 28px;
  margin-bottom: 4px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, var(--accent), transparent 60%),
    linear-gradient(225deg, var(--accent-2), transparent 55%);
  opacity: 0.9;
}

.rail-head {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

.rail-head h2,
.panel h3,
.empty-state h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.35rem;
}

#busca-casos {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
  padding: 10px 12px;
  font: 500 13px/1.2 var(--font-ui);
}

.lista {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  flex: 1;
  min-height: 120px;
  padding-right: 2px;
}

.caso {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  color: inherit;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  font: inherit;
}

.caso:hover {
  border-color: var(--line-strong);
  background: rgba(61, 155, 132, 0.08);
}

.caso.active {
  border-color: rgba(61, 155, 132, 0.55);
  background: rgba(61, 155, 132, 0.14);
  box-shadow: inset 3px 0 0 var(--accent);
}

.caso strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
}

.caso .meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.rail-foot {
  display: grid;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.stage {
  padding: 28px 28px 48px;
  animation: rise 0.85s ease 0.08s both;
}

.stage-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-2);
}

#caso-titulo {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 400;
  line-height: 1.1;
}

.muted { color: var(--muted); font-size: 14px; }
.micro { font-size: 12px; color: var(--muted); line-height: 1.4; }
.hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }

.stage-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.empty-state {
  max-width: 520px;
  padding: 36px 0;
  animation: fade 0.8s ease both;
}

.empty-kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
}

.empty-state p:last-child {
  color: var(--muted);
  line-height: 1.55;
}

.workspace {
  display: grid;
  gap: 16px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  background: var(--panel);
  backdrop-filter: blur(14px);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.dialogue textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--ink);
  padding: 14px;
  font: 500 14px/1.5 var(--font-ui);
}

.dialogue textarea:focus,
#busca-casos:focus,
select:focus,
input:focus {
  outline: 2px solid rgba(61, 155, 132, 0.45);
  outline-offset: 1px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.switch input { accent-color: var(--accent); }

.group-label {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.action-groups { display: grid; gap: 16px; }

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.action-grid.primary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.action-grid.dense {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.action-grid .wide { grid-column: 1 / -1; }

button,
.file-btn {
  font: 600 13px/1.2 var(--font-ui);
  border: 0;
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
}

button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.1);
}

button.direct {
  background: rgba(61, 155, 132, 0.16);
  border-color: rgba(61, 155, 132, 0.35);
}

button.direct:hover {
  background: rgba(61, 155, 132, 0.28);
}

button.accent {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

button.accent:hover {
  filter: brightness(1.06);
}

button.ghost {
  background: transparent;
  color: var(--ink);
}

label.file-inline {
  display: inline-flex;
  align-items: center;
  margin: 0;
  font: 600 13px/1.2 var(--font-ui);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
}

label.file-inline:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.1);
}

button.block { width: 100%; }

button:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.prompts-box {
  margin-top: 12px;
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.45;
  max-height: 200px;
  overflow: auto;
  padding: 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  color: var(--muted);
}

.result .preview {
  margin: 0;
  max-height: min(58vh, 640px);
  overflow: auto;
  padding: 22px 24px;
  border-radius: 12px;
  background: var(--paper);
  color: var(--paper-ink);
  font-size: 14px;
  line-height: 1.65;
  white-space: normal;
  font-family: "Times New Roman", Times, serif;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
  animation: fade 0.45s ease both;
}
.result .preview p {
  margin: 0 0 0.7em;
  text-align: justify;
  text-indent: 1.25em;
}
.result .preview h4 {
  margin: 1em 0 0.4em;
  text-align: center;
  letter-spacing: 0.03em;
}
.result .preview button.fl,
.indice-item.fl {
  cursor: pointer;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  padding: 0;
}

.file-chips {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.status-line {
  min-height: 1.2em;
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.status-line.error { color: var(--danger); }
.status-line.ok { color: var(--accent); }

.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(12px);
  max-width: min(520px, 92vw);
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.busy {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(6, 10, 14, 0.55);
  backdrop-filter: blur(6px);
}

/* Sem isso, display:grid vence o atributo hidden e o overlay aparece ao abrir a página */
.busy[hidden] {
  display: none !important;
}

.busy-card {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 28px 32px;
  border-radius: 16px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  min-width: min(420px, 92vw);
  text-align: center;
}

.busy-steps {
  margin: 0;
  padding: 0 0 0 1.2em;
  text-align: left;
  width: 100%;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.busy-steps li.active {
  color: var(--accent);
  font-weight: 600;
}

.busy-steps li.done {
  color: var(--ink);
  opacity: 0.75;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
}

.chips button {
  padding: 8px 10px;
  font-size: 12px;
  border-radius: 999px;
}

.indice-lista {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.indice-item {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
}

.indice-item em {
  font-style: normal;
  color: var(--accent-2);
}

.fls-alerta {
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.4;
}

.extrato-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}

.extrato-grid label.span2 { grid-column: span 2; }

.extrato-grid input,
.cruzamento input,
.cruzamento select {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--ink);
  font: 500 13px var(--font-ui);
}

.table-wrap { overflow-x: auto; }

.cruzamento {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.cruzamento th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  padding: 6px 6px 8px;
}

.cruzamento td { padding: 4px 6px; vertical-align: top; }

.cruzamento tr.risco td { background: rgba(217, 137, 122, 0.08); }
.cruzamento tr.ok td { background: rgba(61, 155, 132, 0.08); }

@media (max-width: 800px) {
  .extrato-grid { grid-template-columns: 1fr; }
  .extrato-grid label.span2 { grid-column: auto; }
}

.checklist-wrap {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(61, 155, 132, 0.08);
}

.checklist {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.checklist li {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.4;
}

.checklist li span.tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent-2);
  min-width: 2.6em;
}

.checklist li.ok span.tag { color: var(--accent); }
.checklist li.no span.tag { color: var(--danger); }
.checklist li.na span.tag { color: var(--muted); }

.diff-wrap {
  margin: 0 0 14px;
}

.diff-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.diff-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.diff-pane {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  padding: 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  color: var(--muted);
}

.diff-pane .add { color: #7dcea0; }
.diff-pane .del { color: #e8a598; text-decoration: line-through; opacity: 0.85; }

@media (max-width: 800px) {
  .diff-cols { grid-template-columns: 1fr; }
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

dialog {
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 22px;
  width: min(460px, 92vw);
  background: var(--panel-solid);
  color: var(--ink);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(4, 8, 12, 0.65);
  backdrop-filter: blur(4px);
}

dialog h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.8rem;
}

label {
  display: block;
  margin: 14px 0;
  font-size: 13px;
  color: var(--muted);
}

select,
input[type="password"],
input[type="text"] {
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--ink);
  font: 500 14px var(--font-ui);
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 0 0;
  margin: 0;
}

a { color: var(--accent-2); }

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .lista { max-height: 220px; }
  .action-grid.dense { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage { padding: 20px 16px 40px; }
}

@media (max-width: 800px) {
  .prazo-box .contexto-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .prazo-box .contexto-row { grid-template-columns: 1fr; }
  .action-grid,
  .action-grid.primary,
  .action-grid.dense {
    grid-template-columns: 1fr;
  }
  .stage-top { flex-direction: column; }
}

.contexto-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.prazo-box .contexto-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.prazo-box { margin-bottom: 12px; }
.convidados-lista { margin: 8px 0 12px; padding-left: 18px; }
.convidados-lista li { margin: 6px 0; }
.prazo-resultado {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(196, 165, 116, 0.12);
  color: var(--ink);
  line-height: 1.45;
}
.contexto-row label { font-size: 12px; color: var(--muted); }
.contexto-row select, .contexto-row input { width: 100%; margin-top: 4px; }
.rail-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 4px 0 12px; }
.camadas-texto { white-space: pre-wrap; max-height: 220px; overflow: auto; font-size: 12px; line-height: 1.45; }
.disclaimer { margin: 0; padding: 8px 18px 16px; font-size: 12px; color: var(--muted); }
.juris-lista { display: grid; gap: 8px; margin: 8px 0 12px; }
.juris-card {
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(61, 155, 132, 0.08);
  border-left: 3px solid var(--accent);
}
.juris-card.cancelada, .juris-card.ausente { border-left-color: var(--danger); background: rgba(217, 137, 122, 0.1); }
.juris-card h4 { margin: 4px 0; font-size: 14px; }
.juris-card p { margin: 0 0 6px; font-size: 13px; line-height: 1.45; }
html[data-theme="light"] {
  --bg0: #f4f1ea;
  --bg1: #fffdf8;
  --ink: #1c241f;
  --muted: #5c6b64;
  --line: rgba(20, 30, 26, 0.12);
  --line-strong: rgba(20, 30, 26, 0.22);
  --panel: rgba(255, 253, 248, 0.92);
  --panel-solid: #fffdf8;
  --accent-ink: #f7f3ea;
  --shadow: 0 18px 40px rgba(40, 32, 20, 0.08);
}

