/* grok2api admin — "awesome-design-md-cn" design language.
   Cold-gray canvas · deep-charcoal anchor · one cool-blue accent.
   Self-contained, no build step. All tokens live in :root.
   Ref: project DESIGN.md — low-fatigue, editorial, Chinese-first, compact. */

:root {
  /* ---- primary / anchor ---- */
  --graphite: #111318;      /* deep charcoal: sidebar, dark containers, strong text */
  --ink:      #1f2937;      /* secondary dark, high-emphasis chrome */
  --accent:       #4b6bff;  /* the single accent: interaction, active, grouping */
  --accent-hover: #3f5cf0;
  --accent-press: #354fd6;
  --accent-text:  #3a54d9;  /* accent as TEXT on light surfaces (AA, ~5:1) */
  --accent-wash:  rgba(75,107,255,0.06);   /* active chips, subtle fills */
  --accent-wash2: rgba(75,107,255,0.12);   /* stronger accent surface */
  --accent-border:rgba(75,107,255,0.28);
  --focus-ring:   rgba(75,107,255,0.30);

  /* ---- surfaces (light side) ---- */
  --canvas:    #f2f5f9;                     /* global cold-gray background */
  --panel:     rgba(255,255,255,0.82);      /* main content panels */
  --panel-solid:#ffffff;
  --card:      #f7f9fc;                      /* directory cards / table surface */
  --raised:    #fbfcfe;                      /* hovered / emphasized surfaces */
  --sunken:    #eef1f6;                      /* segmented track, insets */
  --border:        rgba(15,23,42,0.16);      /* default border / row divider (~2.4:1) */
  --border-strong: rgba(15,23,42,0.28);      /* inputs, dividers that must read (~3:1) */

  /* ---- text (on light) — AA-verified against --card #f7f9fc ---- */
  --text:       #16181d;                     /* strong titles */
  --text-body:  rgba(17,19,24,0.88);
  --text-muted: #565d68;                     /* secondary descriptions (~6:1) */
  --text-quiet: #6b7280;                     /* TEXT FLOOR: headers/labels/counts (~4.6:1) */
  --text-oncolor:#ffffff;

  /* ---- text / chrome on the charcoal anchor ---- */
  --on-dark:        rgba(255,255,255,0.92);
  --on-dark-muted:  rgba(255,255,255,0.66);
  --on-dark-quiet:  rgba(255,255,255,0.55);   /* text floor on dark chrome */
  --dark-border:    rgba(255,255,255,0.12);
  --dark-hover:     rgba(255,255,255,0.06);
  --dark-active-bg: rgba(75,107,255,0.20);
  --dark-active-fg: #aeb9ff;

  /* ---- functional status (used only where meaning needs it) ---- */
  --success: #187a43; --success-soft: #e7f4ec;
  --warning: #8a5e0f; --warning-soft: #f6efdd;
  --danger:  #b8362d; --danger-soft:  #fbeae8;
  --info:    var(--accent); --info-soft: var(--accent-wash2);
  --neutral-dot: #c2c9d4;

  /* ---- radius (DESIGN.md scale) ---- */
  --r-xs: 6px; --r-sm: 8px; --r-card: 10px; --r-panel: 12px; --r-pill: 999px;

  /* ---- elevation: soft, low-contrast; depth mostly from surface contrast ---- */
  --shadow-xs:    0 1px 2px rgba(17,19,24,0.05);
  --shadow-panel: 0 1px 2px rgba(17,19,24,0.04), 0 0 0 1px rgba(15,23,42,0.03);
  --shadow-menu:  0 8px 24px rgba(17,19,24,0.16), 0 2px 6px rgba(17,19,24,0.08);
  --shadow-pop:   0 10px 30px rgba(17,19,24,0.12), 0 2px 6px rgba(17,19,24,0.06);
  --shadow-modal: 0 24px 64px rgba(17,19,24,0.26), 0 4px 12px rgba(17,19,24,0.10);

  /* ---- motion ---- */
  --dur-fast: 120ms; --dur: 160ms; --dur-slow: 220ms;

  /* ---- z-index ladder (no more ad-hoc 30/40/50/60) ---- */
  --z-nav: 100; --z-savebar: 200; --z-dropdown: 300; --z-modal: 400; --z-toast: 500;

  /* ---- spacing (4px base; half-steps 6/10 that were being faked inline) ---- */
  --sp-1: 4px; --sp-1_5: 6px; --sp-2: 8px; --sp-2_5: 10px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px; --sp-16: 64px;

  /* ---- type: Chinese-first system stack, mono for numerics ---- */
  --font: "SF Pro Display", -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", system-ui, Roboto, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --fs-xs: 12px; --fs-sm: 13px; --fs-base: 14px; --fs-md: 15px;
  --fs-lg: 18px; --fs-xl: 24px; --fs-hero: 30px; --fs-stat: 28px;
  --fw-regular: 400; --fw-medium: 500; --fw-semibold: 600;
  --lh-tight: 1.1; --lh-body: 1.6;

  --sidebar-w: 220px; --rail-w: 236px; --page-max: 1920px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   dark theme — remap surfaces/text/borders; the sidebar/hero/login
   are already dark. Respects OS preference and an explicit [data-theme].
   ============================================================ */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #0e1014; --panel: rgba(22,25,31,0.92); --panel-solid: #1a1d24;
    --card: #14171d; --raised: #1e222b; --sunken: #0f1218;
    --border: rgba(255,255,255,0.10); --border-strong: rgba(255,255,255,0.20);
    --text: #f2f4f8; --text-body: rgba(255,255,255,0.88);
    --text-muted: rgba(255,255,255,0.66); --text-quiet: rgba(255,255,255,0.52);
    --accent-wash: rgba(120,146,255,0.12); --accent-wash2: rgba(120,146,255,0.20);
    --accent-border: rgba(120,146,255,0.40); --accent-press: #aeb9ff; --accent-text: #aeb9ff;
    --success: #45c47e; --success-soft: rgba(24,122,67,0.22);
    --warning: #e0b055; --warning-soft: rgba(138,94,15,0.24);
    --danger: #ef6a60; --danger-soft: rgba(184,54,45,0.22);
    --neutral-dot: #4a515c;
    --shadow-menu: 0 8px 24px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.4);
    --shadow-pop: 0 10px 30px rgba(0,0,0,0.55), 0 2px 6px rgba(0,0,0,0.4);
    --shadow-modal: 0 24px 64px rgba(0,0,0,0.7), 0 4px 12px rgba(0,0,0,0.5);
    --shadow-panel: 0 1px 2px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.04);
  }
}
:root[data-theme="dark"] {
  --canvas: #0e1014; --panel: rgba(22,25,31,0.92); --panel-solid: #1a1d24;
  --card: #14171d; --raised: #1e222b; --sunken: #0f1218;
  --border: rgba(255,255,255,0.10); --border-strong: rgba(255,255,255,0.20);
  --text: #f2f4f8; --text-body: rgba(255,255,255,0.88);
  --text-muted: rgba(255,255,255,0.66); --text-quiet: rgba(255,255,255,0.52);
  --accent-wash: rgba(120,146,255,0.12); --accent-wash2: rgba(120,146,255,0.20);
  --accent-border: rgba(120,146,255,0.40); --accent-press: #aeb9ff;
  --success: #45c47e; --success-soft: rgba(24,122,67,0.22);
  --warning: #e0b055; --warning-soft: rgba(138,94,15,0.24);
  --danger: #ef6a60; --danger-soft: rgba(184,54,45,0.22);
  --neutral-dot: #4a515c;
  --shadow-menu: 0 8px 24px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.4);
  --shadow-pop: 0 10px 30px rgba(0,0,0,0.55), 0 2px 6px rgba(0,0,0,0.4);
  --shadow-modal: 0 24px 64px rgba(0,0,0,0.7), 0 4px 12px rgba(0,0,0,0.5);
  --shadow-panel: 0 1px 2px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.04);
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--canvas); color: var(--text-body);
  font: var(--fw-regular) var(--fs-base)/var(--lh-body) var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  /* no negative tracking at body size — it cramps CJK text */
}
a { color: var(--accent-text); text-decoration: none; }
h1,h2,h3 { margin: 0; color: var(--text); letter-spacing: -0.03em; }
svg { display: inline-block; vertical-align: middle; flex-shrink: 0; }
.ico { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.75;
  fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ico--sm { width: 14px; height: 14px; }
::selection { background: var(--accent-wash2); }

/* ============================================================
   app shell: charcoal sidebar + cold-gray content
   ============================================================ */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh; min-height: 100dvh; }

