/* Operator console. Dark glass by default, a light theme on [data-theme="light"].
   Only system fonts: nothing is fetched from outside. */

:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --brand: #5641D6;
  --radius: 16px;
  --radius-sm: 10px;
  --ease: cubic-bezier(.2, .8, .2, 1);

  --bg: #08071A;
  --bg-2: #0F0C2B;
  --glass: rgba(255, 255, 255, .045);
  --glass-2: rgba(255, 255, 255, .075);
  --glass-solid: rgba(20, 17, 48, .92);
  /* Cards on a phone: solid, as blur behind every card costs a phone's battery and frames. */
  --card-solid: #141133;
  --line: rgba(255, 255, 255, .085);
  --line-2: rgba(255, 255, 255, .16);
  --ink: #EEEDFB;
  --muted: #A3A0C7;
  --faint: #8582AD;
  --accent: #8B7BFF;
  --accent-ink: #fff;
  --accent-soft: rgba(139, 123, 255, .16);
  --teal: #2ED3B7;
  --teal-soft: rgba(46, 211, 183, .14);
  --warn: #F7B955;
  --warn-soft: rgba(247, 185, 85, .14);
  --bad: #FF6B85;
  --bad-soft: rgba(255, 107, 133, .14);
  --shadow: 0 10px 40px -12px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .05);
  --glow: 0 0 0 1px rgba(139, 123, 255, .35), 0 8px 30px -6px rgba(86, 65, 214, .55);
  --orb-a: rgba(86, 65, 214, .55);
  --orb-b: rgba(46, 211, 183, .28);
  --orb-c: rgba(140, 60, 220, .3);
  --skeleton: rgba(255, 255, 255, .06);
  --skeleton-hi: rgba(255, 255, 255, .13);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #F3F2FB;
  --bg-2: #ECEAFA;
  --glass: rgba(255, 255, 255, .66);
  --glass-2: rgba(255, 255, 255, .85);
  --glass-solid: rgba(255, 255, 255, .96);
  --card-solid: #FFFFFF;
  --line: rgba(30, 20, 99, .09);
  --line-2: rgba(30, 20, 99, .18);
  --ink: #15142A;
  --muted: #5D5B78;
  --faint: #6E6B8A;
  --accent: #5641D6;
  --accent-soft: rgba(86, 65, 214, .1);
  --teal: #08705F;
  --teal-soft: rgba(12, 154, 130, .12);
  --warn: #8A5600;
  --warn-soft: rgba(214, 140, 0, .13);
  --bad: #C8323F;
  --bad-soft: rgba(200, 50, 63, .1);
  --shadow: 0 10px 30px -14px rgba(30, 20, 99, .25), inset 0 1px 0 rgba(255, 255, 255, .8);
  --glow: 0 0 0 1px rgba(86, 65, 214, .3), 0 8px 24px -8px rgba(86, 65, 214, .4);
  --orb-a: rgba(86, 65, 214, .22);
  --orb-b: rgba(46, 211, 183, .2);
  --orb-c: rgba(160, 120, 255, .16);
  --skeleton: rgba(30, 20, 99, .06);
  --skeleton-hi: rgba(30, 20, 99, .12);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
p { margin: 0 0 10px; }
.num, table .num { font-variant-numeric: tabular-nums; }
.mono, code, kbd, pre { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.right { text-align: end; }
.grow { flex: 1; min-width: 0; }
.t-ok { color: var(--teal); } .t-warn { color: var(--warn); } .t-bad { color: var(--bad); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.center { justify-content: center; margin-top: 12px; }
.stack { display: grid; gap: 12px; }
/* Read by screen readers, not drawn. Also how the top-bar title hides on wide screens: still the page's h1. */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 6px; }
.view:focus { outline: none; }
::selection { background: var(--accent-soft); }

/* The glowing backdrop behind the glass. */
.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: radial-gradient(1200px 800px at 85% -10%, var(--bg-2), var(--bg) 60%); }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .9; }
.orb.a { width: 520px; height: 520px; background: var(--orb-a); top: -160px; left: -120px; animation: float 22s ease-in-out infinite alternate; }
.orb.b { width: 420px; height: 420px; background: var(--orb-b); bottom: -140px; right: -80px; animation: float 26s ease-in-out infinite alternate-reverse; }
.orb.c { width: 360px; height: 360px; background: var(--orb-c); top: 40%; left: 45%; animation: float 30s ease-in-out infinite alternate; }
.grid-lines { position: absolute; inset: 0; background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px; mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 70%); -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 70%); opacity: .5; }
@keyframes float { to { transform: translate(60px, 40px) scale(1.08); } }

