/* Foundation and shared components: the shell, cards, controls, tables,
   overlays and feedback. Values come from tokens.css. */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: var(--page);
  color: var(--ink-1);
  font: var(--fs-md) / var(--lh-normal) var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern";
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: var(--lh-tight); }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre, kbd, .mono { font-family: var(--font-mono); font-size: 0.9em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-wash-strong); }

.muted { color: var(--ink-3); }
.secondary { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.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;
}
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.phrase { display: inline-block; max-width: 100%; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.stack { display: flex; flex-direction: column; gap: var(--sp-5); }
.stack.tight { gap: var(--sp-2); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-5); }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
.icon { width: 18px; height: 18px; flex: none; }
.icon.sm { width: 16px; height: 16px; }
.icon.xs { width: 14px; height: 14px; }

/* Status symbols: a filled shape in the status colour with a white mark. */
.sym { width: 14px; height: 14px; flex: none; display: block; }
.sym .sym-shape { fill: currentColor; }
.sym .sym-mark { fill: none; stroke: #fff; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sym .sym-dot { fill: #fff; }
.sym.outline .sym-shape { fill: none; stroke: currentColor; stroke-width: 1.4; }
.sym.outline .sym-mark { stroke: currentColor; }

/* ---- the shell: a floating sidebar and the page */
.app {
  display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh;
  background: var(--page);
}
.sidebar {
  position: sticky; top: 12px; margin: 12px 0 12px 12px; height: calc(100vh - 24px); height: calc(100dvh - 24px);
  display: flex; flex-direction: column; padding: var(--sp-4) 10px 10px; z-index: 20;
  background: var(--material); -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
  border: 1px solid var(--material-edge); border-radius: var(--r-2xl); box-shadow: var(--shadow-card), var(--highlight);
  overflow: hidden;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px var(--sp-4); min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: none; display: grid; place-items: center; color: #fff;
  background: linear-gradient(160deg, var(--brand-a), var(--brand-b));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 4px 10px -4px rgba(0, 88, 214, 0.6);
}
.brand-mark .icon { width: 19px; height: 19px; }
.brand-name { font-weight: 650; font-size: 15px; line-height: 1.25; letter-spacing: -0.01em; }
.brand-sub { color: var(--ink-3); font-size: var(--fs-xs); }
/* In a window too short for the whole sidebar the list of pages scrolls,
   and the brand, the upstream's state and the account stay in view. The
   list reaches 4px past the items so their focus rings are not cut. */
.nav {
  display: flex; flex-direction: column; gap: 2px; min-height: 0; margin: 0 -4px; padding: 0 4px 4px;
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav-label {
  color: var(--ink-3); font-size: var(--fs-2xs); font-weight: 600; letter-spacing: 0.02em;
  padding: var(--sp-4) 10px 6px;
}
.nav-item {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 4px 10px 4px 6px;
  border-radius: var(--r-md); color: var(--ink-1); font-weight: 500;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-item:hover { background: var(--hover); text-decoration: none; }
.nav-item:active { background: var(--press); }
.nav-item[aria-current="page"] { background: var(--accent-fill); color: var(--ink-on-accent); }
.nav-item:focus-visible { outline-offset: 1px; }
/* The coloured tile in front of each page, as in System Settings. */
.nav-icon {
  --tone: var(--tone-gray);
  width: 24px; height: 24px; border-radius: 7px; flex: none; display: grid; place-items: center; color: #fff;
  background: linear-gradient(180deg, color-mix(in srgb, var(--tone) 76%, #fff), var(--tone));
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.1), 0 1px 1.5px rgba(0, 0, 0, 0.12);
}
.nav-icon .icon { width: 15px; height: 15px; stroke-width: 2.1; }
.nav-item[aria-current="page"] .nav-icon { box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.7); }
.tone-blue { --tone: var(--tone-blue); }
.tone-indigo { --tone: var(--tone-indigo); }
.tone-orange { --tone: var(--tone-orange); }
.tone-teal { --tone: var(--tone-teal); }
.tone-green { --tone: var(--tone-green); }
.tone-pink { --tone: var(--tone-pink); }
.tone-purple { --tone: var(--tone-purple); }
.tone-gray { --tone: var(--tone-gray); }
.tone-brown { --tone: var(--tone-brown); }
.sidebar-foot { margin-top: auto; padding-top: var(--sp-4); display: flex; flex-direction: column; gap: 6px; }
.upstream-pill {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px var(--sp-2); padding: 8px 10px; border-radius: var(--r-lg);
  box-shadow: inset 0 0 0 1px var(--line); font-size: var(--fs-sm); color: var(--ink-2); font-weight: 500;
}
.upstream-pill > span:not(.status) { white-space: nowrap; }
.upstream-pill:hover { text-decoration: none; background: var(--hover); }
.upstream-pill .status { margin-left: auto; }
.me-button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; background: none;
  border-radius: var(--r-lg); cursor: pointer; text-align: left;
  transition: background var(--t-fast) var(--ease);
}
.me-button:hover, .me-button[aria-expanded="true"] { background: var(--hover); }
.me-button .who { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; flex: 1; }
.me-button .who .name { font-weight: 600; }
.me-button .who .role { color: var(--ink-3); font-size: var(--fs-xs); }
/* A monogram, as in Contacts. */
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 600; font-size: 13px; color: #fff; letter-spacing: 0;
  background: linear-gradient(180deg, #a5abb8, #858994);
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.08);
}
.avatar.lg { width: 64px; height: 64px; font-size: 26px; }
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }

.topbar { display: none; }
.main { min-width: 0; }
.page { max-width: var(--content-width); margin: 0 auto; padding: var(--sp-7) var(--sp-8) var(--sp-9); }
.page-body { animation: page-in var(--t-med) var(--ease); }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } }
.page-head { display: flex; align-items: flex-end; gap: var(--sp-4); margin-bottom: var(--sp-6); flex-wrap: wrap; }
.page-head .titles { min-width: 0; flex: 1 1 320px; }
.page-head h1 { font-family: var(--font-display); font-size: var(--fs-3xl); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.page-head .description { color: var(--ink-3); margin-top: 6px; font-size: 15px; }
.page-head .actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }

/* The bar that takes the page's title once the large title has scrolled
   away, over a translucent material. */
.toolbar {
  position: fixed; z-index: 30; top: 0; left: var(--sidebar-width); right: 0; height: 52px; display: flex; align-items: center;
  padding: 0 var(--sp-8); gap: var(--sp-3);
  background: var(--material-strong); -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
  border-bottom: 1px solid var(--line);
  visibility: hidden; opacity: 0; transform: translateY(-4px);
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), visibility 0s var(--t-fast);
}
.toolbar.shown { visibility: visible; opacity: 1; transform: none; transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.toolbar .toolbar-title { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.toolbar .toolbar-up { margin-left: auto; }

/* ---- cards: grouped content on the page */
.card {
  background: var(--surface); border: 1px solid var(--card-edge); border-radius: var(--r-xl); box-shadow: var(--shadow-card);
  min-width: 0;
}
.card-head {
  display: flex; align-items: center; gap: 6px var(--sp-3); padding: var(--sp-4) var(--sp-5) var(--sp-3); min-height: 60px; flex-wrap: wrap;
}
.card-head h2 { font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.01em; }
.card-head .hint { color: var(--ink-3); font-size: var(--fs-sm); }
/* A text button in a card's header lines its words up with the card's
   content rather than its capsule, at the end of the line or, wrapped, at
   the start of the next. */
.card-head > .btn.ghost.sm { margin: 0 -12px; }
.card-head + .card-body { padding-top: var(--sp-1); }
.card-body { padding: var(--sp-5); }
.card-body.flush { padding: 0; }
/* A flush body at the top or bottom of a card is cut to the card's
   corners; otherwise a header row, a hovered row or the totals would be
   drawn square across them. */
.card > .card-body.flush:first-child { border-top-left-radius: inherit; border-top-right-radius: inherit; overflow: hidden; }
.card > .card-body.flush:last-child { border-bottom-left-radius: inherit; border-bottom-right-radius: inherit; overflow: hidden; }
.card-foot { padding: var(--sp-3) var(--sp-5) var(--sp-4); border-top: 1px solid var(--line); color: var(--ink-3); font-size: var(--fs-sm); }
.section-title { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); margin-bottom: var(--sp-3); }

/* ---- buttons: capsules. Grey fill by default, the accent for the one
   thing a view is for, plain text for the quiet ones. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 16px;
  border: 0; background: var(--fill); color: var(--ink-1); border-radius: var(--r-full);
  font-weight: 500; font-size: var(--fs-md); cursor: pointer; white-space: nowrap; -webkit-user-select: none; user-select: none;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), transform 120ms var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--fill-hover); text-decoration: none; }
.btn:active { background: var(--fill-press); transform: scale(0.97); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn .icon { width: 16px; height: 16px; }
.btn.primary { background: var(--accent-fill); color: var(--ink-on-accent); }
.btn.primary:hover { background: var(--accent-fill-hover); }
.btn.danger { color: var(--bad-ink); }
.btn.danger:hover { background: var(--bad-wash); }
.btn.danger-fill { background: var(--bad-fill); color: #fff; }
.btn.danger-fill:hover { background: var(--bad-fill-hover); }
.btn.ghost { background: transparent; color: var(--accent-ink); }
.btn.ghost:hover { background: var(--hover); }
.btn.ghost:active { background: var(--press); }
.btn.ghost.icon-only { color: var(--ink-2); }
.btn.ghost.icon-only:hover { color: var(--ink-1); }
.btn.sm { height: 28px; padding: 0 12px; font-size: var(--fs-sm); }
.btn.sm .icon { width: 15px; height: 15px; }
.btn.lg { height: 44px; padding: 0 22px; font-size: 15px; font-weight: 600; }
.btn.icon-only { width: 34px; padding: 0; }
.btn.sm.icon-only { width: 28px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn[aria-busy="true"] { cursor: progress; }
.btn[aria-busy="true"] > .icon { display: none; }
.btn[aria-busy="true"]::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- form controls: every control is the same height, so a row lines up */
input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="email"],
input[type="search"], select, textarea {
  height: 36px; width: 100%; min-width: 0; padding: 0 12px; border: 1px solid var(--control-border);
  border-radius: var(--r-md); background-color: var(--surface); color: var(--ink-1);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
dialog input[type="text"], dialog input[type="password"], dialog input[type="number"], dialog input[type="date"],
dialog input[type="email"], dialog input[type="search"], dialog select, dialog textarea { background-color: var(--raised); }
textarea { height: auto; min-height: 76px; padding: 9px 12px; resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
input[aria-invalid="true"] { border-color: var(--bad); }
input:disabled, select:disabled { background-color: var(--sunken); color: var(--ink-3); cursor: not-allowed; }
input[type="search"] { -webkit-appearance: none; appearance: none; }
/* Pop-up buttons carry the up-and-down chevrons of macOS. */
select {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer; text-overflow: ellipsis;
  background-image: url(../img/select.svg); background-repeat: no-repeat; background-position: right 11px center; background-size: 9px 14px;
}
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) select { background-image: url(../img/select-dark.svg); } }
:root[data-theme="dark"] select { background-image: url(../img/select-dark.svg); }
input[type="date"] { padding-right: 8px; }
/* No spin buttons: Safari and Firefox always draw them, in the middle of a
   field that has a unit after it, and nobody steps to 50,000 by ones. */
