/* ============================================================================
   Client portal — layered on top of styles.css (same Liquid Glass palette)
   ============================================================================ */

/* The `hidden` attribute must always win over author display rules
   (e.g. label.field { display:flex } would otherwise reveal hidden fields). */
[hidden] { display: none !important; }

/* ============================================================================
   Auth (login) screen
   ============================================================================ */
.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }

/* Sign-out toast on the login page */
.auth-toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translate(-50%, -120%);
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.35);
  z-index: 100;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: transform 0.4s var(--ease-out), opacity 0.4s var(--ease-out);
  opacity: 0;
}
.auth-toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

/* Prototype banner — non-intrusive, top of portal */
.proto-banner {
  background: linear-gradient(90deg, rgba(201, 145, 60, 0.18), rgba(58, 109, 181, 0.12));
  border-bottom: 1px solid rgba(201, 145, 60, 0.4);
  color: var(--ink-2);
  font-size: 12.5px;
  text-align: center;
  padding: 8px 24px;
  position: relative;
  z-index: 49;
}
.proto-banner strong { color: var(--ink); font-weight: 700; }
.proto-banner .pb-close {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  color: var(--ink-2);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
}
.proto-banner .pb-close:hover { background: rgba(0,0,0,0.06); }

.auth-back {
  position: fixed;
  top: 18px; left: 22px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--glass-strong);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-edge);
  transition: background 0.2s, color 0.2s;
  z-index: 5;
}
.auth-back:hover { background: var(--surface); color: var(--ink); text-decoration: none; }

.auth-shell {
  width: 100%;
  max-width: 460px;
}
.auth-card {
  background: var(--glass);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  padding: 36px;
  box-shadow:
    inset 0 1px 0 var(--glass-edge),
    var(--shadow-lg);
  position: relative;
  overflow: hidden;
  animation: card-pop 0.7s var(--ease-out);
}
.auth-card::before {
  content: "";
  position: absolute;
  top: -80px; right: -60px;
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(58,109,181,0.18), transparent 60%);
  pointer-events: none;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  text-decoration: none;
  color: inherit;
}
.auth-brand img { width: 48px; height: 48px; border-radius: 12px; }
.auth-brand-name { font-size: 16px; font-weight: 700; color: var(--ink); }
.auth-brand-motto { font-size: 11px; color: var(--primary); letter-spacing: 3px; text-transform: uppercase; font-weight: 600; margin-top: 2px; }

.auth-card h1 {
  font-size: 28px;
  margin: 0 0 8px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.auth-sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; }

.auth-card .field { margin: 12px 0; }
.auth-card .field input {
  padding: 13px 14px;
  border-radius: 10px;
  background: rgb(var(--glass-rgb) / 0.85);
}

.auth-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 14px 0 18px;
  font-size: 13px;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--ink-2);
  user-select: none;
}
.check input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--primary);
}
.auth-link { color: var(--primary); font-weight: 500; }

.auth-error {
  background: rgba(196, 74, 74, 0.10);
  border: 1px solid rgba(196, 74, 74, 0.3);
  color: var(--danger);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 12px;
  display: none;
}
.auth-error.show { display: block; animation: row-in 0.3s ease forwards; opacity: 1; }

/* User menu dropdown in the portal topbar */
.user-menu-wrap {
  position: relative;
}
.user-menu-trigger {
  /* Safari/WebKit doesn't honor display:flex on <button> directly — flex layout
     goes on the inner <span class="umt-inner"> below. */
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 16px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  line-height: 1;
}
.user-menu-trigger .umt-inner {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.user-menu-trigger:hover {
  background: rgba(15,23,42,0.04);
  border-color: var(--primary-soft);
}
.user-menu-trigger[aria-expanded="true"] {
  background: rgba(58,109,181,0.08);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(58,109,181,0.12);
}
.user-menu-trigger .user-info {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  line-height: 1.15;
  gap: 2px;
}
.user-menu-trigger .user-name { font-weight: 600; font-size: 14px; color: var(--ink); }
.user-menu-trigger .user-firm { font-size: 11px; color: var(--muted); }
.user-menu-trigger .user-avatar {
  /* Avatar inside the trigger is the same circle from .portal-user, just inline */
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  color: #fff;
  border-radius: 50%;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  box-shadow: inset 0 1px 0 rgb(var(--glass-rgb) / 0.4), 0 4px 10px rgba(58,109,181,0.3);
  flex-shrink: 0;
}
.user-caret {
  color: var(--muted);
  transition: transform 0.2s var(--ease-out);
  flex-shrink: 0;
}
.user-menu-trigger[aria-expanded="true"] .user-caret {
  transform: rotate(180deg);
  color: var(--primary);
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: rgb(var(--glass-rgb) / 0.95);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 100;
  animation: menu-pop 0.18s var(--ease-out);
}
.user-menu-dropdown[hidden] { display: none; }
@keyframes menu-pop {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  width: 100%;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.user-menu-item:hover {
  background: var(--primary-soft);
  color: var(--primary);
  text-decoration: none;
}
.user-menu-item.user-menu-signout:hover {
  background: rgba(196,74,74,0.10);
  color: var(--danger);
}
.umi-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: rgba(15,23,42,0.06);
  border-radius: 6px;
  font-weight: 700;
  font-size: 12px;
}
.user-menu-item:hover .umi-icon {
  background: var(--primary);
  color: #fff;
}
.user-menu-item.user-menu-signout:hover .umi-icon {
  background: var(--danger);
  color: #fff;
}
.user-menu-sep {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 6px 4px;
}
.user-menu-form { display: block; margin: 0; }
.user-menu-form .user-menu-item { padding: 10px 12px; }

@media (max-width: 600px) {
  .user-menu-trigger .user-info { display: none; }
}

/* Profile + tax page hint that explains why secondary contact matters */
.profile-hint {
  background: linear-gradient(180deg, rgba(201,145,60,0.10), rgba(201,145,60,0.04));
  border: 1px solid rgba(201,145,60,0.32);
  border-left-width: 4px;
  border-radius: 10px;
  padding: 14px 16px;
  margin: 0 0 16px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-2);
}
.profile-hint strong { color: var(--ink); }

/* Address autocomplete + route map (Nominatim + OSRM + Leaflet) */
.ac-wrap { position: relative; }
.ac-list {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: rgb(var(--glass-rgb) / 0.95);
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  margin-top: 4px;
  box-shadow: var(--shadow);
  z-index: 1000;
  max-height: 260px;
  overflow-y: auto;
  display: none;
}
.ac-list.show { display: block; animation: fade-down 0.18s var(--ease-out); }
@keyframes fade-down {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.ac-item {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid rgba(15,23,42,0.06);
  color: var(--ink);
  transition: background 0.15s;
}
.ac-item:last-child { border-bottom: 0; }
.ac-item:hover,
.ac-item.active { background: var(--primary-soft); }
.ac-item .ac-main { font-weight: 600; color: var(--ink); }
.ac-item .ac-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.ac-hint {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

#pk-map {
  width: 100%;
  height: 280px;
  border-radius: 14px;
  margin: 0 0 14px;
  background: #e8e3d4;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--glass-border);
}
#pk-map .map-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 20px;
  pointer-events: none;
}
.leaflet-container { background: #dfd8c4; font-family: inherit; }

/* Invoice export grid */
.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.export-card {
  background: rgb(var(--glass-rgb) / 0.55);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.3s var(--ease-out), background 0.3s;
}
.export-card:hover { transform: translateY(-2px); background: rgb(var(--glass-rgb) / 0.78); }
.export-card .export-label {
  font-weight: 700;
  color: var(--ink);
  font-size: 14px;
}
.export-card .export-sub {
  font-size: 12px;
  color: var(--muted);
}
.export-card .export-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
}
.export-card .ghost-btn {
  margin: 0;
  padding: 8px 12px;
  font-size: 12px;
  flex: 1;
  text-align: center;
  text-decoration: none;
}
.export-year,
.export-date {
  font: inherit;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  font-size: 13px;
  color: var(--ink);
}
.export-range-fields { display: flex; flex-direction: column; gap: 6px; }
.export-range { display: flex; align-items: center; gap: 8px; }
.export-range > span { flex: none; width: 34px; font-size: 11px; font-weight: 600; color: var(--muted); }
.export-range .export-date { flex: 1; min-width: 0; }
/* It's the only export card now — keep it a sensible width, not full-bleed. */
.export-card[data-period="range"] { max-width: 340px; }
.export-hint { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); }
.export-hint-warn { color: var(--danger); font-weight: 600; }
.export-actions .ghost-btn.is-disabled { pointer-events: none; opacity: 0.4; cursor: default; }

