:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17212f;
  --ink-soft: #667085;
  --line: #e4e8ee;
  --accent: #2563eb;
  --accent-soft: #eaf1ff;
  --good-bg: #eaf8f1; --good-ink: #18794e;
  --bad-bg: #fff0f0;  --bad-ink: #c93b42;
  --warn-bg: #fff7e6; --warn-ink: #a86308;
  --formula: #6b3fd4;
  --navy: #0f1d2e;
  --navy2: #17283d;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(15,29,46,.05), 0 8px 28px rgba(15,29,46,.04);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: row;
}
.spacer { flex: 1; }
.muted { color: var(--ink-soft); }
.hidden { display: none !important; }
[hidden] { display: none !important; }

.app-col { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; }

/* left nav */
#sidenav {
  width: 224px; flex-shrink: 0; background: var(--navy); color: #b9c5d2;
  display: flex; flex-direction: column; padding: 20px 14px; gap: 2px;
}
.nav-brand {
  height: 40px; display: flex; align-items: center; gap: 4px; padding: 0 6px 20px;
  font: 700 1rem -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: -.02em;
}
.nav-brand strong { color: #3b82f6; }
.nav-label {
  font-size: .68rem; letter-spacing: .09em; text-transform: uppercase; color: #647695;
  margin: 16px 9px 6px; font-family: "IBM Plex Sans Condensed", "Arial Narrow", sans-serif;
}
.nav-label:first-of-type { margin-top: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  min-height: 40px; background: none; border: 0; color: #b9c5d2; padding: 0 10px; border-radius: 6px;
  cursor: pointer; font-size: .84rem; font-family: inherit;
}
.nav-item:hover:not(:disabled) { background: #172b42; color: #fff; }
.nav-item.active { background: #244264; color: #fff; box-shadow: inset 3px 0 #5b91ff; }
.nav-item.arm { background: var(--warn-ink); color: #fff; }
.nav-item:disabled, .nav-item.disabled { opacity: .38; cursor: default; }
.nav-ico { width: 17px; height: 17px; display: inline-flex; align-items: center; justify-content: center; opacity: .9; flex-shrink: 0; }
.nav-ico svg { width: 17px; height: 17px; }
.nav-sep { height: 1px; background: #26374a; margin: 10px 4px; }
.nav-spacer { flex: 1; }
.nav-item.nav-danger { color: #e79aa0; }
.nav-item.nav-danger:hover:not(:disabled) { background: #3a2b2e; color: #fff; }
.nav-item.nav-danger.active { background: var(--bad-ink); color: #fff; }

/* danger zone (setup / restore) */
.danger-zone { border: 1px solid #f0c0c0; background: #fdf5f5; border-radius: 10px; padding: 14px 16px; }
.danger-zone h3 { margin: 0 0 6px; font-size: 14px; color: var(--bad-ink); display: flex; align-items: center; gap: 8px; }
.dz-tag { font-size: 9.5px; font-weight: 800; letter-spacing: .06em; background: var(--bad-ink); color: #fff; padding: 2px 6px; border-radius: 4px; }
.danger-zone > p { margin: 0 0 12px; font-size: 12px; color: var(--ink-soft); line-height: 1.55; max-width: 760px; }
.danger-zone input[type="file"] { display: block; margin-bottom: 10px; }
.danger-zone .confirm-check { margin: 0 0 10px; }

.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; row-gap: 6px;
  height: 60px; padding: 0 20px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 12;
}
.brand strong { font-size: 15px; }
.tag {
  margin-left: 8px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 600;
}
.stats { color: var(--ink-soft); font-size: .78rem; white-space: nowrap; }
#search {
  width: 240px; padding: 7px 10px 7px 30px; border: 1px solid #cfd5dd;
  border-radius: 6px; font-size: .8rem; background-color: #fff;
  background-repeat: no-repeat; background-position: 9px center; background-size: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237b8797' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
}
#search:focus { outline: none; border-color: #4f7fe5; box-shadow: 0 0 0 3px rgba(37,99,235,.09); }
#clientPicker {
  width: 190px; padding: 6px 10px; border: 1px solid var(--line);
  border-radius: 6px; font-size: 13px; background: #fff;
}
.btn {
  padding: 0 13px; height: 34px; border: 1px solid #d7dce3; border-radius: 6px;
  background: #fff; color: #344054; cursor: pointer; font-size: .8rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: #f7f9fc; border-color: #bac5d3; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 3px 10px rgba(37,99,235,.2); }
.btn.primary:hover { background: #1d55ce; }
.btn.danger { background: #fff; border-color: var(--bad-ink); color: var(--bad-ink); }
.btn.danger:hover { background: var(--bad-bg); }
input.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .02em; }
.ch-goto { width: 150px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 7px; font-size: 12.5px; }

/* KPI strip — two labelled rows, mockup-style cards with severity accent rails */
#kpis { padding: 16px 20px 4px; display: flex; flex-direction: column; gap: 8px; }
.kpi-row { display: grid; grid-template-columns: 70px 1fr; gap: 12px; align-items: stretch; }
.kpi-row-label {
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
  padding-left: 8px; font: 600 .76rem "IBM Plex Sans Condensed", "Arial Narrow", sans-serif;
  letter-spacing: .045em; color: #536174; line-height: 1.1;
}
.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 8px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 10px 13px 10px 15px; box-shadow: var(--shadow); min-height: 76px; min-width: 0;
}
.kpi.bad { border-left: 3px solid var(--bad-ink); }
.kpi.warn { border-left: 3px solid var(--warn-ink); }
.kpi.good { border-left: 3px solid var(--good-ink); }
.kpi-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .045em; color: #697586;
}
.kpi-value { font: 700 1.05rem -apple-system, BlinkMacSystemFont, sans-serif; margin-top: 5px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .68rem; color: #7a8492; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(3, minmax(160px,1fr)); overflow-x: auto; } }
@media (max-width: 760px) { .kpi-row { grid-template-columns: 1fr; } .kpi-row-label { flex-direction: row; gap: 4px; padding: 2px 0; } .kpi-grid { display: flex; overflow-x: auto; } .kpi { min-width: 175px; } }

/* KPI report page */
.kpi-report-head { margin: 12px 0 4px; }
.kpi-report-head .kpi { display: inline-block; min-width: 300px; border-left-width: 4px; }
.kpi-report-head .kpi-value { font-size: 24px; }
.kpi-points { width: auto; min-width: 460px; margin: 10px 0 4px; }
.kpi-points .kp-total td { font-weight: 700; border-top: 2px solid var(--line); }
.kpi-points .kp-bad td:first-child { color: var(--bad-ink); font-weight: 600; }
.kpi-sub-h { margin: 20px 0 6px; font-size: 14px; }
.received-chart-wrap {
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 12px 4px; margin-bottom: 8px;
}
.received-chart { display: block; max-width: 100%; height: auto; }
.kpi-two-col { display: flex; gap: 16px; align-items: flex-start; margin-top: 8px; }
.kpi-panel {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px 16px; background: #fcfcfd;
}
.kpi-panel h3:first-child { margin-top: 0; }
@media (max-width: 1200px) { .kpi-two-col { flex-direction: column; } .kpi-panel { width: 100%; } }

/* rate emphasis — color-banded by severity */
.kpi-report-head { display: flex; flex-wrap: wrap; gap: 10px; }
.kpi-report-head .kpi-value { font-size: 32px; }
.kpi-report-head .kpi.rate-good { border-left-color: var(--good-ink); }
.kpi-report-head .kpi.rate-warn { border-left-color: var(--warn-ink); }
.kpi-report-head .kpi.rate-bad { border-left-color: var(--bad-ink); }

/* zebra striping for long, scannable tables (not the rep-sections table —
   its band/title rows already carry their own shading) */
.ci-table.zebra tbody tr:nth-child(even) td { background: #f7f8fa; }
.ci-table.zebra tbody tr:hover td { background: #eef4ff; }

.ci-table tfoot td { font-weight: 700; border-top: 2px solid var(--line); padding: 6px 12px; white-space: nowrap; }

/* KPI in-delay-by-representante sections */
.rep-sections tbody tr.rep-band td {
  background: #eef1f4; font-weight: 700; border-top: 2px solid var(--line);
  padding-top: 8px; padding-bottom: 8px;
}
.rep-sections tbody tr.rep-band:first-child td { border-top: 0; }
.rep-sections tbody tr.rep-title td:first-child { padding-left: 24px; }
.rep-sections tbody tr.rep-title td { color: var(--ink); background: #fff; }
.rep-sections tbody tr:hover td { background: #fff; }
.rep-sections tbody tr.rep-title:hover td { background: #f4f8ff; }

/* client header */
#clientHead { padding: 10px 12px 2px; display: flex; flex-direction: column; gap: 8px; }
.ch-top { display: flex; align-items: center; gap: 12px; }
.ch-top h2 { margin: 0; font-size: 17px; }
.ch-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11.5px; color: var(--ink-soft); }
#clientHead .kpi-grid { grid-template-columns: repeat(4, minmax(120px, 1fr)); }
.ch-timeline { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; }
.ch-timeline summary { cursor: pointer; font-size: 12px; font-weight: 600; }
.ch-timeline .timeline-list { margin-top: 8px; max-height: 260px; }

.toolbar-check { display: flex; align-items: center; gap: 5px; font-size: 12.5px; white-space: nowrap; }

main { flex: 1; overflow: hidden; padding: 14px 20px; display: flex; flex-direction: column; gap: 10px; }

/* quick-filter tabs (Receivables view only) — each just toggles state.filters
   on vencimento/legal + forces "Only not-paid", reusing the same grid query
   the column filter popovers already build; counts come from the already
   -loaded /api/kpis payload. See applyQuickTab() / renderQuickTabs(). */
.tabs {
  flex-shrink: 0; display: flex; align-items: center; gap: 22px; height: 46px;
  padding: 0 16px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.tab {
  background: none; border: 0; height: 100%; padding: 0 2px; display: flex; align-items: center; gap: 6px;
  color: #697586; font-size: .82rem; font-weight: 600; cursor: pointer; position: relative; font-family: inherit;
}
.tab span { font-size: .68rem; background: #eef1f4; color: #697586; padding: 2px 7px; border-radius: 9px; font-weight: 700; }
.tab:hover:not(.active) { color: #344054; }
.tab.active { color: #194b9e; }
.tab.active span { background: var(--accent-soft); color: var(--accent); }
.tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); }

.grid-wrap {
  flex: 1; min-height: 0; overflow: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
thead th {
  position: sticky; top: 0; z-index: 3; background: #f8f9fb;
  border-bottom: 1px solid var(--line); border-right: 1px solid var(--line);
  padding: 8px 10px; text-align: left; white-space: nowrap;
  font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; color: #687484;
  cursor: pointer; user-select: none;
}
thead tr.filters th { top: 33px; z-index: 2; cursor: auto; padding: 3px 6px; }
.filter-btn {
  width: 100%; min-width: 76px; padding: 2px 6px; font-size: 10.5px;
  border: 1px solid var(--line); border-radius: 5px; background: #fff;
  color: var(--ink-soft); cursor: pointer; text-align: left; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.filter-btn:hover { background: #f0f2f5; }
.filter-btn.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 600; }

.filter-pop {
  position: fixed; z-index: 60; width: 300px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.2);
  padding: 10px; font-size: 12px;
}
.fp-head { font-weight: 700; margin-bottom: 6px; }
.fp-range { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.fp-range input { flex: 1; padding: 4px 6px; border: 1px solid var(--line); border-radius: 5px; font-size: 12px; }
.fp-search { width: 100%; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 6px; }
.fp-list { max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.fp-item { display: flex; align-items: center; gap: 7px; padding: 3px 8px; cursor: pointer; }
.fp-item:hover { background: #f4f6f9; }
.fp-item input { width: auto; }
.fp-v { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fp-n { color: var(--ink-soft); font-variant-numeric: tabular-nums; font-size: 11px; }
.fp-note { font-size: 10.5px; margin: 5px 2px; }
.fp-actions { display: flex; gap: 6px; }
.fp-actions .btn { flex: 1; padding: 5px 6px; font-size: 11.5px; }

.client-link { color: var(--accent); text-decoration: none; }
.client-link:hover { text-decoration: underline; }

/* clients index page */
.clients-wrap { height: 100%; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.ci-bar { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.ci-bar h2 { margin: 0; font-size: 16px; }
.ci-bar input { padding: 6px 10px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; width: 260px; }
.ci-count { font-size: 11.5px; margin-bottom: 6px; }
.ci-table { width: 100%; border-collapse: collapse; }
.ci-table th {
  position: sticky; top: 0; background: #fbfcfd; text-align: left; padding: 7px 12px;
  border-bottom: 1px solid var(--line); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.ci-table td { padding: 6px 12px; border-bottom: 1px solid #eef1f4; white-space: nowrap; }
.ci-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.ci-table td.ci-bad { color: var(--bad-ink); }
.ci-table tbody tr { cursor: pointer; }
.ci-table tbody tr:hover td { background: #f4f8ff; }

/* percent input: value then % suffix */
.money-input.pct .pct-suf { border-right: 0; border-left: 1px solid var(--line); }

/* import / load page */
.import-wrap { height: 100%; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; }
.import-wrap > h2 { margin: 0 0 12px; font-size: 17px; }
.import-section { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; background: #fcfcfd; }
.import-section h3 { margin: 0 0 4px; font-size: 13.5px; }
.import-section > p { margin: 0 0 10px; font-size: 12px; }
.steps { display: flex; flex-direction: column; gap: 2px; }
.step { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(300px, 1.3fr); gap: 22px; padding: 14px 0; border-top: 1px solid var(--line); }
.step:first-child { border-top: 0; }
.step.step-wide { grid-template-columns: 1fr; gap: 8px; }
.step.step-wide .step-explain { max-width: 720px; }
.step-head { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.step-num { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; }
.step-explain p { margin: 0; font-size: 12px; color: var(--ink-soft); line-height: 1.5; }
.step-controls { font-size: 12.5px; }
.btn-row { display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.import-out { font-size: 12px; margin-top: 6px; }
.import-out .ok-line { color: var(--good-ink); font-weight: 600; }
.import-out details { margin-top: 6px; }
.import-out summary { cursor: pointer; }
.map-table { border-collapse: collapse; margin-top: 6px; font-size: 11.5px; }
.map-table td { padding: 2px 8px 2px 0; }
.tally { display: flex; flex-direction: column; gap: 5px; }
.tally-item { font-size: 12.5px; padding: 6px 10px; border-radius: 7px; background: #eef1f4; border-left: 3px solid var(--line); }
.tally-item b { font-size: 14px; }
.tally-item.good { background: var(--good-bg); border-left-color: var(--good-ink); }
.tally-item.warn { background: var(--warn-bg); border-left-color: var(--warn-ink); }
.preview-scroll { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 7px; margin: 8px 0; }
.preview-scroll .ci-table th { font-size: 11px; }
.preview-scroll .ci-table td { font-size: 11.5px; }
.erp-preview tbody tr { cursor: default; }
.erp-preview tbody tr:hover td { background: transparent; }
/* Import step 4 only — paid-at-issuance titles (Emissão = Vencimento), added
   already Paid instead of as a normal open title. Not used anywhere else. */
.erp-preview tbody tr.erp-paid-at-issuance td { background: var(--good-bg); }
.erp-preview input[type="checkbox"] { display: block; margin: 0 auto; }
.erp-preview tfoot td {
  position: sticky; bottom: 0; background: #f4f6f9; border-top: 2px solid var(--line);
  font-weight: 700; font-size: 12px;
}
.erp-foot-label { text-align: right; padding-right: 12px !important; }
.erp-foot-sum { color: var(--ink); white-space: nowrap; }

/* reconcile edit table */
.recon-table td { vertical-align: middle; }
.cell-in { width: 118px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; font-size: 11.5px; font-family: inherit; }
.cell-in.num { text-align: right; font-variant-numeric: tabular-nums; }
input.cell-in[type="date"] { width: 130px; }
.cell-computed {
  display: inline-block; width: 118px; padding: 3px 6px; text-align: right;
  font-variant-numeric: tabular-nums; font-size: 11.5px; border-radius: 5px;
  background: #f4f2fb; color: #6a6a7a; border: 1px solid var(--line);
}
.recon-table .step { padding-top: 14px; }
.confirm-check { display: flex; align-items: flex-start; gap: 7px; font-size: 12.5px; margin: 4px 0 2px; max-width: 560px; }
.confirm-check input { margin-top: 2px; }

.done-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--good-bg); color: var(--good-ink); border: 1px solid #bfe4cd;
  border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; font-weight: 600; font-size: 12.5px;
}
.done-x { border: 0; background: none; color: inherit; font-size: 16px; line-height: 1; cursor: pointer; padding: 0 4px; }
input[type="file"] { font-size: 12px; }
@media (max-width: 900px) { .step { grid-template-columns: 1fr; gap: 8px; } }
th .sort-ind { color: var(--accent); margin-left: 4px; font-size: 10px; }
th .kind { font-size: 9px; margin-left: 5px; padding: 0 4px; border-radius: 4px; vertical-align: middle; }
th .kind.f { background: #efe9fc; color: var(--formula); }
th .kind.c { background: #e3f1e8; color: var(--good-ink); }
th .kind.i { background: #eef1f4; color: var(--ink-soft); }

tbody td {
  padding: 8px 10px; border-bottom: 1px solid #edf0f3; border-right: 1px solid #eef1f4;
  white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; font-size: .78rem;
}
tbody tr:hover td { background: #f7faff; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.edit-cell { text-align: center; cursor: pointer; color: var(--accent); }
.col-pin {
  position: sticky; z-index: 1; background: var(--panel);
  box-shadow: 1px 0 0 var(--line);
}
.col-pin:nth-child(1) { left: 0; width: 34px; min-width: 34px; }
.col-pin:nth-child(2) { left: 34px; min-width: 118px; }
thead .col-pin { z-index: 4; background: #fbfcfd; }
tbody tr:hover .col-pin { background: #f7f9fc; }
td.timeline-cell { max-width: 340px; color: var(--ink-soft); font-style: italic; }

.pill { padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.pill.good { background: var(--good-bg); color: var(--good-ink); }
.pill.bad { background: var(--bad-bg); color: var(--bad-ink); }
.pill.warn { background: var(--warn-bg); color: var(--warn-ink); }

.statusbar {
  display: flex; align-items: center; gap: 0;
  padding: 0 16px; min-height: 46px; background: #f8fafc; border-top: 1px solid var(--line);
  font-size: 12px;
}
.statusbar { flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.pager select { padding: 3px 4px; }
.sums {
  display: flex; flex-wrap: wrap; font-variant-numeric: tabular-nums; justify-content: flex-end;
  margin-left: auto;
}
.sums span {
  white-space: nowrap; padding: 8px 14px; border-left: 1px solid #e3e7ed;
  display: flex; flex-direction: column; gap: 2px; font-size: .68rem;
  text-transform: uppercase; letter-spacing: .03em; color: #7c8796;
}
.sums span:first-child { border-left: 3px solid var(--accent); background: var(--accent-soft); color: #194f9e; border-radius: 4px 0 0 4px; }
.sums b { font-weight: 700; font-size: .82rem; text-transform: none; letter-spacing: 0; color: #273547; }
.sums span:first-child b { color: #194f9e; }

.editor-overlay {
  position: fixed; inset: 0; background: rgba(20,24,30,.35);
  display: flex; justify-content: center; align-items: flex-start; padding: 3vh 2vw; z-index: 50;
}
.editor-panel {
  background: var(--panel); border-radius: 10px; width: min(1100px, 100%);
  max-height: 94vh; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: -15px 0 40px rgba(9,22,38,.14), 0 20px 60px rgba(0,0,0,.2);
}
.editor-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.editor-title-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.editor-head #editorMeta { font-size: 12px; }
.editor-actions { display: flex; gap: 8px; }
.editor-body { padding: 12px 18px 22px; overflow: auto; }

.paid-badge { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; letter-spacing: .02em; }
.paid-badge.paid { background: var(--good-bg); color: var(--good-ink); }
.paid-badge.open { background: var(--bad-bg); color: var(--bad-ink); }

.save-confirm {
  margin: 10px 18px 0; padding: 10px 12px; background: #fff8e6;
  border: 1px solid #f0d98b; border-radius: 9px;
}
.sc-title { font-weight: 700; margin-bottom: 6px; }
.sc-list { display: flex; flex-direction: column; gap: 3px; max-height: 200px; overflow: auto; margin-bottom: 8px; }
.sc-row { font-size: 12px; }
.sc-from { color: var(--bad-ink); text-decoration: line-through; }
.sc-to { color: var(--good-ink); font-weight: 600; }
.sc-actions { display: flex; gap: 8px; }

.money-input { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff; }
.money-input.disabled { background: #f4f2fb; }
.money-pre { padding: 5px 6px 5px 8px; color: var(--ink-soft); font-size: 12px; background: #f4f6f9; border-right: 1px solid var(--line); }
.money-input input { border: none !important; border-radius: 0 !important; }
.money-input input:disabled { background: transparent; }
.group {
  background: #fcfcfd; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px 16px; margin-bottom: 14px;
}
.group:last-child { margin-bottom: 0; }
.group h3 {
  margin: 0 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.group h3, .timeline-panel h3 {
  font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--ink-soft);
}

/* Cobrança timeline — highlighted, pulled to the top of the editor */
.timeline-panel {
  background: #fffdf5; border: 1px solid #f0e2b8; border-radius: 10px;
  padding: 10px 14px 14px; margin-bottom: 6px;
}
.timeline-panel h3 { margin-top: 2px; color: #8a6d1d; }
.timeline-panel h3 .kt { margin-left: 7px; }
.tl-confirm { color: var(--bad-ink); font-size: 11px; }
.timeline-add { display: grid; grid-template-columns: 150px 1fr auto; gap: 8px; align-items: start; margin-bottom: 12px; }
.timeline-add textarea {
  width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px;
  font: inherit; resize: vertical;
}
.timeline-add input[type="date"] { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; }
.timeline-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow: auto; }
.tl-item { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
.tl-head { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.tl-date { font-weight: 600; font-size: 12px; font-variant-numeric: tabular-nums; }
.tl-origin { font-size: 9.5px; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 999px; }
.tl-origin.legacy { background: #eef1f4; color: var(--ink-soft); }
.tl-origin.user { background: var(--accent-soft); color: var(--accent); }
.tl-del { margin-left: auto; border: none; background: none; color: var(--ink-soft); cursor: pointer; font-size: 12px; padding: 2px 4px; }
.tl-del:hover { color: var(--bad-ink); }
.tl-text { font-size: 12.5px; white-space: pre-wrap; word-break: break-word; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px 16px; }
.field label { display: block; font-size: 11.5px; color: var(--ink-soft); margin-bottom: 3px; }
.field label .kt { font-size: 9px; padding: 0 4px; border-radius: 4px; margin-left: 5px; }
.field label .kt.f { background: #efe9fc; color: var(--formula); }
.field label .kt.c { background: #e3f1e8; color: var(--good-ink); }
.field label .kt.i { background: #eef1f4; color: var(--ink-soft); }
.field input, .field select {
  width: 100%; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 13px; background: #fff;
}
.field input:disabled { background: #f4f2fb; color: #6a6a7a; }
.field input[type="checkbox"] { width: auto; }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--navy2); color: #fff; padding: 11px 16px; border-radius: 7px;
  opacity: 0; transition: all .25s; pointer-events: none; z-index: 100; font-size: 12.5px;
  box-shadow: 0 8px 30px rgba(0,0,0,.18);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* topbar identity */
.whoami { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }

/* login overlay — a two-panel screen (brand story + form) that covers the
   whole app until a session exists. Left panel is copy-only, no live stats:
   there's no unauthenticated endpoint to source real portfolio numbers from,
   and this screen doesn't show anything we can't actually back today. */
.login-overlay {
  position: fixed; inset: 0; z-index: 200; background: var(--bg);
  display: grid; grid-template-columns: minmax(360px, 42%) 1fr; color: var(--ink);
}
.login-brand-panel {
  position: relative; overflow: hidden; background: #172331; color: #fff;
  padding: 38px 44px 34px; display: flex; flex-direction: column;
}
.login-brand-panel::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, transparent 8%, #000 52%, transparent 100%);
}
.login-brand-panel .login-brand { position: relative; z-index: 1; margin-bottom: 0; font-size: 1.05rem; font-weight: 650; }
.login-brand-panel .login-brand strong { color: #3d82f6; font-weight: 750; }
.login-brand-copy { position: relative; z-index: 1; max-width: 520px; margin: auto 0 54px; }
.login-kicker {
  margin: 0 0 14px; font: 600 .76rem "IBM Plex Sans Condensed", "Arial Narrow", sans-serif;
  letter-spacing: .11em; color: #8492a4;
}
.login-brand-copy .login-kicker { color: #75a6f7; }
.login-brand-copy h1 {
  margin: 0 0 18px; max-width: 480px; font-size: clamp(2.1rem, 3.3vw, 3.65rem);
  line-height: 1.04; letter-spacing: -.045em; font-weight: 620;
}
.login-brand-copy > p:last-child { margin: 0; max-width: 460px; color: #b9c4d0; font-size: 1rem; line-height: 1.6; }

.login-form-panel { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; background: var(--bg); }
.login-form { width: min(100%, 380px); }
.login-mobile-brand { display: none; margin-bottom: 40px; }
.login-form-head { margin-bottom: 22px; }
.login-form-head h2 { margin: 0 0 6px; font-size: 1.35rem; letter-spacing: -.02em; font-weight: 650; }
.login-form-head p:last-child { margin: 0; font-size: 12.5px; color: var(--ink-soft); }

.login-brand { font: 700 1rem -apple-system, BlinkMacSystemFont, sans-serif; letter-spacing: -.02em; }
.login-brand strong { color: #3b82f6; }

.login-field { display: block; margin-bottom: 14px; }
.login-field > span { display: block; margin-bottom: 5px; font-size: 11.5px; color: var(--ink-soft); }
.login-field input {
  box-sizing: border-box; display: block; width: 100%; height: 40px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 7px; font-size: 13.5px; font: inherit; background: #fff;
}
.login-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.login-submit { width: 100%; margin-top: 4px; padding: 9px; font-size: 13.5px; }
.login-msg { min-height: 16px; margin-top: 10px; font-size: 12px; color: var(--bad-ink); }

.login-legal {
  display: flex; justify-content: space-between; gap: 16px; width: min(100%, 380px);
  margin-top: 28px; color: #9aa4b2; font-size: 10.5px;
}

.totp-secret-box {
  background: #f4f6f9; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 12px;
}
.totp-row { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; font-size: 11px; }
.totp-row:last-child { margin-bottom: 0; }
.totp-row code {
  font-size: 12px; word-break: break-all; background: #fff; border: 1px solid var(--line);
  border-radius: 5px; padding: 4px 6px;
}

@media (max-width: 820px) {
  .login-overlay { grid-template-columns: 1fr; }
  .login-brand-panel { display: none; }
  .login-mobile-brand { display: block; font: 700 1.05rem -apple-system, BlinkMacSystemFont, sans-serif; }
  .login-mobile-brand strong { color: #3b82f6; }
  .login-form-panel { padding: 32px 22px; }
}
@media (max-width: 480px) {
  .login-form-panel { align-items: flex-start; justify-content: flex-start; padding-top: 34px; overflow-y: auto; }
  .login-mobile-brand { margin-bottom: 44px; }
  .login-legal { flex-wrap: wrap; }
}
