/* ============================================================
   BD Portal — styles
   Look: Idea Fueled site — warm off-white, blue actions, yellow highlight,
   bold serif headings, soft rounded panels. Brand colors come from Settings
   (--brand, --accent are set inline in the page head).
   ============================================================ */

:root {
  --bg: #F7F7F2;
  --soft: #EDEDE6;
  --surface: #FFFFFF;
  --surface-2: #F4F4EF;
  --ink: #1A1A18;
  --ink-2: #3D3D39;
  --muted: #6B6B64;
  --line: #E3E3DB;
  --line-strong: #CECEC5;
  --ok: #2F7D4F;   --ok-bg: #E3F1E7;
  --warn: #8A5A00; --warn-bg: #FBF0D4;
  --err: #B3261E;  --err-bg: #FAE3E0;
  --chart-p: #1E6FBF; --chart-r: #B97A00; --chart-grid: #E7E7E0;
  --brand-ui: var(--brand);
  --shadow: 0 1px 2px rgba(26, 26, 24, .06), 0 8px 24px -12px rgba(26, 26, 24, .12);
  --shadow-btn: 0 6px 16px -8px color-mix(in oklab, var(--brand) 70%, transparent);

  --font-ui: "Figtree", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-display: "Source Serif 4", Georgia, "Times New Roman", serif;
  --r-sm: 8px; --r: 12px; --r-lg: 20px;
  --side: 256px;
  color-scheme: light;
}

/* Dark tokens: applied for data-theme=dark, and for system when the device is dark */
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root[data-theme="system"] { color-scheme: dark; } }

:root[data-theme="dark"] {
  --bg: #131412; --soft: #1C1D1A; --surface: #212320; --surface-2: #282A26;
  --ink: #EDEDE7; --ink-2: #D0D0C9; --muted: #A1A199; --line: #33352F; --line-strong: #474941;
  --ok: #74C493; --ok-bg: #1D3326; --warn: #E5B65C; --warn-bg: #382C12; --err: #F28B80; --err-bg: #3D1F1C;
  --chart-p: #3F8BDB; --chart-r: #B8801A; --chart-grid: #30322D;
  --brand-ui: color-mix(in oklab, var(--brand) 72%, white);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px -14px rgba(0,0,0,.6);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #131412; --soft: #1C1D1A; --surface: #212320; --surface-2: #282A26;
    --ink: #EDEDE7; --ink-2: #D0D0C9; --muted: #A1A199; --line: #33352F; --line-strong: #474941;
    --ok: #74C493; --ok-bg: #1D3326; --warn: #E5B65C; --warn-bg: #382C12; --err: #F28B80; --err-bg: #3D1F1C;
    --chart-p: #3F8BDB; --chart-r: #B8801A; --chart-grid: #30322D;
    --brand-ui: color-mix(in oklab, var(--brand) 72%, white);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px -14px rgba(0,0,0,.6);
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font-ui); }
a { color: var(--brand-ui); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.2; color: var(--ink); }
h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.2rem); letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
small { font-size: .82rem; }
.muted { color: var(--muted); }
.block { display: block; }
.nowrap { white-space: nowrap; }
.sr { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: var(--r-sm); z-index: 50; }
.skip:focus { left: 8px; }
.icon { flex-shrink: 0; vertical-align: -3px; }
.text-warn { color: var(--warn); font-weight: 600; }
:focus-visible { outline: 2px solid var(--brand-ui); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; background: var(--bg); }
.sidebar {
  width: var(--side); flex-shrink: 0; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 8px; padding: 18px 14px 14px;
  background: linear-gradient(180deg, color-mix(in oklab, var(--surface) 92%, var(--soft)), var(--surface));
  border-right: 1px solid var(--line);
  box-shadow: inset -1px 0 0 rgba(255,255,255,.04);
  transition: width .2s ease;
}
.brand {
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 16px; margin-bottom: 4px;
  border-radius: 16px; background: color-mix(in oklab, var(--surface-2) 75%, transparent);
  border: 1px solid var(--line);
}
.brand img { border-radius: 10px; object-fit: contain; box-shadow: 0 10px 18px -12px rgba(0,0,0,.32); }
.brand-name { font-weight: 700; font-size: 1.06rem; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.collapse-btn { margin-left: auto; }

.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; padding: 2px 2px 0; }
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 12px;
  color: var(--ink-2); text-decoration: none; font-weight: 600; white-space: nowrap; border: 1px solid transparent;
  transition: all .16s ease;
}
.nav-link span { overflow: hidden; text-overflow: ellipsis; }
.nav-link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; border-color: var(--line); }
.nav-link.active {
  background: linear-gradient(135deg, var(--brand), color-mix(in oklab, var(--brand) 78%, white));
  color: var(--on-brand); box-shadow: var(--shadow-btn); border-color: transparent;
}
.nav-link .icon { width: 18px; height: 18px; }
.nav-lock { margin-top: 2px; }
.nav-lock:not(.active) { background: color-mix(in oklab, var(--accent) 18%, transparent); color: var(--ink); border-color: color-mix(in oklab, var(--accent) 30%, transparent); }
.nav-lock:not(.active) .icon { color: var(--ink); }
.nav-lock:not(.active):hover { background: color-mix(in oklab, var(--accent) 30%, transparent); }