.sidebar { position: sticky; top: 0; align-self: start; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; padding: var(--sp-5) var(--sp-3) var(--sp-4);
  background: var(--graphite); color: var(--on-dark);
  border-right: 1px solid var(--dark-border); }
.sidebar__brand { display: flex; align-items: center; gap: var(--sp-2);
  padding: 4px var(--sp-2) var(--sp-6); font-weight: var(--fw-semibold);
  color: var(--on-dark); letter-spacing: -0.02em; }
.sidebar__logo { width: 28px; height: 28px; border-radius: var(--r-sm);
  background: linear-gradient(140deg, #5f78ff, var(--accent)); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: var(--fw-semibold);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06), 0 6px 18px rgba(75,107,255,0.45);
  font-family: var(--font-mono); }
.sidebar__name { font-size: var(--fs-md); }
.sidebar__foot { margin-top: auto; padding-top: var(--sp-3);
  display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--dark-border); }
.sidebar__envrow { padding: var(--sp-2) var(--sp-2) 2px; }
.sidebar__env { font: var(--fs-xs)/1 var(--font-mono); color: var(--on-dark-quiet);
  padding: 5px 10px; background: rgba(255,255,255,0.04); border: 1px solid var(--dark-border);
  border-radius: var(--r-pill); }

.sidenav { display: flex; flex-direction: column; gap: 2px; }
.sidenav__item { display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: none; background: none; border-radius: var(--r-sm);
  font-size: var(--fs-base); font-weight: var(--fw-medium); color: var(--on-dark-muted);
  cursor: pointer; text-align: left;
  transition: color .14s var(--ease), background .14s var(--ease); }
