/* =====================================================================
   moopa.css — the design every Moopa page shares: the System pages and a project's own pages.
   Vanilla CSS, no build step. Three layers:
     1. Tokens      — custom properties; a project themes by overriding them in its theme.css
                      (docs/design.md), never by overriding rules
     2. Primitives  — page header, card, button, badge, field, table, modal, tabs, dropdown, toast,
                      and components: combobox, dropzone, file list, drawer, metrics, stepper…
     3. Shell       — sidebar, collapse, mobile drawer, profile menu
   "Quiet Ledger Studio": graphite ink on warm paper, one vivid accent. Route markup uses these
   classes and tokens only: no colour literals.
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. TOKENS
   --------------------------------------------------------------------- */
:root {
  /* brand ink — the primary actions' colour is --signal below; --primary is quiet graphite */
  --primary:            oklch(27% 0.014 250);
  --primary-soft:       oklch(94.5% 0.004 250);
  --primary-deep:       oklch(20% 0.014 250);
  --primary-press:      oklch(14% 0.012 250);
  --primary-subdued:    oklch(82% 0.010 250);

  /* signal — the one vivid colour, for state only: on, selected, current, focus, links, primary actions */
  --signal:             oklch(52% 0.150 258);
  --signal-deep:        oklch(45% 0.150 258);
  --signal-press:       oklch(39% 0.140 258);
  --signal-hover:       var(--signal-deep);   /* a primary button under the pointer; a light accent sets a deeper tone of itself */
  --signal-soft:        oklch(96.5% 0.018 258);
  --signal-subdued:     oklch(84% 0.060 258);
  --on-signal:          oklch(99% 0.001 80);

  /* ink */
  --ink:                oklch(19.5% 0.020 41);
  --ink-secondary:      oklch(33% 0.022 41);
  --ink-mute:           oklch(50% 0.018 41);
  --ink-mute-2:         oklch(58% 0.016 41);

  /* paper */
  --canvas:             oklch(97.6% 0.002 80);
  --canvas-soft:        oklch(96.2% 0.003 80);
  --canvas-cream:       oklch(96.8% 0.004 80);
  --surface:            oklch(99% 0.001 80);
  --hairline:           oklch(88% 0.004 80);
  --hairline-strong:    oklch(80% 0.006 80);

  /* semantic */
  --info:               oklch(57% 0.105 238);
  --info-surface:       oklch(98% 0.012 238);
  --info-border:        oklch(75% 0.070 238);
  --info-text:          oklch(42% 0.090 238);
  --success:            oklch(56% 0.130 151);
  --success-surface:    oklch(98.4% 0.010 151);
  --success-border:     oklch(78% 0.080 151);
  --success-text:       oklch(37% 0.105 151);
  --warning:            oklch(70% 0.145 73);
  --warning-surface:    oklch(98% 0.018 73);
  --warning-border:     oklch(78% 0.100 73);
  --warning-text:       oklch(42% 0.100 73);
  --danger:             oklch(56% 0.215 18);
  --danger-surface:     oklch(97.5% 0.018 25);
  --danger-border:      oklch(70% 0.135 18);
  --danger-text:        oklch(42% 0.170 18);
  --danger-deep:        oklch(48% 0.205 18);

  /* code blocks (stack traces, SQL) */
  --code-bg:            oklch(22% 0.014 250);
  --code-ink:           oklch(93% 0.006 80);

  /* geometry */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 14px;
  --radius-pill: 9999px;

  /* depth — focus colours follow --signal, so re-branding it re-brands focus too */
  --shadow-1: 0 1px 2px oklch(19.5% 0.020 41 / 0.045);
  --shadow-2: 0 18px 48px oklch(19.5% 0.020 41 / 0.12), 0 4px 14px oklch(19.5% 0.020 41 / 0.08);
  --focus-ring: color-mix(in oklab, var(--signal) 50%, transparent);
  --focus-ring-strong: color-mix(in oklab, var(--signal) 65%, transparent);
  --focus-halo: 0 0 0 4px color-mix(in oklab, var(--signal) 20%, transparent);

  /* type — system fonts: nothing to download, nothing loaded from another origin. A theme that names a
     font (e.g. Inter) can switch on its OpenType features with --font-features. */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --font-features: "tnum";
  --heading-tracking: -0.02em;
  --text-xs: 0.6875rem;
  --text-sm: 0.8125rem;
  --text-base: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.5rem;
  --text-2xl: 2rem;

  /* controls & density — the Hub shell sets data-density="compact" on <html> */
  --control-h: 2.5rem;
  --control-h-sm: 2rem;
  --control-h-xs: 1.625rem;
  --control-pad-x: 0.75rem;
  --control-font: var(--text-base);
  --control-radius: var(--radius-md);
  --btn-radius: var(--radius-pill);
  --btn-pad-x: 1rem;
  --label-font: var(--text-sm);
  --field-gap: 0.375rem;
  --field-rhythm: var(--sp-4);
  --card-pad: var(--sp-4);
  --card-pad-y: var(--sp-3);
  --card-gap: var(--sp-5);
  --cell-pad-y: 0.625rem;  --cell-pad-x: 0.75rem;
  --cell-sm-pad-y: 0.375rem; --cell-sm-pad-x: 0.625rem;
  --tab-pad-y: 0.5rem;

  /* spacing */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;

  /* z-index scale — every z-index in this file uses one of these */
  --z-raised: 1;
  --z-catch: 29;
  --z-popover: 30;
  --z-bar: 35;
  --z-backdrop: 40;
  --z-sidebar: 50;
  --z-drawer: 60;
  --z-tooltip: 1000;
  --z-toast: 2000;
  --z-debug: 9999;

  /* shell panel — the sidebar is a darker panel than the page, for contrast. Its own tokens, so a
     project can re-colour the panel without touching the page. */
  --shell-bg:            #293042;   /* Titan's sidebar panel, so a project's shell and Moopa's match */
  --shell-bg-raised:     #333b50;
  --shell-line:          #3a4257;
  --shell-edge:          #1f2534;
  --shell-ink:           #f4f5f8;
  --shell-ink-secondary: #d5d9e2;
  --shell-ink-mute:      #9aa3b5;
  --shell-ink-mute-2:    #7f889b;
  --shell-signal:        oklch(74% 0.120 258);   /* the accent, lifted to read on the dark panel */
  --shell-danger:        oklch(75% 0.140 22);

  /* shell */
  --sb-w: 264px;
  --shell-logo-h: 3.25rem;          /* the brand logo's height in the sidebar (application.moopa_theme.logo) */
  --shell-logo-h-mobile: 2rem;      /* and in the mobile bar */
  --sb-w-collapsed: 72px;
  --t: 200ms;
  --ease: cubic-bezier(.22,1,.36,1);
  --shell-backdrop: oklch(19.5% 0.020 41 / 0.42);
  --shell-scrollbar: oklch(19.5% 0.020 41 / 0.18);
  --shell-scrollbar-hover: oklch(19.5% 0.020 41 / 0.28);
  --shell-danger-bg: oklch(58% 0.220 25 / 0.08);

  /* charts — series colours for Chart.js and the like, read with getComputedStyle */
  --chart-ink:      #363c47;
  --chart-grid:     #e8e7e3;
  --chart-tick:     #6b675f;
  --chart-series-1: #2a78d6;
  --chart-series-2: #1baf7a;
  --chart-series-3: #4a3aa7;
  --chart-series-4: #eda100;
  --chart-series-5: #e87ba4;
  --chart-series-6: #008300;
  --chart-series-7: #e34948;
}

[data-density="compact"] {
  --control-h: 2rem;
  --control-h-sm: 1.75rem;
  --control-h-xs: 1.5rem;
  --control-pad-x: 0.625rem;
  --control-font: var(--text-sm);
  --control-radius: var(--radius-sm);
  --btn-radius: var(--radius-sm);
  --btn-pad-x: 0.75rem;
  --label-font: 0.75rem;
  --field-gap: 0.25rem;
  --field-rhythm: var(--sp-3);
  --card-pad: var(--sp-3);
  --card-pad-y: var(--sp-2);
  --card-gap: var(--sp-4);
  --cell-pad-y: 0.375rem;  --cell-pad-x: 0.625rem;
  --cell-sm-pad-y: 0.25rem; --cell-sm-pad-x: 0.5rem;
  --tab-pad-y: 0.375rem;
}
[data-density="compact"] .label { color: var(--ink-secondary); }
[data-density="compact"] .card-title { font-size: var(--text-base); }

/* ---------------------------------------------------------------------
   Base
   --------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { text-rendering: geometricPrecision; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  font-feature-settings: var(--font-features);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}
h1, h2, h3, h4 { margin: 0; color: var(--ink); font-weight: 500; letter-spacing: var(--heading-tracking); line-height: 1.2; }
h1 { font-size: var(--text-xl); line-height: 1.1; }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-md); }
p { margin: 0; }
a { color: var(--signal-deep); text-decoration: none; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
input, select, textarea, button { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
code, pre, kbd, samp { font-family: var(--font-mono); }
[hidden] { display: none !important; }
[x-cloak] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* ---------------------------------------------------------------------
   Text helpers (deliberately few)
   --------------------------------------------------------------------- */
