/* SF DataBank - console styles. No external fonts, no frameworks. 8px spacing grid. */

/* ---------- Tokens ---------- */
:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Consolas, "Liberation Mono", monospace;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 12px;
  --sidebar-w: 236px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 56px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur: 140ms;

  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --surface-3: #f2f4f7;
  --hover: #f2f4f7;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #475467;
  --text-3: #667085;
  --accent: #0f766e;
  --accent-hover: #0c625b;
  --accent-fg: #ffffff;
  --accent-soft: #e7f5f3;
  --accent-text: #0f766e;
  --ring: 0 0 0 3px rgba(15, 118, 110, .28);
  --danger: #d92d20;
  --danger-hover: #b42318;
  --danger-soft: #fef1f0;
  --danger-text: #b42318;
  --warn: #dc6803;
  --warn-soft: #fff7e8;
  --warn-text: #93370d;
  --success: #079455;
  --success-soft: #ecfdf3;
  --success-text: #067647;
  --info: #1d63d8;
  --info-soft: #eef4ff;
  --info-text: #1849a9;
  --p1: #2563eb;
  --p1-soft: #eaf1ff;
  --p2: #7c3aed;
  --p2-soft: #f3edff;
  --p3: #d97706;
  --p3-soft: #fff4e0;
  --px: #64748b;
  --px-soft: #f1f5f9;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .07), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 16px 40px -12px rgba(16, 24, 40, .22), 0 4px 10px -4px rgba(16, 24, 40, .08);
  --skel: #eceff3;
  --skel-hi: #f7f8fa;
  --overlay: rgba(15, 23, 41, .45);
  --chart-grid: #eef0f3;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0e13;
    --surface: #12161d;
    --surface-2: #151a22;
    --surface-3: #1a2029;
    --hover: #1c222c;
    --border: #232a35;
    --border-strong: #313a48;
    --text: #e6e9ef;
    --text-2: #aab2bf;
    --text-3: #7f8898;
    --accent: #2bb3a3;
    --accent-hover: #40c5b5;
    --accent-fg: #03201c;
    --accent-soft: rgba(43, 179, 163, .14);
    --accent-text: #5fd3c4;
    --ring: 0 0 0 3px rgba(43, 179, 163, .38);
    --danger: #f0645a;
    --danger-hover: #ff7b72;
    --danger-soft: rgba(240, 100, 90, .13);
    --danger-text: #ff8a80;
    --warn: #f5a524;
    --warn-soft: rgba(245, 165, 36, .12);
    --warn-text: #fbbf55;
    --success: #34c47c;
    --success-soft: rgba(52, 196, 124, .12);
    --success-text: #5ad69a;
    --info: #6b9cff;
    --info-soft: rgba(107, 156, 255, .12);
    --info-text: #9dbcff;
    --p1: #5b8cff;
    --p1-soft: rgba(91, 140, 255, .15);
    --p2: #a07bff;
    --p2-soft: rgba(160, 123, 255, .16);
    --p3: #f2a93b;
    --p3-soft: rgba(242, 169, 59, .15);
    --px: #94a3b8;
    --px-soft: rgba(148, 163, 184, .14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 18px 44px -12px rgba(0, 0, 0, .65), 0 4px 12px -4px rgba(0, 0, 0, .4);
    --skel: #1b212b;
    --skel-hi: #232a36;
    --overlay: rgba(0, 0, 0, .6);
    --chart-grid: #1f2530;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0b0e13;
  --surface: #12161d;
  --surface-2: #151a22;
  --surface-3: #1a2029;
  --hover: #1c222c;
  --border: #232a35;
  --border-strong: #313a48;
  --text: #e6e9ef;
  --text-2: #aab2bf;
  --text-3: #7f8898;
  --accent: #2bb3a3;
  --accent-hover: #40c5b5;
  --accent-fg: #03201c;
  --accent-soft: rgba(43, 179, 163, .14);
  --accent-text: #5fd3c4;
  --ring: 0 0 0 3px rgba(43, 179, 163, .38);
  --danger: #f0645a;
  --danger-hover: #ff7b72;
  --danger-soft: rgba(240, 100, 90, .13);
  --danger-text: #ff8a80;
  --warn: #f5a524;
  --warn-soft: rgba(245, 165, 36, .12);
  --warn-text: #fbbf55;
  --success: #34c47c;
  --success-soft: rgba(52, 196, 124, .12);
  --success-text: #5ad69a;
  --info: #6b9cff;
  --info-soft: rgba(107, 156, 255, .12);
  --info-text: #9dbcff;
  --p1: #5b8cff;
  --p1-soft: rgba(91, 140, 255, .15);
  --p2: #a07bff;
  --p2-soft: rgba(160, 123, 255, .16);
  --p3: #f2a93b;
  --p3-soft: rgba(242, 169, 59, .15);
  --px: #94a3b8;
  --px-soft: rgba(148, 163, 184, .14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 18px 44px -12px rgba(0, 0, 0, .65), 0 4px 12px -4px rgba(0, 0, 0, .4);
  --skel: #1b212b;
  --skel-hi: #232a36;
  --overlay: rgba(0, 0, 0, .6);
  --chart-grid: #1f2530;
  color-scheme: dark;
}

/* Phase color scopes: any element with .p1/.p2/.p3/.px exposes --ph / --ph-soft */
.p1 { --ph: var(--p1); --ph-soft: var(--p1-soft); }
.p2 { --ph: var(--p2); --ph-soft: var(--p2-soft); }
.p3 { --ph: var(--p3); --ph-soft: var(--p3-soft); }
.px { --ph: var(--px); --ph-soft: var(--px-soft); }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; }
p { margin: 0; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-soft); }
table { border-collapse: collapse; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.icon { flex: none; display: inline-block; vertical-align: middle; }
[hidden] { display: none !important; }

/* ---------- Layout helpers ---------- */
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.stack-lg { display: flex; flex-direction: column; gap: 24px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-nowrap { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main-side { display: grid; gap: 16px; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-list-cal { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
@media (max-width: 1100px) { .grid-list-cal { grid-template-columns: minmax(0, 1fr); } }
.grid-table-panel { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
@media (max-width: 1200px) {
  .grid-table-panel { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  .grid-main-side { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns var(--dur) var(--ease);
}
.app.nav-collapsed { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }

.skip-link {
  position: fixed; left: 8px; top: 8px; z-index: 100;
  transform: translateY(-150%);
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 12px; box-shadow: var(--shadow-lg);
}
.skip-link:focus-visible { transform: none; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
  z-index: 30;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  height: var(--topbar-h); padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-fg);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .12);
}
.brand-name { font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.brand-name span { color: var(--text-3); font-weight: 500; }
.nav { flex: 1; overflow-y: auto; padding: 12px 8px; }
.nav-group + .nav-group { margin-top: 16px; }
.nav-group-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-3); padding: 0 12px 6px; white-space: nowrap;
}
.nav-link {
  display: flex; align-items: center; gap: 12px;
  height: 36px; padding: 0 12px; border-radius: 8px;
  color: var(--text-2); font-weight: 500; white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-link:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }
.nav-link .icon { opacity: .9; }
.nav-link .nav-badge {
  margin-left: auto; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px;
  background: var(--accent); color: var(--accent-fg);
}
.sidebar-foot {
  border-top: 1px solid var(--border); padding: 8px;
  display: flex; align-items: center; gap: 8px;
}
.sidebar-foot .version { font-size: 11px; color: var(--text-3); white-space: nowrap; padding-left: 4px; }
.nav-collapsed .brand-name,
.nav-collapsed .nav-group-label,
.nav-collapsed .nav-text,
.nav-collapsed .nav-badge,
.nav-collapsed .sidebar-foot .version { display: none; }
.nav-collapsed .brand { padding: 0 17px; }
.nav-collapsed .nav-link { justify-content: center; padding: 0; }
.nav-collapsed .sidebar-foot { justify-content: center; }
.nav-collapsed .collapse-btn .icon { transform: rotate(180deg); }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .menu-btn { display: none; }
.date-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-2);
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  white-space: nowrap;
}
.user-chip {
  display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2);
  padding-left: 8px; border-left: 1px solid var(--border); white-space: nowrap;
}
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent-text);
}
.content {
  padding: 24px;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  flex: 1;
}
.content:focus { outline: none; }
.scrim { display: none; }