.me {
  border-top: 1px solid var(--line); padding-top: 12px; margin-top: 6px; display: flex; align-items: center; gap: 8px;
}
.me-card {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 8px 10px; border-radius: 12px; color: inherit;
  text-decoration: none; background: transparent; border: 1px solid transparent; transition: all .16s ease;
}
.me-card:hover, .me-card.active { background: var(--surface-2); border-color: var(--line); text-decoration: none; }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.me-text b { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: var(--muted); }
.me-actions { display: flex; gap: 4px; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; flex-shrink: 0;
  background: color-mix(in oklab, var(--brand) 14%, var(--surface)); color: var(--brand-ui);
  font-weight: 700; font-size: .82rem; letter-spacing: .02em;
}
.avatar.sm { width: 30px; height: 30px; font-size: .74rem; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-sm);
  background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: none; font: inherit; font-size: 1.1rem; line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.show-dark { display: none; }
:root[data-theme="dark"] .show-light { display: none; }
:root[data-theme="dark"] .show-dark { display: inline; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] .show-light { display: none; }
  :root[data-theme="system"] .show-dark { display: inline; }
}

/* compact sidebar (icons only) */
.compact { --side: 76px; }
.compact .brand-name, .compact .nav-link span, .compact .me-text { display: none; }
.compact .brand { flex-direction: column; padding-bottom: 12px; }
.compact .collapse-btn { margin: 0; transform: rotate(180deg); }
.compact .nav-link { justify-content: center; padding: 10px; }
.compact .me { flex-direction: column; }
.compact .me-card { flex: none; }
.compact .me-actions { flex-direction: column; }

