/* Self-serve portal — page-specific styles.
   Palette, layout, header/footer, and the agent log widget live in
   bss_portal_ui/static/css/portal_base.css (loaded first via base.html). */

/* ─── Header nav (v0.8 — sign-in / sign-out + email pill) ──────── */

.portal-nav {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
}
.portal-nav a {
  color: var(--fg-muted);
  text-decoration: none;
}
.portal-nav a:hover { color: var(--fg); }
.nav-email {
  font-family: var(--mono);
  color: var(--accent);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
}
.nav-logout-form { margin: 0; }
.nav-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.nav-logout:hover { color: var(--fg); border-color: var(--fg-muted); }

/* ─── Signup form — verified-email banner (v0.8) ──────────────── */

.signed-in-as {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}
.signed-in-as-label { color: var(--fg-muted); }
.signed-in-as-email { font-family: var(--mono); color: var(--accent); font-weight: 600; }
.signed-in-as-note  { color: var(--fg-muted); }

/* ─── Dashboard (v0.8 placeholder, v0.10 fills it in) ─────────── */

.dashboard,
.dashboard-empty {
  max-width: 640px;
  margin: 32px auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.dashboard-empty-cta-row,
.dashboard-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
}
.dashboard-placeholder {
  background: var(--bg-inset);
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 24px;
  color: var(--fg-muted);
  font-size: 14px;
}
.dashboard-cust {
  font-family: var(--mono);
  color: var(--accent);
}
.dashboard-logout-form { margin: 0; }

/* ─── Dashboard line cards (v0.10) ───────────────────────────── */

