/*
 * Station UI — shared stylesheet of the account center and the product sites (chat, ...).
 * Spec: docs/ui-style.md. Served by the account center at /assets/ui.css (no CDN, no web fonts).
 *
 * This file is the single source: product sites copy it unchanged and keep only their own
 * layout in a separate file (chat: frontend/src/styles/app.css). Shared components
 * (menus, dialogs, drawers, toasts, ...) belong here, not in a product's file.
 *
 * Rules: use the variables below, never raw colours or sizes in pages. Every colour pair
 * used for text was checked against WCAG AA (4.5:1 text, 3:1 UI boundaries) in both themes.
 * Dynamic sizes / colours: JS sets a CSS variable (el.style.setProperty('--x', …)), never a
 * style attribute — see "CSP 与动态样式" in the spec.
 */

/* ------------------------------------------------------------------ tokens: light (default) */
:root {
  color-scheme: light dark;

  /* colour */
  --c-bg: #f5f6f8;            /* page background */
  --c-surface: #ffffff;       /* cards, inputs */
  --c-surface-2: #f0f2f5;     /* table heads, quiet panels, hover rows */
  --c-text: #171a1f;          /* body text */
  --c-text-2: #4f5663;        /* secondary text, labels */
  --c-text-3: #636a77;        /* hints, placeholders, captions */
  --c-border: #e2e5ea;        /* dividers, card outlines */
  --c-border-strong: #8b929e; /* input outlines (>= 3:1 on surface) */
  --c-primary: #2952cc;       /* links, focus, selected */
  --c-primary-soft: #eef2fd;  /* selected backgrounds, info alert */
  --c-primary-solid: #2952cc; /* primary button */
  --c-primary-solid-hover: #2145b0;
  --c-primary-solid-active: #1b3a94;
  --c-on-primary: #ffffff;
  --c-accent: #a84f08;        /* sparing highlights: expiring soon, "new" */
  --c-accent-soft: #fff4e5;
  --c-success: #18794e;
  --c-success-soft: #ecf8f1;
  --c-success-border: #b5e3c9;
  --c-warning: #8f5400;
  --c-warning-soft: #fff7e6;
  --c-warning-border: #f3d49b;
  --c-danger: #c22f2f;
  --c-danger-soft: #fdeeee;
  --c-danger-border: #f3c0c0;
  --c-focus: #2952cc;
  --c-overlay: rgba(23, 26, 31, 0.04);
  --c-scrim: rgba(23, 26, 31, 0.4);  /* behind dialogs and drawers */

  /* type */
  --font-sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans CJK SC", "Source Han Sans SC", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;   /* body */
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 24px;
  --fs-3xl: 36px;  /* hero numbers */
  --lh-tight: 1.25;
  --lh-normal: 1.5;
  --lh-relaxed: 1.7;
  --fw-normal: 400;
  --fw-medium: 500;
  --fw-semibold: 600;

  /* space (4px grid) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  /* shape */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 999px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 1px 3px rgba(16, 24, 40, 0.08), 0 4px 12px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 8px 28px rgba(16, 24, 40, 0.12);
  --focus-ring: 0 0 0 3px color-mix(in srgb, var(--c-focus) 35%, transparent);

  /* sizes */
  --control-h: 40px;
  --control-h-sm: 32px;
  --content-w: 960px;
  --auth-w: 400px;
  --console-w: 1280px;   /* admin consoles */
  --duration: 120ms;
}

