/* AI Mail account console (/account): the signed-in app shell and its components
   (src/console/web.js, kit.js, overview.js, mail-pages.js, billing-pages.js, charts.js).
   Modelled on GoLive's console (golivemcp#64) in AI Mail's own brand.

   Loaded after /site.css (base tokens: --bg --panel --ink --muted --line --accent --action
   --code-bg --danger --ok) and before /connect.css (the sign-in card, body.auth). Everything
   here is scoped to the console (body.console-body, .console, .app): the public site header
   (.top, src/http/siteHeader.js) is never styled from this file.

   Brand: the site's Indigo tokens (/site.css: --brand, --brand-ink, --brand-soft, --accent,
   --action, --teal; light and dark) are used as they are. The console adds only what the site
   does not have: --brand-strong (indigo text on --brand-soft), --accent-soft (= --brand-soft),
   and a text-safe teal secondary (--brand-2-ink, --brand-2-soft) next to --brand-2 (= --teal).
   Nothing here names the brand indigo itself.

   Rules: no inline style anywhere (CSP style-src 'self'); motion 150 to 220 ms, transform and
   opacity only, and nothing moves under prefers-reduced-motion; every interactive element has a
   visible focus ring; tap targets are at least 44 px on touch screens. */
:root {
  --brand-strong: color-mix(in srgb, var(--brand) 86%, #000); --accent-soft: var(--brand-soft);
  --brand-2: var(--teal); --brand-2-ink: #0f766e; --brand-2-soft: #e6f7f4;
  --bg2: #efeef6; --hover: color-mix(in srgb, var(--ink) 6%, transparent);
  --radius: 14px; --shadow: 0 1px 2px rgba(22, 24, 29, .04), 0 8px 24px rgba(22, 24, 29, .06);
  --shadow-pop: 0 16px 40px -12px rgba(15, 12, 50, .28);
  --ok-c: #15803d; --ok-soft: #e7f6ec; --warn-c: #a15c07; --warn-soft: #fdf3e1; --bad-c: #b4232a; --bad-soft: #fdecec;
  --info-c: #1d4ed8; --info-soft: #e8efff;
  --side-w: 256px; --side-w-collapsed: 76px; --side-bg: var(--panel);
  --field-bg: var(--panel); --focus: color-mix(in srgb, var(--brand) 70%, transparent);
  --ease: cubic-bezier(.2, .8, .2, 1); --t-fast: 150ms; --t: 200ms;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --brand-strong: var(--brand); --brand-2-ink: #5eead4; --brand-2-soft: #123330; --bg2: #121127; --hover: color-mix(in srgb, var(--ink) 8%, transparent);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35); --shadow-pop: 0 18px 44px -12px rgba(0, 0, 0, .6);
    --ok-c: #4ade80; --ok-soft: #10301f; --warn-c: #f6c453; --warn-soft: #30260f; --bad-c: #ff8a8a; --bad-soft: #3a1518;
    --info-c: #93c5fd; --info-soft: #12203a; --side-bg: #12112a; --field-bg: #100f24;
  }
}
:root[data-theme=dark] {
  --brand-strong: var(--brand); --brand-2-ink: #5eead4; --brand-2-soft: #123330; --bg2: #121127; --hover: color-mix(in srgb, var(--ink) 8%, transparent);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35); --shadow-pop: 0 18px 44px -12px rgba(0, 0, 0, .6);
  --ok-c: #4ade80; --ok-soft: #10301f; --warn-c: #f6c453; --warn-soft: #30260f; --bad-c: #ff8a8a; --bad-soft: #3a1518;
  --info-c: #93c5fd; --info-soft: #12203a; --side-bg: #12112a; --field-bg: #100f24;
}

/* ── shell ─────────────────────────────────────────────────────────────────────────── */
body.console-body { margin: 0; background: var(--bg); overflow-x: hidden; }
.console-body .sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.console-body :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; padding: 10px 14px; border-radius: 10px; background: var(--ink); color: var(--bg); font-weight: 650; transition: transform var(--t-fast) var(--ease); }
.skip:focus { transform: translateY(72px); text-decoration: none; }
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.app.is-collapsed { grid-template-columns: var(--side-w-collapsed) minmax(0, 1fr); }
.app-main { min-width: 0; display: flex; flex-direction: column; }
main.console.page { width: 100%; max-width: 1180px; margin: 0 auto; padding: 32px 32px 56px; outline: none; flex: 1; animation: page-in 180ms var(--ease) backwards; }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@view-transition { navigation: auto; }
::view-transition-old(root) { animation-duration: 150ms; }
::view-transition-new(root) { animation-duration: 180ms; }

