/* Paleta Sicredi (manual de identidade oficial):
   Verde Sicredi #64C832 (Pantone 361 C) — destaques e barras de progresso
   Verde escuro  #146E37 (Pantone 7733 C) — botões, links e itens ativos no tema claro */

:root {
  --bg: #f3f6f1;
  --surface: #ffffff;
  --surface-2: #f7faf6;
  --text: #17251b;
  --muted: #5b6b5f;
  --border: #e1e8df;
  --accent: #146e37;
  --accent-hover: #0f5a2c;
  --on-accent: #ffffff;
  --brand: #64c832;
  --brand-soft: #e9f7e3;
  --red: #b42318;
  --red-soft: #fdecea;
  --yellow: #8a5a00;
  --yellow-soft: #fdf4dc;
  --info: #2a5fa8;
  --info-soft: #e7effa;
  --shadow: 0 1px 2px rgba(16, 24, 20, 0.05), 0 2px 8px rgba(16, 24, 20, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1410;
    --surface: #151e18;
    --surface-2: #1a251e;
    --text: #e6efe6;
    --muted: #98aa9c;
    --border: #26332a;
    --accent: #64c832;
    --accent-hover: #7ed64a;
    --on-accent: #0d1a0f;
    --brand: #64c832;
    --brand-soft: #17301f;
    --red: #ff8a80;
    --red-soft: #3a1f1d;
    --yellow: #f5c04a;
    --yellow-soft: #33290f;
    --info: #8ab4f8;
    --info-soft: #172a44;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

:root[data-theme="dark"] {
  --bg: #0d1410;
  --surface: #151e18;
  --surface-2: #1a251e;
  --text: #e6efe6;
  --muted: #98aa9c;
  --border: #26332a;
  --accent: #64c832;
  --accent-hover: #7ed64a;
  --on-accent: #0d1a0f;
  --brand: #64c832;
  --brand-soft: #17301f;
  --red: #ff8a80;
  --red-soft: #3a1f1d;
  --yellow: #f5c04a;
  --yellow-soft: #33290f;
  --info: #8ab4f8;
  --info-soft: #172a44;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */

.app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.brand strong { display: block; font-size: 14px; }
.brand small { color: var(--muted); font-size: 12px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  text-align: left;
  font-weight: 550;
}

.nav button:hover { background: var(--surface-2); color: var(--text); }

.nav button.active {
  background: var(--brand-soft);
  color: var(--accent);
}

.nav .count:empty { display: none; }

.nav-grupo {
  margin: 14px 10px 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.nav-grupo:first-child { margin-top: 0; }

.nav .count {
  margin-left: auto;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--border);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 8px; }
.sidebar-foot .nav-config { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; background: none; color: var(--muted); font: inherit; border-radius: var(--radius-sm); cursor: pointer; text-align: left; }
.sidebar-foot .nav-config:hover { background: var(--surface-2); color: var(--text); }
.sidebar-foot .nav-config.active { background: var(--brand-soft); color: var(--accent); }
.nav button.nav-config-mobile { display: none; }

.content { min-width: 0; }

.pagebar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 32px 18px;
}

.pagebar-title p { margin-top: 4px; }
.pagebar-actions { display: flex; gap: 8px; }

main { padding: 0 32px 40px; }

.view { display: none; }
.view.active { display: block; }

/* ---------- ícones (SVG inline) ---------- */

.ico {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- botões e campos ---------- */

button.primary, button.ghost, button.danger, .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 550;
  white-space: nowrap;
}

button.small { height: 30px; padding: 0 10px; font-size: 13px; }

.btn-link {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-weight: 550;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}

.btn-link:hover { background: var(--brand-soft); }

.sidebar-foot .btn-link { height: 32px; color: var(--muted); }
.sidebar-foot .btn-link:hover { color: var(--accent); }

button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.ghost:hover, .icon-btn:hover { background: var(--surface-2); }
button.danger { color: var(--red); background: transparent; }
button.danger:hover { background: var(--red-soft); }

.icon-btn { width: 36px; padding: 0; border: 0; background: none; color: var(--muted); font-size: 16px; }

input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

textarea { resize: vertical; min-height: 84px; }

/* ---------- barra de filtros ---------- */

.filterbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }

.search { position: relative; flex: 1; min-width: 220px; display: block; }
.search .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 38px; }

.filterbar select { width: auto; min-width: 200px; }