.main { flex: 1; min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 60px; max-width: 1320px; }
.topbar {
  display: flex; align-items: center; gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
  padding: 18px 20px; background: linear-gradient(180deg, color-mix(in oklab, var(--surface) 95%, var(--soft)), var(--surface));
  border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 10px 24px -18px rgba(0,0,0,.22);
}
.titles { flex: 1; min-width: 220px; }
.subtitle { color: var(--muted); margin-top: 6px; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.menu-btn { display: none; }
.scrim { display: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--r-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: 600 .92rem/1.2 var(--font-ui);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { border-color: var(--ink-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); box-shadow: var(--shadow-btn); }
.btn-primary:hover { background: color-mix(in oklab, var(--brand) 88%, black); border-color: transparent; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 6px 16px -8px color-mix(in oklab, var(--accent) 80%, transparent); }
.btn-accent:hover { background: color-mix(in oklab, var(--accent) 88%, black); border-color: transparent; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--brand-ui); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-sm { padding: 6px 11px; font-size: .84rem; }
.btn-lg { padding: 13px 22px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn.disabled { opacity: .45; pointer-events: none; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--brand-ui); font: 600 .88rem var(--font-ui); cursor: pointer; }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; box-shadow: var(--shadow); }
.panel + .panel, .panel + .table-card, .table-card + .panel, .table-card + .table-card, .chart-card + .table-card, .chart-card + .panel { margin-top: 18px; }
.panel h2 { margin-bottom: 4px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head a { font-weight: 700; text-decoration: none; }
.panel-head a:hover { text-decoration: underline; }
.table-card .panel-head { padding: 18px 20px 0; }
.section-title { font-family: var(--font-display); font-size: 1.3rem; margin: 30px 0 12px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.span-2 { grid-column: span 2; }
.empty { color: var(--muted); text-align: center; padding: 28px 16px !important; }
.note p { color: var(--ink-2); margin-top: 8px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; margin-top: 18px; }
.nav-done { color: var(--ok) !important; }
.nav-done .icon { color: var(--ok); }

/* ---------- alerts ---------- */
.alert { border-radius: var(--r-sm); padding: 12px 16px; margin-bottom: 18px; border: 1px solid; font-weight: 500; }
.alert-ok { background: var(--ok-bg); border-color: color-mix(in oklab, var(--ok) 30%, transparent); color: var(--ink); }
.alert-warn { background: var(--warn-bg); border-color: color-mix(in oklab, var(--warn) 35%, transparent); color: var(--ink); }
.alert-err { background: var(--err-bg); border-color: color-mix(in oklab, var(--err) 35%, transparent); color: var(--ink); }
.copy-row { display: flex; gap: 8px; margin-top: 10px; }
.copy-row input { flex: 1; font-size: .85rem; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field > legend { font-weight: 600; font-size: .88rem; color: var(--ink-2); padding: 0; }
.field > legend { margin-bottom: 6px; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); width: 100%;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 9px 12px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-ui); box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand) 22%, transparent); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--err); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--brand); }
input[type="color"] { width: 46px; height: 38px; padding: 3px; cursor: pointer; }
input[readonly] { background: var(--surface-2); }
.hint { color: var(--muted); font-size: .8rem; }
.error { color: var(--err); font-size: .84rem; font-weight: 600; }
.error-box { background: var(--err-bg); color: var(--ink); border-left: 3px solid var(--err); padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; }
.check { display: flex; align-items: center; gap: 9px; font-size: .9rem; cursor: pointer; }
.form-panel { display: flex; flex-direction: column; gap: 20px; max-width: 860px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.stamp { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .87rem; padding: 10px 14px; background: var(--surface-2); border-radius: var(--r-sm); }
.stamp b { color: var(--ink-2); }

.segmented { align-self: flex-start; max-width: 100%; display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 7px; font-weight: 600; font-size: .88rem; color: var(--muted); }
.segmented input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.segmented input:focus-visible + span { outline: 2px solid var(--brand-ui); outline-offset: 1px; }

.color-input { display: flex; align-items: center; gap: 10px; }
.color-input code { font-size: .85rem; color: var(--muted); }
.presets { display: flex; flex-wrap: wrap; gap: 10px; }
.preset { display: flex; align-items: center; gap: 0; padding: 6px 12px 6px 6px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; cursor: pointer; font: 500 .84rem var(--font-ui); color: var(--ink-2); }
.preset span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--surface); }
.preset span + span { margin-left: -6px; }
.preset small { margin-left: 8px; }
.preset:hover { border-color: var(--ink-2); }
.logo-row { display: flex; align-items: center; gap: 12px; }
.logo-preview { border-radius: 8px; object-fit: contain; background: var(--surface-2); padding: 4px; }

