/* Sarv panel — design system, ported from docs/design/kit.html (v1).
   Rules: tokens live in :root and nowhere else; logical properties only;
   no gradient, no glow, no CDN; Persian text never gets letter-spacing,
   italic, or a weight below 400. See docs/design/DESIGN.md for the why. */

/* ------------------------------------------------------------------ fonts
   Self-hosted, see static/FONTS-OFL.txt for the licences. */
@font-face {
  font-family: "Estedad";
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
  src: url("/static/estedad-vf.woff2") format("woff2-variations");
}
@font-face {
  font-family: "Vazirmatn";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("/static/vazirmatn-regular.woff2") format("woff2");
}
@font-face {
  font-family: "Vazirmatn";
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: url("/static/vazirmatn-bold.woff2") format("woff2");
}
@font-face {
  font-family: "Sarv Mono";
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  src: url("/static/jetbrains-mono-vf.woff2") format("woff2-variations");
}

:root {
  /* ---- brand (from the logo: ink lines, gold facets, paper) ---- */
  --ink:        #1B1A17;
  --ink-2:      #3A3833;
  --ink-3:      #6E6A61;
  --paper:      #F4F3EE;   /* workspace background */
  --surface:    #FFFFFF;
  --surface-2:  #F8F7F3;
  --line:       #E3E0D7;
  --line-2:     #CFCBBF;
  --gold:       #B39A5B;   /* the only accent */
  --gold-deep:  #8C7640;
  --gold-tint:  #F3EDDC;

  /* ---- dark rail (sidebar) ---- */
  --rail:       #1B1A17;
  --rail-2:     #23221E;
  --rail-line:  #33312B;
  --rail-fg:    #D9D5CA;
  --rail-muted: #8F8B80;

  /* ---- semantic ---- */
  --ok:    #2E7D5B; --ok-bg:   #E6F2EC;
  --warn:  #9A6A12; --warn-bg: #F7EFD9;
  --bad:   #B3402F; --bad-bg:  #F8E6E2;
  --info:  #2F5F8F; --info-bg: #E4EDF5;
  --gray:  #5C6570; --gray-bg: #ECEEF0;

  /* ---- type ---- */
  --font-display: "Estedad", "Vazirmatn", system-ui, sans-serif;
  --font-body:    "Vazirmatn", system-ui, sans-serif;
  --font-mono:    "Sarv Mono", ui-monospace, "Cascadia Mono", monospace;

  /* ---- rhythm ---- */
  --s0: 4px; --s1: 8px; --s2: 12px; --s3: 16px; --s4: 24px; --s5: 32px; --s6: 48px;
  --r1: 4px; --r2: 8px; --r3: 12px;
  --rail-w: 252px;
  --shadow-1: 0 1px 2px rgba(27,26,23,.06);
  --shadow-2: 0 6px 24px -8px rgba(27,26,23,.18);
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0; color: var(--ink);
  font-family: var(--font-body); font-size: 15px; line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .display { font-family: var(--font-display); line-height: 1.35; margin: 0; }
h1 { font-size: 1.55rem; font-weight: 700; }
h2 { font-size: 1.12rem; font-weight: 600; }
h3 { font-size: 1rem;    font-weight: 600; }
a { color: var(--gold-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--ink-3); }
.small { font-size: .86rem; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.mono { font-family: var(--font-mono); font-size: .84em; direction: ltr; unicode-bidi: isolate; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: var(--r1); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: var(--rail-w) 1fr; min-block-size: 100vh; }

.rail {
  background: var(--rail); color: var(--rail-fg);
  position: sticky; inset-block-start: 0; block-size: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
.brand {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s4) var(--s4) var(--s3);
  text-decoration: none; color: inherit;
}
.brand img { block-size: 46px; inline-size: auto; flex: none; object-fit: contain; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; line-height: 1.1; }
.brand-sub  { color: var(--rail-muted); font-size: .78rem; }

.nav { padding: 0 var(--s2) var(--s3); flex: 1 1 auto; }
.nav details { border-block-start: 1px solid var(--rail-line); }
.nav details:first-child { border-block-start: none; }
.nav summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; justify-content: space-between;
  color: var(--rail-muted); font-size: .8rem; font-weight: 600;
  padding: var(--s2) var(--s2) var(--s1);
}
.nav summary::-webkit-details-marker { display: none; }
.nav summary::after {
  content: ""; inline-size: 7px; block-size: 7px;
  border-inline-end: 1.5px solid currentColor; border-block-end: 1.5px solid currentColor;
  transform: rotate(45deg); transition: transform .15s; margin-inline-end: 4px;
}
.nav details[open] > summary::after { transform: rotate(-135deg); }
.nav-item {
  display: flex; align-items: center; gap: var(--s2);
  color: var(--rail-fg); padding: 7px var(--s2); margin-block: 1px;
  border-radius: var(--r2); border-inline-start: 2px solid transparent;
  font-size: .95rem;
}
.nav-item:hover { background: var(--rail-2); text-decoration: none; }
.nav-item.active { background: var(--rail-2); border-inline-start-color: var(--gold); color: #fff; font-weight: 600; }
.nav-item .count {
  margin-inline-start: auto; font-size: .74rem; font-variant-numeric: tabular-nums;
  background: var(--rail-line); color: var(--rail-fg); padding: 0 7px; border-radius: 999px; line-height: 1.6;
}
.nav-item .count.hot { background: var(--gold); color: var(--ink); font-weight: 700; }

.rail-foot {
  border-block-start: 1px solid var(--rail-line); padding: var(--s3) var(--s4);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
}
.rail-foot .who { display: flex; flex-direction: column; line-height: 1.4; }
.rail-foot .who b { font-weight: 600; }
.rail-foot .who span { color: var(--rail-muted); font-size: .78rem; }
.rail-foot .btn { background: transparent; color: var(--rail-fg); border-color: var(--rail-line); }
.rail-foot .btn:hover { background: var(--rail-2); border-color: var(--rail-muted); }
.rail-foot form { margin: 0; }

.workspace { min-inline-size: 0; }
.topbar {
  position: sticky; inset-block-start: 0; z-index: 5;
  background: rgba(244,243,238,.9); backdrop-filter: blur(6px);
  border-block-end: 1px solid var(--line);
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s5);
}
.crumbs { display: flex; gap: var(--s1); color: var(--ink-3); font-size: .86rem; }
.crumbs a { color: var(--ink-3); }
.crumbs .cur { color: var(--ink); }
.topbar .spacer { flex: 1; }
.pulse { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--ink-3); }
.pulse i { inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.pulse.warn i { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.pulse.bad  i { background: var(--bad);  box-shadow: 0 0 0 3px var(--bad-bg); }
.pulse.off  i { background: var(--ink-3); box-shadow: 0 0 0 3px var(--line); }

.page { padding: var(--s4) var(--s5) var(--s6); max-inline-size: 1240px; margin-inline: auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s3); margin-block-end: var(--s4); flex-wrap: wrap; }
.page-head .lede { color: var(--ink-3); margin-block-start: 2px; }
.page-head .actions { display: flex; gap: var(--s1); flex-wrap: wrap; }
.page > h1:first-child { margin-block-end: var(--s4); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; block-size: auto; }
  .page, .topbar { padding-inline: var(--s3); }
}

