/* Equity Act Tracker */
:root {
  color-scheme: light;
  --page: #f6f6f3;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #7a7873;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.18);
  --accent: #256abf;
  --accent-ink: #ffffff;
  --accent-soft: #e6effb;
  --series: #2a78d6;
  --series-wash: rgba(42, 120, 214, 0.10);
  --danger: #b42727;
  --danger-soft: #fbeaea;
  --ok-ink: #006300;
  --focus: #2a78d6;

  --st-green: #0ca30c;
  --st-yellow: #fab219;
  --st-red: #d03b3b;
  --st-black: #0b0b0b;
  --st-green-bg: rgba(12, 163, 12, 0.13);
  --st-yellow-bg: rgba(250, 178, 25, 0.22);
  --st-red-bg: rgba(208, 59, 59, 0.13);
  --st-black-bg: #0b0b0b;
  --st-black-ink: #ffffff;
  --meter-track: #e8e7e2;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 2px 8px rgba(11, 11, 11, 0.04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --page: #0f0f0e;
    --surface: #1a1a19;
    --surface-2: #232321;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #8f8d86;
    --grid: #2c2c2a;
    --axis: #45443f;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);
    --accent: #3987e5;
    --accent-ink: #ffffff;
    --accent-soft: rgba(57, 135, 229, 0.16);
    --series: #3987e5;
    --series-wash: rgba(57, 135, 229, 0.14);
    --danger: #e66767;
    --danger-soft: rgba(230, 103, 103, 0.14);
    --ok-ink: #0ca30c;
    --focus: #6da7ec;
    --st-green-bg: rgba(12, 163, 12, 0.22);
    --st-yellow-bg: rgba(250, 178, 25, 0.22);
    --st-red-bg: rgba(208, 59, 59, 0.26);
    --st-black: #000000;
    --st-black-bg: #000000;
    --meter-track: #2c2c2a;
    --shadow: none;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;
    --page: #0f0f0e;
    --surface: #1a1a19;
    --surface-2: #232321;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #8f8d86;
    --grid: #2c2c2a;
    --axis: #45443f;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);
    --accent: #3987e5;
    --accent-ink: #ffffff;
    --accent-soft: rgba(57, 135, 229, 0.16);
    --series: #3987e5;
    --series-wash: rgba(57, 135, 229, 0.14);
    --danger: #e66767;
    --danger-soft: rgba(230, 103, 103, 0.14);
    --ok-ink: #0ca30c;
    --focus: #6da7ec;
    --st-green-bg: rgba(12, 163, 12, 0.22);
    --st-yellow-bg: rgba(250, 178, 25, 0.22);
    --st-red-bg: rgba(208, 59, 59, 0.26);
    --st-black: #000000;
    --st-black-bg: #000000;
    --meter-track: #2c2c2a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

.boot { padding: 48px 16px; text-align: center; color: var(--muted); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 20px; min-height: 56px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; white-space: nowrap; }
.brand svg { width: 26px; height: 26px; flex: none; }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: none; padding: 16px 12px 14px; cursor: pointer;
  color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.usermenu { position: relative; }
.userbtn {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 4px 10px 4px 4px; cursor: pointer; max-width: 240px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 650; font-size: 13px; flex: none;
}
.userbtn .email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; z-index: 30;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14); padding: 6px;
}
.menu .who { padding: 8px 10px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--border); margin-bottom: 4px; overflow-wrap: anywhere; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.menu button:hover { background: var(--surface-2); }

/* ---------- layout ---------- */
.main { max-width: 1240px; margin: 0 auto; padding: 20px 16px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 4px 0 16px; }
.page-head h1 { font-size: 22px; line-height: 1.25; margin: 0; font-weight: 650; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; min-width: 0;
}
.card h2 { font-size: 16px; margin: 0 0 4px; font-weight: 650; }
.card .sub { margin: 0 0 14px; color: var(--ink-2); font-size: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 550; white-space: nowrap;
  min-height: 38px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: 14px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; filter: none; }
.btn svg { width: 16px; height: 16px; }
.linkbtn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; text-decoration: underline; }

