/* goappfw admin UI — theme tokens + responsive shell.
 *
 * THEMES (2-in-1, runtime-toggle via theme.js):
 *   - Arctic (default) — clean cold light, sky-blue accent, soft shadows.
 *   - Carbon           — brutalist pure B&W, monospace, sharp corners.
 * They are deliberately opposite poles (soft light vs stark brutalist) so an
 * operator gets two genuinely different moods, not a hue-shift. Adding a third
 * is a new [data-theme="…"] block + one entry in theme.js's map.
 *
 * The theme is applied as data-theme on <html> by theme.js (from localStorage,
 * defaulting to Arctic). Every color/spacing/radius/font lives behind a token,
 * so the whole UI reskins by swapping token blocks. NOTE: the token NAMES are a
 * contract — auth.js and confirm.js inject modal styles that reference them
 * (--sans --mono --bg --surface --surface-2 --border --radius --radius-sm
 * --text --text-dim --text-mute --accent --accent-strong --warn), so names
 * stay; new tokens get added alongside.
 *
 * RESPONSIVE: breakpoint at 880px (see @media at the bottom). >=880 = fixed
 * sidebar (desktop). <880 = off-canvas drawer behind a top bar + hamburger.
 * Tables scroll horizontally (never hide columns); touch targets >=44px.
 */