/* Sidebar */
.side { position: sticky; top: 0; align-self: start; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: 14px; padding: 16px 12px; background: var(--side-bg); border-right: 1px solid var(--line); z-index: 40; overflow-y: auto; outline: none; }
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; padding: 0 4px; }
.console-body .side-brand { font-size: 1.02rem; white-space: nowrap; overflow: hidden; color: var(--ink); text-decoration: none; }
.console-body .brand .logo { border-radius: 7px; flex: none; }
.console-body .brand .wordmark span { color: var(--brand); }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; flex: none; text-decoration: none; padding: 0; transition: transform var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease); }
.icon-btn:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.icon-btn:active { transform: scale(.94); }
.icon-btn .ico { width: 20px; height: 20px; }
.side-close { display: none; }
.side-toggle:not([hidden]) { display: inline-grid; }

/* Account switcher card and user card (<details> menus; /console.js closes them on outside
   click and Escape). */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.acct, .user { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); min-height: 52px; transition: border-color var(--t-fast) var(--ease); }
.menu > summary.acct:hover, .menu > summary.user:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.acct-tile, .avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; flex: none; font-weight: 750; font-size: .92rem; background: var(--brand); color: var(--brand-ink); }
.acct-tile.small { width: 26px; height: 26px; font-size: .8rem; border-radius: 8px; }
.avatar { border-radius: 50%; background: var(--brand-soft); color: var(--brand-strong); }
.acct-text, .user-text { display: grid; min-width: 0; flex: 1; gap: 1px; text-align: left; }
.acct-name { font-weight: 700; font-size: .93rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-sub { font-size: .76rem; color: var(--muted); }
.acct-chev { width: 16px; height: 16px; color: var(--muted); flex: none; }
.user-email { font-size: .84rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-chip { justify-self: start; display: inline-block; font-size: .68rem; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; background: var(--bg2); color: var(--muted); line-height: 1.5; vertical-align: middle; }
.role-chip.role-owner { background: var(--brand-soft); color: var(--brand-strong); }
.role-chip.role-admin { background: var(--brand-2-soft); color: var(--brand-2-ink); }
.menu-pop { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 50; padding: 6px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-pop); animation: pop-in 160ms var(--ease) both; transform-origin: top; min-width: 220px; }
.menu.up .menu-pop { top: auto; bottom: calc(100% + 6px); transform-origin: bottom; }
.menu-pop form { margin: 0; }
.menu-head { padding: 6px 8px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-label { margin: 4px 8px 6px; font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.menu-head .menu-label { margin: 0 0 2px; }
.menu-email { margin: 0; font-weight: 650; font-size: .9rem; overflow-wrap: anywhere; }
.menu-acct { margin: 2px 0 0; font-size: .82rem; color: var(--muted); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 10px; border-radius: 10px; border: 0; background: none; color: var(--ink); font: inherit; font-size: .92rem; font-weight: 550; text-align: left; text-decoration: none; cursor: pointer; }
.menu-item:hover { background: var(--hover); text-decoration: none; }
.menu-item .ico { width: 18px; height: 18px; color: var(--muted); flex: none; }
.menu-item.signout:hover { color: var(--bad-c); }
.menu-item.signout:hover .ico { color: var(--bad-c); }
.menu-item-text { display: grid; min-width: 0; }
.menu-item-text .small { font-size: .78rem; }
@keyframes pop-in { from { opacity: 0; transform: scale(.97) translateY(-4px); } to { opacity: 1; transform: none; } }

/* Nav: groups, icon + label, a tinted active pill, badges. */
.side-nav { display: grid; gap: 14px; }
.nav-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav-group-label { margin: 0 0 4px; padding: 0 12px; font-size: .7rem; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.nav-link { position: relative; display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 8px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 560; font-size: .94rem; white-space: nowrap; transition: transform var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease); }
.nav-link .ico { width: 19px; height: 19px; flex: none; }
.nav-link:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.nav-link:active { transform: scale(.98); }
.nav-link[aria-current="page"] { background: var(--brand-soft); color: var(--brand-strong); font-weight: 680; }
.nav-link[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.nav-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-badge { margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center; font-size: .72rem; font-weight: 750; background: var(--bg2); color: var(--ink); font-variant-numeric: tabular-nums; }
.nav-badge.warn { background: var(--warn-soft); color: var(--warn-c); }
.nav-badge.bad { background: var(--bad-c); color: var(--panel); }
.side-bottom { margin-top: auto; }

/* Collapsed: icons only; labels stay for screen readers (title and aria-label). */
@media (min-width: 901px) {
  .app.is-collapsed .nav-text, .app.is-collapsed .nav-group-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .app.is-collapsed .side { padding: 16px 10px; }
  .app.is-collapsed .side-top { flex-direction: column; padding: 0; }
  .app.is-collapsed .nav-link { justify-content: center; padding: 8px; }
  .app.is-collapsed .nav-badge { position: absolute; top: 2px; right: 4px; min-width: 18px; height: 16px; font-size: .64rem; }
  .app.is-collapsed .nav-link[aria-current="page"]::before { left: -10px; }
  .app.is-collapsed .acct, .app.is-collapsed .user { justify-content: center; padding: 8px 0; border-color: transparent; background: transparent; }
  .app.is-collapsed .user .role-chip { display: none; }
  .app.is-collapsed .menu-pop { left: 0; right: auto; width: 250px; }
  .app.is-collapsed .side-toggle .ico { transform: scaleX(-1); }
}

/* Phones and tablets: a top bar; the sidebar becomes a drawer (menu button or :target). */
.mtop, .nav-scrim { display: none; }
.nav-progress { position: fixed; left: 0; top: 0; height: 3px; width: 100%; z-index: 90; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transform: scaleX(0); transform-origin: left; opacity: 0; pointer-events: none; }
html.is-navigating .nav-progress { opacity: 1; animation: nav-load 2.4s cubic-bezier(.1, .7, .2, 1) forwards; }
@keyframes nav-load { from { transform: scaleX(0); } to { transform: scaleX(.85); } }
@media (max-width: 900px) {
  .app, .app.is-collapsed { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); height: auto; transform: translateX(-105%); visibility: hidden; box-shadow: none; transition: transform var(--t) var(--ease), visibility 0s linear var(--t); padding-top: max(16px, env(safe-area-inset-top)); }
  .app.nav-open .side, .side:target { transform: none; visibility: visible; box-shadow: 24px 0 48px -24px rgba(0, 0, 0, .45); transition: transform var(--t) var(--ease), visibility 0s; }
  .side-toggle:not([hidden]) { display: none; }
  .side-close { display: inline-grid; }
  .nav-scrim { position: fixed; inset: 0; z-index: 35; background: rgba(8, 7, 30, .45); }
  .app.nav-open .nav-scrim, .side:target ~ .nav-scrim { display: block; animation: fade-in 180ms var(--ease) both; }
  .nav-link, .menu-item { min-height: 46px; }
  .mtop { display: flex; position: sticky; top: 0; z-index: 30; align-items: center; gap: 8px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); min-width: 0; }
  .mtop .icon-btn { width: 44px; height: 44px; }
  .mtop .brand { font-size: 1rem; min-width: 0; flex: none; text-decoration: none; color: var(--ink); }
  .mtop-acct { margin-left: auto; display: flex; align-items: center; gap: 6px; min-width: 0; }
  .mtop-name { font-size: .85rem; font-weight: 600; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  main.console.page { padding: 22px 16px 40px; }
}
@media (max-width: 420px) { .mtop .brand .wordmark { display: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ── page furniture ────────────────────────────────────────────────────────────────── */
.console h1, .console h2, .console h3 { color: var(--ink); }
.page-title { margin-bottom: 22px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; color: var(--muted); font-size: .88rem; font-weight: 600; min-height: 32px; }
.back-link .ico { width: 16px; height: 16px; }
.back-link:hover { color: var(--ink); }
.page-title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; }
.page-title-text { min-width: 0; }
main.console .page-title h1 { font-size: clamp(1.55rem, 2.6vw, 2rem); line-height: 1.15; margin: 0; letter-spacing: -.025em; overflow-wrap: anywhere; }
.page-title .lead { margin: 6px 0 0; color: var(--muted); }
.page-title .chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
main.console h2 { font-size: 1.05rem; margin: 0 0 12px; letter-spacing: -.01em; }
main.console h3 { font-size: 1rem; }
.panel, .console .card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin: 0 0 18px; box-shadow: var(--shadow); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head h2 { margin: 0 !important; }
.panel-note, .console .card > p.muted.small { margin: 14px 0 0; color: var(--muted); font-size: .86rem; line-height: 1.55; }
.panel.attention { border-color: color-mix(in srgb, var(--warn-c) 40%, var(--line)); }
.console .muted { color: var(--muted); }
.console .small, .console small { font-size: .86rem; }
.console .hint { color: var(--muted); font-size: .85rem; margin: 6px 0 0; }
.console code { overflow-wrap: anywhere; font-size: .86em; }

/* Buttons. Primary: indigo; ghost: outlined; quiet: text; danger and danger-ghost. */
.console .btn, .console button.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 9px 16px; border-radius: 11px; border: 1px solid transparent; background: var(--brand); color: var(--brand-ink); font: inherit; font-weight: 650; font-size: .94rem; line-height: 1.2; cursor: pointer; text-decoration: none; white-space: nowrap; transition: transform var(--t-fast) var(--ease), filter var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease); }
.console .btn:hover { text-decoration: none; filter: brightness(1.06); }
.console .btn:active { transform: scale(.97); }
.console .btn .ico { width: 17px; height: 17px; flex: none; }
.console .btn.ghost { background: var(--panel); color: var(--ink); border-color: var(--line); }
.console .btn.ghost:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); filter: none; }
.console .btn.quiet { background: transparent; color: var(--brand-strong); padding-left: 8px; padding-right: 8px; }
.console .btn.quiet:hover { background: var(--hover); filter: none; }
.console .btn.danger { background: var(--bad-c); color: var(--panel); }
.console .btn.danger-ghost { background: transparent; color: var(--bad-c); border-color: color-mix(in srgb, var(--bad-c) 35%, var(--line)); }
.console .btn.danger-ghost:hover { background: var(--bad-soft); filter: none; }
.console .btn.small { min-height: 36px; padding: 6px 12px; font-size: .86rem; border-radius: 10px; }
.console .btn.block { width: 100%; }
.console .btn.disabled { opacity: .4; pointer-events: none; }
@media (pointer: coarse) { .console .btn.small { min-height: 44px; } }
/* Plain buttons left in a form (the generic pages) look like the primary button. */
.console button:not(.btn):not(.menu-item):not(.icon-btn):not(.cx-btn):not(.pick) { font: inherit; font-weight: 650; min-height: 44px; padding: 9px 16px; border-radius: 11px; border: 0; background: var(--brand); color: var(--brand-ink); cursor: pointer; }
.console button.danger:not(.btn) { background: var(--bad-c); color: var(--panel); }

