/* Graphite, the customer pages' design system: one token set (light and dark), Geist type, a 4 px grid. */

/* Geist and Geist Mono, from the gateway itself (public/fonts, SIL Open Font License). */
@font-face { font-family: 'Geist'; font-style: normal; font-weight: 400; font-display: swap; src: url(/static/fonts/geist-400.woff2) format('woff2'); }
@font-face { font-family: 'Geist'; font-style: normal; font-weight: 500; font-display: swap; src: url(/static/fonts/geist-500.woff2) format('woff2'); }
@font-face { font-family: 'Geist'; font-style: normal; font-weight: 600; font-display: swap; src: url(/static/fonts/geist-600.woff2) format('woff2'); }
@font-face { font-family: 'Geist Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url(/static/fonts/geist-mono-400.woff2) format('woff2'); }
@font-face { font-family: 'Geist Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url(/static/fonts/geist-mono-500.woff2) format('woff2'); }

:root {
  /* Graphite neutrals. */
  --ink: #111318;
  --ink-2: #353b47;
  --muted: #5e6675;
  --control: #7d8594;
  --border-strong: #c9ced6;
  --line: #e3e6eb;
  --subtle: #eef0f3;
  --canvas: #f6f7f9;
  --surface: #ffffff;
  /* Phone Gateway's accent, signal blue. A partner's colour replaces it under white label (brand.js). */
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-soft: #eef3fe;
  --on-accent: #ffffff;
  /* State: ok, attention, problem (always with a word or an icon). */
  --ok: #15803d;
  --ok-bg: #eef8f1;
  --warn: #a15c07;
  --warn-bg: #fef6e7;
  --warn-line: #f1d7a8;
  --bad: #b42318;
  --bad-bg: #fef1f0;
  --bad-line: #f3c4bf;
  --shadow-pop: 0 12px 32px rgba(17, 19, 24, .10);
  --sans: 'Geist', ui-sans-serif, system-ui, sans-serif;
  --mono: 'Geist Mono', ui-monospace, monospace;
  --control-h: 36px;
  --gutter: 24px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #eceef2;
    --ink-2: #c4cad3;
    --muted: #9aa3b2;
    --control: #6e7685;
    --border-strong: #3a404b;
    --line: #262b33;
    --subtle: #1e2229;
    --canvas: #0b0d11;
    --surface: #14171d;
    --accent: #93c5fd;
    --accent-hover: #bfdbfe;
    --accent-soft: #172338;
    --on-accent: #14171d;
    --ok: #74d99f;
    --ok-bg: #12261b;
    --warn: #f2c26b;
    --warn-bg: #2b2111;
    --warn-line: #59431c;
    --bad: #f7a59c;
    --bad-bg: #2e1614;
    --bad-line: #5c2a25;
    --shadow-pop: 0 12px 32px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
/* Touch and phone widths: 44 px controls, 16 px gutters. */
@media (max-width: 640px), (pointer: coarse) { :root { --control-h: 44px; } }
@media (max-width: 640px) { :root { --gutter: 16px; } }

* { box-sizing: border-box; }
/* A field scrolled to (the first one wrong, a question to answer) isn't hidden under the sticky header,
   nor under sticky announcement banners above it (--anx-top: their height, set by app.js while they show). */
html { scroll-padding-top: calc(128px + var(--anx-top, 0px)); -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 14px/22px var(--sans); background: var(--canvas); color: var(--ink); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; color: var(--ink); }
h1 { font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 16px; line-height: 24px; font-weight: 600; }
h3 { font-size: 14px; line-height: 22px; font-weight: 600; }
p, ul, ol, dl { margin: 0; }
b, strong { font-weight: 600; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 20px; }
.mono, code { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.break { overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.hidden, [hidden] { display: none !important; }
/* Tabs hidden while the sub-account sees a page of its own (its trial ended), whatever else shows them. */
.landing-hidden, body.landing [data-help] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* Focus shows for the keyboard only: 3 px of the accent. */
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }

/* ------------------------------------------------------------ the frame */

/* Header, content and footer share one edge: at most 1200 px, 24 px in (16 on a phone). */
.shell { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 var(--gutter); }
.topbar { position: sticky; top: var(--anx-top, 0px); z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
/* On a white tile like the app icon, so the logo's dark blue stays visible in dark mode. */
.logo { display: block; width: 28px; height: 28px; padding: 2px; border-radius: 8px; background: #fff; box-shadow: 0 0 0 1px var(--line); object-fit: contain; flex: none; }
/* A partner's logo (white-label): any shape, as tall as the app's, at most 140 px wide. */
.logo.brand-logo { width: auto; max-width: 140px; }
/* A partner without a logo: the first letter of its name in its colours. */
.logo-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 14px; flex: none; }
.title { font-size: 15px; line-height: 22px; font-weight: 600; white-space: nowrap; }
.subtitle { font-size: 13px; line-height: 20px; color: var(--muted); white-space: nowrap; }
/* Until the page knows whose brand to show (the app's or a partner's), the header names nobody
   (shown anyway after 8 seconds, should the script never get that far). */
.brand-pending .topbar .brand { visibility: hidden; animation: brand-reveal 0s linear 8s forwards; }
@keyframes brand-reveal { to { visibility: visible; } }
.account { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; line-height: 20px; color: var(--ink-2); }
.account #location-name { font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 999px; background: var(--subtle); color: var(--ink-2); font-size: 12px; line-height: 16px; font-weight: 500; white-space: nowrap; flex: none; }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
@media (max-width: 640px) { .chip .chip-state { display: none; } }

/* The sections: an underline tab bar, scrolled sideways on a phone (never cut short). */
.tabs { display: flex; gap: 4px; margin: 0 -12px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; height: 44px; padding: 0 12px; border: 0; border-radius: 0; background: none; color: var(--muted); font: inherit; cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-current="page"] { color: var(--ink); font-weight: 500; box-shadow: inset 0 -2px 0 var(--accent); }
/* More sections off to a side (a phone's width): that edge fades, so the row reads as one to scroll. */
.tabs.more-right { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent); }
.tabs.more-left { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 48px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 48px), transparent); }
.tabs.more-left.more-right { -webkit-mask-image: linear-gradient(to right, transparent, #000 48px, #000 calc(100% - 48px), transparent); mask-image: linear-gradient(to right, transparent, #000 48px, #000 calc(100% - 48px), transparent); }

main.shell { display: flex; flex-direction: column; gap: 24px; padding-top: 32px; padding-bottom: 64px; }
.tab, .tab-body { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
@media (max-width: 640px) { main.shell { padding-top: 24px; padding-bottom: 48px; } }

/* A section's title (24/32) and one line on what it is for, its action on the right. */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; }
.page-head > div:first-child { display: flex; flex-direction: column; gap: 4px; flex: 1 1 420px; min-width: 0; }
.page-desc { color: var(--muted); max-width: 760px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------ layout */

.card { display: flex; flex-direction: column; gap: 16px; min-width: 0; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.card-head, .account-head { display: flex; justify-content: space-between; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.card-head > a { font-size: 13px; line-height: 20px; text-decoration: none; }
/* A card's own actions sit at its foot, level with the card beside it. */
.card-actions { margin-top: auto; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1 1 auto; min-width: 0; }
/* One 12-column grid: 3 up (4 each), main and side (8 and 4), halves (6 and 6). */
.grid-12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gutter); align-items: stretch; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: 1 / -1; }
@media (max-width: 960px) { .span-4, .span-6, .span-8 { grid-column: 1 / -1; } }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 640px) { .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* Notices: what needs the user, tinted by state. */
.notice { display: flex; flex-direction: column; gap: 8px; padding: 16px 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.notice.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.notice.bad { background: var(--bad-bg); border-color: var(--bad-line); }
.notice .muted { color: var(--ink-2); }
/* Texts from your CRM (Phones tab): its words at a reading width, its buttons under them. */
.sms-check p, .finish-setup p { max-width: 760px; }
.sms-check .row, .finish-setup .row { margin-top: 4px; }
.sms-check .row > a:not(.btn), .finish-setup .row > a:not(.btn) { font-size: 13px; line-height: 20px; }
/* Finish setup: the steps to choose the app as the CRM's SMS provider, right after the install. */
.finish-setup { border-color: var(--accent); }
.finish-setup .steps { color: var(--ink); max-width: 760px; }
.finish-setup.quiet { padding: 12px 16px; border-color: var(--line); }

/* ------------------------------------------------------------ controls */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--control-h); padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; line-height: 20px; white-space: nowrap; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--subtle); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn.danger { color: var(--bad); border-color: var(--bad-line); }
.btn.danger:hover { background: var(--bad-bg); color: var(--bad); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.quiet:hover { background: var(--subtle); }
.btn.small { padding: 0 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:disabled:hover { background: var(--surface); }
.btn.primary:disabled:hover { background: var(--accent); }

input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--control); border-radius: 10px; }
input, select { height: var(--control-h); padding: 0 12px; }
textarea { min-height: 88px; padding: 8px 12px; resize: vertical; }
select { -webkit-appearance: none; appearance: none; padding-right: 36px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%237d8594' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 12px center; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
input:disabled, select:disabled, textarea:disabled { background-color: var(--canvas); color: var(--ink-2); cursor: not-allowed; }
input[type=number], input[type=tel], .mono-input { font-family: var(--mono); font-variant-numeric: tabular-nums; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; margin: 3px 0 0; padding: 0; flex: none; accent-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; line-height: 20px; font-weight: 500; }
.field small { font-size: 13px; line-height: 20px; color: var(--muted); }
.field .field-error { display: flex; gap: 6px; align-items: flex-start; color: var(--bad); }
.field .field-error::before { content: "!"; display: grid; place-items: center; flex: none; width: 14px; height: 14px; margin-top: 3px; border: 1.5px solid currentColor; border-radius: 999px; font-size: 10px; line-height: 1; font-weight: 600; }
[aria-invalid="true"] { border-color: var(--bad); }
.check, .choice { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.check > span, .choice > span { min-width: 0; }

/* Badges: a tint, a dot or icon, and a word. */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border-radius: 999px; background: var(--subtle); color: var(--ink-2); font-size: 12px; line-height: 16px; font-weight: 500; white-space: nowrap; flex: none; }
.badge .dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; flex: none; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }

/* Placeholders in the shape of what is loading (the page's figures, a tab's list). */
.skeleton { display: block; border-radius: 6px; background: var(--subtle); animation: skeleton-pulse 1.6s ease-in-out infinite; }
.skeleton + .skeleton { margin-top: 12px; }
.sk-title { width: 40%; height: 16px; }
.sk-line { width: 72%; height: 12px; }
.sk-row { height: 40px; }
.sk-block { height: 160px; }
.sk-figure { width: 50%; height: 28px; }
.list > .skeleton { margin: 12px 0; }
@keyframes skeleton-pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
/* Until the page's figures arrive, the settings form (which would show empty boxes) waits behind its placeholder. */
main:not(.is-loading) .settings-skeleton, .is-loading #settings-form { display: none; }
/* The page couldn't load: only the reason and Retry. */
main.boot-failed .tab { display: none; }

/* Tables: muted 12 px headings, 12 px rows, numbers in mono. Narrow screens scroll the box, never the page. */
.table-box { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.table { width: 100%; min-width: 560px; border-collapse: collapse; }
.table th { padding: 0 16px 8px 0; text-align: left; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.table td { padding: 12px 16px 12px 0; border-top: 1px solid var(--subtle); vertical-align: middle; }
.table th:last-child, .table td:last-child { padding-right: 0; }
.table .end { text-align: right; }
.table .time { font-family: var(--mono); font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.table .num { font-family: var(--mono); white-space: nowrap; }
.table .text { color: var(--ink-2); max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-empty { color: var(--muted); }

/* Lists (history, channel messages): rows with the detail on the right. */
.list { display: flex; flex-direction: column; }
.item { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; border-top: 1px solid var(--subtle); }
.item:first-child { border-top: 0; padding-top: 0; }
.item:last-child { padding-bottom: 0; }
.item .main { min-width: 0; }
.item .body { color: var(--ink-2); overflow-wrap: anywhere; }
.item .side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; font-size: 13px; line-height: 20px; color: var(--muted); text-align: right; }

/* Dialogs: a sheet over the page (from the bottom on a phone), one title, real verbs. */
dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop); }
dialog::backdrop { background: rgba(17, 19, 24, .5); }
.dialog-body { display: flex; flex-direction: column; gap: 16px; padding: 24px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.dialog-head h2 { font-size: 20px; line-height: 28px; }
.dialog-x { display: grid; place-items: center; flex: none; width: 36px; height: 36px; margin: -4px -8px 0 0; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; }
.dialog-x:hover { background: var(--subtle); color: var(--ink); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding-top: 8px; }
@media (max-width: 640px) {
  dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 14px 14px 0 0; max-height: 92dvh; }
  .dialog-body { padding: 20px 16px 24px; }
  .dialog-actions .btn { flex: 1 1 0; }
}
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; color: var(--ink-2); }
.pair-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; align-items: center; }
.pair-grid > div:last-child { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
@media (max-width: 480px) { .pair-grid { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; } .pair-grid > div:last-child { align-items: center; } }
.qr { width: 200px; height: 200px; padding: 6px; border-radius: 10px; background: #fff; box-shadow: 0 0 0 1px var(--line); }
.qr svg { display: block; width: 100%; height: 100%; }
/* A pairing code that has expired: its QR code can't link a phone any more. */
.qr.expired { opacity: .2; }
.pair-code { font-family: var(--mono); font-size: 28px; line-height: 36px; font-weight: 500; letter-spacing: .12em; }

/* Toasts: one at a time, bottom right (bottom centre on a phone). */
#toast-area { position: fixed; right: 24px; bottom: 24px; z-index: 30; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { padding: 12px 16px; border-radius: 10px; background: var(--ink); color: var(--surface); box-shadow: var(--shadow-pop); font-size: 14px; line-height: 20px; pointer-events: auto; }
.toast.error { background: #b42318; color: #fff; }
@media (max-width: 640px) { #toast-area { left: 16px; right: 16px; bottom: 16px; width: auto; } }

/* A settings form's sticky save bar: only while something is changed, at the bottom of the screen. */
.save-bar { position: sticky; bottom: 16px; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; padding: 12px 12px 12px 20px; border-radius: 14px; background: var(--ink); color: var(--surface); box-shadow: 0 12px 32px rgba(17, 19, 24, .18); }
.save-bar .btn { border-color: transparent; }
.save-bar .btn.quiet { color: var(--line); }
.save-bar .btn.quiet:hover { background: color-mix(in srgb, var(--surface) 12%, transparent); color: var(--surface); }
.save-bar .btn.primary, .save-bar .btn.primary:hover { background: var(--surface); color: var(--ink); }

/* ------------------------------------------------------------ Phones */

/* Setup until it is done: one segment per step, the next step's action as the primary button. */
.setup ol { display: grid; grid-template-columns: repeat(var(--steps, 4), minmax(0, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.setup li { display: flex; flex-direction: column; gap: 8px; min-width: 0; color: var(--ink-2); }
.setup li::before { content: ""; height: 4px; border-radius: 999px; background: var(--line); }
.setup li.done::before { background: var(--accent); }
.setup li > span { display: flex; align-items: center; gap: 8px; }
.setup li.next > span { color: var(--ink); font-weight: 500; }
.setup li svg { flex: none; }
.setup .hint { color: var(--ink-2); }
.setup .tick, .setup .ring { position: relative; flex: none; width: 16px; height: 16px; border-radius: 999px; }
.setup .tick { background: var(--ok); }
.setup .tick::after { content: ""; position: absolute; left: 5px; top: 2.5px; width: 4px; height: 8px; border: solid var(--surface); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.setup .ring { border: 1.5px solid var(--control); }
/* On a phone the steps are a list (the heading already counts them), so none sits alone on a row. */
@media (max-width: 640px) { .setup ol { grid-template-columns: minmax(0, 1fr); gap: 8px; } .setup li::before { display: none; } }

/* Three figures: a label, a number in mono, one line of context. */
.figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gutter); }
.figure { gap: 4px; }
.figure .label { font-size: 13px; line-height: 20px; color: var(--muted); }
.figure .value { font-family: var(--mono); font-size: 28px; line-height: 36px; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.figure .context { font-size: 13px; line-height: 20px; color: var(--ink-2); }
@media (max-width: 960px) {
  .figures { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  /* One line each on a narrow screen: label and context on the left, the number on the right. */
  .figure { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 16px; padding: 16px 20px; }
  .figure .value { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
}

/* Phones, three to a row, the same height; the last one takes what's left of its row (never an orphan). */
.phone-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gutter); align-items: stretch; }
.phone-grid > :last-child:nth-child(3n + 1) { grid-column: 1 / -1; }
.phone-grid > :last-child:nth-child(3n + 2) { grid-column: span 2; }
@media (max-width: 1100px) {
  .phone-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .phone-grid > :last-child:nth-child(n) { grid-column: auto; }
  .phone-grid > :last-child:nth-child(2n + 1) { grid-column: 1 / -1; }
}
@media (max-width: 700px) { .phone-grid { grid-template-columns: minmax(0, 1fr); } .phone-grid > :last-child:nth-child(n) { grid-column: auto; } }
.phone-card { gap: 16px; }
.phone-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.phone-head > div { display: flex; flex-direction: column; min-width: 0; }
.phone-name { font-size: 16px; line-height: 24px; overflow-wrap: anywhere; }
.phone-model { font-size: 13px; line-height: 20px; color: var(--muted); }
.phone-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.phone-facts > div { display: flex; flex-direction: column; min-width: 0; }
.phone-facts dt { font-size: 12px; line-height: 16px; color: var(--muted); }
.phone-facts dd { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phone-facts dd.mono { font-size: 14px; }
.lines { display: flex; flex-direction: column; gap: 12px; }
.line { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.line-top { display: flex; gap: 8px; align-items: center; }
.line .sim { flex: none; display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: 6px; background: var(--subtle); color: var(--ink-2); font-size: 12px; line-height: 16px; font-weight: 500; }
.line-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 13px; line-height: 20px; color: var(--muted); }
.line-meta .badge { flex: 0 1 auto; min-width: 0; white-space: normal; height: auto; min-height: 24px; padding: 2px 8px; }
/* A sentence, not a status: it may take two lines on a phone. */
.line-meta .badge.warn { border-radius: 10px; }
.line-actions { display: flex; gap: 8px; flex-wrap: wrap; }
/* A SIM the gateway keeps off (its number in use in another account, or unknown): why, and what to do. */
.line-block { margin: 0; padding: 10px 12px; gap: 4px; border-radius: 10px; }
.line-block p { margin: 0; }
.phone-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: auto; padding-top: 16px; border-top: 1px solid var(--subtle); }
@media (max-width: 640px) { .line-actions .btn { flex: 1 1 calc(50% - 4px); } }
/* Pair another phone: a dashed card in the grid (a slim row of its own when it starts a row). */
.pair-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 200px; padding: 20px; border: 1.5px dashed var(--border-strong); border-radius: 14px; background: transparent; color: var(--ink-2); font: inherit; text-align: center; cursor: pointer; }
.phone-grid > .pair-card:last-child:nth-child(3n + 1) { flex-direction: row; min-height: 88px; gap: 12px; }
@media (max-width: 1100px) {
  .phone-grid > .pair-card:last-child:nth-child(3n + 1) { flex-direction: column; min-height: 200px; }
  .phone-grid > .pair-card:last-child:nth-child(2n + 1) { flex-direction: row; min-height: 88px; }
}
@media (max-width: 700px) { .phone-grid > .pair-card:last-child:nth-child(n) { flex-direction: row; min-height: 88px; text-align: left; } }
.pair-card:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.pair-card:disabled { cursor: not-allowed; }
.pair-card .plus { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 999px; background: var(--subtle); color: var(--ink); }
.pair-card b { color: var(--ink); font-weight: 500; }
.pair-card .small { color: var(--muted); max-width: 320px; }

/* ------------------------------------------------------------ Channels */

.channel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gutter); align-items: stretch; }
.channel-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
@media (max-width: 800px) { .channel-grid { grid-template-columns: minmax(0, 1fr); } }
.channels-later .item .main { flex-wrap: nowrap; align-items: flex-start; }
.channel-card { gap: 16px; }
.channel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.channel-name { display: flex; align-items: center; gap: 10px; font-size: 16px; line-height: 24px; font-weight: 600; min-width: 0; }
/* A channel's mark, 32 px whatever else the page styles: its classes are its own (mark-<tone>, never a
   bare channel id: `.line` above is a phone's SIM line), and nothing may pad or border it. */
.channel-mark { display: inline-flex; align-items: center; justify-content: center; flex: none; box-sizing: border-box; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px; color: #fff; font-size: 14px; font-weight: 600; }
.channel-mark.mark-telegram { background: #2aa3df; }
.channel-mark.mark-viber { background: #7360f2; }
.channel-mark.mark-line { background: #06c755; }
.channel-mark.mark-discord { background: #5865f2; }
.channel-mark.mark-planned { background: var(--subtle); color: var(--ink-2); }
/* The channel's logo (drawn in the page) or the owner's icon for it, in place of the letter. */
.channel-mark.icon { background: none; overflow: hidden; }
.channel-mark img, .channel-mark svg { display: block; flex: none; width: 32px; height: 32px; object-fit: contain; }
.channel-facts, .facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; }
.channel-facts dt, .facts dt { color: var(--muted); }
.channel-facts dd, .facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.channel-share { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; align-items: center; }
.channel-share > div { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.channel-share .qr { width: 112px; height: 112px; }
.channel-share a { display: block; font-family: var(--mono); font-size: 13px; line-height: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-note { padding: 12px; border-radius: 10px; background: var(--canvas); color: var(--ink-2); font-size: 13px; line-height: 20px; }
.channel-usage { font-size: 13px; line-height: 20px; color: var(--muted); }
.channel-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
/* A channel the plan doesn't include: its mark greyed, so the ones in the plan stand out. */
.channel-card.off-plan .channel-mark { filter: grayscale(1); opacity: .55; }
.form-error { color: var(--bad); }
@media (max-width: 480px) { .channel-share { grid-template-columns: minmax(0, 1fr); } }

/* ------------------------------------------------------------ Dialer */

.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.keypad button { height: 48px; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas); color: var(--ink); font-family: var(--mono); font-size: 18px; font-weight: 500; cursor: pointer; }
.keypad button:hover { background: var(--subtle); }
.dial-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.dial-actions:has(#hangup-btn:not(.hidden)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.live-call { display: flex; flex-direction: column; gap: 4px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.live-call.ringing { border-color: var(--accent); background: var(--accent-soft); }

/* ------------------------------------------------------------ Settings */

/* Each group: its name and what it does on the left (4), its fields on the right (8). */
.settings-group { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px var(--gutter); }
.settings-group > .about { grid-column: span 4; display: flex; flex-direction: column; gap: 4px; }
.settings-group > .fields { grid-column: span 8; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 960px) { .settings-group > .about, .settings-group > .fields { grid-column: 1 / -1; } }
.field.narrow { max-width: 360px; }

/* ------------------------------------------------------------ Subscription */

/* Plan usage meters. */
.meters { display: flex; flex-direction: column; gap: 16px; }
.meter .label { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; line-height: 20px; color: var(--ink-2); }
.meter .label b { color: var(--ink); font-family: var(--mono); font-weight: 500; white-space: nowrap; }
.meter .bar { height: 6px; margin-top: 6px; border-radius: 999px; background: var(--subtle); overflow: hidden; }
.meter .bar > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.meter.warn .bar > span { background: var(--warn); }
.meter.full .bar > span { background: var(--bad); }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: var(--gutter); align-items: stretch; }
.plan-option { display: flex; flex-direction: column; gap: 12px; padding: 20px; border: 1px solid var(--line); border-radius: 14px; }
.plan-option.current { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.plan-option > .account-head b { font-size: 16px; line-height: 24px; font-weight: 600; }
.plan-option .price { font-family: var(--mono); font-size: 20px; line-height: 28px; font-weight: 500; }
.plan-option .price .muted { font-family: var(--sans); font-size: 13px; font-weight: 400; }
.plan-option ul { display: flex; flex-direction: column; gap: 4px; padding-left: 18px; color: var(--ink-2); font-size: 13px; line-height: 20px; }
.plan-option > .btn { margin-top: auto; }
.facts dd { font-variant-numeric: tabular-nums; }
.invoice { display: flex; justify-content: space-between; align-items: center; gap: 12px 16px; flex-wrap: wrap; padding: 16px; border: 1px solid var(--accent); border-radius: 10px; background: var(--accent-soft); }
.invoice .amount { font-family: var(--mono); font-size: 20px; line-height: 28px; font-weight: 500; }
.pay-text { padding: 12px 16px; border-radius: 10px; background: var(--canvas); border: 1px solid var(--line); font-family: var(--mono); font-size: 13px; line-height: 20px; white-space: pre-wrap; overflow-wrap: anywhere; }
/* Their plan (or the one chosen for the renewal) is no longer for sale. */
.notice-text { padding: 12px 16px; border-radius: 10px; background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--ink); }
.pending-request { padding: 12px 16px; border-radius: 10px; background: var(--accent-soft); color: var(--ink); }
/* A subscription a white-label partner manages (collects): who, its invoice, how to reach it. */
.managed { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px; border-radius: 10px; background: var(--canvas); border: 1px solid var(--line); }
.managed-ways { overflow-wrap: anywhere; }
.choice { padding: 4px 0; }
.choice input[type=date] { width: auto; margin-left: 8px; }
.block-banner { flex-direction: row; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.block-banner > div { display: flex; flex-direction: column; gap: 4px; flex: 1 1 420px; min-width: 0; }

/* Build your own: the calculator (amounts on the left, the price beside them; one column on a phone). */
.byo-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: var(--gutter); align-items: start; }
@media (max-width: 960px) { .byo-grid { grid-template-columns: minmax(0, 1fr); } }
.byo-controls, .byo-term, .byo-change { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.byo-item { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding-bottom: 16px; border-bottom: 1px solid var(--subtle); }
.byo-item-head { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; }
.byo-item-head label { font-weight: 500; }
.byo-item-price { font-family: var(--mono); font-size: 13px; line-height: 20px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.byo-qty { display: grid; grid-template-columns: auto minmax(0, 1fr) auto 112px; grid-template-areas: "less range more num"; gap: 8px; align-items: center; }
.byo-qty .byo-less { grid-area: less; }
.byo-qty input[type=range] { grid-area: range; }
.byo-qty .byo-more { grid-area: more; }
.byo-qty .byo-num { grid-area: num; }
.byo-qty input[type=range] { height: var(--control-h); padding: 0; border: 0; background: transparent; box-shadow: none; accent-color: var(--accent); }
.byo-step { width: var(--control-h); padding: 0; font-size: 18px; }
.byo-num { text-align: right; }
/* A phone: the slider across, then − the number + (thumb-sized). */
@media (max-width: 640px) { .byo-qty { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "range range range" "less num more"; } }
/* Below the side-by-side layout the price comes after every control: its total follows along the bottom. */
.byo-mini { display: none; }
@media (max-width: 960px) {
  .byo-mini:not(:empty) { position: sticky; bottom: 0; z-index: 2; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 0 -20px -20px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface); box-shadow: 0 -8px 16px rgba(17, 19, 24, .06); }
  .byo-mini b { font-family: var(--mono); font-weight: 500; font-size: 16px; }
}
.byo-feature { flex-direction: row; justify-content: space-between; align-items: flex-start; gap: 12px; }
.byo-help { display: block; }
.byo-hint:empty { display: none; }
.byo-discounts { display: flex; flex-wrap: wrap; gap: 6px; }
.byo-discounts:empty { display: none; }
/* Messages per channel while no chat channel is chosen: off, with why. */
.byo-locked .byo-item-head label, .byo-locked .byo-item-price { color: var(--muted); }
.byo-locked .byo-hint { color: var(--ink-2); }
.byo-summary { display: flex; flex-direction: column; gap: 12px; min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas); position: sticky; top: 128px; }
@media (max-width: 960px) { .byo-summary { position: static; } }
.byo-summary h4 { margin: 0; font-size: 13px; line-height: 20px; font-weight: 600; }
.byo-summary-body { display: flex; flex-direction: column; gap: 8px; }
.byo-rows { display: flex; flex-direction: column; gap: 8px; }
.byo-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 13px; line-height: 20px; }
.byo-row > span { min-width: 0; color: var(--ink-2); }
.byo-row > b { font-family: var(--mono); font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }
.byo-row.sub { padding-top: 8px; border-top: 1px solid var(--line); }
.byo-row.minus > b { color: var(--ok); }
.byo-row.total { padding-top: 12px; border-top: 1px solid var(--border-strong); font-size: 15px; line-height: 24px; }
.byo-row.total > span { color: var(--ink); font-weight: 600; }
.byo-row.total > b { font-size: 20px; line-height: 28px; }
.byo-note { display: block; }
.byo-total { display: flex; flex-direction: column; gap: 4px; }
.byo-total:empty, .byo-submit:empty { display: none; }
.byo-estimate { padding: 8px 12px; border-radius: 8px; background: var(--accent-soft); }
.byo-credit { margin: 0; padding: 8px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--ink); }
.byo-submit .btn { width: 100%; }
.byo-suggested { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); color: var(--ink); }
.linkish { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.linkish:hover { color: var(--accent-hover); }
.meter-note { color: var(--warn); }
.meter.full .meter-note { color: var(--bad); }
/* Over 80% of a build's amount, on every tab (Build your own). */
.build-banner { flex-direction: row; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.build-banner > div { display: flex; flex-direction: column; gap: 4px; flex: 1 1 420px; min-width: 0; }

/* ------------------------------------------------------------ Support */

.sp-dot { display: inline-block; width: 8px; height: 8px; border-radius: 999px; background: var(--accent); flex: none; }
.tabs .sp-dot { margin-left: 6px; vertical-align: 1px; }
.sp-tickets { display: flex; flex-direction: column; margin: 0 -12px; }
.sp-ticket { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; padding: 12px; border: 0; border-top: 1px solid var(--subtle); border-radius: 0; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.sp-ticket:first-child { border-top: 0; }
.sp-ticket:hover { background: var(--canvas); }
.sp-ticket-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sp-subject { display: flex; align-items: center; gap: 8px; font-weight: 500; overflow-wrap: anywhere; }
.sp-ticket.unread .sp-subject { font-weight: 600; }
.sp-ticket .badge { flex: none; }
.sp-title { overflow-wrap: anywhere; }
.sp-h3 { font-size: 16px; line-height: 24px; }
.sp-error { color: var(--bad); white-space: pre-wrap; }
.sp-error-text { color: var(--bad); }
/* A topic's own questions (any kind), each one under the other. */
.sp-questions { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.sp-questions:empty { display: none; }
.sp-question { min-width: 0; }
.sp-question .check span { overflow-wrap: anywhere; }
.sp-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px 16px; }
.sp-question.sp-invalid { outline: 2px solid var(--bad); outline-offset: 4px; border-radius: 10px; }
.sp-question input[type=date] { max-width: 240px; }
.sp-fieldset { display: flex; flex-direction: column; gap: 12px; min-width: 0; margin: 0; padding: 12px 16px 16px; border: 1px solid var(--line); border-radius: 10px; }
.sp-fieldset legend { padding: 0 4px; font-size: 13px; line-height: 20px; font-weight: 500; }
/* Facebook Messenger and Instagram: on a line of their own, with the 24-hour rule under them. */
.sp-meta-hint { display: block; }
.sp-connect-row + .sp-connect-row { margin-top: 8px; }
.sp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 16px; }
.sp-thread { display: flex; flex-direction: column; gap: 12px; }
.sp-msg { max-width: 85%; padding: 12px 16px; border: 1px solid var(--line); border-radius: 14px; }
.sp-msg.from-customer { align-self: flex-end; background: var(--canvas); }
.sp-msg.from-support { align-self: flex-start; border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); background: var(--accent-soft); }
.sp-msg-meta { margin-bottom: 4px; font-size: 13px; line-height: 20px; color: var(--muted); }
.sp-msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.sp-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.sp-file { display: inline-flex; flex-direction: column; gap: 4px; max-width: 180px; font-size: 13px; line-height: 20px; overflow-wrap: anywhere; }
.sp-file img { display: block; max-width: 160px; max-height: 120px; border: 1px solid var(--line); border-radius: 6px; object-fit: cover; background: var(--canvas); }
.sp-attach { display: flex; flex-direction: column; gap: 8px; }
.sp-file-input { display: none; }
.sp-file-list { display: flex; flex-direction: column; gap: 4px; }
.sp-file-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; }
.sp-file-row.failed { border-color: var(--bad-line); background: var(--bad-bg); }
.sp-file-name { overflow-wrap: anywhere; }
.sp-back { align-self: flex-start; }
@media (max-width: 640px) {
  .sp-msg { max-width: 100%; }
  .sp-ticket { flex-direction: column; align-items: flex-start; }
}

/* "Delete all my data": kept apart, at the bottom of the Subscription tab. */
.danger-zone { border-color: var(--bad-line); }
.deletion-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: var(--gutter); }
.deletion-lists h3 { font-size: 14px; line-height: 20px; font-weight: 600; margin-bottom: 4px; }
.deletion-lists ul { display: flex; flex-direction: column; gap: 4px; padding-left: 18px; color: var(--ink-2); font-size: 13px; line-height: 20px; }

/* Build your own for agencies: the Agency section (agency admins only) and a covered sub-account's own notes. */
.agency-build, .agency-coverage, .agency-card { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.agency-build h3, .agency-coverage h3 { margin: 4px 0 0; }
.agency-exclude .check { justify-content: flex-end; align-items: center; position: relative; }
.agency-coverage .table { min-width: 0; }
.agency-coverage .table td .muted { white-space: nowrap; }
.meter.shared .label b { color: var(--ink-2); }
.notice.agency-note { margin: 0; }
@media (max-width: 480px) { .agency-build .facts { grid-template-columns: minmax(0, 1fr); gap: 2px; } .agency-build .facts dd + dt { margin-top: 8px; } }

/* Finish setup: the setting's link to send the agency (its owner and admins alone see the setting). */
.agency-send p { margin: 0 0 6px; }
.agency-send .agency-link { flex: 1 1 260px; min-width: 0; }