/* -------------------------------------------------------------- surfaces */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r3);
  box-shadow: var(--shadow-1); margin-block-end: var(--s4);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  padding: var(--s2) var(--s3); border-block-end: 1px solid var(--line);
}
.panel-head h2 { font-size: 1rem; }
.panel-body { padding: var(--s3); }
.panel-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: var(--s2) var(--s3); border-block-start: 1px solid var(--line); }
.panel.flat { box-shadow: none; }

/* -------------------------------------------------------------- metrics */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--s3); margin-block-end: var(--s4); }
.metric {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r3);
  padding: var(--s3) var(--s3) var(--s2); box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; gap: 2px;
}
.metric .k { color: var(--ink-3); font-size: .86rem; }
.metric .v { font-family: var(--font-display); font-weight: 700; font-size: 2rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.metric .d { font-size: .8rem; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.metric.alert { border-color: var(--bad); background: var(--bad-bg); }
.metric.alert .v { color: var(--bad); }
.metric.attn { border-color: var(--gold); }

/* pipeline strip — the signature element (nodes and edges, like the logo) */
.pipeline {
  background: var(--ink); color: var(--rail-fg); border-radius: var(--r3);
  padding: var(--s4) var(--s4) var(--s3); margin-block-end: var(--s4);
  display: grid; grid-template-columns: repeat(4, 1fr); position: relative;
}
.pipeline::before {
  content: ""; position: absolute; inset-inline: 12.5%; inset-block-start: 41px;
  border-block-start: 1px solid var(--gold); opacity: .6;
}
.stage { position: relative; padding-inline-start: 4px; }
.stage .dot {
  inline-size: 12px; block-size: 12px; border-radius: 50%; background: var(--gold);
  box-shadow: 0 0 0 4px var(--ink); position: relative; z-index: 1; margin-block-end: var(--s2);
}
.stage .name { font-family: var(--font-display); font-weight: 600; font-size: .95rem; }
.stage .v { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stage .s { color: var(--rail-muted); font-size: .8rem; }
.stage .s b { color: var(--gold); font-weight: 600; }
@media (max-width: 720px) { .pipeline { grid-template-columns: 1fr 1fr; } .pipeline::before { display: none; } }

/* -------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { inline-size: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: start; padding: 9px var(--s2); border-block-end: 1px solid var(--line); vertical-align: middle; }
thead th {
  position: sticky; inset-block-start: 0; background: var(--surface-2);
  color: var(--ink-3); font-weight: 600; font-size: .8rem; white-space: nowrap;
  border-block-end: 1px solid var(--line-2);
}
tbody tr:hover > td { background: var(--surface-2); }
tbody tr:last-child > td { border-block-end: none; }
td.num { font-variant-numeric: tabular-nums; }
td.end, th.end { text-align: end; }
td.empty, td.muted[colspan] { text-align: center; color: var(--ink-3); padding-block: var(--s5); }
.row-title { font-weight: 600; }
.row-sub { color: var(--ink-3); font-size: .82rem; }

/* expandable rows: tr.expander owns a details element; the detail row follows */
tr.expander summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--s1); }
tr.expander summary::-webkit-details-marker { display: none; }
tr.expander summary::before {
  content: ""; inline-size: 6px; block-size: 6px; flex: none;
  border-inline-start: 1.5px solid var(--ink-3); border-block-end: 1.5px solid var(--ink-3);
  transform: rotate(45deg); transition: transform .15s;
}
tr.expander details[open] summary::before { transform: rotate(-45deg); }
tr.expander:has(details:not([open])) + tr.detail { display: none; }
tr.detail > td { background: var(--surface-2); padding: var(--s3) var(--s4); }
tr.detail .actions { margin-block-start: var(--s1); }

/* status: the dot carries the colour, the word carries the meaning */
.status { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.status::before { content: ""; inline-size: 8px; block-size: 8px; border-radius: 50%; background: currentColor; }
.status.ok   { color: var(--ok); }   .status.warn { color: var(--warn); }
.status.bad  { color: var(--bad); }  .status.info { color: var(--info); }
.status.gray { color: var(--gray); } .status.off  { color: var(--ink-3); }
.status.pulse::before { box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent); }

/* -------------------------------------------------------------- badges */
.badge {
  display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .78rem; line-height: 1.6;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap;
}
.badge.ok   { background: var(--ok-bg);   color: var(--ok);   border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.bad  { background: var(--bad-bg);  color: var(--bad);  border-color: transparent; }
.badge.info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge.gray { background: var(--gray-bg); color: var(--gray); border-color: transparent; }
.badge.gold { background: var(--gold-tint); color: var(--gold-deep); border-color: transparent; }
.badge.muted { background: transparent; color: var(--ink-3); border-color: transparent; }
.tier { font-family: var(--font-mono); font-size: .74rem; padding: 0 6px; border: 1px solid var(--line-2); border-radius: var(--r1); color: var(--ink-2); }

/* semantic colour for bare spans (no pill, no dot) */
.ok-text { color: var(--ok); }
span.bad { color: var(--bad); }

/* -------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: var(--r2); border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); cursor: pointer;
  font-family: inherit; font-size: .9rem; line-height: 1.6; text-decoration: none;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); text-decoration: none; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: var(--ink-2); }
.btn.gold { background: var(--gold); color: var(--ink); border-color: var(--gold); font-weight: 600; }
.btn.gold:hover { background: var(--gold-deep); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn.small { padding: 3px 10px; font-size: .82rem; }
.btn:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; }
.btn.disabled { pointer-events: none; }

/* -------------------------------------------------------------- forms */
label { display: block; }
input[type="text"], input[type="number"], input[type="password"], input[type="url"],
input[type="search"], input[type="datetime-local"], select, textarea {
  font-family: inherit; font-size: .92rem; padding: 7px 10px; inline-size: 100%;
  border: 1px solid var(--line-2); border-radius: var(--r2); background: var(--surface); color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-tint); }
textarea { resize: vertical; min-block-size: 96px; }
input.ltr, textarea.ltr { direction: ltr; text-align: left; font-family: var(--font-mono); font-size: .86rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--s3); align-items: start; }
.form-grid > .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > .lbl { font-weight: 600; font-size: .9rem; }
.field > .hint { color: var(--ink-3); font-size: .82rem; }
.field.err > input, .field.err > select { border-color: var(--bad); }
.field > .msg { color: var(--bad); font-size: .82rem; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { inline-size: auto; accent-color: var(--gold-deep); }
.form-actions { display: flex; gap: var(--s1); justify-content: flex-start; padding-block-start: var(--s3); border-block-start: 1px solid var(--line); margin-block-start: var(--s3); }

/* toolbar: search and filters above every list */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); padding: var(--s2) var(--s3); border-block-end: 1px solid var(--line); background: var(--surface-2); border-start-start-radius: var(--r3); border-start-end-radius: var(--r3); }
.toolbar input, .toolbar select { inline-size: auto; padding: 5px 9px; font-size: .86rem; }
.toolbar .grow { flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); font-size: .82rem; color: var(--ink-2); cursor: pointer; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.tabs { display: flex; gap: 2px; border-block-end: 1px solid var(--line); margin-block-end: var(--s3); flex-wrap: wrap; }
.tab { padding: 8px 14px; color: var(--ink-3); border-block-end: 2px solid transparent; margin-block-end: -1px; }
.tab:hover { text-decoration: none; color: var(--ink); }
.tab.active { color: var(--ink); border-block-end-color: var(--gold); font-weight: 600; }
.tab .count { color: var(--ink-3); font-size: .8rem; margin-inline-start: 4px; font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------- feedback */
.flash { display: flex; align-items: flex-start; gap: var(--s2); padding: var(--s2) var(--s3); border-radius: var(--r2); border: 1px solid; margin-block-end: var(--s3); font-size: .92rem; }
.flash.ok   { background: var(--ok-bg);   color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.flash.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.flash.bad  { background: var(--bad-bg);  color: var(--bad);  border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.flash b { font-weight: 700; }
.empty { text-align: center; padding: var(--s6) var(--s3); color: var(--ink-3); }
.empty h3 { color: var(--ink); margin-block-end: 4px; }
.empty .btn { margin-block-start: var(--s3); }
.help { border: 1px dashed var(--line-2); border-radius: var(--r2); padding: 0 var(--s3); margin-block-end: var(--s3); background: var(--surface); }
.help summary { cursor: pointer; padding-block: var(--s2); font-weight: 600; color: var(--ink-2); }
.help p { margin-block: 0 var(--s2); color: var(--ink-2); }
.help ul, .help ol { margin-block: 0 var(--s2); color: var(--ink-2); padding-inline-start: var(--s4); }
.errors {
  background: var(--bad-bg); color: var(--bad);
  border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent);
  border-radius: var(--r2); padding: var(--s2) var(--s3); margin-block-end: var(--s3);
}
.errors p { margin: 0; }
.errors ul { margin-block: 4px 0; padding-inline-start: var(--s3); }

/* log rows */
.log { font-size: .9rem; }
.log td.t { font-family: var(--font-mono); font-size: .8rem; color: var(--ink-3); white-space: nowrap; }
.log tr.warn td { background: color-mix(in srgb, var(--warn-bg) 55%, transparent); }
.log tr.error td { background: color-mix(in srgb, var(--bad-bg) 55%, transparent); }
.log .lvl { inline-size: 8px; block-size: 8px; border-radius: 2px; display: inline-block; background: var(--line-2); }
.log tr.warn .lvl { background: var(--warn); } .log tr.error .lvl { background: var(--bad); }

/* ------------------------------------------------------------ login page */
.auth { min-block-size: 100vh; background: var(--ink); display: flex; align-items: center; justify-content: center; padding: var(--s4); }
.login-card { inline-size: 100%; max-inline-size: 380px; background: var(--surface); border-radius: var(--r3); box-shadow: var(--shadow-2); padding: var(--s5); }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: var(--s2); margin-block-end: var(--s4); }
.login-brand img { block-size: 80px; inline-size: auto; }
.login-brand-name { font-family: var(--font-display); font-weight: 700; font-size: 2rem; line-height: 1.1; color: var(--ink); }
.login-heading { font-size: 1.25rem; margin-block-end: var(--s4); text-align: center; }
.login-form .field { margin-block-end: var(--s3); }
.login-form .btn { inline-size: 100%; justify-content: center; margin-block-start: var(--s1); }
.login-version { font-size: .78rem; color: var(--ink-3); text-align: center; margin-block-start: var(--s2); }

/* ------------------------------------------------------------------
   Picker — HTMX suggest-as-you-type source selector (/news toolbar)
   ------------------------------------------------------------------ */
.picker { position: relative; display: inline-flex; align-items: center; gap: 4px; }
.picker > input[type="search"] { inline-size: 14rem; }
.picker-list {
  position: absolute; inset-block-start: calc(100% + 4px); inset-inline: 0;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r2);
  box-shadow: var(--shadow-2); z-index: 10; overflow-y: auto;
  max-block-size: calc(8 * 42px);
}
.picker-list:empty { display: none; }
.picker-item {
  display: flex; align-items: center; gap: var(--s2);
  inline-size: 100%; padding: 8px var(--s3); text-align: start;
  background: transparent; border: none; border-block-end: 1px solid var(--line);
  cursor: pointer; font-family: inherit; font-size: .9rem; color: var(--ink);
}
.picker-item:last-child { border-block-end: none; }
.picker-item:hover { background: var(--surface-2); }
.picker-item-title { font-weight: 600; flex: 1; }
.picker-empty { padding: var(--s2) var(--s3); margin: 0; }
.picker-clear {
  background: transparent; border: none; cursor: pointer;
  color: var(--ink-3); font-size: 1rem; padding: 0 4px; line-height: 1; flex: none;
}
.picker-clear:hover { color: var(--bad); }