/* ---------- tabs, toolbar, filters ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--ink); border-bottom-color: var(--brand); }
.count { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); font-size: .76rem; text-align: center; margin-left: 4px; color: var(--muted); }
.toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .tabs { margin-bottom: 0; flex: 1; }
.search input { width: 280px; max-width: 100%; }
.filter-note { margin: -6px 0 14px; color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 14px 16px; margin-bottom: 18px; }
.filters select { width: auto; min-width: 150px; }
.filters input[type="date"] { width: auto; }
.custom-dates { display: flex; gap: 10px; flex-wrap: wrap; }
.js .filters [data-apply] { display: none; }
.js .filters.has-custom [data-apply] { display: inline-flex; }

/* ---------- tables ---------- */
.table-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-weight: 700; color: var(--muted); font-size: .76rem; letter-spacing: .08em; text-transform: uppercase; padding: 12px 14px; border-bottom: 1px solid var(--line); background: color-mix(in oklab, var(--surface-2) 82%, var(--surface)); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in oklab, var(--surface-2) 62%, transparent); }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line-strong); border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table small { color: var(--muted); }
.table.compact td, .table.compact th { padding: 7px 10px; }
.table tr.dim td { opacity: .55; }
.table tr.clickable { cursor: pointer; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
td.row-actions { display: table-cell; text-align: right; white-space: nowrap; }
td.row-actions > * { vertical-align: middle; }
td.row-actions form { display: inline; }
.inline-actions { display: inline-flex !important; gap: 2px; }
.icon-danger:hover { color: var(--err); background: var(--err-bg); }
.person { display: flex; align-items: center; gap: 10px; }
.person > span:last-child { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.person small { color: var(--muted); }

.status, .role, .mode, .pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 700; white-space: nowrap; border: 1px solid transparent;
}
.status-active { background: var(--ok-bg); color: var(--ok); }
.status-invited { background: var(--warn-bg); color: var(--warn); }
.status-inactive { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
.role { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); }
.role-bdm { background: color-mix(in oklab, var(--brand) 12%, var(--surface)); color: var(--brand-ui); border-color: transparent; }
.role-admin { background: var(--ink); color: var(--bg); }
.mode { color: var(--ink-2); padding-left: 0; }
.pill { background: var(--surface); border-color: var(--line); color: var(--ink-2); padding: 5px 12px; }
.pill-ok { color: var(--ok); border-color: color-mix(in oklab, var(--ok) 35%, transparent); }
.metric-pill {
  display: inline-flex; align-items: center; justify-content: center; min-width: 42px; padding: 6px 10px;
  border-radius: 8px; background: var(--surface-2); color: var(--ink); font-weight: 700; border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35);
}
.muted-pill { background: color-mix(in oklab, var(--surface-2) 85%, var(--surface)); }
.good-pill { background: color-mix(in oklab, var(--ok-bg) 70%, var(--surface)); color: var(--ok); border-color: color-mix(in oklab, var(--ok) 35%, transparent); }
.table-action {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 9px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--ink-2); text-decoration: none; font-weight: 700; font-size: .82rem;
}
.table-action:hover { background: color-mix(in oklab, var(--brand) 10%, var(--surface-2)); border-color: color-mix(in oklab, var(--brand) 30%, var(--line)); color: var(--brand-ui); text-decoration: none; }
.table-compact { color: var(--ink-2); }
.dashboard-table .icon { width: 13px; height: 13px; }
.status .icon { width: 12px; height: 12px; }
.table-action .icon { width: 13px; height: 13px; }
.star-count { display: inline-flex; align-items: center; gap: 2px; color: var(--chart-r); font-size: .78rem; font-weight: 700; margin-left: 4px; }
.star-count .icon { fill: currentColor; }