/* ============ THEME: ARCTIC (default — clean cold light) ============ */
:root,
[data-theme="arctic"] {
  color-scheme: light;

  --bg:          #eef3f8;
  --surface:     #ffffff;
  --surface-2:   #e2eaf2;
  --border:      #d3deea;
  --border-soft: #e8eef4;
  --border-strong: #c3d2e2;

  --text:        #1e2a3a;
  --text-dim:    #5a6b80;
  --text-mute:   #8a9aab;

  --accent:        #0ea5e9;
  --accent-strong: #0284c7;
  --accent-soft:   rgba(14, 165, 233, .10);

  /* status: base steps for text/marks; -soft for tinted chip backgrounds.
     Never color alone — always a label (and a dot where space allows). */
  --success:       #059669;
  --success-vivid: #10b981;
  --success-soft:  rgba(5, 150, 105, .12);
  --warn:          #d97706;
  --warn-vivid:    #f59e0b;
  --warn-soft:     rgba(217, 119, 6, .12);
  --danger:        #dc2626;
  --danger-vivid:  #ef4444;
  --danger-soft:   rgba(220, 38, 38, .10);

  --overlay: rgba(30, 42, 58, .45);

  --radius:    8px;
  --radius-sm: 5px;
  --gap:       1rem;
  --gap-sm:    .5rem;
  --shadow:    0 1px 3px rgba(30, 42, 58, .06);

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ============ THEME: CARBON (brutalist B&W) ============ */
[data-theme="carbon"] {
  color-scheme: light;

  --bg:          #ffffff;
  --surface:     #f4f4f4;
  --surface-2:   #e8e8e8;
  --border:      #000000;
  --border-soft: #bfbfbf;
  --border-strong: #000000;

  --text:        #000000;
  --text-dim:    #525252;
  --text-mute:   #737373;

  --accent:        #000000;
  --accent-strong: #000000;
  --accent-soft:   #e8e8e8;

  /* brutalist: every status collapses to ink — the label/dot carries meaning */
  --success:       #000000;
  --success-vivid: #000000;
  --success-soft:  #e8e8e8;
  --warn:          #525252;
  --warn-vivid:    #525252;
  --warn-soft:     #e8e8e8;
  --danger:        #000000;
  --danger-vivid:  #000000;
  --danger-soft:   #e8e8e8;

  --overlay: rgba(0, 0, 0, .5);

  --radius:    0px;
  --radius-sm: 0px;
  --gap:       1rem;
  --gap-sm:    .5rem;
  --shadow:    none;                       /* brutalist: borders carry the weight */

  --mono: ui-monospace, SFMono-Regular, "Courier New", monospace;
  --sans: ui-monospace, SFMono-Regular, "Courier New", monospace; /* mono throughout */
}
/* Carbon per-element overrides: heavy borders, uppercase labels, inverted
   accents — ported from the pre-redesign Carbon onto the current components.
   (.card h3.title keeps its case: it's an entity NAME, not a section label.) */
[data-theme="carbon"] .brand,
[data-theme="carbon"] .nav .nav-section,
[data-theme="carbon"] .tile .label,
[data-theme="carbon"] .content h1,
[data-theme="carbon"] .card h3,
[data-theme="carbon"] .tbl thead th,
[data-theme="carbon"] .badge { text-transform: uppercase; letter-spacing: .08em; }
[data-theme="carbon"] .card h3.title { text-transform: none; letter-spacing: 0; }
[data-theme="carbon"] .nav li a.active { color: #fff; background: #000; }
[data-theme="carbon"] .tbl .pill.pk { color: #fff; background: #000; }
[data-theme="carbon"] code { background: #000; color: #fff; }
[data-theme="carbon"] button, [data-theme="carbon"] .btn { border-width: 2px; }
[data-theme="carbon"] .btn.primary, [data-theme="carbon"] button.primary { background: #000; border-color: #000; color: #fff; }
[data-theme="carbon"] .brand .mark { border-radius: 0; }
/* the login/purge modals inject their own styles (auth.js/confirm.js) with a
   12px radius; this higher-specificity rule squares them under Carbon */
[data-theme="carbon"] .afw-card { border-radius: 0; }

/* ============ base ============ */
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: .9375rem;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-soft); }

/* ============ shell: sidebar + content ============ */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

/* top bar — hidden on desktop, shown < 880px (see media query) */
.topbar {
  display: none;
  align-items: center; gap: .5rem;
  height: 52px; padding: 0 .65rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.topbar .burger {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); width: 44px; height: 44px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
}
.topbar .burger:hover { color: var(--text); }
.topbar .burger:active { background: var(--accent-soft); }
.topbar .tb-title { font-weight: 600; font-size: .9rem; letter-spacing: -.01em; }
.topbar .spacer { flex: 1; }

/* sidebar */
.nav {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.15rem 0 1rem;
  overflow-y: auto;
  scrollbar-width: thin;
  display: flex; flex-direction: column;
}
.brand {
  display: flex; align-items: center; gap: .55rem;
  padding: 0 1.1rem 1.1rem;
  font-weight: 700; font-size: 1.02rem; letter-spacing: -.01em;
}
.brand .mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: #fff; flex-shrink: 0;
}
.brand .mark svg { width: 15px; height: 15px; }
.brand .ver {
  font-size: .62rem; color: var(--text-mute); font-weight: 600;
  font-family: var(--mono);
  background: var(--surface-2); padding: .12rem .42rem; border-radius: 999px;
  border: 1px solid var(--border);
  margin-left: auto;
}
.nav ul { list-style: none; margin: 0; padding: 0 0 .4rem; }
.nav li a {
  display: flex; align-items: center; gap: .6rem;
  min-height: 44px;                       /* touch target */
  margin: 1px .55rem; padding: 0 .65rem;
  color: var(--text-dim); text-decoration: none; font-size: .855rem;
  border-radius: var(--radius-sm);
  transition: background .15s ease, color .15s ease;
}
.nav li a svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .75; }
.nav li a:hover { background: var(--surface-2); color: var(--text); }
.nav li a:active { background: var(--accent-soft); color: var(--accent-strong); }
.nav li a.active {
  color: var(--accent-strong); background: var(--accent-soft); font-weight: 600;
}
.nav li a.active svg { opacity: 1; }
.nav .nav-section {
  padding: 1.05rem 1.25rem .3rem;
  font-size: .66rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-mute); font-weight: 600;
}
.nav .foot {
  padding: .85rem 1.1rem 0; margin-top: auto;
  border-top: 1px solid var(--border-soft);
  display: flex; flex-direction: column; gap: .6rem;
}