/* ==================================================================
   Page-local rules. Each block below belongs to one page or one
   widget. They use the tokens above and no raw colour. Phases 2-5
   replace them page by page with kit components.
   ================================================================== */


/* inline action clusters inside table cells and page heads */
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
.inline-form { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0; }
.inline { display: inline-flex; align-items: center; gap: 4px; }
.inline-input { inline-size: 12rem; }
.htmx-indicator { color: var(--ink-3); }

.form-grid > label, .form-grid > .field { display: flex; flex-direction: column; align-items: start; gap: 4px; margin: 0; }
.form-grid > label > input, .form-grid > label > select, .form-grid > label > textarea { inline-size: 100%; }
.form-grid > label > .muted, .form-grid > .field > .muted { font-size: .85rem; }
.form-grid > .check { flex-direction: row; align-items: center; gap: 6px; }
/* a checkbox is not a text field: the generic 100% width above would stretch it
   and push its own label away */
.form-grid .check > input { inline-size: auto; flex: none; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s3); align-items: end; }

/* the expander of a source row: one line per live problem, each with the
   place it is fixed */
.problem-list { list-style: none; padding-inline-start: 0; margin: 0; display: flex; flex-direction: column; gap: var(--s1); }
.problem-list li { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.tier-edit { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.w-sec { inline-size: 5.5rem; }
.w-desc { inline-size: 10rem; }

/* selector preview and suggestion boxes */
.preview-box { margin-block-start: var(--s1); }
.preview-links { padding-inline-start: var(--s3); }
.preview-links .p-title { font-weight: 400; }
.preview-links .p-url { color: var(--ink-3); font-size: .85rem; }
.preview-actions { display: flex; align-items: center; gap: var(--s1); flex-wrap: wrap; margin-block-start: var(--s1); }
.suggest-box { margin-block-start: var(--s1); }
.suggest-box details { margin-block-start: var(--s1); }
.suggest-box pre {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r2);
  padding: var(--s1); overflow-x: auto; font-size: .85rem;
}
#preview-fieldset { border: none; padding: 0; margin: 0; }
.pattern-field { margin-block: var(--s3); }
.pattern-field > strong { display: block; }

.fields dt { font-weight: 700; margin-block-start: var(--s1); }
.fields dd { margin-inline-start: 0; }
.fields dd.body { white-space: pre-wrap; }
.media-list { padding-inline-start: var(--s3); }


/* worker log page */
pre.detail { direction: ltr; margin: 0; font-size: .8rem; white-space: pre-wrap; word-break: break-all; color: var(--ink-3); }
.pager { display: flex; gap: var(--s4); align-items: center; margin-block: var(--s3); }

/* rollup detail tables (phase 3 keeps these inside tr.detail) */
.detail-rows td.time { white-space: nowrap; }
.detail-rows td.problem { inline-size: 12rem; }
.detail-rows td.problem .clip { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.label-full { margin-block: 0 var(--s1); color: var(--ink-3); font-size: .85rem; }
tr.detail h3 { margin-block: var(--s2) var(--s1); font-size: .95rem; }
tr.detail h3:first-child { margin-block-start: 0; }
tr.detail .table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); }

