:root {
  --bg: #11140f;
  --bg-2: #1a1f18;
  --ink: #f3efe4;
  --muted: #b7b2a4;
  --line: #2c3328;
  --accent: #c4a35a;
  --accent-2: #8f6b2a;
  --good: #7d9a6c;
  --warn: #c9844a;
  --bad: #b85c4a;
  --card: #1c2219;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Segoe UI", "Helvetica Neue", sans-serif;
}
[data-brand="caep"] {
  --bg: #0f1418;
  --bg-2: #171e24;
  --ink: #eef3f6;
  --muted: #9aadb8;
  --line: #2a3842;
  --accent: #d08a4c;
  --accent-2: #8d5a2e;
  --card: #1a242c;
}
[data-brand="sentient"] {
  --bg: #12151c;
  --bg-2: #1a1f2a;
  --ink: #eef1f6;
  --muted: #a4adc0;
  --line: #2b3344;
  --accent: #7ea48a;
  --accent-2: #3f6b52;
  --card: #1c2230;
}
* { box-sizing: border-box; }
html, body, #root { min-height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(196,163,90,0.12), transparent 50%), var(--bg);
  color: var(--ink);
  font-family: var(--sans);
}
a { color: inherit; }
button, input, select, textarea { font: inherit; }
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.nav {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 28px 20px;
}
.brand-mark {
  font-family: var(--serif);
  font-size: 28px;
  letter-spacing: -0.03em;
  margin: 0 0 4px;
}
.brand-sub { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.14em; }
.nav a, .nav button.linkish {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  color: var(--ink);
  text-decoration: none;
  padding: 10px 0;
  cursor: pointer;
}
.nav a.active { color: var(--accent); }
.nav-group { margin: 2px 0 4px; }
.nav-sub { padding: 2px 0 8px 14px; border-left: 1px solid var(--line); margin: 0 0 4px 2px; }
.nav-sub a { padding: 6px 0; font-size: 13px; color: var(--muted); }
.nav-sub a.active { color: var(--accent); }
.main { padding: 32px 40px 80px; }
.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 28px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; margin: 0 0 8px; }
.muted { color: var(--muted); }
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.table-wrap { overflow: auto; }
.excel-toolbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 12px; }
.excel-toolbar .muted { margin: 0; flex: 1; }
.excel-wrap { max-height: 70vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.excel-wrap table { font-size: 12px; }
.excel-wrap th, .excel-wrap td { padding: 6px 8px; }
.excel-wrap thead th { position: sticky; top: 0; background: var(--card); z-index: 2; }
.excel-wrap th.sticky, .excel-wrap td.sticky { position: sticky; left: 0; background: var(--card); z-index: 1; }
.excel-wrap thead th.sticky { z-index: 3; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: rgba(255,255,255,0.03); }
.btn {
  background: var(--accent);
  color: #16140e;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
}
.btn.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--bad); color: white; }
.btn:disabled, .btn[disabled] {
  background: #3a3a3a;
  color: #8a8a8a;
  cursor: not-allowed;
  opacity: 0.7;
}
input:disabled, select:disabled { opacity: 0.55; cursor: not-allowed; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
input, select {
  width: 100%;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login .card { width: min(440px, 100%); }
.pill {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--muted);
}
.tabs { display: flex; gap: 8px; margin: 18px 0; }
.tabs button { background: none; border: 1px solid var(--line); color: var(--ink); border-radius: 999px; padding: 8px 12px; cursor: pointer; }
.tabs button.on { background: var(--accent); color: #16140e; border-color: var(--accent); }
.chart { width: 100%; height: 180px; }
.chart.tall { height: 360px; }
.chart-wrap { position: relative; color: var(--accent); }
.chart-tip {
  position: absolute;
  transform: translate(-50%, -120%);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow);
}
.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 18px;
}
.range-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.range-btns button {
  background: none;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}