input[type="number"] { font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="checkbox"] { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > .label { font-size: var(--fs-sm); font-weight: 500; color: var(--ink-2); }
.field > .help { font-size: var(--fs-xs); color: var(--ink-3); line-height: 1.5; }
.field > .error { font-size: var(--fs-xs); color: var(--bad-ink); }
.input-affix { position: relative; display: flex; align-items: center; }
.input-affix > input { padding-right: 64px; }
.input-affix > .suffix { position: absolute; right: 12px; color: var(--ink-3); font-size: var(--fs-sm); pointer-events: none; }
.input-affix > .reveal { position: absolute; right: 4px; }
.input-affix > input.has-reveal { padding-right: 40px; }
.input-affix > .prefix { position: absolute; left: 12px; color: var(--ink-3); pointer-events: none; }
.input-affix.prefixed > input { padding-left: 26px; font-variant-numeric: tabular-nums; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-section { display: flex; flex-direction: column; gap: var(--sp-4); }
.form-section + .form-section { border-top: 1px solid var(--line); padding-top: var(--sp-5); margin-top: var(--sp-5); }
.form-section > h3 { font-size: 15px; font-weight: 600; }
/* What a dialog says before its first section, such as why it only shows. */
.notice.form-intro { margin-bottom: var(--sp-5); }
.form-section > .lead { color: var(--ink-3); font-size: var(--fs-sm); margin-top: -10px; }
.check { display: inline-flex; align-items: center; gap: var(--sp-2); cursor: pointer; color: var(--ink-2); }

/* A switch is a checkbox drawn as a track and a knob. */
.switch { display: inline-flex; align-items: center; gap: var(--sp-3); cursor: pointer; }
.switch input {
  appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 13px; margin: 0;
  background: var(--switch-off); position: relative; cursor: pointer; transition: background 200ms var(--ease); flex: none;
}
.switch input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
  transition: transform 280ms var(--spring);
}
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(18px); }
.switch input:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.switch input:disabled { opacity: 0.4; cursor: not-allowed; }
.switch:has(input:disabled) { cursor: not-allowed; }

/* A segmented control: radio-like buttons on a grey track, the chosen one
   on a white thumb that slides (ui.js places it). */