.muted        { color: var(--ink-mute); }
.secondary    { color: var(--ink-secondary); }
.small        { font-size: var(--text-sm); }
.tiny         { font-size: var(--text-xs); }
.strong       { font-weight: 500; }
.mono         { font-family: var(--font-mono); font-size: 0.95em; }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.nowrap       { white-space: nowrap; }
.break        { overflow-wrap: anywhere; }
.eyebrow      { color: var(--ink-mute); font-size: var(--text-xs); font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; }
.text-danger  { color: var(--danger-text); }
.text-success { color: var(--success-text); }
.text-warning { color: var(--warning-text); }
.text-signal  { color: var(--signal-deep); }

/* ---------------------------------------------------------------------
   Layout primitives
   --------------------------------------------------------------------- */
.stack   { display: flex; flex-direction: column; gap: var(--stack-gap, var(--sp-4)); }
.stack-xs { --stack-gap: var(--sp-1); }
.stack-sm { --stack-gap: var(--sp-2); }
.stack-lg { --stack-gap: var(--sp-6); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster-gap, var(--sp-2)); }
.cluster-between { justify-content: space-between; }
.cluster-end { justify-content: flex-end; }
.row     { display: flex; align-items: center; gap: var(--sp-2); }
.row-top { align-items: flex-start; }
.grow    { flex: 1 1 auto; min-width: 0; }
.shrink0 { flex-shrink: 0; }
.min0    { min-width: 0; }
.ml-auto { margin-left: auto; }
.w-full  { width: 100%; }
.contents { display: contents; }
.mt-2 { margin-top: var(--sp-2); }

/* page */
.page { display: flex; flex-direction: column; gap: var(--card-gap); min-width: 0; }
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--sp-3) var(--sp-4); }
.page-header h1 { margin-top: var(--sp-1); }
.page-lede { margin-top: var(--sp-1); color: var(--ink-mute); max-width: 60rem; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }

/* filter sidebar + data column */
.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-5); align-items: start; }
@media (min-width: 1100px) {
  .split { grid-template-columns: var(--split-aside, 18rem) minmax(0, 1fr); }
  .split > aside { position: sticky; top: 0; }
  .split-end { grid-template-columns: minmax(0, 1fr) var(--split-aside, 20rem); }   /* main column first, aside on the right */
}

/* responsive auto grid: --auto-min is the column floor */
.auto-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(min(var(--auto-min, 12rem), 100%), 1fr)); }

/* ---------------------------------------------------------------------
   Card
   --------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  min-width: 0;
}
.card-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2) var(--sp-4);
  padding: var(--card-pad-y) var(--card-pad);
  border-bottom: 1px solid var(--hairline);
}
.card-header-fixed { flex-wrap: nowrap; }
.card-header-fixed > :first-child { flex: 1 1 auto; min-width: 0; }
.card-header-fixed > :last-child { flex: 0 0 auto; }
.card-title { font-size: var(--text-md); font-weight: 500; letter-spacing: -0.02em; }
.card-sub { font-size: var(--text-sm); color: var(--ink-mute); }
.card-body { padding: var(--card-pad); color: var(--ink-secondary); }
.card-body:not(.kv-grid, .auto-grid, .cluster, .stack, .row) > * + * { margin-top: var(--card-pad); }
.card-footer { padding: var(--card-pad-y) var(--card-pad); border-top: 1px solid var(--hairline); }

/* stat tile */
.stat { padding: var(--card-pad); }
.stat-label { color: var(--ink-mute); font-size: var(--text-xs); font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; }
.stat-value { margin-top: var(--sp-1); color: var(--ink); font-size: var(--text-xl); font-weight: 500; letter-spacing: -0.02em; line-height: 1.1; }
.stat-sub { margin-top: var(--sp-1); color: var(--ink-mute); font-size: var(--text-xs); }

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: var(--control-h); padding: 0 var(--btn-pad-x);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--btn-radius);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--control-font); font-weight: 500; line-height: 1;
  white-space: nowrap; text-decoration: none; cursor: pointer; user-select: none;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}
.btn:hover { background: var(--canvas-soft); text-decoration: none; }
.btn:active { background: var(--canvas); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-halo); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
/* every variant sets its own :hover and :active, or .btn's grey ones win */
.btn-primary { background: var(--signal); border-color: var(--signal); color: var(--on-signal); box-shadow: 0 1px 2px color-mix(in oklab, var(--signal) 25%, transparent); }
.btn-primary:hover { background: var(--signal-hover); border-color: var(--signal-hover); }
.btn-primary:active { background: var(--signal-press); border-color: var(--signal-press); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-secondary); }
.btn-ghost:hover { background: var(--canvas-soft); color: var(--ink); }
.btn-ghost:active { background: var(--canvas); color: var(--ink); }
.btn-danger { color: var(--danger-text); border-color: var(--danger-border); }
.btn-danger:hover { background: var(--danger-surface); border-color: var(--danger); }
.btn-danger:active { background: var(--danger-surface); border-color: var(--danger); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: var(--on-signal); }
.btn-danger-solid:hover { background: var(--danger-deep); border-color: var(--danger-deep); }
.btn-danger-solid:active { background: var(--danger-text); border-color: var(--danger-text); }
.btn-sm { min-height: var(--control-h-sm); padding: 0 calc(var(--btn-pad-x) * 0.875); font-size: var(--text-sm); }
.btn-xs { min-height: var(--control-h-xs); padding: 0 calc(var(--btn-pad-x) * 0.625); font-size: var(--text-xs); }
.btn-icon { width: var(--control-h); min-height: var(--control-h); padding: 0; }
.btn-icon.btn-sm { width: var(--control-h-sm); min-height: var(--control-h-sm); }
.btn-icon.btn-xs { width: var(--control-h-xs); min-height: var(--control-h-xs); }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; }
.btn-group > .btn { border-radius: 0; margin-left: -1px; }
/* -of-type, not -child: an Alpine <template x-for> stays in the DOM as the group's first child */
.btn-group > .btn:first-of-type { border-radius: var(--btn-radius) 0 0 var(--btn-radius); margin-left: 0; }
.btn-group > .btn:last-of-type { border-radius: 0 var(--btn-radius) var(--btn-radius) 0; }
.btn.is-active, .btn-group > .btn[aria-pressed="true"] { background: var(--signal-soft); border-color: var(--signal); color: var(--signal-deep); position: relative; z-index: var(--z-raised); }

/* chip toggles */
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.chip {
  display: inline-flex; align-items: center; gap: 0.375rem; cursor: pointer;
  min-height: var(--control-h-xs); padding: 0.3rem 0.7rem; border: 1px solid var(--hairline); border-radius: var(--radius-pill);
  background: var(--surface); color: var(--ink-secondary); font-size: var(--text-sm); line-height: 1;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
.chip:hover { border-color: var(--hairline-strong); color: var(--ink); }
.chip:disabled { opacity: 0.35; cursor: default; }
.chip.is-active, .chip[aria-pressed="true"] { background: var(--signal-soft); border-color: var(--signal-subdued); color: var(--signal-deep); }

/* ---------------------------------------------------------------------
   Badges, dots, avatars
   --------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.125rem 0.5rem; border: 1px solid var(--hairline); border-radius: var(--radius-pill);
  background: var(--canvas-soft); color: var(--ink-secondary);
  font-size: var(--text-xs); font-weight: 500; line-height: 1.5; white-space: nowrap;
}
.badge-success { background: var(--success-surface); border-color: var(--success-border); color: var(--success-text); }
.badge-warning { background: var(--warning-surface); border-color: var(--warning-border); color: var(--warning-text); }
.badge-danger  { background: var(--danger-surface);  border-color: var(--danger-border);  color: var(--danger-text); }
.badge-info    { background: var(--info-surface);    border-color: var(--info-border);    color: var(--info-text); }
.badge-signal  { background: var(--signal-soft);     border-color: var(--signal-subdued); color: var(--signal-deep); }
.badge-solid   { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.badge-outline { background: transparent; }
.badge-upper   { text-transform: uppercase; letter-spacing: 0.06em; }

.dot { display: inline-block; flex: 0 0 auto; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--ink-mute-2); }
.dot-success { background: var(--success); } .dot-warning { background: var(--warning); } .dot-danger { background: var(--danger); } .dot-info { background: var(--info); } .dot-signal { background: var(--signal); }

.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; overflow: hidden;
  width: 1.875rem; height: 1.875rem; border-radius: 50%;
  background: var(--canvas-soft); border: 2px solid var(--hairline);
  color: var(--ink); font-size: var(--text-xs); font-weight: 500; letter-spacing: 0.02em;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 1.5rem; height: 1.5rem; font-size: 0.625rem; }
.avatar-lg { width: 3rem; height: 3rem; font-size: var(--text-sm); }
.avatar-ink { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.avatar-stack { display: inline-flex; align-items: center; }
.avatar-stack .avatar + .avatar { margin-left: -0.375rem; box-shadow: 0 0 0 2px var(--surface); }

/* ---------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--field-gap); min-width: 0; }
:not(.auto-grid, .cluster, .row, .stack) > .field + .field { margin-top: var(--field-rhythm); }
.label { color: var(--ink); font-size: var(--label-font); font-weight: 500; }
.help { color: var(--ink-mute); font-size: var(--text-xs); line-height: 1.5; }
.field-error { color: var(--danger-text); font-size: var(--text-xs); line-height: 1.5; }
.input, .select, .textarea {
  display: block; width: 100%; min-height: var(--control-h);
  padding: 0 var(--control-pad-x);
  border: 1px solid var(--hairline-strong); border-radius: var(--control-radius);
  background: var(--surface); color: var(--ink);
  font-size: var(--control-font);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.textarea { padding: 0.5rem var(--control-pad-x); min-height: 5rem; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--ink-mute-2); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--signal); box-shadow: var(--focus-halo); }
.input:disabled, .select:disabled, .textarea:disabled, .input[readonly] { background: var(--canvas-soft); color: var(--ink-mute); }
.input-sm, .select-sm { min-height: var(--control-h-sm); font-size: var(--text-sm); }
.is-invalid, .is-invalid:focus { border-color: var(--danger); }
.select {
  appearance: none; padding-right: 2rem;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23777' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right var(--control-pad-x) center;
}
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); color: var(--ink-mute); pointer-events: none; font-size: 0.85em; }
.input-icon > .input { padding-left: 2.125rem; }
.input-group { display: flex; align-items: stretch; }
.input-group > * { border-radius: 0; margin-left: -1px; min-height: var(--control-h); }
.input-group > :first-child { margin-left: 0; border-top-left-radius: var(--control-radius); border-bottom-left-radius: var(--control-radius); }
.input-group > :last-child { border-top-right-radius: var(--control-radius); border-bottom-right-radius: var(--control-radius); }
.input-group > .input, .input-group > .select { flex: 1 1 auto; width: auto; min-width: 0; }
.input-group > .btn { flex: 0 0 auto; }
.input-group > :focus, .input-group > :focus-within { position: relative; z-index: var(--z-raised); }
.input-addon { display: inline-flex; align-items: center; flex: 0 0 auto; padding: 0 0.75rem; border: 1px solid var(--hairline-strong); background: var(--canvas-cream); color: var(--ink-mute); font-size: var(--text-sm); white-space: nowrap; }

/* bordered group of options (checkboxes, switches) */
.option-box { display: flex; flex-direction: column; gap: 0.125rem; padding: 0.5rem 0.625rem; border: 1px solid var(--hairline); border-radius: var(--radius-md); background: var(--canvas-cream); }
.option { display: flex; align-items: center; gap: 0.625rem; padding: 0.25rem 0; color: var(--ink-secondary); font-size: var(--text-sm); cursor: pointer; }
.option:hover { color: var(--ink); }
.option:has(:checked) { color: var(--ink); }

.switch {
  appearance: none; flex: 0 0 auto; width: 1.75rem; height: 1rem; margin: 0;
  border-radius: var(--radius-pill); background: var(--hairline-strong);
  position: relative; cursor: pointer; transition: background-color 150ms ease;
}
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px oklch(0% 0 0 / 0.2); transition: transform 150ms var(--ease); }
.switch:checked { background: var(--signal); }
.switch:checked::after { transform: translateX(12px); }
.switch:disabled { opacity: 0.45; cursor: default; }
.switch:focus-visible { outline: none; box-shadow: var(--focus-halo); }
.switch-success:checked { background: var(--success); }