.auth-info {
  background: rgba(58, 109, 181, 0.10);
  border: 1px solid rgba(58, 109, 181, 0.3);
  color: var(--primary);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 16px;
}

.auth-divider {
  margin: 28px 0 18px;
  text-align: center;
  position: relative;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  font-weight: 600;
}
.auth-divider::before, .auth-divider::after {
  content: "";
  position: absolute;
  top: 50%; width: calc(50% - 60px); height: 1px;
  background: var(--line);
}
.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

.demo-creds {
  background: rgb(var(--glass-rgb) / 0.55);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 16px;
  font-size: 13px;
  color: var(--muted);
}
.demo-creds p { margin: 0 0 12px; }
.cred-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgb(var(--glass-rgb) / 0.8);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px 6px 12px;
  margin-bottom: 8px;
}
.cred-row code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}
.copy-btn {
  background: transparent;
  border: 0;
  color: var(--primary);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  transition: background 0.2s;
}
.copy-btn:hover { background: var(--primary-soft); }
.auth-fill {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--primary);
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 6px;
  transition: background 0.2s;
}
.auth-fill:hover { background: var(--primary-soft); }

.auth-foot { font-size: 13px; color: var(--muted); text-align: center; margin: 22px 0 0; }
.auth-foot a { color: var(--primary); font-weight: 600; }

/* Signup helpers */
.label-optional {
  color: var(--muted);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
  margin-left: 4px;
}
.field-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.field-hint::before {
  content: "↑";
  display: inline-block;
  color: var(--primary);
  font-weight: 700;
}
.field-hint.ok {
  color: var(--ok);
  font-weight: 600;
}
.field-hint.ok::before { content: "✓"; color: var(--ok); }
.field-hint.err {
  color: var(--danger);
  font-weight: 600;
}
.field-hint.err::before { content: "✕"; color: var(--danger); }

.terms-check {
  margin: 14px 0 18px;
  align-items: flex-start;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.45;
}
.terms-check input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; }

.auth-view[hidden] { display: none; }

/* ============================================================================
   Portal shell
   ============================================================================ */
.portal-body { padding-bottom: 60px; }

.portal-body .topbar-inner { padding: 14px 24px; }

