/* PathGuard UI. Tokens first; components use tokens only. No inline styles anywhere (CSP). */
:root {
  --bg: #F2F4F7; --surface: #FFFFFF; --surface-2: #E9EDF2; --ink: #111A27; --muted: #566376; --line: #D3DAE3;
  --accent: #1D4ED8; --accent-ink: #FFFFFF; --accent-soft: #E2EAFD;
  --ok: #15803D; --ok-soft: #E1F3E7; --warn: #A16207; --warn-soft: #FBF0D9; --bad: #C2410C; --bad-soft: #FDE7DB;
  --down: #B91C1C; --down-soft: #FBE2E2; --drained: #6D28D9; --drained-soft: #EDE5FC; --unknown: #6B7686; --unknown-soft: #ECEFF3;
  --code-bg: #0E1621; --code-ink: #D8E2EF; --code-dim: #7F8EA3;
  --shadow: 0 1px 2px rgba(17,26,39,.06), 0 4px 16px rgba(17,26,39,.06);
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 10px;
  --sidebar-w: 232px;
  --sidebar-bg: #0F1B2D; --sidebar-ink: #C9D4E3; --sidebar-muted: #7D8DA3; --sidebar-hover: #182840; --sidebar-on: #1E3A66;
  color-scheme: light;
}
/* Dark theme: automatic (system) unless the user picked light; or forced with data-theme="dark". */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1018; --surface: #121A25; --surface-2: #1A2433; --ink: #E4EAF2; --muted: #95A3B6; --line: #263244;
    --accent: #7AA2FF; --accent-ink: #0B1018; --accent-soft: #1B2944;
    --ok: #4ADE80; --ok-soft: #12291C; --warn: #F5B544; --warn-soft: #2D2312; --bad: #FB8A57; --bad-soft: #321C12;
    --down: #F87171; --down-soft: #341517; --drained: #B79CFF; --drained-soft: #241B3D; --unknown: #95A1B2; --unknown-soft: #1C2430;
    --code-bg: #070B11; --code-ink: #D5DFEC; --code-dim: #7C8BA0;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
    --sidebar-bg: #080D15; --sidebar-ink: #C3CEDD; --sidebar-muted: #6F7F95; --sidebar-hover: #121C2A; --sidebar-on: #1B2944;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B1018; --surface: #121A25; --surface-2: #1A2433; --ink: #E4EAF2; --muted: #95A3B6; --line: #263244;
  --accent: #7AA2FF; --accent-ink: #0B1018; --accent-soft: #1B2944;
  --ok: #4ADE80; --ok-soft: #12291C; --warn: #F5B544; --warn-soft: #2D2312; --bad: #FB8A57; --bad-soft: #321C12;
  --down: #F87171; --down-soft: #341517; --drained: #B79CFF; --drained-soft: #241B3D; --unknown: #95A1B2; --unknown-soft: #1C2430;
  --code-bg: #070B11; --code-ink: #D5DFEC; --code-dim: #7C8BA0;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
  --sidebar-bg: #080D15; --sidebar-ink: #C3CEDD; --sidebar-muted: #6F7F95; --sidebar-hover: #121C2A; --sidebar-on: #1B2944;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.55 var(--font-body); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0; text-wrap: balance; }