.checkbox, .radio { appearance: none; flex: 0 0 auto; width: 1rem; height: 1rem; margin: 0; border: 1px solid var(--hairline-strong); background: var(--surface); display: inline-grid; place-content: center; cursor: pointer; }
.checkbox { border-radius: var(--radius-xs); }
.radio { border-radius: 50%; }
.checkbox::after, .radio::after { content: ""; width: 0.55rem; height: 0.55rem; background: var(--signal); transform: scale(0); transition: transform 120ms var(--ease); }
.checkbox::after { border-radius: 2px; }
.radio::after { border-radius: 50%; }
.checkbox:checked, .radio:checked { border-color: var(--signal); }
.checkbox:checked::after, .radio:checked::after { transform: scale(1); }
.checkbox:disabled, .radio:disabled { opacity: 0.45; cursor: default; }
.checkbox:focus-visible, .radio:focus-visible { outline: none; box-shadow: var(--focus-halo); }

/* ---------------------------------------------------------------------
   Table
   --------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table-wrap:has(.dropdown[open]) { overflow: visible; }
/* Scroll-edge fade for wide tables: the side you can still scroll towards fades out, driven by the wrap's own
   horizontal scroll (no JS). Not scrollable: both fades stay 0 and nothing is masked. Dropped while a row
   menu is open so the mask cannot clip it. */
@property --table-fade-l { syntax: "<length>"; inherits: false; initial-value: 0px; }
@property --table-fade-r { syntax: "<length>"; inherits: false; initial-value: 0px; }
@supports (animation-timeline: scroll()) {
  .table-wrap {
    -webkit-mask-image: linear-gradient(to right, transparent 0, black var(--table-fade-l), black calc(100% - var(--table-fade-r)), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, black var(--table-fade-l), black calc(100% - var(--table-fade-r)), transparent 100%);
    animation: table-wrap-fade linear both;
    animation-timeline: scroll(self x);
  }
  .table-wrap:has(.dropdown[open]) { -webkit-mask-image: none; mask-image: none; animation: none; }
  @keyframes table-wrap-fade {
    from { --table-fade-l: 0px; --table-fade-r: 3rem; }
    to   { --table-fade-l: 3rem; --table-fade-r: 0px; }
  }
}
.table { width: 100%; border-collapse: collapse; color: var(--ink); }
.table th, .table td { padding: var(--cell-pad-y) var(--cell-pad-x); text-align: left; vertical-align: middle; border-bottom: 1px solid var(--hairline); }
.table th { color: var(--ink-mute); font-size: var(--text-xs); font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; background: var(--canvas-cream); }
.table tbody tr:last-child td { border-bottom: 0; }
.table-hover tbody tr { transition: background-color 120ms ease; }
.table-hover tbody tr:hover { background: var(--canvas-soft); }
.table-clickable tbody tr { cursor: pointer; }
.table-fixed { table-layout: fixed; }
.table-fixed td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-sm th, .table-sm td { padding: var(--cell-sm-pad-y) var(--cell-sm-pad-x); }
.table-top td { vertical-align: top; }
.table td.actions, .table th.actions { text-align: right; white-space: nowrap; }
.table .text-right { text-align: right; }
.table .text-center, .table td.empty { text-align: center; }
.table tr.is-selected { background: var(--signal-soft); }
.cell-main { color: var(--ink); font-weight: 500; line-height: 1.25; }
.cell-sub  { color: var(--ink-mute); font-size: var(--text-sm); line-height: 1.25; margin-top: 0.125rem; }
.table tr:hover .row-action, .row-action:focus-visible { opacity: 1; }
.row-action { opacity: 0; transition: opacity 120ms ease; }
@media (hover: none) { .row-action { opacity: 1; } }
.card > .table-wrap:first-child .table th:first-child { border-top-left-radius: var(--radius-lg); }
.card > .table-wrap:first-child .table th:last-child { border-top-right-radius: var(--radius-lg); }
.card > .table-wrap .table th:first-child, .card > .table-wrap .table td:first-child { padding-left: var(--card-pad); }
.card > .table-wrap .table th:last-child, .card > .table-wrap .table td:last-child { padding-right: var(--card-pad); }

/* empty and loading states */
.empty { padding: var(--sp-8) var(--sp-4); text-align: center; color: var(--ink-mute); }
.empty > i { display: block; margin: 0 auto var(--sp-2); font-size: 1.5rem; color: var(--ink-mute-2); }

/* a page of its own (tags/moopa_bare.cfm): the status pages (404, 403, 500) and sign-in */
.status-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-6); padding: var(--sp-8) var(--sp-4); text-align: center; }
.status-page-body { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); max-width: 28rem; }
.status-brand { display: inline-flex; align-items: center; margin-bottom: var(--sp-3); padding: 0.625rem 1rem; border-radius: var(--radius-lg); background: var(--shell-bg); color: var(--shell-ink); font-weight: 600; text-decoration: none; }
.status-brand img { display: block; height: var(--shell-logo-h); width: auto; }
.status-code { color: var(--signal-deep); font-size: var(--text-sm); font-weight: 600; letter-spacing: 0.12em; font-variant-numeric: tabular-nums; }
.status-page h1 { font-size: var(--text-2xl); }
.status-message { color: var(--ink-mute); }
.status-actions { justify-content: center; margin-top: var(--sp-3); }
.status-detail { width: 100%; max-width: 64rem; text-align: left; }
/* moopa_bare's split layout (welcome=): a brand panel in the project's shell colours beside the page.
   The sign-in pages (lib/signin.cfc) use it. On a phone the panel is a header, the step's head sits on
   the same colour and its body is a sheet below. */
.auth { --auth-brand: linear-gradient(160deg, var(--shell-bg), color-mix(in oklab, var(--shell-bg) 62%, black));
  min-height: 100vh; display: grid; grid-template-columns: minmax(20rem, 0.8fr) 1fr; background: var(--surface); }
.auth-brand { position: relative; overflow: hidden; isolation: isolate; display: flex; flex-direction: column; gap: var(--sp-8);
  padding: var(--sp-8) clamp(var(--sp-6), 4vw, 3.5rem); background: var(--auth-brand); color: var(--shell-ink); }
.auth-brand::before, .auth-brand::after { content: ""; position: absolute; z-index: -1; border-radius: 50%;
  border: 1px solid color-mix(in oklab, var(--signal) 22%, transparent); pointer-events: none; }