.sidenav__item .ico { color: var(--on-dark-quiet); transition: color .14s var(--ease); }
.sidenav__item:hover { background: var(--dark-hover); color: var(--on-dark); }
.sidenav__item:hover .ico { color: var(--on-dark-muted); }
.sidenav__item--active { background: var(--dark-active-bg); color: #fff; }
.sidenav__item--active .ico { color: var(--dark-active-fg); }
.sidenav__item:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--accent-border); }

.content { min-width: 0; padding: var(--sp-8) var(--sp-8) 88px; }
.content > section { max-width: var(--page-max); margin: 0 auto; }

/* page header (title + actions) */
.pagehead { display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4); margin-bottom: var(--sp-6); }
.pagehead__title { font-size: var(--fs-xl); font-weight: var(--fw-semibold); }
.pagehead__sub { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 5px; }
.pagehead__actions { display: flex; align-items: center; gap: var(--sp-2); }

/* ============================================================
   panels & cards (soft-white translucent over cold gray)
   ============================================================ */
.card { background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-panel); box-shadow: var(--shadow-panel);
  backdrop-filter: saturate(1.2); }
.card__head { padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--border); }
.card__body { padding: var(--sp-6); }
.card__title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.card__desc { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 4px; line-height: 1.55; }

/* ============================================================
   buttons — pill radius, subtle accent (not heavy fills)
   ============================================================ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 15px; border: 1px solid var(--border-strong); border-radius: var(--r-pill);
  background: var(--panel-solid); color: var(--text); cursor: pointer;
  font-size: var(--fs-base); font-weight: var(--fw-medium); font-family: inherit;
  white-space: nowrap; letter-spacing: -0.01em;
  transition: background .14s var(--ease), border-color .14s var(--ease),
    box-shadow .14s var(--ease), color .14s var(--ease), transform .06s var(--ease); }
.btn:hover { border-color: var(--text-quiet); background: var(--raised); }
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
.btn--primary { background: var(--accent-wash2); border-color: var(--accent-border);
  color: var(--accent-press); }
.btn--primary:hover { background: rgba(75,107,255,0.18); border-color: var(--accent);
  color: var(--accent-press); }
.btn--primary:active { background: rgba(75,107,255,0.24); }
.btn--solid { background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 1px 2px rgba(75,107,255,0.25); }
.btn--solid:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--solid:active { background: var(--accent-press); }
.btn--ghost { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--sunken); border-color: transparent; color: var(--text); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger-ghost { color: var(--danger); border-color: transparent; background: transparent; }
.btn--danger-ghost:hover { background: var(--danger-soft); }
.btn--sm { height: 30px; padding: 0 12px; font-size: var(--fs-sm); }
.btn--xs { height: 26px; padding: 0 9px; font-size: var(--fs-xs); }
.btn--icon { padding: 0; width: 30px; border-radius: var(--r-sm); }
.btn--icon.btn--xs { width: 26px; }
.btn--icon .ico { width: 15px; height: 15px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover { background: var(--panel-solid); border-color: var(--border-strong); }

/* ============================================================
   stats — compact directory-style tiles (not marketing blocks)
   ============================================================ */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }
.stat { padding: var(--sp-4) var(--sp-5); background: var(--card);
  border: 1px solid var(--border); border-radius: var(--r-card);
  transition: background .14s var(--ease), border-color .14s var(--ease); }
.stat:hover { background: var(--raised); border-color: var(--border-strong); }
.stat__num { font-size: var(--fs-stat); font-weight: var(--fw-semibold); line-height: 1;
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--text); }
.stat__label { display: block; font-size: var(--fs-sm); color: var(--text-muted); margin-top: 7px; }

/* ============================================================
   pool layout: sticky left filter rail + content
   ============================================================ */
.pool { display: grid; grid-template-columns: var(--rail-w) 1fr; gap: var(--sp-6);
  align-items: start; }
.rail { position: sticky; top: var(--sp-8); display: flex; flex-direction: column;
  gap: var(--sp-4); padding: var(--sp-4); background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--r-panel); box-shadow: var(--shadow-panel); }
.rail__group { display: flex; flex-direction: column; gap: var(--sp-2); }
.rail__label { font: var(--fw-semibold) var(--fs-xs)/1 var(--font); letter-spacing: normal;
  color: var(--text-muted); padding: 0 2px; }
.rail__search { position: relative; }
.rail__search .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-quiet); width: 15px; height: 15px; pointer-events: none; }
.rail__search .input { padding-left: 34px; }
/* vertical chip list for status filters */
.chips { display: flex; flex-direction: column; gap: 3px; }
.chip { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 11px; border-radius: var(--r-pill); border: 1px solid transparent;
  font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-muted);
  cursor: pointer; text-decoration: none; background: transparent;
  transition: background .14s var(--ease), color .14s var(--ease), border-color .14s var(--ease); }
.chip:hover { background: var(--sunken); color: var(--text); }
.chip--active { background: var(--accent-wash); color: var(--accent-press);
  border-color: var(--accent-border); }
.chip__count { font: var(--fw-medium) var(--fs-xs)/1 var(--font-mono);
  color: var(--text-quiet); font-variant-numeric: tabular-nums; }
.chip--active .chip__count { color: var(--accent-press); }
.pool__main { min-width: 0; display: flex; flex-direction: column; gap: var(--sp-5); }
/* account cell: dot + email + badges on one line, badges don't wrap the email away */
.acct { display: flex; align-items: center; gap: var(--sp-1_5); min-width: 0; }
.acct .u-ellipsis { max-width: 260px; }
/* sortable table headers */
.th-sort { border: none; background: none; padding: 0; margin: 0; cursor: pointer; font: inherit;
  color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.th-sort:hover { color: var(--text); }
.th-sort:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); border-radius: var(--r-xs); }
.th-arrow { color: var(--accent-text); font-size: var(--fs-xs); }

/* ============================================================
   toolbar / segmented control
   ============================================================ */
.toolbar { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--sunken); border-radius: var(--r-pill);
  padding: 3px; gap: 2px; }
.seg__item { border: none; background: none; padding: 6px 13px; border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-muted);
  cursor: pointer; text-decoration: none;
  transition: color .14s var(--ease), background .14s var(--ease), box-shadow .14s var(--ease); }
.seg__item:hover { color: var(--text); }
.seg__item--active { background: var(--panel-solid); color: var(--accent-press); box-shadow: var(--shadow-xs); }
.seg--wrap { display: flex; flex-wrap: wrap; }
.input--search { width: 100%; }

/* ============================================================
   bulk action bar
   ============================================================ */
.bulkbar { display: flex; align-items: center; gap: var(--sp-4); padding: 10px var(--sp-4);
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-card);
  transition: background .14s var(--ease), border-color .14s var(--ease); }
