/* Staff console — one stylesheet, no build step, light and dark.
   Accent #4c1d95 matches the Service Manager card in the Apps Portal. */

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  color-scheme: light;
  --font: "Sarabun", "Noto Sans Thai", "Leelawadee UI", -apple-system, BlinkMacSystemFont,
          "Tahoma", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --bg: #f5f4f8;
  --surface: #ffffff;
  --surface-2: #faf9fc;
  --sunken: #f0eef5;
  --ink: #1c1a24;
  --ink-2: #4a4657;
  --muted: #6e6a7c;
  --line: #e6e3ee;
  --line-strong: #d5d0e0;

  --accent: #4c1d95;
  --accent-hover: #3b1574;
  --accent-ink: #ffffff;
  --accent-text: #5b21b6;
  --accent-soft: #efe9fb;
  --accent-soft-2: #e2d7f7;
  --ring: #7c3aed;

  --row-hover: #f6f2fd;
  --zebra: #fbfafd;

  --ok-bg: #e3f5ea;   --ok-fg: #17663a;
  --info-bg: #e5eefc; --info-fg: #1d4f9c;
  --warn-bg: #fdf1dc; --warn-fg: #8a5300;
  --bad-bg: #fde6e6;  --bad-fg: #a61b1b;
  --neutral-bg: #eeedf2; --neutral-fg: #4a4657;
  --danger: #b42318;

  --sidebar-bg: #1f0f43;
  --sidebar-ink: #e9e3f7;
  --sidebar-muted: #a99bc9;
  --sidebar-hover: rgba(255, 255, 255, .07);
  --sidebar-on: rgba(255, 255, 255, .13);

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(28, 16, 60, .06);
  --shadow: 0 1px 2px rgba(28, 16, 60, .05), 0 4px 16px rgba(28, 16, 60, .06);
  --shadow-lg: 0 10px 40px rgba(28, 16, 60, .14);

  --fs-xs: 12px; --fs-sm: 13px; --fs-base: 15px; --fs-md: 17px;
  --fs-lg: 22px; --fs-xl: 28px;
  --sidebar-w: 248px;
  --gutter: 28px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121118;
    --surface: #1a1922;
    --surface-2: #1e1d27;
    --sunken: #15141c;
    --ink: #ecebf2;
    --ink-2: #c5c2d2;
    --muted: #9792a8;
    --line: #2b2937;
    --line-strong: #3a3748;

    --accent: #7c3aed;
    --accent-hover: #8b5cf6;
    --accent-ink: #ffffff;
    --accent-text: #c4b5fd;
    --accent-soft: #2a2140;
    --accent-soft-2: #362a55;
    --ring: #a78bfa;

    --row-hover: #241f33;
    --zebra: #1d1c25;

    --ok-bg: #12301f;   --ok-fg: #86dcaa;
    --info-bg: #142540; --info-fg: #9cc2f7;
    --warn-bg: #352610; --warn-fg: #f3c27a;
    --bad-bg: #3a1618;  --bad-fg: #f5a3a3;
    --neutral-bg: #262431; --neutral-fg: #c5c2d2;
    --danger: #f19999;

    --sidebar-bg: #15101f;
    --sidebar-ink: #e3dcf3;
    --sidebar-muted: #8f84aa;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, .5);
  }
}

/* ── Base ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: var(--fs-base)/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1 { font-size: var(--fs-xl); line-height: 1.2; font-weight: 700; letter-spacing: -.01em; margin: 0; }
h2 { font-size: var(--fs-md); line-height: 1.3; font-weight: 650; margin: 0; }
p { margin: 0 0 10px; }
code { font-family: var(--mono); font-size: .9em; background: var(--sunken);
       padding: 1px 6px; border-radius: 6px; }
svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor;
      stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 4px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 12px; top: -60px; z-index: 50;
  background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: var(--radius-sm);
}
.skip:focus { top: 12px; }

/* ── App shell ──────────────────────────────────────────────────────────── */
.app {
  display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--sidebar-bg); color: var(--sidebar-ink);
  display: flex; flex-direction: column;
  background-image: radial-gradient(120% 60% at 0% 0%, rgba(124, 58, 237, .28), transparent 60%);
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 16px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, #7c3aed, #4c1d95);
  color: #fff; font-weight: 800; font-size: 14px; letter-spacing: .02em;
  box-shadow: 0 2px 8px rgba(76, 29, 149, .45), inset 0 1px 0 rgba(255, 255, 255, .2);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: var(--fs-xs); color: var(--sidebar-muted); }