.seg {
  position: relative; display: inline-flex; padding: 2px; gap: 0; border-radius: var(--r-md); background: var(--fill);
  flex-wrap: wrap; isolation: isolate;
}
.seg-thumb {
  position: absolute; z-index: 0; top: 0; left: 0; width: 0; height: 0; border-radius: var(--r-sm); background: var(--thumb);
  box-shadow: var(--shadow-thumb), 0 0 0 0.5px rgba(0, 0, 0, 0.04); pointer-events: none;
}
.seg.ready .seg-thumb { transition: transform 320ms var(--spring), width 320ms var(--spring), height 320ms var(--spring); }
.seg button {
  position: relative; z-index: 1; height: 28px; padding: 0 12px; border: 0; border-radius: var(--r-sm); background: none; color: var(--ink-2);
  font-size: var(--fs-sm); font-weight: 500; cursor: pointer; white-space: nowrap; -webkit-tap-highlight-color: transparent;
  transition: color var(--t-fast) var(--ease);
}
.seg button:hover { color: var(--ink-1); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { color: var(--ink-1); }
/* Until the thumb is placed (or where it cannot be), the chosen button
   carries the thumb's look itself. */
.seg:not(.has-thumb) button[aria-pressed="true"] { background: var(--thumb); box-shadow: var(--shadow-thumb); }
.seg:not(.has-thumb) .seg-thumb { visibility: hidden; }
.seg button:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* The filter row: one line above what it scopes. */
.filters { display: flex; align-items: flex-end; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.filters .field { width: 180px; }
.filters .field.wide { width: 240px; }
.filters .field.date { width: 156px; }
.filters .field.narrow { width: 140px; }
.filters .field.auto { width: auto; }
.filters .check { height: 36px; }
/* Beside fields, in the filter row or a form, a segmented control is as
   tall as a field; in a form's column it is as wide as its choices rather
   than the column. */
.filters .seg button, .field > .seg button, .stack > .seg button { height: 32px; }
.field > .seg, .stack > .seg { align-self: flex-start; }

/* ---- status: a symbol and a word, never colour alone */
.status {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; font-size: 12.5px; font-weight: 600;
  padding: 0 9px 0 5px; border-radius: var(--r-full); min-height: 22px; line-height: 1.2;
}
.status.good { color: var(--good-ink); background: var(--good-wash); }
.status.good .sym { color: var(--good); }
.status.warn { color: var(--warn-ink); background: var(--warn-wash); }
.status.warn .sym { color: var(--warn); }
.status.bad { color: var(--bad-ink); background: var(--bad-wash); }
.status.bad .sym { color: var(--bad); }
.status.off { color: var(--ink-2); background: var(--off-wash); }
.status.off .sym { color: var(--off); }
.status.plain { background: none; padding: 0; min-height: 0; }
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 0 9px; border-radius: var(--r-full); min-height: 22px; line-height: 1.2;
  font-size: var(--fs-xs); font-weight: 500; color: var(--ink-2); background: var(--fill); white-space: nowrap;
}
.tag.accent { color: var(--accent-ink); background: var(--accent-wash); }
.tag.accent.strong { color: var(--ink-on-accent); background: var(--accent-fill); }
.tag .icon { width: 13px; height: 13px; }
code.chip {
  padding: 2px 7px; border-radius: var(--r-xs); background: var(--fill); font-size: 12px; white-space: nowrap; color: var(--ink-1);
}

/* ---- tables */
.table-wrap { overflow-x: auto; }
table.data { border-collapse: separate; border-spacing: 0; width: 100%; font-size: var(--fs-md); }
table.data th, table.data td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data th:first-child, table.data td:first-child { padding-left: var(--sp-5); }
table.data th:last-child, table.data td:last-child { padding-right: var(--sp-5); }
/* A table set in a card's padded body (not flush with its edges) lines its
   first and last columns up with the content above it. */
.card-body:not(.flush) .table-wrap table.data th:first-child, .card-body:not(.flush) .table-wrap table.data td:first-child { padding-left: 0; }
.card-body:not(.flush) .table-wrap table.data th:last-child, .card-body:not(.flush) .table-wrap table.data td:last-child { padding-right: 0; }
table.data thead th {
  position: sticky; top: 0; z-index: 1; background: var(--surface); color: var(--ink-3); font-weight: 600;
  font-size: var(--fs-xs); white-space: nowrap; padding-top: 9px; padding-bottom: 9px;
}
table.data th.num, table.data td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data th.actions, table.data td.actions { text-align: right; white-space: nowrap; width: 1%; }
table.data tbody tr { transition: background var(--t-fast) var(--ease); }
@media (hover: hover) { table.data tbody tr:hover { background: var(--hover); } }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
table.data tr.muted-row td { color: var(--ink-3); }
table.data tfoot td { font-weight: 600; border-top: 1px solid var(--line-strong); border-bottom: 0; background: var(--sunken); }
table.data .sub { display: block; color: var(--ink-3); font-size: var(--fs-xs); margin-top: 2px; }
table.data th button.sort {
  border: 0; background: none; padding: 0; color: inherit; font: inherit; cursor: pointer; display: inline-flex; gap: 4px; align-items: center;
}
table.data th button.sort:hover { color: var(--ink-1); }
table.data th[aria-sort] { color: var(--ink-1); }
table.data th .arrow { font-size: 9px; }
.cell-main { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.cell-main .text { min-width: 0; }

/* ---- feedback: notifications, as banners on a material */
.toasts {
  position: fixed; right: var(--sp-5); bottom: var(--sp-5); z-index: 100; display: flex; flex-direction: column; gap: var(--sp-2);
  width: min(380px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: var(--sp-3); padding: 12px 10px 12px 14px;
  background: var(--material-strong); -webkit-backdrop-filter: saturate(180%) blur(30px); backdrop-filter: saturate(180%) blur(30px);
  border: 1px solid var(--material-edge); border-radius: var(--r-xl); box-shadow: var(--shadow-2);
  animation: toast-in 420ms var(--spring);
}
.toast .glyph { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: none; color: #fff; }
.toast .glyph .icon { width: 14px; height: 14px; stroke-width: 2.4; }
.toast.good .glyph { background: var(--good); }
.toast.bad .glyph { background: var(--bad); }
.toast .body { flex: 1; min-width: 0; padding-top: 2px; }
.toast .title { font-weight: 600; }
.toast .detail { color: var(--ink-2); font-size: var(--fs-sm); word-break: break-word; margin-top: 1px; }
.toast.leaving { opacity: 0; transform: translateY(8px) scale(0.98); transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.96); } }

/* ---- overlays: sheets (centred), inspectors (a panel at the right) and
   alerts. Heights use the dynamic viewport (dvh) where there is one, so a
   phone's browser bars do not cover a dialog's buttons; vh is the fallback.
   Older Safari and Chrome do not pass custom properties to ::backdrop,
   hence the fallback colour there. */
dialog {
  border: 1px solid var(--material-edge); background: var(--raised); color: var(--ink-1); padding: 0; box-shadow: var(--shadow-3);
  max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); overflow: hidden;
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: var(--overlay, rgba(0, 0, 0, 0.22)); }
dialog.modal { width: min(560px, calc(100vw - 32px)); border-radius: var(--r-2xl); margin: auto; }
dialog.modal.wide { width: min(740px, calc(100vw - 32px)); }
dialog.modal.narrow { width: min(440px, calc(100vw - 32px)); }
dialog.modal[open] { animation: modal-in 380ms var(--spring); }
dialog.drawer {
  margin: 10px 10px 10px auto; height: calc(100vh - 20px); height: calc(100dvh - 20px); max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px);
  width: min(740px, calc(100vw - 20px)); max-width: calc(100vw - 20px); border-radius: var(--r-2xl);
}
dialog.drawer.wide { width: min(980px, calc(100vw - 20px)); }
dialog.drawer[open] { animation: drawer-in 420ms var(--spring); }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.97); } }
@keyframes drawer-in { from { opacity: 0.3; transform: translateX(56px); } }
.dialog-head {
  position: relative; display: flex; align-items: flex-start; gap: var(--sp-3); padding: 20px 20px 14px 24px; flex: none;
}
.dialog-head .titles { flex: 1; min-width: 0; padding-top: 4px; }
.dialog-head h2 { font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }
.dialog-head .sub { color: var(--ink-3); font-size: var(--fs-sm); margin-top: 3px; overflow-wrap: anywhere; }
/* The body takes the height of what is in it, and gives way when the dialog
   reaches its greatest height. Its basis must be auto: with a basis of zero
   Safari gives a dialog that has no height of its own a body of no height. */
