/* Palette sampled from dashboard/ui/script_controller Stitch design. */

:root {
  --primary: #9e1b24;
  --primary-container: #c5232d;
  --primary-hover: #a91d27;
  --secondary: #a51f29;
  --secondary-container: #ffe1df;
  --on-secondary-container: #8f1b24;
  --secondary-fixed-dim: #f3b7b3;

  --surface: #f7f7f8;
  --surface-lowest: #ffffff;
  --surface-low: #f2f2f4;
  --surface-container: #ebebee;
  --surface-high: #e3e3e7;
  --surface-highest: #dadadf;

  --on-surface: #1d1b1e;
  --on-surface-variant: #4a4649;
  --outline: #77727a;
  --outline-variant: #cdc8cc;

  --ok: #1f6349;
  --ok-bg: #dbfceb;
  --ok-dot: #276a4f;
  --bad: #93000a;
  --bad-bg: #ffdad6;
  --bad-dot: #ba1a1a;
  --bad-row: #fff9f9;
  --warn: #633f00;
  --warn-bg: #ffe9be;
  --warn-dot: #885900;
  --warn-row: #fffcf7;
  --off: #77727a;
  --off-bg: #f4f4f6;
  --off-dot: #cdc8cc;
  --off-row: #fcfcfd;

  --bq: #12386e;
  --bq-bg: #dce9ff;
  --mysql: #633f00;
  --mysql-bg: #ffddb4;

  --sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, monospace;

  --rail-w: 240px;
  --bar-h: 56px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

/* If the Material Symbols webfont is unavailable, drop the glyph slots rather
   than printing their ligature names. */
.no-icons .ms { display: none !important; }

.ms {
  font-family: "Material Symbols Outlined";
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  -webkit-font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
  font-size: 18px;
  flex: none;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--on-surface);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; }
p { margin: 0; }
a { color: inherit; }

.mono { font-family: var(--mono); }
.dim { color: var(--outline); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.strong { font-weight: 600; }
.row-gap { display: flex; align-items: center; gap: 8px; }

.caps {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
}

/* ── rail ────────────────────────────────────────────────────────────────── */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--rail-w);
  background: var(--surface-lowest);
  border-right: 1px solid rgba(205, 200, 204, 0.5);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 30;
}

.brand {
  height: var(--bar-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid rgba(205, 200, 204, 0.35);
}

.brand-left { display: flex; align-items: center; gap: 10px; min-width: 0; }

.logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex: none;
}

.brand-name { font-size: 15px; font-weight: 600; line-height: 1.15; }
.brand-left { text-decoration: none; flex: 1 1 auto; min-width: 0; }
.brand-logo { display: block; width: auto; height: auto; max-height: 33px; max-width: 100%; object-fit: contain; }
.foot-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 10px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--outline);
}
.foot-brand img { height: 22px; width: auto; display: block; }
.brand-sub { font-size: 10px; color: var(--on-surface-variant); }

.env-pill {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--on-secondary-container);
  background: var(--secondary-container);
  border: 1px solid var(--secondary-fixed-dim);
  border-radius: 4px;
  padding: 2px 6px;
  flex: none;
}

.nav-group { padding: 12px; }
.nav-group + .nav-group { border-top: 1px solid rgba(205, 200, 204, 0.35); }
.nav-heading { padding: 4px 12px 6px; }
.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--on-surface-variant);
  font-size: 13px;
  font-weight: 500;
}

.nav-item:hover { background: var(--surface-container); color: var(--on-surface); }

.nav-item.active {
  background: var(--primary-container);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(158, 27, 36, 0.25);
}

.nav-item .ms { font-size: 18px; }
.nav-foot { padding: 12px; border-top: 1px solid rgba(205, 200, 204, 0.35); }

.collapse {
  width: 100%;
  border: none;
  background: none;
  color: var(--on-surface-variant);
  padding: 5px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  justify-content: center;
}

.collapse:hover { background: var(--surface-container); }

/* the links scroll when they don't fit; the footer (with the collapse button) stays in view */
.sidebar > div:first-child { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.sidebar > .nav-foot { flex: none; background: var(--surface-lowest); }

/* collapsed rail: icons only (assets/js/core.js, remembered per browser) */
.brand-mark { display: none; width: 30px; height: 30px; object-fit: contain; }
.sidebar, .shell, .topbar { transition: width 0.18s ease, padding-left 0.18s ease, left 0.18s ease; }
.collapse .ms { transition: transform 0.18s ease; }
html[data-rail="collapsed"] { --rail-w: 68px; }
html[data-rail="collapsed"] .collapse .ms { transform: rotate(180deg); }
html[data-rail="collapsed"] .sidebar { overflow-x: hidden; }
html[data-rail="collapsed"] .brand { padding: 0; justify-content: center; }
html[data-rail="collapsed"] .brand-left { flex: none; }
html[data-rail="collapsed"] .brand-logo,
html[data-rail="collapsed"] .env-pill,
html[data-rail="collapsed"] .nav-heading,
html[data-rail="collapsed"] .foot-brand span,
html[data-rail="collapsed"] .nav-item > span:not(.ms),
html[data-rail="collapsed"] .nav-item .nav-lock { display: none; }
html[data-rail="collapsed"] .brand-mark { display: block; }
html[data-rail="collapsed"] .nav-group { padding: 10px 8px; }
html[data-rail="collapsed"] .nav-item { justify-content: center; padding: 10px 0; gap: 0; }
html[data-rail="collapsed"] .nav-item .ms { font-size: 20px; }
html[data-rail="collapsed"] .nav-foot { padding: 10px 8px; }
html[data-rail="collapsed"] .foot-brand { justify-content: center; padding: 4px 0 10px; }
html[data-rail="collapsed"] .foot-brand img { max-width: 44px; height: auto; }
/* if the icon font is blocked, letters stand in for the icons */
html[data-rail="collapsed"] .no-icons .nav-item::before { content: attr(data-short); font-size: 12px; font-weight: 700; letter-spacing: 0.02em; }
.no-icons .collapse::after { content: "\00AB"; font-size: 16px; line-height: 1; }
html[data-rail="collapsed"] .no-icons .collapse::after { content: "\00BB"; }

/* ── topbar ──────────────────────────────────────────────────────────────── */

.shell { padding-left: var(--rail-w); }

.topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: var(--rail-w);
  height: var(--bar-h);
  background: var(--surface-lowest);
  border-bottom: 1px solid rgba(205, 200, 204, 0.5);
  z-index: 20;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.crumb { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--on-surface-variant); }
.crumb strong { font-size: 15px; font-weight: 600; color: var(--on-surface); }
.crumb .sep { color: var(--outline-variant); }

.searchbar { flex: 1; max-width: 520px; position: relative; display: flex; align-items: center; }
.searchbar .ms { position: absolute; left: 12px; color: var(--on-surface-variant); pointer-events: none; }