/* "Act as tenant" shell-level context — a full-width block above the theme
   toggle. Persisted across htmx swaps (the shell isn't swapped) and stamped as
   X-Tenant-ID on every request so the whole UI follows the operator's choice.
   Hidden (hidden attr) until tenant-context.js confirms a catalog is attached. */
.tenant-ctx-wrap { width: 100%; display: flex; flex-direction: column; gap: .3rem; }
.tenant-ctx-wrap[hidden] { display: none; }
.tenant-ctx-wrap .ctx-label {
  font-size: .64rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-mute); font-weight: 600;
}
.tenant-context {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm); padding: .4rem .5rem;
  font-family: var(--mono); font-size: .78rem;
  cursor: pointer; min-height: 38px;
}
.tenant-context:focus-visible { outline-offset: 0; }
/* Shown INSTEAD of the <select> when the operator's credential can't reach
   /api/admin/tenants (403/401 — e.g. an admin-role JWT under the superadmin-only
   tenant-lifecycle gate, D-18b). Explains why the control is unavailable rather
   than the control silently vanishing with no explanation. */
.tenant-ctx-msg {
  display: block; font-size: .74rem; color: var(--text-dim); line-height: 1.45;
  padding: .4rem .5rem; border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
}
.tenant-ctx-msg[hidden] { display: none; }

/* theme toggle button (in sidebar footer + top bar) */
.theme-toggle {
  background: var(--surface-2); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .32rem .6rem; font-size: .76rem; cursor: pointer; font-family: var(--sans);
  display: inline-flex; align-items: center; gap: .4rem; min-height: 38px;
  justify-content: center; width: 100%;
  transition: background .15s ease, color .15s ease;
}
.theme-toggle:hover { color: var(--text); }

/* auth chip — auth.js writes `<span class="badge live">…` / a warn badge into
   #auth-status; badge styles live in the badges section below. */
.auth-status { font-size: .8rem; color: var(--text-dim); }

/* content */
.content {
  padding: 2.1rem 2.5rem 3rem; max-width: 1120px;
  -webkit-overflow-scrolling: touch;
}
.content h1 {
  margin: 0 0 .3rem; font-size: 1.42rem; font-weight: 650; letter-spacing: -.015em;
}
.content .lede { color: var(--text-dim); margin: 0 0 1.9rem; font-size: .92rem; }
.content .head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* "Acting as tenant" subheader — a STICKY one-line strip above #main that echoes
   the sidebar choice. It lives in .content (NOT #main), so htmx fragment swaps
   never replace it; tenant-context.js fills #tenant-subheader-value + reveals it.
   Sticky to the top of the scroll container so it stays visible while the page
   scrolls. Hidden (hidden attr) until a tenant is picked. */
.tenant-subheader {
  position: sticky; top: 0; z-index: 20;
  margin: -.6rem 0 1.25rem; padding: .5rem .85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: inset 3px 0 0 var(--accent);
  display: flex; align-items: center; gap: .55rem; font-size: .82rem;
  white-space: nowrap; overflow: hidden;
}
.tenant-subheader[hidden] { display: none; }
.tenant-subheader .ts-label {
  text-transform: uppercase; letter-spacing: .07em; font-size: .66rem;
  font-weight: 600; color: var(--accent-strong); flex-shrink: 0;
}
.tenant-subheader .ts-value {
  color: var(--text); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; min-width: 0;
}

/* ============ cards ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 1rem; }
/* card section headings — one small-caps label across every page */
.card h3 {
  margin: 0 0 1rem; font-size: .7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; color: var(--text-mute);
}
.card h3 .sub {
  font-size: .78rem; font-weight: 400; text-transform: none; letter-spacing: 0;
  color: var(--text-dim);
}
/* entity TITLE header — when the card is named after a thing (a collection, a
   tool) rather than a section of the page, the header is its name in body
   weight, not a small-caps label */
.card h3.title {
  font-size: .95rem; font-weight: 600; text-transform: none;
  letter-spacing: -.01em; color: var(--text);
}
/* danger-framed card for irreversible actions (delete/purge zones) */
.card.danger-zone { border-color: var(--danger-soft); }
.card.danger-zone h3 { color: var(--danger); }

/* ============ stat tiles ============ */
.tile-grid {
  display: grid; gap: var(--gap); margin-bottom: 1.9rem;
  /* auto-fill seats a tile only when a full track (min + gap) fits, so the
     column count is pure grid math, not a media query. Two tracks need
     2*MIN + 16px; the mobile content area is viewport − 2rem. A 160px min
     meant 2 columns only on >=368px viewports — a 360px phone got a single
     column. 140px min ⇒ 2 columns from ~328px, so average mobiles regain a
     useful 2-col grid. */
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .95rem 1.05rem;
  box-shadow: var(--shadow);
}
.tile .label {
  font-size: .78rem; color: var(--text-mute); margin-bottom: .3rem;
}
.tile .value { font-size: 1.68rem; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; }
.tile .value.ok { color: var(--success); }
.tile .value .unit { font-size: .92rem; color: var(--text-dim); font-weight: 500; letter-spacing: 0; }

/* ============ forms ============ */
/* shared field styling. ONE visual system across every form (collections /
   evolve / tenants / files / records / logs). Bare <button>s render with
   default UA chrome (platform-specific) and look unlike the rest of the app;
   .btn/.link-btn normalize them. .field + .field > label give every control
   the same label-above-input shape. */
.field { display: flex; flex-direction: column; gap: .28rem; }
.field > label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-mute); font-weight: 600;
}
.field input, .field select,
.log-filters input, .log-filters select {
  background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm); padding: .42rem .55rem; font-size: .84rem;
  font-family: var(--mono); min-width: 0;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input::placeholder, .log-filters input::placeholder { color: var(--text-mute); }