@media (max-width: 899px) {
  .app, .app.nav-collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 272px;
    transform: translateX(-100%);
    transition: transform 180ms var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .nav-collapsed .brand-name, .nav-collapsed .nav-group-label, .nav-collapsed .nav-text,
  .nav-collapsed .sidebar-foot .version { display: initial; }
  .nav-collapsed .nav-link { justify-content: flex-start; padding: 0 12px; }
  .collapse-btn { display: none; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim {
    display: block; position: fixed; inset: 0; z-index: 25; background: var(--overlay);
    animation: fade-in 160ms var(--ease);
  }
  .topbar { padding: 0 16px; }
  .topbar .menu-btn { display: inline-flex; }
  .content { padding: 16px; }
  .user-chip .user-name, .date-chip .date-long { display: none; }
}
@media (max-width: 520px) {
  .date-chip { display: none; }
}

/* ---------- Page header ---------- */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.page-head h2 { font-size: 22px; font-weight: 650; }
.page-head .sub { color: var(--text-2); margin-top: 4px; max-width: 72ch; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.section-title { font-size: 13px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 16px 20px 0;
}
.card-head.bordered { padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-sub { color: var(--text-3); font-size: 13px; margin-top: 2px; }
.card-body { padding: 16px 20px 20px; }
.card-body.flush { padding: 0; }
.card-head + .card-body.flush { margin-top: 12px; }
.card-body.flush-x { padding-left: 0; padding-right: 0; }
.card-foot {
  padding: 12px 20px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ---------- KPI ---------- */
.kpi-grid { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi-grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi-grid.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpi-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1200px) {
  .kpi-grid.cols-5, .kpi-grid.cols-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .kpi-grid, .kpi-grid.cols-3, .kpi-grid.cols-5, .kpi-grid.cols-6 { grid-template-columns: minmax(0, 1fr); }
}
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px; box-shadow: var(--shadow-sm); min-width: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.kpi-label { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.kpi-label .icon { color: var(--text-3); }
.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { font-size: 12px; color: var(--text-3); }
.kpi.compact { padding: 12px 16px; gap: 2px; }
.kpi.compact .kpi-value { font-size: 20px; }
.kpi.tone-accent .kpi-value { color: var(--accent-text); }
.kpi.tone-warn .kpi-value { color: var(--warn-text); }
.kpi.tone-danger .kpi-value { color: var(--danger-text); }
.kpi.tone-success .kpi-value { color: var(--success-text); }
a.kpi { color: inherit; transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
a.kpi:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow); }

/* ---------- Buttons ---------- */
.btn {
  --spin: var(--text-2);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 500; font-size: 14px; line-height: 1;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform 80ms var(--ease);
  user-select: none;
}
.btn:hover:not(:disabled) { background: var(--hover); text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--accent); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; box-shadow: none; }
a.btn { color: var(--text); }
.btn-primary { --spin: var(--accent-fg); background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
a.btn-primary { color: var(--accent-fg); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { --spin: #fff; background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn-danger-ghost { color: var(--danger-text); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 6px; border-radius: 7px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; gap: 4px; border-radius: 6px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; border-radius: 10px; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-icon.btn-xs { width: 26px; }
.btn.is-busy { color: transparent !important; pointer-events: none; }
.btn.is-busy .icon { visibility: hidden; }
.btn.is-busy::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border: 2px solid var(--spin); border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: 8px 0 0 8px; }
.btn-group .btn:last-child { border-radius: 0 8px 8px 0; }
.btn-group .btn + .btn { margin-left: -1px; }
.link-btn {
  background: none; border: 0; padding: 0; color: var(--accent-text); font-weight: 500; cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.hint { font-size: 12px; color: var(--text-3); }
.input, .select, .textarea {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; font-family: var(--mono); font-size: 13px; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); opacity: .8; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input:disabled, .select:disabled { opacity: .55; cursor: not-allowed; }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input-sm, .select-sm { height: 30px; font-size: 13px; padding: 0 10px; border-radius: 7px; }
.select {
  appearance: none; -webkit-appearance: none;
  padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.input-num { text-align: right; font-variant-numeric: tabular-nums; }
.input-num::-webkit-outer-spin-button, .input-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input-num { -moz-appearance: textfield; appearance: textfield; }
input[type="date"].input { min-width: 150px; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: 8px 0 0 8px; }
.input-group .btn { border-radius: 0 8px 8px 0; margin-left: -1px; height: auto; }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-icon .input { padding-left: 36px; }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; }

input[type="file"].input { padding: 4px 6px; height: auto; color: var(--text-2); font-size: 13px; }
input[type="file"]::file-selector-button {
  font: inherit; font-weight: 500; color: var(--text); margin-right: 10px;
  height: 28px; padding: 0 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface-2);
  transition: background var(--dur) var(--ease);
}
input[type="file"]::file-selector-button:hover { background: var(--hover); }
.checkbox { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; flex: none; margin: 0; }

/* switch */
.switch { position: relative; display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  position: relative; flex: none; width: 36px; height: 20px; margin-top: 1px;
  border-radius: 999px; background: var(--border-strong);
  transition: background var(--dur) var(--ease);
}
.switch-track::after {
  content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  transition: transform var(--dur) var(--ease);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--ring); }
.switch input:disabled + .switch-track { opacity: .5; }
.switch.is-disabled { cursor: not-allowed; }
.switch-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.switch-label { font-weight: 500; }
.switch-desc { font-size: 13px; color: var(--text-3); }

/* radio cards */
.radio-cards { display: grid; gap: 8px; }
.radio-card {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.radio-card:hover { border-color: var(--border-strong); }
.radio-card input { margin: 3px 0 0; accent-color: var(--accent); flex: none; }
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio-card:has(input:focus-visible) { box-shadow: var(--ring); }
.radio-card .rc-title { font-weight: 600; }
.radio-card .rc-desc { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.radio-card .rc-tag { font-size: 11px; font-weight: 600; color: var(--accent-text); margin-left: 6px; }

/* ---------- Tables ---------- */
.table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; } /* relative: clips absolute children (sr-only, switch inputs) so wide tables never widen the page */
.table { width: 100%; font-size: 13.5px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2);
  font-size: 12px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}
.table th.num, .table td.num { text-align: right; }
.table tbody tr { transition: background var(--dur) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { font-weight: 600; background: var(--surface-2); border-bottom: 0; border-top: 1px solid var(--border-strong); }
.table.dense th, .table.dense td { padding-top: 7px; padding-bottom: 7px; }
.table tr.is-clickable { cursor: pointer; }
.table tr.is-selected { background: var(--accent-soft) !important; }
.table td.actions { text-align: right; white-space: nowrap; }
.table .cell-name { font-weight: 500; }
.table .cell-trunc { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-sort {
  background: none; border: 0; padding: 0; font: inherit; color: inherit; text-transform: inherit;
  letter-spacing: inherit; display: inline-flex; align-items: center; gap: 4px; cursor: pointer;
}
.th-sort:hover { color: var(--text); }
.th-sort.is-active .icon { opacity: 1; }
.th-sort .icon { opacity: .35; }

/* group (phase) rows */
.group-head td, .group-head th {
  background: var(--ph-soft);
  border-bottom: 1px solid var(--border);
  padding-top: 8px; padding-bottom: 8px;
}
.table tbody tr.group-head:hover { background: transparent; }
.group-head .gh {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.group-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  background: none; border: 0; padding: 4px 6px 4px 0; font-weight: 600; color: var(--text); border-radius: 6px;
}
.group-toggle .icon { transition: transform var(--dur) var(--ease); color: var(--text-3); }
tbody.is-collapsed .group-toggle .icon { transform: rotate(-90deg); }
tbody.is-collapsed tr:not(.group-head) { display: none; }
.group-meta { color: var(--text-2); font-size: 13px; }
.group-sub { font-size: 13px; color: var(--text-2); }
.group-sub strong { color: var(--text); font-size: 14px; }
.subtotal-row td { background: var(--surface-2); font-weight: 600; font-size: 13px; color: var(--text-2); }
.subtotal-row td.num { color: var(--text); }

/* ---------- Pills, badges, chips ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.pill.no-dot::before { display: none; }
.pill-success { background: var(--success-soft); color: var(--success-text); }
.pill-warn { background: var(--warn-soft); color: var(--warn-text); }
.pill-danger { background: var(--danger-soft); color: var(--danger-text); }
.pill-info { background: var(--info-soft); color: var(--info-text); }
.pill-accent { background: var(--accent-soft); color: var(--accent-text); }
.pill-muted { background: var(--surface-3); color: var(--text-3); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
  max-width: 100%;
}
.badge .icon { color: var(--text-3); }
.badge.mono { font-family: var(--mono); font-size: 11.5px; }
.badge-warn { border-color: transparent; background: var(--warn-soft); color: var(--warn-text); }

.chip {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 3px 9px; border-radius: 8px;
  background: var(--surface-3); font-size: 12px; color: var(--text-2); white-space: nowrap;
}
.chip b { font-weight: 650; color: var(--text); font-size: 13px; }
.chip.is-zero { opacity: .55; }
.chip-good { background: var(--accent-soft); color: var(--accent-text); }
.chip-good b { color: var(--accent-text); }
.chip-bad b { color: var(--danger-text); }
.chip-warn { background: var(--warn-soft); color: var(--warn-text); }
.chip-warn b { color: var(--warn-text); }

.phase-tag {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--ph-soft); color: var(--ph);
}
.phase-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ph); flex: none; display: inline-block; }
.phase-tag .phase-dot { width: 7px; height: 7px; }
.domain-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.domain-cell .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Callouts ---------- */
.callout {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 16px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: 13.5px;
}
.callout > .icon { margin-top: 1px; }
.callout-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.callout-title { font-weight: 600; }
.callout-text { color: var(--text-2); }
.callout ul { margin: 4px 0 0; padding-left: 18px; color: var(--text-2); }
.callout-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.callout-info { background: var(--info-soft); border-color: transparent; }
.callout-info > .icon { color: var(--info); }
.callout-warn { background: var(--warn-soft); border-color: transparent; }
.callout-warn > .icon { color: var(--warn); }
.callout-warn .callout-title { color: var(--warn-text); }
.callout-danger { background: var(--danger-soft); border-color: transparent; }
.callout-danger > .icon { color: var(--danger); }
.callout-danger .callout-title { color: var(--danger-text); }
.callout-success { background: var(--success-soft); border-color: transparent; }
.callout-success > .icon { color: var(--success); }

/* ---------- Progress / fill bars ---------- */
.progress {
  height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; position: relative;
}
.progress-fill {
  height: 100%; width: 0; border-radius: inherit; background: var(--accent);
  transition: width 160ms linear;
}
.progress.is-indeterminate .progress-fill {
  width: 35% !important; position: absolute; left: 0;
  animation: indeterminate 1.1s var(--ease) infinite;
}
.fill {
  display: flex; align-items: center; gap: 8px; min-width: 120px;
}
.fill-track {
  flex: 1; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; position: relative;
}
.fill-bar { height: 100%; border-radius: inherit; background: var(--ph, var(--accent)); }
.fill.is-short .fill-track {
  background: repeating-linear-gradient(-45deg, var(--danger-soft), var(--danger-soft) 4px, transparent 4px, transparent 8px), var(--surface-3);
}
.fill-pct { font-size: 12px; color: var(--text-3); width: 40px; text-align: right; }
.short-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: 999px; font-weight: 600; font-size: 12.5px;
  background: var(--danger-soft); color: var(--danger-text);
}
.ok-mark { color: var(--success); display: inline-flex; }
.meter { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; width: 160px; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width 200ms var(--ease); }
.meter.is-over > span { background: var(--warn); }

/* ---------- Stepper ---------- */
.stepper {
  list-style: none; margin: 0 0 24px; padding: 6px;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.step-btn {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border: 0; border-radius: 8px; background: transparent; text-align: left;
  color: var(--text-2);
  transition: background var(--dur) var(--ease);
}
.step-btn:hover:not(:disabled) { background: var(--hover); }
.step-btn:disabled { cursor: default; }
.step.is-todo .step-btn:disabled { opacity: .6; }
.step-num {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 650; font-size: 13px;
  border: 1.5px solid var(--border-strong); color: var(--text-3); background: var(--surface);
}
.step.is-current .step-btn { background: var(--accent-soft); color: var(--text); }
.step.is-current .step-num { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.step.is-done .step-num { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.step-text { display: flex; flex-direction: column; min-width: 0; }
.step-label { font-weight: 600; font-size: 14px; color: inherit; }
.step-hint { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 700px) {
  .step-hint { display: none; }
  .step-btn { flex-direction: column; gap: 4px; padding: 8px 4px; text-align: center; }
  .step-label { font-size: 12px; }
}

/* ---------- Wizard ---------- */
.wizard { display: flex; flex-direction: column; min-height: calc(100vh - var(--topbar-h) - 48px); }
.wizard-body { flex: 1; display: flex; flex-direction: column; gap: 16px; padding-bottom: 24px; }
.wizard-body:focus, .wizard-body:focus-visible { outline: none; }
.sticky-bar {
  position: sticky; bottom: 0; z-index: 15;
  margin: 0 -24px -24px;
  padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 20px -14px rgba(16, 24, 40, .35);
}
@media (max-width: 899px) {
  .sticky-bar { margin: 0 -16px -16px; padding: 10px 16px; gap: 8px; }
}
@media (max-width: 600px) {
  .bar-summary { gap: 8px; font-size: 13px; }
  .bar-summary strong, .bar-summary .big { font-size: 14px; }
  .bar-summary .meter { width: 96px; }
  .bar-actions { width: 100%; flex-wrap: nowrap; }
  .bar-actions .btn { flex: 1 1 auto; height: 34px; padding: 0 10px; font-size: 13px; gap: 6px; }
}
.bar-summary { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; color: var(--text-2); }
.bar-summary strong { color: var(--text); font-size: 15px; }
.bar-summary .big { font-size: 15px; color: var(--text); }
.bar-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 32px 16px; text-align: center;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg);
  background: var(--surface-2); color: var(--text-2);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.dropzone:hover { border-color: var(--accent); }
.dropzone:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--accent); }
.dropzone .icon { color: var(--accent-text); }
.dropzone.is-drag { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.005); }
.dz-title { font-size: 15px; font-weight: 600; color: var(--text); }
.dz-title .link { color: var(--accent-text); }
.dz-hint { font-size: 12.5px; color: var(--text-3); }

.queue { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.q-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
  animation: rise-in 160ms var(--ease);
}
.q-item > .icon { color: var(--text-3); }
.q-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.q-top { display: flex; align-items: baseline; gap: 12px; justify-content: space-between; }
.q-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-meta { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.q-item.is-done { border-color: color-mix(in srgb, var(--success) 35%, var(--border)); }
.q-item.is-done .progress-fill { background: var(--success); }
.q-item.is-done > .icon { color: var(--success); }
.q-item.is-error { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); background: var(--danger-soft); }
.q-item.is-error .q-meta { color: var(--danger-text); white-space: normal; }
.q-item.is-error > .icon { color: var(--danger); }
.q-item.is-canceled { opacity: .6; }

.upload-list { display: flex; flex-direction: column; }
.upload-row {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--border);
  transition: background var(--dur) var(--ease);
}
.upload-row:first-child { border-top: 0; }
.upload-row.is-selected { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
.upload-row.is-error { background: color-mix(in srgb, var(--danger-soft) 60%, transparent); }
.ur-head { display: flex; align-items: flex-start; gap: 12px; }
.ur-check { padding-top: 2px; }
.ur-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ur-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; min-width: 0; }
.ur-name { font-weight: 600; overflow-wrap: anywhere; cursor: pointer; }
.ur-meta { font-size: 12.5px; color: var(--text-3); }
.ur-badges, .ur-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.ur-actions { display: flex; gap: 4px; flex: none; align-items: center; }
.ur-details { margin-left: 28px; display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 700px) {
  .ur-head { flex-wrap: wrap; }
  .ur-actions { width: 100%; justify-content: flex-end; }
  .ur-details { margin-left: 0; }
}
.sample-wrap { position: relative; border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; max-height: 340px; }
.sample-table { font-size: 12.5px; width: max-content; min-width: 100%; }
.sample-table th, .sample-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sample-table thead th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; color: var(--text-2); }
.sample-table .is-email { background: var(--accent-soft); }
.sample-table thead th.is-email { color: var(--accent-text); }

.counts-table td { padding-top: 5px; padding-bottom: 5px; }
.counts-table td.count-cell { width: 140px; }
.counts-table .input-num { height: 30px; max-width: 128px; margin-left: auto; display: block; border-radius: 7px; }
.counts-table tr.is-zero .domain-cell .name { color: var(--text-3); }
.counts-table td.elig-cell.is-over { color: var(--warn-text); font-weight: 600; text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
.elig-note { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.elig-note:empty { display: none; }
.phase-set { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.phase-set .input { width: 104px; height: 30px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar .sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
.toolbar .input-num { width: 110px; height: 30px; }

.done-hero {
  display: flex; gap: 16px; align-items: center;
  padding: 24px; border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--success-soft), color-mix(in srgb, var(--accent-soft) 60%, var(--surface)));
  border: 1px solid color-mix(in srgb, var(--success) 25%, var(--border));
}
.done-hero .hero-icon {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--success); color: #fff; box-shadow: 0 6px 16px -6px var(--success);
  animation: pop 260ms var(--ease);
}
.done-hero h3 { font-size: 20px; }
.download-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.dl-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform 80ms var(--ease);
}
.dl-card:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow); }
.dl-card:active { transform: translateY(1px); }
.dl-card .dl-icon {
  width: 36px; height: 36px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: var(--ph-soft, var(--surface-3)); color: var(--ph, var(--text-2));
}
.dl-card.primary { border-color: var(--accent); background: var(--accent-soft); }
.dl-card.primary .dl-icon { background: var(--accent); color: var(--accent-fg); }
.dl-text { display: flex; flex-direction: column; min-width: 0; }
.dl-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-sub { font-size: 12px; color: var(--text-3); }
.dl-card .dl-go { margin-left: auto; color: var(--text-3); }