.bulkbar--active { background: var(--accent-wash); border-color: var(--accent-border); }
.bulkbar__count { color: var(--text); font-size: var(--fs-sm); }
.bulkbar__count b { color: var(--accent-press); }
.bulkbar__actions { display: flex; gap: var(--sp-2); }

/* pagination */
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: var(--sp-2) 2px; }
.pager__info { font-size: var(--fs-sm); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.pager__info b { color: var(--text); }
.pager__ctrl { display: flex; gap: var(--sp-2); }

/* ============================================================
   table — directory grid, slightly gray, low glare
   ============================================================ */
/* .tbl-scroll owns the border/radius/shadow AND the horizontal scroll, so a wide
   table scrolls instead of clipping its rightmost (操作) column off-screen. */
.tbl-scroll { overflow-x: auto; overflow-y: visible; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--r-panel);
  box-shadow: var(--shadow-panel); }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card);
  --row-py: 12px; }
.tbl--pool { min-width: 1000px; }
.tbl--wide { min-width: 1160px; }
.tbl thead th { position: sticky; top: 0; z-index: 1; background: var(--card);
  border-bottom: 1px solid var(--border-strong);
  padding: 11px var(--sp-4); text-align: left; font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  letter-spacing: normal; color: var(--text-muted); white-space: nowrap; }
.tbl td { padding: var(--row-py) var(--sp-4); border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm); vertical-align: middle; color: var(--text-body); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .12s var(--ease); }
.tbl tbody tr:hover { background: var(--raised); }
.tbl tr.is-selected { background: var(--accent-wash); box-shadow: inset 2px 0 0 var(--accent); }
.tbl--compact { --row-py: 7px; }
.tbl--compact thead th { padding-top: 8px; padding-bottom: 8px; }
/* centered log tables (header + content aligned centrally) */
.tbl--center thead th, .tbl--center td { text-align: center; }
.tbl--center .u-ellipsis { margin: 0 auto; }

/* global compact density (admin.ui_density = compact) — applies across pages */
.density-compact .tbl { --row-py: 7px; }
.density-compact .tbl thead th { padding-top: 8px; padding-bottom: 8px; }
.density-compact .kv__row { padding: 6px 0; }
.density-compact .taskrow { padding: 6px var(--sp-6); }
.density-compact .card__body { padding: var(--sp-4) var(--sp-5); }
.density-compact .frow { padding: var(--sp-3) 0; }
.density-compact .hero { padding: var(--sp-4) var(--sp-6); }
.density-compact .stat { padding: var(--sp-3) var(--sp-4); }
.u-num { font-family: var(--font-mono); text-align: right; font-variant-numeric: tabular-nums; }
.u-ellipsis { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: inline-block; vertical-align: bottom; }
.u-muted { color: var(--text-muted); }
.u-subtle { color: var(--text-quiet); }
.u-err { color: var(--danger); }
.mono { font-family: var(--font-mono); }

/* ---- status dots / pills / meters ---- */
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 8px;
  box-shadow: 0 0 0 3px var(--card); }
.dot--ok { background: var(--success); } .dot--off { background: var(--neutral-dot); }
.dot--over { background: var(--warning); }
.at { font: var(--fw-medium) var(--fs-xs)/1 var(--font-mono); padding: 3px 8px;
  border-radius: var(--r-pill); white-space: nowrap; letter-spacing: -0.01em; }
.at--ok { color: var(--success); background: var(--success-soft); }
.at--warn { color: var(--warning); background: var(--warning-soft); }
.at--exp { color: var(--danger); background: var(--danger-soft); }
.meter { width: 56px; height: 6px; border-radius: var(--r-pill); background: var(--sunken);
  overflow: hidden; display: inline-block; vertical-align: middle; }
.meter__fill { height: 100%; background: var(--success); border-radius: inherit;
  transition: width .3s var(--ease); }
.meter__fill.is-warn { background: var(--warning); } .meter__fill.is-crit { background: var(--danger); }
.sso { font-family: var(--font-mono); color: var(--text-muted); font-size: var(--fs-xs); }
/* copy button: revealed on hover OR keyboard focus-within, and ALWAYS visible on
   touch devices (where there is no hover) so it is never unreachable. */