.field input:focus, .field select:focus,
.log-filters input:focus, .log-filters select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field input[type="checkbox"], .field input[type="radio"] {
  accent-color: var(--accent); width: 1rem; height: 1rem; min-width: auto; padding: 0;
  box-shadow: none;
}
/* a checkbox riding in a .field row (e.g. show deleted) — label kebab-cases the
   flex so the box + text sit level instead of stacked */
.field.is-line { flex-direction: row; align-items: center; gap: .45rem; }
.field.is-line > label {
  text-transform: none; letter-spacing: 0; font-size: .82rem;
  color: var(--text); font-weight: 400;
}
/* field-rows — the schema builders (create/evolve collection): a stack of
   name+type+flags rows. #field-rows / #evolve-rows are the containers
   collections.js appends cloned .field-row children to, so the class and the
   two ids are load-bearing. */
#field-rows, #evolve-rows { display: flex; flex-direction: column; gap: .4rem; }
.field-row {
  display: flex; flex-wrap: wrap; gap: .4rem .5rem; align-items: center;
  padding: .45rem .5rem;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}
.field-row input:not([type="checkbox"]), .field-row select {
  background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--text); border-radius: var(--radius-sm);
  padding: .38rem .5rem; font-size: .82rem; font-family: var(--mono);
}
.field-row input[name="name"] { min-width: 10rem; flex: 1; }
.field-row label {
  font-size: .78rem; color: var(--text-dim); white-space: nowrap;
  display: inline-flex; gap: .32rem; align-items: center; cursor: pointer;
}

/* ============ buttons ============ */
/* .btn is the standard (secondary) action; .btn.primary the one accent action
   per view; .btn.danger the destructive outline. .link-btn is the ghosted
   inline one (row actions). Disabled/aria-disabled render muted. */