.nav-button { display: none; }

.nav { padding: 4px 10px 20px; display: flex; flex-direction: column; gap: 14px; }
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-heading {
  margin: 0 0 4px; padding: 0 10px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--sidebar-muted);
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--sidebar-ink); font-size: 14px; opacity: .88;
}
.nav-link svg { width: 17px; height: 17px; opacity: .8; }
.nav-link:hover { background: var(--sidebar-hover); text-decoration: none; opacity: 1; }
.nav-link.on {
  background: var(--sidebar-on); opacity: 1; font-weight: 600;
  box-shadow: inset 3px 0 0 #a78bfa;
}
.nav-link:focus-visible { outline-color: #c4b5fd; }

.main-col { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  min-height: 60px; padding: 10px var(--gutter);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topsearch {
  position: relative; display: flex; align-items: center; gap: 6px;
  flex: 1 1 auto; max-width: 520px;
}
.topsearch svg { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.topsearch input[type="search"] { flex: 1; min-width: 0; padding-left: 36px; }

.who { display: flex; align-items: center; gap: 10px; margin-left: auto; min-width: 0; }
.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-soft-2); color: var(--accent-text); font-weight: 700; font-size: 14px;
}
.who-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.who-name { font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role {
  align-self: flex-start; margin-top: 2px;
  background: var(--accent-soft); color: var(--accent-text);
  padding: 0 7px; border-radius: 99px; font-size: 11px; font-weight: 600;
}
.who form { margin: 0; }

main { padding: 26px var(--gutter) 40px; width: 100%; max-width: 1400px; }
.readonly-note {
  margin-top: 32px; padding-top: 14px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: var(--fs-xs);
}

/* ── Controls ───────────────────────────────────────────────────────────── */
input, button { font: inherit; color: inherit; }
input[type="search"], input[type="text"], input[type="password"], input:not([type]) {
  width: 100%; padding: 9px 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--muted); opacity: .85; }
input:focus { outline: none; border-color: var(--ring);
              box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 22%, transparent); }

.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid var(--accent); font-weight: 600; font-size: 14px; line-height: 1.2;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover, button:hover { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; }
.btn:focus-visible, button:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.btn-ghost {
  background: var(--surface); color: var(--ink-2); border-color: var(--line-strong);
}
.btn-ghost:hover { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-soft-2); }
.btn-quiet { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.btn-quiet:hover { background: var(--accent-soft-2); border-color: transparent; }
.btn-sm { padding: 6px 11px; font-size: var(--fs-sm); }
.btn-block { width: 100%; padding: 11px 16px; }
.btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }

/* Prominent search */
.bigsearch {
  position: relative; display: flex; align-items: center; gap: 10px;
  margin: 18px 0 22px; max-width: 760px;
}
.bigsearch > svg {
  position: absolute; left: 16px; width: 20px; height: 20px;
  color: var(--muted); pointer-events: none;
}
.bigsearch input[type="search"] {
  flex: 1; min-width: 0; padding: 13px 16px 13px 46px;
  font-size: var(--fs-md); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.bigsearch .btn { padding: 13px 22px; border-radius: var(--radius); font-size: 15px; }
.bigsearch.compact { margin: 14px 0 16px; max-width: 640px; }
.bigsearch.compact input[type="search"] { padding: 10px 14px 10px 42px; font-size: var(--fs-base); }
.bigsearch.compact > svg { left: 14px; width: 18px; height: 18px; }
.bigsearch.compact .btn { padding: 10px 18px; }

.busy {
  position: absolute; right: 120px; width: 16px; height: 16px;
  border: 2px solid var(--accent-soft-2); border-top-color: var(--accent-text);
  border-radius: 50%; opacity: 0; transition: opacity .15s;
  animation: spin .8s linear infinite;
}
.busy.htmx-request { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Page headings ──────────────────────────────────────────────────────── */
.page-head { margin-bottom: 4px; }
.page-head h1 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.lead { color: var(--muted); font-size: var(--fs-md); margin: 6px 0 0; }
.crumb { color: var(--muted); font-size: var(--fs-sm); margin: 0 0 6px; }
.crumb-id { font-family: var(--mono); font-size: var(--fs-xs); overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: var(--fs-sm); margin: 6px 0 18px; }
.section-title {
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin: 26px 0 10px;
}
.filters { color: var(--muted); font-size: var(--fs-sm); margin: -6px 0 14px; display: flex; gap: 8px; align-items: center; }

/* Index hero */
.hero {
  position: relative; overflow: hidden;
  padding: 28px 28px 8px; margin-bottom: 8px;
  border-radius: 16px; border: 1px solid var(--line);
  background:
    radial-gradient(90% 140% at 100% 0%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%),
    var(--surface);
  box-shadow: var(--shadow);
}
.hero .bigsearch { margin-bottom: 24px; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.card.count {
  display: flex; flex-direction: column; gap: 2px; color: var(--ink);
  position: relative; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.card.count::after {
  content: "→"; position: absolute; right: 16px; top: 16px;
  color: var(--muted); opacity: 0; transition: opacity .15s, transform .15s;
}
.card.count:hover {
  border-color: var(--accent-soft-2); box-shadow: var(--shadow);
  transform: translateY(-1px); text-decoration: none;
}
.card.count:hover::after { opacity: 1; transform: translateX(2px); }
.card.count .n {
  font-size: 26px; font-weight: 700; letter-spacing: -.01em;
  font-variant-numeric: tabular-nums; color: var(--accent-text);
}
.card.count .l { color: var(--ink-2); font-size: var(--fs-sm); font-weight: 500; }

/* ── Panels & tables ────────────────────────────────────────────────────── */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  margin-bottom: 16px; min-width: 0;
}
.panel.group { padding: 16px 18px; }
.panel.flush { overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; flex-wrap: wrap; }
.panel.group > .table-wrap { margin: 0 -18px -16px; border-top: 1px solid var(--line); }

.badge {
  display: inline-flex; align-items: center;
  background: var(--accent-soft); color: var(--accent-text);
  border-radius: 99px; padding: 1px 9px; font-size: var(--fs-xs); font-weight: 650;
  font-variant-numeric: tabular-nums; letter-spacing: 0;
}
.badge-lg { font-size: var(--fs-sm); padding: 2px 11px; }
.more { margin-left: auto; font-size: var(--fs-sm); font-weight: 500; }

.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; }
.table-wrap.tall { max-height: calc(100vh - 250px); }

table.data { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; }
.data th, .data td {
  text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap; max-width: 380px; overflow: hidden; text-overflow: ellipsis;
  vertical-align: middle;
}
.data th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2);
  color: var(--muted); font-weight: 650; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--line-strong);
}
.data th a { color: inherit; display: inline-flex; align-items: center; gap: 2px; }
.data th a:hover { color: var(--accent-text); text-decoration: none; }
.data th.sorted, .data th.sorted a { color: var(--accent-text); }
.sort-icon { opacity: .55; font-size: 10px; }
.data th.sorted .sort-icon { opacity: 1; }
.data tbody tr:nth-child(even) td { background: var(--zebra); }
.data tbody tr:last-child td { border-bottom: 0; }
.data tbody tr[onclick] { cursor: pointer; }
.data tbody tr:hover td { background: var(--row-hover); }
.data td.primary a { font-weight: 600; }
.data td.num, .data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data td { font-variant-numeric: tabular-nums; }
.dash { color: var(--muted); opacity: .7; }
.masked { font-family: var(--mono); font-size: .9em; color: var(--muted); letter-spacing: .02em; }

/* Status pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px 2px 8px; border-radius: 99px;
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.5;
  background: var(--neutral-bg); color: var(--neutral-fg);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.pill-ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill-info { background: var(--info-bg); color: var(--info-fg); }
.pill-warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill-bad { background: var(--bad-bg); color: var(--bad-fg); }

/* Pager */
.pager {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-top: 1px solid var(--line); background: var(--surface-2);
}
.pager-pos { color: var(--muted); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }

/* ── Record detail ──────────────────────────────────────────────────────── */
.fields {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0 28px; margin: 0;
}
.field {
  display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: 12px;
  padding: 8px 0; border-bottom: 1px dashed var(--line);
}
.fields dt { color: var(--muted); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.fields dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.chip {
  background: var(--accent-soft); color: var(--accent-text);
  border-radius: 99px; padding: 2px 11px; font-size: var(--fs-sm); font-weight: 500;
}

/* ── Empty / error states ───────────────────────────────────────────────── */
.state {
  display: flex; gap: 16px; align-items: flex-start;
  padding: 26px 24px; margin: 8px 0 16px;
  background: var(--surface); border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}
.state-icon {
  width: 42px; height: 42px; padding: 10px; flex: none;
  border-radius: 12px; background: var(--accent-soft); color: var(--accent-text);
  stroke-width: 2;
}
.state-body { min-width: 0; }
.state-body h1 { font-size: var(--fs-lg); margin: 6px 0 8px; }
.state-body > :last-child { margin-bottom: 0; }
.state .empty { margin: 8px 0 4px; }
.empty { color: var(--muted); }
.hint { color: var(--muted); font-size: var(--fs-sm); }
.error {
  color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: var(--fs-sm); margin: 0;
}

/* ── Login ──────────────────────────────────────────────────────────────── */
body.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background:
    radial-gradient(60% 50% at 15% 10%, rgba(124, 58, 237, .30), transparent 70%),
    radial-gradient(50% 50% at 90% 90%, rgba(76, 29, 149, .35), transparent 70%),
    var(--sidebar-bg);
}
.login-wrap { width: 100%; max-width: 380px; }
.login {
  display: flex; flex-direction: column; gap: 16px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 30px 28px 24px; box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.login-brand .brand-mark { width: 44px; height: 44px; font-size: 16px; border-radius: 12px; }
.login h1 { font-size: 20px; }
.login .sub { color: var(--muted); margin: 0; font-size: var(--fs-sm); }
.login label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2);
}
.login input { padding: 11px 12px; }
.login .btn { margin-top: 4px; }
.login-note {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 2px 0 0; color: var(--muted); font-size: var(--fs-xs);
}
.login-note svg { width: 14px; height: 14px; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
/* ── Service Usage report (/staff/reports/usage) ─────────────────────────── */
.report-form {
  display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap;
  padding: 14px 16px; margin: 18px 0 10px;
}
.report-field { display: flex; flex-direction: column; gap: 5px; font-size: var(--fs-sm); color: var(--muted); font-weight: 600; }
.report-field.grow { flex: 1 1 260px; min-width: 0; }
.report-field select {
  font: inherit; font-weight: 500; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 8px 10px; min-width: 180px; max-width: 100%;
}
.report-field select:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.asof { margin: 0 0 18px; font-size: var(--fs-sm); color: var(--muted); }
.asof summary { cursor: pointer; }
.asof strong { color: var(--ink); }
.asof-table { max-width: 420px; margin-top: 8px; }
.report-title { font-size: var(--fs-lg); margin: 6px 0 14px; }
.report-title .meta { font-size: var(--fs-sm); font-weight: 500; margin: 0 0 0 6px; }
.report-stats { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.card.stat { display: flex; flex-direction: column; gap: 4px; }
.card.stat .l { color: var(--muted); font-size: var(--fs-sm); font-weight: 600; }
.card.stat .n { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent-text); }
.card.stat .sub { color: var(--muted); font-size: var(--fs-sm); }
.neg, .card.stat .n.neg { color: var(--danger); }
.report-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 18px 0 6px; }
.seg { display: inline-flex; gap: 4px; margin-left: auto; }
.seg .on { pointer-events: none; }
.data th.num { text-align: right; }
.report-frame-wrap {
  background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 12px 0 18px; overflow-x: auto;
}
.report-frame {
  display: block; width: 100%; max-width: 860px; min-width: 640px; height: 80vh; margin: 0 auto;
  border: 0; border-radius: 4px; background: #fff; box-shadow: var(--shadow-lg);
}
.report-frame-wrap.wide .report-frame { max-width: 1180px; }

/* ── Home: Service Usage first ──────────────────────────────────────────── */
.eyebrow {
  margin: 0 0 4px; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--accent-text);
}
.usage-hero { padding-bottom: 22px; }
.usage-hero h1 { margin: 0; }
.hero-form {
  display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap;
  margin: 20px 0 10px; max-width: 900px;
}
.btn-lg { padding: 10px 22px; font-size: var(--fs-base); }
.hero-asof { margin: 6px 0 0; }
.hero-asof strong { color: var(--ink); }
.nav-link.nav-primary { font-weight: 600; opacity: 1; }