.sso__copy { opacity: 0; transition: opacity var(--dur-fast) var(--ease); margin-left: 6px; }
tr:hover .sso__copy, tr:focus-within .sso__copy { opacity: 1; }
.sso__copy:focus-visible { opacity: 1; outline: none; box-shadow: 0 0 0 2px var(--focus-ring); }
@media (hover: none) { .sso__copy { opacity: 1; } }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; opacity: 1; }

/* ---- badges ---- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px;
  border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: var(--fw-medium);
  letter-spacing: -0.01em; }
.badge--ok { color: var(--success); background: var(--success-soft); }
.badge--warn { color: var(--warning); background: var(--warning-soft); }
.badge--err { color: var(--danger); background: var(--danger-soft); }
.badge--info { color: var(--accent-press); background: var(--accent-wash2); }
.badge--ghost { color: var(--text-muted); background: var(--sunken); }

/* ============================================================
   forms
   ============================================================ */
label { font-size: var(--fs-base); }
.input, select, textarea {
  width: 100%; min-height: 36px; padding: 8px 12px; background: var(--panel-solid);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  font-size: var(--fs-base); color: var(--text); font-family: inherit;
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease); }
textarea { resize: vertical; min-height: 120px; font-family: var(--font-mono);
  font-size: var(--fs-sm); line-height: 1.6; }
.input::placeholder, textarea::placeholder { color: var(--text-quiet); }
.input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring); }
.input:hover:not(:focus), select:hover:not(:focus), textarea:hover:not(:focus) { border-color: var(--text-quiet); }
.input--sm { min-height: 34px; width: 96px; }
.input-affix { position: relative; display: inline-flex; align-items: center; }
.input-affix__suffix { position: absolute; right: 12px; color: var(--text-quiet);
  font-size: var(--fs-sm); pointer-events: none; }
.input-affix .input { padding-right: 40px; width: 150px; }

/* form rows: left label / right control */
.frow { display: grid; grid-template-columns: 1fr 340px; gap: var(--sp-6); align-items: start;
  padding: var(--sp-5) 0; border-bottom: 1px solid var(--border); }
.frow:last-child { border-bottom: none; }
/* full-width row: label on top, control spans the whole card (for tables etc.) */
.frow--full { grid-template-columns: 1fr; gap: var(--sp-3); }
.frow--full .frow__control { justify-content: flex-start; }
.frow__label label { font-weight: var(--fw-medium); color: var(--text); }
.frow__desc { margin-top: 5px; font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.55; }
.frow__control { display: flex; justify-content: flex-end; gap: var(--sp-3); flex-wrap: wrap; min-width: 0; }
.frow__control--split { gap: var(--sp-4); }
.mini { display: flex; flex-direction: column; gap: 5px; font-size: var(--fs-xs); color: var(--text-muted); }

/* switch — the real checkbox is sr-only but FOCUSABLE (keyboard + a11y tree),
   not display:none (which removed all 5 config toggles from keyboard/AT). */
.switch { display: inline-flex; position: relative; }
.switch input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.switch__track { width: 40px; height: 22px; border-radius: var(--r-pill); background: var(--border-strong);
  display: inline-block; position: relative; transition: background var(--dur-slow) var(--ease); cursor: pointer; }
.switch__track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-xs); transition: transform var(--dur-slow) var(--ease); }
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }

/* shared keyboard focus ring for custom interactive elements */
.chip:focus-visible, .seg__item:focus-visible, .dcard__link:focus-visible,
a:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); border-radius: var(--r-sm); }

/* ---- config: segmented tabs + panels + savebar ---- */
.cfg__panels { display: flex; flex-direction: column; gap: var(--sp-6); max-width: 1080px; }
.savebar { position: fixed; left: var(--sidebar-w); right: 0; bottom: 0; z-index: var(--z-savebar);
  display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-4);
  padding: 12px var(--sp-8); background: rgba(242,245,249,0.86);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  transform: translateY(100%); transition: transform .22s var(--ease); }
.savebar--active { transform: translateY(0); }
.savebar__hint { margin-right: auto; color: var(--warning); font-size: var(--fs-sm);
  font-weight: var(--fw-medium); display: inline-flex; align-items: center; gap: 7px; }

/* ============================================================
   modal
   ============================================================ */
.modal-backdrop { position: fixed; inset: 0; background: rgba(17,19,24,.52); display: flex;
  align-items: center; justify-content: center; z-index: var(--z-modal); padding: var(--sp-4);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fadeIn .16s var(--ease); }