/* a number is never as wide as a paragraph: a full-width settings field keeps
   its explanation wide and its input narrow */
.form-grid > .field.full > input[type="number"] { max-inline-size: 14rem; }

/* a toolbar that closes a panel instead of opening it: the pager of a long
   table, the "add" action under a list. Same shape as .toolbar, mirrored. */
.toolbar.foot {
  border-block-end: none; border-block-start: 1px solid var(--line);
  border-start-start-radius: 0; border-start-end-radius: 0;
  border-end-start-radius: var(--r3); border-end-end-radius: var(--r3);
}

/* the bulk action bar of the cluster page: the same foot, but pinned, so the
   operator never scrolls to the end to act */
.toolbar.bulkbar {
  position: sticky; inset-block-end: 0; z-index: 2;
  border-block-end: none; border-block-start: 1px solid var(--line);
  border-start-start-radius: 0; border-start-end-radius: 0;
  border-end-start-radius: var(--r3); border-end-end-radius: var(--r3);
}
.toolbar form { display: flex; align-items: center; gap: var(--s1); margin: 0; }
.toolbar .inline-input { inline-size: 14rem; }
.toolbar p { margin: 0; }
.bulk-close-disclosure { display: inline-block; }
.bulk-close-disclosure summary { cursor: pointer; list-style: none; }
.bulk-close-disclosure summary::-webkit-details-marker { display: none; }
.bulk-close-disclosure form { margin-block-start: var(--s1); flex-wrap: wrap; }

td details h4 { margin-block: var(--s1) 2px; color: var(--ink-3); font-size: .8rem; font-weight: 600; }

/* the warning colour on a plain hint (settings notes) */
.warn-text { color: var(--warn); }

/* a disclosure whose summary is a button: the reset-password form of
   /operators and the detail toggles of the log tables */
summary.btn { display: inline-flex; list-style: none; }
summary.btn::-webkit-details-marker { display: none; }
details.reset-pass { display: inline-block; }
details.reset-pass form { margin-block-start: var(--s1); }
