/* Teltik migration portal — mobile-first.
   Most customers will open this from an email on a phone. Design accordingly. */

:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --ink: #14202e;
  --ink-2: #47566a;
  --ink-3: #6d7c90;
  --line: #dde4ec;
  --line-2: #c4cfdc;
  /* Teltik brand purple, sampled from the brand swatch.
     Change it in ONE place: BRAND_COLOUR in .env overrides this at runtime via
     the nonce'd <style> block in src/views.js, so a brand tweak needs no
     rebuild and no edit here.

     --brand on white is 8.8:1 and white on --brand is the same, so it carries
     text and buttons at AA either way round. --brand-dark and --brand-bright are
     the two ends of the ring's gradient in the logo, used together only as an
     accent rule — --brand-bright on white is 4.75:1, fine for a border or large
     type and NOT for body copy. */
  --brand: #6419b9;
  --brand-dark: #4e00b2;
  --brand-bright: #b600fe;
  --brand-tint: #f5f0fc;
  --ok: #1a7a4c;
  --ok-tint: #eaf6f0;
  --warn: #8a5a00;
  --warn-tint: #fdf5e6;
  --err: #b4232a;
  --err-tint: #fdeeee;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(22, 32, 46, .06), 0 4px 16px rgba(22, 32, 46, .06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Masthead, matching teltik.com: white bar, wordmark left, phone number right.
   The number is not decoration — a customer who suspects a phishing page can
   read the real support line off the top of the page and dial it, which is the
   cheapest reassurance available and costs one line of markup. */
.masthead {
  background: var(--surface);
  color: var(--ink);
  padding: 13px 20px;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(20, 32, 46, .05);
  /* The ring's gradient, as a hairline. The distinctive part of the mark, used
     where it cannot affect the legibility of anything. */
  border-top: 3px solid transparent;
  border-image: linear-gradient(90deg, var(--brand-dark), var(--brand-bright)) 1;
  border-image-slice: 1;
  border-left: 0; border-right: 0;
}
.masthead-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.wordmark {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--brand);
  display: flex;
  align-items: center;
  gap: 9px;
}
/* The supplied asset is 177x56 with a transparent ground, so at 28px high the
   browser downsamples exactly 2x — sharp on a retina screen with no upscaling. */
.wordmark img { height: 28px; width: auto; display: block; }
.masthead .secure {
  font-size: 13px;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 6px;
  text-align: right;
}
.masthead .secure a { color: var(--ink); font-weight: 600; text-decoration: none; white-space: nowrap; }
.masthead .secure a:hover { color: var(--brand); }
.masthead .secure .lbl { color: var(--ink-3); }

@media (max-width: 460px) {
  .masthead .secure .lbl { display: none; }
  .wordmark { font-size: 19px; }
}

.wrap { max-width: 720px; margin: 0 auto; padding: 20px 16px 64px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 20px;
  margin-bottom: 16px;
}

h1 { font-size: 22px; line-height: 1.3; margin: 0 0 8px; letter-spacing: -.015em; }
h2 { font-size: 16px; margin: 0 0 4px; letter-spacing: -.01em; }
.lede { color: var(--ink-2); margin: 0 0 4px; }

.acct {
  background: var(--brand-tint);
  border: 1px solid #e0d3f2;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.acct-row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 3px 0; }
.acct-row dt { color: var(--ink-2); margin: 0; }
.acct-row dd { margin: 0; font-weight: 600; text-align: right; }
.acct h2 { font-size: 15px; margin-bottom: 8px; }

.wrong-acct { font-size: 13px; color: var(--ink-3); margin: 10px 0 0; }
.wrong-acct a { color: var(--brand); }

fieldset { border: 0; padding: 0; margin: 0 0 26px; }
fieldset:last-of-type { margin-bottom: 8px; }
legend { padding: 0; font-size: 16px; font-weight: 650; margin-bottom: 3px; letter-spacing: -.01em; }
.hint { color: var(--ink-3); font-size: 13.5px; margin: 0 0 14px; }

.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 5px; }
.field .sub { font-weight: 400; color: var(--ink-3); font-size: 13px; }