.portal-user {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-info { text-align: right; line-height: 1.15; }
.user-name { font-weight: 600; font-size: 14px; color: var(--ink); }
.user-firm { font-size: 11px; color: var(--muted); }
.user-avatar {
  width: 40px; height: 40px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  color: #fff;
  border-radius: 50%;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  box-shadow: inset 0 1px 0 rgb(var(--glass-rgb) / 0.4), 0 4px 10px rgba(58,109,181,0.3);
}
.logout-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.logout-btn:hover { background: rgba(196,74,74,0.08); border-color: rgba(196,74,74,0.4); color: var(--danger); }

/* Welcome strip */
.portal-welcome {
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 24px 0;
}
.welcome-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}
.welcome-kicker {
  color: var(--primary);
  font-size: 12px;
  letter-spacing: 4px;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 6px;
}
.welcome-text h1 {
  font-size: 38px;
  margin: 0 0 4px;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.welcome-text p { margin: 0; color: var(--muted); font-size: 16px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 26px;        /* breathing room before Ongoing / Recent */
}
.stat-card {
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 13px 15px;
  box-shadow:
    inset 0 1px 0 var(--glass-edge),
    var(--shadow-sm);
  transition: transform 0.3s var(--ease-out), box-shadow 0.3s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: inset 0 1px 0 var(--glass-edge), var(--shadow); }
.stat-label {
  font-size: 9.5px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.stat-value {
  font-size: 23px;
  font-weight: 700;
  color: var(--ink);
  margin: 5px 0 3px;
  letter-spacing: -0.02em;
}
.stat-value.danger { color: var(--danger); }
.stat-value.ok { color: var(--ok); }
.stat-foot { font-size: 11px; color: var(--muted); }

/* Tab nav */
.portal-nav {
  max-width: 1180px;
  margin: 28px auto 0;
  padding: 6px 24px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}
.portal-tab {
  display: inline-block;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.portal-tab:hover { color: var(--ink); text-decoration: none; }
.portal-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Content */
.portal-content {
  max-width: 1180px;
  margin: 28px auto 0;
  padding: 0 24px;
}

.portal-section {
  animation: row-in 0.35s var(--ease-out);
  opacity: 1;
}

/* Panel */
.panel {
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 24px;
  box-shadow:
    inset 0 1px 0 var(--glass-edge),
    var(--shadow-sm);
  margin-bottom: 20px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.panel-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.panel-link {
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.panel-link:hover { text-decoration: underline; }

/* Activity feed */
.activity-feed { list-style: none; padding: 0; margin: 0; }
.activity-feed li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
}
.activity-feed li:last-child { border-bottom: 0; }
.activity-feed .act-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}
.activity-feed .act-icon.green { background: rgba(47,158,100,0.12); color: var(--ok); }
.activity-feed .act-icon.amber { background: rgba(201,145,60,0.15); color: var(--accent); }
.activity-feed .act-title { font-weight: 600; color: var(--ink); font-size: 14px; }
.activity-feed .act-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.activity-feed .act-time { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* Upcoming list */
.upcoming-list { list-style: none; padding: 0; margin: 0; }
.upcoming-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
  gap: 12px;
}
.upcoming-list li:last-child { border-bottom: 0; }
.upcoming-list .up-route { font-weight: 600; color: var(--ink); font-size: 14px; }
.upcoming-list .up-when { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Next invoice */
.next-invoice { font-size: 14px; color: var(--ink); }
.next-invoice .ni-amount { font-size: 32px; font-weight: 700; margin: 4px 0; letter-spacing: -0.02em; }
.next-invoice .ni-due { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.next-invoice button { width: 100%; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
}

/* Data table */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-bar input,
.filter-bar select {
  font: inherit;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(var(--glass-rgb) / 0.85);
  font-size: 13px;
  color: var(--ink);
  outline: none;
}
.filter-bar input { min-width: 220px; }
.filter-bar input:focus,
.filter-bar select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(58,109,181,0.15);
}

.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  padding: 12px 12px;
  border-bottom: 1px solid var(--line);
}
.data-table th.num,
.data-table td.num { text-align: right; }
.data-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink);
  vertical-align: middle;
}
.data-table tbody tr { transition: background 0.15s; }
.data-table tbody tr:hover { background: rgb(var(--glass-rgb) / 0.5); }
.data-table .tracking { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 600; color: var(--primary); font-size: 13px; }
.data-table .route-cell { line-height: 1.35; }
.data-table .route-from { font-weight: 600; color: var(--ink); }
.data-table .route-to { font-size: 12px; color: var(--muted); }
.data-table .row-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-weight: 600;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.data-table .row-btn:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.data-table .row-btn.pay {
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  color: #fff;
  border-color: transparent;
  box-shadow: inset 0 1px 0 rgb(var(--glass-rgb) / 0.3), 0 4px 10px rgba(58,109,181,0.3);
}
.data-table .row-btn.pay:hover { transform: translateY(-1px); }

/* Status pills */
.status-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.status-pill.ok { background: rgba(47,158,100,0.13); color: var(--ok); }
.status-pill.transit { background: rgba(58,109,181,0.13); color: var(--primary); }
.status-pill.scheduled { background: rgba(201,145,60,0.16); color: var(--accent); }
.status-pill.filed { background: rgba(15,23,42,0.08); color: var(--ink-2); }
.status-pill.paid { background: rgba(47,158,100,0.13); color: var(--ok); }
.status-pill.pending { background: rgba(201,145,60,0.16); color: var(--accent); }
.status-pill.overdue { background: rgba(196,74,74,0.13); color: var(--danger); }

/* Invoices summary */
.invoice-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.summary-card {
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: inset 0 1px 0 var(--glass-edge), var(--shadow-sm);
}
.summary-label {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.summary-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 8px;
  letter-spacing: -0.02em;
}
.summary-value.danger { color: var(--danger); }

/* Payment grid */
.payment-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.payment-grid .panel { margin-bottom: 0; }

/* Cards list */
.cards-list { display: flex; flex-direction: column; gap: 12px; }
.card-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  background: rgb(var(--glass-rgb) / 0.65);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  transition: background 0.2s, border-color 0.2s;
}
.card-item.default { border-color: var(--primary); background: rgba(58,109,181,0.06); }
.card-brand {
  width: 52px; height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 1px;
}
.card-brand.visa { background: linear-gradient(135deg, #1a4ba1, #0e2c66); }
.card-brand.mastercard { background: linear-gradient(135deg, #ed7d31, #c9302c); }
.card-brand.amex { background: linear-gradient(135deg, #2e77bb, #1d4a78); }
.card-num { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 600; color: var(--ink); font-size: 14px; }
.card-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card-default-tag {
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 4px 8px;
  border-radius: 999px;
}
.card-actions {
  display: flex;
  gap: 6px;
}
.card-actions button {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}
.card-actions button:hover { color: var(--ink); background: rgba(15,23,42,0.04); }
.card-actions button.danger:hover { color: var(--danger); background: rgba(196,74,74,0.08); }

/* ACH */
.ach-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
  background: rgb(var(--glass-rgb) / 0.65);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  margin-bottom: 12px;
}
.ach-label {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.ach-val {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-weight: 600;
  color: var(--ink);
  font-size: 14px;
  margin-top: 4px;
}

/* Preference row + toggle */
.pref-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
  gap: 16px;
}
.pref-row:last-child { border-bottom: 0; }
.pref-title { font-weight: 600; color: var(--ink); font-size: 14px; }
.pref-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.toggle {
  position: relative;
  width: 46px;
  height: 28px;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle .track {
  position: absolute;
  inset: 0;
  background: rgba(15,23,42,0.15);
  border-radius: 999px;
  transition: background 0.25s;
}
.toggle .track::before {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  background: var(--surface);
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  transition: transform 0.25s var(--ease-out);
}
.toggle input:checked + .track { background: var(--primary); }
.toggle input:checked + .track::before { transform: translateX(18px); }

/* Billing grid */
.billing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

/* Ghost button */
.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-weight: 600;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  margin-right: 8px;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.ghost-btn:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fade-in 0.25s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative;
  width: 100%;
  max-width: 460px;
  background: rgb(var(--glass-rgb) / 0.92);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
  animation: card-pop 0.4s var(--ease-out);
}
.modal-card h2 { margin: 0 0 8px; font-size: 22px; font-weight: 700; }
.modal-sub { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  background: transparent;
  border: 0;
  font-size: 18px;
  color: var(--muted);
  cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 50%;
  transition: background 0.2s, color 0.2s;
}
.modal-close:hover { background: rgba(15,23,42,0.05); color: var(--ink); }

/* Wide modal (for new-pickup form) */
.modal-card.modal-wide {
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 36px;
}
.modal-card.modal-wide h2 { font-size: 24px; }
.modal-card.modal-wide .field-group { background: rgb(var(--glass-rgb) / 0.6); }

.pickup-quote-result {
  background: rgba(58,109,181,0.08);
  border: 1px solid rgba(58,109,181,0.28);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 18px;
  animation: result-in 0.5s var(--ease-out);
}
.pickup-quote-result.error {
  background: rgba(196,74,74,0.08);
  border-color: rgba(196,74,74,0.3);
}
.pickup-quote-result .pqr-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.pickup-quote-result .pqr-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}
.pickup-quote-result .pqr-route {
  font-size: 12px;
  color: var(--muted);
}
.pickup-quote-result .pqr-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(58,109,181,0.18);
  font-size: 14px;
}
.pickup-quote-result .pqr-row:last-of-type { border-bottom: 0; }
.pickup-quote-result .pqr-row .lbl { color: var(--muted); }
.pickup-quote-result .pqr-row .val { font-weight: 600; color: var(--ink); }
.pickup-quote-result .pqr-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 2px solid var(--primary);
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.pickup-quote-result .pqr-total small {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.pickup-quote-result .pqr-err {
  color: var(--danger);
  font-weight: 600;
  font-size: 14px;
}

.pickup-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}
.pickup-actions .ghost-btn,
.pickup-actions .btn {
  flex: 1;
  margin: 0;
}
.pickup-actions .ghost-btn {
  padding: 13px 16px;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.pickup-actions .ghost-btn .spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(58,109,181,0.25);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}
.pickup-actions .ghost-btn.loading .spinner { display: inline-block; }

.pickup-success {
  background: rgba(47,158,100,0.08);
  border: 1px solid rgba(47,158,100,0.3);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
  text-align: center;
  animation: result-in 0.5s var(--ease-out);
}
.pickup-success .ps-icon {
  width: 48px; height: 48px;
  background: var(--ok);
  color: #fff;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 700;
  margin: 0 auto 12px;
}
.pickup-success h3 { margin: 0 0 4px; color: var(--ok); font-size: 18px; font-weight: 700; }
.pickup-success p { margin: 0; color: var(--ink-2); font-size: 14px; }
.pickup-success .ps-tracking {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-weight: 600;
  color: var(--primary);
  margin-top: 6px;
}

.pay-summary {
  background: var(--primary-soft);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 18px;
  font-size: 14px;
}
.pay-summary .pay-amount {
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 4px;
  letter-spacing: -0.02em;
}

/* ============================================================================
   Referral program
   ============================================================================ */

/* Stat card highlight */
.stat-card.stat-referral {
  background: linear-gradient(180deg, rgba(58,109,181,0.10), rgba(58,109,181,0.04)), var(--glass);
  border-color: rgba(58,109,181,0.35);
}
.stat-referral .stat-value { color: var(--primary); }
.stat-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  font-size: 12px;
}
.stat-link:hover { text-decoration: underline; }

/* Hero block */
.referral-hero {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 28px;
  align-items: stretch;
  padding: 32px;
  position: relative;
  overflow: hidden;
}
.referral-hero::before {
  content: "";
  position: absolute;
  top: -80px; right: -60px;
  width: 320px; height: 320px;
  background: radial-gradient(circle, rgba(58,109,181,0.18), transparent 60%);
  pointer-events: none;
}
.referral-hero-text {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.referral-hero-text h2 {
  margin: 6px 0 10px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.18;
}
.referral-lede {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 540px;
  line-height: 1.55;
}
.referral-lede strong { color: var(--ink); font-weight: 600; }

/* Code card */
.referral-code-card {
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  border-radius: 18px;
  padding: 24px;
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgb(var(--glass-rgb) / 0.35),
    0 12px 30px rgba(58,109,181,0.35);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  z-index: 1;
}
.referral-code-card .ach-label {
  color: rgb(var(--glass-rgb) / 0.7);
  font-size: 11px;
  letter-spacing: 2px;
}
.code-display {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  background: rgb(var(--glass-rgb) / 0.18);
  border: 1px dashed rgb(var(--glass-rgb) / 0.45);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: center;
  user-select: all;
}
.code-actions {
  display: flex;
  gap: 8px;
}
.code-actions .ghost-btn {
  flex: 1;
  background: rgb(var(--glass-rgb) / 0.18);
  border-color: rgb(var(--glass-rgb) / 0.35);
  color: #fff;
  margin: 0;
}
.code-actions .ghost-btn:hover {
  background: rgb(var(--glass-rgb) / 0.3);
  border-color: #fff;
  color: #fff;
}
.referral-share-mail {
  text-align: center;
  color: rgb(var(--glass-rgb) / 0.9);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
}
.referral-share-mail:hover {
  background: rgb(var(--glass-rgb) / 0.12);
  color: #fff;
  text-decoration: none;
}

/* Ref stats — wider grid (4 cols) */
.ref-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.ref-stats-grid .summary-value { color: var(--primary); }

/* How it works */
.how-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.how-step {
  padding: 22px 22px 20px;
  background: rgb(var(--glass-rgb) / 0.55);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  position: relative;
  transition: transform 0.3s var(--ease-out), background 0.3s;
}
.how-step:hover { transform: translateY(-3px); background: rgb(var(--glass-rgb) / 0.78); }
.how-num {
  width: 36px; height: 36px;
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  color: #fff;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 12px;
  box-shadow: inset 0 1px 0 rgb(var(--glass-rgb) / 0.4), 0 4px 10px rgba(58,109,181,0.3);
}
.how-step h3 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}
.how-step p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
.how-step p strong { color: var(--ink); font-weight: 600; }

/* Referrals table extras */
#referrals-table .progress-cell { min-width: 180px; }
.progress-bar {
  position: relative;
  height: 6px;
  background: rgba(15,23,42,0.08);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}
.progress-bar > span {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--primary-2), var(--primary));
  border-radius: 999px;
  transition: width 0.6s var(--ease-out);
}
.progress-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}
.firm-cell { line-height: 1.35; }
.firm-name { font-weight: 600; color: var(--ink); }
.firm-contact { font-size: 12px; color: var(--muted); }