.searchbar input {
  width: 100%;
  height: 34px;
  padding: 0 52px 0 36px;
  background: var(--surface);
  border: 1px solid rgba(205, 200, 204, 0.7);
  border-radius: 6px;
  font: inherit;
  color: var(--on-surface);
}

kbd {
  position: absolute;
  right: 10px;
  font-family: var(--mono);
  font-size: 10px;
  background: var(--surface-container);
  color: var(--on-surface-variant);
  border: 1px solid rgba(205, 200, 204, 0.6);
  border-radius: 4px;
  padding: 2px 5px;
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 18px; }

.sync {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--on-surface-variant);
}

.sync .live { width: 8px; height: 8px; border-radius: 50%; background: var(--ok-dot); }

.icon-btn {
  border: none;
  background: none;
  color: var(--on-surface-variant);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover { background: var(--surface-container); color: var(--on-surface); }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex: none;
}

.avatar.sm { width: 22px; height: 22px; font-size: 9px; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }

/* ── page ────────────────────────────────────────────────────────────────── */

main { padding-top: var(--bar-h); }
.page { padding: 20px 24px 28px; display: flex; flex-direction: column; gap: 16px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.page-crumb { display: flex; gap: 7px; font-size: 12px; color: var(--on-surface-variant); margin-bottom: 4px; }
.page-crumb .here { color: var(--primary-container); font-weight: 600; }
.page-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.page-title h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.page-title .sub { font-size: 13px; color: var(--on-surface-variant); }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  padding: 8px 13px;
  cursor: pointer;
  border: 1px solid var(--outline-variant);
  background: var(--surface-lowest);
  color: var(--on-surface);
}

.btn .ms { font-size: 17px; }
.btn:hover:not(:disabled) { background: var(--surface-container); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.primary { background: var(--primary-container); border-color: var(--primary-container); color: #fff; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn.sm { padding: 5px 10px; font-size: 12px; }

/* tabs + metrics */

.tabrow { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }

.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-low);
  border: 1px solid rgba(205, 200, 204, 0.55);
  border-radius: 8px;
  padding: 4px;
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  background: none;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--on-surface-variant);
}

.tab:hover { color: var(--on-surface); }
.tab.active { background: var(--surface-lowest); border-color: rgba(205, 200, 204, 0.6); color: var(--on-surface); font-weight: 600; }
.tab .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--outline-variant); }
.tab[data-filter="due"] .dot, .tab[data-filter="pending"] .dot, .tab[data-filter="stale"] .dot { background: var(--warn-dot); }
.tab[data-filter="failed"] .dot { background: var(--bad-dot); }
.tab[data-filter="all"] .dot { display: none; }
.tab[data-filter="paused"] .dot, .tab[data-filter="inactive"] .dot { background: var(--off-dot); }

.tab-count {
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  background: var(--surface-container);
  border-radius: 4px;
  padding: 1px 6px;
}

.tab.active .tab-count { background: var(--surface-high); }

.metrics { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.metric { display: flex; align-items: center; gap: 7px; font-size: 11px; }
.metric .label { letter-spacing: 0.08em; text-transform: uppercase; color: var(--on-surface-variant); font-weight: 600; }
.metric .value { font-family: var(--mono); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric .dot { width: 7px; height: 7px; border-radius: 50%; }
.metric .dot.warn { background: var(--warn-dot); }
.metric .dot.ok { background: var(--ok-dot); }
.metric .dot.bad { background: var(--bad-dot); }
.metric.bad .value { color: var(--bad-dot); }

/* filters */

.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filter-search { position: relative; display: flex; align-items: center; flex: 1; min-width: 240px; max-width: 380px; }
.filter-search .ms { position: absolute; left: 11px; color: var(--on-surface-variant); pointer-events: none; font-size: 17px; }

.filter-search input {
  width: 100%;
  height: 36px;
  padding: 0 44px 0 34px;
  border: 1px solid var(--outline-variant);
  border-radius: 6px;
  background: var(--surface-lowest);
  font: inherit;
  color: var(--on-surface);
}

select {
  height: 36px;
  border: 1px solid var(--outline-variant);
  border-radius: 6px;
  background: var(--surface-lowest);
  font: inherit;
  font-size: 13px;
  color: var(--on-surface);
  padding: 0 8px;
  cursor: pointer;
}

input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--primary-container);
  outline-offset: -1px;
}

.link-btn {
  border: none;
  background: none;
  font: inherit;
  font-size: 12px;
  color: var(--on-surface-variant);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px;
}

.link-btn:hover { color: var(--primary-container); }

.message {
  border-left: 3px solid var(--bad-dot);
  background: var(--bad-bg);
  color: var(--bad);
  border-radius: 0 6px 6px 0;
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 12px;
}

/* ── table ───────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface-lowest);
  border: 1px solid rgba(205, 200, 204, 0.55);
  border-radius: 10px;
  overflow: hidden;
}

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }

th, td {
  text-align: left;
  padding: 11px 14px;
  white-space: nowrap;
  vertical-align: middle;
}

th {
  background: var(--surface-low);
  border-bottom: 1px solid rgba(205, 200, 204, 0.55);
  font-size: 11px;
  font-weight: 600;
  color: var(--on-surface-variant);
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody td { border-bottom: 1px solid rgba(205, 200, 204, 0.3); }
tbody tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-low); }
tbody tr.row-bad { background: var(--bad-row); }
tbody tr.row-warn { background: var(--warn-row); }
tbody tr.row-off { background: var(--off-row); }
tbody tr.row-off td:not(.act) { opacity: 0.55; }
tbody tr.selected { box-shadow: inset 0 0 0 2px var(--primary-container); }

.stack { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; line-height: 1.35; min-width: 0; max-width: 100%; }
.stack .name { font-weight: 600; font-size: 13px; }
.stack .path { font-family: var(--mono); font-size: 11px; color: var(--on-surface-variant); }
tr.row-bad .stack .name, tr.row-bad .stack .path { color: var(--bad-dot); }

/* max-width on a <td> is ignored under table-layout:auto, so the cell grows and
   its text paints over the next column. Fixed layout + <colgroup> gives every
   column a definite width, which is what makes the ellipsis below work. */
.table-fixed { table-layout: fixed; min-width: 1180px; }
.table-fixed td { overflow: hidden; }

.table-fixed td .stack,
.table-fixed td .source { max-width: 100%; min-width: 0; }