/* ------------------------------------------------------------------ tokens: dark */
@media (prefers-color-scheme: dark) {
  :root {
    --c-bg: #0e1014;
    --c-surface: #161920;
    --c-surface-2: #1d2129;
    --c-text: #e7e9ee;
    --c-text-2: #b0b6c2;
    --c-text-3: #8d94a1;
    --c-border: #2a2f39;
    --c-border-strong: #6b7380;
    --c-primary: #8aa6ff;
    --c-primary-soft: #1a2340;
    --c-primary-solid: #3d64e0;
    --c-primary-solid-hover: #3256c8;
    --c-primary-solid-active: #2a4ab0;
    --c-on-primary: #ffffff;
    --c-accent: #f0a54a;
    --c-accent-soft: #2b2113;
    --c-success: #4cc38a;
    --c-success-soft: #11251b;
    --c-success-border: #1f4d36;
    --c-warning: #e6b04d;
    --c-warning-soft: #2a2112;
    --c-warning-border: #5a4520;
    --c-danger: #f07575;
    --c-danger-soft: #2c1517;
    --c-danger-border: #5c2a2d;
    --c-focus: #8aa6ff;
    --c-overlay: rgba(255, 255, 255, 0.04);
    --c-scrim: rgba(0, 0, 0, 0.6);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.55);
  }
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: var(--lh-tight); font-weight: var(--fw-semibold); }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
p { margin: 0; }
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; border-radius: var(--radius-sm); }
code, .mono { font-family: var(--font-mono); font-size: 0.95em; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--c-text-2); }
.subtle { color: var(--c-text-3); font-size: var(--fs-sm); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: var(--sp-4); top: -100px; z-index: 10; }
.skip-link:focus { top: var(--sp-3); background: var(--c-surface); padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md); }
[hidden] { display: none !important; }
svg.icon { width: 16px; height: 16px; flex: none; vertical-align: -3px; }

/* ------------------------------------------------------------------ layout */
.app-header {
  position: relative; z-index: 30;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}
.app-header__inner {
  max-width: var(--content-w); margin: 0 auto; padding: 0 var(--sp-5);
  height: 56px; display: flex; align-items: center; gap: var(--sp-4);
}
/* Full-width header for app shells (chat): content spans the whole window. */
.app-header--app { flex: none; }
.app-header--app .app-header__inner { max-width: none; padding: 0 var(--sp-4); }
.brand { display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--c-text);
  font-weight: var(--fw-semibold); font-size: var(--fs-lg); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand__mark { width: 28px; height: 28px; border-radius: var(--radius-md); background: var(--c-primary-solid);
  color: var(--c-on-primary); display: inline-grid; place-items: center; }
.brand__mark svg { width: 16px; height: 16px; }
.container { max-width: var(--content-w); margin: 0 auto; padding: var(--sp-6) var(--sp-5) var(--sp-8); }
.page-title { margin-bottom: var(--sp-5); }
.page-title p { margin-top: var(--sp-1); color: var(--c-text-2); }
.stack { display: grid; gap: var(--sp-5); }
.grid-2 { display: grid; gap: var(--sp-5); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: var(--sp-1) var(--sp-3);
  margin-bottom: var(--sp-4); }
.section-head p { color: var(--c-text-3); font-size: var(--fs-sm); }
section[id] { scroll-margin-top: var(--sp-4); }  /* landing on /#section leaves a little air above */

/* ------------------------------------------------------------------ card */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-5);
  min-width: 0;
}
.card.card--flush { padding: 0; overflow: hidden; }
.card__head { padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: var(--control-h); padding: 0 var(--sp-4);
  border: 1px solid transparent; border-radius: var(--radius-md);
  font: inherit; font-weight: var(--fw-medium); line-height: 1; white-space: nowrap;
  cursor: pointer; text-decoration: none;
  transition: background-color var(--duration), border-color var(--duration), color var(--duration),
    box-shadow var(--duration);
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn--primary { background: var(--c-primary-solid); color: var(--c-on-primary); }
.btn--primary:hover { background: var(--c-primary-solid-hover); }
.btn--primary:active { background: var(--c-primary-solid-active); }
.btn--secondary { background: var(--c-surface); color: var(--c-text); border-color: var(--c-border-strong); }
.btn--secondary:hover { background: var(--c-surface-2); }
.btn--ghost { background: transparent; color: var(--c-text-2); }
.btn--ghost:hover { background: var(--c-surface-2); color: var(--c-text); }
.btn--danger { background: var(--c-surface); color: var(--c-danger); border-color: var(--c-danger-border); }
.btn--danger:hover { background: var(--c-danger-soft); }
.btn--block { width: 100%; }
.btn--sm { height: var(--control-h-sm); padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; opacity: 1; }
.btn[aria-busy="true"]::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ form fields */
.form { display: grid; gap: var(--sp-4); }
.field { display: grid; gap: var(--sp-2); }
.label { font-weight: var(--fw-medium); color: var(--c-text); font-size: var(--fs-md); }
.input {
  width: 100%; height: var(--control-h); padding: 0 var(--sp-3);
  background: var(--c-surface); color: var(--c-text);
  border: 1px solid var(--c-border-strong); border-radius: var(--radius-md);
  font: inherit; transition: border-color var(--duration), box-shadow var(--duration);
}
.input::placeholder { color: var(--c-text-3); opacity: 1; }
.input:hover { border-color: var(--c-text-2); }
.input:focus { outline: none; border-color: var(--c-focus); box-shadow: var(--focus-ring); }
.input:disabled { background: var(--c-surface-2); color: var(--c-text-3); cursor: not-allowed; }
.input[aria-invalid="true"] { border-color: var(--c-danger); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-danger) 30%, transparent); }
.input--code { font-family: var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; }
.input--code::placeholder { text-transform: none; letter-spacing: normal; font-family: var(--font-sans); }
.field-hint { color: var(--c-text-3); font-size: var(--fs-sm); }
.field-error { color: var(--c-danger); font-size: var(--fs-sm); display: flex; gap: var(--sp-1); align-items: flex-start; }
.field-error:empty { display: none; }
.inline-form { display: flex; gap: var(--sp-3); align-items: flex-start; }
.inline-form .field { flex: 1; min-width: 0; }