.auth-brand::before { width: 36rem; height: 36rem; right: -20rem; top: -11rem; }
.auth-brand::after { width: 24rem; height: 24rem; right: -14rem; top: -5rem; }
.auth-logo { align-self: flex-start; color: var(--shell-ink); font-weight: 600; font-size: var(--text-lg); text-decoration: none; }
.auth-logo img { display: block; height: calc(var(--shell-logo-h) * 1.15); width: auto; }
.auth-welcome { margin-top: auto; max-width: 24rem; }
.auth-welcome h2 { color: var(--shell-ink); font-size: clamp(2.25rem, 3.2vw, 2.75rem); font-weight: 600; line-height: 1.05; }
.auth-welcome p { margin-top: var(--sp-4); color: var(--shell-ink-mute); line-height: 1.55; text-wrap: pretty; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: var(--sp-8) var(--sp-6); }
.auth-panel { width: 100%; max-width: 25rem; display: flex; flex-direction: column; gap: var(--sp-6); }
.auth-head { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-2); }
.auth-head h1 { font-size: var(--text-2xl); text-wrap: balance; }
.auth-step { color: var(--signal-deep); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }
.auth-lead { color: var(--ink-mute); line-height: 1.55; text-wrap: pretty; }
.auth-lead strong { color: var(--ink); font-weight: 500; overflow-wrap: anywhere; }
.auth-icon { display: grid; place-items: center; width: 3.75rem; height: 3.75rem; margin-bottom: var(--sp-3); border-radius: var(--radius-xl);
  background: var(--signal); color: var(--on-signal); font-size: 1.625rem; transform: rotate(-6deg); }
.auth-icon.is-danger { background: var(--danger-surface); color: var(--danger-text); transform: none; }
.auth-body { display: flex; flex-direction: column; gap: var(--sp-4); }
.auth-wait { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-4); border: 1px solid var(--hairline); border-radius: var(--radius-lg); color: var(--ink); font-size: var(--text-sm); }
.auth-wait small { display: block; margin-top: 0.125rem; color: var(--ink-mute); font-size: var(--text-xs); }
.auth-spinner { flex: none; width: 1.375rem; height: 1.375rem; border-radius: 50%; border: 2.5px solid var(--signal-soft); border-top-color: var(--signal); animation: auth-spin 1s linear infinite; }
@keyframes auth-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .auth-spinner { animation-duration: 3s; } }
.auth-facts { margin: 0; padding: var(--sp-4); border: 1px solid var(--hairline); border-radius: var(--radius-lg); background: var(--canvas); }
.auth-facts dd { margin: 0; }
.auth-actions { display: flex; flex-direction: column; gap: var(--sp-2); }
.auth-note { color: var(--ink-mute); font-size: var(--text-sm); }
.auth-links { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-5); font-size: var(--text-sm); }
.auth-links form { display: contents; }
.auth-links .btn-link { padding: 0; border: 0; background: none; color: var(--ink-mute); font: inherit; cursor: pointer; }
.auth-links .btn-link:hover { color: var(--ink); text-decoration: underline; }
.signin-ref { font-family: var(--font-mono); letter-spacing: 0.08em; }
@media (max-width: 48rem) {
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; background: var(--auth-brand); }
  .auth-brand { padding: var(--sp-6) var(--sp-5) 0; background: none; }
  .auth-welcome { display: none; }
  .auth-main { align-items: stretch; padding: 0; }
  .auth-panel { max-width: none; gap: 0; }
  .auth-head { padding: var(--sp-6) var(--sp-5) var(--sp-8); }
  .auth-head h1 { color: var(--shell-ink); }
  .auth-step { color: var(--signal); }
  .auth-lead { color: var(--shell-ink-mute); }
  .auth-lead strong { color: var(--shell-ink); }
  .auth-body { flex: 1; padding: var(--sp-6) var(--sp-5) var(--sp-8); border-radius: 1.5rem 1.5rem 0 0; background: var(--surface); }
  .auth-panel > .auth-head:last-child { flex: 1; }
}

/* hairline-divided rows inside a card */
.list-rows { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: 0.625rem var(--card-pad); border-bottom: 1px solid var(--hairline); color: var(--ink); text-decoration: none; }
.list-row:last-child { border-bottom: 0; }
a.list-row:hover, button.list-row:hover { background: var(--canvas-soft); text-decoration: none; }
button.list-row { width: 100%; text-align: left; }

/* a row of columns: list rows that line up like a table (tree views) */
.grid-row { display: grid; grid-template-columns: var(--cols, minmax(0, 1fr) auto); align-items: center; gap: var(--sp-3); padding: var(--cell-pad-y) var(--card-pad); border-bottom: 1px solid var(--hairline); }
.grid-row:last-child { border-bottom: 0; }
.grid-row-head { color: var(--ink-mute); font-size: var(--text-xs); font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; background: var(--canvas-cream); }
.grid-rows-hover > .grid-row:not(.grid-row-head):hover { background: var(--canvas-soft); }
@media (max-width: 1023.98px) { .grid-row > .wide-only { display: none; } .grid-row { grid-template-columns: var(--cols-narrow, minmax(0, 1fr) auto); } }
.tree-icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 1.5rem; height: 1.5rem; border: 1px solid var(--hairline); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink-mute); font-size: 0.75rem; }
.tree-icon.is-folder { color: var(--signal); }

/* label/value pairs */
.kv-grid { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--sp-2) var(--sp-4); align-items: baseline; }
.kv-label { color: var(--ink-mute); font-size: var(--text-xs); font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; }
.kv-value { color: var(--ink); min-width: 0; overflow-wrap: anywhere; }

/* code block (stack traces, SQL, JSON) */
.code-block { margin: 0; padding: var(--sp-4); border-radius: var(--radius-md); background: var(--code-bg); color: var(--code-ink); font-family: var(--font-mono); font-size: var(--text-xs); line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; overflow: auto; max-height: 60vh; }
.code-inline { padding: 0.0625rem 0.3rem; border-radius: var(--radius-xs); background: var(--canvas-soft); border: 1px solid var(--hairline); font-family: var(--font-mono); font-size: 0.9em; }
.kbd { display: inline-block; padding: 0.05rem 0.4rem; border: 1px solid var(--hairline-strong); border-bottom-width: 2px; border-radius: var(--radius-xs); background: var(--canvas-soft); font-family: var(--font-mono); font-size: var(--text-xs); color: var(--ink-secondary); }

/* ---------------------------------------------------------------------
   Modal — native <dialog>: el.showModal() / el.close()
   --------------------------------------------------------------------- */
.modal {
  padding: 0; border: 1px solid var(--hairline); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2);
  width: min(40rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem);
  display: none; flex-direction: column;
}
.modal[open] { display: flex; }
.modal::backdrop { background: var(--shell-backdrop); backdrop-filter: blur(2px); }
.modal-sm { width: min(26rem, calc(100vw - 2rem)); }
.modal-lg { width: min(52rem, calc(100vw - 2rem)); }
.modal-xl { width: min(72rem, calc(100vw - 2rem)); height: min(52rem, calc(100vh - 2rem)); }
.modal-header { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2) var(--sp-4); padding: var(--card-pad-y) var(--card-pad); border-bottom: 1px solid var(--hairline); }
.modal-header > :first-child { flex: 1 1 auto; min-width: 0; }
.modal-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: var(--card-pad); }
.modal-footer { flex: 0 0 auto; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-2); padding: var(--card-pad-y) var(--card-pad); border-top: 1px solid var(--hairline); }
.modal-section + .modal-section { margin-top: var(--sp-4); padding-top: var(--sp-4); border-top: 1px solid var(--hairline); }

/* ---------------------------------------------------------------------
   Alert
   --------------------------------------------------------------------- */
.alert { display: flex; align-items: flex-start; gap: var(--sp-3); padding: 0.75rem 1rem; border: 1px solid var(--hairline); border-radius: var(--radius-lg); background: var(--surface); color: var(--ink-secondary); font-size: var(--text-sm); line-height: 1.45; }
.alert > i { margin-top: 0.2em; }
.alert-info    { border-color: var(--info-border);    background: var(--info-surface);    color: var(--info-text); }
.alert-success { border-color: var(--success-border); background: var(--success-surface); color: var(--success-text); }
.alert-warning { border-color: var(--warning-border); background: var(--warning-surface); color: var(--warning-text); }
.alert-danger  { border-color: var(--danger-border);  background: var(--danger-surface);  color: var(--danger-text); }

/* ---------------------------------------------------------------------
   Dropdown (native <details>)
   --------------------------------------------------------------------- */
.dropdown { position: relative; display: inline-block; }
.dropdown > summary { list-style: none; cursor: pointer; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown > summary::marker { content: ""; }
.dropdown-menu {
  position: absolute; top: calc(100% + 0.25rem); left: 0; z-index: var(--z-popover); min-width: 11rem;
  margin: 0; padding: 0.375rem 0; list-style: none;
  border: 1px solid var(--hairline); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow-2);
}
.dropdown-menu-end { left: auto; right: 0; }
.dropdown-item { display: flex; align-items: center; gap: 0.625rem; width: 100%; padding: 0.5rem 0.75rem; color: var(--ink-secondary); font-size: var(--text-sm); text-align: left; white-space: nowrap; text-decoration: none; cursor: pointer; }
.dropdown-item:hover { background: var(--canvas-soft); color: var(--ink); text-decoration: none; }
.dropdown-item i { width: 1rem; text-align: center; color: var(--ink-mute); }
.dropdown-item-danger { color: var(--danger-text); }
.dropdown-item-danger i { color: inherit; }
.dropdown-item-danger:hover { background: var(--shell-danger-bg); color: var(--danger-text); }
.dropdown-divider { margin: 0.375rem 0; border: 0; border-top: 1px solid var(--hairline); }
.dropdown[open] > summary::before { content: ""; position: fixed; inset: 0; z-index: var(--z-catch); cursor: default; }