.dashboard-lines {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dashboard-lines-item {
  margin: 0;
}
.line-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  background: var(--bg-inset);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.line-card--blocked {
  border-color: #c0392b;
  background: #fdecea;
  color: #1a1a1a;
}
.line-card--terminated {
  opacity: 0.7;
}
.line-card-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.line-card-state {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  /* v0.11 — ACTIVE pill is the default (no state modifier).
     Phosphor accent on dark text — much better contrast than the
     old white-on-light-green which washed out (real-portal
     feedback). The other state modifiers below override the
     background to colours that work cleanly with white text. */
  background: var(--accent);
  color: #0e1014;
}
.line-card-state--blocked {
  background: #c0392b;
  color: #ffffff;
}
.line-card-state--terminated {
  background: var(--fg-muted);
  color: #0e1014;
}
.line-card-state--pending-activation {
  background: #f39c12;
  color: #0e1014;
}
.line-card-plan-name {
  font-weight: 600;
}
.line-card-msisdn {
  margin-left: auto;
  font-family: var(--mono);
  color: var(--fg-muted);
}
.line-card-pending-banner {
  background: #fff8e1;
  border: 1px solid #f39c12;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: #1a1a1a;
}
.line-card-pending-banner a,
.line-card-pending-banner button,
.line-card-pending-banner .line-card-cta-link {
  color: #8a4500;
}
.line-card-pending-cancel {
  margin: 0 0 0 auto;
}
.line-card-bars {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.line-card-bar {
  display: grid;
  grid-template-columns: 60px 1fr 140px;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}
.line-card-bar-label {
  color: var(--fg-muted);
}
.line-card-bar-track {
  display: block;
  height: 8px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.line-card-bar-fill {
  display: block;
  height: 100%;
  /* Default — proportional fill matched to v0.6 ASCII bar's intent. */
  background: linear-gradient(90deg, #2ecc71 0%, #27ae60 100%);
  transition: width 200ms ease;
}
.line-card-bar--low .line-card-bar-fill {
  background: linear-gradient(90deg, #f39c12 0%, #e67e22 100%);
}
.line-card-bar--exhausted .line-card-bar-fill {
  background: linear-gradient(90deg, #c0392b 0%, #922b21 100%);
}
.line-card-bar--unlimited .line-card-bar-fill {
  /* Striped 'unlimited' fill — distinguishable at a glance from
     a healthy bar without a numeric value the customer has to parse. */
  background: repeating-linear-gradient(
    -45deg,
    var(--accent) 0,
    var(--accent) 6px,
    rgba(0, 0, 0, 0) 6px,
    rgba(0, 0, 0, 0) 12px
  );
}
.line-card-bar-value {
  text-align: right;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-muted);
}
.line-card-period {
  margin: 0;
  font-size: 13px;
  color: var(--fg-muted);
}
.line-card-cta-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.line-card-cta {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  text-decoration: none;
  color: var(--fg);
  background: var(--bg);
  font-size: 13px;
}
.line-card-cta--primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}
.line-card-cta-link {
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.line-card-terminated-badge {
  font-size: 13px;
  color: var(--fg-muted);
}

/* ─── Payment methods (v0.10) ────────────────────────────────── */

.cof, .cof-add, .cof-forbidden {
  max-width: 640px;
  margin: 32px auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.cof-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cof-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  background: var(--bg-inset);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cof-card--default {
  border-color: var(--accent);
  border-width: 2px;
}
.cof-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
}
.cof-card-brand {
  font-weight: 600;
  letter-spacing: 0.05em;
}
.cof-card-last4 {
  color: var(--fg-muted);
}
.cof-card-expiry {
  margin-left: auto;
  color: var(--fg-muted);
  font-size: 13px;
}
.cof-card-badge {
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.05em;
}
.cof-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.cof-action-form { margin: 0; }
.cof-remove { color: #c0392b; }
.cof-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cof-form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cof-form-row > span {
  font-size: 13px;
  color: var(--fg-muted);
}
.cof-form-row input {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--mono);
  background: var(--bg);
  color: var(--fg);
}
.cof-form-row-pair {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}
.cof-form-row-pair label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cof-form-row-pair label > span {
  font-size: 13px;
  color: var(--fg-muted);
}
.cof-form-row-pair input {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--mono);
  background: var(--bg);
  color: var(--fg);
}
.cof-form-disclaimer {
  font-size: 12px;
  color: var(--fg-muted);
}
.form-error {
  background: #fdecea;
  border: 1px solid #c0392b;
  border-radius: 4px;
  padding: 8px 12px;
  color: #922b21;
  font-size: 14px;
}
.form-flash {
  background: #eaf6ee;
  border: 1px solid #27ae60;
  border-radius: 4px;
  padding: 8px 12px;
  color: #1e6e3e;
  font-size: 14px;
}

/* ─── Billing history (v0.10) ────────────────────────────────── */

.billing-history {
  max-width: 880px;
  margin: 32px auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.billing-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-inset);
}
.billing-table th,
.billing-table td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.billing-table th {
  background: var(--bg);
  color: var(--fg-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
}
.billing-row:last-child td { border-bottom: none; }
.billing-amount, .billing-method, .billing-ref {
  font-family: var(--mono);
}
.billing-status {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.billing-status--succeeded { color: #1e6e3e; }
.billing-status--declined,
.billing-status--failed { color: #c0392b; }
.billing-status--pending { color: #f39c12; }
.billing-decline {
  display: block;
  color: #c0392b;
  font-size: 12px;
  margin-top: 2px;
}
.billing-method-removed {
  color: var(--fg-muted);
  font-style: italic;
}
.billing-pager {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ─── Profile / contact medium (v0.10) ───────────────────────── */

.profile-contact,
.profile-email-pending,
.profile-email-verify,
.profile-forbidden {
  max-width: 640px;
  margin: 32px auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.profile-pending-banner {
  background: #fff8e1;
  border: 1px solid #f39c12;
  border-radius: 4px;
  padding: 12px 16px;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #1a1a1a;
}
.profile-pending-banner a,
.profile-pending-banner button,
.profile-pending-banner .line-card-cta-link {
  color: #8a4500;
}
.profile-pending-cancel { margin: 0; }
.profile-contact-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.profile-cm {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  background: var(--bg-inset);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.profile-cm--email {
  border-color: var(--accent);
}
.profile-cm-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.profile-cm-type {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 3px;
}
.profile-cm-value {
  font-family: var(--mono);
  font-size: 14px;
}
.profile-cm-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.profile-cm-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.profile-cm-form label > span {
  font-size: 13px;
  color: var(--fg-muted);
}
.profile-cm-form input {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--mono);
  background: var(--bg);
  color: var(--fg);
}
.profile-cm-fineprint {
  font-size: 12px;
  color: var(--fg-muted);
}
.profile-email-verify-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.profile-email-verify-form input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 16px;
  letter-spacing: 0.2em;
  background: var(--bg);
  color: var(--fg);
}

/* ─── Cancel a line (v0.10) ──────────────────────────────────── */

.cancel-confirm,
.cancel-success,
.cancel-already,
.cancel-forbidden {
  max-width: 640px;
  margin: 32px auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.cancel-loss-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid #c0392b;
  border-radius: 6px;
  background: #fdecea;
  color: #1a1a1a;
}
.cancel-loss-row {
  padding: 12px 16px;
  border-bottom: 1px solid #c0392b22;
  font-size: 14px;
}
.cancel-loss-row:last-child { border-bottom: none; }
.cancel-loss-balances {
  margin: 6px 0 0 1.2em;
  padding: 0;
  font-family: var(--mono);
  font-size: 13px;
  color: #922b21;
}
.cancel-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.cancel-confirm-button {
  background: #c0392b;
  border-color: #c0392b;
  color: white;
}

/* ─── eSIM view (v0.10) ──────────────────────────────────────── */

.esim-view, .esim-forbidden {
  max-width: 640px;
  margin: 32px auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.esim-qr {
  margin: 0;
  text-align: center;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
}
.esim-qr img {
  display: block;
  margin: 0 auto;
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.esim-qr figcaption {
  margin-top: 12px;
  color: var(--fg-muted);
  font-size: 13px;
}
.esim-code-block {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 8px 0;
}
.esim-meta-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
  margin: 0;
  font-size: 13px;
}
.esim-meta-list dt { color: var(--fg-muted); }
.esim-meta-list dd { margin: 0; font-family: var(--mono); }
.esim-fineprint {
  font-size: 12px;
  color: var(--fg-muted);
}
.esim-rearm-note {
  background: #fff8e1;
  border: 1px solid #f39c12;
  border-radius: 4px;
  padding: 12px 16px;
  font-size: 14px;
  color: #1a1a1a;
}

/* ─── Plan change (v0.10) ────────────────────────────────────── */

.plan-change,
.plan-change-scheduled,
.plan-change-forbidden {
  max-width: 640px;
  margin: 32px auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.plan-change-pending {
  background: #fff8e1;
  border: 1px solid #f39c12;
  border-radius: 4px;
  padding: 12px 16px;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #1a1a1a;
}
.plan-change-pending a,
.plan-change-pending button,
.plan-change-pending .line-card-cta-link {
  color: #8a4500;
}
.plan-change-pending-cancel { margin: 0; }
.plan-change-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.plan-change-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  background: var(--bg-inset);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.plan-change-card--current { opacity: 0.7; border-style: dashed; }
.plan-change-card--pending { border-color: #f39c12; }
.plan-change-card-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.plan-change-card-name { font-weight: 600; }
.plan-change-card-price {
  margin-left: auto;
  font-family: var(--mono);
  color: var(--accent);
  font-weight: 600;
}
.plan-change-card-badge {
  background: var(--fg-muted);
  color: white;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.05em;
}
.plan-change-card-badge--pending { background: #f39c12; }
.plan-change-card-allowances {
  margin: 0 0 0 1.2em;
  padding: 0;
  font-size: 13px;
  color: var(--fg-muted);
}
.plan-change-card-form { margin: 0; }
.plan-change-no-proration {
  background: #eaf6ee;
  border: 1px solid #27ae60;
  border-radius: 4px;
  padding: 12px 16px;
  font-size: 14px;
  color: #1a1a1a;
}
.plan-change-no-proration strong { color: #1e6e3e; }

/* ─── Top-up (v0.10) ─────────────────────────────────────────── */

.top-up,
.top-up-success,
.top-up-forbidden {
  max-width: 640px;
  margin: 32px auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.top-up-vas-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.top-up-vas-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  background: var(--bg-inset);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.top-up-vas-card--preselected {
  border-color: var(--accent);
  border-width: 2px;
}
.top-up-vas-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.top-up-vas-name { font-weight: 600; }
.top-up-vas-price {
  margin-left: auto;
  font-family: var(--mono);
  color: var(--accent);
  font-weight: 600;
}
.top-up-vas-quota {
  margin: 0;
  font-size: 13px;
  color: var(--fg-muted);
}
.top-up-vas-form { margin: 0; }
.top-up-balance-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-inset);
}
.top-up-balance-row {
  display: flex;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.top-up-balance-row:last-child { border-bottom: none; }
.top-up-balance-label { color: var(--fg-muted); }
.top-up-balance-value {
  margin-left: auto;
  font-family: var(--mono);
}

/* ─── Welcome page (v0.8) ────────────────────────────────────── */

.welcome-card {
  max-width: 560px;
  margin: 48px auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.welcome-cta-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 8px;
}
.welcome-cta {
  background: var(--bg-inset);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px 22px;
  text-decoration: none;
  font-weight: 500;
}
.welcome-cta--primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.welcome-cta:hover { filter: brightness(1.1); }
.welcome-foot { color: var(--fg-muted); font-size: 13px; }

/* ─── Auth surfaces (v0.8) ───────────────────────────────────── */

.auth-card {
  max-width: 480px;
  margin: 32px auto;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.auth-label {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--fg-muted);
}
.auth-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 15px;
  color: var(--fg);
  font-family: var(--mono);
}
.auth-input:focus { outline: 2px solid var(--accent-dim); }
.auth-input--otp {
  letter-spacing: 0.4em;
  font-size: 22px;
  text-align: center;
}
.auth-cta {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  padding: 12px;
  font-weight: 600;
  cursor: pointer;
}
.auth-cta:hover { filter: brightness(1.08); }
.auth-hint {
  color: var(--fg-muted);
  font-size: 13px;
  margin: 0;
}
.auth-error {
  background: rgba(220, 80, 80, 0.12);
  border: 1px solid rgba(220, 80, 80, 0.4);
  color: #ff8a8a;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 14px;
}
.auth-email {
  font-family: var(--mono);
  color: var(--accent);
}
.auth-action {
  font-family: var(--mono);
  color: var(--accent);
}
.auth-resend-form { margin-top: 8px; }
.auth-resend {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  border-radius: 4px;
  padding: 8px;
  cursor: pointer;
  font-size: 13px;
  width: 100%;
}
.auth-resend:hover { color: var(--fg); }

/* ─── Plan cards ─────────────────────────────────────────── */

.plan-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 16px;
}
.plan-card {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
  transition: border-color 120ms;
}
.plan-card:hover { border-color: var(--accent-dim); }
.plan-card-header { display: flex; justify-content: space-between; align-items: baseline; }
.plan-card-id { font-family: var(--mono); color: var(--accent); font-weight: 600; }
.plan-card-name { color: var(--fg-muted); font-size: 13px; }
.plan-card-price { display: flex; align-items: baseline; gap: 6px; }
.price-currency { color: var(--fg-muted); font-size: 13px; }
.price-amount { font-size: 32px; font-weight: 600; }
.price-cadence { color: var(--fg-muted); font-size: 13px; }

.plan-card-allowances {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
  font-family: var(--mono); font-size: 13px;
}
.plan-card-allowances li { display: flex; justify-content: space-between; }
.allowance-label { color: var(--fg-muted); }
.allowance-value { color: var(--fg); }

.plan-card-cta {
  display: block; text-align: center;
  padding: 10px 14px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  text-decoration: none;
  border-radius: 4px;
  font-family: var(--mono);
  transition: background 120ms;
}
.plan-card-cta:hover { background: var(--accent-bright); }

/* ─── MSISDN picker ──────────────────────────────────────── */

.msisdn-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 16px;
}
.msisdn-tile {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 18px 14px;
  text-align: center;
  font-family: var(--mono);
  color: var(--fg);
  text-decoration: none;
  transition: border-color 120ms, transform 80ms;
  display: flex; flex-direction: column; gap: 4px;
}
.msisdn-tile:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.msisdn-country {
  color: var(--fg-muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.msisdn-number {
  font-size: 18px; font-weight: 600;
  letter-spacing: 1px;
}

.msisdn-refresh {
  display: flex; gap: 12px; align-items: end;
  margin-top: 28px;
  padding: 16px 18px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 6px;
  flex-wrap: wrap;
}
.msisdn-refresh label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 13px; color: var(--fg-muted);
}
.msisdn-refresh input {
  background: var(--bg-code); border: 1px solid var(--border);
  color: var(--fg); font-family: var(--mono);
  padding: 8px 10px; border-radius: 4px;
  width: 140px;
}
.msisdn-refresh .form-hint {
  flex-basis: 100%; margin: 0;
}

/* ─── Signup form ─────────────────────────────────────────── */

.signup-form { display: flex; flex-direction: column; gap: 20px; max-width: 560px; }
.signup-form fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 20px;
  background: var(--bg-inset);
}
.signup-form legend {
  font-family: var(--mono); color: var(--fg-muted); font-size: 12px;
  padding: 0 8px; text-transform: uppercase; letter-spacing: 1px;
}
.signup-form label {
  display: flex; flex-direction: column; gap: 4px;
  margin-bottom: 12px;
  font-size: 13px; color: var(--fg-muted);
}
.signup-form label:last-child { margin-bottom: 0; }
.signup-form input {
  background: var(--bg-code);
  border: 1px solid var(--border);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 4px;
  outline: none;
}
.signup-form input:focus { border-color: var(--accent); }

.form-hint {
  color: var(--fg-dim); font-size: 12px;
  margin: 8px 0 0 0; font-family: var(--mono);
}
.form-submit {
  background: var(--accent); color: var(--bg);
  border: none; padding: 12px 16px;
  font-family: var(--mono); font-weight: 600;
  border-radius: 4px; cursor: pointer;
  font-size: 14px;
}
.form-submit:hover { background: var(--accent-bright); }

.msisdn-chosen {
  display: flex; align-items: baseline; gap: 16px;
  padding: 12px 14px;
  background: var(--bg-code);
  border: 1px solid var(--accent-dim);
  border-radius: 4px;
  font-family: var(--mono);
}
.msisdn-chosen-value {
  font-size: 20px; color: var(--accent); font-weight: 600;
  letter-spacing: 1px; flex: 1;
}
.msisdn-chosen-change {
  color: var(--fg-muted); font-size: 12px; text-decoration: none;
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 3px;
}
.msisdn-chosen-change:hover { color: var(--accent); border-color: var(--accent-dim); }

.kyc-badge {
  display: flex; align-items: center; gap: 12px;
  padding: 8px;
  background: var(--bg-code);
  border: 1px solid var(--accent-dim);
  border-radius: 4px;
}
.kyc-badge-check {
  color: var(--accent); font-weight: 700; font-size: 20px;
  padding: 4px 10px;
}
.kyc-badge-body { flex: 1; }
.kyc-badge-title { font-weight: 600; color: var(--fg); }
.kyc-badge-meta { color: var(--fg-muted); font-size: 12px; font-family: var(--mono); }
.kyc-badge-edit {
  background: transparent; color: var(--fg-dim);
  border: 1px solid var(--border); padding: 4px 10px;
  border-radius: 3px; cursor: not-allowed;
  font-family: var(--mono); font-size: 12px;
}

/* ─── Confirmation (QR + LPA) ────────────────────────────── */

.confirmation-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 32px;
  align-items: start;
  margin-top: 16px;
}
.confirmation-qr img {
  background: #fff; padding: 12px; border-radius: 8px;
  display: block;
}
.confirmation-qr-fallback {
  width: 240px; height: 240px; display: grid; place-items: center;
  background: var(--bg-inset); border: 1px dashed var(--border);
  border-radius: 8px; color: var(--fg-muted); text-align: center; padding: 16px;
}
.confirmation-details dl {
  display: grid; grid-template-columns: max-content 1fr;
  row-gap: 10px; column-gap: 16px;
  margin: 0;
}
.confirmation-details dt {
  color: var(--fg-muted); font-size: 13px;
  font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.5px;
  padding-top: 2px;
}
.confirmation-details dd { margin: 0; }
.confirmation-lpa {
  display: inline-block; word-break: break-all;
  background: var(--bg-code); padding: 6px 10px; border-radius: 4px;
  color: var(--accent-amber); font-size: 13px; max-width: 100%;
}
.copy-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--fg-muted); padding: 3px 10px; margin-left: 8px;
  border-radius: 3px; cursor: pointer;
  font-family: var(--mono); font-size: 12px;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent-dim); }
.confirmation-next { margin-top: 24px; }
.confirmation-next .plan-card-cta { display: inline-block; width: auto; padding: 8px 20px; }

/* ─── Progress ────────────────────────────────────────────── */

.progress-card {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px;
  margin-top: 16px;
}
.progress-lane {
  display: flex; flex-wrap: wrap; gap: 8px 12px;
  align-items: center;
  font-family: var(--mono); font-size: 13px;
  margin-bottom: 16px;
}
.progress-step {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--fg-muted);
  background: var(--bg-code);
}
.progress-step.active {
  color: var(--accent); border-color: var(--accent-dim);
}
.progress-arrow { color: var(--fg-dim); }
.progress-note {
  color: var(--fg-dim); font-size: 12px; font-family: var(--mono);
}

/* ─── v0.12 — chat surface ─────────────────────────────────────── */

.chat-page {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 760px;
  margin: 0 auto;
}
.chat-page-header { display: flex; flex-direction: column; gap: 6px; }

.chat-thread-host { display: flex; flex-direction: column; }
.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.chat-message {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.chat-message header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.chat-message-user {
  background: var(--bg);
  border-color: var(--border);
}
.chat-message-assistant {
  background: var(--bg);
  border-color: var(--accent-soft, var(--border));
}
.chat-message p { margin: 0; line-height: 1.45; white-space: pre-wrap; }
.chat-status { display: inline-flex; align-items: center; gap: 6px; }
.chat-status .dot {
  display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--fg-muted);
}
.chat-status .dot.live  { background: #2ea043; box-shadow: 0 0 6px #2ea043; }
.chat-status .dot.done  { background: #2ea043; }
.chat-status .dot.error { background: #c84f4f; }
.chat-status .dot.idle  { background: var(--fg-muted); opacity: 0.6; }

.chat-log {
  /* v0.12 PR17 — chat-log is just a flex column. The agent-log
     style (mono font + left-bar) was inherited from the v0.4
     portal log widget and was visually overriding the chat
     bubble's padding/border/background, making the streamed
     reply look like a terminal entry instead of a bubble. The
     bubbles + tool pills carry their own styling. */
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.chat-form .form-label {
  font-size: 13px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.chat-form textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  resize: vertical;
}
.chat-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.chat-form button { align-self: flex-start; }

.chat-after-turn {
  display: flex;
  gap: 10px;
  margin: 0;
}
.welcome-cta-secondary {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
}

.chat-fineprint {
  font-size: 12px;
  color: var(--fg-muted);
  margin: 4px 0 0;
}

.chat-cap-tripped {
  padding: 18px 20px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-left: 3px solid #c89400;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-cap-tripped h2 { margin: 0; font-size: 16px; }
.chat-cap-tripped p  { margin: 0; }
.chat-cap-tripped-actions { margin-top: 6px; }

/* ─── Floating chat-launcher button (v0.12 — visible on every
       post-login page via base.html) ─────────────────────────────── */

.chat-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  border: 1px solid transparent;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}
.chat-fab:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
  color: var(--bg);
}
.chat-fab .chat-fab-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 4px;
  position: relative;
}
.chat-fab .chat-fab-icon::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 4px;
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 5px solid currentColor;
  border-right: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

/* ─── v0.12 PR13 — popup chat widget + bubbles + tool pills ─────── */

.chat-widget-host {
  /* Always present, even when empty, so htmx-sse handlers route
     into it. Visual presence comes from the widget partial. */
  position: fixed;
  inset: auto 0 0 auto;
  z-index: 70;
  pointer-events: none;
}
.chat-widget-host > * { pointer-events: auto; }

.chat-widget {
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  font-size: 14px;
}
.chat-widget-popup {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 380px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 100px);
}
.chat-widget-inline {
  /* Standalone /chat page: drop the fixed positioning + give it
     a generous max width so the conversation reads on a desktop. */
  max-width: 760px;
  margin: 0 auto;
}
.chat-widget-inline .chat-widget {
  width: 100%;
  max-height: none;
  position: static;
}
.chat-widget-inline .chat-widget-popup {
  position: static;
  width: 100%;
  max-width: 100%;
  max-height: none;
  right: auto;
  bottom: auto;
}

.chat-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-inset);
  border-bottom: 1px solid var(--border);
}
.chat-widget-title {
  font-weight: 600;
  letter-spacing: 0.02em;
}
.chat-widget-header-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}
.chat-widget-iconbtn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg-muted);
  width: 26px;
  height: 26px;
  border-radius: 4px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.chat-widget-iconbtn:hover {
  border-color: var(--border);
  color: var(--fg);
  background: var(--bg);
}
.chat-widget-reset-form { margin: 0; }

.chat-widget-thread {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  overflow-y: auto;
  background: var(--bg);
  min-height: 220px;
  max-height: 50vh;
  /* v0.12 PR19 — smooth-scroll on the inline JS auto-stick
     so each SSE frame's append animates rather than jumping. */
  scroll-behavior: smooth;
}
.chat-widget-inline .chat-widget-thread {
  max-height: 60vh;
}

.chat-bubble {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
  font-size: 14px;
  max-width: 100%;
}
.chat-bubble-user {
  align-self: flex-end;
  background: var(--accent-dim);
  color: #f4fbe8;
  border-color: transparent;
  max-width: 80%;
}
.chat-bubble-assistant {
  align-self: flex-start;
  background: var(--bg-inset);
  border-color: var(--border);
  max-width: 90%;
}
.chat-bubble-streaming {
  border-style: dashed;
}
.chat-bubble-error {
  border-color: var(--accent-error);
  color: #ffd1d1;
}
.chat-bubble .chat-status-row {
  font-size: 11px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.chat-empty {
  color: var(--fg-muted);
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.chat-tool-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  padding: 4px 10px;
  background: var(--bg-code);
  border: 1px dashed var(--border-strong);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-muted);
}
.chat-tool-icon { color: var(--accent); }

.chat-widget-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
}
.chat-widget-form textarea {
  flex: 1 1 auto;
  padding: 8px 10px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  resize: none;
  min-height: 44px;
}
.chat-widget-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.chat-widget-form button { padding: 8px 16px; }

.chat-widget-cap {
  margin: 12px;
  padding: 10px 12px;
  background: var(--bg-code);
  border: 1px solid var(--accent-amber);
  border-left-width: 3px;
  border-radius: 6px;
}
.chat-widget-cap strong { color: var(--accent-amber); }
.chat-widget-cap p { margin: 4px 0 0; }

.chat-widget-fineprint {
  margin: 0;
  padding: 8px 14px 12px;
  font-size: 11px;
  color: var(--fg-dim);
  line-height: 1.4;
  background: var(--bg-elev);
}

@media (max-width: 720px) {
  .chat-widget-popup {
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
    max-width: none;
  }
}

/* ─── v0.12 PR14 — streaming-area cleanup (no bubble shell) ─────── */

/* The streaming container is just a vertical stack — status pill
   + chat-log children. The assistant's final reply renders as a
   normal .chat-bubble-assistant inside .chat-log, same shape as
   prior turns. The earlier dashed-bordered "streaming bubble"
   wrapper was visual noise. */
.chat-streaming {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-streaming-status {
  align-self: flex-start;
  font-size: 11px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
/* v0.12 PR17 — the .chat-streaming .chat-log overrides that
   nullified the agent-log left-bar are gone now that .chat-log
   itself is a plain flex column. Children carry their own
   styling. */

/* ─── v0.12 PR15 — markdown inside chat bubbles ─────────────────── */

.chat-bubble p {
  margin: 0 0 8px 0;
}
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble strong { color: var(--fg); font-weight: 700; }
.chat-bubble em { font-style: italic; }
.chat-bubble code {
  font-family: var(--mono);
  font-size: 0.92em;
  padding: 1px 5px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--fg);
}
.chat-bubble ul, .chat-bubble ol {
  margin: 4px 0 8px 0;
  padding-left: 22px;
}
.chat-bubble ul { list-style: disc; }
.chat-bubble ol { list-style: decimal; }
.chat-bubble ul:last-child, .chat-bubble ol:last-child { margin-bottom: 0; }
.chat-bubble li {
  margin: 2px 0;
  padding-left: 2px;
}

/* v0.13.1 — extended block markdown (tables, headings, code fences). */
.chat-bubble h3, .chat-bubble h4, .chat-bubble h5, .chat-bubble h6 {
  margin: 10px 0 6px;
  font-weight: 600; color: var(--fg);
}
.chat-bubble h3 { font-size: 1.05em; }
.chat-bubble h4, .chat-bubble h5, .chat-bubble h6 { font-size: 1em; }
.chat-bubble pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px; margin: 6px 0;
  overflow-x: auto;
}
.chat-bubble pre code {
  background: transparent; padding: 0; border: none;
  font-family: var(--mono); font-size: 0.9em;
  white-space: pre;
}
.chat-table {
  border-collapse: collapse;
  margin: 6px 0;
  font-size: 0.95em;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.chat-table th, .chat-table td {
  text-align: left;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
}
.chat-table th {
  font-weight: 600;
  background: var(--bg-elev);
}
.chat-table tr:last-child td { border-bottom: none; }

/* ─── v0.12 PR20 — legal pages + footer links ───────────────────── */

.legal-page {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  line-height: 1.55;
}
.legal-page h2 {
  margin: 18px 0 4px;
  font-size: 16px;
  color: var(--fg);
}
.legal-page ul {
  margin: 4px 0 8px 0;
  padding-left: 22px;
  list-style: disc;
}
.legal-page li { margin: 4px 0; }
.legal-page p { margin: 0 0 6px; }
.legal-page code {
  font-family: var(--mono);
  font-size: 0.92em;
  padding: 1px 5px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 3px;
}
.legal-footer-note {
  margin-top: 18px;
  font-size: 13px;
  color: var(--fg-muted);
}

.portal-footer-links {
  margin-left: 12px;
}
.portal-footer-links a {
  color: var(--fg-muted);
  text-decoration: none;
}
.portal-footer-links a:hover { color: var(--fg); }


/* ─── Mobile polish (v0.14) ─────────────────────────────────────
   Plan cards stack vertically below 720px (was a 3-column grid that
   overflowed horizontally on 390-wide screens). Inner price + allowance
   layout tightened so cards stay compact on a phone. */
@media (max-width: 720px) {
  .plan-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 12px;
  }
  .plan-card {
    padding: 16px;
    gap: 12px;
  }
  .price-amount { font-size: 28px; }

  /* MSISDN picker — same overflow problem. */
  .msisdn-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
  }
}