/* ------------------------------------------------------------------ alerts */
.alert {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-3) var(--sp-4); border-radius: var(--radius-md); border: 1px solid;
  font-size: var(--fs-md);
}
.alert svg.icon { margin-top: 2px; }
.alert--info { background: var(--c-primary-soft); border-color: color-mix(in srgb, var(--c-primary) 30%, transparent);
  color: var(--c-text); }
.alert--info svg.icon { color: var(--c-primary); }
.alert--success { background: var(--c-success-soft); border-color: var(--c-success-border); color: var(--c-text); }
.alert--success svg.icon { color: var(--c-success); }
.alert--warning { background: var(--c-warning-soft); border-color: var(--c-warning-border); color: var(--c-text); }
.alert--warning svg.icon { color: var(--c-warning); }
.alert--danger { background: var(--c-danger-soft); border-color: var(--c-danger-border); color: var(--c-text); }
.alert--danger svg.icon { color: var(--c-danger); }
.alert:empty { display: none; }

/* ------------------------------------------------------------------ tags */
.tag {
  display: inline-flex; align-items: center; height: 22px; padding: 0 var(--sp-2);
  border-radius: var(--radius-full); font-size: var(--fs-xs); font-weight: var(--fw-medium);
  background: var(--c-surface-2); color: var(--c-text-2); border: 1px solid var(--c-border); white-space: nowrap;
}
.tag--primary { background: var(--c-primary-soft); color: var(--c-primary); border-color: transparent; }
.tag--success { background: var(--c-success-soft); color: var(--c-success); border-color: transparent; }
.tag--warning { background: var(--c-warning-soft); color: var(--c-warning); border-color: transparent; }
.tag--danger { background: var(--c-danger-soft); color: var(--c-danger); border-color: transparent; }
.tag--accent { background: var(--c-accent-soft); color: var(--c-accent); border-color: transparent; }
.tags { display: flex; flex-wrap: wrap; gap: var(--sp-1); }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
.table th {
  text-align: left; font-weight: var(--fw-medium); color: var(--c-text-2); font-size: var(--fs-sm);
  background: var(--c-surface-2); padding: var(--sp-2) var(--sp-4); white-space: nowrap;
  border-bottom: 1px solid var(--c-border);
}
.table td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--c-border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--c-overlay); }
.table th.num, .table td.num { text-align: right; }
.cell-stack { display: grid; gap: var(--sp-1); }

/* Narrow screens: every row becomes a small card (label from data-label). */
@media (max-width: 640px) {
  .table--stack thead { display: none; }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
  .table--stack tr { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--c-border); }
  .table--stack tr:last-child { border-bottom: 0; }
  .table--stack td { border: 0; padding: var(--sp-1) 0; display: flex; justify-content: space-between;
    gap: var(--sp-4); text-align: right; }
  .table--stack td::before { content: attr(data-label); color: var(--c-text-3); text-align: left; flex: none; }
  .table--stack td.num { text-align: right; }
  .table--stack .cell-stack { justify-items: end; }
  .table--stack tbody tr:hover td { background: none; }
}