.glass {
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(18px) saturate(150%); backdrop-filter: blur(18px) saturate(150%);
}

/* ── Controls ── */
.input {
  width: 100%; font: inherit; color: var(--ink); background: var(--glass-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: 9px 12px; transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--faint); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input:disabled { opacity: .5; }
select.input { appearance: none; -webkit-appearance: none; padding-inline-end: 30px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
select.input option { background: var(--bg-2); color: var(--ink); }
textarea.input { resize: vertical; min-height: 64px; }
.code-input { letter-spacing: .3em; font-size: 18px; text-align: center; }
.field { display: grid; gap: 6px; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field small { font-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.check input { accent-color: var(--brand); width: 16px; height: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: inherit; font-weight: 600; font-size: 13.5px;
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--glass-2); color: var(--ink);
  cursor: pointer; white-space: nowrap; transition: transform .12s var(--ease), background .15s, box-shadow .2s, border-color .15s; text-decoration: none;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; padding: 11px; }
.btn.icon-only { padding: 8px; }
.btn.icon-only.sm { padding: 5px; }
.btn.primary { background: linear-gradient(135deg, #6A55F0, var(--brand)); border-color: transparent; color: #fff; box-shadow: var(--glow); }
.btn.primary:hover { filter: brightness(1.08); }
/* Both ends of the gradient keep white text at 4.5:1 or more (WCAG AA). */
.btn.danger { background: linear-gradient(135deg, #D63852, #C8323F); border-color: transparent; color: #fff; }
.btn.danger-ghost { color: var(--bad); }
.btn.danger-ghost:hover { border-color: var(--bad); background: var(--bad-soft); }
.btn.accent-ghost { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); }
.btn.subtle { background: transparent; border-color: transparent; color: var(--muted); }
.btn.subtle:hover { color: var(--ink); background: var(--glass-2); border-color: var(--line); }
.btn.wa { color: #fff; background: #117A43; border-color: transparent; } /* WhatsApp green, dark enough for white text (5.4:1) */
.btn.busy { position: relative; color: transparent !important; }
.btn.busy > * { visibility: hidden; }
.btn.busy::after { content: ""; position: absolute; width: 15px; height: 15px; border-radius: 50%; border: 2px solid currentColor; border-color: var(--muted) transparent var(--muted) transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
kbd { font-size: 11px; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--glass-2); color: var(--muted); box-shadow: inset 0 -1px 0 var(--line-2); }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--glass-2); border: 1px solid var(--line); white-space: nowrap; }
.chip .dot { width: 6px; height: 6px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.chip.plan { color: var(--muted); }
.st-trial { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.st-active { color: var(--teal); background: var(--teal-soft); border-color: transparent; }
.st-past_due { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.st-suspended { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

.avatar { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; flex: none; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--brand), #2ED3B7); box-shadow: var(--glow); font-size: 14px; }
.avatar.sm { width: 30px; height: 30px; border-radius: 9px; font-size: 12px; box-shadow: none; }
.avatar.lg { width: 56px; height: 56px; border-radius: 16px; font-size: 20px; }

/* ── Sign-in ── */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(420px, 100%); padding: 28px; display: grid; gap: 18px; animation: rise .5s var(--ease) both; }
.auth-title { font-size: 20px; margin-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand .logo { width: 34px; height: 34px; border-radius: 9px; box-shadow: var(--glow); }
.brand b { display: block; font-size: 16px; line-height: 1.1; }
.brand small { color: var(--muted); font-size: 12px; }
.brand.big .logo { width: 44px; height: 44px; }
.qr { display: block; width: 220px; height: 220px; margin: 8px auto; image-rendering: pixelated; border-radius: 12px; background: #fff; padding: 8px; }
details > summary { cursor: pointer; color: var(--accent); margin-bottom: 8px; }
.key { display: block; font-size: 15px; line-height: 1.6; letter-spacing: .08em; background: var(--glass-2); padding: 10px; border-radius: 8px; word-break: break-all; margin-bottom: 8px; }

/* ── Shell ── */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; border-radius: 0; border-width: 0 1px 0 0; display: flex; flex-direction: column; gap: 18px; padding: 20px 14px; }
.nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.nav-link { position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 11px; color: var(--muted); font-weight: 550; transition: background .15s, color .15s; }
.nav-link:hover { color: var(--ink); background: var(--glass-2); text-decoration: none; }
.nav-link.on { color: var(--ink); background: linear-gradient(90deg, var(--accent-soft), transparent); }
.nav-link.on::before { content: ""; position: absolute; inset-inline-start: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.nav-link.on .icon { color: var(--accent); }
.badge { margin-inline-start: auto; min-width: 20px; padding: 0 6px; height: 20px; border-radius: 10px; font-size: 11px; font-weight: 700; display: grid; place-items: center; background: var(--brand); color: #fff; box-shadow: 0 0 12px var(--accent-soft); }
.who { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; border: 1px solid var(--line); color: var(--ink); min-width: 0; }
.who:hover { text-decoration: none; background: var(--glass-2); }
.who-text { display: grid; min-width: 0; }
.who-text b, .who-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 14px; padding: 14px 28px;
  background: linear-gradient(var(--bg) 0%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.page-title { font-size: 17px; font-weight: 650; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-trigger { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; min-width: 280px; padding: 8px 10px 8px 12px; font: inherit; color: var(--faint);
  background: var(--glass); border: 1px solid var(--line-2); border-radius: 11px; cursor: pointer; transition: border-color .15s, box-shadow .2s; }
.palette-trigger:hover { border-color: var(--accent); box-shadow: var(--glow); }
.palette-trigger .trigger-text { flex: 1; text-align: start; }
.top-actions { display: flex; gap: 2px; }
.view { padding: 24px 28px 48px; max-width: 1440px; width: 100%; }
.view-root { display: grid; gap: 18px; }
.view-root.enter { animation: rise .38s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ── Page building blocks ── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 26px; font-weight: 700; background: linear-gradient(120deg, var(--ink) 30%, var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.page-head p { margin: 4px 0 0; }
.card { padding: 18px 20px; min-width: 0; }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 650; margin-bottom: 14px; color: var(--ink); }
.card-title .icon { color: var(--accent); }
.sub-title { font-size: 12.5px; color: var(--muted); font-weight: 600; margin: 14px 0 4px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 8px 0 0; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.dash { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.span-2 { grid-column: 1 / -1; }

.kpi-grid { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* The page heading says where you are on a wide screen; the top bar title is for phones. */
@media (min-width: 861px) { .page-title { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; } }
.kpi { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; color: var(--ink); overflow: hidden; transition: transform .2s var(--ease), box-shadow .2s, border-color .2s; }
a.kpi:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--line-2); box-shadow: var(--shadow), var(--glow); }
.kpi::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(240px 90px at 0% 0%, var(--accent-soft), transparent 70%); }
.kpi-label { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 28px; font-weight: 750; letter-spacing: -.02em; line-height: 1.15; }
.kpi .spark { margin-top: 2px; width: 100%; }
.kpi-sub { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--muted); }
.kpi-mrr { grid-column: span 2; background: linear-gradient(135deg, rgba(86, 65, 214, .32), rgba(46, 211, 183, .12)), var(--glass); }
.kpi-mrr .kpi-value { font-size: 30px; }
.kpi-mrr small { display: block; }
.mrr-list { display: flex; flex-wrap: wrap; gap: 2px 22px; align-items: baseline; }
.mrr-list.many .kpi-value { font-size: 24px; }
.kpi.tone-warn .kpi-value { color: var(--warn); }
.kpi.tone-accent { border-color: var(--accent); box-shadow: var(--shadow), var(--glow); }
.kpi-link { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 600; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.search-box { position: relative; flex: 1 1 260px; display: flex; align-items: center; }
.search-box > .icon { position: absolute; inset-inline-start: 12px; color: var(--faint); pointer-events: none; }
.search-box .input { padding-inline-start: 36px; }
.search-box.big .input { padding-block: 12px; font-size: 15px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--glass); border: 1px solid var(--line); flex-wrap: wrap; }
.seg-btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); background: transparent; border: 0; padding: 6px 12px; border-radius: 9px; cursor: pointer; }
.seg-btn:hover { color: var(--ink); }
.seg-btn.on { background: var(--glass-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.on { color: var(--ink); border-color: var(--accent); }
.filters { display: grid; gap: 10px; grid-template-columns: 2fr 1.4fr 1.2fr 1.2fr auto auto; align-items: end; margin-bottom: 16px; }
.date-pair { display: grid; gap: 4px; }

.table-wrap { overflow-x: auto; margin: 0 -6px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: start; font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: var(--glass); }
.table tbody tr:last-child td { border-bottom: 0; }
.table.clickable tbody tr { cursor: pointer; }
.table tr.dim { opacity: .6; }
.table.shortcuts td { padding: 7px 4px; }
.table.shortcuts kbd { margin: 0 2px; }
.usage-cell { min-width: 170px; }

.list-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list-row:last-child { border-bottom: 0; }
ul.rows { list-style: none; margin: 0; padding: 0; }

/* ── Feedback ── */
.skeleton-block { display: grid; gap: 10px; padding: 4px 0; }
.skeleton { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--skeleton) 0%, var(--skeleton-hi) 50%, var(--skeleton) 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.skeleton:first-child { height: 18px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.empty { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 26px 12px; }
.empty-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); margin-bottom: 4px; }
.empty p { margin: 0; max-width: 340px; }
.error-line, .info-line { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bad-soft); color: var(--bad); font-weight: 550; }
.info-line { background: var(--accent-soft); color: var(--accent); }
.error-line .icon, .info-line .icon { flex: none; margin-top: 2px; }
.warn-box { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--ink); border: 1px solid var(--warn-soft); }
.warn-box > .icon { color: var(--warn); flex: none; margin-top: 2px; }
.warn-box ul { margin: 6px 0 0; padding-inline-start: 18px; color: var(--muted); }

.toasts { position: fixed; z-index: 100; inset-inline-end: 20px; bottom: 20px; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 8px 11px 14px; border-radius: 12px; background: var(--glass-solid); border: 1px solid var(--line-2);
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .5); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); animation: toastIn .3s var(--ease) both; }
.toast-stack { display: grid; gap: 8px; }
.toast-stack:empty { display: none; }
.toast span { flex: 1; }
.toast.ok > .icon { color: var(--teal); } .toast.bad > .icon { color: var(--bad); } .toast.info > .icon { color: var(--accent); }
.toast.bad { border-color: var(--bad-soft); }
.toast.leaving { animation: toastOut .3s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

/* ── Dialogs ── */
dialog { color: var(--ink); padding: 0; }
dialog::backdrop { background: rgba(6, 5, 20, .55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.dialog { width: min(480px, calc(100vw - 24px)); max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); background: var(--glass-solid); border: 1px solid var(--line-2); border-radius: 20px; overflow: auto; animation: pop .22s var(--ease) both; }
.dialog.wide { width: min(720px, calc(100vw - 24px)); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.97); } }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 20px 6px; }
.dialog-head h2 { font-size: 17px; }
.dialog-body { padding: 8px 20px 4px; display: grid; gap: 14px; }
.dialog-body p { margin: 0; }
.dialog-error:empty { display: none; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 20px 18px; flex-wrap: wrap; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.overrides { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.overrides summary { margin: 0; }
.override-row { display: grid; grid-template-columns: 1fr 120px auto; gap: 10px; align-items: center; padding: 6px 0; }
.copy-field { display: flex; gap: 8px; }
.choices { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px 10px; margin: 0; display: grid; gap: 6px; }
.choices legend { font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 0 4px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.choice input { accent-color: var(--brand); width: 18px; height: 18px; margin: 2px 0 0; flex: none; }
.choice span { display: grid; gap: 1px; }
.switch-row { margin-bottom: 10px; color: var(--ink); }
.copy-field .input { flex: 1; }
.link-out { display: inline-flex; align-items: center; gap: 5px; }

/* Command palette. */
.palette { width: min(620px, calc(100vw - 24px)); margin-top: 12vh; background: var(--glass-solid); border: 1px solid var(--line-2); border-radius: 18px; overflow: hidden; animation: pop .18s var(--ease) both; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .7), var(--glow); }
.palette-search { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--muted); }
.palette-input { flex: 1; font: inherit; font-size: 16px; color: var(--ink); background: transparent; border: 0; outline: none; }
.palette-list { list-style: none; margin: 0; padding: 6px; max-height: min(420px, 55vh); overflow-y: auto; }
.palette-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 10px 10px 4px; font-weight: 650; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px; cursor: pointer; color: var(--muted); }
.palette-item.on { background: var(--accent-soft); color: var(--ink); box-shadow: inset 0 0 0 1px var(--accent-soft); }
.palette-item.on .icon { color: var(--accent); }
.palette-empty { padding: 18px; text-align: center; }
.palette-foot { display: flex; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--line); }
.palette-foot kbd { margin-inline-end: 2px; }

/* ── Charts ── */
.chart-wrap { display: grid; gap: 6px; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .gridline { stroke: var(--line); stroke-width: 1; }
.chart .gridline.strong { stroke: var(--line-2); }
.chart .axis { fill: var(--faint); font-size: 11px; font-family: var(--font); }
.chart .pt { opacity: 0; transition: opacity .2s; }
.chart:hover .pt { opacity: 1; }
.glow-line { filter: drop-shadow(0 0 6px currentColor); }
.draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.1s var(--ease) .1s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.fade-in { animation: fadeIn .9s ease .3s both; }
@keyframes fadeIn { from { opacity: 0; } }
.bar.grow { animation: growY .7s var(--ease) both; transform-box: view-box; }
@keyframes growY { from { transform: scaleY(0); } }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--muted); align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend b { color: var(--ink); }
.legend-note { color: var(--faint); font-size: 12px; }
.foot-note { margin: 12px 0 0; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; justify-content: center; }
.donut-track { stroke: var(--line); }
.donut-seg { animation: donutIn .9s var(--ease) both; }
@keyframes donutIn { from { stroke-dasharray: 0 100; } }
.donut-total { fill: var(--ink); font-size: 28px; font-weight: 750; font-family: var(--font); font-variant-numeric: tabular-nums; }
.donut-label { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.donut-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; min-width: 150px; }
.donut-legend li { display: grid; grid-template-columns: 12px 1fr auto 38px; align-items: center; gap: 8px; }
.donut-legend small { text-align: end; }
.bar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.bar-row { display: flex; align-items: baseline; gap: 8px; margin-bottom: 5px; }
.bar-row a, .bar-row > span:nth-child(2) { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row b { margin-inline-start: auto; white-space: nowrap; font-size: 13px; }
.rank { color: var(--faint); font-size: 12px; width: 16px; }
.bar-track, .meter { height: 7px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar-fill, .meter-fill { display: block; height: 100%; width: 0; border-radius: 4px; transition: width .9s var(--ease); }
.bar-fill { background: linear-gradient(90deg, var(--brand), var(--teal)) !important; box-shadow: 0 0 10px var(--accent-soft); }
.meter-fill.ok { background: linear-gradient(90deg, var(--teal), #4CE0C6); }
.meter-fill.warn { background: linear-gradient(90deg, #E8A33A, var(--warn)); }
.meter-fill.bad { background: linear-gradient(90deg, #E2405E, var(--bad)); }
.meter-row { display: grid; gap: 5px; margin-bottom: 12px; }
.meter-row:last-child { margin-bottom: 0; }
.meter-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.near-list { display: grid; gap: 14px; }
.near-item a { font-weight: 600; display: block; margin-bottom: 4px; }

/* ── Workspace 360° ── */
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; width: fit-content; }
.hero { display: grid; gap: 16px; padding: 22px; background: linear-gradient(135deg, rgba(86, 65, 214, .22), rgba(46, 211, 183, .06) 70%), var(--glass); }
.hero-top { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.hero-id { flex: 1; min-width: 220px; }
.hero-id h2 { font-size: 26px; font-weight: 750; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.hero-side { display: grid; gap: 2px; text-align: end; }
.slug { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); background: var(--glass-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px 8px; cursor: pointer; }
.slug:hover { color: var(--ink); border-color: var(--accent); }
.countdown { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted); }
.countdown.t-warn { color: var(--warn); }
.action-bar { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
/* A small menu (details/summary): the hero's less used actions. */
.menu { position: relative; }
.menu > summary { list-style: none; margin: 0; color: var(--ink); }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; z-index: 10; inset-inline-start: 0; top: calc(100% + 6px); display: grid; gap: 2px; padding: 6px; min-width: 220px; background: var(--glass-solid); }
.menu-panel .btn { justify-content: flex-start; }
.reason { white-space: pre-wrap; overflow-wrap: anywhere; }
/* The More sheet (phones): the pages that do not fit the bottom bar. */
.sheet-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.sheet-link { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 12px; font: inherit; font-weight: 600;
  color: var(--ink); background: transparent; border: 1px solid transparent; cursor: pointer; text-align: start; }
.sheet-link:hover { background: var(--glass-2); text-decoration: none; }
.sheet-link.on { background: var(--accent-soft); }
.sheet-link .icon { color: var(--accent); }
.nav-more-item { display: none; }
button.nav-link { font: inherit; background: transparent; border: 0; cursor: pointer; width: 100%; }
.filters-fold > summary { display: none; }
.owner-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.kv { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.kv li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kv li > .icon { color: var(--faint); flex: none; }
.devices { margin-top: 12px; }
.signins { margin-top: 12px; }
.signins ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.signins li { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 13px; }
.tool-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.mini-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.mini-kpis > div { padding: 10px 12px; border-radius: 12px; background: var(--glass); border: 1px solid var(--line); display: grid; }
.mini-kpis b { font-size: 20px; }
.overrides-list { margin-top: 14px; }
.notes { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.notes li { padding: 10px 12px; border-radius: 12px; background: var(--glass); border: 1px solid var(--line); }
.notes p { margin: 0 0 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.notes .row { gap: 4px; }
.notes .row .btn { margin-inline-start: auto; }
.note-add { display: grid; gap: 8px; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; inset-inline-start: 6px; top: 6px; bottom: 6px; width: 2px; background: linear-gradient(var(--accent), var(--teal), transparent); opacity: .35; border-radius: 2px; }
.tl-item { position: relative; display: flex; gap: 14px; padding: 8px 0; }
.tl-dot { flex: none; width: 14px; height: 14px; border-radius: 50%; margin-top: 3px; background: var(--bg); border: 3px solid var(--accent); box-shadow: 0 0 10px var(--accent-soft); z-index: 1; }
.tl-body { min-width: 0; flex: 1; }
.tl-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.tl-detail summary { font-size: 12.5px; margin: 4px 0 0; }
.tl-detail pre { margin: 6px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--glass-2); border: 1px solid var(--line); font-size: 12px; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; }

/* ── Health ── */
.tile-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.tile { padding: 14px 16px; display: grid; gap: 4px; animation: rise .4s var(--ease) both; }
.no-anim .tile { animation: none; }
.tile.ok { box-shadow: var(--shadow), inset 0 2px 0 var(--teal-soft); }
.tile.down { border-color: var(--bad); box-shadow: var(--shadow), 0 0 24px -6px var(--bad-soft); }
.tile.warn { border-color: var(--warn-soft); }
.tile-head { display: flex; align-items: center; gap: 8px; }
.tile-val { font-size: 22px; font-weight: 700; }
.tile.down .tile-val { color: var(--bad); }
.tile.warn .tile-val { color: var(--warn); }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 0 var(--teal); animation: pulse 2s infinite; }
.pulse.down { background: var(--bad); animation: none; box-shadow: 0 0 10px var(--bad); }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.lag-cell { min-width: 200px; }
.lag-cell b { min-width: 48px; }
.me-card { display: flex; }

/* ── Phones and tablets ── */
@media (max-width: 1180px) {
  .grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.dash { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  /* The sidebar becomes a bottom bar; it scrolls sideways when the labels do not fit. */
  .sidebar { position: fixed; z-index: 20; inset: auto 0 0 0; top: auto; height: auto; flex-direction: row; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-width: 1px 0 0; background: var(--glass-solid); }
  .sidebar .brand, .sidebar .who { display: none; }
  .sidebar nav { flex: 1; overflow-x: auto; scrollbar-width: none; }
  /* Four pages and More: each item a readable width, nothing scrolled out of sight. */
  .nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; }
  .nav-secondary { display: none; }
  .nav-more-item { display: block; }
  .nav-link { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 11px; min-width: 0; min-height: 48px; justify-content: center; }
  .nav-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* Signing out is in the More sheet on a phone. */
  #signout-btn { display: none; }
  /* Solid cards and still orbs: blur and endless animation cost a phone more than they give. */
  .glass { background: var(--card-solid); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .hero { background: linear-gradient(135deg, rgba(86, 65, 214, .22), rgba(46, 211, 183, .06) 70%), var(--card-solid); }
  .kpi-mrr { background: linear-gradient(135deg, rgba(86, 65, 214, .32), rgba(46, 211, 183, .12)), var(--card-solid); }
  .orb { animation: none; }
  .dialog.sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .nav-link.on::before { inset: auto 22% -6px 22%; width: auto; height: 3px; top: auto; }
  .badge { position: absolute; top: 2px; inset-inline-end: 8px; height: 16px; min-width: 16px; font-size: 10px; }
  .topbar { padding: 10px 14px; gap: 8px; }
  .palette-trigger { min-width: 0; width: auto; padding: 8px; }
  .palette-trigger .trigger-text, .palette-trigger kbd { display: none; }
  .view { padding: 16px 14px 32px; }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-mrr { grid-column: 1 / -1; }
  .kpi-value { font-size: 24px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .search-box { grid-column: 1 / -1; }
  .hero-side { text-align: start; }
  .page-head h2 { font-size: 22px; }
  .toasts { bottom: calc(80px + env(safe-area-inset-bottom)); inset-inline-end: 16px; }
  .palette { margin-top: 6vh; }
  .override-row { grid-template-columns: 1fr 100px; }
  .override-row .check { grid-column: 1 / -1; }
  /* Fingers, not pointers: every control is at least 44px tall (and wide, for icon buttons). */
  .btn, .btn.sm, .seg-btn, .tab, .palette-trigger { min-height: 44px; }
  .btn.icon-only, .btn.icon-only.sm, .palette-trigger { min-width: 44px; }
  .check input, .choice input { width: 22px; height: 22px; }
  .choice, .check { min-height: 44px; align-items: center; }
}
/* Phones: wide tables become one card per row, each value under its column's name, buttons in full view. */
@media (max-width: 600px) {
  .table.cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); }
  .table.cards, .table.cards tbody, .table.cards tr, .table.cards td { display: block; width: 100%; }
  .table.cards tr { padding: 12px 6px; border-bottom: 1px solid var(--line); }
  .table.cards tbody tr:last-child { border-bottom: 0; }
  .table.cards td { border: 0; padding: 4px 0; text-align: start; }
  .table.cards td[data-label] { display: grid; grid-template-columns: 7.5em minmax(0, 1fr); gap: 10px; align-items: start; }
  .table.cards td[data-label]::before { content: attr(data-label); color: var(--faint); font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; padding-top: 2px; }
  .table.cards .cell-v { min-width: 0; }
  .table.cards td.right, .table.cards td:last-child:not([data-label]) { padding-top: 8px; }
  .table.cards td:last-child:not([data-label]) .row.end { justify-content: flex-start; }
  .table.cards .usage-cell { min-width: 0; }
  .table-wrap:has(.table.cards) { overflow-x: visible; margin: 0; }
  .filters-fold > summary { display: inline-flex; margin-bottom: 12px; }
  .filters { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px 14px; }
  .card { padding: 14px; }
  .action-bar .btn { flex: 1 1 calc(50% - 8px); }
  .dialog-actions .btn { flex: 1; }
}

/* Touch screens have no keyboard to speak of: no shortcuts button. */
@media (pointer: coarse) { #help-btn { display: none; } }

/* Motion off: everything appears in place at once. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .orb { animation: none !important; }
}

/* Rows with a name and buttons: the name keeps a readable width; the buttons wrap below it when narrow. */
.list-row > .grow { flex: 1 1 170px; }

/* Plans: cards never narrower than their rows need, each plan's prices side by side, sections spaced apart. */
.plan-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.plan-section { margin: 18px 0 6px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.plan-prices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.plan-card .override-row { grid-template-columns: minmax(0, 1fr) 104px auto; }
.plan-save { margin-top: 16px; }
@media (max-width: 860px) { .plan-card .override-row { grid-template-columns: minmax(0, 1fr) 100px; } }
@media (max-width: 400px) { .plan-grid { grid-template-columns: 1fr; } }