.table-fixed td .name,
.table-fixed td .path,
.table-fixed td .card-path {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-fixed td .source .name { flex: 1; min-width: 0; }
.table-fixed td .row-gap { max-width: 100%; min-width: 0; }
td.act { text-align: center; }
td.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.when { font-family: var(--mono); font-size: 11px; font-variant-numeric: tabular-nums; }
td.overdue .when { color: var(--warn-dot); font-weight: 600; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 20px;
  padding: 4px 10px 4px 8px;
  border: 1px solid transparent;
}

.pill .dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.pill.ok { background: var(--ok-bg); color: var(--ok); border-color: #b9e6cf; }
.pill.ok .dot { background: var(--ok-dot); }
.pill.bad { background: var(--bad-bg); color: var(--bad); border-color: #f2b8b5; }
.pill.bad .dot { background: var(--bad-dot); }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: #f0cd8e; }
.pill.warn .dot { background: var(--warn-dot); }
.pill.off { background: var(--off-bg); color: var(--off); border-color: var(--outline-variant); }
.pill.off .dot { background: var(--off-dot); }

.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  border-radius: 5px;
  padding: 3px 8px;
}

.badge.bq { background: var(--bq-bg); color: var(--bq); }
.badge.sql { background: var(--mysql-bg); color: var(--mysql); }

.mode {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  border: 1px solid var(--outline-variant);
  border-radius: 5px;
  padding: 3px 8px;
  color: var(--on-surface-variant);
}

.owner { display: flex; align-items: center; gap: 7px; }

.switch {
  appearance: none;
  border: none;
  width: 34px;
  height: 18px;
  border-radius: 10px;
  position: relative;
  background: var(--outline-variant);
  cursor: pointer;
  padding: 0;
  vertical-align: middle;
  transition: background 0.12s;
}

.switch.on { background: var(--ok-dot); }
.switch:disabled { opacity: 0.4; cursor: not-allowed; }

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.12s;
}

.switch.on::after { left: 18px; }

.approve-btn {
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #f0cd8e;
  color: var(--warn);
  background: var(--warn-bg);
  border-radius: 5px;
  padding: 3px 10px;
  cursor: pointer;
}

.approve-btn:hover { background: var(--warn-dot); border-color: var(--warn-dot); color: #fff; }
.approved { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--ok); font-weight: 600; }

.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  background: var(--surface-low);
  font-size: 12px;
  color: var(--on-surface-variant);
}

.pages { display: flex; align-items: center; gap: 4px; }

.pages button {
  min-width: 30px;
  height: 30px;
  border: 1px solid var(--outline-variant);
  background: var(--surface-lowest);
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  color: var(--on-surface);
  padding: 0 8px;
}

.pages button:hover:not(:disabled):not(.current) { background: var(--surface-container); }
.pages button.current { background: var(--primary-container); border-color: var(--primary-container); color: #fff; font-weight: 600; }
.pages button:disabled { opacity: 0.45; cursor: default; }

.empty { padding: 48px 20px; text-align: center; color: var(--outline); }
.empty strong { display: block; color: var(--on-surface-variant); margin-bottom: 4px; font-size: 14px; }

/* ── bottom cards ────────────────────────────────────────────────────────── */

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.info-card { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; }
.info-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.info-title { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; }
.info-title .ms { font-size: 19px; }
.info-body { font-size: 12px; color: var(--on-surface-variant); line-height: 1.55; }
.info-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-family: var(--mono); font-size: 11px; color: var(--on-surface-variant); }

.tag {
  font-size: 11px;
  font-weight: 600;
  border-radius: 5px;
  padding: 3px 9px;
}

.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag.ok { background: var(--ok-bg); color: var(--ok); }

.meter { display: flex; flex-direction: column; gap: 5px; }
.meter-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 12px; }
.meter-row .v { font-family: var(--mono); font-weight: 600; }
.meter-track { height: 7px; background: var(--surface-container); border-radius: 4px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--secondary); border-radius: 4px; }
.meter-fill.warn { background: var(--warn-dot); }
.meter-fill.bad { background: var(--bad-dot); }

/* ── split (DB user) ─────────────────────────────────────────────────────── */