/* Credit history */
.credit-history { list-style: none; padding: 0; margin: 0; }
.credit-history li {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
}
.credit-history li:last-child { border-bottom: 0; }
.credit-history .ch-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
}
.credit-history .ch-icon.earned { background: rgba(47,158,100,0.13); color: var(--ok); }
.credit-history .ch-icon.applied { background: rgba(58,109,181,0.13); color: var(--primary); }
.credit-history .ch-title { font-weight: 600; color: var(--ink); font-size: 14px; }
.credit-history .ch-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.credit-history .ch-amount {
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.credit-history .ch-amount.earned { color: var(--ok); }
.credit-history .ch-amount.applied { color: var(--primary); }
.credit-history .ch-date { color: var(--muted); font-size: 12px; }

/* Credit-apply box in pay modal */
.credit-apply {
  background: rgba(58,109,181,0.07);
  border: 1px solid rgba(58,109,181,0.25);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 16px;
}
.credit-apply .check { font-size: 14px; }
.credit-breakdown {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(58,109,181,0.18);
  font-size: 13px;
  color: var(--muted);
  display: none;
}
.credit-breakdown.show { display: block; }
.credit-breakdown .br-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}
.credit-breakdown .br-row.total {
  font-weight: 700;
  color: var(--ink);
  border-top: 1px dashed rgba(58,109,181,0.25);
  padding-top: 8px;
  margin-top: 4px;
  font-size: 14px;
}

/* Responsive */
@media (max-width: 900px) {
  .referral-hero { grid-template-columns: 1fr; }
  .ref-stats-grid { grid-template-columns: 1fr 1fr; }
  .how-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .ref-stats-grid { grid-template-columns: 1fr; }
}

/* Footer */
.portal-foot {
  max-width: 1180px;
  margin: 60px auto 0;
  padding: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}
.portal-foot a { color: var(--primary); }

/* Responsive */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .invoice-summary { grid-template-columns: 1fr; }
  .payment-grid { grid-template-columns: 1fr; }
  .welcome-text h1 { font-size: 28px; }
  .billing-grid { grid-template-columns: 1fr; }
  .ach-row { grid-template-columns: 1fr; gap: 10px; }
  .filter-bar input { width: 100%; min-width: 0; }
  .user-info { display: none; }
  .portal-foot { flex-direction: column; gap: 8px; }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .data-table { font-size: 13px; }
  .data-table th, .data-table td { padding: 10px 8px; }
}

/* ============================================================================
   Payment methods (Stripe)
   ============================================================================ */
.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line, var(--bd-cool));
  border-radius: 12px;
  background: var(--surface);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.card-row.is-default {
  border-color: var(--accent, #3a6db5);
  box-shadow: 0 0 0 2px rgba(58, 109, 181, 0.08);
}
.card-brand {
  font-weight: 700;
  font-size: 11px;
  letter-spacing: .05em;
  padding: 6px 9px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  min-width: 48px;
  text-align: center;
}
.card-meta {
  flex: 1;
  min-width: 0;
}
.card-line {
  font-weight: 600;
  font-size: 15px;
  color: var(--ink, var(--ink));
  letter-spacing: .02em;
}
.card-sub {
  font-size: 12px;
  color: var(--muted, var(--muted));
  margin-top: 2px;
}
.card-default-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  padding: 2px 7px;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  margin-left: 6px;
  vertical-align: middle;
}
.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.card-actions .row-btn.danger {
  color: #b91c1c;
  border-color: #fecaca;
}
.card-actions .row-btn.danger:hover {
  background: #fef2f2;
}