.dialog-body { padding: var(--sp-2) var(--sp-6) var(--sp-5); overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.dialog-foot {
  display: flex; justify-content: flex-end; align-items: center; gap: var(--sp-2); padding: 14px var(--sp-6) 18px;
  border-top: 1px solid var(--line); flex: none; flex-wrap: wrap;
}
.dialog-foot .left { margin-right: auto; color: var(--ink-3); font-size: var(--fs-sm); }
/* An alert: centred, a symbol over the title, two equal buttons. */
dialog.confirm { text-align: center; }
dialog.confirm .dialog-head { flex-direction: column; align-items: center; padding: 28px 24px 4px; }
dialog.confirm .dialog-head .titles { padding-top: 0; }
dialog.confirm .dialog-head > .btn.icon-only { position: absolute; top: 12px; right: 12px; }
dialog.confirm .dialog-head h2 { font-size: 17px; }
dialog.confirm .dialog-body { color: var(--ink-2); padding: 6px 28px 6px; font-size: var(--fs-md); }
dialog.confirm .dialog-body .notice { text-align: left; }
dialog.confirm .dialog-foot { border-top: 0; padding: 18px 20px 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
dialog.confirm .dialog-foot .btn { width: 100%; height: 38px; }
.confirm-glyph { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; flex: none; margin-bottom: 6px; }
.confirm-glyph .icon { width: 26px; height: 26px; }
.confirm-glyph.bad { background: var(--bad-wash); color: var(--bad-ink); }
.confirm-glyph.warn { background: var(--warn-wash); color: var(--warn-ink); }
.confirm-glyph.info { background: var(--accent-wash); color: var(--accent-ink); }

/* ---- menus (a popover list of actions), as macOS draws them */
.menu {
  position: fixed; z-index: 60; min-width: 220px; padding: 5px;
  background: var(--material-strong); -webkit-backdrop-filter: saturate(180%) blur(30px); backdrop-filter: saturate(180%) blur(30px);
  border: 1px solid var(--material-edge); border-radius: var(--r-lg); box-shadow: var(--shadow-2);
  animation: menu-in 160ms var(--ease); transform-origin: top;
}
@keyframes menu-in { from { opacity: 0; transform: scale(0.97); } }
.menu [role="menuitem"], .menu [role="menuitemradio"] {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 32px; padding: 4px 10px; border: 0; background: none;
  border-radius: 7px; text-align: left; cursor: pointer; color: var(--ink-1); font-size: var(--fs-md);
}
.menu [role^="menuitem"] .icon { color: var(--ink-2); width: 16px; height: 16px; }
.menu [role^="menuitem"]:hover, .menu [role^="menuitem"]:focus { background: var(--accent-fill); color: #fff; outline: none; }
.menu [role^="menuitem"]:hover .icon, .menu [role^="menuitem"]:focus .icon { color: #fff; }
.menu [role^="menuitem"].danger { color: var(--bad-ink); }
.menu [role^="menuitem"].danger .icon { color: var(--bad-ink); }
.menu [role^="menuitem"].danger:hover, .menu [role^="menuitem"].danger:focus { background: var(--bad-fill); color: #fff; }
.menu [role^="menuitem"].danger:hover .icon, .menu [role^="menuitem"].danger:focus .icon { color: #fff; }
.menu [role="menuitemradio"] .check-mark { margin-left: auto; visibility: hidden; }
.menu [role="menuitemradio"][aria-checked="true"] .check-mark { visibility: visible; }
.menu .sep { height: 1px; background: var(--line); margin: 5px 10px; }
.menu .menu-label { padding: 6px 10px 3px; color: var(--ink-3); font-size: var(--fs-xs); font-weight: 600; }

/* ---- states: empty, error, loading */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px;
  padding: var(--sp-9) var(--sp-5); color: var(--ink-2);
}
.empty .glyph {
  width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; margin-bottom: var(--sp-2);
  background: var(--fill); color: var(--ink-3);
}
.empty .glyph .icon { width: 28px; height: 28px; stroke-width: 1.6; }
.empty .title { font-weight: 600; color: var(--ink-1); font-size: var(--fs-lg); letter-spacing: -0.01em; }
.empty .text { max-width: 440px; color: var(--ink-3); }
.empty .actions { margin-top: var(--sp-3); display: flex; gap: var(--sp-2); flex-wrap: wrap; justify-content: center; }
.empty.compact { padding: var(--sp-7) var(--sp-4); }
.empty.compact .glyph { width: 48px; height: 48px; }
.empty.compact .glyph .icon { width: 22px; height: 22px; }
.empty.bad .glyph { background: var(--bad-wash); color: var(--bad-ink); }
.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-lg);
  background: var(--accent-wash); color: var(--ink-1); font-size: var(--fs-sm); line-height: 1.55;
}
.notice .icon { color: var(--accent-ink); margin-top: 1px; width: 17px; height: 17px; }
.notice.warn { background: var(--warn-wash); }
.notice.warn .icon { color: var(--warn-ink); }
.notice.bad { background: var(--bad-wash); }
.notice.bad .icon { color: var(--bad-ink); }
.skeleton {
  display: block; border-radius: var(--r-xs); background: var(--fill); position: relative; overflow: hidden;
}
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, var(--hover), transparent); animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.skeleton-rows { display: flex; flex-direction: column; gap: 14px; padding: var(--sp-5); }
.skeleton-rows .skeleton { height: 14px; }
.skeleton-rows .skeleton[data-w="1"] { width: 86%; }
.skeleton-rows .skeleton[data-w="2"] { width: 72%; }
.skeleton-rows .skeleton[data-w="3"] { width: 92%; }
.loading-frame { opacity: 0.5; transition: opacity var(--t-med) var(--ease); pointer-events: none; }

/* ---- small parts */
/* Facts as an inset grouped list: a label and its value on each row. */
.kv {
  display: grid; grid-template-columns: max-content minmax(0, 1fr); font-size: var(--fs-md);
  background: var(--sunken); border-radius: var(--r-lg); padding: 0 var(--sp-4);
}
.kv dt, .kv dd { padding: 10px 0; border-bottom: 1px solid var(--line); min-height: 42px; }
.kv dt { color: var(--ink-3); padding-right: var(--sp-6); display: flex; align-items: center; }
.kv dd { margin: 0; min-width: 0; word-break: break-word; display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.kv dt:last-of-type, .kv dd:last-of-type { border-bottom: 0; }
.code {
  position: relative; background: var(--sunken); border-radius: var(--r-lg);
  padding: 14px var(--sp-4); padding-right: 52px; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-all; margin: 0; color: var(--ink-1);
}
.code .copy { position: absolute; top: 8px; right: 8px; }
.secret {
  display: flex; align-items: center; gap: var(--sp-2); padding: 12px 12px 12px var(--sp-4);
  border: 1.5px solid var(--accent); border-radius: var(--r-lg); background: var(--accent-wash);
}
.secret code { flex: 1; min-width: 0; word-break: break-all; font-size: 13.5px; -webkit-user-select: all; user-select: all; }
/* Tabs read as a segmented control. */
.tabs {
  display: flex; width: fit-content; max-width: 100%; gap: 2px; padding: 2px; border-radius: var(--r-md); background: var(--fill);
  margin-bottom: var(--sp-4); overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: 0; background: none; height: 28px; padding: 0 12px; color: var(--ink-2); font-weight: 500; font-size: var(--fs-sm); cursor: pointer;
  white-space: nowrap; border-radius: var(--r-sm); flex: none; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.tabs button:hover { color: var(--ink-1); }
.tabs button[aria-selected="true"] { color: var(--ink-1); background: var(--thumb); box-shadow: var(--shadow-thumb); }
.tabs button:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.tabs .count { color: var(--ink-3); font-weight: 400; margin-left: 5px; }
.tabs button[aria-selected="true"] .count { color: inherit; }
.meter { height: 8px; border-radius: var(--r-full); background: var(--fill); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); min-width: 2px; }
.meter.warn > i { background: var(--warn); }
.meter.bad > i { background: var(--bad); }
.phone-only { display: none; }
.btn .count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent-fill); color: var(--ink-on-accent);
  font-size: 11px; font-weight: 600; display: inline-grid; place-items: center;
}
.pager { display: flex; align-items: center; gap: var(--sp-2); padding: 12px var(--sp-5); border-top: 1px solid var(--line); color: var(--ink-3); font-size: var(--fs-sm); }
.pager .spacer { flex: 1; }
kbd {
  padding: 0 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: var(--r-xs);
  font-size: 11px; color: var(--ink-2); background: var(--surface);
}
time { white-space: nowrap; }

/* ---- narrow screens: the sidebar becomes a panel behind a top bar, wide
   tables become cards, dialogs become sheets from the bottom. On a laptop's
   screen the sidebar, the page's gutters and the cells give up a little
   room, so the widest lists (requests, members, usage) fit their cards
   instead of scrolling sideways. */
@media (max-width: 1366px) {
  :root { --sidebar-width: 240px; }
  .page { padding-left: var(--sp-7); padding-right: var(--sp-7); }
  .toolbar { padding: 0 var(--sp-7); }
  table.data th, table.data td { padding-left: 10px; padding-right: 10px; }
  table.data .cell-key { max-width: 140px; }
  table.data th:first-child, table.data td:first-child { padding-left: var(--sp-4); }
  table.data th:last-child, table.data td:last-child { padding-right: var(--sp-4); }
}
@media (max-width: 1100px) {
  .page { padding: var(--sp-6) var(--sp-6) var(--sp-8); }
  .toolbar { padding: 0 var(--sp-6); }
}
@media (max-width: 760px) {
  /* A page shorter than the screen stays under the top bar: the rows keep
     their own heights instead of sharing out the space left over. */
  .app { grid-template-columns: minmax(0, 1fr); align-content: start; }
  .toolbar { display: none; }
  .topbar {
    display: flex; align-items: center; gap: var(--sp-2); position: sticky; top: 0; z-index: 20; height: 54px;
    padding: 0 var(--sp-2) 0 var(--sp-2);
    background: var(--material-strong); -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
    border-bottom: 1px solid var(--line);
  }
  .topbar .brand { padding: 0; flex: 1; }
  .topbar .brand-sub { display: none; }
  .topbar .brand-mark { width: 30px; height: 30px; border-radius: 8px; }
  .sidebar {
    position: fixed; z-index: 50; left: 8px; top: 8px; bottom: 8px; margin: 0; height: auto; width: min(300px, 84vw);
    transform: translateX(calc(-100% - 16px)); transition: transform 380ms var(--spring); box-shadow: var(--shadow-3); visibility: hidden;
    background: var(--material-strong);
  }
  .app.nav-open .sidebar { transform: none; visibility: visible; }
  .scrim { position: fixed; inset: 0; z-index: 40; background: var(--overlay); animation: fade-in var(--t-med) var(--ease); }
  @keyframes fade-in { from { opacity: 0; } }
  .page { padding: var(--sp-5) var(--sp-4) var(--sp-8); }
  .page-head { margin-bottom: var(--sp-5); align-items: flex-start; }
  .page-head h1 { font-size: 28px; }
  .page-head .description { font-size: var(--fs-sm); }
  .card { border-radius: var(--r-lg); }
  .card-head, .card-body { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .grid-2, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .stack { gap: var(--sp-4); }
  .grid-2 { gap: var(--sp-4); }
  .filters { gap: var(--sp-2); }
  .filters .field, .filters .field.wide, .filters .field.date, .filters .field.narrow { width: calc(50% - 4px); }
  .filters .field.auto { width: 100%; }
  .filters .seg, .field > .seg, .stack > .seg { display: flex; align-self: stretch; }
  .filters .seg button, .field > .seg button, .stack > .seg button { flex: 1 1 auto; }
  .filters .field.full { width: 100%; }
  dialog.modal, dialog.modal.wide, dialog.modal.narrow, dialog.drawer, dialog.drawer.wide {
    width: 100vw; max-width: 100vw; height: calc(100% - 10px); max-height: calc(100% - 10px); margin: 10px 0 0; border-radius: var(--r-2xl) var(--r-2xl) 0 0;
    border-width: 1px 0 0;
  }
  dialog.modal[open], dialog.drawer[open] { animation: sheet-in 420ms var(--spring); }
  @keyframes sheet-in { from { transform: translateY(40px); opacity: 0.4; } }
  /* An alert is a sheet as tall as what it says, at the bottom: it names
     .modal.narrow as well, which would otherwise make it a full sheet. The
     height is fit-content, as a dialog's own is: a modal dialog is pinned to
     every edge of the screen, so an auto height would fill it all. */
  dialog.modal.confirm, dialog.modal.narrow.confirm { height: fit-content; max-height: calc(100% - 10px); margin: auto 0 0; }
  .dialog-head { padding: 16px 12px 10px var(--sp-4); }
  .dialog-body, .dialog-foot { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .toasts { left: 12px; right: 12px; bottom: 12px; width: auto; }
  /* A table marked to reflow shows each row as a card of label: value lines. */
  table.data.reflow thead { display: none; }
  table.data.reflow, table.data.reflow tbody, table.data.reflow tr, table.data.reflow td { display: block; width: 100%; }
  table.data.reflow tr { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line); }
  table.data.reflow tbody tr:last-child { border-bottom: 0; }
  table.data.reflow td { border: 0; padding: 3px 0 !important; text-align: left; display: flex; gap: var(--sp-3); justify-content: space-between; align-items: center; }
  table.data.reflow td.num { text-align: right; }
  table.data.reflow td::before { content: attr(data-label); color: var(--ink-3); font-size: var(--fs-sm); flex: none; font-weight: 400; }
  table.data.reflow tr { position: relative; }
  table.data.reflow td.lead { font-weight: 600; padding: 0 44px 4px 0 !important; white-space: normal; }
  table.data.reflow td.lead .sub { font-weight: 400; }
  table.data.reflow td.lead::before, table.data.reflow td.actions::before,
  table.data.reflow td.p-meta::before, table.data.reflow td.p-plain::before { content: none; }
  table.data.reflow td.actions { position: absolute; top: 8px; right: 8px; width: auto; padding: 0 !important; }
  table.data.reflow td.p-meta { display: inline-flex; width: auto; margin-right: 10px; color: var(--ink-2); font-size: var(--fs-sm); vertical-align: middle; }
  table.data.reflow td.p-plain { display: block; color: var(--ink-2); font-size: var(--fs-sm); }
  table.data.reflow td.p-figure { display: inline-flex; width: auto; margin-right: 14px; gap: 6px; font-size: var(--fs-sm); }
  table.data.reflow td.p-figure::before { font-size: var(--fs-xs); }
  table.data.reflow td.p-figure .sub { display: none; }
  table.data.reflow td.p-hide { display: none; }
  table.data.reflow .sub { display: inline; margin: 0 0 0 6px; }
  table.data.reflow .cell-main .sub { display: block; margin: 1px 0 0; }
  .filters:not(.open) { display: none; }
  .phone-only { display: inline-flex; }
  table.data.reflow td > * { min-width: 0; }
  table.data.reflow tfoot { display: block; }
  .kv { grid-template-columns: minmax(0, 1fr); padding: 0 var(--sp-3); }
  /* The whole key takes the width and the copy button goes under it:
     beside the button the key broke into short lines and an orphan. */
  .secret { flex-wrap: wrap; }
  .secret code { flex-basis: 100%; }
  .secret .btn { flex: 1 1 auto; }
  /* Tabs that do not fit wrap onto a second line and share each line, as
     segmented controls do here, rather than hiding the last ones in a
     strip that does not look scrollable. */
  .tabs { flex-wrap: wrap; overflow: visible; }
  .tabs button { flex: 1 1 auto; }
  .kv dt { padding: 10px 0 0; border-bottom: 0; min-height: 0; font-size: var(--fs-xs); }
  .kv dd { padding: 2px 0 10px; min-height: 0; }
  /* Fingers need larger targets than a pointer: 36px at least, 40px for the
     main controls. Fields take 16px type, below which Safari on a phone
     zooms the page into a field when it is focused. */
  .btn, input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="email"],
  input[type="search"], select { height: 40px; }
  input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="email"],
  input[type="search"], select, textarea { font-size: 16px; }
  .btn.icon-only { width: 40px; }
  .btn.sm { height: 36px; }
  .btn.sm.icon-only { width: 36px; }
  .seg button, .filters .seg button, .field > .seg button, .stack > .seg button, .tabs button { height: 36px; }
  .switch, .check, .fold > summary { min-height: 36px; }
  .nav-item { min-height: 42px; }
  .menu [role="menuitem"], .menu [role="menuitemradio"] { min-height: 40px; }
  table.data.reflow td a:not(.btn), .thread-meta a { display: inline-flex; align-items: center; justify-content: flex-end; min-height: 36px; min-width: 36px; }
  /* A short link that starts a line, a member's name leading a card, keeps
     its words at the start of its larger target, in line with the others. */
  table.data.reflow td.lead a:not(.btn), table.data.reflow td.p-meta a:not(.btn), table.data.reflow td.p-plain a:not(.btn) { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .skeleton::after { display: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .sidebar, .toolbar, .topbar, .menu, .toast { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--raised); }
}
@media (forced-colors: active) {
  .sym, .nav-icon, .chart svg, .spark { forced-color-adjust: none; }
  .nav-item[aria-current="page"] { outline: 2px solid CanvasText; }
}