input[type=text], input[type=email], input[type=tel], input[type=number], select, textarea {
  width: 100%;
  padding: 11px 12px;
  font: inherit;
  font-size: 16px; /* 16px stops iOS zooming on focus */
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(28, 75, 138, .14);
}
textarea { min-height: 76px; resize: vertical; }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.row .w-state { flex: 0 0 84px; }
.row .w-zip { flex: 0 0 120px; }

.choices { display: grid; gap: 8px; }
.choice {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 12px 13px;
  cursor: pointer;
  background: #fff;
  transition: border-color .12s, background .12s;
}
.choice:hover { border-color: var(--brand); }
.choice input { margin: 2px 0 0; flex: 0 0 auto; width: 18px; height: 18px; accent-color: var(--brand); }
.choice-body strong { display: block; font-size: 15px; }
.choice-body span { display: block; color: var(--ink-3); font-size: 13.5px; margin-top: 1px; }
.choice.sel { border-color: var(--brand); background: var(--brand-tint); }

.reveal { display: none; margin-top: 12px; padding-left: 13px; border-left: 3px solid var(--brand-tint); }
.reveal.on { display: block; }

details.help { margin-top: 8px; }
details.help summary { font-size: 13.5px; color: var(--brand); cursor: pointer; }
details.help p { font-size: 13.5px; color: var(--ink-2); margin: 8px 0 0; }
code {
  background: #eef1f5; padding: 1px 5px; border-radius: 4px;
  font: 13px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* per-line keep/release */
.lines-tools { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; align-items: center; }
.mini {
  font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 7px 12px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--line-2); background: #fff; color: var(--ink-2);
}
.mini:hover { border-color: var(--brand); color: var(--brand); }
.lines-count { font-size: 13.5px; color: var(--ink-3); margin-left: auto; }
.lines-count.done { color: var(--ok); font-weight: 600; }