/* ------------------------------------------------------------------ tabs */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--c-border); padding: 0 var(--sp-3);
  overflow-x: auto; }
.tab {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent;
  padding: var(--sp-3) var(--sp-3); margin-bottom: -1px; font: inherit; color: var(--c-text-2);
  cursor: pointer; white-space: nowrap; display: inline-flex; gap: var(--sp-2); align-items: center;
}
.tab:hover { color: var(--c-text); }
.tab[aria-selected="true"] { color: var(--c-primary); border-bottom-color: var(--c-primary);
  font-weight: var(--fw-medium); }
.tab:focus-visible { outline-offset: -2px; }
.tab__count { font-size: var(--fs-xs); color: var(--c-text-3); background: var(--c-surface-2);
  border-radius: var(--radius-full); padding: 0 var(--sp-2); line-height: 18px; }
.tab-panel:focus-visible { outline-offset: -2px; }

/* ------------------------------------------------------------------ icon button */
.icon-btn {
  display: inline-grid; place-items: center; width: var(--control-h-sm); height: var(--control-h-sm); flex: none;
  border: 0; border-radius: var(--radius-md); background: transparent; color: var(--c-text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--c-surface-2); color: var(--c-text); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.icon-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ------------------------------------------------------------------ select */
.select {
  height: var(--control-h-sm); padding: 0 var(--sp-6) 0 var(--sp-3); max-width: 100%;
  background: var(--c-surface); color: var(--c-text); font: inherit; font-size: var(--fs-sm);
  border: 1px solid var(--c-border-strong); border-radius: var(--radius-md); cursor: pointer;
}
.select:hover { border-color: var(--c-text-2); }
.select:focus { outline: none; border-color: var(--c-focus); box-shadow: var(--focus-ring); }
.select:disabled { background: var(--c-surface-2); color: var(--c-text-3); cursor: not-allowed; }
select.input { padding-right: var(--sp-6); }

/* ------------------------------------------------------------------ spinner */
.spinner {
  width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite;
}
.spinner--lg { width: 24px; height: 24px; }

/* ------------------------------------------------------------------ segmented control */
/* Pick one of a few options (e.g. tiers). Selected: aria-pressed; not available: aria-disabled
   (stays clickable so it can explain why). */
.segmented {
  display: inline-flex; gap: 2px; padding: 2px; flex: none;
  background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: var(--radius-md);
}
.segmented__item {
  display: inline-flex; align-items: center; gap: var(--sp-1); height: 26px; padding: 0 var(--sp-3);
  border: 0; border-radius: var(--radius-sm); background: transparent; cursor: pointer;
  font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--c-text-2);
}
.segmented__item:hover { color: var(--c-text); }
.segmented__item[aria-pressed="true"] { background: var(--c-surface); color: var(--c-primary); box-shadow: var(--shadow-sm); }
.segmented__item[aria-disabled="true"] { color: var(--c-text-3); opacity: 0.6; cursor: not-allowed; }
.segmented__item[aria-disabled="true"]:hover { color: var(--c-text-3); }
.segmented__item:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.segmented__item .icon { width: 12px; height: 12px; }

/* ------------------------------------------------------------------ dropdown menu */
.menu {
  position: absolute; right: 0; top: calc(100% + var(--sp-1)); z-index: 50; min-width: 248px;
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: var(--sp-1);
}
.menu__head { padding: var(--sp-3) var(--sp-3) var(--sp-2); }
.menu__head .stat__value { font-size: var(--fs-xl); margin-top: var(--sp-1); }
.menu__head .stat__label { font-size: var(--fs-sm); }
.menu__head .stat__meta { margin-top: var(--sp-1); }
.menu__sep { height: 1px; background: var(--c-border); margin: var(--sp-1) 0; border: 0; }
.menu__item {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%; height: var(--control-h);
  padding: 0 var(--sp-3); border: 0; border-radius: var(--radius-md); background: none;
  font: inherit; color: var(--c-text); text-align: left; cursor: pointer; text-decoration: none;
}
.menu__item:hover, .menu__item:focus-visible { background: var(--c-surface-2); text-decoration: none; }
.menu__item:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.menu__item .icon { color: var(--c-text-2); }
.menu__item-meta { margin-left: auto; color: var(--c-text-3); font-size: var(--fs-xs); }