/* Stripe Card Element host */
.stripe-card-element {
  background: var(--surface);
  padding: 13px 14px;
  border: 1px solid var(--line, var(--bd-cool));
  border-radius: 10px;
  min-height: 44px;
}
.stripe-card-element.StripeElement--focus {
  border-color: var(--accent, #3a6db5);
  box-shadow: 0 0 0 3px rgba(58, 109, 181, 0.12);
}
.stripe-card-element.StripeElement--invalid {
  border-color: #ef4444;
}

/* Pay-modal: payment method picker */
.pay-method-section {
  margin: 16px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pay-method-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted, var(--muted));
  text-transform: uppercase;
  letter-spacing: .05em;
}
.pm-radio {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line, var(--bd-cool));
  border-radius: 10px;
  cursor: pointer;
  background: var(--surface);
  transition: border-color .15s ease, background .15s ease;
}
.pm-radio:has(input:checked) {
  border-color: var(--accent, #3a6db5);
  background: rgba(58, 109, 181, 0.05);
}
.pm-radio input[type="radio"] {
  accent-color: var(--accent, #3a6db5);
  margin: 0;
}
.pm-brand {
  font-weight: 700;
  font-size: 10px;
  letter-spacing: .05em;
  padding: 5px 8px;
  border-radius: 5px;
  background: var(--ink);
  color: #fff;
  min-width: 44px;
  text-align: center;
}
.pm-info {
  font-weight: 600;
  font-size: 14px;
  flex: 1;
  letter-spacing: .02em;
}
.pm-exp {
  color: var(--muted, var(--muted));
  font-weight: 500;
  margin-left: 6px;
  font-size: 12px;
}
.pay-or {
  text-align: center;
  font-size: 12px;
  color: var(--muted, var(--muted));
  text-transform: uppercase;
  letter-spacing: .12em;
  margin: 6px 0;
}
#pay-apple-pay-btn { min-height: 44px; }

@media (max-width: 600px) {
  .card-row { flex-wrap: wrap; }
  .card-actions { width: 100%; }
  /* Apple Pay button is most useful on mobile — keep it visible there */
  #pay-apple-pay-wrap:not([hidden]) { margin-top: 4px; }
}

/* ============================================================================
   Delivery tracking modal (client)
   ============================================================================ */
.track-modal .track-card {
  max-width: 560px;
  max-height: 90vh;            /* never taller than the screen… */
  display: flex;
  flex-direction: column;
}
.track-modal #track-body {
  flex: 0 1 auto;              /* …the detail scrolls inside instead */
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.track-row { cursor: pointer; transition: background .12s ease; }
.track-row:hover { background: var(--primary-soft, rgba(58,109,181,0.06)); }
.track-row:focus-visible { outline: 2px solid var(--primary, #3a6db5); outline-offset: -2px; }

.trk-head-card { margin-bottom: 16px; }
.trk-route { font-size: 15px; font-weight: 600; color: var(--ink, var(--ink)); }
.trk-sub { font-size: 13px; color: var(--muted, var(--muted)); margin-top: 4px; }

/* Live driver map */
.trk-map-wrap { margin: 4px 0 18px; }
.trk-map-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.trk-live { color: #1b7a43; font-weight: 700; letter-spacing: 0; margin-left: 4px; }
.trk-map { height: 200px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line, var(--bd-cool)); }
.trk-map-time { font-size: 11px; color: var(--muted); margin-top: 4px; }
.trk-map-placeholder {
  margin: 4px 0 18px; padding: 16px; border-radius: 12px;
  background: rgba(58,109,181,0.05); border: 1px dashed rgba(58,109,181,0.3);
  font-size: 13px; color: var(--muted, var(--muted)); line-height: 1.5;
}

/* Vertical stepper */
.trk-steps { list-style: none; margin: 0; padding: 0; }
.trk-step { position: relative; padding: 0 0 20px 36px; }
.trk-step:before { content: ""; position: absolute; left: 11px; top: 22px; bottom: -2px; width: 2px; background: var(--line, var(--bd-cool)); }
.trk-step:last-child:before { display: none; }
.trk-dot {
  position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
  background: #eef1f6; color: #94a3b8; border: 2px solid var(--bd-cool);
}
.trk-step.done .trk-dot { background: #1b7a43; color: #fff; border-color: #1b7a43; }
.trk-step.done:before { background: #b6e2c7; }
.trk-step.cancelled .trk-dot { background: #b42318; color: #fff; border-color: #b42318; }
.trk-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.trk-label { font-weight: 600; font-size: 14px; color: var(--ink, var(--ink)); }
.trk-step.pending .trk-label { color: #94a3b8; }
.trk-time { font-size: 12px; color: var(--muted, var(--muted)); white-space: nowrap; }
.trk-meta { font-size: 13px; color: var(--muted, var(--muted)); margin-top: 3px; }
.trk-sig { margin-top: 8px; }
.trk-sig-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.trk-sig img { max-width: 200px; max-height: 90px; border: 1px solid var(--line, var(--bd-cool)); border-radius: 8px; background: var(--surface); padding: 4px; }

/* ============================================================================
   Dashboard — ongoing deliveries (horizontal band)
   ============================================================================ */
.ongoing-section { margin-bottom: 18px; }
.ongoing-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px;
}
.ongoing-head h2 { margin: 0; font-size: 18px; }
.ongoing-count {
  font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: #1b7a43; background: #dcfce7; padding: 3px 10px; border-radius: 999px;
}

/* Horizontal scroller */
.ongoing-track {
  display: flex; gap: 14px;
  overflow-x: auto; padding: 2px 2px 8px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.ongoing-track::-webkit-scrollbar { height: 6px; }
.ongoing-track::-webkit-scrollbar-thumb { background: rgba(15,23,42,0.15); border-radius: 999px; }

.ongoing-card {
  scroll-snap-align: start;
  flex: 0 0 264px;
  min-width: 264px;
  background: var(--glass-strong, #fff);
  border: 1px solid var(--line, var(--bd-cool));
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  position: relative;
  transition: transform .15s ease, box-shadow .2s ease, border-color .15s ease;
  box-shadow: 0 2px 10px rgba(15,23,42,0.04);
}
.ongoing-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary, #3a6db5);
  box-shadow: 0 10px 24px rgba(58,109,181,0.16);
}
.ongoing-card:focus-visible { outline: 2px solid var(--primary, #3a6db5); outline-offset: 2px; }
.og-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.og-top .tracking { font-size: 12px; }
.og-top .status-pill { font-size: 9.5px; padding: 3px 8px; }
.og-route { margin-bottom: 11px; }
.og-from { font-weight: 600; font-size: 13px; color: var(--ink, var(--ink)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.og-to { font-size: 12px; color: var(--muted, var(--muted)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Segmented progress bar */
.og-progress { display: flex; gap: 4px; margin-bottom: 8px; }
.og-seg {
  flex: 1; height: 5px; border-radius: 999px;
  background: #e6eaf0;
}
.og-seg.done { background: #1b7a43; }
.og-seg.current {
  background: var(--primary, #3a6db5);
  animation: ogPulse 1.6s ease-in-out infinite;
}
@keyframes ogPulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

.og-foot { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.og-step { font-size: 12px; font-weight: 600; color: var(--primary, #3a6db5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.og-eta { font-size: 10.5px; color: var(--muted, var(--muted)); white-space: nowrap; }

@media (max-width: 600px) {
  .ongoing-card { flex-basis: 84%; min-width: 84%; }
}

/* ============================================================================
   Settings — notification preferences
   ============================================================================ */
.settings-block { margin-bottom: 22px; }
.settings-block-title {
  font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  color: var(--muted, var(--muted)); margin-bottom: 10px;
}
.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 0; border-bottom: 1px solid rgba(15,23,42,0.06);
}
.settings-row:last-child { border-bottom: 0; }
.settings-row-text { min-width: 0; }
.settings-row-label { font-weight: 600; font-size: 15px; color: var(--ink, var(--ink)); }
.settings-row-sub { font-size: 13px; color: var(--muted, var(--muted)); margin-top: 2px; line-height: 1.45; }
.settings-tag {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--primary, #3a6db5); background: var(--primary-soft, #d8e4f6);
  padding: 1px 7px; border-radius: 999px; margin-left: 6px; vertical-align: middle;
}

/* iOS-style toggle switch */
.switch { position: relative; display: inline-block; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: #cbd5e1; border-radius: 999px;
  transition: background .2s ease;
  box-shadow: inset 0 1px 2px rgba(15,23,42,0.12);
}
.switch-slider:before {
  content: ""; position: absolute; height: 22px; width: 22px; left: 3px; top: 3px;
  background: var(--surface); border-radius: 50%;
  transition: transform .2s ease;
  box-shadow: 0 1px 3px rgba(15,23,42,0.25);
}
.switch input:checked + .switch-slider { background: linear-gradient(180deg, #5784c7, #3a6db5); }
.switch input:checked + .switch-slider:before { transform: translateX(20px); }
.switch input:focus-visible + .switch-slider { outline: 2px solid var(--primary, #3a6db5); outline-offset: 2px; }

/* ============================================================================
   Settings — its own section with sub-tabs (hide dashboard chrome)
   ============================================================================ */
body.settings-mode .portal-welcome,
body.settings-mode .portal-nav { display: none; }

.settings-header { margin-bottom: 18px; }
.settings-back {
  display: inline-block; font-size: 13px; color: var(--primary, #3a6db5);
  text-decoration: none; font-weight: 600; margin-bottom: 10px;
}
.settings-back:hover { text-decoration: underline; }
.settings-header h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
.settings-header p { margin: 4px 0 0; color: var(--muted, var(--muted)); font-size: 14px; }

.settings-subnav {
  display: flex; gap: 6px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line, var(--bd-cool));
  margin-bottom: 20px;
}
.settings-subtab {
  appearance: none; background: transparent; border: 0;
  border-bottom: 2px solid transparent;
  padding: 11px 16px; margin-bottom: -1px;
  font: inherit; font-size: 15px; font-weight: 600;
  color: var(--muted, var(--muted)); cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}
.settings-subtab:hover { color: var(--ink, var(--ink)); }
.settings-subtab.active { color: var(--primary, #3a6db5); border-bottom-color: var(--primary, #3a6db5); }

/* Delivery row action cell (Confirmation + Track) */
.del-actions { white-space: nowrap; }
.del-actions .row-btn { margin-left: 4px; }
.del-actions .pod-link { color: #1b7a43; border-color: #b6e2c7; }
.del-actions .pod-link:hover { background: #f0faf4; border-color: #1b7a43; color: #1b7a43; }
.trk-pod-btn { display: inline-block; text-decoration: none; }

/* ============================================================================
   Billing-suspension banner
   ============================================================================ */
.suspend-banner {
  background: linear-gradient(180deg, #fff4f3, #ffe9e6);
  border: 1px solid #f3c7c2;
  border-radius: 14px;
  margin: 0 0 18px;
  padding: 14px 18px;
  box-shadow: 0 2px 10px rgba(180, 35, 24, 0.08);
}
.suspend-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 1180px;
  margin: 0 auto;
}
.suspend-ico {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #b42318;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
}
.suspend-text { flex: 1; font-size: 14px; color: #7a1d15; line-height: 1.45; }
.suspend-text strong { color: #5c150f; display: block; margin-bottom: 1px; }
.suspend-btn {
  flex: none;
  appearance: none; border: 0; cursor: pointer;
  background: linear-gradient(180deg, #d9483b, #b42318);
  color: #fff; font: inherit; font-weight: 600; font-size: 14px;
  padding: 10px 20px; border-radius: 999px;
  box-shadow: 0 4px 10px rgba(180, 35, 24, 0.3);
  transition: transform .15s ease, filter .2s ease;
}
.suspend-btn:hover { transform: translateY(-1px); filter: saturate(115%); }

@media (max-width: 600px) {
  .suspend-inner { flex-wrap: wrap; }
  .suspend-btn { width: 100%; }
}

/* ============================================================================
   Booking form — size radios, add-ons menu, quote breakdown
   ============================================================================ */
.size-radios { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.size-radio {
  flex: 1; min-width: 120px;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border: 1px solid var(--line, var(--bd-cool)); border-radius: 10px;
  cursor: pointer; background: var(--surface); transition: border-color .15s ease, background .15s ease;
}
.size-radio.is-checked { border-color: var(--primary, #3a6db5); background: rgba(58,109,181,0.05); }
.size-radio input { accent-color: var(--primary, #3a6db5); margin: 0; }
.size-radio span { font-size: 14px; font-weight: 600; color: var(--ink, var(--ink)); }
.size-radio small { display: block; font-weight: 500; font-size: 11px; color: var(--muted, var(--muted)); }

.addon-menu { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.addon-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border: 1px solid var(--line, var(--bd-cool)); border-radius: 9px;
  cursor: pointer; background: var(--surface); font-size: 14px;
}
.addon-item.is-checked { border-color: var(--primary, #3a6db5); background: rgba(58,109,181,0.04); }
.addon-item input { accent-color: var(--primary, #3a6db5); margin: 0; }
.addon-item small { color: var(--muted, var(--muted)); font-weight: 600; }

.pqr-head { display: flex; align-items: baseline; justify-content: space-between; }
.pqr-zone { font-size: 12px; font-weight: 600; color: var(--primary, #3a6db5); }
.pqr-flag {
  margin-top: 8px; padding: 8px 10px; border-radius: 8px;
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; font-size: 12px; line-height: 1.4;
}

/* ============================================================================
   Address Book
   ============================================================================ */
.addr-pick { width: 100%; }
.addr-save { margin-top: 6px; font-size: 13px; color: var(--ink-2, #1f2a44); }
.addr-save input { accent-color: var(--primary, #3a6db5); }

/* Search box */
.addr-search {
  width: 100%; font: inherit; font-size: 14px;
  padding: 11px 14px; margin-bottom: 10px;
  border: 1px solid var(--line, var(--bd-cool)); border-radius: 12px; background: var(--surface);
}
.addr-search:focus { outline: none; border-color: var(--primary, #3a6db5); box-shadow: 0 0 0 3px rgba(58,109,181,0.12); }

/* Scrolling vertical list (touch-friendly for the app) */
.addr-list { list-style: none; margin: 0; padding: 0; }
.addr-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 6px;
  border-bottom: 1px solid rgba(15,23,42,0.07);
}
.addr-row:last-child { border-bottom: 0; }
.addr-row:hover { background: rgba(58,109,181,0.035); border-radius: 10px; }

.addr-avatar {
  flex: none; width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, var(--primary-2, #5784c7), var(--primary, #3a6db5));
  color: #fff; font-weight: 700; font-size: 15px; letter-spacing: 0.02em;
  box-shadow: inset 0 1px 0 rgb(var(--glass-rgb) / 0.35), 0 4px 10px rgba(58,109,181,0.28);
}
.addr-avatar.sm { width: 38px; height: 38px; border-radius: 10px; font-size: 14px; }

.addr-row-text { flex: 1; min-width: 0; }
.addr-row-title { font-weight: 700; font-size: 15px; color: var(--ink, var(--ink)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.addr-row-city { font-weight: 600; font-size: 12px; color: var(--primary, #3a6db5); margin-left: 8px; }
.addr-row-sub { font-size: 13px; color: var(--muted, var(--muted)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.addr-row-meta { font-size: 12px; color: #94a3b8; margin-top: 1px; }

.addr-row-actions { flex: none; display: flex; align-items: center; gap: 6px; }
.addr-mini {
  appearance: none; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600;
  padding: 6px 11px; border-radius: 999px;
  border: 1px solid var(--line, var(--bd-cool)); background: var(--surface); color: var(--primary, #3a6db5);
  transition: background .15s ease, border-color .15s ease;
}
.addr-mini:hover { background: var(--primary-soft, #d8e4f6); border-color: var(--primary, #3a6db5); }
.addr-mini.danger { color: #b42318; border-color: #f3c7c2; padding: 6px 9px; }
.addr-mini.danger:hover { background: #fef2f2; }
.addr-empty { list-style: none; padding: 22px; text-align: center; color: var(--muted, var(--muted)); }

/* Contact editor modal (create / edit a saved address) */
.addr-form { display: block; margin-top: 4px; }
.addr-form label { display: block; margin-bottom: 12px; }
.addr-form .label-text { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.addr-form .label-text em { color: var(--danger, #b42318); font-style: normal; }
.addr-form input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); font-size: 15px; font-family: inherit;
}
.addr-form input:focus { outline: none; border-color: var(--primary, #3a6db5); box-shadow: 0 0 0 3px rgba(58,109,181,0.12); }
.addr-form-err { color: var(--danger, #b42318); font-size: 13px; margin: 2px 0 10px; }
.addr-form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

@media (max-width: 640px) {
  .addr-row { flex-wrap: wrap; }
  .addr-row-actions { width: 100%; padding-left: 50px; }
  .addr-mini { flex: 1; text-align: center; }
  .addr-mini.danger { flex: 0 0 auto; }
}

/* ============================================================================
   Settings → Security (2FA + recovery email)
   ============================================================================ */
.sec-panel { margin-bottom: 18px; }
.sec-lead { margin: 0 0 18px; font-size: 14px; line-height: 1.6; color: var(--ink-2, var(--ink-3)); }

.sec-apps {
  background: var(--primary-soft, #eef3fb);
  border: 1px solid #dbe5f3;
  border-radius: 14px;
  padding: 16px 16px 14px;
  margin: 0 0 20px;
}
.sec-apps-title {
  font-size: 11px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--muted, var(--muted)); margin-bottom: 12px;
}
.sec-app-list { display: flex; flex-direction: column; gap: 8px; }
.sec-app {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--line, var(--bd-paper)); border-radius: 10px;
  padding: 12px 14px; text-decoration: none; transition: border-color .15s, box-shadow .15s;
}
.sec-app:hover { border-color: var(--primary, #3a6db5); box-shadow: 0 2px 8px rgba(58,109,181,.12); }
.sec-app-name { font-weight: 600; font-size: 14px; color: var(--ink, var(--ink)); }
.sec-app-cta { font-size: 12px; font-weight: 600; color: var(--primary, #3a6db5); white-space: nowrap; }
.sec-app-note { margin: 12px 0 0; font-size: 12px; color: var(--muted, var(--muted)); }

.sec-btn { width: auto; padding: 12px 22px; font-size: 14px; text-transform: none; letter-spacing: 0; }
.sec-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }

.danger-btn {
  background: var(--surface); border: 1px solid #f0c2bd; color: #b42318;
  font-weight: 600; font-size: 13px; padding: 10px 16px; border-radius: 999px; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.danger-btn:hover { background: #fef2f2; border-color: #e0867d; }

.sec-2fa-on p { margin: 0 0 12px; font-size: 14px; color: var(--ink-2, var(--ink-3)); }
.sec-disable-panel {
  margin-top: 14px; padding: 16px; border-radius: 12px;
  background: rgba(196,74,74,.05); border: 1px solid rgba(196,74,74,.22);
}
.sec-disable-panel p { margin: 0 0 10px; font-weight: 600; font-size: 13px; }
.sec-disable-panel input {
  font: inherit; width: 100%; max-width: 320px; padding: 10px 13px;
  border: 1px solid var(--line, var(--bd-paper)); border-radius: 10px; background: var(--surface); margin-bottom: 4px;
}

.sec-setup {
  margin-top: 20px; padding: 22px; border-radius: 14px;
  background: rgba(58,109,181,.04); border: 1px solid rgba(58,109,181,.18);
}
.sec-setup-h { margin: 0 0 12px; font-size: 16px; color: var(--ink, var(--ink)); }
.sec-steps { margin: 0 0 16px; padding-left: 20px; font-size: 14px; line-height: 1.7; color: var(--ink-2, var(--ink-3)); }
.sec-qr-frame {
  display: inline-flex; padding: 14px; background: var(--surface); border: 1px solid var(--line, var(--bd-paper));
  border-radius: 14px; box-shadow: inset 0 1px 0 #fff, 0 2px 4px rgba(15,23,42,.04);
}
.sec-qr-frame canvas { display: block; }
.sec-manual { margin: 16px 0; background: var(--surface); border: 1px solid var(--line, var(--bd-paper)); border-radius: 10px; }
.sec-manual summary { padding: 12px 14px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink, var(--ink)); }
.sec-manual-body { padding: 0 14px 14px; }
.sec-kv { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 13px; flex-wrap: wrap; }
.sec-kv > span { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted, var(--muted)); font-weight: 700; min-width: 78px; }
.sec-kv code { font-family: ui-monospace, Menlo, monospace; font-size: 14px; color: var(--ink, var(--ink)); letter-spacing: 1px; }
.linkish { background: transparent; border: 0; color: var(--primary, #3a6db5); font-weight: 600; cursor: pointer; font-size: 12px; }
.sec-verify { margin-top: 18px; }
.sec-verify p { margin: 0 0 8px; font-weight: 600; font-size: 14px; }
.sec-verify-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sec-verify-row input {
  font-family: ui-monospace, Menlo, monospace; font-size: 18px; letter-spacing: 6px; text-align: center;
  width: 150px; padding: 11px 14px; border: 1px solid var(--line, var(--bd-paper)); border-radius: 10px; background: var(--surface);
}

/* ============================================================================
   Settings → Payment options (credit waterfall + preferred/backup cards)
   ============================================================================ */
.card-hint { margin: 0 0 14px; font-size: 13px; color: var(--muted, var(--muted)); }
.card-backup-pill {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .06em;
  padding: 2px 7px; border-radius: 999px; background: #fef3c7; color: #92400e;
  margin-left: 6px; vertical-align: middle;
}
.card-row.is-backup { box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.10); }
.card-row.is-default.is-backup { box-shadow: 0 0 0 2px rgba(58, 109, 181, 0.08); }

.pay-waterfall {
  list-style: none; margin: 18px 0 0; padding: 14px 18px;
  background: var(--primary-soft, #eef3fb); border: 1px solid #dbe5f3; border-radius: 12px;
  counter-reset: pw;
}
.pay-waterfall li {
  position: relative; padding: 6px 0 6px 30px; font-size: 13.5px; line-height: 1.5;
  color: var(--ink-2, var(--ink-3));
}
.pay-waterfall li::before {
  counter-increment: pw; content: counter(pw);
  position: absolute; left: 0; top: 5px;
  width: 20px; height: 20px; border-radius: 999px;
  background: var(--primary, #3a6db5); color: #fff;
  font-size: 11px; font-weight: 700; text-align: center; line-height: 20px;
}
.pay-waterfall li strong { color: var(--ink, var(--ink)); }

/* ============================================================================
   Settings → Appearance (theme picker)
   ============================================================================ */
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 6px; }
.theme-card {
  position: relative; text-align: left; cursor: pointer; font: inherit; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--bd-cool); border-radius: 14px;
  padding: 16px 16px 18px; display: flex; flex-direction: column; gap: 3px;
  transition: border-color .15s, box-shadow .15s;
}
.theme-card:hover { border-color: var(--primary); }
.theme-card.is-active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.theme-card-icon { font-size: 22px; line-height: 1; }
.theme-card-label { font-weight: 700; font-size: 15px; margin-top: 6px; }
.theme-card-desc { font-size: 12px; color: var(--muted); line-height: 1.45; }
.theme-card-check {
  position: absolute; top: 12px; right: 12px; width: 20px; height: 20px; border-radius: 999px;
  background: var(--primary); color: var(--on-accent); font-size: 12px; font-weight: 700;
  display: none; align-items: center; justify-content: center;
}
.theme-card.is-active .theme-card-check { display: flex; }
@media (max-width: 560px) { .theme-grid { grid-template-columns: 1fr; } }

/* Quick theme toggle button (topbar / nav) */
.theme-toggle {
  background: var(--surface); border: 1px solid var(--bd-cool); color: var(--ink);
  width: 38px; height: 38px; border-radius: 999px; cursor: pointer; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color .15s, background .15s; line-height: 1;
}
.theme-toggle:hover { border-color: var(--primary); }

/* ============================================================================
   Messages — client ↔ dispatch chat (mirrors the admin panel styling)
   ========================================================================== */
.portal-tab .nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 17px; padding: 0 5px; margin-left: 6px;
  border-radius: 9px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1; vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
.portal-tab .nav-badge[hidden] { display: none; }

.msg-panel {
  display: flex; flex-direction: column;
  height: calc(100vh - 340px); min-height: 460px;
  padding: 0; overflow: hidden;
}
.msg-panel .panel-head {
  margin: 0; padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.msg-head-sub { font-size: 12.5px; color: var(--muted); font-weight: 500; }

.msg-stream {
  flex: 1; overflow-y: auto; padding: 18px 22px;
  display: flex; flex-direction: column; gap: 9px;
  background: var(--bg-base);
}
.msg-empty { margin: auto; max-width: 430px; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.5; }
.msg-row { display: flex; }
.msg-row.mine { justify-content: flex-end; }
.msg-row.theirs { justify-content: flex-start; }
.msg-bubble { max-width: 76%; padding: 9px 13px; border-radius: 15px; box-shadow: var(--shadow-sm); }
.msg-row.theirs .msg-bubble { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg-row.mine .msg-bubble { background: linear-gradient(180deg, var(--primary-2), var(--primary)); color: #fff; border-bottom-right-radius: 4px; }
.msg-text { font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.msg-meta { font-size: 10.5px; margin-top: 4px; }
.msg-row.mine .msg-meta { color: rgba(255, 255, 255, 0.85); }
.msg-row.theirs .msg-meta { color: var(--muted); }

.msg-compose {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface);
}
.msg-compose textarea {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 13px; font: inherit; font-size: 14px; line-height: 1.45;
  color: var(--ink); background: var(--bg-base); max-height: 130px;
}
.msg-compose textarea:focus { outline: none; border-color: var(--primary); }
.msg-send {
  border: 0; border-radius: 12px; padding: 10px 20px; cursor: pointer;
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  color: #fff; font-weight: 700; font-size: 14px; white-space: nowrap;
}
.msg-send:hover { filter: brightness(1.05); }

@media (max-width: 720px) {
  .msg-panel { height: calc(100vh - 300px); min-height: 380px; }
  .msg-bubble { max-width: 86%; }
}

/* Per-delivery chat inside the tracking pop-up */
.trk-msg { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.trk-msg-head { font-size: 13px; font-weight: 700; color: var(--ink); margin-bottom: 10px; }
.trk-msg-stream {
  max-height: 280px; min-height: 90px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg-base); padding: 12px; margin-bottom: 10px;
}
.trk-msg-compose { padding: 0; background: transparent; border: 0; }
.trk-msg-closed {
  margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px;
  text-align: center; color: var(--muted); font-size: 13px;
}

/* ============================================================================
   Portal app shell — static left sidebar + static topbar (mirrors the admin)
   ========================================================================== */
body.portal-app { height: 100vh; overflow: hidden; padding-bottom: 0; }

.portal-shell {
  display: grid;
  grid-template-columns: 234px 1fr;
  height: 100vh;
  max-width: 1480px;
  margin: 0 auto;
}

/* Right column: fixed topbar + the only scrolling region */
.portal-col {
  min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.portal-topbar { position: static; }
.portal-topbar .topbar-inner { max-width: none; margin: 0; }

/* Sidebar — full-height, never scrolls away */
.portal-sidebar {
  background: rgb(var(--glass-rgb) / 0.55);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-right: 1px solid var(--line);
  padding: 14px 11px;
  height: 100vh;
  overflow-y: auto;
  display: flex; flex-direction: column;
}
.sidebar-top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 2px 5px 11px; margin-bottom: 5px;
  border-bottom: 1px solid var(--line);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 9px;
  text-decoration: none;
}
/* Hamburger — hidden on desktop, shown in the mobile breakpoint below */
.sidebar-toggle {
  display: none;
  flex: none;
  width: 36px; height: 34px;
  flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: transparent; border: 1px solid var(--line); border-radius: 9px;
  cursor: pointer; padding: 0;
}
.sidebar-toggle span {
  display: block; width: 18px; height: 2px; border-radius: 2px;
  background: var(--ink-2);
  transition: transform 0.22s var(--ease-out), opacity 0.2s;
}
.portal-sidebar.nav-open .sidebar-toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.portal-sidebar.nav-open .sidebar-toggle span:nth-child(2) { opacity: 0; }
.portal-sidebar.nav-open .sidebar-toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
/* Account block (avatar + theme + sign out) — only used inside the mobile dropdown. */
.sidebar-account { display: none; }
.sidebar-brand img { width: 28px; height: 28px; flex: none; }
.sidebar-brand .brand-name { color: var(--ink); font-weight: 800; font-size: 16px; line-height: 1.1; letter-spacing: -0.01em; }
.sidebar-brand .brand-motto { color: var(--primary); font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; }
.sidebar-section { margin-bottom: 11px; }
.sidebar-label {
  font-size: 9.5px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--muted); padding: 0 11px 4px;
}
.sidebar-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; text-align: left;
  padding: 6px 11px; margin: 1px 0;
  border: 0; background: transparent;
  border-radius: 9px;
  color: var(--ink-2); text-decoration: none;
  font-size: 13px; font-weight: 500; font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.sidebar-item:hover { background: rgba(58, 109, 181, 0.1); color: var(--primary); text-decoration: none; }
.sidebar-item.active {
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  color: #fff;
  box-shadow: inset 0 1px 0 rgb(var(--glass-rgb) / 0.3), 0 4px 10px rgba(58,109,181,0.3);
}
.sidebar-item .si-icon {
  width: 19px; height: 19px;
  display: inline-grid; place-items: center;
  font-size: 12px; font-weight: 700;
  border-radius: 6px; background: rgba(15, 23, 42, 0.06);
}
.sidebar-item.active .si-icon { background: rgb(var(--glass-rgb) / 0.18); color: #fff; }
.sidebar-cta { color: var(--primary); font-weight: 700; }
.sidebar-cta .si-icon { background: rgba(58, 109, 181, 0.16); color: var(--primary); }
.sidebar-foot {
  margin-top: auto; padding: 10px 11px;
  font-size: 10px; color: var(--muted);
  letter-spacing: 1px; text-transform: uppercase;
}

/* Main scroll region */
.portal-main {
  flex: 1; min-height: 0; min-width: 0;
  overflow-y: auto;
  padding: 22px 28px 60px;
}
.portal-app .portal-content { max-width: 1200px; margin: 0 auto; padding: 0; }

/* Section header (mirrors .admin-head) */
.portal-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 18px; flex-wrap: wrap; margin-bottom: 18px;
}
.portal-kicker {
  color: var(--primary); font-size: 9px; font-weight: 700;
  letter-spacing: 2.5px; text-transform: uppercase; margin-bottom: 2px;
}
.portal-head h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.015em; color: var(--ink); }

/* Phone/tablet: unlock the viewport, sidebar becomes a horizontal strip */
@media (max-width: 900px) {
  body.portal-app { height: auto; overflow: visible; }
  .portal-shell { grid-template-columns: 1fr; height: auto; max-width: none; }
  .portal-col { overflow: visible; }
  .portal-main { overflow: visible; min-height: auto; padding: 18px 16px 60px; }
  .portal-sidebar {
    height: auto; flex-direction: column;
    overflow: visible; border-right: 0; border-bottom: 1px solid var(--line);
    padding: 10px 0; gap: 0;
    position: relative; z-index: 60;      /* anchor the dropdown + stack above the topbar */
  }
  .sidebar-top { margin-bottom: 0; border-bottom: 0; padding: 2px 14px; }
  .sidebar-toggle { display: inline-flex; }
  /* Dropdown — floats OVER the content below instead of pushing it down. */
  .portal-nav-sections {
    display: none;
    position: absolute; top: 100%; left: 0; right: 0;
    background: rgb(var(--glass-rgb) / 0.97);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid var(--line); border-top: 0;
    border-radius: 0 0 14px 14px;
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.16);
    padding: 10px 14px 14px;
  }
  .portal-sidebar.nav-open .portal-nav-sections { display: block; }
  .sidebar-section { margin: 0 0 8px; }
  .sidebar-item { white-space: nowrap; font-size: 15px; padding: 10px 12px; }
  .sidebar-item .si-icon { width: 22px; height: 22px; font-size: 13px; }
  .sidebar-foot { display: none; }
  /* User controls move out of the topbar and into the dropdown menu. */
  .portal-topbar { display: none; }
  .sidebar-account {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 2px 12px 12px; margin-bottom: 8px;
    border-bottom: 1px solid var(--line);
  }
  .sa-user { display: flex; align-items: center; gap: 9px; min-width: 0; }
  .sa-name { font-weight: 600; font-size: 15px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sa-actions { display: flex; align-items: center; gap: 8px; flex: none; }
}