.split { display: grid; grid-template-columns: minmax(300px, 36%) 1fr; gap: 16px; align-items: start; }
.split-left { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.split-right { padding: 20px 22px; min-height: 420px; }
.chip-filters { display: flex; flex-wrap: wrap; gap: 6px; }

.filter-chip {
  font: inherit;
  font-size: 11px;
  border: 1px solid var(--outline-variant);
  background: var(--surface-lowest);
  border-radius: 20px;
  padding: 4px 11px;
  cursor: pointer;
  color: var(--on-surface-variant);
}

.filter-chip:hover { border-color: var(--primary-container); color: var(--primary-container); }
.filter-chip.active { border-color: var(--primary-container); background: var(--primary-container); color: #fff; }

.account-list { max-height: 560px; overflow: auto; border: 1px solid rgba(205, 200, 204, 0.55); border-radius: 8px; }

.account {
  width: 100%;
  border: none;
  border-bottom: 1px solid rgba(205, 200, 204, 0.3);
  border-left: 3px solid transparent;
  background: var(--surface-lowest);
  font: inherit;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
}

.account:hover { background: var(--surface-low); }
.account.active { background: var(--surface-container); border-left-color: var(--primary-container); }
.account-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.account-name { font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.account-name .at { color: var(--outline); }
.account-sub { font-size: 11px; color: var(--on-surface-variant); }

.warn-flag { font-size: 10px; font-weight: 700; color: var(--warn); background: var(--warn-bg); border-radius: 4px; padding: 2px 6px; flex: none; }
.placeholder { padding: 48px 20px; text-align: center; color: var(--outline); }
.placeholder strong { display: block; color: var(--on-surface-variant); margin-bottom: 4px; }

.detail-head { display: flex; align-items: center; gap: 13px; padding-bottom: 16px; border-bottom: 1px solid rgba(205, 200, 204, 0.5); }
.facts { display: flex; flex-wrap: wrap; gap: 26px; padding: 16px 0; border-bottom: 1px solid rgba(205, 200, 204, 0.5); }
.fact { display: flex; flex-direction: column; gap: 3px; }
.fact-label { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--on-surface-variant); font-weight: 600; }
.fact-value { font-family: var(--mono); font-size: 13px; }
.fact-value.warn { color: var(--warn); font-weight: 600; background: var(--warn-bg); border-radius: 4px; padding: 1px 7px; margin-left: -7px; }
.fact-value.ok { color: var(--ok); font-weight: 600; }

.grant-block { padding: 16px 0; border-bottom: 1px solid rgba(205, 200, 204, 0.3); display: flex; flex-direction: column; gap: 10px; }
.grant-privs { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grant-names { display: flex; flex-wrap: wrap; gap: 6px; }
.grant-name { font-family: var(--mono); font-size: 11px; background: var(--surface-low); border: 1px solid rgba(205, 200, 204, 0.5); border-radius: 5px; padding: 3px 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-family: var(--mono); font-size: 10px; font-weight: 500; border-radius: 4px; padding: 2px 7px; background: var(--surface-container); color: var(--on-surface-variant); }
.chip.write { background: var(--warn-bg); color: var(--warn); font-weight: 700; }

/* ── drawer ──────────────────────────────────────────────────────────────── */

.scrim { position: fixed; inset: 0; background: rgba(29, 27, 30, 0.32); z-index: 40; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 720px;
  max-width: 100vw;
  height: 100vh;
  background: var(--surface-lowest);
  z-index: 41;
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 40px rgba(29, 27, 30, 0.16);
}

.drawer-top { padding: 18px 24px 0; display: flex; flex-direction: column; gap: 14px; border-bottom: 1px solid rgba(205, 200, 204, 0.5); }
.drawer-title { display: flex; align-items: center; gap: 12px; }
.drawer-title h2 { font-family: var(--mono); font-size: 19px; font-weight: 600; }
.drawer-title .spacer { flex: 1; }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-bottom: 16px; }

.drawer-body { flex: 1; overflow: auto; padding: 20px 24px 28px; display: flex; flex-direction: column; gap: 26px; }
.section { display: flex; flex-direction: column; gap: 10px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }

.panel {
  background: var(--surface);
  border: 1px solid rgba(205, 200, 204, 0.5);
  border-radius: 10px;
  padding: 16px 18px;
}

.overview { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 28px; }
.ov { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ov-label { font-size: 11px; color: var(--on-surface-variant); }
.ov-value { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
.ov-value.plain { font-family: var(--sans); font-weight: 600; }

.sched-line { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; }
.sched-line + .sched-line { border-top: 1px solid rgba(205, 200, 204, 0.4); }
.sched-line .ms { color: var(--on-surface-variant); font-size: 19px; margin-top: 1px; }
.sched-main { font-size: 13px; font-weight: 600; }
.sched-sub { font-family: var(--mono); font-size: 11px; color: var(--on-surface-variant); }
.sched-line.overdue .ms, .sched-line.overdue .sched-main { color: var(--warn-dot); }

.runbars { display: flex; align-items: flex-end; gap: 4px; height: 76px; }
.runbar { flex: 1; min-width: 6px; background: var(--ok-dot); border-radius: 2px 2px 0 0; }
.runbar.bad { background: var(--bad-dot); }
.runbar.skip { background: var(--outline-variant); }
.runbar-foot { display: flex; justify-content: space-between; font-size: 11px; color: var(--on-surface-variant); margin-top: 8px; }

.sql-box {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  background: var(--surface-low);
  border: 1px solid rgba(205, 200, 204, 0.5);
  border-radius: 8px;
  padding: 14px;
  max-height: 340px;
  overflow: auto;
  white-space: pre;
  margin: 0;
}

.field-group { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; font-weight: 500; }
.field .hint { font-size: 11px; color: var(--outline); }

.field input, .field textarea {
  font-family: var(--mono);
  font-size: 12px;
  border: 1px solid var(--outline-variant);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--surface-lowest);
  color: var(--on-surface);
  resize: vertical;
}

.field input:disabled, .field textarea:disabled { background: var(--surface-low); color: var(--on-surface-variant); }
.field.changed input, .field.changed textarea { border-color: var(--ok-dot); background: #f1faf6; }

.drawer-foot { border-top: 1px solid rgba(205, 200, 204, 0.5); padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.drawer-note { font-size: 12px; color: var(--on-surface-variant); }
.drawer-note.error { color: var(--bad-dot); }

/* ── toast ───────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 13px;
  box-shadow: 0 10px 28px rgba(158, 27, 36, 0.3);
}

.toast .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--secondary-container); flex: none; }
.toast.bad { background: #8c1d18; box-shadow: 0 10px 28px rgba(140, 29, 24, 0.3); }
.toast.bad .dot { background: var(--bad-bg); }

@media (max-width: 1100px) {
  html[data-rail="collapsed"] { --rail-w: 240px; }
  .collapse { display: none; }
  .sidebar { position: static; width: 100%; }
  .shell { padding-left: 0; }
  .topbar { position: static; left: 0; }
  main { padding-top: 0; }
  .split { grid-template-columns: 1fr; }
  .overview { grid-template-columns: 1fr; }
}

/* ── card view ───────────────────────────────────────────────────────────── */

.view-toggle {
  display: flex;
  gap: 2px;
  background: var(--surface-low);
  border: 1px solid var(--outline-variant);
  border-radius: 7px;
  padding: 3px;
  margin-left: auto;
}

.view-toggle button {
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: none;
  font: inherit;
  font-size: 12px;
  color: var(--on-surface-variant);
  border-radius: 5px;
  padding: 5px 11px;
  cursor: pointer;
}

.view-toggle button .ms { font-size: 16px; }
.view-toggle button:hover { color: var(--on-surface); }
.view-toggle button.active { background: var(--surface-lowest); color: var(--primary-container); font-weight: 600; box-shadow: 0 1px 2px rgba(29, 27, 30, 0.08); }

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 14px;
}

.job-card {
  background: var(--surface-lowest);
  border: 1px solid rgba(205, 200, 204, 0.55);
  border-top: 3px solid var(--off-dot);
  border-radius: 10px;
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  transition: box-shadow 0.12s, transform 0.12s;
}

.job-card:hover { box-shadow: 0 6px 20px rgba(29, 27, 30, 0.1); transform: translateY(-1px); }
.job-card.ok { border-top-color: var(--ok-dot); }
.job-card.bad { border-top-color: var(--bad-dot); background: var(--bad-row); }
.job-card.warn { border-top-color: var(--warn-dot); background: var(--warn-row); }
.job-card.off { border-top-color: var(--off-dot); background: var(--off-row); }
.job-card.off .card-id, .job-card.off .card-facts { opacity: 0.6; }

.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-id { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.card-name { font-family: var(--mono); font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.job-card.bad .card-name { color: var(--bad-dot); }
.card-path { font-family: var(--mono); font-size: 11px; color: var(--on-surface-variant); overflow-wrap: anywhere; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.card-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  padding: 11px 0;
  border-top: 1px solid rgba(205, 200, 204, 0.4);
  border-bottom: 1px solid rgba(205, 200, 204, 0.4);
  font-size: 12px;
}

.card-facts dt { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--on-surface-variant); font-weight: 600; align-self: center; }
.card-facts dd { margin: 0; text-align: right; font-family: var(--mono); font-size: 12px; }
.card-facts dd.overdue { color: var(--warn-dot); font-weight: 600; }
.card-facts dd.flow { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }

.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-owner { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--on-surface-variant); min-width: 0; }
.card-owner span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-actions { display: flex; align-items: center; gap: 8px; flex: none; }

/* ── catalog ─────────────────────────────────────────────────────────────── */

.count-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--surface-low);
  border: 1px solid rgba(205, 200, 204, 0.55);
  border-radius: 5px;
  padding: 3px 9px;
}

.count-chip small { font-family: var(--sans); font-size: 10px; font-weight: 500; color: var(--on-surface-variant); }

.lineage-list { display: flex; flex-direction: column; gap: 1px; }

.lineage-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.lineage-row + .lineage-row { border-top: 1px solid rgba(205, 200, 204, 0.35); }
.lineage-row.off { opacity: 0.5; }
.lineage-row .flow-arrow { color: var(--primary-container); font-size: 17px; }
.lineage-name { flex: 1; min-width: 0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lineage-flow { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.flow-node {
  flex: 1;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface-lowest);
  border: 1px solid var(--outline-variant);
  border-radius: 8px;
  padding: 11px 13px;
}

.flow-node .mono { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.flow-node.built { border-color: var(--primary-container); background: #fdf3f3; }
.flow-big { color: var(--primary-container); font-size: 26px; }

/* ── tree view ───────────────────────────────────────────────────────────── */

.tree-split {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

@media (max-width: 1180px) {
  .tree-split { grid-template-columns: minmax(0, 1fr); }
}

.filters .spacer { flex: 1; }

.depth-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--on-surface-variant);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(205, 200, 204, 0.55);
  background: var(--surface-low);
}

.panel-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.panel-title .ms { font-size: 18px; color: var(--primary-container); }
.pad { padding: 14px 16px; }

.tree { padding: 10px 12px 16px; max-height: 620px; overflow: auto; }

.tkids {
  margin-left: 13px;
  padding-left: 16px;
  border-left: 1px dashed var(--outline-variant);
}

.tnode {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 7px;
  cursor: pointer;
  min-width: 0;
}

.tnode:hover { background: var(--surface-low); }
.tnode.off { opacity: 0.55; }

.tname {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.tmeta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  font-size: 11px;
  color: var(--on-surface-variant);
}

.tico { font-size: 18px; flex: none; }
.kind-project > .tico { color: var(--primary); }
.kind-project .tname { font-weight: 700; font-size: 13.5px; }
.kind-schema > .tico { color: var(--primary-container); }
.kind-table > .tico { color: var(--secondary); font-size: 16px; }
.kind-table .tname { font-size: 12px; font-weight: 500; }
.kind-stray > .tico { color: var(--warn-dot); }

.kind-table.on {
  background: var(--secondary-container);
  box-shadow: inset 2px 0 0 var(--primary-container);
}

.kind-table.on .tname { color: var(--primary); font-weight: 700; }

.twist {
  flex: none;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: none;
  background: none;
  border-radius: 5px;
  padding: 0;
  cursor: pointer;
  color: var(--on-surface-variant);
}

.twist .ms { font-size: 18px; transition: transform 0.12s ease; }
.twist.open .ms { transform: rotate(90deg); }
.twist:hover { background: var(--surface-container); }
.twist[disabled] { opacity: 0.25; cursor: default; }
.twist-gap { width: 20px; flex: none; }

.edge-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  border-radius: 20px;
  padding: 2px 7px 2px 5px;
}

.edge-chip .ms { font-size: 13px; }
.edge-chip.up { background: var(--surface-high); color: var(--bq); }
.edge-chip.down { background: var(--ok-bg); color: var(--ok); }
.edge-chip.none { color: var(--outline-variant); padding: 2px 6px; }

/* ── dependency walk ─────────────────────────────────────────────────────── */

.flow-body { padding: 14px 16px 18px; max-height: 620px; overflow: auto; }

.flow-root {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
}

.flow-root .ms { font-size: 20px; }
.flow-root-name { font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
.flow-root-path { font-size: 11px; opacity: 0.75; }

.flow-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 14px 0 6px;
}

.dep-tree { list-style: none; margin: 0; padding: 0 0 0 10px; }
.dep-tree .dep-tree { padding-left: 18px; }

.dep-item { position: relative; padding-left: 18px; }

/* ::before is the vertical run, ::after the elbow into the node. The last
   child stops its vertical line at the elbow so the branch closes. */
.dep-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-left: 1px solid var(--outline-variant);
}

.dep-item:last-child::before { bottom: auto; height: 18px; }

.dep-item::after {
  content: "";
  position: absolute;
  left: 0;
  top: 18px;
  width: 14px;
  border-top: 1px solid var(--outline-variant);
}

.dep-node {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  padding: 7px 10px;
  border: 1px solid var(--outline-variant);
  border-radius: 8px;
  background: var(--surface-lowest);
}

.dep-node:hover { border-color: var(--primary-container); }
.dep-item.off > .dep-node { opacity: 0.6; background: var(--off-row); }
.dep-node .flow-arrow { font-size: 16px; color: var(--primary-container); flex: none; }
.dep-name { font-size: 12px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Without the webfont a tree loses its expand arrows and its direction cues,
   so draw plain-text stand-ins for the few places that carry meaning. */
.no-icons .twist::after { content: "\25B8"; font-size: 13px; transition: transform 0.12s ease; }
.no-icons .twist.open::after { transform: rotate(90deg); }
.no-icons .edge-chip.up::before { content: "\2199"; margin-right: 3px; }
.no-icons .edge-chip.down::before { content: "\2197"; margin-right: 3px; }
.no-icons .dep-node::before { content: "\2192"; color: var(--primary-container); font-weight: 700; }
.no-icons .flow-root::before { content: "\25A4"; font-size: 15px; }

/* ── ask screen ──────────────────────────────────────────────────────────── */

.nav-item.ask-item {
  background: var(--secondary-container);
  color: var(--primary);
  font-weight: 600;
}

.nav-item.ask-item:hover { background: var(--secondary-fixed-dim); }
.nav-item.ask-item.active { background: var(--primary); color: #fff; }

.ask-card { display: flex; flex-direction: column; }

.chat {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  min-height: 340px;
  max-height: 58vh;
  overflow-y: auto;
}

.bubble {
  max-width: 86%;
  padding: 12px 15px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
}

.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }

.bubble.me {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
  max-width: 70%;
}

.bubble.bot {
  align-self: flex-start;
  background: var(--surface-low);
  border: 1px solid var(--outline-variant);
  border-bottom-left-radius: 4px;
  width: 100%;
  max-width: 100%;
}

.bubble.bot.unsure { background: var(--warn-row); border-color: #f0cd8e; }
.ask-answer { font-size: 13.5px; font-weight: 500; }
.bad-text { color: var(--bad-dot); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }

.chip {
  border: 1px solid var(--outline-variant);
  background: var(--surface-lowest);
  border-radius: 20px;
  padding: 6px 12px;
  font: inherit;
  font-size: 12px;
  color: var(--on-surface-variant);
  cursor: pointer;
}

.chip:hover { border-color: var(--primary-container); color: var(--primary); background: var(--ok-bg); }

.ask-section { margin-top: 12px; }
.ask-section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.ask-section-head .link-btn { margin-left: auto; }
.ask-table-wrap { overflow-x: auto; border: 1px solid var(--outline-variant); border-radius: 8px; background: var(--surface-lowest); }

.ask-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.ask-table th {
  text-align: left;
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
  padding: 8px 10px;
  background: var(--surface-low);
  white-space: nowrap;
}

.ask-table td {
  padding: 8px 10px;
  border-top: 1px solid rgba(205, 200, 204, 0.45);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ask-note {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--warn);
  background: var(--warn-bg);
  border-radius: 7px;
  padding: 8px 10px;
}

.ask-note .ms { font-size: 16px; flex: none; }
.ask-actions { margin-top: 12px; }

.ask-sources { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.ask-sources code {
  font-family: var(--mono);
  font-size: 10.5px;
  background: var(--surface-container);
  color: var(--bq);
  border-radius: 4px;
  padding: 2px 6px;
}

.ask-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--outline-variant);
  background: var(--surface-low);
}

.ask-input { position: relative; display: flex; align-items: center; flex: 1; }
.ask-input .ms { position: absolute; left: 12px; color: var(--on-surface-variant); font-size: 18px; pointer-events: none; }

.ask-input input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 38px;
  border: 1px solid var(--outline-variant);
  border-radius: 8px;
  background: var(--surface-lowest);
  font: inherit;
  font-size: 13px;
  color: var(--on-surface);
}

.ask-input input:focus { outline: none; border-color: var(--primary-container); box-shadow: 0 0 0 3px rgba(197, 35, 45, 0.12); }
.ask-foot { margin: 0; padding: 10px 20px 14px; font-size: 11px; color: var(--outline); }
.ask-matched { font-size: 11.5px; color: var(--on-surface-variant); font-style: italic; }

/* ── storage cost ────────────────────────────────────────────────────────── */

.cost-page { gap: 16px; }
.table-fixed td.num, .num { text-align: right; font-variant-numeric: tabular-nums; }

.head-actions { display: flex; align-items: flex-end; gap: 10px; flex: none; }
.cost-pick { display: flex; flex-direction: column; gap: 4px; }
.cost-pick select {
  height: 36px; min-width: 200px; padding: 0 10px; font: inherit; font-size: 13px;
  border: 1px solid var(--outline-variant); border-radius: 7px; background: var(--surface-lowest);
}

/* scope: the single control everything else follows */
.scope-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 8px 8px 14px; border: 1px solid var(--outline-variant); border-radius: 10px;
  background: var(--surface-lowest);
}
.scope { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; min-width: 0; flex: 1; }
.scope-icon { font-size: 18px; color: var(--primary-container); margin-right: 4px; }
.scope-sep { font-size: 16px; color: var(--outline); }
.scope-link, .scope-here { font: inherit; font-size: 13.5px; padding: 4px 8px; border-radius: 6px; }
.scope-link { border: none; background: none; color: var(--primary-container); cursor: pointer; }
.scope-link:hover { background: var(--surface-low); text-decoration: underline; }
.scope-here { font-weight: 700; color: var(--on-surface); }
.scope-bar .view-toggle { margin-left: auto; flex: none; }

/* headline figures */
.kpis { display: grid; grid-template-columns: 1.35fr 1fr 1fr 1fr; gap: 14px; }
.kpi { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; min-width: 0; }
.kpi-label { font-size: 12px; font-weight: 600; color: var(--on-surface-variant); }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; color: var(--on-surface); font-variant-numeric: tabular-nums; }
.kpi-hero .kpi-value { font-size: 36px; color: var(--primary); }
.kpi-delta { font-size: 12.5px; min-height: 17px; }
.kpi-foot { font-size: 12px; line-height: 1.45; margin-top: auto; }
.kpi-spark { height: 32px; }