/* Account menu: right end of the header, trigger shows the credit balance. */
.account-menu { position: relative; margin-left: auto; }
.account-menu__trigger { gap: var(--sp-2); padding: 0 var(--sp-3); }
.account-menu__balance { font-variant-numeric: tabular-nums; color: var(--c-text); font-weight: var(--fw-medium); }
.account-menu__trigger[aria-expanded="true"] { background: var(--c-surface-2); color: var(--c-text); }

/* ------------------------------------------------------------------ pager */
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--c-border); color: var(--c-text-2); font-size: var(--fs-sm); }
.pager__buttons { display: flex; gap: var(--sp-2); align-items: center; }

/* ------------------------------------------------------------------ dialog / drawer */
.scrim { position: fixed; inset: 0; z-index: 60; background: var(--c-scrim); }
.modal-layer { position: fixed; inset: 0; z-index: 61; display: grid; place-items: center; padding: var(--sp-4); }
.modal {
  width: min(480px, 100%); max-height: calc(100dvh - var(--sp-6)); overflow-y: auto;
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.modal:focus { outline: none; }
.modal__head { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-5) var(--sp-5) 0; }
.modal__titles { flex: 1; min-width: 0; }
.modal__head p { margin-top: var(--sp-1); color: var(--c-text-2); font-size: var(--fs-sm); }
.modal__body { padding: var(--sp-4) var(--sp-5); display: grid; gap: var(--sp-4); }
.modal__foot { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: 0 var(--sp-5) var(--sp-5); }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61; width: min(440px, 100%);
  display: flex; flex-direction: column; background: var(--c-surface); border-left: 1px solid var(--c-border);
  box-shadow: var(--shadow-lg);
}
.drawer:focus { outline: none; }
.drawer__head { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--c-border); }
.drawer__head > div { flex: 1; min-width: 0; }
.drawer__head p { color: var(--c-text-3); font-size: var(--fs-sm); margin-top: var(--sp-1); overflow-wrap: anywhere; }
.drawer__body { flex: 1; overflow-y: auto; padding: var(--sp-5); display: grid; gap: var(--sp-4); align-content: start; }
.drawer__foot { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--c-border); }

/* ------------------------------------------------------------------ toast (floating, short feedback) */
.toasts { position: fixed; right: var(--sp-4); bottom: var(--sp-4); z-index: 70; display: grid; gap: var(--sp-2);
  width: min(380px, calc(100vw - var(--sp-6))); pointer-events: none; }
.toasts > [role] { display: grid; gap: var(--sp-2); }
.toast { box-shadow: var(--shadow-md); align-items: flex-start; pointer-events: auto; }
.toast__body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.toast__title { font-weight: var(--fw-medium); }
.toast .icon-btn { width: 24px; height: 24px; margin: -2px -4px 0 0; }

/* ------------------------------------------------------------------ empty state */
.empty { text-align: center; padding: var(--sp-7) var(--sp-5); color: var(--c-text-2); }
.empty__icon { width: 40px; height: 40px; margin: 0 auto var(--sp-3); border-radius: var(--radius-full);
  background: var(--c-surface-2); color: var(--c-text-3); display: grid; place-items: center; }
.empty__icon svg { width: 20px; height: 20px; }
.empty__title { color: var(--c-text); font-weight: var(--fw-medium); margin-bottom: var(--sp-1); }
.empty--compact { padding: var(--sp-5); }

/* ------------------------------------------------------------------ stat (big number) */
.stat__label { color: var(--c-text-2); font-size: var(--fs-md); }
.stat__value { font-size: var(--fs-3xl); font-weight: var(--fw-semibold); line-height: 1.1;
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em; margin-top: var(--sp-2); word-break: break-all; }
.stat__unit { font-size: var(--fs-lg); color: var(--c-text-2); font-weight: var(--fw-normal); margin-left: var(--sp-1); }
.stat__meta { margin-top: var(--sp-3); color: var(--c-text-3); font-size: var(--fs-sm); }

