/*
 * Color tokens. Each is light-dark(<light>, <dark>): the browser picks one from color-scheme, which follows the
 * computer (System) unless the person chose Light or Dark in Settings (html[data-mode]).
 * Palettes (html[data-palette], chosen in Settings) only change the accent; status colors stay the same so
 * "failed" is always red and "succeeded" always green. Palette ids must match settings.js and preferences.py.
 */
:root {
  color-scheme: light dark;
  --bg: light-dark(#f5f7fa, #0b1220);
  --surface: light-dark(#ffffff, #111a2c);
  --surface-2: light-dark(#f9fafb, #0f1727);
  --border: light-dark(#e4e7ec, #1f2a40);
  --border-strong: light-dark(#d0d5dd, #2b3954);
  --text: light-dark(#101828, #e6eaf2);
  --text-2: light-dark(#475467, #b4bfd1);
  --muted: light-dark(#667085, #8a97ad);
  --ok: light-dark(#067647, #47cd89);    --ok-soft: light-dark(#ecfdf3, #0c2a1c);    --ok-line: light-dark(#abefc6, #145c3a);
  --bad: light-dark(#b42318, #f97066);   --bad-soft: light-dark(#fef3f2, #2d1414);   --bad-line: light-dark(#fecdca, #6e2a24);
  --warn: light-dark(#b54708, #fdb022);  --warn-soft: light-dark(#fffaeb, #2b2010);  --warn-line: light-dark(#fedf89, #6b4a12);
  --info: light-dark(#175cd3, #53b1fd);  --info-soft: light-dark(#eff8ff, #0d2238);  --info-line: light-dark(#b2ddff, #1d4b78);
  --idle: light-dark(#475467, #a1acbf);  --idle-soft: light-dark(#f2f4f7, #1a2438);  --idle-line: light-dark(#e4e7ec, #2b3954);
  /* light-dark() takes colors only, so shadows switch through their color. */
  --shadow-color: light-dark(rgba(16, 24, 40, .07), rgba(0, 0, 0, .4));
  --shadow-color-lg: light-dark(rgba(16, 24, 40, .25), rgba(0, 0, 0, .6));
  --shadow: 0 1px 2px var(--shadow-color), 0 1px 3px var(--shadow-color);
  --shadow-lg: 0 20px 40px -12px var(--shadow-color-lg);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  --topbar-h: 57px;
  --nav-w: var(--nav-w-open, 248px);  /* --nav-w-open: the width the person dragged the sidebar to */
}
:root[data-mode="light"] { color-scheme: light; }
:root[data-mode="dark"] { color-scheme: dark; }
:root[data-nav="collapsed"] { --nav-w: 72px; }

/* Accent palettes. --on-primary is the text color on a filled accent (buttons, selected chips). */
:root, :root[data-palette="blue"] {
  --primary: light-dark(#1d4ed8, #4f7cff);
  --primary-hover: light-dark(#1e40af, #6b91ff);
  --primary-soft: light-dark(#eff4ff, #16244a);
  --on-primary: #ffffff;
}
/* Medvertex: the logo's orange as the accent, its navy for the top bar and navigation. */
:root[data-palette="medvertex"] {
  --primary: light-dark(#d63a17, #ff7a4d);
  --primary-hover: light-dark(#b52f11, #ff9670);
  --primary-soft: light-dark(#fff1ec, #3a1a10);
  --on-primary: light-dark(#ffffff, #1a0b05);
  --chrome-bg: #003058;
  --chrome-fg: #ffffff;
  --chrome-muted: rgba(255, 255, 255, .7);
  --chrome-hover: rgba(255, 255, 255, .1);
  --chrome-active: rgba(255, 255, 255, .14);
  --chrome-border: rgba(255, 255, 255, .12);
}
:root[data-palette="teal"] {
  --primary: light-dark(#0f766e, #2dd4bf);
  --primary-hover: light-dark(#115e59, #5eead4);
  --primary-soft: light-dark(#f0fdfa, #0b2b29);
  --on-primary: light-dark(#ffffff, #042f2e);
}
:root[data-palette="indigo"] {
  --primary: light-dark(#4338ca, #6366f1);
  --primary-hover: light-dark(#3730a3, #818cf8);
  --primary-soft: light-dark(#eef2ff, #1c1b48);
  --on-primary: #ffffff;
}
:root[data-palette="violet"] {
  --primary: light-dark(#6d28d9, #8b5cf6);
  --primary-hover: light-dark(#5b21b6, #a78bfa);
  --primary-soft: light-dark(#f5f3ff, #25154a);
  --on-primary: #ffffff;
}
:root[data-palette="graphite"] {
  --primary: light-dark(#334155, #cbd5e1);
  --primary-hover: light-dark(#1e293b, #e2e8f0);
  --primary-soft: light-dark(#f1f5f9, #1c2638);
  --on-primary: light-dark(#ffffff, #0f172a);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
code, pre { font-family: var(--mono); font-size: 12.5px; }
h1, h2 { margin: 0; letter-spacing: -.01em; }

/* --- top bar ---------------------------------------------------------------------------------------------- */
.topbar {
  min-width: 0; height: var(--topbar-h);
  position: sticky; top: 0; z-index: 25;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 20px 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; color: inherit; text-decoration: none; border-radius: 8px; }
.brand:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: 2px; }
.brand-logo { width: 34px; height: 34px; flex: none; padding: 3px; border-radius: 9px; background: #fff; border: 1px solid var(--border); object-fit: contain; }
.brand-text { display: grid; min-width: 0; line-height: 1.3; }
.brand-name { font-weight: 650; white-space: nowrap; }
.brand-sub { color: var(--muted); font-size: 12.5px; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8;
        stroke-linecap: round; stroke-linejoin: round; }
#settings-link[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 60; padding: 8px 14px; border-radius: 8px;
  background: var(--primary); color: var(--on-primary); font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* --- shell: side navigation + content --------------------------------------------------------------------- */
.shell { position: relative; display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); }
/* Drag to resize the sidebar (double-click: back to the default width) */
.nav-resizer {
  position: absolute; top: 0; bottom: 0; left: calc(var(--nav-w) - 3px); z-index: 5; width: 7px;
  cursor: col-resize; touch-action: none; background: transparent; transition: background .15s;
}
.nav-resizer:hover, .nav-resizer:focus-visible, :root.nav-resizing .nav-resizer {
  background: color-mix(in srgb, var(--primary) 35%, transparent); outline: none;
}
:root.nav-resizing, :root.nav-resizing * { cursor: col-resize !important; user-select: none; }
:root.nav-resizing .sidenav { transition: none; }
:root[data-nav="collapsed"] .nav-resizer { display: none; }
.sidenav .nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-count, .nav-chevron, .nav-item .icon { flex-shrink: 0; }
.sidenav {
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 8px; padding: 14px 12px;
  background: var(--surface); border-right: 1px solid var(--border);
  transition: width .2s ease;
}
.sidenav-head { display: none; }
.nav-section { display: grid; gap: 4px; }
.nav-bottom { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.nav-heading {
  padding: 4px 12px 6px; color: var(--muted);
  font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap;
}
.nav-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav-item a {
  position: relative; display: flex; align-items: center; gap: 12px;
  height: 40px; padding: 0 12px; border-radius: 9px;
  color: var(--text-2); text-decoration: none; font-weight: 550; white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav-item a:hover { background: var(--idle-soft); color: var(--text); }
.nav-item a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 650; }
.nav-item a[aria-current="page"]::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--primary);
}
.nav-item a:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: -2px; }
.nav-meta { padding: 8px 12px 0; color: var(--muted); font-size: 12px; white-space: nowrap; }
.content { min-width: 0; outline: none; }
.nav-scrim { position: fixed; inset: 0; z-index: 34; background: rgba(16, 24, 40, .45); }

/* Collapsed (desktop): only Dashboard, Favorites, Recent and All modules, as icons (the label shows as a tooltip);
   the last three open a panel beside the menu. */
.nav-rail { display: none; }
:root[data-nav="collapsed"] .nav-rail { display: grid; }
:root[data-nav="collapsed"] .nav-quick, :root[data-nav="collapsed"] .nav-modules,
:root[data-nav="collapsed"] .nav-setup, :root[data-nav="collapsed"] .nav-bottom { display: none; }
.nav-rail .nav-label { display: none; }
.nav-rail .nav-item a { justify-content: center; padding: 0; }
.nav-rail-btn {
  width: 100%; height: 40px; display: grid; place-items: center; border: 0; border-radius: 9px;
  background: none; color: var(--text-2); cursor: pointer; transition: background .15s, color .15s;
}
.nav-rail-btn:hover, .nav-rail-btn[aria-expanded="true"] { background: var(--idle-soft); color: var(--text); }
.nav-rail-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: -2px; }

/* Favorites and Recent: a star on each screen in the menu (shown on hover; always when starred) */
.nav-item { position: relative; }
.nav-item:has(.nav-star) > a { padding-right: 36px; }
.nav-star {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: grid; place-items: center;
  width: 26px; height: 26px; border: 0; border-radius: 7px; background: none; color: var(--muted); cursor: pointer;
  opacity: 0; transition: opacity .15s, background .15s;
}
.nav-star .icon { width: 16px; height: 16px; }
.nav-item:hover .nav-star, .nav-star:focus-visible { opacity: 1; }
.nav-star:hover { background: var(--idle-soft); color: var(--text); }
.nav-star:focus-visible { outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent); }
.nav-star.on, .fav-toggle.on .icon { color: #f5a524; }
.nav-quick .nav-star.on, .nav-panel .nav-star.on { opacity: 1; }
.nav-quick { padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.nav-count:empty { display: none; }
.nav-empty { padding: 6px 12px 8px; color: var(--muted); font-size: 12.5px; line-height: 1.4; }

/* The panel beside the collapsed menu */
.nav-panel {
  position: fixed; z-index: 40; width: 300px; max-height: calc(100vh - var(--topbar-h) - 16px); display: flex; flex-direction: column;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.nav-panel-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 8px; font-weight: 650; }
.nav-panel-head .icon { color: var(--muted); }
.nav-panel-search { margin: 0 12px 8px; width: calc(100% - 24px); }
.nav-panel-body { overflow-y: auto; padding: 0 10px 10px; }
.nav-panel .nav-item a[aria-current="page"]::before { display: none; }

/* Views */
.view.is-loading > :not(.view-loading) { display: none !important; }
.view-loading { display: none; }
.view.is-loading > .view-loading {
  display: grid; justify-items: center; gap: 4px; padding: 80px 16px; color: var(--muted);
}

/* Submenus (groups) in the side navigation */
.nav-group-btn {
  width: 100%; display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: 9px;
  border: 0; background: none; color: var(--text-2); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.nav-group-btn:hover { background: var(--idle-soft); color: var(--text); }
.nav-group-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: -2px; }
.nav-chevron { margin-left: auto; display: grid; transition: transform .15s; }
.nav-chevron .icon { width: 16px; height: 16px; }
.nav-group-btn[aria-expanded="false"] .nav-chevron { transform: rotate(-90deg); }
.nav-sub { list-style: none; margin: 2px 0 0; padding: 0 0 0 14px; display: grid; gap: 2px; }
.nav-sub .nav-item a { height: 36px; font-size: 13.5px; }
.nav-sub .nav-item a[aria-current="page"]::before { left: -26px; }
.nav-subgroup-btn { height: 34px; font-size: 13px; color: var(--muted); font-weight: 600; }
.nav-subgroup-btn .icon { width: 16px; height: 16px; opacity: .8; }
.nav-count {
  margin-left: auto; min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--idle-soft);
  font-size: 11.5px; font-weight: 600; text-align: center; line-height: 18px;
}
.nav-count + .nav-chevron { margin-left: 6px; }
.nav-sub .nav-sub .nav-item a[aria-current="page"]::before { left: -40px; }

/* --- data grid -------------------------------------------------------------------------------------------- */
.grid-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.grid-search-wrap { display: flex; align-items: center; gap: 6px; margin-right: auto; }
.grid-search { width: min(320px, 70vw); }
.grid-count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.grid-wrap { max-height: calc(100vh - 290px); overflow: auto; }
.grid-table th { position: sticky; top: 0; z-index: 2; }
.th-inner { display: flex; align-items: center; gap: 4px; }
.num .th-inner { justify-content: flex-end; }
.filter-btn {
  display: inline-grid; place-items: center; width: 24px; height: 24px; padding: 0; flex: none;
  border: 1px solid transparent; border-radius: 6px; background: none; color: var(--muted); cursor: pointer;
}
.filter-btn .icon { width: 14px; height: 14px; }
.filter-btn:hover { background: var(--idle-soft); color: var(--text); }
.filter-btn.on { color: var(--primary); background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 30%, transparent); }
.filter-btn.on .icon { fill: currentColor; }
.filter-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: 1px; }
th.is-filtered .sort-btn { color: var(--primary); }
.filter-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.filter-chip {
  display: inline-flex; align-items: center; border-radius: 999px; overflow: hidden;
  background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent); color: var(--primary);
}
.filter-chip button { border: 0; background: none; color: inherit; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.chip-main { padding: 3px 4px 3px 10px; }
.chip-x { display: grid; place-items: center; width: 24px; height: 24px; padding: 0; }
.chip-x .icon { width: 13px; height: 13px; stroke-width: 2.4; }
.filter-chip button:hover { text-decoration: underline; }
.filter-chip button:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; border-radius: 999px; }
.filter-pop {
  position: fixed; z-index: 45; width: 290px; overflow: auto; align-content: start;
  display: grid; gap: 12px; padding: 14px; text-transform: none; letter-spacing: normal; font-weight: 400;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
}
.pop-title { font-weight: 650; }
.pop-section { display: grid; gap: 6px; }
.pop-label { color: var(--muted); font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
.pop-op { width: 100%; }
.pop-inputs { display: grid; gap: 6px; }
.pop-inputs .input { height: 34px; }
.pop-and { font-size: 12px; }
.pop-search { height: 32px; }
.pop-list { display: grid; gap: 1px; max-height: 220px; overflow: auto; padding: 2px; border: 1px solid var(--border); border-radius: 8px; }
.pop-check { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px; cursor: pointer; font-size: 13.5px; }
.pop-check:hover { background: var(--idle-soft); }
.pop-check input { accent-color: var(--primary); width: 15px; height: 15px; margin: 0; flex: none; }
.pop-check span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-n { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.pop-all { font-weight: 600; }
.pop-more { padding: 6px 8px; font-size: 12px; }
.pop-foot { position: sticky; bottom: -14px; display: flex; justify-content: space-between; gap: 8px; margin: 0 -14px -14px; padding: 4px 14px 14px; border-top: 1px solid var(--border); background: var(--surface); }
.pop-foot .btn { margin-top: 8px; }
.sort-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none; cursor: pointer;
  color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; white-space: nowrap;
}
.sort-btn:hover { color: var(--text); }
.sort-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: 2px; border-radius: 4px; }
.sort-mark { font-size: 10px; color: var(--muted); }
th[aria-sort="ascending"] .sort-mark, th[aria-sort="descending"] .sort-mark { color: var(--primary); }
.grid-table td { white-space: nowrap; }
.actions-col { position: sticky; right: 0; background: var(--surface); text-align: right; box-shadow: -1px 0 0 var(--border); }
.grid-table thead .actions-col { background: var(--surface-2); z-index: 3; }
tr.clickable:focus-visible td { background: var(--primary-soft); }
.row-actions { display: inline-flex; gap: 6px; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 5px; }
.btn-sm .icon { width: 16px; height: 16px; }
.btn .icon { width: 18px; height: 18px; }
.cell-link { color: var(--primary); font-weight: 600; text-decoration: none; }
.cell-link:hover { text-decoration: underline; }
.value-code { background: var(--idle-soft); padding: 1px 6px; border-radius: 4px; }
.grid-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--border); }
.danger { color: var(--bad); }

/* --- record screens --------------------------------------------------------------------------------------- */
.record-view { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.back-link { display: inline-flex; align-items: center; gap: 4px; width: fit-content; color: var(--text-2); text-decoration: none; font-weight: 550; }
.back-link:hover { color: var(--primary); }
.back-link .icon { width: 18px; height: 18px; }
.record-kicker { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.record-sub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.status-chip.neutral { color: var(--idle); background: var(--idle-soft); border-color: var(--idle-line); }
.banner-info { color: var(--info); background: var(--info-soft); border-color: var(--info-line); }
.record-panel { overflow: hidden; }
.record-tabs { display: flex; flex-wrap: nowrap; overflow-x: auto; margin: 12px 16px 0; max-width: calc(100% - 32px); }
.record-tabs button { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tab-count { padding: 0 7px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.tab-dirty { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.record-body { padding: 18px 20px 24px; display: grid; gap: 22px; grid-template-columns: minmax(0, 1fr); }
.record-section { min-width: 0; }
.section-heading { margin: 0 0 12px; font-size: 14px; font-weight: 650; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px 20px; }
.field-item { display: grid; gap: 4px; align-content: start; min-width: 0; padding: 2px 0; border-radius: 8px; }
.field-label-text { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.field-value { overflow-wrap: anywhere; }
.field-item.changed .input, td.changed .input, .chip-row .input { border-color: var(--warn); }
.field-item.changed .field-label-text::after { content: "edited"; color: var(--warn); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.field-item.invalid .input, td.invalid .input { border-color: var(--bad); }
.field-warn { color: var(--warn); font-size: 12px; }
.lock { display: inline-grid; color: var(--muted); }
.lock .icon { width: 14px; height: 14px; }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.45; }
.num-input { font-variant-numeric: tabular-nums; }
.subsection { margin: 16px 0 0; padding: 14px 16px 16px; border: 1px solid var(--border); border-radius: 10px; min-width: 0; }
.subsection legend { padding: 0 6px; color: var(--text-2); font-weight: 650; font-size: 13px; }
.card-list { display: grid; gap: 12px; }
.item-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.item-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.item-title { font-weight: 650; }
.item-card > .field-grid, .item-card > .subsection { margin: 14px; }
.item-card > .subsection { margin-top: 0; }
.subtable-wrap { display: grid; gap: 10px; justify-items: start; }
.subtable-wrap .table-wrap { width: 100%; border: 1px solid var(--border); border-radius: 10px; }
.subtable td { white-space: nowrap; }
.subtable .input { min-width: 120px; height: 32px; }
.subtable .switch { vertical-align: middle; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 3px 10px; border-radius: 999px; background: var(--idle-soft); border: 1px solid var(--border); font-variant-numeric: tabular-nums; font-size: 13px; }
.chip-edit { display: grid; gap: 8px; justify-items: start; }
.chip-row { display: flex; gap: 6px; align-items: center; }
.chip-row .input { width: 200px; }
.array-empty { display: flex; align-items: center; gap: 12px; }
.record-grid { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.record-grid .grid-wrap { max-height: 520px; }
.json-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.json-view { margin: 0; padding: 14px 16px; max-height: 60vh; overflow: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; font-size: 12.5px; }
.link-out { color: var(--primary); overflow-wrap: anywhere; }
.view-loading-inline { display: grid; justify-items: center; gap: 6px; padding: 40px 16px; color: var(--muted); }
.audit-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.audit-list > li { padding-left: 14px; border-left: 2px solid var(--border); }
.change-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; font-size: 13.5px; }
.change-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.change-path { font-weight: 600; min-width: 220px; }
.change-old { color: var(--bad); text-decoration: line-through; overflow-wrap: anywhere; }
.change-new { color: var(--ok); font-weight: 600; overflow-wrap: anywhere; }
.review-list { max-height: 50vh; overflow: auto; padding: 4px 2px; }
.form-panel { max-width: 720px; }
.form-panel .modal-foot { border-radius: 0 0 var(--radius) var(--radius); }

/* --- links to master records, right-click menu, empty states ---------------------------------------------- */
.ref { display: inline-grid; gap: 1px; }
.ref-link { color: var(--primary); font-weight: 600; text-decoration: none; }
.ref-link:hover { text-decoration: underline; }
.ref-link:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: 2px; border-radius: 4px; }
.ref-sub { color: var(--muted); font-size: 12.5px; font-weight: 400; white-space: normal; }
.ref-sub.missing { color: var(--warn); }
.ref-table { border: 1px solid var(--border); border-radius: 10px; }
.chip-row .ref-sub { max-width: 280px; }
.context-menu {
  position: fixed; z-index: 55; min-width: 190px; padding: 6px; display: grid; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
}
.context-item {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border: 0; border-radius: 7px;
  background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; white-space: nowrap;
}
.context-item .icon { width: 17px; height: 17px; color: var(--muted); }
.context-item:hover, .context-item:focus { background: var(--primary-soft); color: var(--primary); outline: none; }
.context-item:hover .icon, .context-item:focus .icon { color: var(--primary); }
.empty-state {
  display: grid; justify-items: center; gap: 10px; padding: 48px 24px; text-align: center;
  background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.empty-state h2 { font-size: 18px; }
.empty-state p { margin: 0; max-width: 520px; }
.empty-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--warn-soft); color: var(--warn); }
.empty-icon .icon { width: 26px; height: 26px; }
.req { color: var(--bad); }

/* --- settings --------------------------------------------------------------------------------------------- */
.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.settings-tabs { display: grid; gap: 2px; position: sticky; top: calc(var(--topbar-h) + 24px); }
.settings-tabs a {
  display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border-radius: 9px;
  color: var(--text-2); text-decoration: none; font-weight: 550;
}
.settings-tabs a:hover { background: var(--idle-soft); color: var(--text); }
.settings-tabs a[aria-selected="true"] { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); border: 1px solid var(--border); }
.settings-tabs a:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: 1px; }
.settings-body { padding: 18px 20px 22px; display: grid; gap: 18px; max-width: 720px; }
.settings-intro { margin: 0; color: var(--text-2); }
.choice-list { display: grid; gap: 10px; }
.choice {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  transition: border-color .15s, background .15s;
}
.choice:hover { border-color: var(--border-strong); }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.choice input { margin: 3px 0 0; accent-color: var(--primary); width: 16px; height: 16px; flex: none; }
.choice-text { display: grid; gap: 2px; min-width: 0; }
.choice-title { font-weight: 600; }
.choice-sub { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.tz-picker { display: grid; gap: 10px; }
.tz-list {
  width: 100%; padding: 4px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
.tz-list option { padding: 6px 8px; border-radius: 6px; }
.tz-list optgroup { color: var(--muted); font-size: 12px; font-style: normal; }
.tz-list option:checked { background: var(--primary-soft); color: var(--primary); }
.tz-now { padding: 14px 16px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); display: grid; gap: 2px; }
.tz-clock { font-size: 20px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.callout.callout-info { color: var(--info); background: var(--info-soft); border-color: var(--info-line); }
.mode-picker { max-width: 360px; }
.palette-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.palette-card {
  position: relative; display: grid; gap: 10px; padding: 12px; text-align: left; cursor: pointer;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.palette-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.palette-card[aria-checked="true"] { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.palette-card:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: 2px; }
.palette-preview { display: grid; grid-template-columns: 1.4fr 1fr 1fr; height: 44px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.swatch { display: block; }
.palette-text { display: grid; }
.palette-name { font-weight: 650; }
.palette-note { color: var(--muted); font-size: 12.5px; }
.palette-check {
  position: absolute; top: 18px; right: 18px; width: 24px; height: 24px; border-radius: 50%;
  display: none; place-items: center; background: var(--surface); color: var(--primary);
  box-shadow: var(--shadow);
}
.palette-check .icon { width: 16px; height: 16px; stroke-width: 2.6; }
.palette-card[aria-checked="true"] .palette-check { display: grid; }
.env-badge {
  margin-left: 8px; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; border: 1px solid;
}
.env-badge.prod { color: var(--bad); background: var(--bad-soft); border-color: var(--bad-line); }
.env-badge.test { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
.account { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 650; font-size: 12px;
}
.account-name { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }

/* --- buttons and fields ----------------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow);
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
a.btn { text-decoration: none; }
.btn:focus-visible, .select:focus-visible, input:focus-visible, .tabs button:focus-visible, tr.clickable:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: 1px;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { box-shadow: none; border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--idle-soft); }
.icon-btn { width: 36px; padding: 0; }
.field { display: inline-flex; align-items: center; gap: 8px; }
.field-label { color: var(--muted); font-size: 13px; }
input[type="date"], .select {
  height: 36px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}

/* --- gate (sign-in, errors) ------------------------------------------------------------------------------- */
/* Medvertex brand colours, from the logo; they stay the same whatever palette a person picks. */
:root { --mv-navy: #003058; --mv-navy-2: #0a4a7d; --mv-orange: #e8411e; --mv-orange-2: #f26a35; }
body.gated .topbar { display: none; }
.gate { min-height: 100vh; display: grid; grid-template-columns: minmax(400px, 5fr) 6fr; }
.gate-brand {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between;
  padding: 56px clamp(32px, 5vw, 72px) 32px; color: #fff;
  background:
    radial-gradient(600px 400px at 100% 0%, color-mix(in srgb, var(--mv-orange) 32%, transparent), transparent 70%),
    radial-gradient(500px 500px at 0% 100%, color-mix(in srgb, var(--mv-navy-2) 90%, transparent), transparent 70%),
    linear-gradient(160deg, var(--mv-navy) 0%, #00213f 100%);
}
.gate-brand::after {  /* the logo's wing colours, as a thin band */
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px;
  background: linear-gradient(90deg, var(--mv-orange), var(--mv-orange-2) 40%, #f4b400 70%, #4f8ff7);
}
.gate-brand-inner { max-width: 480px; margin: auto 0; }
.gate-logo-tile {
  width: 96px; height: 96px; display: grid; place-items: center; border-radius: 24px;
  background: #fff; box-shadow: 0 18px 40px -12px rgba(0, 0, 0, .45);
}
.gate-logo-tile img { width: 72px; height: 72px; }
.gate-eyebrow { margin: 32px 0 4px; font-size: 13px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--mv-orange-2); }
.gate-product { margin: 0; font-size: clamp(34px, 4vw, 46px); font-weight: 750; letter-spacing: -.025em; line-height: 1.1; }
.gate-tagline { margin: 16px 0 0; font-size: 16px; line-height: 1.6; color: rgba(255, 255, 255, .82); }
.gate-points { list-style: none; margin: 28px 0 0; padding: 0; display: grid; gap: 12px; }
.gate-points li { position: relative; padding-left: 30px; color: rgba(255, 255, 255, .9); }
.gate-points li::before {
  content: ""; position: absolute; left: 0; top: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: color-mix(in srgb, var(--mv-orange) 85%, #fff) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5l4 4 8-9'/%3E%3C/svg%3E") center / 12px no-repeat;
}
.gate-legal { margin: 32px 0 0; font-size: 12.5px; color: rgba(255, 255, 255, .55); }
.gate-panel { display: grid; place-items: center; padding: 40px 24px; background: var(--bg); }
.gate-card {
  width: 100%; max-width: 420px; padding: 36px 36px 32px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg);
}
.gate-card-head { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 20px; min-height: 24px; }
.gate-card-logo { display: none; width: 40px; height: 40px; }
.gate-card h2 { font-size: 22px; margin: 0 0 8px; letter-spacing: -.015em; }
.gate-card p { color: var(--text-2); margin: 0 0 24px; }
.gate-card code { background: var(--idle-soft); padding: 1px 6px; border-radius: 4px; }
.gate-card #gate-env { margin-left: 0; }
.btn-ms {
  width: 100%; height: 44px; gap: 12px; font-weight: 600; font-size: 15px;
  background: #fff; color: #3b3b3b; border: 1px solid #8c8c8c; border-radius: 6px; box-shadow: none;
}
.btn-ms:hover { background: #f3f3f3; }
.btn-ms .ms-logo { flex: none; }
.gate-help { margin: 18px 0 0 !important; font-size: 13px; color: var(--muted) !important; }
@media (max-width: 900px) {
  .gate { grid-template-columns: minmax(0, 1fr); }
  .gate-brand { padding: 32px 24px 28px; }
  .gate-brand-inner { margin: 0; }
  .gate-logo-tile { width: 64px; height: 64px; border-radius: 16px; }
  .gate-logo-tile img { width: 48px; height: 48px; }
  .gate-eyebrow { margin-top: 20px; }
  .gate-points, .gate-legal { display: none; }
  .gate-panel { align-items: start; padding: 24px 16px 40px; }
}
.spinner {
  width: 28px; height: 28px; margin: 0 auto 16px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- layout ----------------------------------------------------------------------------------------------- */
.app { max-width: 1280px; margin: 0 auto; padding: 24px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 22px; }
.page-sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.toolbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.banner { padding: 12px 16px; border-radius: 10px; border: 1px solid; }
.banner-warning { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
.banner code { color: inherit; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: 15px; margin-right: auto; }
.panel-hint { color: var(--muted); font-size: 12.5px; }

/* --- KPI tiles -------------------------------------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi {
  position: relative; overflow: hidden;
  padding: 16px 18px 18px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--idle-line); }
.kpi.ok::before { background: var(--ok); }
.kpi.bad::before { background: var(--bad); }
.kpi.warn::before { background: var(--warn); }
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 550; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { margin-top: 6px; font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.kpi-sub { margin-top: 2px; color: var(--text-2); font-size: 13px; }
.kpi-value .of { color: var(--muted); font-size: 16px; font-weight: 550; }

/* --- steps ------------------------------------------------------------------------------------------------ */
.steps-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.step { padding: 16px 18px; border-right: 1px solid var(--border); position: relative; min-width: 0; }
.step:last-child { border-right: 0; }
.step-order { color: var(--muted); font-size: 12px; font-weight: 600; }
.step-name { font-weight: 650; margin: 2px 0 10px; }
.step-counts { display: flex; gap: 14px; font-size: 13px; color: var(--text-2); }
.step-counts b { font-variant-numeric: tabular-nums; }
.bar { display: flex; height: 6px; margin: 10px 0 8px; border-radius: 99px; overflow: hidden; background: var(--idle-soft); }
.bar > span { display: block; height: 100%; }
.bar .s-ok { background: var(--ok); }
.bar .s-bad { background: var(--bad); }
.bar .s-skip { background: var(--warn); }
.step-error { margin-top: 8px; font-size: 12.5px; color: var(--bad); overflow-wrap: anywhere; }
.step-quiet { margin-top: 8px; font-size: 12.5px; color: var(--muted); }

/* --- status pills ----------------------------------------------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px 2px 8px; border-radius: 999px; border: 1px solid;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.succeeded { color: var(--ok); background: var(--ok-soft); border-color: var(--ok-line); }
.pill.failed { color: var(--bad); background: var(--bad-soft); border-color: var(--bad-line); }
.pill.running { color: var(--info); background: var(--info-soft); border-color: var(--info-line); }
.pill.running::before { animation: pulse 1.2s ease-in-out infinite; }
.pill.queued, .pill.pending { color: var(--idle); background: var(--idle-soft); border-color: var(--idle-line); }
.pill.skipped { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
@keyframes pulse { 50% { opacity: .25; } }

/* --- tabs and table --------------------------------------------------------------------------------------- */
.tabs { display: inline-flex; padding: 3px; gap: 2px; background: var(--idle-soft); border-radius: 9px; }
.tabs button {
  height: 30px; padding: 0 12px; border: 0; border-radius: 7px;
  background: transparent; color: var(--text-2); font: inherit; font-weight: 550; cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; padding: 10px 18px; white-space: nowrap;
  color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.table td { padding: 12px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .nowrap { white-space: nowrap; }
.table .muted { color: var(--muted); }
.table .err { color: var(--bad); max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
.empty { padding: 40px 18px; text-align: center; color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* --- failures list ---------------------------------------------------------------------------------------- */
.failures { list-style: none; margin: 0; padding: 0; }
.failures li {
  display: grid; grid-template-columns: 90px 280px 1fr; gap: 12px; align-items: baseline;
  padding: 12px 18px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.failures li:last-child { border-bottom: 0; }
.failures li:hover { background: var(--surface-2); }
.failures .when { color: var(--muted); font-variant-numeric: tabular-nums; }
.failures .what { font-weight: 600; }
.failures .why { color: var(--bad); overflow-wrap: anywhere; }

/* --- drawer ----------------------------------------------------------------------------------------------- */
.scrim { position: fixed; inset: 0; z-index: 30; background: rgba(16, 24, 40, .45); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 31;
  width: min(640px, 100vw); display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .2s ease;
}
.drawer.open { transform: none; }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.drawer-kicker { color: var(--muted); font-size: 12.5px; font-weight: 550; }
.drawer-head h2 { font-size: 18px; margin-top: 2px; }
.drawer-body { padding: 18px 20px 28px; overflow-y: auto; display: grid; gap: 18px; align-content: start; }
.facts { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; margin: 0; font-size: 13.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.section-title { font-size: 13px; font-weight: 650; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.callout { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--bad-line); background: var(--bad-soft); color: var(--bad); overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.timeline li { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.tl-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface-2); }
.tl-num {
  width: 22px; height: 22px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--idle-soft); color: var(--idle);
}
.tl-name { font-weight: 600; margin-right: auto; }
.tl-time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.tl-body { padding: 10px 14px; display: grid; gap: 8px; }
.tl-body .callout { padding: 8px 10px; font-size: 13px; }
pre.output {
  margin: 0; padding: 10px 12px; max-height: 220px; overflow: auto;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-2); white-space: pre-wrap; word-break: break-word;
}
.result { margin: 0; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }

/* --- modal and toast -------------------------------------------------------------------------------------- */
.modal-wrap { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(16, 24, 40, .5); }
.modal { width: 100%; max-width: 460px; padding: 24px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.modal h2 { font-size: 18px; margin-bottom: 8px; }
.modal p { color: var(--text-2); margin: 0 0 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px;
  background: var(--text); color: var(--surface); box-shadow: var(--shadow-lg); font-weight: 550;
}
.toast.error { background: var(--bad); color: #fff; }

/* --- schedules -------------------------------------------------------------------------------------------- */
.banner-bad { color: var(--bad); background: var(--bad-soft); border-color: var(--bad-line); }
.status-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; border: 1px solid;
  font-size: 12px; font-weight: 600;
}
.status-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-chip.online { color: var(--ok); background: var(--ok-soft); border-color: var(--ok-line); }
.status-chip.offline { color: var(--bad); background: var(--bad-soft); border-color: var(--bad-line); }
.status-chip.warning { color: var(--warn); background: var(--warn-soft, var(--idle-soft)); border-color: var(--warn-line, var(--idle-line)); }
.sched-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sched-card { padding: 18px 20px 16px; display: grid; gap: 14px; align-content: start; min-width: 0; }
.sched-card + .sched-card { border-left: 1px solid var(--border); }
.sched-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.sched-head h3 { margin: 0; font-size: 15px; }
.sched-about { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.sched-next {
  display: grid; gap: 2px; padding: 14px 16px; border-radius: 10px;
  background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 18%, transparent);
}
.sched-card.paused .sched-next { background: var(--warn-soft); border-color: var(--warn-line); }
.sched-label { color: var(--text-2); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.countdown { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--primary); }
.sched-card.paused .countdown { color: var(--warn); font-size: 22px; }
.sched-when { color: var(--text-2); font-size: 13px; }
.sched-facts { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: 13.5px; }
.sched-facts dt { color: var(--muted); }
.sched-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.sched-facts .link { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; display: inline-flex; gap: 8px; align-items: center; }
.sched-facts .link:hover .muted { text-decoration: underline; }
.sched-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sched-foot .muted, .sched-facts .muted { color: var(--muted); }

.switch {
  position: relative; flex: none; width: 44px; height: 24px; padding: 0; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--idle-soft); transition: background .15s, border-color .15s;
}
.switch > span {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow); transition: transform .15s;
}
.switch[aria-checked="true"] { background: var(--ok); border-color: var(--ok); }
.switch[aria-checked="true"] > span { transform: translateX(20px); }
.switch:disabled { opacity: .5; cursor: not-allowed; }
.switch:focus-visible, .segmented button:focus-visible, .chips button:focus-visible, .input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: 1px;
}

/* --- schedule editor -------------------------------------------------------------------------------------- */
.modal-lg { max-width: 620px; padding: 0; display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 2px 0 0; }
.editor-body { padding: 18px 22px; display: grid; gap: 18px; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}
.tz-note { color: var(--muted); font-size: 12.5px; }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
}
.toggle-title { font-weight: 600; }
.toggle-sub { color: var(--muted); font-size: 12.5px; }
.form-group { margin: 0; padding: 0; border: 0; min-width: 0; }
.form-label { display: block; margin-bottom: 6px; color: var(--text-2); font-size: 13px; font-weight: 600; }
.segmented { display: flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--idle-soft); border-radius: 9px; }
.segmented button {
  flex: 1 1 auto; height: 32px; padding: 0 12px; border: 0; border-radius: 7px;
  background: transparent; color: var(--text-2); font: inherit; font-weight: 550; cursor: pointer;
}
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-field { display: flex; flex-direction: column; min-width: 0; }
.form-field .form-label { margin-bottom: 6px; }
.form-wide { grid-column: 1 / -1; }
.input, .form-field .select {
  height: 38px; padding: 0 10px; width: 100%;
  border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit;
}
.input.mono { font-family: var(--mono); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.form-help { margin-top: 6px; color: var(--muted); font-size: 12.5px; }
.form-help code { background: var(--idle-soft); padding: 0 4px; border-radius: 4px; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chips button {
  height: 32px; min-width: 48px; padding: 0 10px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font: inherit; font-weight: 550;
}
.chips button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.chips .chip-link { border-color: transparent; background: none; color: var(--primary); min-width: 0; padding: 0 6px; }
.chips-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.preview { padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.preview-summary { font-weight: 650; }
.preview-list { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.preview-list li { display: flex; justify-content: space-between; gap: 12px; }
.preview-list .in { color: var(--muted); }
.preview.invalid { color: var(--bad); background: var(--bad-soft); border-color: var(--bad-line); }
.preview.paused { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
.callout.callout-warn { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
.history summary { cursor: pointer; color: var(--text-2); font-weight: 600; font-size: 13px; }
.history-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; font-size: 13px; }
.history-list li { display: grid; gap: 1px; padding-left: 12px; border-left: 2px solid var(--border); }
.history-list .who { color: var(--muted); font-size: 12.5px; }

/* --- navy top bar and navigation (palettes that set --chrome-bg) ------------------------------------------ */
:root[data-palette="medvertex"] .topbar, :root[data-palette="medvertex"] .sidenav {
  background: var(--chrome-bg); color: var(--chrome-fg); border-color: var(--chrome-border);
}
:root[data-palette="medvertex"] .topbar .btn-ghost, :root[data-palette="medvertex"] .sidenav .btn-ghost,
:root[data-palette="medvertex"] .account-name, :root[data-palette="medvertex"] .brand-sub,
:root[data-palette="medvertex"] .nav-heading, :root[data-palette="medvertex"] .nav-meta,
:root[data-palette="medvertex"] .sidenav .nav-item a, :root[data-palette="medvertex"] .sidenav .nav-group-btn,
:root[data-palette="medvertex"] .nav-rail-btn, :root[data-palette="medvertex"] .sidenav .nav-star,
:root[data-palette="medvertex"] .sidenav .nav-empty { color: var(--chrome-muted); }
:root[data-palette="medvertex"] .topbar .btn-ghost:hover, :root[data-palette="medvertex"] .sidenav .nav-item a:hover,
:root[data-palette="medvertex"] .sidenav .nav-group-btn:hover, :root[data-palette="medvertex"] .nav-rail-btn:hover,
:root[data-palette="medvertex"] .nav-rail-btn[aria-expanded="true"],
:root[data-palette="medvertex"] .sidenav .nav-star:hover { background: var(--chrome-hover); color: var(--chrome-fg); }
:root[data-palette="medvertex"] .sidenav .nav-star.on { color: #ffb84d; }
:root[data-palette="medvertex"] .sidenav .nav-count { background: var(--chrome-hover); color: var(--chrome-fg); }
:root[data-palette="medvertex"] .sidenav .nav-item a[aria-current="page"], :root[data-palette="medvertex"] #settings-link[aria-current="page"] {
  background: var(--chrome-active); color: #fff;
}
:root[data-palette="medvertex"] .sidenav .nav-item a[aria-current="page"]::before { background: #ff7a4d; }
:root[data-palette="medvertex"] .nav-bottom, :root[data-palette="medvertex"] .sidenav-head,
:root[data-palette="medvertex"] .nav-quick { border-color: var(--chrome-border); }
:root[data-palette="medvertex"] .avatar { background: #ff7a4d; color: #1a0b05; }
:root[data-palette="medvertex"] .brand-logo { border-color: transparent; }

/* --- saved views, columns, collapsible panels ------------------------------------------------------------- */
.view-btn { gap: 6px; max-width: 320px; }
.view-btn .muted { font-weight: 500; }
.view-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view-btn .icon:last-child { width: 14px; height: 14px; color: var(--muted); }
.view-mod { padding: 0 7px; border-radius: 999px; font-size: 11.5px; font-weight: 700; color: var(--warn); background: var(--warn-soft); border: 1px solid var(--warn-line); }
.view-pop { width: 320px; }
.pop-hint { margin: -6px 0 0; color: var(--muted); font-size: 12.5px; }
.view-list { display: grid; gap: 2px; padding: 4px; border: 1px solid var(--border); border-radius: 8px; max-height: 220px; overflow: auto; }
.view-row {
  display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 8px; border: 0; border-radius: 6px;
  background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.view-row:hover, .view-row:focus-visible { background: var(--idle-soft); outline: none; }
.view-row[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.view-check { width: 18px; display: grid; place-items: center; flex: none; }
.view-check .icon { width: 16px; height: 16px; stroke-width: 2.4; }
.view-row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view-default { margin-left: auto; padding: 0 7px; border-radius: 999px; font-size: 11.5px; font-weight: 700; color: var(--ok); background: var(--ok-soft); border: 1px solid var(--ok-line); }
.view-actions { display: grid; gap: 2px; padding-top: 6px; border-top: 1px solid var(--border); }
.view-actions .context-item { height: 32px; white-space: normal; text-align: left; }
.view-actions .danger, .view-actions .danger .icon { color: var(--bad); }
.view-form { display: grid; gap: 10px; }
.collapse-btn { margin-left: 4px; }
.collapse-btn .icon { transition: transform .15s; }
.collapse-btn[aria-expanded="false"] .icon { transform: rotate(-90deg); }
.panel.collapsed > .panel-head { border-bottom: 0; }

/* --- small screens ---------------------------------------------------------------------------------------- */
@media (max-width: 900px) {
  /* The side navigation becomes a drawer that slides in from the left. */
  .nav-resizer { display: none; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidenav {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 35; width: min(300px, 86vw); height: 100vh;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg);
  }
  .sidenav.open { transform: none; }
  .sidenav-head { display: flex; align-items: center; gap: 10px; padding: 0 0 10px 4px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
  .sidenav-head .brand-name { margin-right: auto; }
  :root[data-nav="collapsed"] .nav-rail { display: none; }
  :root[data-nav="collapsed"] .nav-quick, :root[data-nav="collapsed"] .nav-modules,
  :root[data-nav="collapsed"] .nav-setup, :root[data-nav="collapsed"] .nav-bottom { display: grid; }
  .nav-star { opacity: 1; }
  .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .settings-tabs { position: static; grid-auto-flow: column; justify-content: start; overflow-x: auto; }
}
@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .step:nth-child(2) { border-right: 0; }
  .step:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
}
@media (max-width: 640px) {
  .topbar { padding: 0 12px 0 8px; gap: 8px; }
  .account-name, .brand-sub, .brand-text, .avatar { display: none; }
  .topbar-client .field-label { display: none; }
  .topbar-client .client-select { min-width: 0; max-width: 140px; }
  .env-badge { margin-left: 0; }
  .app { padding: 16px; gap: 16px; }
  .kpis, .steps-grid, .sched-grid, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .sched-card + .sched-card { border-left: 0; border-top: 1px solid var(--border); }
  .modal-wrap { padding: 8px; }
  .modal-lg { max-height: calc(100vh - 16px); }
  .modal-foot .modal-actions { width: 100%; }
  .modal-foot .modal-actions .btn { flex: 1; }
  .step { border-right: 0; border-bottom: 1px solid var(--border); }
  .step:last-child { border-bottom: 0; }
  .failures li { grid-template-columns: 1fr; gap: 2px; }
  .facts { grid-template-columns: 1fr; gap: 0 0; }
  .facts dd { margin-bottom: 8px; }
}

/* Client picker (per-client screens) and the client access form */
.client-picker .client-select { min-width: 200px; font-weight: 600; }
.topbar-client .client-select { min-width: 160px; max-width: 240px; height: 34px; }
.client-badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  background: var(--accent-soft, var(--idle-soft)); color: var(--accent, inherit); font-weight: 600; font-size: 13px; }
.check-list { display: grid; gap: 6px; max-height: 280px; overflow: auto; padding: 4px 0; }
.check-row { display: flex; align-items: center; gap: 10px; }
.check-row .mono { font-size: 12px; }
.data-loading { padding: 28px 20px; margin: 0; }

/* --- notifications: the bell and its panel, the screen ------------------------------------------------------ */
.bell-wrap { position: relative; }
.bell { position: relative; }
.bell-badge {
  position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  display: grid; place-items: center; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700;
  line-height: 1; border: 2px solid var(--surface); pointer-events: none;
}
.bell-badge.dot { min-width: 12px; width: 12px; height: 12px; padding: 0; top: 6px; right: 6px; background: var(--primary); }
.bell-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; width: min(400px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg, var(--shadow));
  display: grid; overflow: hidden;
}
.bell-head, .bell-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; }
.bell-head { border-bottom: 1px solid var(--border); }
.bell-head .muted { font-size: 12.5px; }
.bell-foot { border-top: 1px solid var(--border); background: var(--surface-2); }
.bell-list { list-style: none; margin: 0; padding: 4px 0; max-height: 360px; overflow-y: auto; }
.bell-item { display: flex; gap: 10px; align-items: flex-start; padding: 9px 14px; color: inherit; text-decoration: none; }
.bell-item:hover, .bell-item:focus-visible { background: var(--idle-soft); outline: none; }
.bell-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--idle); }
.bell-dot.offline { background: var(--bad); }
.bell-dot.warning { background: var(--warn); }
.bell-dot.online { background: var(--ok); }
.bell-text { display: grid; gap: 2px; min-width: 0; }
.bell-title { font-weight: 600; overflow-wrap: anywhere; }
.bell-when { color: var(--muted); font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bell-empty { margin: 0; padding: 22px 14px; color: var(--muted); text-align: center; }
.note-read { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.note-read.unread { color: var(--primary); font-weight: 650; }
.note-read.unread::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; }
.cell-link.strong { font-weight: 700; }
.note-panel { padding: 18px 20px 22px; display: grid; gap: 16px; }
.note-message { margin: 0; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); overflow-wrap: anywhere; }
.note-message.level-error { color: var(--bad); background: var(--bad-soft); border-color: var(--bad-line); }
.note-message.level-warning { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
.note-panel .output { max-height: 420px; overflow: auto; }
#notes-tabs button { display: inline-flex; align-items: center; gap: 6px; }
#notes-tabs .tab-count { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-line); }

/* Eligibility */
.form-field.inline-field { flex-direction: row; align-items: center; gap: 8px; }
.form-field.inline-field .form-label { margin-bottom: 0; }
#view-eligibility .kpis { margin-bottom: 16px; }
#view-eligibility .callout ul { margin: 6px 0; padding-left: 20px; }
#view-eligibility .change-list li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
#elig-types .check-row span:last-child { color: var(--text-2); }
/* Claims and resubmissions */
.callout.callout-ok { color: var(--ok); background: var(--ok-soft); border-color: var(--ok-line); }
.resub-modal { max-width: 720px; }
.resub-preview { display: grid; gap: 10px; margin-top: 8px; }
.resub-list { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.claims-find { display: flex; gap: 8px; align-items: center; }
.claims-find .input { width: 220px; }
@media (max-width: 600px) { .claims-find .input { width: 100%; } .resub-modal .facts { grid-template-columns: 1fr; } }
/* A confirmation asked from inside another dialog shows above it */
#confirm.modal-wrap { z-index: 50; }

/* --- payment report ------------------------------------------------------------------------------------------ */
.pr-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); margin-bottom: 16px; }
.pr-kpis .kpi-value { font-size: 22px; }
.pr-kpi-click { cursor: pointer; }
.pr-kpi-click:hover { border-color: var(--border-strong); }
.pr-head { flex-wrap: wrap; }
.pr-quick button { height: 28px; font-size: 13px; }
.pr-quick-label { font-size: 12.5px; margin-right: 2px; }
.pr-cas { font-family: var(--mono, ui-monospace, monospace); font-size: 12px; white-space: nowrap; }
.pr-issues { display: inline-block; max-width: 420px; white-space: normal; font-size: 12.5px; color: var(--bad); }
.pr-drawer { width: min(760px, 100vw); }
.pr-history { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pr-step { padding: 12px 14px; border: 1px solid var(--border); border-left: 4px solid var(--ok); border-radius: 10px; display: grid; gap: 6px; font-size: 13.5px; }
.pr-step.bad { border-left-color: var(--bad); }
.pr-step .pr-cas { white-space: normal; overflow-wrap: anywhere; }
.pr-step-issues { color: var(--bad); font-size: 13px; }
.pr-step-note { color: var(--text-2); font-size: 13px; }
#pr-drawer-title { display: flex; align-items: center; gap: 10px; }
@media (max-width: 1200px) { .pr-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 700px) { .pr-kpis { grid-template-columns: minmax(0, 1fr); } }

/* --- EDI text reports ---------------------------------------------------------------------------------------- */
#txt-record { display: grid; gap: 16px; }
.txt-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.txt-find { width: 220px; }
.txt-text { margin: 0; padding: 14px 18px; max-height: 70vh; overflow: auto; white-space: pre; font-size: 12px; line-height: 1.45; }
.bad-text { color: var(--bad); font-weight: 650; }

/* --- menu sections: Modules, Setup (master database) --------------------------------------------------------- */
.nav-setup { padding-top: 8px; border-top: 1px solid var(--border); }
.nav-setup[hidden] { display: none !important; }
.nav-heading-sub { margin-left: 4px; font-weight: 550; text-transform: none; letter-spacing: 0; opacity: .75; }
.nav-panel-body .nav-heading { list-style: none; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
:root[data-palette="medvertex"] .nav-setup { border-color: var(--chrome-border); }

/* --- periodic jobs ------------------------------------------------------------------------------------------- */
#view-periodic .record-view { display: grid; gap: 16px; }
.periodic-schedule-body { padding: 14px 18px 18px; display: grid; gap: 12px; }
.periodic-sched-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.periodic-manage { margin-left: auto; }
.periodic-facts { grid-template-columns: 120px 1fr; }