/* Chips. */
.console .chip { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; font-weight: 650; padding: 3px 9px; border-radius: 999px; background: var(--bg2); color: var(--muted); white-space: nowrap; line-height: 1.4; vertical-align: middle; }
.console .chip .ico { width: 13px; height: 13px; }
.console .chip.ok { background: var(--ok-soft); color: var(--ok-c); }
.console .chip.warn { background: var(--warn-soft); color: var(--warn-c); }
.console .chip.bad { background: var(--bad-soft); color: var(--bad-c); }
.console .chip.info { background: var(--info-soft); color: var(--info-c); }
.console .chip.accent { background: var(--brand-soft); color: var(--brand-strong); }
.console .t-warn { color: var(--warn-c); font-weight: 650; }

/* Notices. */
.console .notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; margin: 0 0 18px; border: 1px solid var(--line); background: var(--panel); }
.console .notice > .ico { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.console .notice p { margin: 0; }
.console .notice.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok-c) 30%, transparent); color: var(--ink); }
.console .notice.ok > .ico { color: var(--ok-c); }
.console .notice.err { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad-c) 35%, transparent); }
.console .notice.err > .ico { color: var(--bad-c); }
.console .notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn-c) 30%, transparent); }
.console .notice.warn > .ico { color: var(--warn-c); }
.console .ok { color: var(--ok-c); font-weight: 600; }
.console .err { color: var(--bad-c); font-weight: 600; }
.console p.warn { background: var(--warn-soft); padding: 10px 12px; border-radius: 10px; border-left: 3px solid var(--warn-c); }