/* ------------------------------------------------------------------ description list */
.dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--sp-2) var(--sp-5); margin: 0; }
.dl dt { color: var(--c-text-2); }
.dl dd { margin: 0; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ product list */
.products { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.product {
  border: 1px solid var(--c-border); border-radius: var(--radius-md); padding: var(--sp-4);
  display: grid; gap: var(--sp-3); align-content: start; background: var(--c-surface);
}
.product__head { display: flex; align-items: center; gap: var(--sp-3); justify-content: space-between; }
.product__title { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.product__icon { width: 28px; height: 28px; flex: none; border-radius: var(--radius-md); display: inline-grid;
  place-items: center; background: var(--c-primary-soft); color: var(--c-primary); }
.product__name { font-weight: var(--fw-semibold); overflow-wrap: anywhere; }
.product__tiers { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; font-size: var(--fs-sm);
  color: var(--c-text-3); }
.product__tier-names { color: var(--c-text); font-weight: var(--fw-medium); }

/* ------------------------------------------------------------------ auth pages */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: var(--sp-6) var(--sp-4);
}
.auth__box { width: 100%; max-width: var(--auth-w); }
.auth__brand { display: flex; justify-content: center; margin-bottom: var(--sp-5); }
.auth__card { padding: var(--sp-6); box-shadow: var(--shadow-md); }
.auth__title { text-align: center; margin-bottom: var(--sp-2); }
.auth__lead { text-align: center; color: var(--c-text-2); margin-bottom: var(--sp-5); }
.auth__switch { text-align: center; margin-top: var(--sp-5); color: var(--c-text-2); }
.auth__foot { text-align: center; margin-top: var(--sp-5); color: var(--c-text-3); font-size: var(--fs-sm); }

/* ------------------------------------------------------------------ error page */
.error-page { text-align: center; }
.error-page__code { font-size: var(--fs-3xl); font-weight: var(--fw-semibold); color: var(--c-text-3);
  font-variant-numeric: tabular-nums; margin-bottom: var(--sp-3); }
.error-page .auth__title { margin-bottom: var(--sp-3); }
.error-page p, .auth__lead, .empty p { text-wrap: balance; }
.error-page__actions { display: flex; justify-content: center; gap: var(--sp-3); margin-top: var(--sp-5);
  flex-wrap: wrap; }

/* ------------------------------------------------------------------ console (admin back offices) */
/* Shared by the account center's /admin pages and the chat site's console, so both look like one product. */
.container--console { max-width: var(--console-w); }
.app-header--console .app-header__inner { max-width: var(--console-w); }
.subnav { background: var(--c-surface); border-bottom: 1px solid var(--c-border); flex: none; }
.subnav__inner { max-width: var(--console-w); margin: 0 auto; padding: 0 var(--sp-5); display: flex; gap: var(--sp-1);
  overflow-x: auto; }
.subnav__link {
  display: inline-flex; align-items: center; gap: var(--sp-2); height: 44px; padding: 0 var(--sp-3); flex: none;
  border: 0; border-bottom: 2px solid transparent; background: none; font: inherit; color: var(--c-text-2);
  cursor: pointer; white-space: nowrap; text-decoration: none;
}
.subnav__link:hover { color: var(--c-text); text-decoration: none; }
.subnav__link[aria-current="page"] { color: var(--c-primary); border-bottom-color: var(--c-primary);
  font-weight: var(--fw-medium); }
.subnav__link:focus-visible { outline-offset: -2px; }
.subnav__count { font-size: var(--fs-xs); border-radius: var(--radius-full); padding: 0 var(--sp-2); line-height: 18px;
  background: var(--c-warning-soft); color: var(--c-warning); font-variant-numeric: tabular-nums; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap;
  margin-bottom: var(--sp-5); }
.page-head p { margin-top: var(--sp-1); color: var(--c-text-2); }
.page-head__crumb { font-size: var(--fs-sm); margin-bottom: var(--sp-2); }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.stat-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.stat--sm .stat__value { font-size: var(--fs-2xl); word-break: normal; }
.stat--sm .stat__label { font-size: var(--fs-sm); }
.stat--sm .stat__meta { margin-top: var(--sp-2); }
.toolbar { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: flex-end; padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--c-border); }
.toolbar .field { flex: 0 1 180px; min-width: 140px; gap: var(--sp-1); }
.toolbar .field--grow { flex: 1 1 240px; }
.toolbar .label { font-size: var(--fs-sm); font-weight: var(--fw-normal); color: var(--c-text-2); }
.toolbar .input { height: var(--control-h-sm); font-size: var(--fs-sm); }
.toolbar .btn { height: var(--control-h-sm); font-size: var(--fs-sm); padding: 0 var(--sp-3); }
.toolbar__note { margin-left: auto; align-self: center; color: var(--c-text-3); font-size: var(--fs-sm); }
textarea.input { height: auto; min-height: 72px; padding: var(--sp-2) var(--sp-3); line-height: var(--lh-normal);
  resize: vertical; }
.cell-actions { text-align: right; white-space: nowrap; }
.cell-actions .btn + .btn { margin-left: var(--sp-1); }
.table--actions td { vertical-align: middle; padding-top: var(--sp-2); padding-bottom: var(--sp-2); }
.mono-id { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--c-text-2); }
.summary { background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4); }
.secret { font-family: var(--font-mono); font-size: var(--fs-lg); padding: var(--sp-3) var(--sp-4);
  background: var(--c-surface-2); border: 1px dashed var(--c-border-strong); border-radius: var(--radius-md);
  user-select: all; overflow-wrap: anywhere; text-align: center; }