/* ---------- Tabs ---------- */
.tabs {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-3); border-radius: 10px;
}
.tab {
  height: 30px; padding: 0 14px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text-2); font-weight: 500; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tab .count { font-size: 11px; color: var(--text-3); }
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-3); border-radius: 9px; }
.seg button {
  height: 26px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent;
  font-size: 12.5px; font-weight: 500; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Pager ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pager-info { font-size: 13px; color: var(--text-3); }

/* ---------- Empty, skeleton, error ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
  padding: 40px 24px; color: var(--text-2);
}
.empty-icon {
  width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-3); margin-bottom: 4px;
}
.empty-title { font-weight: 600; color: var(--text); font-size: 15px; }
.empty-text { max-width: 46ch; font-size: 13.5px; color: var(--text-3); }
.empty .btn { margin-top: 8px; }

.skel {
  display: block; height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, var(--skel) 0%, var(--skel-hi) 50%, var(--skel) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
.skel-block { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.skel-lg { height: 26px; width: 50%; }
.skel-row { display: grid; gap: 16px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.skel-card { height: 104px; border-radius: var(--radius-lg); }
.skel-chart { height: 220px; border-radius: var(--radius); }

.boot { min-height: 100vh; display: grid; place-items: center; color: var(--text-3); }
.boot .spinner { width: 28px; height: 28px; }
.spinner {
  display: inline-block; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin .7s linear infinite; vertical-align: middle;
}
.loading-note { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 13.5px; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none; max-width: calc(100vw - 32px);
}
.toast {
  pointer-events: auto;
  display: flex; gap: 10px; align-items: flex-start;
  width: 380px; max-width: 100%;
  padding: 12px 12px 12px 14px; border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  animation: toast-in 180ms var(--ease);
  font-size: 13.5px;
}
.toast.is-leaving { animation: toast-out 160ms var(--ease) forwards; }
body:has(.sticky-bar) .toasts { bottom: 80px; }
@media (max-width: 600px) {
  .toasts { left: 16px; right: 16px; align-items: stretch; }
  body:has(.sticky-bar) .toasts { bottom: 120px; }
  .toast { width: auto; }
}
.toast-icon { margin-top: 1px; display: inline-flex; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warn .toast-icon { color: var(--warn); }
.toast-info .toast-icon { color: var(--info); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.toast-close {
  border: 0; background: none; color: var(--text-3); padding: 2px; border-radius: 4px; display: inline-flex;
}
.toast-close:hover { color: var(--text); background: var(--hover); }

/* ---------- Modal ---------- */
dialog.modal {
  padding: 0; border: 0; background: transparent; color: var(--text);
  max-width: calc(100vw - 32px); width: 460px; max-height: calc(100vh - 48px);
  overflow: visible;
}
dialog.modal.modal-md { width: 560px; }
dialog.modal::backdrop { background: var(--overlay); animation: fade-in 160ms var(--ease); }
dialog.modal[open] .modal-card { animation: modal-in 180ms var(--ease); }
.modal-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; max-height: calc(100vh - 48px);
}
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 0; }
.modal-head .m-icon {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent-text);
}
.modal-head .m-icon.danger { background: var(--danger-soft); color: var(--danger); }
.modal-head .m-icon.warn { background: var(--warn-soft); color: var(--warn); }
.modal-head h3 { font-size: 16px; padding-top: 6px; }
.modal-body { padding: 12px 20px 4px; color: var(--text-2); overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-body ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.modal-body strong { color: var(--text); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 20px 20px; flex-wrap: wrap; }
.confirm-type code { background: var(--surface-3); padding: 1px 6px; border-radius: 4px; color: var(--text); }

/* ---------- Charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart:focus-visible { outline: none; }
.chart svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis-label { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .line { fill: none; stroke: var(--chart-color, var(--accent)); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area-stop-a { stop-color: var(--chart-color, var(--accent)); stop-opacity: .22; }
.chart .area-stop-b { stop-color: var(--chart-color, var(--accent)); stop-opacity: 0; }
.chart .bar { fill: var(--chart-color, var(--accent)); opacity: .35; }
.chart .hover-line { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hover-dot { fill: var(--surface); stroke: var(--chart-color, var(--accent)); stroke-width: 2; }
.chart-tip {
  position: absolute; top: 0; left: 0; pointer-events: none; z-index: 5;
  background: var(--text); color: var(--bg);
  padding: 6px 10px; border-radius: 8px; font-size: 12px; line-height: 1.4;
  box-shadow: var(--shadow-lg); white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px));
}
.chart-tip b { font-weight: 650; }
.chart-empty { height: 100%; display: grid; place-items: center; color: var(--text-3); font-size: 13px; }
.spark { display: block; overflow: visible; }
.spark .spark-line { fill: none; stroke: var(--ph, var(--accent)); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark .spark-area { fill: var(--ph-soft, var(--accent-soft)); }
.spark .spark-dot { fill: var(--ph, var(--accent)); }

.hbar-list { display: flex; flex-direction: column; gap: 16px; }
.hbar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.hbar-name { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.hbar-val { font-size: 13px; color: var(--text-2); }
.hbar-val b { color: var(--text); }
.hbar-track { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: inherit; background: var(--ph); transition: width 300ms var(--ease); }
.hbar-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* phase summary cards */
.phase-card { border-top: 3px solid var(--ph); }
.phase-card .phase-big { font-size: 22px; font-weight: 650; }

/* health strip */
.health { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.health > div { padding: 14px 20px; border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.health > div:first-child { border-left: 0; }
.health .h-label { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.health .h-value { font-weight: 600; }
@media (max-width: 900px) {
  .health { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .health > div:nth-child(3) { border-left: 0; }
  .health > div:nth-child(n+3) { border-top: 1px solid var(--border); }
}

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { font-size: 11px; color: var(--text-3); text-align: center; font-weight: 600; text-transform: uppercase; padding-bottom: 4px; }
.cal-day {
  position: relative; aspect-ratio: 1 / 1; min-height: 34px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between;
  padding: 4px 6px; font-size: 12px; color: var(--text-2); text-align: left;
  transition: border-color var(--dur) var(--ease), transform 80ms var(--ease);
}
.cal-day:hover:not(:disabled) { border-color: var(--accent); }
.cal-day:disabled { cursor: default; }
.cal-day.is-out { visibility: hidden; }
.cal-day.is-today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-day.is-selected { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-day.lv1 { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.cal-day.lv2 { background: color-mix(in srgb, var(--accent) 26%, var(--surface)); }
.cal-day.lv3 { background: color-mix(in srgb, var(--accent) 44%, var(--surface)); color: var(--text); }
.cal-day.lv4 { background: color-mix(in srgb, var(--accent) 66%, var(--surface)); color: var(--accent-fg); }
.cal-dots { display: flex; gap: 3px; }
.cal-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-3); display: block; }
.cal-dots i.up { background: var(--info); }
.cal-dots i.run { background: var(--success); }
.cal-legend { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--text-3); flex-wrap: wrap; }
.cal-legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; vertical-align: middle; margin-right: 4px; }

/* details / key-value */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* login */
.auth-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(900px 500px at 15% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%),
    radial-gradient(700px 420px at 110% 110%, color-mix(in srgb, var(--p2) 10%, transparent), transparent 70%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-lg); padding: 32px;
  animation: rise-in 220ms var(--ease);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-brand .brand-mark { width: 40px; height: 40px; border-radius: 11px; }
.auth-brand h1 { font-size: 20px; }
.auth-brand p { font-size: 13px; color: var(--text-3); }
.auth-foot { margin-top: 20px; font-size: 12px; color: var(--text-3); text-align: center; display: flex; justify-content: center; align-items: center; gap: 6px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 44px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }

/* lookup */
.lookup-result { border-top: 1px solid var(--border); }
.lookup-flags { display: flex; gap: 8px; flex-wrap: wrap; }

/* misc */
.divider { height: 1px; background: var(--border); margin: 4px 0; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.order-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-width: 360px; }
.order-list li {
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
}
.order-list .ord-n { width: 20px; color: var(--text-3); font-size: 12px; }
.example-box {
  font-family: var(--mono); font-size: 12.5px; padding: 8px 10px; border-radius: 8px;
  background: var(--surface-3); color: var(--text); overflow-wrap: anywhere;
}
.settings-section { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 24px; padding: 24px 20px; border-top: 1px solid var(--border); }
.settings-section:first-child { border-top: 0; }
.settings-section h3 { font-size: 15px; }
.settings-section .s-desc { color: var(--text-3); font-size: 13px; margin-top: 4px; }
@media (max-width: 900px) {
  .settings-section { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}
.detail-json { font-family: var(--mono); font-size: 12px; color: var(--text-2); overflow-wrap: anywhere; }
.detail-json .k { color: var(--text-3); }
.panel-sticky { position: sticky; top: calc(var(--topbar-h) + 16px); }
.inline-edit { border-color: transparent; box-shadow: none; background: transparent; padding: 0 8px; height: 30px; font-weight: 500; }
.inline-edit:hover { border-color: var(--border-strong); }
.inline-edit:focus { background: var(--surface); }
.not-found { padding: 48px 0; }

/* ---------- Animations ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.06); } 100% { transform: none; opacity: 1; } }
@keyframes indeterminate { 0% { left: -35%; } 100% { left: 100%; } }
.fade-in { animation: rise-in 180ms var(--ease); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .skel { animation: none; }
}

@media print {
  .sidebar, .topbar, .sticky-bar, .toasts { display: none !important; }
  .app { display: block; }
}