/* The free-account callout. */
.callout { display: flex; gap: 16px; align-items: flex-start; padding: 18px 20px; margin: 0 0 18px; border-radius: var(--radius); border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--line)); background: linear-gradient(140deg, var(--brand-soft), var(--panel) 75%); box-shadow: var(--shadow); }
.callout-ico { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; flex: none; background: var(--brand); color: var(--brand-ink); }
.callout-ico .ico { width: 22px; height: 22px; }
.callout-body { min-width: 0; }
main.console .callout h2 { margin: 2px 0 6px; font-size: 1.1rem; }
.callout p { margin: 0 0 6px; }
.callout-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px !important; }

/* Empty states that teach. */
.empty-state { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 28px 16px; border: 1px dashed var(--line); border-radius: 14px; background: color-mix(in srgb, var(--bg2) 55%, transparent); }
.empty-state.compact { padding: 18px 14px; }
.empty-state .empty-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--panel); border: 1px solid var(--line); color: var(--brand); margin-bottom: 4px; }
.empty-state .empty-icon .ico { width: 22px; height: 22px; }
main.console .empty-state h3 { margin: 0; font-size: 1rem; }
.empty-state p { margin: 0 0 8px; color: var(--muted); max-width: 52ch; font-size: .92rem; }
.empty-line { color: var(--muted); margin: 0; }
.message-page { max-width: 560px; }
.confirm-card { max-width: 640px; }
.confirm-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
main.console .confirm-card-head h1, main.console .confirm-card-head h2 { margin: 0; font-size: 1.3rem; overflow-wrap: anywhere; }
.confirm-ico { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--bad-soft); color: var(--bad-c); flex: none; }
.confirm-ico .ico { width: 20px; height: 20px; }