.lines { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.line-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.line-row:last-child { border-bottom: 0; }
.line-row:nth-child(even) { background: #fafbfd; }
.line-num { font-weight: 600; font-variant-numeric: tabular-nums; }
.line-plan { font-size: 12.5px; color: var(--ink-3); }
.line-meta { flex: 1 1 140px; min-width: 0; }
.seg { display: flex; gap: 6px; flex: 0 0 auto; }
.seg label {
  font-size: 13px; font-weight: 600; padding: 6px 12px;
  border: 1px solid var(--line-2); border-radius: 7px; cursor: pointer; background: #fff; color: var(--ink-2);
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + span { color: #fff; }
.seg label:has(input:checked) { background: var(--brand); border-color: var(--brand); color: #fff; }
.seg label:has(input[value=release]:checked) { background: var(--ink-3); border-color: var(--ink-3); }
.seg input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 3px; }

.notice { border-radius: 8px; padding: 13px 15px; font-size: 14px; margin-bottom: 16px; }
.notice-ok { background: var(--ok-tint); border: 1px solid #bde0cd; color: #12603b; }
.notice-warn { background: var(--warn-tint); border: 1px solid #f0dfb8; color: var(--warn); }
.notice-err { background: var(--err-tint); border: 1px solid #f2c7c9; color: var(--err); }
.notice strong { display: block; margin-bottom: 2px; }

.err { color: var(--err); font-size: 13px; margin-top: 5px; display: none; }
.err.on { display: block; }
.field.bad input, .field.bad select, .field.bad textarea { border-color: var(--err); }
.field.bad input:focus { box-shadow: 0 0 0 3px rgba(180, 35, 42, .13); }

/* Deliberately NOT sticky. A floating submit bar sits on top of the radio
   options and address fields on a phone, which is worse than scrolling. */
.actions { padding: 8px 0 0; }
/* Pill CTA, matching the "Get Started" buttons on teltik.com. */
button.submit {
  width: 100%; padding: 15px 20px; font: inherit; font-size: 16px; font-weight: 650;
  color: #fff; background: var(--brand); border: 0; border-radius: 999px; cursor: pointer;
  transition: background .12s, box-shadow .12s;
  box-shadow: 0 2px 8px rgba(100, 25, 185, .24);
}
button.submit:hover { background: var(--brand-dark); box-shadow: 0 3px 12px rgba(100, 25, 185, .32); }
button.submit:disabled { background: var(--ink-3); cursor: default; }

.safety {
  margin-top: 22px; padding: 14px 16px; background: #fff;
  border: 1px solid var(--line); border-left: 3px solid var(--brand); border-radius: 8px;
  font-size: 13.5px; color: var(--ink-2);
}
.safety strong { color: var(--ink); }

.foot { text-align: center; color: var(--ink-3); font-size: 13px; margin-top: 26px; line-height: 1.7; }
.foot a { color: var(--brand); }

.summary { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin: 18px 0; }
.summary div { display: flex; justify-content: space-between; gap: 14px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.summary div:last-child { border-bottom: 0; }
.summary div:nth-child(even) { background: #fafbfd; }
.summary dt { color: var(--ink-2); margin: 0; flex: 0 0 auto; }
.summary dd { margin: 0; font-weight: 600; text-align: right; word-break: break-word; }
.ref {
  font: 600 19px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .04em; background: var(--brand-tint); border: 1px solid #e0d3f2;
  padding: 12px 16px; border-radius: 8px; display: inline-block; margin: 6px 0 10px;
}
.summary + h2 { margin-top: 24px; }

@media (min-width: 620px) {
  .wrap { padding: 28px 20px 72px; }
  .card { padding: 28px 30px; }
  h1 { font-size: 25px; }
}

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

/* Utility classes.
   These exist so no inline style attribute is ever needed — the CSP is
   style-src 'self', with no 'unsafe-inline'. Adding an inline style anywhere
   will be silently dropped by the browser, so put it here instead. */
.m0 { margin: 0; }
.mt-sm { margin-top: 16px; }
.mt-md { margin-top: 20px; }
.mt-xs { margin-top: 6px; }
.mb-md { margin-bottom: 18px; }
.hint-tight { margin-top: -8px; }
.hidden { display: none !important; }

/* Inline identity confirmation — only shown when shipping to an address that
   is not the one on file. */
.inline-verify { margin: 1.25rem 0; }
.inline-verify-box {
  border: 2px solid var(--accent, #0f5132);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  background: var(--surface-alt, #f6f8f7);
}
.inline-verify-msg { margin: 0 0 .75rem; font-weight: 600; }
.inline-verify-box label { display: block; margin-bottom: .35rem; font-weight: 600; }
.inline-verify-box input { max-width: 12rem; }

/* Live device check — the one-line verdict under the IMEI field.
   Colour is a reinforcement, never the message itself: the text alone says
   what happened, so it still reads correctly in monochrome or to a colour-blind
   customer. */
.device-status {
  font-size: 13.5px;
  margin: -8px 0 14px;
  min-height: 1.2em;
  color: var(--ink-3);
}
.device-status.ds-good    { color: var(--ok);   font-weight: 600; }
.device-status.ds-warn    { color: var(--warn); font-weight: 600; }
.device-status.ds-bad     { color: var(--err);  font-weight: 600; }
.device-status.ds-checking { color: var(--ink-3); }

/* Per-device results for a pasted list.
   One row per device, numbered, so "row 9 is wrong" is actionable — a single
   summary line telling someone that one of fifteen IMEIs is bad just makes them
   check all fifteen again. */
.device-rows { margin: -4px 0 14px; }
.device-row {
  display: grid;
  grid-template-columns: 1.8em auto 1fr;
  align-items: baseline;
  gap: 4px 10px;
  padding: 6px 9px;
  border-radius: 6px;
  font-size: 13.5px;
  border-left: 3px solid var(--line-2);
}
/* A 32-digit EID is wider than a phone screen once a message sits beside it, so
   below that width the message drops to its own line rather than being squeezed
   into a one-word-per-line column. */
@media (max-width: 520px) {
  .device-row { grid-template-columns: 1.8em 1fr; }
  .device-row .dr-m { grid-column: 2; }
}
.device-row + .device-row { margin-top: 3px; }
.device-row .dr-n { color: var(--ink-3); min-width: 1.6em; text-align: right; font-variant-numeric: tabular-nums; }
.device-row .dr-v { font-variant-numeric: tabular-nums; letter-spacing: .01em; word-break: break-all; }
.device-row .dr-m { color: var(--ink-2); }
.device-row.ds-good { border-left-color: var(--ok);   background: var(--ok-tint); }
.device-row.ds-warn { border-left-color: var(--warn); background: var(--warn-tint); }
.device-row.ds-bad  { border-left-color: var(--err);  background: var(--err-tint); }
.device-row.ds-bad .dr-m { color: var(--err); font-weight: 600; }

/* ── Per-line SIM plan ────────────────────────────────────────────────────
   One row per line: number, physical/eSIM toggle, IMEI, Check, verdict.
   Grid rather than flex so the toggle column lines up down the page — a
   ragged left edge on fifteen rows makes them much harder to scan. */
.lines-sims {
  margin: 8px 0 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
}
/* Collapsed by default. The summary has to read as a control, not a heading —
   people do not click headings. */
.lines-sims > summary {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius);
}
.lines-sims > summary::-webkit-details-marker { display: none; }
.lines-sims > summary:hover { background: #f2f6fb; }
.lines-sims > summary:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.ls-sum-title { font-weight: 650; font-size: 14.5px; }
.ls-sum-title::before {
  content: '\25B8'; display: inline-block; margin-right: 8px;
  color: var(--ink-3); transition: transform .12s ease;
}
.lines-sims[open] .ls-sum-title::before { transform: rotate(90deg); }
.ls-sum-now { color: var(--ink-2); font-size: 13.5px; }
.ls-sum-now.warn-text { color: var(--warn); font-weight: 600; }
.ls-body { padding: 0 12px 12px; }
.lines-sims[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 10px; }
/* The whole-account buttons, above the collapsed list rather than inside it. */
.ls-quick {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  margin: 12px 0 0;
}
.ls-quick-title { font-weight: 650; font-size: 14px; }
.ls-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.ls-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 8px; flex-wrap: wrap;
}
.ls-title { font-weight: 650; font-size: 14px; }

/* Number, SIM type and number choice on one line; the IMEI on its own beneath.
   Grid rather than flex so the toggles line up down the page — a ragged left
   edge on fifteen rows is much harder to scan.

   THE IMEI IS NOT A FOURTH COLUMN, and that is the fix for a real bug: a
   `minmax(180px, 1fr)` column reserves its 180px whether or not there is an
   IMEI field in it, so the row's minimum width came to about 750px inside a
   676px card. The row could not shrink, so it pushed the section wider than the
   card it sits in and the whole form — headings, paragraphs and all — spilled
   past the white panel on every desktop.

   Given as areas rather than spans so the empty case collapses to nothing:
   a row with no IMEI field has no second line at all. */
.ls-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto auto;
  grid-template-areas:
    "num sim numchoice"
    "imei imei imei"
    "msg  msg msg";
  align-items: center;
  gap: 8px 12px;
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-2);
  /* Nothing in here may make the row wider than the card. */
  max-width: 100%;
  min-width: 0;
}
.ls-row > * { min-width: 0; }
.ls-num { grid-area: num; }
/* Named rather than positional: with eSIM off there is only ONE toggle in the
   row, and :first-of-type would have put the number choice in the SIM slot. */
.ls-sim { grid-area: sim; }
.ls-numchoice { grid-area: numchoice; }
.ls-imei { grid-area: imei; }
.ls-msg { grid-area: msg; }
.ls-row + .ls-row { margin-top: 6px; }
.ls-row.ls-good     { border-left-color: var(--ok); }
.ls-row.ls-bad      { border-left-color: var(--err); }
.ls-row.ls-unknown  { border-left-color: var(--warn); }
.ls-row.ls-checking { border-left-color: var(--brand); }

@media (max-width: 720px) {
  /* Stacked, because three columns at phone width gives every one of them a
     line-break and the row stops reading as one line's decision. */
  .ls-row {
    grid-template-columns: 1fr;
    grid-template-areas: "num" "sim" "numchoice" "imei" "msg";
    gap: 8px;
  }
  .ls-toggle label { flex: 1 1 0; justify-content: center; }
}

.ls-num { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ls-i { color: var(--ink-3); font-size: 12.5px; font-variant-numeric: tabular-nums; min-width: 1.5em; }
.ls-msisdn { font-weight: 600; font-variant-numeric: tabular-nums; }
.ls-plan { color: var(--ink-3); font-size: 12.5px; }

/* Two-state segmented toggle. Big enough to hit with a thumb. */
.ls-toggle { display: flex; gap: 0; }
.ls-toggle label {
  display: inline-flex; align-items: center; cursor: pointer;
  border: 1px solid var(--line-2); padding: 7px 13px; font-size: 13.5px;
  background: var(--surface); color: var(--ink-2); white-space: nowrap;
}
.ls-toggle label:first-child { border-radius: 999px 0 0 999px; }
.ls-toggle label:last-child { border-radius: 0 999px 999px 0; border-left: 0; }
.ls-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.ls-toggle input:checked + span { color: #fff; }
.ls-toggle label:has(input:checked) {
  background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600;
}
.ls-toggle input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 3px; }

.ls-imei { display: flex; gap: 6px; align-items: center; }
.ls-imei input {
  flex: 1 1 auto; min-width: 0; padding: 8px 10px; font: inherit; font-size: 14px;
  border: 1px solid var(--line-2); border-radius: 7px;
  font-variant-numeric: tabular-nums;
}
button.mini.check {
  flex: 0 0 auto; padding: 8px 14px; border-radius: 999px;
  background: var(--brand-tint); color: var(--brand-dark);
  border: 1px solid #ddcdf3; font-weight: 600; cursor: pointer; font-size: 13.5px;
}
button.mini.check:hover { background: #ece1fa; }

.ls-msg { font-size: 13px; color: var(--ink-2); }
.ls-row.ls-good .ls-msg { color: var(--ok); font-weight: 600; }
.ls-row.ls-bad .ls-msg  { color: var(--err); font-weight: 600; }
.ls-row.ls-unknown .ls-msg { color: var(--warn); }
.ls-msg:empty { display: none; }

.warn-text { color: var(--warn); font-weight: 600; }

/* Single-line customer: field and button on one row. */
.imei-one { display: flex; gap: 8px; align-items: flex-start; }
.imei-one .field { flex: 1 1 auto; margin-bottom: 0; }
.imei-one button.mini.check { margin-top: 26px; }

@media (max-width: 560px) {
  .ls-row { grid-template-columns: 1fr; }
  .ls-toggle { flex-wrap: wrap; }
  .ls-toggle { justify-content: stretch; }
  .ls-toggle label { flex: 1 1 50%; justify-content: center; }
}

/* Optional interest checkbox. Deliberately quiet — it records a lead for later,
   it is not one of the choices the customer is being asked to make now. */
label.check {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 13px; margin: 4px 0 6px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); cursor: pointer; font-size: 14.5px;
}
label.check:hover { border-color: var(--line-2); }
label.check input { margin: 2px 0 0; width: 18px; height: 18px; flex: 0 0 auto; accent-color: var(--brand); }
label.check:has(input:checked) { border-color: var(--brand); background: var(--brand-tint); }
