/*
 * GNSW SMS — shares its visual language with GNSW Mail:
 * navy rail, flag seam, white panels on a cool canvas, Inter throughout.
 */

@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

:root {
  --gm-red: #e31e24;
  --gm-blue: #1e2c72;
  --gm-green: #0b6b3a;
  --navy: #0a1642;
  --brand: #22348a;
  --brand-strong: #1a2870;
  --brand-bright: #3b56d0;
  --ring: rgba(59, 86, 208, 0.28);

  --ink: #0d1117;
  --ink-soft: #1e293b;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --canvas: #f3f5fa;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --field: #f8fafc;
  --hover: #f1f5f9;

  --ok: #10b981;
  --ok-ink: #0a7a4c;
  --ok-soft: #ecfdf5;
  --warn: #f5b942;
  --warn-ink: #8a5a00;
  --warn-soft: #fffbeb;
  --bad: #d92d20;
  --bad-ink: #b42318;
  --bad-soft: #fef2f2;
  --info-ink: #2d44a8;
  --info-soft: #eef2ff;

  --chart-sent: #3b56d0;
  --chart-failed: #d92d20;
  --chart-grid: #e8edf4;

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.07);
  --shadow-md: 0 8px 22px rgba(15, 23, 42, 0.09);
  --shadow-lg: 0 24px 56px rgba(14, 22, 48, 0.14);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}