/* ---------------------------------------------------------------------
   Tabs
   --------------------------------------------------------------------- */
.tabs { display: flex; flex-wrap: wrap; gap: var(--sp-1); border-bottom: 1px solid var(--hairline); }
.tab { cursor: pointer; padding: var(--tab-pad-y) 0.75rem; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--ink-mute); font-size: var(--text-sm); font-weight: 500; text-decoration: none; }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.is-active, .tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--signal); }
.tab-count { display: inline-flex; align-items: center; justify-content: center; min-width: 1.25rem; height: 1.125rem; margin-left: 0.375rem; padding: 0 0.375rem; border: 1px solid var(--hairline); border-radius: var(--radius-pill); background: var(--canvas-soft); color: var(--ink-mute); font-size: 0.6875rem; font-weight: 500; line-height: 1; vertical-align: middle; }
.tab.is-active .tab-count { color: var(--ink); }
/* .is-attention throbs while something in the pane needs the user (unread, alert, open follow-up) */
.tab-count.is-attention { background: var(--signal); border-color: var(--signal); color: var(--on-signal); animation: tab-throb 1.6s ease-in-out infinite; }
@keyframes tab-throb {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 color-mix(in oklab, var(--signal) 45%, transparent); }
  50% { transform: scale(1.08); box-shadow: 0 0 0 6px color-mix(in oklab, var(--signal) 0%, transparent); }
}
@media (prefers-reduced-motion: reduce) { .tab-count.is-attention { animation: none; } }