.modal { background: var(--panel-solid); border-radius: var(--r-panel); box-shadow: var(--shadow-modal);
  width: 560px; max-width: 100%; max-height: 88vh; overflow: auto;
  animation: modalIn .2s var(--ease); }
.modal__head { padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--border); }
.modal__title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.modal__body { padding: var(--sp-6); }
.modal__foot { padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: var(--sp-3); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }

/* ============================================================
   toast
   ============================================================ */
.toast-stack { position: fixed; right: var(--sp-6); bottom: var(--sp-6); z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: var(--sp-2); }
/* sticky dismiss button for error toasts (success auto-dismiss) */
.toast__close { margin-left: auto; border: none; background: none; cursor: pointer;
  color: var(--text-quiet); padding: 2px; border-radius: var(--r-xs); display: inline-flex; }
.toast__close:hover { color: var(--text); background: var(--sunken); }
.toast__close:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--focus-ring); }
.toast { min-width: 240px; padding: 12px 14px; border-radius: var(--r-card); background: var(--panel-solid);
  border: 1px solid var(--border); box-shadow: var(--shadow-pop); font-size: var(--fs-sm);
  color: var(--text); display: flex; gap: 8px; align-items: center; animation: toastIn .2s var(--ease); }
.toast--ok { border-left: 3px solid var(--success); }
.toast--err { border-left: 3px solid var(--danger); }
.toast--progress { border-left: 3px solid var(--accent); }
.toast__spin { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--accent-wash2); border-top-color: var(--accent);
  animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toastIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

/* ============================================================
   utilities
   ============================================================ */
.u-row { display: flex; align-items: center; gap: var(--sp-2); }
.u-mt { margin-top: var(--sp-4); }
.u-hidden { display: none; }
.thumb { max-width: 100%; border-radius: var(--r-sm); border: 1px solid var(--border); }

/* ============================================================
   responsive
   ============================================================ */