/* ---------- cards e tabelas ---------- */

.card, .table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card { padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head .muted { font-size: 12px; }

.table-card { overflow: auto; max-height: calc(100vh - 230px); }

table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 11px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
}

tbody tr { cursor: pointer; transition: background 0.1s; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.strong { font-weight: 600; }
td.wrap { white-space: normal; min-width: 220px; max-width: 360px; }

/* ---------- badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 550;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--brand-soft); color: var(--accent); border-color: transparent; }
.badge.warn { background: var(--yellow-soft); color: var(--yellow); border-color: transparent; }
.badge.bad { background: var(--red-soft); color: var(--red); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.neutral { background: var(--surface-2); color: var(--muted); }
.badge.off { background: transparent; color: var(--muted); }

/* ---------- estados vazios ---------- */

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); margin-bottom: 4px; font-size: 15px; }

/* ---------- painel ---------- */

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }

.kpi {
  position: relative;
  padding: 18px 18px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.kpi.red::before { background: var(--red); }
.kpi.yellow::before { background: var(--yellow); }
.kpi.info::before { background: var(--info); }

.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 550; }
.kpi .value { margin-top: 6px; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .sub { margin-top: 2px; color: var(--muted); font-size: 12.5px; }

.meter { height: 8px; margin-top: 12px; border-radius: 999px; background: var(--border); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--brand); transition: width 0.4s ease; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.seg button {
  border: 0;
  background: none;
  padding: 5px 10px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 550;
  white-space: nowrap;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg button .n { color: var(--muted); margin-left: 4px; font-variant-numeric: tabular-nums; }

.alerts { display: flex; flex-direction: column; gap: 6px; max-height: 480px; overflow: auto; margin: 0 -6px; padding: 0 6px; }

.alert {
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px 10px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s;
}

.alert:hover { background: var(--surface-2); }
.alert .bar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--yellow); }
.alert.vermelho .bar { background: var(--red); }
.alert .title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert .meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.alert.summary { background: var(--info-soft); }
.alert.summary .bar { background: var(--info); }

.ramo { padding: 10px 0; border-bottom: 1px solid var(--border); }
.ramo:last-child { border-bottom: 0; padding-bottom: 0; }
.ramo .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ramo .name { font-weight: 600; }
.ramo .pct { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); }
.ramo .sub { color: var(--muted); font-size: 12.5px; margin: 2px 0 8px; }

.next { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 6px; border-radius: var(--radius-sm); cursor: pointer; }
.next:hover { background: var(--surface-2); }

.date-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 0;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  line-height: 1.1;
}
.date-chip b { font-size: 18px; font-variant-numeric: tabular-nums; }
.date-chip span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* ---------- diálogo de formulário ---------- */

dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

dialog::backdrop { background: rgba(10, 20, 14, 0.45); backdrop-filter: blur(2px); }

#form { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }

.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 14px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { font-size: 17px; }

.dialog-body { padding: 6px 22px 18px; overflow: auto; }

.form-section { padding: 16px 0 6px; }
.form-section + .form-section { border-top: 1px solid var(--border); }
.form-section h3 { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > span { font-size: 12.5px; font-weight: 550; color: var(--muted); }
.field > span .req { color: var(--red); }
.field .msg { font-size: 12px; color: var(--red); min-height: 0; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--red); }

.field.check { flex-direction: row; align-items: center; gap: 10px; }
.field.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.field.check span { color: var(--text); font-size: 13.5px; font-weight: 500; }

.form-alert {
  margin: 0 22px 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--red-soft);
  color: var(--red);
  font-size: 13px;
}

.dialog-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 14px 14px;
}

.spacer { flex: 1; }

/* ---------- notificações ---------- */

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }

.toast {
  min-width: 240px;
  max-width: 380px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
  font-weight: 550;
  animation: toast-in 0.2s ease;
}