h1 { font-size: 1.45rem; font-weight: 650; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
code, .mono, pre, kbd { font-family: var(--font-mono); }
code { font-size: .88em; background: var(--surface-2); padding: .05em .35em; border-radius: 4px; }
.num, td.n { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Layout */
.container { max-width: 1320px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
main.container { padding-block: 20px 48px; display: grid; gap: 18px; align-content: start; min-height: calc(100vh - 120px); }
.footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .78rem; }
.footer .container { padding-block: 14px; }
.stack { display: grid; gap: 14px; align-content: start; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid-2 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
.grid-3 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
.grid-cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.section-title { font-size: .72rem; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }

/* Shell (0.3): fixed sidebar on wide screens, off-canvas on phones; top bar with breadcrumbs; status bar */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.shell-main { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }
.shell-main > main { flex: 1 0 auto; }

/* 0.3.3 icon rail: one entry per function, icon above its label */
:root { --sidebar-w: 96px; }
.sidebar.rail .sidebar-head { justify-content: center; padding: 14px 8px 8px; }
.sidebar.rail .logo { flex-direction: column; gap: 4px; font-size: .62rem; letter-spacing: .06em; text-transform: uppercase; color: #fff; }
.sidebar.rail .rail-brand img { width: 36px; height: 36px; display: block; }
.sidebar.rail .rail-brand:hover { text-decoration: none; }
/* brand logos: white on the dark theme, navy on the light theme (the rail is dark in both) */
.brand-block { display: grid; gap: 6px; justify-items: start; }
.brand-logo { width: 220px; height: auto; display: block; }
.brand-product { font: 650 .78rem var(--font-body); letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.brand-on-light { display: none; }
:root[data-theme="light"] .brand-on-dark { display: none; }
:root[data-theme="light"] .brand-on-light { display: block; }
.railnav { display: grid; gap: 2px; align-content: start; padding: 6px 8px 16px; }
.rail-item { display: grid; justify-items: center; gap: 5px; padding: 10px 4px 9px; border-radius: 10px; color: var(--sidebar-ink); text-align: center; }
.rail-item .ico { width: 22px; height: 22px; opacity: .85; }
.rail-label { font: 650 .6rem/1.2 var(--font-body); letter-spacing: .05em; text-transform: uppercase; overflow-wrap: anywhere; }
.rail-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.rail-item.on { background: var(--sidebar-on); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.rail-item.on .ico { opacity: 1; }
.sidebar.rail .sidebar-foot { text-align: center; padding: 10px 4px 14px; font-size: .68rem; }

/* section bar: the active function's pages as tabs */
.sectionbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.sectionbar-inner { display: flex; align-items: center; gap: 6px 18px; flex-wrap: wrap; min-height: 44px; }
.section-name { font: 700 .72rem var(--font-body); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.section-tabs { display: flex; gap: 4px 16px; flex-wrap: wrap; }
.section-tabs a { padding: 11px 2px 9px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; }
.section-tabs a:hover { color: var(--ink); text-decoration: none; }
.section-tabs a.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.infostrip { display: flex; gap: 10px; align-items: flex-start; background: var(--accent-soft); border-radius: 8px; padding: 10px 14px; font-size: .86rem; color: var(--ink); }
.infostrip .ico { color: var(--accent); width: 18px; height: 18px; margin-top: 1px; }
.shell-main main.container { width: 100%; min-height: 0; }
.sidebar { background: var(--sidebar-bg); color: var(--sidebar-ink); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: grid; grid-template-rows: auto 1fr auto; z-index: 40; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; }
.sidebar .logo { color: #fff; }
.sidebar-close { display: none; color: var(--sidebar-ink); }
.sidenav { display: grid; gap: 14px; align-content: start; padding: 6px 10px 16px; }
.sidenav-sec { display: grid; gap: 2px; }
.sidenav-title { font-size: .66rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--sidebar-muted); padding: 4px 10px; }
.sidenav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--sidebar-ink); font-weight: 500; font-size: .88rem; }
.sidenav a .ico { width: 17px; height: 17px; opacity: .8; }
.sidenav a:hover { background: var(--sidebar-hover); text-decoration: none; color: #fff; }
.sidenav a.on { background: var(--sidebar-on); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.sidenav a.on .ico { opacity: 1; }
.sidebar-foot { padding: 10px 20px 16px; color: var(--sidebar-muted); }
.sidebar-scrim { display: none; }
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); font-size: 1rem; }
.logo:hover { text-decoration: none; }
.logo i { width: 18px; height: 18px; border-radius: 5px; background: var(--accent); position: relative; }
.logo i::after { content: ""; position: absolute; left: 5px; top: 3px; width: 6px; height: 9px; border: solid var(--accent-ink); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.sidebar .icon-btn:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar .sidebar-close, .topbar .menu-btn { display: none; }
.shell-main .container { max-width: 1480px; margin-inline: 0; padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner { padding: 8px max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)); display: flex; align-items: center; gap: 14px; min-height: 52px; }
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; font-size: .86rem; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--ink); }
.crumb-sep { color: var(--line); }
.crumb-here { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
/* legacy horizontal nav (kept for pages that still render .nav) */
.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 7px; font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a.on { background: var(--surface-2); color: var(--ink); }

/* Status bar */
.statusbar { border-top: 1px solid var(--line); background: var(--surface); font-size: .78rem; }
.statusbar-inner { display: flex; gap: 6px 18px; flex-wrap: wrap; align-items: center; padding-block: 8px; }
.sb-item { display: inline-flex; gap: 6px; align-items: center; color: var(--ink); }
.sb-link:hover { text-decoration: none; color: var(--down); }
.sb-end { margin-left: auto; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--unknown); display: inline-block; }
.dot.ok { background: var(--ok); }
.dot.down { background: var(--down); }
.dot.warn { background: var(--warn); }

/* Toolbars and filters (tables) */
.toolbar { display: flex; gap: 8px 10px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=search], .toolbar select { width: auto; min-width: 180px; padding: 6px 10px; }
.toolbar .grow { flex: 1 1 220px; }
.toolbar .count { color: var(--muted); font-size: .8rem; margin-left: auto; }
input[type=search] { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; width: 100%; min-width: 0; }
tr.group-row td { background: var(--surface-2); font-weight: 650; font-size: .8rem; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .72rem; font-weight: 600; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
/* separators as outward 1px shadows clipped by the container: an incomplete last row leaves no grey block */
.kpis { display: grid; gap: 0; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.kpi { background: var(--surface); padding: 12px 14px; display: grid; gap: 2px; box-shadow: -1px 0 0 var(--line), 0 -1px 0 var(--line); }
.kpi b { font-size: 1.35rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: .78rem; }
.usermenu { position: relative; }
.usermenu summary { cursor: pointer; list-style: none; padding: 5px 10px; border: 1px solid var(--line); border-radius: 7px; font-size: .82rem; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu-pop { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 6px; display: grid; min-width: 170px; z-index: 30; }
.usermenu-pop a, .usermenu-pop .linkbtn { padding: 7px 10px; border-radius: 6px; color: var(--ink); text-align: left; }
.usermenu-pop a:hover, .usermenu-pop .linkbtn:hover { background: var(--surface-2); text-decoration: none; }
.linkbtn { background: none; border: 0; font: inherit; cursor: pointer; width: 100%; }

/* Flash */
.flash { padding: 10px 14px; border-radius: 8px; background: var(--accent-soft); }
.flash.ok { background: var(--ok-soft); }
.flash.error { background: var(--down-soft); }
.flash.warn { background: var(--warn-soft); }

/* Cards, panels */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 10px; align-content: start; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 8px; font-size: .8rem; color: var(--muted); }
.panel-note { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: .86rem; }
.alert-strip { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border-radius: 8px; padding: 9px 12px; background: var(--warn-soft); }
.alert-strip.critical { background: var(--down-soft); }
.alert-strip.drained { background: var(--drained-soft); }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.empty h1 { color: var(--ink); }

/* Chips */
.chip { display: inline-flex; align-items: center; gap: 6px; font: 600 .7rem/1.6 var(--font-mono); letter-spacing: .03em; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.ok { color: var(--ok); background: var(--ok-soft); }
.chip.warn { color: var(--warn); background: var(--warn-soft); }
.chip.bad { color: var(--bad); background: var(--bad-soft); }
.chip.down { color: var(--down); background: var(--down-soft); }
.chip.drained { color: var(--drained); background: var(--drained-soft); }
.chip.unknown { color: var(--unknown); background: var(--unknown-soft); }
.chip.plain { color: var(--muted); background: var(--surface-2); }
.chip.mode { color: var(--accent); background: var(--accent-soft); }
.chip.plain::before, .chip.mode::before { display: none; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .86rem; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font: 650 .68rem var(--font-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; white-space: nowrap; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 500 .84rem var(--font-body); padding: 7px 13px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { background: var(--down); border-color: var(--down); color: #fff; }
.btn.small { padding: 4px 9px; font-size: .78rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Forms */
form.form { display: grid; gap: 14px; max-width: 880px; }
.field { display: grid; gap: 5px; min-width: 0; align-content: start; }
.form-grid { align-items: start; }
.lib-prose textarea, textarea.prose { font-family: var(--font-body); font-size: .88rem; white-space: pre-wrap; }
.field label, .field .label { font-weight: 600; font-size: .84rem; }
.field .help { color: var(--muted); font-size: .78rem; }
.field .err { color: var(--down); font-size: .8rem; }
input[type=text], input[type=password], input[type=number], input[type=url], select, textarea {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; width: 100%; min-width: 0;
}
textarea { min-height: 110px; font-family: var(--font-mono); font-size: .82rem; line-height: 1.55; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.checkbox { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 14px; margin: 0; display: grid; gap: 12px; min-width: 0; }
legend { font-weight: 650; padding: 0 6px; }

/* Code / preview */
pre.code, .diff { background: var(--code-bg); color: var(--code-ink); border-radius: 8px; padding: 12px 14px; font: .8rem/1.6 var(--font-mono); overflow-x: auto; margin: 0; white-space: pre; }
/* diff lines keep the code text colour on a tinted band (readable on the dark code background in both themes) */
.diff .add { color: var(--code-ink); background: color-mix(in srgb, var(--ok) 28%, transparent); }
.diff .del { color: var(--code-ink); background: color-mix(in srgb, var(--down) 28%, transparent); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.code-wrap { position: relative; }
.code-wrap .copy { position: absolute; top: 8px; right: 8px; }
.problems { margin: 0; padding-left: 1.1em; color: var(--down); font-size: .84rem; }

/* Upstream rows (overview cards) */
.urow { display: grid; grid-template-columns: minmax(56px, auto) auto minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: .82rem; }
.urow .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.urow .mt { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Decision / key-value lists */
dl.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 14px; margin: 0; font-size: .86rem; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* Steps timeline */
.steps { display: grid; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 14px; }
.step { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: .84rem; }
.step:last-child { border-bottom: 0; }
.step i { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); display: inline-block; }
.step i.fail { background: var(--down); }
.step .d { color: var(--muted); font: .74rem var(--font-mono); white-space: nowrap; }
.step small { display: block; color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }

/* Charts */
.chart-box { position: relative; height: 180px; min-width: 0; }
.chart-box.tall { height: 240px; }
.chart-box canvas { width: 100% !important; }
.range-tabs { display: inline-flex; gap: 4px; }
.range-tabs a { padding: 3px 9px; border-radius: 6px; font-size: .78rem; color: var(--muted); border: 1px solid var(--line); }
.range-tabs a.on { background: var(--ink); color: var(--bg); border-color: var(--ink); text-decoration: none; }

/* Tabs */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.tabs a { padding: 6px 11px; border-radius: 7px; color: var(--muted); font-weight: 500; }
.tabs a.on { background: var(--accent-soft); color: var(--ink); }

/* Dialog */
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); padding: 18px; width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(10, 15, 25, .45); }

/* Login */
.login-wrap { min-height: 70vh; display: grid; place-items: center; }
.login-card { width: min(380px, 100%); }

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(280px, 86vw); transform: translateX(-100%); transition: transform .18s ease; box-shadow: var(--shadow); }
  body.sidebar-open .sidebar { transform: none; }
  .sidebar.rail { width: 120px; }
  body.sidebar-open .sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(10, 15, 25, .45); z-index: 35; }
  .sidebar .sidebar-close, .topbar .menu-btn { display: inline-grid; }
}
@media (max-width: 640px) {
  .shell-main .container { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
}
@media (max-width: 640px) {
  .topbar-inner { flex-wrap: wrap; gap: 8px; }
  .crumbs { order: 3; flex-basis: 100%; }
  .hide-sm { display: none; }
  .sb-end { margin-left: 0; }
  .toolbar input[type=search], .toolbar select { min-width: 0; width: 100%; }
  .urow { grid-template-columns: minmax(48px, auto) auto minmax(0, 1fr); }
  .urow > :last-child { grid-column: 1 / -1; justify-self: start; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