.range-btns button.on { background: var(--accent); color: #16140e; border-color: var(--accent); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
.impersonation { padding: 10px 0; border-top: 1px solid var(--line); }
.stmt { display: grid; gap: 16px; }
.stmt-head-top, .stmt-head-main { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.stmt-head-top { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.stmt-head-main > div:first-child { flex: 1; min-width: 0; }
.stmt-email-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; min-width: 0; }
.stmt-email { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; }
.stmt-fee-class { text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.stmt-due { text-align: right; flex: 0 0 auto; }
.stmt-due-box {
  margin-top: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  white-space: nowrap;
}
.stmt-months td:not(:first-child), .stmt-kv-row span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.stmt-month-bar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.stmt-month-bar .btn { height: 38px; }
.stmt-scroll { max-height: 292px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; margin-top: 12px; }
.stmt-scroll thead th { position: sticky; top: 0; background: var(--card); z-index: 1; }
.month-year { display: grid; grid-template-columns: 1fr 5.5rem; gap: 8px; }
tr.on { background: rgba(196,163,90,0.12); }
.stmt-two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stmt-kv-head, .stmt-kv-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.stmt-kv-head { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.stmt-kv-row.bold { font-weight: 700; }
.stmt-kv-row.italic { font-style: italic; color: var(--muted); }
.stmt-kv-row.right span:first-child { text-align: right; }
.stmt-kv-row.split { border-bottom-width: 2px; border-bottom-color: var(--ink); }
.stmt-glossary { color: var(--muted); font-size: 12px; margin-top: 14px; line-height: 1.45; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px 18px; margin-top: 10px; font-size: 12px; }
.chart-tip-wide { min-width: 240px; }
.handoff { margin-top: 16px; }
.handoff-csv {
  margin: 6px 0;
  padding: 10px 12px;
  overflow-x: auto;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  white-space: pre;
}
.err { color: var(--bad); }
.ok { color: var(--good); }
.money-cell { text-align: right; }
.money-cell .sub { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.chip {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  letter-spacing: 0.04em;
}
.chip.ok { color: var(--good); border-color: rgba(125, 154, 108, 0.45); }
.chip.fail { color: var(--bad); border-color: rgba(184, 92, 74, 0.45); }
.chip.warn { color: var(--warn); border-color: rgba(201, 132, 74, 0.45); }
.chip.info { color: var(--accent); border-color: rgba(196, 163, 90, 0.45); }
.chip.neutral, .chip.muted { color: var(--muted); }
.note {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}
.note.warn { color: var(--warn); }
.note.fail { color: var(--bad); }
.note.ok { color: var(--good); }
.note.info { color: var(--ink); }
.hist { font-size: 12px; }
.hist th, .hist td { padding: 6px 8px; }
.hist td.num, .hist th.num { text-align: right; font-variant-numeric: tabular-nums; }
.hist .indent { color: var(--muted); padding-left: 18px; }
.heat-grid { overflow: auto; }
.heat-grid table { font-size: 11px; }
.heat-grid th, .heat-grid td { padding: 4px 6px; }
.heat-grid td.heat { text-align: right; font-variant-numeric: tabular-nums; }
.coin-row { cursor: pointer; }
.coin-row:hover { background: rgba(255,255,255,0.03); }
.coin-detail { padding: 12px 8px 18px; background: var(--bg); }
.spark-stack { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.spark-card { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.spark-card .muted { font-size: 11px; margin-bottom: 4px; }
.jump-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.jump-cards .card { cursor: pointer; }
.jump-cards .card:hover { border-color: var(--accent); }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .stats, .form-grid, .filters, .stmt-two, .stmt-head-top, .stmt-head-main, .jump-cards, .spark-stack { grid-template-columns: 1fr; }
  .stmt-head-top, .stmt-head-main { display: grid; }
  .stmt-due { text-align: left; }
  .main { padding: 20px; }
}