/* ── overview ──────────────────────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi-card { position: relative; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; color: var(--ink); transition: transform var(--t) var(--ease), border-color var(--t) var(--ease); }
a.kpi-card:hover { text-decoration: none; border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); transform: translateY(-1px); }
.kpi-card.accent { background: linear-gradient(160deg, var(--brand-soft), var(--panel) 72%); }
.kpi-card.warn { border-color: color-mix(in srgb, var(--warn-c) 45%, var(--line)); }
.kpi-card.bad { border-color: color-mix(in srgb, var(--bad-c) 45%, var(--line)); }
.kpi-main { flex: 1; min-width: 0; }
.kpi-side { flex: none; }
.kpi-foot { flex: 1 1 100%; min-width: 0; }
.kpi-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .82rem; font-weight: 650; }
.kpi-ico { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--brand-soft); color: var(--brand-strong); flex: none; }
.kpi-ico .ico { width: 15px; height: 15px; }
.kpi-card.warn .kpi-ico { background: var(--warn-soft); color: var(--warn-c); }
.kpi-card.bad .kpi-ico { background: var(--bad-soft); color: var(--bad-c); }
.kpi-card.muted .kpi-ico { background: var(--bg2); color: var(--muted); }
.kpi-num { font-size: 1.7rem; font-weight: 760; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.2; margin: 8px 0 4px; overflow-wrap: anywhere; }
.kpi-sub { color: var(--muted); font-size: .82rem; line-height: 1.45; }
.kpi-sub strong { color: var(--ink); }
.kpi-cap { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); padding-top: 8px; border-top: 1px solid var(--line); }
.kpi-cap .ico { width: 14px; height: 14px; }
.kpi-cap strong { color: var(--ink); }
svg.ring { display: block; }
svg.ring .ring-track { fill: none; stroke: var(--bg2); }
svg.ring .ring-fill { fill: none; stroke: var(--brand); stroke-linecap: round; }
svg.ring.warn .ring-fill { stroke: var(--warn-c); }
svg.ring.bad .ring-fill { stroke: var(--bad-c); }
svg.ring .ring-text { fill: var(--ink); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
svg.pbar { display: block; width: 100%; height: 8px; margin: 6px 0 4px; }
svg.pbar .pbar-track { fill: var(--bg2); }
svg.pbar .pbar-fill { fill: var(--brand); }
svg.pbar.warn .pbar-fill { fill: var(--warn-c); }
svg.pbar.bad .pbar-fill { fill: var(--bad-c); }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; align-items: start; }
.dash-grid .span-2 { grid-column: 1 / -1; }
.chart-fig { margin: 0; }
.chart-cap { margin: 10px 0 0; color: var(--muted); font-size: .86rem; }
.todo-list, .feed, .steps-list { list-style: none; margin: 0; padding: 0; }
.todo-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.todo-list li:first-child { border-top: 0; padding-top: 0; }
.todo-ico, .feed-ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; flex: none; background: var(--warn-soft); color: var(--warn-c); }
.todo-ico .ico, .feed-ico .ico { width: 17px; height: 17px; }
.todo-text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.todo-title { font-weight: 650; overflow-wrap: anywhere; }
.feed li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.feed li:first-child { border-top: 0; padding-top: 0; }
.feed-ico.in { background: var(--brand-2-soft); color: var(--brand-2-ink); }
.feed-ico.out { background: var(--brand-soft); color: var(--brand-strong); }
.feed-main { min-width: 0; flex: 1; }
.feed-line { font-size: .92rem; overflow-wrap: anywhere; }
.feed-addr { color: var(--ink); }
.feed-meta { color: var(--muted); font-size: .82rem; margin-top: 2px; overflow-wrap: anywhere; }
.feed-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.feed-amt.plus { color: var(--ok-c); }
.steps-list { display: grid; gap: 14px; }
.steps-list li { display: flex; gap: 12px; align-items: flex-start; }
.steps-list p { margin: 2px 0 0; }
.step-dot { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; flex: none; background: var(--brand); color: var(--brand-ink); font-weight: 750; font-size: .85rem; }

/* key-value lists */
.console dl.kv { display: grid; grid-template-columns: minmax(130px, max-content) minmax(0, 1fr); gap: 8px 22px; margin: 0; }
.console dl.kv dt { color: var(--muted); }
.console dl.kv dd { margin: 0; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.console dl.kv.compact { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }

/* ── tables: zebra rows, hover, sticky header ──────────────────────────────────────── */
.table-wrap, .console .scroll { overflow-x: auto; margin: 0 -6px; padding: 0 6px; }
.console table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .92rem; }
.console table th { text-align: left; font-size: .74rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel); }
.console table.data th { position: sticky; top: 0; z-index: 1; }
.console table td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.console table tbody tr { transition: background-color var(--t-fast) var(--ease); }
.console table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--bg2) 45%, transparent); }
.console table tbody tr:hover { background: var(--hover); }
.console table tbody tr:last-child td { border-bottom: 0; }
.console table tr.attn td:first-child { box-shadow: inset 3px 0 0 var(--warn-c); }
.console th.num, .console td.num { text-align: right; font-variant-numeric: tabular-nums; }
.console tr.revoked td { color: var(--muted); }
.console tr.revoked .cell-title { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 55%, transparent); }
.cell-title { font-weight: 650; color: var(--ink); }
a.cell-title { color: var(--brand-strong); }
.console .cell-sub { display: block; }
.actions-cell { text-align: right; white-space: nowrap; }
.console td.wrap-any { white-space: normal; overflow-wrap: anywhere; min-width: 14em; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person .avatar, .app-tile { width: 32px; height: 32px; }
.app-tile { display: inline-grid; place-items: center; border-radius: 10px; background: var(--bg2); color: var(--ink); font-weight: 750; flex: none; }

/* in-page confirmation */
details.confirm { position: relative; display: inline-block; text-align: left; }
details.confirm > summary { list-style: none; }
details.confirm > summary::-webkit-details-marker { display: none; }
details.confirm[open] > summary { opacity: .55; }
.confirm-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 25; width: min(340px, calc(100vw - 32px)); padding: 14px; border-radius: 14px; background: var(--panel); border: 1px solid color-mix(in srgb, var(--bad-c) 35%, var(--line)); box-shadow: var(--shadow-pop); white-space: normal; animation: pop-in 160ms var(--ease) both; transform-origin: top right; }
.confirm-q { font-weight: 700; margin: 0 0 4px; overflow-wrap: anywhere; }
.confirm-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* drawers (Top up) */
.drawer { position: fixed; inset: 0; z-index: 60; display: none; }
.drawer:target, .drawer.is-open { display: block; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(8, 7, 30, .45); animation: fade-in 180ms var(--ease) both; }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(460px, 100%); display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); box-shadow: -24px 0 48px -24px rgba(0, 0, 0, .35); animation: drawer-in 200ms var(--ease) both; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
main.console .drawer-head h2 { margin: 0; font-size: 1.15rem; }
.drawer-body { padding: 18px 20px 28px; overflow-y: auto; }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 16px; }
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes sheet-up { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* forms */
.console form.stack { display: grid; gap: 14px; max-width: 560px; }
.console label { font-weight: 600; font-size: .9rem; display: grid; gap: 6px; }
.console label.radio { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 2px 0; min-height: 36px; flex-wrap: wrap; }
.console fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin: 0; }
.console legend { font-weight: 600; font-size: .9rem; padding: 0 4px; }
.console input[type=email], .console input:not([type]), .console input[type=text], .console input[type=number], .console select { font: inherit; min-height: 44px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--field-bg); color: var(--ink); max-width: 100%; transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease); }
.console input:focus-visible, .console select:focus-visible { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
.console input[type=number] { max-width: 12em; }
.console input[type=checkbox], .console input[type=radio] { accent-color: var(--brand); width: 18px; height: 18px; }
.console .row { display: flex; gap: 10px 14px; align-items: end; flex-wrap: wrap; justify-content: flex-start; }
.console form.row { align-items: center; }
.console form.row.tight { gap: 6px; flex-wrap: nowrap; }
.console .row.addr .at { padding-bottom: 12px; color: var(--muted); font-weight: 650; }
.console .row > label { min-width: 0; }
.console .add-row { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); align-items: end; }
.console .fwd-form input { min-width: 14em; }
.console .decide-row { margin-top: 14px; gap: 10px; }
.console blockquote { margin: 8px 0 12px; padding: 10px 14px; border-left: 3px solid var(--line); background: var(--bg2); border-radius: 0 10px 10px 0; overflow-wrap: anywhere; }
.console section.setting .panel-head { margin-bottom: 8px; }
.console .disclosure { padding: 0; }
.console .disclosure > summary { cursor: pointer; padding: 16px 22px; font-weight: 650; min-height: 44px; }
.console .disclosure[open] > summary { border-bottom: 1px solid var(--line); }
.console .disclosure > .table-wrap { padding: 8px 22px 16px; margin: 0; }