[data-theme="dark"] {
  --ink: #f1f5f9;
  --ink-soft: #cbd5e1;
  --muted: #94a3b8;
  --faint: #64748b;
  --line: #1e293b;
  --line-strong: #334155;
  --canvas: #0a0f1a;
  --panel: #0f172a;
  --panel-soft: #111a2e;
  --field: #16213a;
  --hover: #17223a;
  --ok-ink: #34d399;
  --ok-soft: #0a2e1f;
  --warn-ink: #fbbf24;
  --warn-soft: #2e2205;
  --bad-ink: #f87171;
  --bad-soft: #2e0f12;
  --info-ink: #a5b4fc;
  --info-soft: #1a2448;
  --chart-sent: #5b76e8;
  --chart-failed: #e5484d;
  --chart-grid: #1e293b;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 22px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 56px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand-bright); text-decoration: none; }
[data-theme="dark"] a { color: #8ea2ff; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--brand-bright); outline-offset: 2px; }

/* ── Loading ─────────────────────────────────────────────────────────────── */
.loading-view {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  gap: 22px;
  background: radial-gradient(ellipse at top, #22377570, transparent 70%), var(--navy);
  color: #fff;
}
.loading-brand { display: flex; align-items: center; gap: 14px; }
.loading-brand img { width: 64px; height: 42px; object-fit: contain; background: #fff; border-radius: 10px; padding: 4px; }
.loading-brand strong { display: block; font-size: 18px; }
.loading-brand span { color: #a4b2da; font-size: 13px; }
.loading-line { height: 3px; border-radius: 3px; background: linear-gradient(90deg, var(--gm-red) 0 30%, #fff 30% 35%, var(--gm-blue) 35% 65%, #fff 65% 70%, var(--gm-green) 70%); animation: loadline 1.4s var(--ease) infinite; transform-origin: left; }
@keyframes loadline { 0% { transform: scaleX(0.1); opacity: .6 } 60% { transform: scaleX(1); opacity: 1 } 100% { transform: scaleX(1); opacity: 0 } }

/* ── Buttons & fields ────────────────────────────────────────────────────── */
.btn-primary, .btn, .btn-ghost, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 9px 16px; border-radius: 11px; font-size: 13px; font-weight: 600;
  border: 1px solid transparent; transition: background .15s, box-shadow .15s, border-color .15s, transform .1s;
  white-space: nowrap; text-decoration: none;
}
.btn-primary { background: linear-gradient(120deg, #344aa8, #22348a); color: #fff !important; box-shadow: 0 5px 12px #22348a25; }
.btn-primary:hover { background: #3048b1; box-shadow: 0 7px 18px #22348a35; }
.btn-primary:active, .btn:active { transform: translateY(1px); }
.btn-primary[disabled], .btn[disabled], .btn-danger[disabled] { opacity: .55; cursor: not-allowed; box-shadow: none; }
.btn { background: var(--panel); border-color: var(--line); color: var(--ink-soft); box-shadow: var(--shadow-xs); }
.btn:hover { border-color: var(--line-strong); background: var(--panel-soft); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--hover); color: var(--ink); }
.btn-danger { background: var(--bad-soft); color: var(--bad-ink); border-color: transparent; }
.btn-danger:hover { background: var(--bad); color: #fff; }
.btn-sm { min-height: 32px; padding: 6px 11px; font-size: 12px; border-radius: 9px; }
.block { width: 100%; }
.btn-primary .ic, .btn .ic, .btn-ghost .ic, .btn-danger .ic { width: 16px; height: 16px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: 0; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }

.field { display: grid; gap: 7px; margin: 0 0 16px; }
.field > span:first-child, .label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.input, .field input, .field select, .field textarea, select.input {
  width: 100%; min-height: 42px; padding: 10px 13px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--field); color: var(--ink);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field textarea, textarea.input { min-height: 140px; resize: vertical; line-height: 1.55; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand-bright); box-shadow: 0 0 0 4px var(--ring); background: var(--panel);
}
.input-wrap { position: relative; display: block; }
.input-wrap .input-icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--faint); display: flex; pointer-events: none; }
.input-wrap input { padding-left: 44px; min-height: 52px; font-size: 15px; border-radius: 13px; }
.input-wrap .reveal { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--faint); width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; }
.input-wrap .reveal:hover { color: var(--ink); background: var(--hover); }
.input-wrap input.has-reveal, .input-wrap input[type="password"] { padding-right: 50px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink-soft); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.form-error { margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--bad-soft); color: var(--bad-ink); font-size: 13px; font-weight: 500; }

/* ── Status pill ─────────────────────────────────────────────────────────── */
.status-pill {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px 0 10px;
  border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap;
  border: 1px solid var(--line); color: var(--ink-soft); background: var(--panel);
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #9fb4ff; flex: none; }
[data-state="online"] > .status-dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(16, 185, 129, .18); }
[data-state="degraded"] > .status-dot { background: var(--warn); box-shadow: 0 0 0 3px rgba(245, 185, 66, .22); }
[data-state="offline"] > .status-dot { background: var(--bad); box-shadow: 0 0 0 3px rgba(217, 45, 32, .18); }
[data-state="checking"] > .status-dot { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35 } }

/* ── Sign in ─────────────────────────────────────────────────────────────── */
.auth-view { min-height: 100dvh; display: flex; background: radial-gradient(ellipse at top, #22377570, transparent 70%), var(--navy); }
.auth-side, .auth-seam { display: none; }
.auth-main { flex: 1; display: grid; place-items: center; padding: 84px 16px 32px; position: relative; }
.auth-top { position: absolute; top: 18px; right: 18px; display: flex; gap: 10px; align-items: center; }
.auth-top .status-pill { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); color: rgba(255,255,255,.85); }
.auth-top .icon-btn { border: 1px solid rgba(255,255,255,.18); color: #fff; background: rgba(255,255,255,.06); }

.auth-card {
  position: relative; width: 100%; max-width: 440px; padding: 30px 22px 22px; overflow: hidden;
  border: 1px solid var(--line); border-radius: 20px; background: var(--panel);
  box-shadow: 0 1px 2px rgba(14,22,48,.06), 0 32px 64px rgba(0,0,0,.32);
}
.auth-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--gm-red) 0 33%, transparent 33% 34%, var(--gm-blue) 34% 66%, transparent 66% 67%, var(--gm-green) 67%);
}
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.auth-brand img { width: 84px; height: 46px; object-fit: contain; border: 1px solid var(--line); border-radius: 10px; padding: 4px; background: #fff; }
.auth-brand strong { display: block; font-size: 19px; letter-spacing: -.01em; }
.auth-brand span { color: var(--muted); font-size: 13px; }
.auth-card h2 { margin: 0 0 20px; font-size: 27px; letter-spacing: -.02em; }
.auth-card .check { margin: 2px 0 22px; }
.auth-card .btn-primary { min-height: 52px; font-size: 16px; border-radius: 13px; background: linear-gradient(180deg, #3b56d0, #22348a); }
.auth-foot { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 18px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.auth-foot span { display: inline-flex; align-items: center; gap: 6px; }
.auth-foot .ic { width: 14px; height: 14px; color: var(--gm-green); }
.copyright { margin: 10px 0 0; text-align: center; font-size: 12px; color: var(--faint); }
.btn-primary .spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }

@media (min-width: 400px) { .auth-card { padding: 36px 32px 26px; } }

@media (min-width: 1024px) {
  .auth-view { background: none; }
  .auth-side {
    display: flex; flex: 1.5; min-width: 0; position: relative; overflow: hidden; color: #fff;
    background:
      radial-gradient(circle at 20% 15%, rgba(59, 86, 208, .35), transparent 45%),
      radial-gradient(circle at 80% 90%, rgba(11, 107, 58, .18), transparent 40%),
      linear-gradient(160deg, #13206b, #0a1642 60%, #081035);
  }
  .auth-side::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.05) 1px, transparent 1px); background-size: 22px 22px; pointer-events: none; }
  .auth-side-inner { position: relative; z-index: 1; padding: 88px 60px 48px; display: flex; flex-direction: column; width: 100%; }
  .auth-seam { display: block; width: 5px; flex: none; background: linear-gradient(180deg, var(--gm-red) 0 33%, #fff 33% 39%, var(--gm-blue) 39% 61%, #fff 61% 67%, var(--gm-green) 67%); }
  .auth-main { flex: 1; min-width: 460px; background: linear-gradient(160deg, #f6f8fc, #e9edf7); }
  [data-theme="dark"] .auth-main { background: linear-gradient(160deg, #0d1426, #0a0f1a); }
  .auth-top .status-pill { background: var(--panel); border-color: var(--line); color: var(--ink-soft); }
  .auth-top .icon-btn { border-color: var(--line); color: var(--ink-soft); background: var(--panel); box-shadow: var(--shadow-xs); }
  .auth-card { box-shadow: 0 1px 2px rgba(14,22,48,.05), 0 24px 56px rgba(14,22,48,.10); padding: 38px 36px 28px; }
  [data-theme="dark"] .auth-card { box-shadow: 0 24px 56px rgba(0,0,0,.45); }
}

.eyebrow-live { margin: 0 0 14px; font-size: 11.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #c6d0f2; display: flex; align-items: center; gap: 8px; }
.eyebrow-live .dim, .eyebrow-live .sep { color: #7f8fc4; font-weight: 600; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px rgba(16,185,129,.2); }
.auth-headline { margin: 0; max-width: 560px; font-size: clamp(34px, 3.3vw, 46px); line-height: 1.08; letter-spacing: -.03em; font-weight: 750; }
.auth-headline .grad { background: linear-gradient(90deg, #9fb0ff, #7be0c3); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 22px 0 0; font-size: 12px; color: #c6d0f2; }
.auth-tags .mono { font-size: 13px; color: #e2e8ff; }
.auth-tags .arrow { color: #7f8fc4; margin-right: 6px; }
.auth-tags .tag { padding: 4px 10px; border-radius: 999px; border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.05); font-weight: 600; }

.route { margin-top: auto; padding-top: 48px; display: grid; grid-template-columns: 1fr 44px 1fr 64px 1fr 44px 1fr; align-items: center; }
.route-node { display: grid; justify-items: center; text-align: center; gap: 5px; padding: 16px 8px; border-radius: 16px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1); backdrop-filter: blur(4px); }
.route-node strong { font-size: 13px; }
.route-node small { font-size: 11px; color: #a4b2da; }
.route-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: rgba(255,255,255,.1); color: #fff; }
.route-link { position: relative; height: 2px; background: rgba(255,255,255,.18); overflow: visible; }
.route-link i { position: absolute; top: -3px; left: 0; width: 8px; height: 8px; border-radius: 50%; background: #9fb0ff; box-shadow: 0 0 12px #9fb0ff; animation: travel 2.4s linear infinite; }
.route-link.tunnel { height: 10px; border-radius: 10px; background: rgba(123, 224, 195, .12); border: 1px solid rgba(123, 224, 195, .35); }
.route-link.tunnel i { top: 0; background: #7be0c3; box-shadow: 0 0 12px #7be0c3; }
.route-link:nth-of-type(4) i { animation-delay: .8s; }
.route-link:nth-of-type(6) i { animation-delay: 1.6s; }
@keyframes travel { from { left: 0 } to { left: calc(100% - 8px) } }
.route[data-gateway="degraded"] .route-link.tunnel { background: rgba(245,185,66,.12); border-color: rgba(245,185,66,.5); }
.route[data-gateway="degraded"] .route-link.tunnel i, .route[data-gateway="degraded"] .route-link:last-of-type i { animation: none; opacity: 0; }
.route[data-gateway="degraded"] [data-node="operator"] .route-icon { background: rgba(245,185,66,.18); color: var(--warn); }
.route[data-gateway="online"] [data-node="operator"] .route-icon { background: rgba(16,185,129,.2); color: #6ee7b7; }

.phone-demo { align-self: flex-end; margin-top: 28px; width: 320px; padding: 14px 16px 18px; border-radius: 20px; background: rgba(8, 14, 44, .7); border: 1px solid rgba(255,255,255,.1); box-shadow: 0 20px 40px rgba(0,0,0,.3); }
.phone-demo-head { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; color: #c6d0f2; margin-bottom: 10px; letter-spacing: .04em; }
.phone-demo-head small { color: #7f8fc4; font-weight: 500; }
.bubble { min-height: 62px; padding: 11px 14px; border-radius: 16px 16px 16px 4px; background: #1d2a66; color: #eef1ff; font-size: 13.5px; line-height: 1.5; }
.bubble::after { content: "▍"; color: #9fb0ff; animation: pulse 1s steps(1) infinite; }

/* ── Workspace shell ─────────────────────────────────────────────────────── */
.app-view { display: grid; grid-template-columns: 76px 232px minmax(0, 1fr); min-height: 100dvh; }
.rail {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 10px; padding: 22px 10px 26px;
  background: radial-gradient(ellipse at top, #22377570, transparent 70%), var(--navy);
}
.rail::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, var(--gm-red) 0 30%, #fff 30% 35%, var(--gm-blue) 35% 65%, #fff 65% 70%, var(--gm-green) 70%); }
.rail-logo { display: grid; place-items: center; height: 44px; margin-bottom: 18px; }
.rail-logo img { width: 46px; height: 30px; object-fit: contain; background: #fff; padding: 3px; border-radius: 8px; }
.rail-items { display: grid; gap: 6px; }
.rail-item { display: grid; justify-items: center; gap: 6px; padding: 10px 0 9px; border-radius: 12px; color: #a4b2da !important; font-size: 11px; font-weight: 550; text-align: center; }
.rail-item:hover { color: #fff !important; background: #ffffff12; }
.rail-item.active { color: #fff !important; background: #ffffff17; box-shadow: inset 0 0 0 1px #ffffff12; }
.rail-live { margin: auto auto 0; width: 9px; height: 9px; border-radius: 50%; background: #9fb4ff; }
.rail-live[data-state="online"] { background: var(--ok); box-shadow: 0 0 0 4px rgba(16,185,129,.2); }
.rail-live[data-state="degraded"] { background: var(--warn); box-shadow: 0 0 0 4px rgba(245,185,66,.2); }

.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; padding: 26px 16px 20px; background: var(--canvas); overflow-y: auto; }
.sidebar-head { padding: 0 8px; margin-bottom: 20px; }
.eyebrow { margin: 0 0 4px; font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.sidebar-head h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.sidebar-user { margin: 3px 0 0; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.compose-btn { min-height: 47px; border-radius: 12px; margin-bottom: 24px; }
.sidebar-nav { display: grid; gap: 2px; }
.sidebar-section { margin: 14px 12px 8px; font-size: 9.5px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; color: var(--muted); }
.side-link { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--ink-soft) !important; font-size: 13.5px; font-weight: 500; }
.side-link .ic { color: var(--faint); width: 17px; height: 17px; }
.side-link:hover { background: var(--hover); }
.side-link.active { background: var(--panel); box-shadow: var(--shadow-xs); color: var(--ink) !important; font-weight: 600; }
.side-link.active .ic { color: var(--brand-bright); }
.side-link .count { margin-left: auto; min-width: 24px; padding: 1px 7px; border-radius: 999px; background: var(--info-soft); color: var(--info-ink); font-size: 11px; font-weight: 700; text-align: center; }
.sidebar-foot { margin-top: auto; padding-top: 18px; display: grid; gap: 8px; }
.gateway-mini { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.gateway-mini strong { display: block; font-size: 12.5px; }
.gateway-mini small { display: block; font-size: 11.5px; color: var(--muted); }
.signout { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; }
.signout:hover { background: var(--hover); color: var(--ink); }
.signout .ic { color: var(--bad); width: 16px; height: 16px; }
.nav-backdrop { display: none; }

.workspace { min-width: 0; display: flex; flex-direction: column; padding: 0 24px 24px 4px; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 22px 0 18px; }
.title-block { min-width: 0; }
.title-block h2 { margin: 0; font-size: 24px; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-btn { display: none; }
.search { flex: 1; max-width: 420px; margin-left: auto; margin-right: 8px; position: relative; display: flex; align-items: center; }
.search .ic { position: absolute; left: 14px; color: var(--faint); width: 16px; height: 16px; }
.search input { width: 100%; height: 42px; padding: 0 14px 0 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow-xs); }
.search input:focus { outline: none; border-color: var(--brand-bright); box-shadow: 0 0 0 4px var(--ring); }
.top-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.mobile-only { display: none; }
.top-actions .status-pill { margin-right: 8px; }
.avatar { width: 36px; height: 36px; margin-left: 6px; border-radius: 50%; border: 0; background: linear-gradient(135deg, #3b56d0, #22348a); color: #fff; font-weight: 700; font-size: 14px; box-shadow: 0 0 0 3px var(--panel), 0 0 0 4px var(--line); }
.menu-anchor { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 10px); z-index: 40; min-width: 230px; padding: 6px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.menu-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-head strong { display: block; font-size: 13.5px; }
.menu-head small { color: var(--muted); font-size: 12px; }
.menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 12px; border: 0; border-radius: 9px; background: transparent; font-size: 13px; font-weight: 500; text-align: left; }
.menu button:hover { background: var(--hover); }
.menu .ic { width: 16px; height: 16px; color: var(--muted); }

.content { flex: 1; min-width: 0; outline: none; }
.content > .view { animation: rise .35s var(--ease); }
.content > .view.quiet { animation: none; }
/* Shown only while navigating to a page whose data hasn't arrived yet. */
.view-loading { height: 3px; margin: 2px 0 0; border-radius: 3px; overflow: hidden; background: var(--line); position: relative; }
.view-loading::after { content: ""; position: absolute; inset: 0; width: 35%; border-radius: 3px; background: linear-gradient(90deg, var(--brand-bright), #7be0c3); animation: indeterminate 1.1s var(--ease) infinite; }
@keyframes indeterminate { from { transform: translateX(-100%) } to { transform: translateX(290%) } }
@keyframes rise { from { opacity: 0; transform: translateY(6px) } }

/* ── Panels & layout ─────────────────────────────────────────────────────── */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-width: 0; }
[data-theme="dark"] .panel { border-color: #1b2740; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 18px 20px 14px; }
.panel-head h3 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.panel-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 0 20px 20px; }
.grid { display: grid; gap: 18px; }
.grid-kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); align-items: start; }
.grid-halves { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: grid; gap: 18px; align-content: start; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }

.kpi { padding: 18px 20px; display: grid; gap: 6px; position: relative; overflow: hidden; }
.kpi .label { font-size: 12px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.kpi .label .ic { width: 15px; height: 15px; color: var(--faint); }
.kpi .value { font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi .sub b { font-weight: 650; }
.kpi .sub .up { color: var(--ok-ink); }
.kpi .sub .down { color: var(--bad-ink); }

/* Segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: var(--hover); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.seg button.active { background: var(--panel); color: var(--ink); box-shadow: var(--shadow-xs); }
.seg button .n { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }

/* Status chips */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 650; white-space: nowrap; background: var(--hover); color: var(--ink-soft); }
.chip .ic { width: 13px; height: 13px; stroke-width: 2.2; }
.chip.sent, .chip.completed, .chip.active-user { background: var(--ok-soft); color: var(--ok-ink); }
.chip.failed, .chip.expired, .chip.revoked, .chip.disabled { background: var(--bad-soft); color: var(--bad-ink); }
.chip.queued, .chip.sending, .chip.pending { background: var(--info-soft); color: var(--info-ink); }
.chip.scheduled { background: var(--warn-soft); color: var(--warn-ink); }
.chip.cancelled { background: var(--hover); color: var(--muted); }
.chip.admin { background: var(--info-soft); color: var(--info-ink); }

/* Tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; padding: 10px 16px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); background: var(--panel-soft); white-space: nowrap; }
.table th:first-child { border-top-left-radius: var(--radius); }
.table th:last-child { border-top-right-radius: var(--radius); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: var(--panel-soft); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .tel { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
.table .msg { max-width: 420px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .when { color: var(--muted); white-space: nowrap; font-size: 12.5px; }
.table .actions { text-align: right; white-space: nowrap; }
.table .strong { font-weight: 600; }
.table .sub { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.pager .btns { display: flex; gap: 6px; }

/* Progress */
.progress { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--hover); gap: 2px; }
.progress span { display: block; height: 100%; min-width: 0; }
.progress .p-sent { background: var(--chart-sent); }
.progress .p-failed { background: var(--chart-failed); }
.progress .p-cancelled { background: var(--line-strong); }
.progress.lg { height: 12px; }

/* Empty state */
.empty { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 56px 24px; }
.empty-icon { width: 76px; height: 76px; border-radius: 22px; display: grid; place-items: center; background: var(--panel); box-shadow: var(--shadow-md); color: var(--brand-bright); margin-bottom: 10px; border: 1px solid var(--line); }
.empty-icon .ic { width: 32px; height: 32px; stroke-width: 1.5; }
.empty .eyebrow { margin-top: 6px; }
.empty h3 { margin: 0; font-size: 21px; letter-spacing: -.02em; }
.empty p { margin: 0; max-width: 380px; color: var(--muted); font-size: 13.5px; }
.empty .btn, .empty .btn-primary { margin-top: 12px; }

/* Lists in panels */
.rows { display: grid; }
.row { display: flex; align-items: center; gap: 14px; padding: 13px 20px; border-top: 1px solid var(--line); color: inherit !important; }
a.row:hover { background: var(--panel-soft); }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .progress { width: 110px; flex: none; }
.row .aside { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }

/* Gateway card */
.gateway-card { padding: 20px; display: grid; gap: 16px; }
.gateway-state { display: flex; align-items: center; gap: 14px; }
.gateway-badge { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--hover); color: var(--muted); }
.gateway-card[data-state="online"] .gateway-badge { background: var(--ok-soft); color: var(--ok-ink); }
.gateway-card[data-state="degraded"] .gateway-badge { background: var(--warn-soft); color: var(--warn-ink); }
.gateway-state strong { display: block; font-size: 15px; }
.gateway-state small { color: var(--muted); font-size: 12.5px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
.facts div { padding: 11px 12px; border-radius: 11px; background: var(--panel-soft); border: 1px solid var(--line); }
.facts dt { font-size: 11px; font-weight: 600; color: var(--muted); }
.facts dd { margin: 3px 0 0; font-weight: 650; font-size: 13.5px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.note { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; font-size: 12.5px; line-height: 1.5; background: var(--warn-soft); color: var(--warn-ink); }
.note.info { background: var(--info-soft); color: var(--info-ink); }
.note .ic { width: 16px; height: 16px; margin-top: 1px; }

/* Chart */
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; }
.chart { position: relative; padding: 4px 20px 16px; }
.chart svg { display: block; width: 100%; height: 240px; overflow: visible; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar-sent { fill: var(--chart-sent); }
.chart .bar-failed { fill: var(--chart-failed); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover { fill: var(--hover); opacity: .6; }
.tooltip { position: absolute; z-index: 5; pointer-events: none; min-width: 150px; padding: 10px 12px; border-radius: 11px; background: var(--ink-soft); color: #fff; font-size: 12px; box-shadow: var(--shadow-lg); transform: translate(-50%, calc(-100% - 12px)); }
[data-theme="dark"] .tooltip { background: #e2e8f0; color: #0f172a; }
.tooltip strong { display: block; margin-bottom: 6px; }
.tooltip div { display: flex; justify-content: space-between; gap: 14px; }
.tooltip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.chart-table { padding: 0 0 8px; }

/* ── Composer ────────────────────────────────────────────────────────────── */
.composer { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.step { padding: 22px 22px 8px; }
.step + .step { border-top: 1px solid var(--line); }
.step-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.step-num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--info-soft); color: var(--info-ink); font-size: 12px; font-weight: 700; }
.step-head h3 { margin: 0; font-size: 15px; }
.step-head p { margin: 0; font-size: 12.5px; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { border: 0; background: transparent; padding: 10px 12px; font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 8px; align-items: center; }
.tabs button.active { color: var(--ink); border-bottom-color: var(--brand-bright); }
.tabs button .n { font-size: 11px; padding: 0 7px; border-radius: 99px; background: var(--info-soft); color: var(--info-ink); }
.dropzone { display: grid; justify-items: center; gap: 6px; padding: 28px 16px; border: 1.5px dashed var(--line-strong); border-radius: 14px; background: var(--panel-soft); text-align: center; color: var(--muted); font-size: 13px; cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--brand-bright); background: var(--info-soft); }
.dropzone strong { color: var(--ink); font-size: 14px; }
.dropzone .ic { width: 26px; height: 26px; color: var(--brand-bright); }
.list-pick { display: grid; gap: 8px; }
.list-pick label { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); cursor: pointer; }
.list-pick label:hover { background: var(--panel-soft); }
.list-pick input { width: 17px; height: 17px; accent-color: var(--brand); }
.list-pick .name { flex: 1; font-weight: 600; }
.list-pick .n { color: var(--muted); font-size: 12px; }
.audience-summary { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 12px 0 14px; font-size: 12.5px; color: var(--muted); }
.audience-summary b { color: var(--ink); }
.audience-summary .bad { color: var(--bad-ink); }
.row-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tokens { display: flex; flex-wrap: wrap; gap: 6px; margin: -6px 0 12px; }
.token { border: 1px solid var(--line); background: var(--panel-soft); border-radius: 8px; padding: 3px 9px; font-family: var(--mono); font-size: 11.5px; color: var(--info-ink); }
.token:hover { border-color: var(--brand-bright); }
.counter { display: flex; justify-content: space-between; gap: 10px; margin: -8px 0 16px; font-size: 12px; color: var(--muted); }
.counter b { color: var(--ink); font-variant-numeric: tabular-nums; }
.counter .warn { color: var(--warn-ink); }
.radio-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.radio-cards label { display: flex; gap: 12px; padding: 14px; border-radius: 12px; border: 1px solid var(--line); cursor: pointer; }
.radio-cards label:has(input:checked) { border-color: var(--brand-bright); box-shadow: 0 0 0 3px var(--ring); }
.radio-cards input { accent-color: var(--brand); margin-top: 2px; }
.radio-cards strong { display: block; font-size: 13.5px; }
.radio-cards small { color: var(--muted); font-size: 12px; }

.preview { position: sticky; top: 20px; display: grid; gap: 18px; }
.phone { margin: 0 auto; width: 270px; padding: 12px; border-radius: 38px; background: #0b1020; box-shadow: var(--shadow-lg), inset 0 0 0 2px #273253; }
.phone-screen { border-radius: 28px; overflow: hidden; background: #f2f4f8; min-height: 380px; display: flex; flex-direction: column; }
[data-theme="dark"] .phone-screen { background: #151b2c; }
.phone-top { padding: 14px 16px 12px; text-align: center; background: rgba(255,255,255,.7); border-bottom: 1px solid #e5e8ef; }
[data-theme="dark"] .phone-top { background: #1b2336; border-color: #252f47; }
.phone-avatar { width: 38px; height: 38px; margin: 0 auto 5px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, #3b56d0, #22348a); color: #fff; font-weight: 700; font-size: 14px; }
.phone-top strong { font-size: 12.5px; }
.phone-top small { display: block; font-size: 10.5px; color: var(--muted); }
.phone-body { padding: 16px 12px; display: grid; gap: 6px; align-content: start; }
.phone-time { text-align: center; font-size: 10.5px; color: var(--muted); }
.phone-bubble { justify-self: start; max-width: 88%; padding: 9px 12px; border-radius: 18px 18px 18px 5px; background: #e4e7ee; color: #0f172a; font-size: 13px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
[data-theme="dark"] .phone-bubble { background: #26304a; color: #eef1ff; }
.phone-bubble.placeholder { color: #8a94a8; font-style: italic; }
.summary { padding: 18px 20px; display: grid; gap: 10px; }
.summary .line { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.summary .line b { color: var(--ink); font-variant-numeric: tabular-nums; }
.summary .total { padding-top: 10px; border-top: 1px solid var(--line); font-size: 14px; }
.summary .btn-primary { margin-top: 6px; min-height: 48px; font-size: 14px; }

/* ── Detail header ───────────────────────────────────────────────────────── */
.detail-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-bottom: 18px; }
.detail-head .back { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted) !important; }
.detail-head .back:hover { color: var(--ink) !important; }
.detail-head h3 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.detail-head .spacer { flex: 1; }
.detail-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.message-card { padding: 18px 20px; }
.message-card .text { margin: 0 0 14px; padding: 14px 16px; border-radius: 14px; background: var(--panel-soft); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.55; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }

/* Cards grid (templates, lists) */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { padding: 18px; display: grid; gap: 10px; align-content: start; color: inherit !important; transition: box-shadow .15s, transform .15s, border-color .15s; }
a.card:hover, .card.hoverable:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: var(--line-strong); }
.card h4 { margin: 0; font-size: 14.5px; }
.card p { margin: 0; color: var(--ink-soft); font-size: 13px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.card .foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.card .foot .spacer { flex: 1; }
.card-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--info-soft); color: var(--info-ink); }
.big-number { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }

/* Code */
.code { position: relative; margin: 0 0 16px; padding: 16px 18px; border-radius: 14px; background: #0b1226; color: #dbe3ff; font-family: var(--mono); font-size: 12.5px; line-height: 1.65; overflow-x: auto; white-space: pre; }
.code .copy { position: absolute; top: 10px; right: 10px; }
.code .c { color: #7f8fc4; }
.code .s { color: #7be0c3; }
.secret { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--panel-soft); border: 1px dashed var(--line-strong); font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
.secret span { flex: 1; }

/* ── Modal / drawer ──────────────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(8, 12, 30, .45); backdrop-filter: blur(3px); animation: fade .2s ease; }
@keyframes fade { from { opacity: 0 } }
.modal { width: 100%; max-width: 520px; max-height: calc(100dvh - 32px); overflow-y: auto; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-lg); animation: pop .25s var(--ease); }
.modal.wide { max-width: 760px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98) } }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 22px 24px 6px; }
.modal-head h3 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.modal-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.modal-head .icon-btn { margin: -6px -8px 0 auto; }
.modal-body { padding: 16px 24px 8px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px 22px; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(8, 12, 30, .35); animation: fade .2s ease; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 61; width: min(460px, 100%); background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .3s var(--ease); }
@keyframes slide { from { transform: translateX(30px); opacity: 0 } }
.drawer .modal-body { flex: 1; overflow-y: auto; }

/* Toasts */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 80; display: grid; gap: 10px; }
.toast { display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 420px; padding: 12px 16px; border-radius: 13px; background: var(--ink-soft); color: #fff; font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); animation: pop .25s var(--ease); }
[data-theme="dark"] .toast { background: #e2e8f0; color: #0f172a; }
.toast .ic { width: 16px; height: 16px; }
.toast.ok .ic { color: var(--ok); }
.toast.err .ic { color: #f87171; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .composer { grid-template-columns: minmax(0, 1fr) 300px; }
}
@media (max-width: 1100px) {
  .composer { grid-template-columns: minmax(0, 1fr); }
  .preview { position: static; grid-template-columns: 1fr 1fr; align-items: start; }
}
@media (max-width: 900px) {
  .app-view { grid-template-columns: minmax(0, 1fr); padding-bottom: 74px; }
  .rail { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: 66px; z-index: 30; flex-direction: row; align-items: center; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
  .rail::after { top: 0; bottom: auto; }
  .rail-logo, .rail-live { display: none; }
  .rail-items { display: flex; flex: 1; justify-content: space-around; gap: 2px; }
  .rail-item { flex: 1; padding: 7px 0 5px; font-size: 10px; gap: 3px; }
  .rail-item[data-extra] { display: none; }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; width: 280px; background: var(--panel); box-shadow: var(--shadow-lg); transform: translateX(-105%); transition: transform .3s var(--ease); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 45; border: 0; background: rgba(8, 12, 30, .4); }
  .workspace { padding: 0 16px 16px; }
  .menu-btn { display: inline-grid; margin-left: -8px; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 14px 0; }
  .title-block h2 { font-size: 20px; }
  .search { order: 5; flex-basis: 100%; max-width: none; margin: 0; }
  .title-block { flex: 1 1 0; }
  .top-actions [data-action="refresh"] { display: none; }
  .mobile-only { display: block; }
  .top-actions .status-pill .status-text { display: none; }
  .top-actions .status-pill { padding: 0 11px; margin-right: 2px; }
  .grid-halves, .row-fields, .radio-cards { grid-template-columns: minmax(0, 1fr); }
  .preview { grid-template-columns: minmax(0, 1fr); }
  .row .progress { display: none; }
  .table .msg { max-width: 200px; }
  .toasts { left: 16px; right: 16px; bottom: 84px; }
  .toast { min-width: 0; max-width: none; }
}
@media (max-width: 520px) {
  .grid-kpi { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
  .kpi { padding: 14px; }
  .kpi .value { font-size: 24px; }
  .detail-head .actions { width: 100%; }
  .facts { grid-template-columns: minmax(0, 1fr); }
  .seg { max-width: 100%; overflow-x: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Heading text takes the free space so header buttons stay on its line. */
.panel-head > div:first-child { flex: 1 1 220px; min-width: 0; }
.panel-head > div:first-child + .spacer { display: none; }