button, .btn {
  font-family: var(--sans);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: .42rem .85rem; font-size: .84rem;
  cursor: pointer; line-height: 1.25;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
button:hover, .btn:hover { background: var(--surface-2); }
button:active, .btn:active { background: var(--accent-soft); }
button:disabled, button[aria-disabled="true"], .btn[aria-disabled="true"] { opacity: .5; cursor: default; }
.btn.primary, button.primary {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
.btn.primary:hover, button.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger, button.danger {
  border-color: var(--danger); color: var(--danger); background: transparent;
}
.btn.danger:hover, button.danger:hover { background: var(--danger-soft); }
.link-btn {
  background: none; border: none; padding: 0;
  color: var(--accent); font-size: .84rem; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}
.link-btn.danger { color: var(--danger); }
.link-btn:hover { text-decoration: none; background: transparent; }
.link-btn:active { color: var(--accent-strong); background: transparent; }

/* small hint text under cards / in status lines */
.hint { font-size: .84rem; color: var(--text-dim); }
/* copy-to-clipboard chip beside an id (clipboard.js). Sized to sit inline in a
   table cell without stretching the row; the label flashes the outcome, so it
   is min-width'd to keep the column from jumping on "✓ copied". */
.copy-btn {
  font-family: var(--mono); font-size: .68rem; line-height: 1;
  padding: .22rem .45rem; min-height: 0; min-width: 5.2rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-mute);
  cursor: pointer; vertical-align: middle; white-space: nowrap;
}
.copy-btn:hover { color: var(--text); background: var(--surface-2); border-color: var(--border-strong); }
/* a page <h1> with an action chip next to it (tenant detail). The chip must
   stay OUTSIDE the h1 — nav.js reads #main h1's text for the tab title. */
.title-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .3rem; }
.title-row h1 { margin-bottom: 0; }
/* small quiet mono (timestamps, ids in dense tables) */
.muted { font-size: .78rem; color: var(--text-dim); }
/* a horizontal group of .field controls (create/edit forms) — the same shape
   .log-filters gives filter rows, named for form use */
.form-row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
/* a form separated from content above it by a hairline (the records browser's
   create + inline-edit forms) */
.subform { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: 1rem; }

/* ============ tables ============ */
/* wrapped in .tbl-wrap for horizontal scroll on narrow widths */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -.35rem; padding: 0 .35rem; }
.tbl { width: 100%; border-collapse: collapse; font-size: .86rem; min-width: 480px; }
.tbl th, .tbl td { padding: .58rem .75rem; text-align: left; white-space: nowrap; }
/* .tbl td.wrap — a cell that should WRAP on narrow widths instead of forcing the
   whole table wide. Body/text cells get this; terminal output stays nowrap. The
   log viewer's message column is the canonical case: a long message must not
   stretch the table past the viewport on mobile. */
.tbl td.wrap { white-space: normal; word-break: break-word; min-width: 12rem; }
.tbl thead th {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
  font-weight: 600; color: var(--text-mute);
  border-bottom: 1px solid var(--border-strong);
}
.tbl thead th a { color: inherit; text-decoration: none; }
.tbl thead th a:hover { color: var(--accent-strong); }
.tbl tbody tr { border-bottom: 1px solid var(--border-soft); }
.tbl tbody tr:last-child { border-bottom: none; }
.tbl tbody tr:hover { background: var(--surface-2); }
/* numeric/id cells align their digits without narrowing the headline columns */
.tbl .mono { font-family: var(--mono); font-size: .82em; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .85em; }
.tbl-total td { font-weight: 600; border-bottom: none; }

/* chips — soft-tinted, borderless; replaced the old outlined pills */
.tbl .pill {
  display: inline-block; font-size: .72rem; padding: .14rem .55rem;
  border-radius: 999px; white-space: nowrap;
  background: var(--surface-2); color: var(--text-dim);
}
.tbl .pill.pk { color: var(--accent-strong); background: var(--accent-soft); }
.tbl .pill.req { color: var(--warn); background: var(--warn-soft); }
.tbl .pill.bad { color: var(--danger); background: var(--danger-soft); }
.tbl .pill.mut { color: var(--text-mute); background: var(--surface-2); }

/* ============ badges ============ */
/* auth.js writes `<span class="badge live"><span class="dot"></span>…` into
   #auth-status; keep these class names. */