/* ---------------------------------------------------------------------
   Toasts (window.toast in moopa.js)
   --------------------------------------------------------------------- */
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--sp-2); width: min(24rem, calc(100vw - 2rem)); pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: var(--sp-3); padding: 0.75rem 0.875rem; border: 1px solid var(--hairline); border-radius: var(--radius-lg); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2); font-size: var(--text-sm); line-height: 1.4; pointer-events: auto; animation: toast-in 180ms var(--ease); }
.toast > i { margin-top: 0.15em; color: var(--ink-mute); }
.toast-title { font-weight: 500; }
.toast-text { color: var(--ink-secondary); overflow-wrap: anywhere; }
.toast-close { margin-left: auto; color: var(--ink-mute); }
.toast-close:hover { color: var(--ink); }
.toast-success > i { color: var(--success); }
.toast-error { border-color: var(--danger-border); }
.toast-error > i { color: var(--danger); }
.toast-warning > i { color: var(--warning); }
.toast-info > i { color: var(--info); }
.toast.is-leaving { opacity: 0; transform: translateY(4px); transition: opacity 160ms ease, transform 160ms ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------------
   Components — combobox, sortable list, dropzone and file list, drawer, sections, metrics, steppers,
   row lists and cards, and small helpers. Behaviour lives in the project's scripts (Alpine); these are
   the looks every Moopa project shares.
   --------------------------------------------------------------------- */
.kv + .kv { margin-top: var(--sp-3); }
.kv > .kv-value { margin-top: 0.125rem; font-size: var(--text-base); }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.eyebrow-signal { color: var(--signal-deep); }
.mt-1 { margin-top: var(--sp-1); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.split-wide { --split-aside: 20rem; }
@media (min-width: 1100px) {
  .split-wide { grid-template-columns: var(--split-aside) minmax(0, 1fr); }
}
.card-flat { box-shadow: none; }
.btn-ink { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.btn-ink:hover { background: var(--ink-secondary); border-color: var(--ink-secondary); }
.btn-ink:active { background: var(--ink); border-color: var(--ink); }
.chip-wide { padding-left: 0.7rem; padding-right: 0.7rem; }
.avatar-ok { border-color: var(--success); }
.avatar-bad { border-color: var(--danger); }
.swatch { display: inline-block; width: 1rem; height: 1rem; border-radius: var(--radius-xs); border: 1px solid var(--hairline-strong); flex: 0 0 auto; }
.field-w-xs { max-width: 6rem; }
.field-w-sm { max-width: 10rem; }
.field-w-md { max-width: 16rem; }
.field-w-lg { max-width: 24rem; }
.input-addon, .input-prefix { display: inline-flex; align-items: center; flex: 0 0 auto; padding: 0 0.75rem; border: 1px solid var(--hairline-strong); background: var(--canvas-cream); color: var(--ink-mute); font-size: var(--text-sm); white-space: nowrap; }
.input-addon > .swatch { width: 1.125rem; height: 1.125rem; }
.range-presets { display: grid; grid-template-columns: auto 1fr auto; gap: 0.375rem; }
.range-presets + .range-presets { margin-top: 0.375rem; }
.table td:has(> .money), .table td:has(> .badge + .money) { text-align: right; }
.table-airy tbody td { padding-top: 1rem; padding-bottom: 1rem; vertical-align: top; }
.chart-wrap { position: relative; height: var(--chart-h, 14rem); }
.chart-wrap-tall { --chart-h: max(24rem, calc(100vh - 14rem)); }
.modal-full { width: calc(100vw - 2rem); height: calc(100vh - 2rem); }
.modal-body:has(.combo-list:not([style*="display: none"])) > .stack { padding-bottom: 15rem; }
.callout { border-left: 3px solid var(--success); border-radius: var(--radius-xs); background: var(--success-surface); color: var(--success-text); font-size: var(--text-sm); line-height: 1.35; padding: 0.45rem 0.6rem; }
.dropdown-menu-panel { width: min(30rem, calc(100vw - 2rem)); padding: 0.5rem; }
@media (max-width: 600px) {
  .dropdown-menu-panel { position: fixed; top: auto; left: 1rem; right: 1rem; width: auto; max-height: calc(100vh - 2rem); overflow-y: auto; }
}
.dropdown-menu-panel > * + * { margin-top: 0.5rem; }
.dropdown-scroll { max-height: 56vh; overflow-y: auto; }
.input-group > .input-narrow { flex: 0 0 auto; width: 6.5rem; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); border: 1px solid var(--hairline); border-radius: var(--radius-md); overflow: hidden; background: var(--surface); }
.metric { padding: 0.75rem; min-height: 4.5rem; border-right: 1px solid var(--hairline); }
.metric:last-child { border-right: 0; }
.metric-label { color: var(--ink-mute); font-size: var(--text-xs); font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; }
.metric-value { margin-top: 0.35rem; color: var(--ink); font-size: var(--text-md); font-weight: 500; }
.drawer-backdrop { position: fixed; inset: 0; z-index: var(--z-drawer); background: var(--shell-backdrop); backdrop-filter: blur(2px); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: calc(var(--z-drawer) + 1); display: flex; flex-direction: column; width: min(1120px, calc(100vw - 280px)); min-width: min(760px, 100vw); background: var(--surface); border-left: 1px solid var(--hairline); box-shadow: var(--shadow-2); }
.drawer-header { flex: 0 0 auto; padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--hairline); }
.drawer-body { flex: 1 1 auto; overflow-y: auto; padding: var(--sp-4) var(--sp-5) var(--sp-5); }
.drawer-body > * + * { margin-top: var(--sp-4); }
.section { border: 1px solid var(--hairline); border-radius: var(--radius-md); background: var(--surface); }
.section-header { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--hairline); }
.section-body { padding: 0.75rem; }
.editable { display: inline-flex; align-items: center; min-height: 1.45rem; border-bottom: 1px dotted var(--ink-mute-2); color: var(--ink-secondary); cursor: pointer; line-height: 1.2; padding: 0 0.1rem 0.05rem; }
.editable:hover { border-bottom-color: var(--signal); background: var(--signal-soft); color: var(--ink); }
.editable-title { font-size: var(--text-md); font-weight: 500; color: var(--ink); }
.row-list > .row-item { display: grid; grid-template-columns: minmax(260px, 1.05fr) minmax(240px, 1.3fr) minmax(200px, 0.9fr) auto; gap: var(--sp-4); align-items: center; padding: 0.9rem var(--sp-4); border-bottom: 1px solid var(--hairline); cursor: pointer; transition: background-color 120ms ease; }
.row-list > .row-item:last-child { border-bottom: 0; }
.row-list > .row-item:hover { background: var(--canvas-soft); }
@media (max-width: 1100px) {
  .row-list > .row-item { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .row-list > .row-item { grid-template-columns: 1fr; }
}
.note-list > .note-item { padding: 0.75rem; border-bottom: 1px solid var(--hairline); }
.note-list > .note-item:last-child { border-bottom: 0; }
.row-card { display: grid; grid-template-columns: minmax(260px, 1.05fr) minmax(240px, 1.3fr) minmax(200px, 0.9fr) auto; gap: var(--sp-4); align-items: center; padding: 0.85rem 1rem; border: 1px solid var(--hairline); border-radius: var(--radius-md); background: var(--surface); cursor: pointer; transition: border-color 120ms ease, box-shadow 120ms ease; }
.row-card:hover { border-color: var(--hairline-strong); box-shadow: var(--shadow-1); }
.row-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.55rem; color: var(--ink-mute); font-size: var(--text-sm); }
.row-card-list { display: grid; gap: 0.65rem; }
@media (max-width: 1100px) {
  .row-card { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .row-card { grid-template-columns: 1fr; }
}
.modal-body-frame { padding: 0; display: flex; }
.input-narrow { max-width: 10rem; }
.textarea-auto { overflow-y: auto; resize: none; min-height: 3em; max-height: 25em; }
.combo { position: relative; }
.combo-shell { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; min-height: var(--control-h); padding: 0.125rem 2.25rem 0.125rem calc(var(--control-pad-x) - 0.25rem); border: 1px solid var(--hairline-strong); border-radius: var(--control-radius); background: var(--surface); cursor: text; transition: border-color 150ms ease, box-shadow 150ms ease; }
.combo-shell.is-sm { min-height: var(--control-h-sm); }
.combo-shell:focus-within { border-color: var(--signal); box-shadow: var(--focus-halo); }
.combo-shell > input { flex: 1 1 6rem; min-width: 4rem; border: 0; outline: 0; background: transparent; padding: 0.125rem 0.25rem; font-size: var(--control-font); color: var(--ink); }
.combo-shell > input::placeholder { color: var(--ink-mute-2); }
.combo-tools { position: absolute; right: 0.375rem; top: 50%; transform: translateY(-50%); display: flex; align-items: center; gap: 0.125rem; }
.combo-tools button { width: 1.5rem; height: 1.5rem; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-xs); color: var(--ink-mute); cursor: pointer; }
.combo-tools button:hover { background: var(--canvas-soft); color: var(--ink); }
.combo-chip { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.1rem 0.25rem 0.1rem 0.5rem; border-radius: var(--radius-pill); background: var(--ink); color: var(--surface); font-size: var(--text-xs); line-height: 1.5; white-space: nowrap; }
.combo-chip button { width: 1rem; height: 1rem; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: inherit; opacity: .7; cursor: pointer; }
.combo-chip button:hover { opacity: 1; background: color-mix(in oklab, var(--surface) 18%, transparent); }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 0.25rem); z-index: var(--z-popover); max-height: 15rem; overflow-y: auto; margin: 0; padding: 0.375rem 0; list-style: none; border: 1px solid var(--hairline); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-2); }
.combo-option { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.45rem 0.75rem; color: var(--ink-secondary); font-size: var(--text-sm); cursor: pointer; }
.combo-option:hover, .combo-option.is-active { background: var(--canvas-soft); color: var(--ink); }
.combo-option.is-selected { color: var(--ink); font-weight: 500; }
.combo-option.is-selected::after { content: "\2713"; color: var(--signal); }
.combo-option.is-disabled { opacity: .45; pointer-events: none; }
.combo-empty { padding: 0.5rem 0.75rem; color: var(--ink-mute); font-size: var(--text-sm); }
.combo-group { padding: 0.35rem 0.75rem 0.15rem; color: var(--ink-mute); font-size: var(--text-xs); letter-spacing: 0.06em; text-transform: uppercase; }
.combo-sub { display: block; color: var(--ink-mute); font-size: var(--text-xs); }
.sort-list { margin: 0; padding: 0; list-style: none; border: 1px solid var(--hairline); border-radius: var(--radius-md); background: var(--surface); }
.sort-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.625rem; border-bottom: 1px solid var(--hairline); font-size: var(--text-sm); }
.sort-item:last-child { border-bottom: 0; }
.sort-item .grip { color: var(--ink-mute-2); cursor: grab; }
.sort-item.is-dragging { opacity: .5; }
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.25rem; min-height: 5.5rem; padding: var(--sp-3) var(--sp-4); border: 1px dashed var(--hairline-strong); border-radius: var(--radius-md); background: var(--canvas-cream); color: var(--ink-secondary); font-size: var(--text-sm); text-align: center; cursor: pointer; transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease; }
.dropzone:hover { border-color: var(--ink-mute-2); background: var(--surface); }
.dropzone:focus-within { border-color: var(--signal); box-shadow: var(--focus-halo); }
.dropzone.is-over { border-style: solid; border-color: var(--signal); background: var(--signal-soft); color: var(--ink); }
.dropzone.is-busy { cursor: progress; }
.dropzone > input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
.dropzone > i { width: auto; margin-bottom: 0.25rem; font-size: 1.5rem; color: var(--ink-mute); transition: color 150ms ease, transform 150ms ease; }
.dropzone.is-over > i { color: var(--signal); transform: translateY(-2px); }
.dropzone strong { color: var(--ink); font-weight: 500; }
.dropzone .help { color: var(--ink-mute); }
.file-list { margin: 0; padding: 0; list-style: none; }
.file-item { display: grid; grid-template-columns: auto minmax(0,1fr) auto auto; align-items: center; gap: 0.75rem; padding: 0.5rem 0; border-bottom: 1px solid var(--hairline); font-size: var(--text-sm); }
.file-item:last-child { border-bottom: 0; }
.file-icon { display: inline-flex; align-items: center; justify-content: center; width: var(--control-h); height: var(--control-h); border: 1px solid var(--hairline); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink-mute); font-size: 1.125rem; }
.file-icon > i { width: auto; }
.file-body { display: flex; flex-direction: column; gap: 0.125rem; min-width: 0; }
.file-name { display: block; max-width: 100%; color: var(--ink); font-weight: 500; text-align: left; line-height: 1.35; }
.file-name:hover { color: var(--signal-deep); text-decoration: underline; }
.file-name:focus-visible { outline: none; border-radius: var(--radius-xs); box-shadow: var(--focus-halo); }
.file-name:disabled { cursor: default; color: var(--ink-secondary); text-decoration: none; }
.file-meta { color: var(--ink-mute); font-size: var(--text-xs); line-height: 1.35; }
.file-status { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--ink-mute); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.file-actions { display: inline-flex; align-items: center; gap: 0.125rem; }
.file-item:not(.is-removed) .file-actions > .btn-ghost:hover { color: var(--danger-text); background: var(--danger-surface); }
.file-item.is-removed .file-icon, .file-item.is-removed .file-meta { opacity: .55; }
.file-item.is-removed .file-name { color: var(--ink-mute); text-decoration: line-through; }
.file-item.is-error .file-icon { border-color: var(--danger-border); background: var(--danger-surface); color: var(--danger-text); }
.progress { width: 6rem; height: 0.375rem; border-radius: var(--radius-pill); background: var(--canvas-soft); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--signal); transition: width 120ms linear; }
.terms { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem; }
.terms .input { width: 3.5rem; text-align: center; padding: 0; }
.btn-touch { min-height: 3.25rem; padding: 0 1.5rem; font-size: var(--text-md); border-radius: var(--radius-lg); }
.btn-touch:active { transform: scale(0.99); }
.signature { display: flex; align-items: center; justify-content: center; min-height: 6rem; border: 1px dashed var(--hairline-strong); border-radius: var(--radius-md); background: var(--surface); cursor: crosshair; touch-action: none; }
.signature.is-signed { border-style: solid; }
.stepper { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: 0; padding: 0; list-style: none; }
.stepper > li { flex: 1 1 9rem; display: flex; align-items: center; gap: 0.5rem; min-height: 2.75rem; padding: 0 0.75rem; border: 1px solid var(--hairline); border-radius: var(--radius-md); background: var(--surface); color: var(--ink-mute); font-size: var(--text-sm); font-weight: 500; cursor: default; min-width: 0; }
.stepper > li.is-done { cursor: pointer; color: var(--ink-secondary); }
.stepper > li.is-current { border-color: var(--signal); background: var(--signal-soft); color: var(--signal-deep); }
.stepper-dot { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; border: 1px solid currentColor; font-size: var(--text-xs); }
.stepper > li.is-done .stepper-dot { background: var(--success); border-color: var(--success); color: var(--on-signal); }
.stepper-value { margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-weight: 400; }
.chips-alpha > .chip { min-width: 2rem; justify-content: center; padding-left: 0; padding-right: 0; }
.chips-alpha > .chip-wide { padding-left: 0.7rem; padding-right: 0.7rem; }
/* phones: the stepper's steps share one row, compact, values hidden; the alphabet chips scroll sideways */
@media (max-width: 600px) {
  .stepper { flex-wrap: nowrap; gap: var(--sp-1); }
  .stepper > li { flex: 1 1 0; min-height: 2.25rem; padding: 0 0.5rem; gap: 0.375rem; font-size: var(--text-xs); }
  .stepper-dot { width: 1.25rem; height: 1.25rem; }
  .stepper-value { display: none; }
  .chips-alpha { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .chips-alpha::-webkit-scrollbar { display: none; }
  .chips-alpha > .chip { flex: 0 0 auto; min-width: 2.25rem; min-height: 2.25rem; }
}
.prose > * { margin: 0.25rem 0 0; }
.prose ul, .prose ol { padding-left: 1.25rem; }

/* =====================================================================
   3. SHELL
   ===================================================================== */
/* The sidebar and the mobile bar are the dark panel: the page tokens are re-pointed at the shell's
   inside them, so every primitive used there (rows, menus, the profile dropdown) follows. */
.moo-shell-sidebar, .moo-shell-mobile-bar {
  --surface: var(--shell-bg);
  --canvas: var(--shell-bg);
  --canvas-soft: var(--shell-bg-raised);
  --canvas-cream: var(--shell-bg-raised);
  --hairline: var(--shell-line);
  --hairline-strong: var(--shell-line);
  --ink: var(--shell-ink);
  --ink-secondary: var(--shell-ink-secondary);
  --ink-mute: var(--shell-ink-mute);
  --ink-mute-2: var(--shell-ink-mute-2);
  --signal: var(--shell-signal);
  --danger-text: var(--shell-danger);
  --shell-danger-bg: color-mix(in oklab, var(--shell-danger) 14%, transparent);
  --shadow-2: 0 18px 48px oklch(0% 0 0 / 0.45), 0 4px 14px oklch(0% 0 0 / 0.30);
  --shell-scrollbar: oklch(100% 0 0 / 0.18);
  color: var(--ink);
}
.moo-shell-root { display: flex; height: 100dvh; }
.moo-shell-main { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
.moo-shell-content { flex: 1 1 auto; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: var(--card-gap); padding: var(--sp-5); }
@media (min-width: 768px)  { .moo-shell-content { padding: var(--sp-6) 1.75rem; } }
@media (min-width: 1024px) { .moo-shell-content { padding: var(--sp-6) var(--sp-8); } }
@media (max-width: 767.98px) { .moo-shell-mobile-bar + .moo-shell-root .moo-shell-content { padding-top: calc(3.5rem + var(--sp-4)); } }

.moo-shell-sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; flex: 0 0 var(--sb-w); width: var(--sb-w); min-width: 0;
  background: var(--surface); border-right: 1px solid var(--shell-edge);
  transition: width var(--t) var(--ease);
  overflow-x: hidden;
}
@media (min-width: 768px) { .moo-shell-sidebar { z-index: var(--z-popover); } }
.moo-shell-brand-row { position: relative; flex: 0 0 auto; display: flex; align-items: center; height: 5rem; padding-left: 1.5rem; padding-right: 55px; }
.moo-shell-brand-text { display: inline-block; flex: 1 1 auto; min-width: 0; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--ink); font-size: 1.0625rem; font-weight: 500; letter-spacing: -0.02em; line-height: 1; transition: opacity 120ms var(--ease), max-width var(--t) var(--ease); }
.moo-shell-brand-text:hover { text-decoration: none; }
.moo-shell-brand-row .moo-shell-nav-row-wrap { position: absolute; top: 50%; right: 23px; transform: translateY(-50%); }