@media (max-width: 960px) {
  .pool { grid-template-columns: 1fr; }
  .rail { position: static; }
  .chips { flex-direction: row; flex-wrap: wrap; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: var(--z-nav); height: auto; flex-direction: row;
    align-items: center; gap: var(--sp-3); padding: 8px var(--sp-4);
    border-right: none; border-bottom: 1px solid var(--dark-border); }
  .sidebar__brand { padding: 0; margin-right: var(--sp-2); }
  .sidebar__name { display: none; }
  .sidenav { flex-direction: row; gap: 2px; }
  .sidenav__item span { display: none; }
  .sidenav__item { padding: 9px; }
  .sidebar__foot { margin-top: 0; margin-left: auto; padding: 0; border-top: none; }
  .sidebar__envrow { display: none; }
  .content { padding: var(--sp-5) var(--sp-4) 88px; }
  .savebar { left: 0; padding: 12px var(--sp-4); }
}
@media (max-width: 720px) {
  .frow { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .pagehead { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============================================================
   login — the one place a deep-charcoal hero belongs
   ============================================================ */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
  padding: var(--sp-4); letter-spacing: -0.01em; color: var(--on-dark);
  background:
    radial-gradient(1000px 520px at 50% -12%, rgba(75,107,255,0.28) 0%, transparent 60%),
    radial-gradient(700px 400px at 85% 110%, rgba(75,107,255,0.10) 0%, transparent 55%),
    var(--graphite); }
.login__card { width: 100%; max-width: 392px; background: rgba(255,255,255,0.04);
  border: 1px solid var(--dark-border); border-radius: var(--r-panel);
  box-shadow: var(--shadow-modal); padding: var(--sp-8);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.login__brand { display: flex; align-items: center; gap: var(--sp-2);
  font-weight: var(--fw-semibold); color: var(--on-dark); }
.login__brandname { font-size: var(--fs-md); }
.login__title { font-size: var(--fs-hero); font-weight: var(--fw-semibold);
  margin-top: var(--sp-5); letter-spacing: -0.04em; color: #fff; line-height: 1.05; }
.login__sub { font-size: var(--fs-sm); color: var(--on-dark-muted); margin-top: 8px; }
.login__error { display: flex; align-items: center; gap: 8px; margin-top: var(--sp-4);
  padding: 10px 12px; border-radius: var(--r-sm); font-size: var(--fs-sm);
  color: #ffb4ad; background: rgba(184,54,45,0.18); border: 1px solid rgba(184,54,45,0.35); }
.login__error .ico { color: #ffb4ad; }
.login__form { display: flex; flex-direction: column; gap: var(--sp-4); margin-top: var(--sp-6); }
.login__field { display: flex; flex-direction: column; gap: 7px; }
.login__label { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--on-dark-muted); }
/* dark inputs on the login hero */
.login .input { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.14);
  color: #fff; }
.login .input::placeholder { color: var(--on-dark-quiet); }
.login .input:hover:not(:focus) { border-color: rgba(255,255,255,0.28); }
.login .input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(75,107,255,0.35); }
.login__submit { width: 100%; height: 42px; margin-top: var(--sp-2); }
.login__foot { text-align: center; margin-top: var(--sp-6); font-size: var(--fs-xs); color: var(--on-dark-quiet); }

/* ============================================================
   hero band — the deep-charcoal signature (short title + metrics)
   ============================================================ */
.hero { position: relative; overflow: hidden; display: flex; align-items: flex-end;
  justify-content: space-between; gap: var(--sp-6); flex-wrap: wrap;
  padding: var(--sp-6) var(--sp-8); margin-bottom: var(--sp-6);
  border: 1px solid var(--dark-border); border-radius: var(--r-panel);
  color: var(--on-dark);
  background:
    radial-gradient(680px 260px at 88% -40%, rgba(75,107,255,0.30) 0%, transparent 62%),
    radial-gradient(420px 200px at 0% 140%, rgba(75,107,255,0.10) 0%, transparent 60%),
    linear-gradient(180deg, #171a21 0%, var(--graphite) 100%); }
.hero__main { min-width: 0; }
.hero__title { font-size: var(--fs-hero); font-weight: var(--fw-semibold); color: #fff;
  letter-spacing: -0.04em; line-height: 1.05; }
.hero__sub { margin-top: 8px; font-size: var(--fs-sm); color: var(--on-dark-muted); max-width: 60ch; }
.hero__metrics { display: flex; gap: var(--sp-8); }
.hero__metric { display: flex; flex-direction: column; gap: 4px; }
.hero__metric-num { font: var(--fw-semibold) var(--fs-xl)/1 var(--font); color: #fff;
  font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.hero__metric-label { font-size: var(--fs-xs); color: var(--on-dark-quiet); letter-spacing: 0.02em; }

/* dashboard metric tiles: 4-up */
.stats--4 { grid-template-columns: repeat(4, 1fr); }

/* ============================================================
   directory cards (overview grouped sections)
   ============================================================ */
.dcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--sp-4);
  align-items: start; }
.dcard { display: flex; flex-direction: column; }
.dcard__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.dcard__link { display: inline-flex; align-items: center; gap: 5px; border: none; background: none;
  color: var(--accent-text); font: var(--fw-medium) var(--fs-sm)/1 var(--font); cursor: pointer;
  padding: 4px 6px; border-radius: var(--r-sm); transition: background var(--dur) var(--ease); }
.dcard__link:hover { background: var(--accent-wash); }
.dcard__body--flush { padding: var(--sp-2) 0; }
.dcard__foot { padding: var(--sp-3) var(--sp-6) 0; }

/* key/value rows */
.kv { display: flex; flex-direction: column; }
.kv__row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: 9px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.kv__row:last-child { border-bottom: none; }
.kv__k { color: var(--text-muted); display: inline-flex; align-items: center; }
.kv__v { color: var(--text); font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; }

/* recent-task list */
.tasklist { list-style: none; margin: 0; padding: 0; }
.taskrow { display: flex; align-items: center; gap: var(--sp-2); padding: 9px var(--sp-6);
  border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.taskrow:last-child { border-bottom: none; }
.taskrow__prompt { flex: 1; min-width: 0; color: var(--text-body); }
.taskrow__time { font-size: var(--fs-xs); white-space: nowrap; }
.taskrow--empty { justify-content: center; padding: var(--sp-6); }

/* hero + dashboard responsive */
@media (max-width: 720px) {
  .hero { padding: var(--sp-5); }
  .hero__metrics { gap: var(--sp-5); }
  .stats--4 { grid-template-columns: repeat(2, 1fr); }
}