.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .74rem; font-weight: 500; padding: .18rem .6rem; border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim);
}
.badge.live { color: var(--success); background: var(--success-soft); }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* API explorer method chips (color per verb). Neutral by default; the m-* mods
   tint per method. */
.tbl .pill.m-get  { color: var(--success); background: var(--success-soft); }
.tbl .pill.m-post { color: var(--accent-strong); background: var(--accent-soft); }
.tbl .pill.m-patch{ color: var(--warn); background: var(--warn-soft); }
.tbl .pill.m-del  { color: var(--danger); background: var(--danger-soft); }

/* ============ notices / empty states ============ */
/* inline status line: icon + label + color, never color alone */
.notice {
  display: flex; gap: .55rem; align-items: flex-start;
  font-size: .86rem; border-radius: var(--radius-sm);
  padding: .65rem .8rem; margin: 0 0 1rem;
}
.notice svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: .12rem; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.danger { background: var(--danger-soft); color: var(--danger); }
.notice.ok { background: var(--success-soft); color: var(--success); }
.notice span { color: var(--text-dim); }
.notice b, .notice strong { color: inherit; }

.empty {
  text-align: center; color: var(--text-mute); font-size: .88rem;
  padding: 2.1rem 1rem;
}
.empty svg { width: 22px; height: 22px; display: block; margin: 0 auto .5rem; opacity: .7; }

/* ============ pager ============ */
/* for the records browser page navigation. hx-get links swap #main only, so
   paging never reloads the shell (mobile drawer state preserved). */
.pager {
  display: flex; align-items: center; gap: .5rem;
  margin-top: 1.25rem; flex-wrap: wrap;
}
.pager .pg-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 38px; padding: .35rem .9rem; font-size: .84rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); text-decoration: none;
  cursor: pointer; transition: background .15s ease; font-family: var(--sans);
}
.pager a.pg-btn:hover  { background: var(--surface-2); }
.pager a.pg-btn:active { background: var(--accent-soft); }
.pager .pg-btn.dim { color: var(--text-mute); border-color: var(--border); cursor: default; }
.pager .pg-info { font-size: .8rem; color: var(--text-dim); padding: 0 .35rem; }

/* ============ breadcrumbs ============ */
/* the top-of-page escape from deep pages (the records browser). The old "←"
   escape sat at the page FOOTNOTE; on mobile that meant scrolling past the
   whole table to leave. A crumbs row at the top fixes it. */
.crumbs { font-size: .82rem; color: var(--text-mute); margin: 0 0 .7rem; }
.crumbs a { color: var(--text-dim); text-decoration: none; }
.crumbs a:hover { color: var(--accent-strong); text-decoration: underline; }
.crumbs .crumb-sep { color: var(--border-strong); padding: 0 .3rem; }

/* a ghosted "clear" reset action next to a filter form's submit button */
.clear-btn {
  background: none; border: none; padding: 0;
  color: var(--text-mute); font-size: .8rem; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}
.clear-btn:hover { color: var(--text-dim); }

/* ============ logs viewer ============ */
/* filter form + level-tinted rows. The form swaps #main via hx-get so
   filtering never reloads the shell (mobile drawer preserved). */
.log-filters {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end;
}
.log-filters + * { margin-top: 1rem; }
.log-filters label {
  display: flex; flex-direction: column; gap: .28rem;
  font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-mute); font-weight: 600;
}
.log-filters input, .log-filters select { min-width: 130px; }

.log-tbl .log-ts { color: var(--text-mute); font-size: .78rem; white-space: nowrap; }
.log-tbl .log-level { font-family: var(--mono); font-size: .72rem; }
.log-tbl .log-level.lvl-debug { color: var(--text-mute); background: var(--surface-2); }
.log-tbl .log-level.lvl-info  { color: var(--accent-strong); background: var(--accent-soft); }
.log-tbl .log-level.lvl-warn  { color: var(--warn); background: var(--warn-soft); }
.log-tbl .log-level.lvl-error { color: var(--danger); background: var(--danger-soft); }
.log-tbl tr.log-error { background: var(--danger-soft); }
.log-tbl tr.log-warn  { background: var(--warn-soft); }