.moo-shell-nav { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding: 0 0.75rem 1rem; display: flex; flex-direction: column; gap: 0.25rem; scrollbar-width: thin; scrollbar-color: transparent transparent; transition: scrollbar-color 200ms var(--ease);
  /* the edge it can still scroll towards fades out: the shell script sets .moo-shell-has-top / -has-bottom */
  position: relative; --mask-top: black; --mask-bot: black;
  -webkit-mask-image: linear-gradient(to bottom, var(--mask-top) 0, black 28px, black calc(100% - 28px), var(--mask-bot) 100%);
  mask-image: linear-gradient(to bottom, var(--mask-top) 0, black 28px, black calc(100% - 28px), var(--mask-bot) 100%); }
.moo-shell-sidebar:hover .moo-shell-nav, .moo-shell-nav.moo-shell-scrolling { scrollbar-color: var(--shell-scrollbar) transparent; }

.moo-shell-mobile-bar { display: none; }
@media (max-width: 767.98px) {
  .moo-shell-mobile-bar { position: fixed; top: 0; left: 0; right: 0; z-index: var(--z-bar); height: 3.5rem; display: flex; align-items: center; gap: 0.5rem; padding: 0 1rem 0 0.5rem; background: var(--surface); border-bottom: 1px solid var(--hairline); font-weight: 500; }
}
.moo-shell-icon-button { width: 2rem; height: 2rem; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-md); color: var(--ink-mute); transition: background-color 150ms ease, color 150ms ease; }
.moo-shell-icon-button:hover, .moo-shell-icon-button:focus-visible { color: var(--ink); background: var(--canvas-soft); }
.moo-shell-icon-button i { font-size: 14px; }
.moo-shell-icon-button .ico-expanded, .moo-shell-icon-button .ico-collapsed { display: none; }
.moo-shell-icon-button .ico-mobile { display: inline-block; font-size: 18px; }
@media (min-width: 768px) {
  .moo-shell-icon-button .ico-mobile { display: none; }
  html:not(.moo-shell-collapsed) .moo-shell-icon-button .ico-expanded { display: inline-block; }
  html.moo-shell-collapsed .moo-shell-icon-button .ico-collapsed { display: inline-block; }
}

.moo-shell-section-title { padding: 0.75rem 0.75rem 0.25rem; color: var(--ink-mute); font-size: 0.6875rem; line-height: 1.15; letter-spacing: 0.04em; text-transform: uppercase; overflow: hidden; max-height: 28px; transition: opacity 140ms var(--ease), max-height var(--t) var(--ease); }

.moo-shell-nav-row-wrap { position: relative; }
.moo-shell-nav-row {
  position: relative; display: flex; align-items: center; gap: 0.75rem; width: 100%;
  height: 2.25rem; padding: 0 0.75rem;
  border: 1px solid transparent; background: transparent;
  color: var(--ink-secondary); border-radius: var(--radius-md);
  font-size: 0.875rem; text-align: left; text-decoration: none;
  white-space: nowrap; overflow: hidden; cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}
.moo-shell-nav-row:hover { color: var(--ink); background: var(--canvas-soft); text-decoration: none; }
.moo-shell-nav-row:focus-visible { outline: none; background: var(--canvas-soft); box-shadow: inset 0 0 0 1px var(--focus-ring-strong); }
.moo-shell-nav-row.is-depth-1 { height: auto; min-height: 32px; padding: 0.375rem 0.75rem 0.375rem 38px; font-size: 0.84375rem; }
.moo-shell-nav-row.is-depth-2 { height: auto; min-height: 32px; padding: 0.375rem 0.75rem 0.375rem 54px; font-size: 0.84375rem; }
.moo-shell-nav-icon { width: 18px; height: 18px; flex: 0 0 18px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-mute); }
.moo-shell-nav-icon i { font-size: 14px; }
.moo-shell-chevron { width: 0.875rem; height: 0.875rem; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-mute); transition: opacity 140ms var(--ease), transform 200ms var(--ease); }
.moo-shell-chevron i { font-size: 10px; }
.moo-shell-nav-row-current { color: var(--ink); font-weight: 500; }
.moo-shell-nav-row-current .moo-shell-nav-icon, .moo-shell-nav-row-parent-current > .moo-shell-nav-icon { color: var(--signal); }
.moo-shell-nav-row:hover .moo-shell-nav-icon { color: var(--ink); }
.moo-shell-label { display: inline-block; flex: 1 1 auto; min-width: 0; max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: opacity 160ms var(--ease) 80ms, max-width var(--t) var(--ease); }

/* Moopa's System group follows the app's menus, below a line */
.moo-shell-nav-system { padding-top: var(--sp-1); }
.moo-shell-sub-nav { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 180ms var(--ease); }
.moo-shell-sub-nav > .moo-shell-sub-inner { overflow: hidden; min-height: 0; position: relative; }
.moo-shell-nav-row-wrap[data-open="true"] > .moo-shell-sub-nav { grid-template-rows: 1fr; }
.moo-shell-nav-row-wrap[data-open="true"] > .moo-shell-nav-row > .moo-shell-chevron { transform: rotate(90deg); }
.moo-shell-sub-inner::before { content: ""; position: absolute; left: 22px; top: 4px; bottom: 4px; width: 1px; background: var(--hairline); }
.moo-shell-sub-inner .moo-shell-nav-row-current { background: transparent; }
.moo-shell-sub-inner .moo-shell-nav-row-current::before { content: ""; position: absolute; left: 22px; top: 50%; width: 2px; height: 1.125rem; background: var(--signal); transform: translateY(-50%); }
html.moo-shell-collapsed .moo-shell-sub-nav { grid-template-rows: 0fr !important; }