.meter { display: flex; gap: 2px; height: 10px; width: 100%; margin: 4px 0 2px; }
.meter.small { height: 7px; max-width: 120px; margin: 0 0 3px; }
.meter span { display: block; min-width: 0; border-radius: 3px; }
.meter-active { background: var(--primary-container); }
.meter-long { background: var(--secondary-fixed-dim); }

.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--on-surface-variant); white-space: nowrap; }
.delta .ms { font-size: 15px; }
.delta.bad { color: var(--bad-dot); }
.delta.ok { color: var(--ok); }
.delta .rel { font-weight: 500; margin-left: 3px; }
.delta .dim { font-weight: 400; margin-left: 4px; }
.tag-new { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--primary); background: var(--secondary-container); border-radius: 4px; padding: 2px 6px; }

/* panels */
.panel-card { padding: 18px 20px 16px; overflow: visible; }
.panel-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.panel-top h3 { margin: 0 0 3px; font-size: 15px; font-weight: 700; }
.panel-top p { margin: 0; }
.cost-split { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 14px; align-items: start; }

.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 16px; max-width: 60%; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--on-surface-variant); white-space: nowrap; }
.legend-item strong { color: var(--on-surface); font-variant-numeric: tabular-nums; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* charts */
.chart-host { position: relative; }
.chart-host.single { padding: 8px 0 4px; }
.chart-svg { display: block; overflow: visible; font-family: var(--sans); }
.chart-grid { stroke: #ececef; stroke-width: 1; shape-rendering: crispEdges; }
.chart-base { stroke: var(--outline-variant); stroke-width: 1; shape-rendering: crispEdges; }
.chart-axis { font-size: 11px; fill: var(--outline); font-variant-numeric: tabular-nums; }
.chart-end-value { font-size: 12px; font-weight: 700; fill: var(--on-surface); font-variant-numeric: tabular-nums; }
.chart-col { transition: opacity 0.12s ease; }
.split-bar { display: flex; gap: 2px; height: 28px; border-radius: 6px; overflow: hidden; }
.split-bar span { display: block; min-width: 3px; }

.chart-tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 190px; max-width: 300px;
  background: var(--on-surface); color: #fff; border-radius: 8px; padding: 10px 12px;
  font-size: 12px; box-shadow: 0 8px 24px rgba(29, 27, 30, 0.25);
}
.tip-head { font-weight: 700; margin-bottom: 6px; }
.tip-row { display: flex; align-items: center; gap: 8px; line-height: 1.65; }
.tip-key { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.tip-name { flex: 1; min-width: 0; color: #d6d2d6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tip-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-total { border-top: 1px solid rgba(255, 255, 255, 0.22); margin-top: 5px; padding-top: 4px; }
.tip-total .tip-name { color: #fff; font-weight: 600; }

/* breakdown: html rows, so text can never overlap */
.bd { display: flex; flex-direction: column; }
.bd-head, .bd-row {
  display: grid; grid-template-columns: 10px minmax(0, 1.25fr) minmax(90px, 1fr) 84px 96px 18px;
  align-items: center; column-gap: 14px;
}
.bd-head { padding: 0 8px 8px; font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--outline); border-bottom: 1px solid var(--outline-variant); }
.bd-row { padding: 10px 8px; border-bottom: 1px solid rgba(205, 200, 204, 0.4); border-radius: 6px; }
.bd-row:last-child { border-bottom: none; }
.bd-row.open { cursor: pointer; }
.bd-row.open:hover, .bd-row.open:focus-visible { background: var(--surface-low); outline: none; }
.bd-row.open:hover .bd-title { color: var(--primary); }
.bd-name { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.bd-title { font-family: var(--mono); font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-meta { font-size: 11.5px; color: var(--outline); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-bar { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bd-bar span { display: block; height: 10px; border-radius: 0 4px 4px 0; flex: none; max-width: calc(100% - 44px); }
.bd-bar em { font-style: normal; font-size: 11.5px; color: var(--on-surface-variant); font-variant-numeric: tabular-nums; }
.bd-cost { font-weight: 700; font-size: 13.5px; }
.bd-change .delta { font-size: 12px; }
.bd-go { font-size: 18px; color: var(--outline); }

/* what changed */
.seg { display: flex; gap: 2px; padding: 3px; margin-bottom: 8px; background: var(--surface-low); border: 1px solid var(--outline-variant); border-radius: 8px; }
.seg button {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px;
  border: none; background: none; border-radius: 6px; font: inherit; font-size: 12.5px; color: var(--on-surface-variant); cursor: pointer;
}
.seg button.active { background: var(--surface-lowest); color: var(--primary); font-weight: 700; box-shadow: 0 1px 2px rgba(29, 27, 30, 0.08); }
.seg-count { font-size: 10.5px; font-weight: 700; background: var(--surface-container); color: var(--on-surface-variant); border-radius: 10px; padding: 1px 6px; }
.movers { display: flex; flex-direction: column; }
.mover { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid rgba(205, 200, 204, 0.4); }
.mover:last-child { border-bottom: none; }
.mover-name { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.mover-name .mono { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mover-name .tiny { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quiet { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 30px 12px; text-align: center; color: var(--outline); }
.quiet .ms { font-size: 26px; color: var(--outline-variant); }
.quiet p { margin: 0; font-size: 13px; max-width: 260px; }

/* table list */
.cost-table th[data-sort] { cursor: pointer; user-select: none; }
.cost-table th[data-sort]:hover, .cost-table th.sorted { color: var(--primary); }
.cost-table th.sorted::after { content: " ↓"; }
.cost-table th.sorted[data-dir="asc"]::after { content: " ↑"; }
.cost-table td { vertical-align: middle; }
.cell-with-swatch { display: flex; align-items: center; gap: 9px; min-width: 0; }

@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cost-split { grid-template-columns: minmax(0, 1fr); }
  .legend { max-width: none; justify-content: flex-start; }
  .panel-top { flex-wrap: wrap; }
}

/* ── loading ─────────────────────────────────────────────────────────────── */

.sk {
  display: block;
  border-radius: 5px;
  background: linear-gradient(90deg, #ececef 0%, #f6f6f8 40%, #ececef 80%);
  background-size: 300% 100%;
  animation: sk-shimmer 1.4s ease-in-out infinite;
}
@keyframes sk-shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }

.sk-line { height: 10px; margin: 3px 0; }
.sk-sub { height: 8px; margin-top: 6px; opacity: 0.7; }
.sk-title { height: 13px; }
.sk-big { height: 26px; margin: 6px 0; }
.sk-chip { display: inline-block; height: 28px; border-radius: 14px; margin-right: 8px; vertical-align: middle; }
.sk-pill { display: inline-block; width: 64px; height: 18px; border-radius: 9px; margin-right: 6px; }
.sk-pills { margin: 4px 0 8px; }
.sk-block { width: 100%; border-radius: 8px; margin-bottom: 10px; }
.sk-input { height: 34px; border-radius: 6px; margin-top: 2px; }
.sk-row td { padding-top: 14px; padding-bottom: 14px; }
.sk-card { display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.sk-list-row { border-bottom: 1px solid rgba(205, 200, 204, 0.35); }
.sk-list-row:last-child { border-bottom: none; }

/* the saved card/table choice applies before any script runs, so only one skeleton shows */
html[data-view="table"] #card-view, html[data-view="cards"] #table-view { display: none; }

/* thin bar under the top bar while any request is in flight */
.busy-bar { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; overflow: hidden; pointer-events: none; opacity: 0; transition: opacity 0.2s; }
.busy-bar::after { content: ""; position: absolute; top: 0; bottom: 0; width: 35%; background: var(--primary-container); animation: busy-slide 1.1s ease-in-out infinite; }
body.busy .busy-bar { opacity: 1; }
@keyframes busy-slide { from { left: -35%; } to { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .busy-bar::after { animation: none; width: 100%; opacity: 0.5; } }

/* reloads keep the old rows visible, dimmed, rather than blanking the page */
#rows, #card-view, #account-list, .panel-card, .kpis, #hierarchy { transition: opacity 0.15s; }
body.loaded.busy #rows, body.loaded.busy #card-view, body.loaded.busy #account-list,
body.loaded.busy .panel-card, body.loaded.busy .kpis, body.loaded.busy #hierarchy {
  opacity: 0.55; pointer-events: none;
}

/* ── edit form ───────────────────────────────────────────────────────────── */

.field select {
  font: inherit; font-size: 12.5px; height: 34px; padding: 0 8px; width: 100%;
  border: 1px solid var(--outline-variant); border-radius: 6px; background: var(--surface-lowest);
}
.field input[type="time"], .field input[type="date"], .field input[type="datetime-local"], .field input[type="number"] { max-width: 260px; }
.field select:disabled { background: var(--surface-low); color: var(--on-surface-variant); }
.field.changed select, .field.changed .tags { border-color: var(--ok-dot); background: #f1faf6; }
.field.invalid input, .field.invalid textarea, .field.invalid select, .field.invalid .tags { border-color: var(--bad-dot); background: #fff8f8; }
.field-error { font-size: 11.5px; color: var(--bad-dot); font-weight: 600; }
.field label { display: flex; align-items: center; gap: 5px; }
.field .req { color: var(--bad-dot); font-weight: 700; }
.field .lock-icon { font-size: 14px; color: var(--outline); }
.field.is-locked label { color: var(--on-surface-variant); }

.select-wrap { display: flex; flex-direction: column; gap: 6px; }
.with-button { display: flex; gap: 6px; align-items: center; }
.mini-btn {
  align-self: flex-start; font: inherit; font-size: 11.5px; font-weight: 600; height: 30px; padding: 0 10px;
  border: 1px solid var(--outline-variant); border-radius: 6px; background: var(--surface-lowest);
  color: var(--primary-container); cursor: pointer; white-space: nowrap;
}
.mini-btn:hover { border-color: var(--primary-container); background: var(--surface-low); }

.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; align-self: flex-start; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-track { position: relative; width: 38px; height: 22px; border-radius: 11px; background: var(--outline-variant); transition: background 0.15s; }
.toggle-thumb { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); transition: left 0.15s; }
.toggle input:checked + .toggle-track { background: var(--ok-dot); }
.toggle input:checked + .toggle-track .toggle-thumb { left: 19px; }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--primary-container); outline-offset: 2px; }
.toggle-text { font-size: 12.5px; font-weight: 600; color: var(--on-surface-variant); }
.toggle.locked { cursor: not-allowed; opacity: 0.6; }

.tags {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 36px; padding: 5px 6px;
  border: 1px solid var(--outline-variant); border-radius: 6px; background: var(--surface-lowest);
}
.tags.locked { background: var(--surface-low); }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
  font-family: var(--mono); font-size: 11.5px; padding: 3px 4px 3px 8px; border-radius: 12px;
  background: var(--surface-container); color: var(--on-surface); overflow-wrap: anywhere;
}
.tags.locked .tag-chip { padding-right: 8px; }
.tag-chip button { border: none; background: none; font-size: 14px; line-height: 1; cursor: pointer; color: var(--on-surface-variant); padding: 0 3px; border-radius: 50%; }
.tag-chip button:hover { background: var(--outline-variant); color: var(--on-surface); }
.field .tags .tag-entry { flex: 1; min-width: 140px; border: none; padding: 4px; background: transparent; outline: none; }

.form-banner { display: flex; gap: 12px; padding: 12px 14px; margin-bottom: 16px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); }
.form-banner .ms { font-size: 20px; }
.form-banner strong { display: block; margin-bottom: 3px; }
.form-banner p { margin: 0; font-size: 12.5px; line-height: 1.5; }
.form-banner.bad { background: var(--bad-bg); color: var(--bad); }

/* ── edit form: folding groups, choice pills, schedule preview ─────────────── */

.drawer-body > .section > .caps,
.drawer-body > .section > .section-head { cursor: pointer; user-select: none; }
.drawer-body > .section > .caps::after,
.drawer-body > .section > .section-head .caps::after { content: " ▾"; font-size: 10px; color: var(--outline); }
.drawer-body > .section.collapsed > .caps::after,
.drawer-body > .section.collapsed > .section-head .caps::after { content: " ▸"; }
.drawer-body > .section.collapsed > :not(.caps):not(.section-head) { display: none; }
.drawer-body > .section.collapsed { gap: 0; }
#drawer-extra:not(:empty) { display: flex; flex-direction: column; gap: 12px; }

.form-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.form-bar strong { display: block; font-size: 14px; }
.form-bar .tiny { font-size: 11px; }

.fgroups { display: flex; flex-direction: column; gap: 10px; }
.fgroup { border: 1px solid var(--outline-variant); border-radius: 10px; background: var(--surface-lowest); }
.fgroup > summary {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  cursor: pointer; list-style: none; user-select: none; border-radius: 10px;
}
.fgroup > summary::-webkit-details-marker { display: none; }
.fgroup > summary:hover { background: var(--surface-low); }
.fgroup[open] > summary { border-bottom: 1px solid var(--outline-variant); border-radius: 10px 10px 0 0; }
.fgroup .chev { font-size: 18px; color: var(--outline); transform: rotate(-90deg); transition: transform 0.15s; }
.fgroup[open] .chev { transform: none; }
.fg-title { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--on-surface-variant); }
.fg-count { font-size: 11px; color: var(--outline); margin-right: auto; }
.fg-badge { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 10px; }
.fg-badge.changed { background: var(--ok-bg); color: var(--ok); }
.fg-badge.error { background: var(--bad-bg); color: var(--bad); }
.fgroup > .field-group { padding: 14px; gap: 16px; }

.field .kind { font-size: 15px; color: var(--primary-container); opacity: 0.75; }
.field.is-locked .kind { color: var(--outline); }

.choice { display: flex; flex-wrap: wrap; gap: 6px; }
.choice-opt {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px;
  border: 1px solid var(--outline-variant); border-radius: 999px; background: var(--surface-lowest);
  font-size: 12.5px; cursor: pointer; transition: background 0.1s, border-color 0.1s;
}
.choice-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice-opt .ms { font-size: 14px; }
.choice-opt:hover { border-color: var(--primary-container); }
.choice-opt:has(input:checked) { background: var(--primary-container); border-color: var(--primary-container); color: #fff; font-weight: 600; }
.choice-opt:has(input:focus-visible) { outline: 2px solid var(--primary-container); outline-offset: 2px; }
.choice-opt.noted { border-style: dashed; color: var(--on-surface-variant); }
.choice-opt.bad { border-color: var(--bad-dot); color: var(--bad); background: #fff8f8; }
.choice-opt.bad:has(input:checked) { background: var(--bad-dot); color: #fff; }
.choice.locked .choice-opt { cursor: not-allowed; opacity: 0.6; }
.field.changed .choice-opt:has(input:checked) { box-shadow: 0 0 0 2px #b9e6cf; }
.field.invalid .choice-opt { border-color: var(--bad-dot); }

.sched-preview {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 8px;
  background: var(--surface-low); color: var(--on-surface); font-size: 12.5px; font-weight: 500;
}
.sched-preview .ms { font-size: 18px; color: var(--primary-container); }
.sched-preview.warn { background: var(--warn-bg); color: var(--warn); }
.sched-preview.warn .ms { color: var(--warn-dot); }

/* ── search and filters (DFC.searchNote, DFC.wireSort, DFC.loadFacets) ───── */
.search-note {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -4px 0 14px;
  font-size: 12.5px; color: var(--on-surface-variant);
}
.search-note .ms { font-size: 17px; color: var(--outline); }
.search-note strong { color: var(--on-surface); font-weight: 600; }
.search-note.close { color: var(--warn); }
.search-note.close .ms { color: var(--warn-dot); }
.search-note.none .ms { color: var(--bad-dot); }
.search-tips {
  margin-left: auto; font-size: 11.5px; color: var(--outline); border-bottom: 1px dotted var(--outline-variant); cursor: help;
}
.filters select.set { border-color: var(--primary-container); color: var(--primary); font-weight: 600; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--on-surface); }
th.sortable:focus-visible { outline: 2px solid var(--primary-container); outline-offset: -2px; }
th.sortable::after { content: "\2195"; margin-left: 5px; font-size: 10px; opacity: 0; }
th.sortable:hover::after { opacity: 0.45; }
th.sorted { color: var(--primary); }
th.sorted[data-dir="asc"]::after { content: "\2191"; opacity: 1; }
th.sorted[data-dir="desc"]::after { content: "\2193"; opacity: 1; }