/* ============ loading states ============ */
/* htmx: loading indicator on the swapping element */
.htmx-request { opacity: .55; }
.htmx-indicator { display: none; }
.htmx-show.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline-block; }
/* skeleton pulse for the shell's first-load placeholder (shell.html) */
.skel {
  height: 1rem; border-radius: var(--radius-sm);
  background: var(--surface-2); margin: .35rem 0;
  animation: afw-pulse 1.4s ease-in-out infinite;
}
@keyframes afw-pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .skel { animation: none; }
  * { transition-duration: .01ms !important; }
}

/* ============ keyboard focus ============ */
/* every interactive element gets a visible ring. :focus-visible only fires for
   keyboard + programmatic focus, so mouse clicks stay clean. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ============ misc ============ */
code {
  font-family: var(--mono); font-size: .85em;
  background: var(--surface-2); padding: .1rem .35rem; border-radius: 5px;
  color: var(--text-dim);
}
pre {
  font-family: var(--mono); font-size: .8rem; line-height: 1.6;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .85rem .95rem; overflow: auto;
  margin: .6rem 0 0;
}
a { color: var(--accent); }
a:hover { color: var(--accent-strong); }

/* scrim behind the open drawer (mobile) */
.scrim { display: none; }

/* ============ RESPONSIVE: < 880px → off-canvas drawer ============ */
@media (max-width: 880px) {
  .shell { display: block; position: relative; }
  .topbar { display: flex; }
  .nav {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 25;
    width: 250px;
    transform: translateX(-100%);
    transition: transform .2s cubic-bezier(.2, .8, .2, 1);
    box-shadow: 0 0 40px rgba(0, 0, 0, .25);
  }
  .nav.open { transform: translateX(0); }
  .scrim.show {
    display: block; position: fixed; inset: 0; z-index: 24;
    background: var(--overlay);
  }
  .content { padding: 1.25rem 1rem 2rem; }
  .content h1 { font-size: 1.22rem; }
  /* The mobile topbar (52px, sticky top:0 z-index 30) sits above the subheader;
     push the sticky subheader down so it isn't hidden behind the topbar. */
  .tenant-subheader { top: 52px; }
}

/* ============ RESPONSIVE: narrow tables → card reflow ============
   A master LIST (collections) becomes a set of cards on <560px: every column
   reads vertically instead of hiding past the horizontal scroll fold. This
   reflow is applied ONLY to a table holding a `data-label` on every body <td>
   (see collections.html) — NOT to data grids (records/files/logs) where each
   row is a dense record and the horizontal scroll is the right call. The grid
   cells function as <tr>/<td> for AT (display override is visual only), so no
   markup semantics change. A 560px breakpoint still keeps the shell's 880px
   drawer logic and the 480px table territory to itself. */
@media (max-width: 559px) {
  .table-stackable {
    display: block; min-width: 0; width: 100%;
  }
  .table-stackable thead { display: none; } /* cards carry their own labels */
  .table-stackable tbody { display: block; }
  .table-stackable tbody tr {
    display: block; padding: .8rem .95rem; margin-bottom: .6rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
  .table-stackable tbody tr:hover { background: var(--surface); }
  .table-stackable td {
    display: block; white-space: normal; width: 100%;
    padding: .12rem 0; font-size: .87rem;
  }
  .table-stackable td .mono, .table-stackable td .pill { font-size: .85em; }
  .table-stackable td[data-label]::before {
    content: attr(data-label);
    display: block; font-size: .66rem; color: var(--text-mute);
    text-transform: uppercase; letter-spacing: .06em; margin-bottom: .12rem;
  }
  .table-stackable td:first-child[data-label]::before { display: none; } /* the name is the card title */
  .table-stackable td:first-child { font-weight: 600; padding-bottom: .4rem; }
}