/* profile */
.moo-shell-profile-menu { position: relative; flex: 0 0 auto; border-top: 1px solid var(--hairline); padding: 0.5rem; }
.moo-shell-profile-button { position: relative; width: 100%; height: 3rem; display: flex; align-items: center; gap: 0.75rem; padding: 0 0.5rem; border-radius: var(--radius-md); color: var(--ink-secondary); text-align: left; white-space: nowrap; overflow: hidden; transition: background-color 150ms ease, color 150ms ease; }
.moo-shell-profile-button:hover, .moo-shell-profile-button:focus-visible { color: var(--ink); background: var(--canvas-soft); }
.moo-shell-avatar { width: 2rem; height: 2rem; flex: 0 0 2rem; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; border-radius: var(--radius-pill); background: var(--shell-signal); color: var(--shell-edge); font-size: 0.75rem; font-weight: 600; }
/* The picture covers the initials; if it fails to load it removes itself and the initials show */
.moo-shell-avatar { position: relative; }
.moo-shell-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.moo-shell-profile-name { display: block; overflow: hidden; text-overflow: ellipsis; color: var(--ink); font-size: 0.8125rem; }
.moo-shell-profile-email { display: block; overflow: hidden; text-overflow: ellipsis; color: var(--ink-mute); font-size: 0.71875rem; }
.moo-shell-profile-switch-icon { width: 1rem; flex: 0 0 1rem; display: inline-flex; justify-content: center; color: var(--ink-mute); font-size: 12px; }
.moo-shell-profile-dropdown { position: absolute; left: 0.5rem; right: 0.5rem; bottom: 100%; z-index: var(--z-popover); margin-bottom: 0.25rem; padding: 0.375rem 0; max-height: calc(100vh - 6rem); overflow-y: auto; border: 1px solid var(--hairline); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-2); transform-origin: bottom; opacity: 0; transform: scale(0.95); pointer-events: none; transition: opacity 150ms ease-out, transform 150ms ease-out; }
.moo-shell-profile-dropdown.moo-shell-open { opacity: 1; transform: scale(1); pointer-events: auto; }
.moo-shell-profile-dropdown-header { margin-bottom: 0.25rem; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--hairline); }
.moo-shell-menu-heading { padding: 0.5rem 0.75rem 0.25rem; color: var(--ink-mute); font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; }
.moo-shell-menu-item { display: flex; align-items: center; gap: 0.625rem; width: 100%; padding: 0.5rem 0.75rem; color: var(--ink-secondary); font-size: 0.8125rem; text-align: left; text-decoration: none; transition: background-color 150ms ease, color 150ms ease; }
.moo-shell-menu-item:hover, .moo-shell-menu-item:focus-visible { color: var(--ink); background: var(--canvas-soft); text-decoration: none; outline: none; }
.moo-shell-menu-item[aria-current="page"] { color: var(--ink); font-weight: 500; }
.moo-shell-menu-item[aria-current="page"] .moo-shell-menu-item-icon { color: var(--signal); }
.moo-shell-menu-item-icon { width: 1rem; flex: 0 0 1rem; display: inline-flex; justify-content: center; color: var(--ink-mute); font-size: 13px; }
.moo-shell-menu-item:hover .moo-shell-menu-item-icon { color: var(--ink); }
.moo-shell-menu-divider { margin: 0.375rem 0; border-top: 1px solid var(--hairline); }
.moo-shell-menu-item-danger { color: var(--danger-text); }
.moo-shell-menu-item-danger:hover, .moo-shell-menu-item-danger:focus-visible { color: var(--danger-text); background: var(--shell-danger-bg); }
html.moo-shell-collapsed .moo-shell-profile-dropdown { position: fixed; left: calc(var(--sb-w-collapsed) + 8px); right: auto; width: 240px; bottom: 8px; margin: 0; transform-origin: bottom left; }

/* collapsed rail */
html.moo-shell-collapsed .moo-shell-sidebar { width: var(--sb-w-collapsed); flex-basis: var(--sb-w-collapsed); }
html.moo-shell-collapsed .moo-shell-label, html.moo-shell-collapsed .moo-shell-profile-switch-icon { opacity: 0; max-width: 0; }
html.moo-shell-collapsed .moo-shell-section-title { opacity: 0; max-height: 0; padding-top: 0; padding-bottom: 0; }
html.moo-shell-collapsed .moo-shell-chevron { opacity: 0; }
html.moo-shell-collapsed .moo-shell-brand-text { opacity: 0; max-width: 0; flex: 0 0 0; }
html.moo-shell-collapsed .moo-shell-brand-row .moo-shell-nav-row-wrap { left: 17px; right: auto; }

/* tooltip portal (moopa.js) for the collapsed rail */
.moo-shell-nav-tooltip { display: none; }
.moo-shell-nav-tooltip-portal { position: fixed; z-index: var(--z-tooltip); pointer-events: none; background: var(--ink); color: var(--surface); font-size: 12.5px; padding: 6px 10px; border-radius: 7px; white-space: nowrap; box-shadow: var(--shadow-2); opacity: 0; translate: 0 -50%; transform: translateX(-4px) scale(.96); transform-origin: left center; transition: opacity 120ms var(--ease), transform 160ms var(--ease); }
.moo-shell-nav-tooltip-portal.show { opacity: 1; transform: translateX(0) scale(1); }

/* mobile drawer */
.moo-shell-backdrop { position: fixed; inset: 0; background: var(--shell-backdrop); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity var(--t) var(--ease); z-index: var(--z-backdrop); }
body.moo-shell-mobile-open .moo-shell-backdrop { opacity: 1; pointer-events: auto; }
@media (max-width: 767.98px) {
  .moo-shell-sidebar { position: fixed !important; top: 0; left: 0; height: 100dvh; z-index: var(--z-sidebar); width: min(var(--sb-w), calc(100vw - 3rem)) !important; flex: 0 0 0 !important; transform: translateX(-100%); transition: transform var(--t) var(--ease) !important; box-shadow: var(--shadow-2); }
  .moo-shell-icon-button { width: 2.75rem; height: 2.75rem; }
  .moo-shell-brand-row { height: 4.25rem; padding-left: 1rem; }
  .moo-shell-brand-row .moo-shell-nav-row-wrap { right: 0.75rem; }
  .moo-shell-nav-row { min-height: 2.75rem; padding-block: 0.625rem; }
  .moo-shell-profile-menu { padding: 0.75rem; }
  .moo-shell-profile-button { min-height: 3.25rem; }
  body:not(.moo-shell-mobile-open) .moo-shell-sidebar { box-shadow: none; visibility: hidden; transition: transform var(--t) var(--ease), visibility 0s var(--t) !important; }
  body.moo-shell-mobile-open .moo-shell-sidebar { transform: translateX(0) !important; }
  body.moo-shell-mobile-open { overflow: hidden; }
}
@media (min-width: 768px) { .moo-shell-backdrop { display: none !important; } }

/* impersonation banner */
.moo-shell-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--sp-2) var(--sp-3); padding: 0.5rem 1rem; background: var(--warning-surface); border-bottom: 1px solid var(--warning-border); color: var(--warning-text); font-size: var(--text-sm); }


/* Shell extras: brand logo and name, quieter nav rows, nav badges, profile dropdown lines, a copy-to-clipboard
   button, and the route-security button with its frame */
.moo-shell-logo { display: block; width: auto; height: var(--shell-logo-h); max-width: 100%; object-fit: contain; }
.moo-shell-logo-mobile { height: var(--shell-logo-h-mobile); }
.moo-shell-brand-name { font-size: 1.0625rem; font-weight: 500; letter-spacing: -0.02em; color: var(--ink); }
.moo-shell-icon-button-lg { width: 2.5rem; height: 2.5rem; }
.moo-shell-nav-row-default:hover, .moo-shell-nav-row-muted:hover, .moo-shell-nav-row-parent-current:hover { color: var(--ink); background: var(--canvas-soft); }
.moo-shell-nav-row-muted { color: var(--ink-mute); }
.moo-shell-nav-badge { margin-inline-start: auto; display: inline-flex; align-items: center; border: 1px solid var(--hairline); background: var(--canvas-soft); color: var(--ink-mute); border-radius: var(--radius-pill); padding: 0.125rem 0.375rem; font-size: 0.6875rem; }
.moo-shell-profile-dropdown-name { display: block; overflow: hidden; text-overflow: ellipsis; color: var(--ink); font-size: 0.8125rem; }
.moo-shell-profile-dropdown-email { display: block; overflow: hidden; text-overflow: ellipsis; color: var(--ink-mute); font-size: 0.71875rem; }
.moo-shell-copy-button { cursor: pointer; transition: color 150ms ease; color: inherit; }
.moo-shell-copy-button:hover { color: var(--ink-secondary); text-decoration: underline; }
.moo-shell-copy-feedback { margin-inline-start: 0.25rem; color: var(--success); opacity: 0; transition: opacity 150ms ease; }
html.moo-shell-collapsed .moo-shell-nav-badge { opacity: 0; transform: scale(.6); pointer-events: none; }
.moo-shell-nav.moo-shell-has-top { --mask-top: transparent; }
.moo-shell-nav.moo-shell-has-bottom { --mask-bot: transparent; }
@media (max-width: 767.98px) {
  .moo-shell-icon-button, .moo-shell-icon-button-lg { width: 2.75rem; height: 2.75rem; }
}
.moo-shell-security-fab {
  position: fixed; right: 0.75rem; bottom: 0.75rem; z-index: var(--z-bar);
  display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem;
  border: 1px solid var(--hairline); border-radius: var(--radius-pill); background: var(--surface); color: var(--ink-mute);
  box-shadow: var(--shadow-1); cursor: pointer; font-size: 0.95rem; opacity: 0.6;
  transition: opacity var(--t) var(--ease), color var(--t) var(--ease);
}
.moo-shell-security-fab:hover, .moo-shell-security-fab:focus-visible { opacity: 1; color: var(--ink); }
.moo-shell-security-frame { flex: 1 1 auto; width: 100%; height: 100%; border: 0; background: var(--surface); }

/* RustCFML debug footer */
.rustcfml-debug { position: fixed; inset: auto 0 0 0; max-height: 55vh; overflow-y: auto; z-index: var(--z-debug); box-shadow: 0 -6px 24px oklch(0% 0 0 / 0.18); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; } }