.toast.error { background: var(--red); color: #fff; }
.toast.ok { background: var(--accent); color: var(--on-accent); }
.toast.aviso { background: #8a5a00; color: #fff; }

@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.muted { color: var(--muted); }
.error { color: var(--red); }

/* ---------- marca (logo Quesito) ---------- */

.brand-logo { width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0; }
.login-logo { width: 52px; height: 52px; border-radius: 14px; }

/* ---------- tela de login ---------- */

.link-btn {
  align-self: center;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 550;
  padding: 4px 6px;
  border-radius: 6px;
}

.link-btn:hover { text-decoration: underline; }

.form-ok {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  color: var(--accent);
  font-size: 13px;
}

/* medidor de força da senha */
.forca { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: -4px; }
.forca span { height: 6px; border-radius: 999px; background: var(--border); transition: background 0.2s; }
.forca[data-nivel="1"] span:nth-child(-n+1) { background: var(--red); }
.forca[data-nivel="2"] span:nth-child(-n+2) { background: var(--yellow); }
.forca[data-nivel="3"] span:nth-child(-n+3) { background: var(--brand); }
.forca[data-nivel="4"] span { background: var(--accent); }
.forca-texto { font-size: 12.5px; margin-top: -6px; }

.regras { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.regras li { display: flex; align-items: center; gap: 8px; }
.regras li::before { content: "○"; width: 14px; text-align: center; color: var(--border); }
.regras li.ok { color: var(--accent); }
.regras li.ok::before { content: "✓"; color: var(--accent); font-weight: 700; }

/* ---------- tela de login ---------- */

/* ---------- configurações ---------- */

.config-grid { display: grid; gap: 14px; max-width: 760px; }
.config-card { padding: 18px; }
.config-card h2 { margin-bottom: 4px; }
.config-card > .muted { margin-bottom: 10px; }
.config-card .form-section { padding: 14px 0 4px; }
.config-card .form-section + .form-section { border-top: 1px solid var(--border); }
.config-card .form-section > .muted { margin: 2px 0 12px; }
.config-card .actions { margin-top: 12px; }

/* ---------- primeiro acesso ---------- */

.onboarding { max-width: 760px; }
.passos { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; counter-reset: passo; }
.passos li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.passos li > div { min-width: 0; }
.passos li p { margin: 2px 0 0; font-size: 13px; }
.passos li strong::before { counter-increment: passo; content: counter(passo) ". "; color: var(--accent); }

/* ---------- financeiro e honorários ---------- */

.fin-resumo { margin-bottom: 14px; }
.fin-resumo .kpis { margin-bottom: 0; }

.barras { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; align-items: end; height: 150px; }
.barra-mes { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.barra-mes .duas { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.barra-mes .b-rec, .barra-mes .b-des { width: 40%; min-height: 2px; border-radius: 4px 4px 0 0; }
.barra-mes .b-rec { background: var(--brand); }
.barra-mes .b-des { background: var(--border); }
.barra-mes small { color: var(--muted); font-size: 11px; }

.calc { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.calc-form h2, .calc-result h2 { margin-bottom: 10px; }
.calc-form .form-grid { margin-top: 12px; }
.res-linha { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.res-linha.destaque { font-weight: 650; }
.res-linha.destaque strong { color: var(--accent); }
.avisos { margin: 14px 0 0; padding-left: 18px; color: var(--yellow); font-size: 13px; }

@media (max-width: 820px) {
  .calc { grid-template-columns: 1fr; }
  .barras { height: 120px; gap: 3px; }
}

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login[hidden] { display: none; }

.login-card {
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card h1 { font-size: 20px; }
.login-card .field > span { font-size: 12.5px; }
.login-card button.primary { height: 40px; margin-top: 4px; }
.app[hidden] { display: none; }

/* ---------- cofre de certidões (anexos) ---------- */

.anexo-drop {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.anexo-drop:hover { border-color: var(--accent); color: var(--accent); }
.anexo-drop > span { font-weight: 550; color: var(--accent); white-space: nowrap; }
/* O input nativo fica escondido; a área tracejada é o botão de verdade (acessível por teclado via label). */
.anexo-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
.anexo-drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.anexo-aviso { font-size: 12px; margin-top: 6px; }

.anexos { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

.anexo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 13px;
}

.anexo-nome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }

@media (max-width: 820px) {
  .anexo { grid-template-columns: minmax(0, 1fr) auto; }
  .anexo > .muted { grid-column: 1 / -1; }
}

/* ---------- responsivo ---------- */

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}

/* Barra lateral só some em telas de celular (abaixo de 700 px). Em janelas estreitas de computador, ela continua visível. */
@media (max-width: 700px) {
  /* minmax(0, …): sem isso, a coluna cresce com a barra de abas e a página fica mais larga que a tela */
  .app { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px 0;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-foot { display: none; }

  .nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 10px; scrollbar-width: none; }
  .nav button { width: auto; white-space: nowrap; padding: 8px 12px; min-height: 44px; }
  .nav button.nav-config-mobile { display: flex; }
  .nav .count { display: none; }
  .nav-grupo { display: none; }

  .pagebar { flex-direction: column; align-items: stretch; padding: 18px 16px 12px; }
  .pagebar-actions { justify-content: flex-end; }
  main { padding: 0 16px 32px; }

  .table-card { max-height: none; }
  .filterbar select { flex: 1 1 100%; width: 100%; min-width: 0; }
  .kpis { gap: 10px; }
  .kpi .value { font-size: 24px; }
  .form-grid { grid-template-columns: 1fr; }
  .toasts { left: 16px; right: 16px; bottom: 16px; }
  .toast { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Despesas por categoria (Financeiro) */
.cat-lista { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 12px; }
.cat-linha { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.cat-barra { height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
.cat-barra span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

/* Nomeações em cartões (celular) */
.cartoes { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.cartao { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; cursor: pointer; display: grid; gap: 6px; }
.cartao:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cartao-topo { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.cartao-prazo { font-size: 14px; }

/* Intimações do DJEN (Nomeações) */
.intimacoes { margin-top: 18px; }
.lista-intimacoes { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 10px; }
.lista-intimacoes li { border-top: 1px solid var(--border); padding-top: 10px; display: grid; gap: 4px; font-size: 14px; }
.intimacao-topo { display: flex; justify-content: space-between; gap: 10px; }

/* Alvos de toque no celular (44 px, recomendação para uso com o dedo) */
@media (max-width: 820px) {
  .primary, .ghost, .danger, .btn-link, .icon-btn { min-height: 44px; }
  input:not([type="checkbox"]):not([type="radio"]), select, textarea { min-height: 44px; }
}

/* Certidões (Documentos) */
.certidoes { margin-top: 18px; }
.lista-certidoes { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 12px; }
.lista-certidoes li { border-top: 1px solid var(--border); padding-top: 12px; display: grid; gap: 4px; font-size: 14px; }
.certidao-topo { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.lista-certidoes p { margin: 2px 0 6px; }

/* Centro documental (Documentos) */
.doc-resumo { display: grid; gap: 12px; margin-bottom: 14px; }
.doc-indicadores { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.doc-ind { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; display: grid; gap: 2px; }
.doc-ind strong { font-size: 20px; }
.doc-ind span { font-size: 12px; }
.acoes { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn-arquivo { cursor: pointer; display: inline-flex; align-items: center; }
.anexo.substituida { opacity: 0.7; }
@media (max-width: 820px) { .doc-indicadores { grid-template-columns: repeat(2, 1fr); } }

/* Lista de trabalho (Próximas ações) */
.next.acao { display: flex; align-items: center; gap: 12px; cursor: default; }
.acao-meta { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* Histórico da nomeação */
.historico { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; font-size: 14px; }
.historico li { border-top: 1px solid var(--border); padding-top: 8px; }

/* Memória do cálculo de prazo */
.memoria { margin: 10px 0; font-size: 14px; }
.memoria summary { cursor: pointer; font-weight: 600; }
.memoria ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 4px; }

/* Gestão da Perícia */
.pericia-lista { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-bottom: 16px; }
.pericia-cartao { text-align: left; display: grid; gap: 6px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); cursor: pointer; min-height: 44px; font: inherit; }
.pericia-cartao.ativo { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.pericia-indicadores { display: grid; gap: 2px; font-size: 13px; color: var(--muted); }
.pericia-abas { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.pericia-aba { min-height: 44px; padding: 8px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font: inherit; }
.pericia-aba.ativa { background: var(--surface-2, var(--surface)); color: var(--text); font-weight: 600; }
.pericia-itens { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.pericia-itens li { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.pericia-itens li > .muted, .pericia-itens li > .badge { grid-column: 2; justify-self: start; }
.pericia-itens li.concluida .link-item { text-decoration: line-through; color: var(--muted); }
.pericia-itens.historico li { grid-template-columns: auto auto 1fr; }
.link-item { background: none; border: 0; padding: 4px 0; text-align: left; color: var(--text); cursor: pointer; font: inherit; min-height: 44px; }
.laudo-texto, .laudo-texto-versao { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; line-height: 1.5; }
.laudo-texto-versao { white-space: pre-wrap; background: var(--surface-2, var(--surface)); padding: 12px; border-radius: 8px; max-height: 320px; overflow: auto; }
.laudo-versao { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.laudo-versao summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
@media (max-width: 640px) {
  .pericia-lista { grid-template-columns: 1fr; }
  .laudo-acoes { flex-direction: column; }
  .laudo-acoes button { width: 100%; }
}

/* Menu do celular: barra fixa com atalhos e a folha "Mais" com todas as seções. */
.tabbar, .folha, .folha-fundo { display: none; }
.folha[hidden], .folha-fundo[hidden], .tabbar[hidden] { display: none; }

@media (max-width: 700px) {
  .sidebar .nav { display: none; }
  main { padding-bottom: 96px; }

  .tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    gap: 2px;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
  }
  .tabbar button {
    flex: 1;
    min-width: 0;
    min-height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px 2px;
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 11px;
    cursor: pointer;
  }
  .tabbar button span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar button.active { color: var(--accent); background: var(--brand-soft); font-weight: 600; }

  .folha-fundo {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(0, 0, 0, 0.4);
  }
  .folha {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    max-height: 82vh;
    overflow-y: auto;
    padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.2);
  }
  .folha-topo { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
  .folha .folha-lista { flex-direction: column; overflow: visible; padding-bottom: 0; gap: 2px; }
  .folha .folha-lista button { width: 100%; min-height: 48px; }
  .folha .nav-grupo { display: block; margin: 14px 0 4px; }
  .folha .nav-grupo:first-child { margin-top: 0; }
  .folha .nav .count { display: none; }
}

/* Ajudas de campo e conferência do número CNJ */
.ajuda { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.cnj-ok { color: var(--accent); }
.cnj-aviso { color: #9a6700; }

/* Seções recolhidas do formulário (campos de uso raro) */
.form-section.recolhida > summary { cursor: pointer; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; min-height: 44px; display: flex; align-items: center; }
.form-section.recolhida[open] > summary { margin-bottom: 12px; }

/* Histórico de backups */
.historico-lista { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.historico-lista li { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.historico-lista li ul { flex-basis: 100%; padding-left: 16px; margin: 0; font-size: 12px; }

/* Agenda e prazos */
.agenda-barra { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.agenda-barra strong { margin-right: auto; }
.segmentado { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.segmentado button { min-height: 40px; padding: 0 14px; border: 0; background: var(--surface); color: var(--muted); font: inherit; cursor: pointer; }
.segmentado button[aria-pressed="true"] { background: var(--brand-soft); color: var(--accent); font-weight: 600; }
.agenda-vencidos { border: 1px solid #9a6700; border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.agenda-vencidos strong { color: #9a6700; }
.agenda-lista { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.agenda-item { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.agenda-item .link-item { min-height: 44px; }
.agenda-dia { padding: 12px 0; border-bottom: 1px solid var(--border); }
.agenda-dia h3 { font-size: 14px; margin: 0 0 6px; }
.agenda-grade { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
.agenda-cab { padding: 8px; font-size: 12px; color: var(--muted); text-align: center; border-bottom: 1px solid var(--border); }
.agenda-celula { min-height: 104px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.agenda-celula:nth-child(7n) { border-right: 0; }
.agenda-celula.fora { background: var(--surface-2, transparent); color: var(--muted); }
.agenda-celula.hoje .agenda-numero { background: var(--accent); color: #fff; border-radius: 999px; }
.agenda-numero { font-size: 12px; font-weight: 600; width: 24px; height: 24px; display: grid; place-items: center; }
.agenda-chip { text-align: left; font-size: 11px; padding: 3px 6px; border: 0; border-radius: 6px; background: var(--brand-soft); color: var(--accent); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: inherit; font-size: 11px; }
@media (max-width: 820px) {
  .agenda-barra strong { order: -1; width: 100%; margin-right: 0; }
}

/* Aviso do financeiro (receitas ligadas a nomeação) */
.aviso-financeiro { border: 1px solid #9a6700; border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; justify-content: space-between; }
.aviso-financeiro p { margin: 0; color: #9a6700; }

/* Modelos de documentos */
.modelos-lista { display: grid; gap: 10px; }
.modelo-cartao { display: grid; gap: 4px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; }
.modelo-cartao .ghost { justify-self: start; min-height: 44px; }