label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); font-weight: 550; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"], input[type="search"], select, textarea {
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--radius-sm);
  padding: 7px 10px; min-height: 38px; color: var(--ink); font-size: 15px; width: 100%;
}
textarea { min-height: 150px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
input[type="number"] { max-width: 120px; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 16px; }
.filters .grow { flex: 1 1 220px; }
.filters label.field { min-width: 150px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); background: var(--surface);
  border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: 14px; min-height: 34px;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--page); border-color: var(--ink); }
.chip .dot { width: 9px; height: 9px; }

/* ---------- status ---------- */
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot.green { background: var(--st-green); }
.dot.yellow { background: var(--st-yellow); }
.dot.red { background: var(--st-red); }
.dot.black { background: var(--st-black); box-shadow: 0 0 0 1.5px var(--border-strong); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 999px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.pill.green { background: var(--st-green-bg); }
.pill.yellow { background: var(--st-yellow-bg); }
.pill.red { background: var(--st-red-bg); }
.pill.black { background: var(--st-black-bg); color: var(--st-black-ink); box-shadow: inset 0 0 0 1px var(--border-strong); }
.pill.black .dot { background: #fff; box-shadow: none; }

.meter { display: inline-block; width: 64px; height: 6px; border-radius: 3px; background: var(--meter-track); overflow: hidden; vertical-align: middle; }
.meter > span { display: block; height: 100%; border-radius: 3px; }
.meter > span.green { background: var(--st-green); }
.meter > span.yellow { background: var(--st-yellow); }
.meter > span.red { background: var(--st-red); }
.meter > span.black { background: var(--st-black); }

/* ---------- stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); min-width: 0; text-align: left;
}
button.tile { cursor: pointer; font: inherit; color: inherit; }
button.tile:hover { border-color: var(--border-strong); }
button.tile[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.tile .label { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.tile .value { font-size: 28px; font-weight: 650; line-height: 1.2; margin-top: 4px; }
.tile .hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
@media (max-width: 1000px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .tile .value { font-size: 24px; } }

/* ---------- chart ---------- */
.chart-wrap { position: relative; width: 100%; }
.chart-wrap svg { display: block; width: 100%; height: 260px; overflow: visible; touch-action: pan-y; }
.chart-wrap .gridline { stroke: var(--grid); stroke-width: 1; }
.chart-wrap .baseline { stroke: var(--axis); stroke-width: 1; }
.chart-wrap .tick { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart-wrap .line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-wrap .area { fill: var(--series-wash); stroke: none; }
.chart-wrap .pt { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.chart-wrap .crosshair { stroke: var(--ink-2); stroke-width: 1; }
.chart-wrap .hit { fill: transparent; cursor: crosshair; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 8px 10px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14); font-size: 13px; white-space: nowrap; z-index: 5;
}
.tooltip .v { font-size: 16px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.tooltip .v .key { width: 14px; height: 2px; background: var(--series); border-radius: 1px; }
.tooltip .d { color: var(--ink-2); }
details.datatable { margin-top: 10px; font-size: 14px; }
details.datatable summary { cursor: pointer; color: var(--ink-2); }
details.datatable .scroll { max-height: 260px; overflow: auto; margin-top: 8px; }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table.data { border-collapse: collapse; width: 100%; font-size: 14px; }
table.data th, table.data td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--grid); white-space: nowrap; }
table.data th { font-size: 12px; font-weight: 600; color: var(--ink-2); background: var(--surface); position: sticky; top: 0; }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--ink); }
table.data th .arrow { display: inline-block; width: 10px; color: var(--ink); }
table.data td.r, table.data th.r { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.name { white-space: normal; min-width: 140px; }
table.data th.m, table.data td.m { padding-left: 6px; padding-right: 6px; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data td.zero { color: var(--muted); }
table.data td.days { font-weight: 650; }
table.data .daysbox { display: inline-flex; align-items: center; gap: 10px; justify-content: flex-end; }
.empty { padding: 32px 12px; text-align: center; color: var(--ink-2); }
.empty strong { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }
.table-foot { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- add data ---------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 820px) { .two-col { grid-template-columns: 1fr; } }
.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius); padding: 28px 16px; text-align: center;
  color: var(--ink-2); background: var(--surface-2); min-height: 150px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; cursor: pointer;
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone svg { width: 30px; height: 30px; color: var(--accent); }
.dropzone .small { font-size: 13px; color: var(--muted); }
.mapping { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 720px) { .mapping { grid-template-columns: 1fr; } }
.inline { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }
.notice { border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; margin: 10px 0; border: 1px solid var(--border); background: var(--surface-2); }
.notice.warn { background: var(--st-yellow-bg); border-color: transparent; }
.notice.error { background: var(--danger-soft); border-color: transparent; color: var(--ink); }
.notice.ok { background: var(--st-green-bg); border-color: transparent; }
.notice ul { margin: 6px 0 0; padding-left: 20px; }
.summary-row { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 6px 0 12px; font-size: 14px; color: var(--ink-2); }
.summary-row b { color: var(--ink); font-size: 16px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.radio-row { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.radio-row label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }

/* ---------- settings ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.legend-line { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
ol.steps { margin: 6px 0 0; padding-left: 20px; }
ol.steps li { margin: 4px 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 380px; }
.login .brand { justify-content: center; font-size: 20px; margin-bottom: 18px; }
.login .brand svg { width: 34px; height: 34px; }
.login form { display: flex; flex-direction: column; gap: 14px; }
.login .help { font-size: 13px; color: var(--muted); text-align: center; margin: 14px 0 0; }

/* ---------- modal & toast ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.38); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 440px; padding: 20px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3); }
.modal h3 { margin: 0 0 8px; font-size: 18px; }
.modal p { margin: 0 0 10px; color: var(--ink-2); }
.modal form { display: flex; flex-direction: column; gap: 12px; }
.modal .actions { justify-content: flex-end; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--page); padding: 10px 16px; border-radius: 8px; max-width: calc(100% - 32px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); font-size: 14px;
}
.toast.error { background: var(--danger); color: #fff; }
.loading { opacity: 0.55; transition: opacity 0.15s; }
.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .topbar-inner { flex-wrap: wrap; gap: 0 12px; padding-top: 8px; }
  .brand { flex: 1; }
  .tabs { order: 3; flex-basis: 100%; }
  .tab { padding: 10px 10px 10px; }
  .userbtn .email { display: none; }
  .userbtn { padding: 4px; }
  .card { padding: 14px; }
  .table-scroll { margin: 0 -14px; padding: 0 14px; }
}
@media print {
  .topbar, .filters, .actions, .btn { display: none !important; }
  body { background: #fff; }
  .card, .tile { box-shadow: none; }
}
.over { color: var(--danger); font-weight: 600; }
form > .actions { margin: 0 0 16px; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tags { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border); white-space: nowrap; }
.tag.warn { background: var(--st-yellow-bg); color: var(--ink); border-color: transparent; }
td.attn { color: var(--danger); font-weight: 600; }
.actions.tight { margin-top: 0; }
.mapping.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1000px) { .mapping.five { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .mapping.five { grid-template-columns: 1fr; } }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
@media (max-width: 900px) { .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .form-grid { grid-template-columns: 1fr; } }
textarea.plain { font-family: var(--font); font-size: 15px; min-height: 80px; }
.person-sum { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; font-size: 15px; }
.linkbtn.back { display: inline-block; margin: 0 0 8px; text-decoration: none; font-weight: 550; }
ul.log { list-style: none; margin: 0; padding: 0; }
ul.log li { padding: 8px 0; border-bottom: 1px solid var(--grid); font-size: 14px; }
ul.log li:last-child { border-bottom: 0; }
ul.log .when { color: var(--muted); font-size: 12px; }
.section-title { font-size: 16px; margin: 24px 0 10px; font-weight: 650; }
table.data td .linkbtn { text-align: left; }
.nowrap { white-space: nowrap; }
.form-grid.two { grid-template-columns: 1fr 1fr; margin-bottom: 0; }
@media (max-width: 520px) { .form-grid.two { grid-template-columns: 1fr; } }
.modal { max-width: 520px; }
.modal .notice { margin: 0; }
td .tag { margin-left: 6px; }
.updated { display: block; margin-top: 2px; }
.menu .sep { border-top: 1px solid var(--border); margin: 4px 0; }
.menu .label { padding: 6px 10px 2px; font-size: 12px; color: var(--muted); }
.menu button[aria-checked="true"]::after { content: "✓"; float: right; font-weight: 700; }