.glance { margin: 22px 0 8px; }
.glance-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.glance-head h2 { font-size: var(--fs-md); margin: 0; }
.glance-head a { font-size: var(--fs-sm); font-weight: 600; }
.glance-loading {
  display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: var(--fs-sm);
  padding: 22px 18px; border: 1px dashed var(--line-strong); border-radius: var(--radius);
}
.spinner {
  width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 2px solid var(--accent-soft-2); border-top-color: var(--accent-text);
  animation: spin .8s linear infinite;
}
.glance-stats { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: 12px; }
.card.stat.tone-bad .n { color: var(--danger); }
.card.stat.tone-warn .n { color: var(--warn-fg); }
.glance-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 12px; }
.glance-panel { padding: 14px 16px; margin: 0; }
.glance-panel h3 {
  margin: 0 0 8px; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.glance-panel .empty { margin: 4px 0; }
.glance-list { list-style: none; margin: 0; padding: 0; }
.glance-list li {
  display: flex; align-items: center; gap: 10px; padding: 7px 0;
  border-top: 1px solid var(--line); font-size: var(--fs-sm);
}
.glance-list li:first-child { border-top: 0; }
.glance-list li > a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.glance-list li > a b { color: var(--accent-text); }
.glance-list .meta { margin: 0; }
.glance-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.glance-list.bars li > a { flex: 0 0 96px; }
.bar { flex: 1; height: 8px; border-radius: 99px; background: var(--sunken); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.browse { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 6px 22px; margin-top: 10px; }
.browse-title {
  margin: 14px 0 8px; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.compact-cards { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.compact-cards .card { padding: 10px 12px; }
.compact-cards .card.count .n { font-size: 19px; }
.compact-cards .card.count::after { display: none; }

@media (max-width: 1100px) {
  :root { --gutter: 22px; }
}

@media (max-width: 860px) {
  .glance-grid { grid-template-columns: minmax(0, 1fr); }
  :root { --gutter: 16px; }
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar {
    position: sticky; top: 0; z-index: 20; height: auto; max-height: 100vh;
    overflow: visible;
  }
  .sidebar-head { padding: 10px 16px; }
  .brand-mark { width: 32px; height: 32px; font-size: 13px; }
  .nav-button {
    display: inline-grid; place-items: center; width: 40px; height: 40px;
    border-radius: var(--radius-sm); cursor: pointer; color: #fff;
  }
  .nav-button:hover { background: var(--sidebar-hover); }
  .nav-toggle:focus-visible ~ .sidebar .nav-button { outline: 2px solid #c4b5fd; }
  .nav {
    display: none; max-height: calc(100vh - 60px); overflow-y: auto;
    padding: 4px 12px 16px; border-top: 1px solid rgba(255, 255, 255, .08);
  }
  .nav-toggle:checked ~ .sidebar .nav { display: flex; }
  .topbar { position: static; padding: 10px var(--gutter); flex-wrap: wrap; gap: 10px; }
  .topsearch { order: 2; flex-basis: 100%; max-width: none; }
  .who { margin-left: 0; width: 100%; }
  .who form { margin-left: auto; }
  main { padding-top: 20px; }
}

@media (max-width: 560px) {
  .seg { margin-left: 0; }
  .hero-form .btn { width: 100%; }
  .glance-list.bars li > a { flex-basis: 76px; }
  .report-field select { min-width: 0; width: 100%; }
  .report-field { width: 100%; }
  h1 { font-size: 23px; }
  .hero { padding: 20px 16px 4px; border-radius: var(--radius); }
  .bigsearch { flex-wrap: wrap; }
  .bigsearch .btn { width: 100%; }
  .bigsearch > svg { top: 14px; }
  .bigsearch.compact > svg { top: 12px; }
  .busy { right: 14px; top: 15px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { padding: 14px; }
  .card.count .n { font-size: 22px; }
  .panel.group { padding: 14px; }
  .panel.group > .table-wrap { margin: 0 -14px -14px; }
  .field { grid-template-columns: 1fr; gap: 2px; }
  .state { flex-direction: column; padding: 20px 16px; }
  .data th, .data td { padding: 9px 12px; max-width: 240px; }
  .pager { flex-wrap: wrap; justify-content: center; }
  .who-text .role { display: none; }
}

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