/* dropdown menu (details/summary) */
.menu { position: relative; display: inline-block; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 230px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--shadow); padding: 6px;
  display: flex; flex-direction: column; text-align: left;
}
.menu-list button, .menu-list a {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 10px; border: 0; background: none; border-radius: 6px;
  font: 500 .88rem var(--font-ui); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.menu-list button:hover, .menu-list a:hover { background: var(--surface-2); }
.menu-list .danger { color: var(--err); }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: linear-gradient(180deg, var(--surface), color-mix(in oklab, var(--surface) 90%, var(--surface-2))); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; inset: 0 auto auto 0; width: 100%; height: 3px; background: linear-gradient(90deg, var(--brand), transparent); opacity: .7; }
.stat-label { color: var(--muted); font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.stat-value { font-family: var(--font-display); font-size: 2rem; font-weight: 700; line-height: 1.15; font-variant-numeric: lining-nums tabular-nums; }
.stat-note { color: var(--muted); font-size: .8rem; }
.stat-good .stat-note { color: var(--ok); font-weight: 600; }

/* ---------- chart ---------- */
.chart-card { margin-bottom: 18px; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.chart-head h2 { margin: 0; }
.legend { display: flex; gap: 16px; font-size: .84rem; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.key { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.key-p { background: var(--chart-p); }
.key-r { background: var(--chart-r); }
.chart-wrap { position: relative; overflow-x: auto; overflow-y: visible; padding-top: 70px; margin-top: -70px; }
.chart-svg { min-width: 560px; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-svg .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart-svg .axis { stroke: var(--line-strong); stroke-width: 1; }
.chart-svg .tick { fill: var(--muted); font: 11px var(--font-ui); }
.chart-svg .tick-today { fill: var(--ink); font-weight: 700; }
.chart-svg .bar-p { fill: var(--chart-p); }
.chart-svg .bar-r { fill: var(--chart-r); }
.chart-svg .hit { fill: transparent; }
.chart-svg .col:hover .hit, .chart-svg .col.on .hit { fill: color-mix(in oklab, var(--ink) 5%, transparent); }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 150px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-sm);
  box-shadow: var(--shadow); padding: 9px 12px; font-size: .84rem; transform: translate(-50%, -100%);
}
.tooltip b { display: block; margin-bottom: 4px; }
.tooltip div { display: flex; align-items: center; gap: 7px; }
.tooltip div span:last-child { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.table-view { margin-top: 10px; }
.table-view summary { cursor: pointer; color: var(--muted); font-size: .84rem; font-weight: 600; }
.table-view table { margin-top: 8px; }

/* ---------- BDE today card ---------- */
.today-card {
  background: var(--soft); border-radius: var(--r-lg); padding: clamp(22px, 3vw, 36px);
  display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
  border: 1px solid var(--line);
}
.today-text { flex: 1 1 380px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.today-text h2 { font-family: var(--font-display); font-size: clamp(1.35rem, 1.1rem + .8vw, 1.8rem); max-width: 26ch; }
.today-text p { max-width: 60ch; }
.today-nums { display: flex; gap: 10px; margin: 0; flex-wrap: wrap; }
.today-nums div { background: var(--surface); border-radius: var(--r); padding: 10px 16px; min-width: 92px; border: 1px solid var(--line); }
.today-nums dt { font-size: .78rem; color: var(--muted); font-weight: 600; }
.today-nums dd { margin: 0; font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.today-card.is-locked { background: color-mix(in oklab, var(--ok-bg) 70%, var(--soft)); }

.day-list { list-style: none; margin: 0; padding: 0; }
.day-list li + li { border-top: 1px solid var(--line); }
.day-list a { display: flex; align-items: center; gap: 16px; padding: 12px 4px; color: inherit; text-decoration: none; }
.day-list a:hover { background: var(--surface-2); }
.day-date { display: flex; flex-direction: column; flex: 1; line-height: 1.3; }
.day-date small { color: var(--muted); }
.day-nums { display: flex; gap: 16px; color: var(--ink-2); font-size: .9rem; font-variant-numeric: tabular-nums; }

/* ---------- proposals view ---------- */
.proposals { margin-top: 26px; display: flex; flex-direction: column; gap: 12px; }
.proposal-view { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow); }
.proposal-view.starred { border-color: color-mix(in oklab, var(--chart-r) 55%, transparent); box-shadow: 0 0 0 1px color-mix(in oklab, var(--chart-r) 40%, transparent), var(--shadow); }
.proposal-view header { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 10px; }
.seq { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex-shrink: 0; color: var(--ink-2); }
.p-title { flex: 1; min-width: 0; }
.p-title h3 { font-size: 1.02rem; }
.p-link { font-size: .84rem; display: inline-flex; align-items: center; gap: 4px; margin-top: 2px; }
.p-actions { display: flex; align-items: center; gap: 6px; }
.p-text { color: var(--ink-2); white-space: normal; overflow-wrap: anywhere; }
.p-text.clamp { max-height: 7.8em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }
.p-text.clamp.open { max-height: none; -webkit-mask-image: none; mask-image: none; }
.star-btn { background: none; border: 1px solid var(--line-strong); border-radius: 50%; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.star-btn:hover { color: var(--chart-r); border-color: var(--chart-r); }
.star-btn[aria-pressed="true"] { color: var(--chart-r); border-color: var(--chart-r); background: color-mix(in oklab, var(--chart-r) 12%, var(--surface)); }
.star-btn[aria-pressed="true"] .icon { fill: currentColor; }
.star-badge { display: inline-flex; align-items: center; gap: 4px; color: var(--chart-r); font-size: .8rem; font-weight: 700; }
.star-badge .icon { fill: currentColor; }

/* ---------- people cards (BDM) ---------- */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.person-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.person-card.dim { opacity: .6; }
.person-card header { display: flex; gap: 12px; align-items: center; }
.person-card header .avatar { width: 44px; height: 44px; font-size: .92rem; }
.person-card h3 { margin-bottom: 4px; }
.facts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: .88rem; color: var(--ink-2); }
.facts li { display: flex; align-items: center; gap: 8px; min-width: 0; }
.facts a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facts .icon { color: var(--muted); }
.mini-cap { margin-bottom: -8px; }
.mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; background: var(--surface-2); border-radius: var(--r-sm); padding: 10px 12px; }
.mini dt { font-size: .74rem; color: var(--muted); font-weight: 600; }
.mini dd { margin: 0; font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; }
.person-card footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: auto; }

.details { margin: 14px 0 0; display: grid; gap: 0; }
.details div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid var(--line); }
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 600; text-align: right; }

/* ---------- lock dialog ---------- */
.lock-dialog {
  width: min(820px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0;
  border-radius: var(--r-lg); background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(0,0,0,.45);
}
.lock-dialog[open] { display: flex; animation: pop .22s ease-out; }
.lock-dialog::backdrop { background: rgba(20, 20, 18, .5); backdrop-filter: blur(3px); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.lock-dialog form { display: flex; flex-direction: column; width: 100%; max-height: inherit; }
.lock-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 22px 24px 10px; }
.lock-head h2 { font-family: var(--font-display); font-size: 1.5rem; }
.lock-head p { font-size: .86rem; margin-top: 4px; }
.stepper { list-style: none; display: flex; gap: 6px; margin: 0; padding: 6px 24px 16px; border-bottom: 1px solid var(--line); counter-reset: s; }
.stepper li { flex: 1; display: flex; align-items: center; gap: 8px; font-size: .86rem; font-weight: 600; color: var(--muted); padding-top: 10px; border-top: 3px solid var(--line); }
.stepper li span { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--surface-2); font-size: .76rem; border: 1px solid var(--line-strong); }
.stepper li.current { color: var(--ink); border-top-color: var(--brand); }
.stepper li.current span { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.stepper li.done { color: var(--ink-2); border-top-color: color-mix(in oklab, var(--brand) 45%, var(--line)); }
.stepper li.done span { background: color-mix(in oklab, var(--brand) 15%, var(--surface)); color: var(--brand-ui); border-color: transparent; }
.lock-body { padding: 20px 24px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.step-intro { color: var(--ink-2); margin-bottom: 16px; }
.num-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.num-field { display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.num-label { font-weight: 700; }
.stepper-input { display: flex; align-items: center; gap: 8px; }
.stepper-input input { text-align: center; font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; padding: 4px 6px; background: var(--surface); -moz-appearance: textfield; }
.stepper-input input::-webkit-inner-spin-button, .stepper-input input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper-input button { width: 44px; height: 44px; flex-shrink: 0; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: 1.3rem; cursor: pointer; }
.stepper-input button:hover { border-color: var(--brand-ui); color: var(--brand-ui); }

.chip-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; position: sticky; top: -20px; background: var(--surface); padding: 8px 0; z-index: 2; }
.chip { min-width: 34px; height: 30px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); font: 600 .82rem var(--font-ui); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.chip.done { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.chip.bad { border-color: var(--err); color: var(--err); }
.proposal-list { display: flex; flex-direction: column; gap: 14px; }
.proposal-card { border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 12px; scroll-margin-top: 56px; }
.proposal-card header { display: flex; align-items: center; justify-content: space-between; }
.proposal-card h3 small { font-weight: 500; }
.done-mark { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: transparent; }
.proposal-card.complete { border-color: color-mix(in oklab, var(--ok) 40%, var(--line)); }
.proposal-card.complete .done-mark { background: var(--ok-bg); color: var(--ok); }
.proposal-card.invalid { border-color: var(--err); }
.empty-step { background: var(--surface-2); border-radius: var(--r); padding: 22px; color: var(--ink-2); text-align: center; }

.review-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0 0 16px; }
.review-nums div { background: var(--surface-2); border-radius: var(--r-sm); padding: 10px 14px; }
.review-nums dt { font-size: .78rem; color: var(--muted); font-weight: 600; }
.review-nums dd { margin: 0; font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; }
.review-list { margin: 0 0 16px; padding-left: 22px; display: flex; flex-direction: column; gap: 4px; color: var(--ink-2); }
.review-list small { color: var(--muted); }
.confirm { margin-top: 14px; padding: 12px 14px; border-radius: var(--r-sm); background: color-mix(in oklab, var(--accent) 16%, var(--surface)); font-weight: 600; }
.lock-foot { display: flex; align-items: center; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--line); background: var(--surface); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.spacer { flex: 1; }

/* ---------- auth pages ---------- */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 500px at 50% -10%, var(--soft), var(--bg)); }
.auth { width: min(440px, 100%); display: flex; flex-direction: column; gap: 18px; }
.auth-brand { display: flex; align-items: center; gap: 10px; justify-content: center; font-weight: 700; font-size: 1.25rem; }
.auth-brand img { border-radius: 10px; object-fit: contain; box-shadow: 0 8px 18px -12px rgba(0,0,0,.28); }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 30px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 18px; }
.auth-card h1 { font-size: clamp(1.8rem, 1.4rem + 1vw, 2.4rem); letter-spacing: -.03em; }
.auth-header { display: flex; flex-direction: column; gap: 8px; }
.auth-eyebrow { margin: 0; letter-spacing: .12em; text-transform: uppercase; font-size: .72rem; font-weight: 700; color: var(--brand-ui); }
.auth-subtitle { margin: 0; color: var(--muted); line-height: 1.5; }
.auth-form { display: flex; flex-direction: column; gap: 18px; }
.auth-card .field span { font-size: .83rem; color: var(--ink-2); }
.auth-card .field input { padding: 12px 13px; border-radius: 10px; }
.auth-card .field input::placeholder { color: var(--muted); }
.input-with-icon {
  position: relative; display: flex; align-items: center;
}
.input-with-icon .icon {
  position: absolute; left: 14px; width: 16px; height: 16px; color: var(--muted); pointer-events: none;
}
.input-with-icon input {
  width: 100%; padding-left: 42px !important;
}
.password-wrap {
  position: relative;
}
.password-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--muted); display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
}
.password-toggle:hover { background: var(--surface-2); color: var(--ink); }
.password-toggle .icon { width: 16px; height: 16px; }
.password-wrap input { padding-right: 42px !important; }
.auth-error { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 10px; }
.auth-error strong { font-size: .85rem; letter-spacing: .02em; }
.auth-foot { text-align: center; font-size: .9rem; margin-top: 4px; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-105%); transition: transform .22s ease; width: 272px !important; box-shadow: var(--shadow); }
  .compact .brand-name, .compact .nav-link span, .compact .me-text { display: revert; }
  .compact .nav-link { justify-content: flex-start; padding: 9px 12px; }
  .compact .brand, .compact .me, .compact .me-actions { flex-direction: row; }
  .collapse-btn { display: none; }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 30; }
  .menu-btn { display: inline-grid; margin-left: -6px; }
  .topbar { align-items: center; }
  .main { padding-top: 18px; }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .num-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .review-nums { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value { font-size: 1.6rem; }
  .today-card .btn-lg { width: 100%; }
  .lock-head, .lock-body, .lock-foot { padding-left: 16px; padding-right: 16px; }
  .stepper { padding-left: 16px; padding-right: 16px; }
  .stepper li { font-size: 0; gap: 0; }
  .stepper li span { font-size: .76rem; }
  .stepper li.current { font-size: .8rem; gap: 6px; }
  .search input { width: 100%; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .day-nums { flex-direction: column; gap: 0; text-align: right; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