/* keys */
.console .reveal { border-color: var(--brand); }
.reveal-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
main.console .reveal-head h2 { margin: 0; }
.keybox { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.keybox code { flex: 1 1 320px; word-break: break-all; padding: 12px 14px; background: var(--code-bg); border-radius: 10px; font-size: .9rem; user-select: all; }

/* billing */
.bill-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; align-items: start; }
.panel.balance { background: linear-gradient(150deg, var(--brand-soft), var(--panel) 65%); }
.big-num { font-size: 2.4rem; font-weight: 780; letter-spacing: -.035em; font-variant-numeric: tabular-nums; line-height: 1.1; margin: 2px 0 8px; }
.big-num.muted-num { color: var(--muted); font-size: 1.8rem; }
.limit-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.limit-row p { margin: 2px 0 0; }
.limit-val { font-weight: 760; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.limit-meter { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.limit-meter-text { flex: 1; min-width: 0; }
.limit-meter-text p { margin: 0; }

/* ── usage analytics (src/console/charts.js): server-rendered SVG, colours from here ── */
.console .month-nav { display: flex; align-items: center; gap: 8px; }
.console .month-label { min-width: 9em; text-align: center; font-variant-numeric: tabular-nums; }
.console .kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.console .kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.console .kpi.warn { border-color: color-mix(in srgb, var(--warn-c) 45%, var(--line)); }
.console .kpi .kpi-label { font-size: .82rem; }
.console .kpi-value { font-size: 1.6rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.25; margin: 4px 0; overflow-wrap: anywhere; }
.console .delta { display: inline-block; font-size: .8rem; font-weight: 650; color: var(--muted); margin-bottom: 2px; }
.console .delta.up { color: var(--ink); }
.console svg.meter { display: block; width: 100%; height: 8px; border-radius: 4px; margin: 4px 0 6px; overflow: hidden; }
.console svg .track { fill: var(--bg2); }
.console svg.meter .fill, .console svg.hbar .fill { fill: var(--brand); }
.console svg.meter.warn .fill { fill: var(--warn-c); }
.console svg.meter.bad .fill { fill: var(--bad-c); }
.console .usage-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.console .usage-grid > .kpis, .console .usage-grid > .card.wide { grid-column: 1 / -1; }
.console .card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 14px; flex-wrap: wrap; margin-bottom: 12px; }
.console .card-head h2 { margin: 0; }
.console nav.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; background: var(--bg2); border-radius: 10px; padding: 3px; }
.console nav.seg a { text-decoration: none; font-size: .85rem; padding: 6px 10px; border-radius: 8px; color: var(--muted); white-space: nowrap; }
.console nav.seg a:hover { color: var(--ink); }
.console nav.seg a[aria-current] { background: var(--panel); color: var(--ink); font-weight: 650; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.console .chart-wrap { position: relative; }
.console svg.chart { display: block; width: 100%; height: auto; font-family: inherit; }
.console svg.chart .grid { stroke: var(--line); stroke-width: 1; }
.console svg.chart .grid.base { stroke: color-mix(in srgb, var(--muted) 45%, var(--line)); }
.console svg.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.console svg.chart .axis-title { fill: var(--muted); font-size: 11.5px; font-weight: 600; }
.console svg.chart .bar { fill: var(--brand); }
.console svg.chart .bar.stack { fill: color-mix(in srgb, var(--brand) 38%, var(--panel)); }
.console svg.chart .line { fill: none; stroke: var(--brand-2-ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.console svg.chart .dot { fill: var(--brand-2-ink); stroke: var(--panel); stroke-width: 1.5; }
.console svg.chart .hit { fill: transparent; }
.console svg.chart .hit:hover { fill: color-mix(in srgb, var(--ink) 6%, transparent); }
.console .chart-wrap.is-empty svg.chart { opacity: .5; }
.console .chart-empty { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); width: min(88%, 440px); margin: 0; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: 12px; padding: 12px 16px; font-size: .9rem; }
.console p.empty { color: var(--muted); background: var(--bg2); border-radius: 10px; padding: 14px 16px; margin: 0; font-size: .92rem; }
.console table.bars td.name { white-space: nowrap; max-width: 14em; overflow: hidden; text-overflow: ellipsis; }
.console table.bars td.measure { width: 42%; min-width: 96px; }
.console table.bars td.measure span { display: block; font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 2px; white-space: nowrap; }
.console svg.hbar { display: block; width: 100%; height: 8px; border-radius: 4px; overflow: hidden; }
.console td.t-muted { color: var(--muted); }
.console td.t-warn { color: var(--warn-c); font-weight: 600; }
.console td.t-bad { color: var(--bad-c); font-weight: 600; }
.console table.rich td { white-space: nowrap; }
.console table.rich td:nth-child(3) { white-space: normal; overflow-wrap: anywhere; min-width: 10em; }
.console .pill { display: inline-block; font-size: .78rem; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: var(--bg2); color: var(--muted); }
.console .pill.t-ok { background: var(--ok-soft); color: var(--ok-c); }
.console .pill.t-info { background: var(--info-soft); color: var(--info-c); }
.console .pill.t-warn { background: var(--warn-soft); color: var(--warn-c); }
.console .pill.t-bad { background: var(--bad-soft); color: var(--bad-c); }

/* footer: links to the legal pages (src/http/legal.js) */
.console-foot { text-align: center; padding: 20px 16px 28px; }
body.auth .console-foot { padding: 12px 0 0; }

/* ── responsive ────────────────────────────────────────────────────────────────────── */
@media (max-width: 1180px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .dash-grid, .bill-grid, .console .usage-grid { grid-template-columns: minmax(0, 1fr); } .console .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) {
  .kpi-grid, .kpi-grid.three { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .kpi-card { padding: 14px; }
  .kpi-num { font-size: 1.45rem; }
  .panel, .console .card { padding: 16px 14px; }
  .page-title-row { align-items: flex-start; }
  .page-actions { width: 100%; }
  .page-actions > .btn { flex: 1; }
  .page-actions .month-nav { flex: 1 1 100%; }
  .console .month-label { min-width: 0; flex: 1; }
  .big-num { font-size: 2rem; }
  .callout { flex-direction: column; padding: 16px; }
  .console dl.kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .console dl.kv dd { margin-bottom: 8px; }
  /* Data tables become stacked rows: each cell on its own line, the header hidden. */
  .console table.data thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .console table.data, .console table.data tbody, .console table.data tr, .console table.data td { display: block; width: 100%; }
  .console table.data tr { padding: 12px 4px; border-bottom: 1px solid var(--line); }
  .console table.data tbody tr:last-child { border-bottom: 0; }
  .console table.data td { padding: 3px 0; border: 0; text-align: left; white-space: normal; overflow-wrap: anywhere; }
  .console table.data td.num { text-align: left; }
  .console table.data td:empty { display: none; }
  .console table.data td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 8.5em; margin-right: 8px; color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
  .console table.data td[data-label]:first-child::before { display: none; }
  .actions-cell { padding-top: 8px !important; }
  .console form.row.tight { flex-wrap: wrap; }
  .console .fwd-form input { min-width: 0; width: 100%; }
  .confirm-pop { left: 0; right: auto; transform-origin: top left; }
  .drawer-panel { top: auto; left: 0; width: 100%; max-height: 92dvh; border-left: 0; border-top: 1px solid var(--line); border-radius: 20px 20px 0 0; animation-name: sheet-up; }
  .console .chart-wrap { overflow-x: auto; }
  .console svg.chart { min-width: 560px; }
  .console table.bars { font-size: .86rem; }
  .console table.bars th, .console table.bars td { padding: 8px 4px; }
  .console table.bars td.name { max-width: 7.5em; }
  .console table.bars td.measure { min-width: 64px; width: 30%; }
  .console table.bars td.measure span { white-space: normal; }
  .console .row.addr .at { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  main.console.page, .menu-pop, .drawer-panel, .drawer-backdrop, .confirm-pop, .nav-scrim { animation: none !important; }
  .side { transition: none !important; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; }
  a.kpi-card:hover, .console .btn:active, .nav-link:active, .icon-btn:active { transform: none; }
  html.is-navigating .nav-progress { animation: none; transform: scaleX(.5); }
}

/* The sidebar's column runs the full page height (the sidebar itself is sticky). */
@media (min-width: 901px) {
  .app { background: linear-gradient(90deg, var(--side-bg) calc(var(--side-w) - 1px), var(--line) calc(var(--side-w) - 1px), var(--line) var(--side-w), transparent var(--side-w)); }
  .app.is-collapsed { background: linear-gradient(90deg, var(--side-bg) calc(var(--side-w-collapsed) - 1px), var(--line) calc(var(--side-w-collapsed) - 1px), var(--line) var(--side-w-collapsed), transparent var(--side-w-collapsed)); }
}
main.console a:not(.btn):not(.kpi-card) { color: var(--brand-strong); }
@media (max-width: 560px) { .todo-list li { flex-wrap: wrap; } .todo-text { flex-basis: calc(100% - 46px); } .todo-list li > .btn { margin-left: 46px; } }