.modal--wide { width: min(640px, 100%); }
.rows { display: grid; gap: var(--sp-2); }
.rows__item { display: grid; grid-template-columns: 120px minmax(0, 1fr) minmax(0, 1fr) auto; gap: var(--sp-2);
  align-items: center; }
.chain { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: stretch; list-style: none; margin: 0; padding: 0; }
.chain__step { border: 1px solid var(--c-border); border-radius: var(--radius-md); padding: var(--sp-2) var(--sp-3);
  display: grid; gap: 2px; align-content: start; min-width: 160px; background: var(--c-surface); }
.chain__arrow { align-self: center; color: var(--c-text-3); }
.note { color: var(--c-text-3); font-size: var(--fs-sm); padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--c-border); }
.card__body { padding: var(--sp-4) var(--sp-5); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 768px) {
  .app-header--app .app-header__inner { padding: 0 var(--sp-3); gap: var(--sp-2); }
  .app-header--app .brand__name { display: none; }
  .account-menu__trigger > .icon:first-child, .account-menu__label { display: none; }
  .account-menu__trigger { padding: 0 var(--sp-2); gap: var(--sp-1); }
  .account-menu .menu { position: fixed; top: 60px; left: var(--sp-3); right: var(--sp-3); min-width: 0; }
}

@media (max-width: 640px) {
  .container { padding: var(--sp-5) var(--sp-4) var(--sp-7); }
  .app-header__inner { padding: 0 var(--sp-4); gap: var(--sp-3); }
  .modal__head { padding: var(--sp-4) var(--sp-4) 0; }
  .modal__body { padding: var(--sp-3) var(--sp-4); }
  .modal__foot { padding: 0 var(--sp-4) var(--sp-4); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .card { padding: var(--sp-4); }
  .card__head { padding: var(--sp-3) var(--sp-4); }
  .auth__card { padding: var(--sp-5); }
  .inline-form { flex-direction: column; align-items: stretch; }
  .stat__value { font-size: 32px; }
  .tabs { padding: 0 var(--sp-2); }
  .tab { padding: var(--sp-3) var(--sp-2); }
  .subnav__inner { padding: 0 var(--sp-2); }
  .toolbar { padding: var(--sp-3) var(--sp-4); }
  .toolbar .field, .toolbar .field--grow { flex: 1 1 100%; }
  .toolbar__note { margin-left: 0; }
  .table--stack td.cell-actions { justify-content: flex-end; }
  .table--stack td.cell-actions::before { content: none; }
  .rows__item { grid-template-columns: minmax(0, 1fr); }
  .note, .card__body { padding: var(--sp-3) var(--sp-4); }
}

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