/* StampRight Web Bank — clean, bank-grade UI. */

:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --ink: #14213d;
  --muted: #6a7589;
  --line: #e6e9f1;
  --line-strong: #d4d9e6;
  --accent: #2196F3;
  --accent-ink: #ffffff;
  --ok: #1a8a4a;
  --bad: #c0392b;
  --warn: #b7791f;
  --shadow: 0 1px 2px rgba(20, 33, 61, 0.05), 0 1px 1px rgba(20, 33, 61, 0.03);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.small { font-size: 12px; }
.hidden { display: none; }

/* ---- Welcome screen ---- */
.welcome {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 22px;
}
.welcome-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 40px 36px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow);
}
.welcome-card .brand {
  font-size: 22px; font-weight: 700; margin-bottom: 4px;
}
.welcome-card .brand .mark { color: var(--accent); margin-right: 4px; }
/* Welcome / sign-in / sign-up hero — crisp stamp icon centered, with
   "StampRight" rendered as real HTML text so it never looks washed out. */
.welcome-card .hero-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 0 auto 16px;
}
.welcome-card .hero-mark {
  display: block;
  width: 56px;
  height: 56px;
  margin: 0;
}
.welcome-card .hero-wordmark {
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1;
}
.welcome-card .tag {
  color: var(--muted); font-size: 14px; margin-bottom: 24px;
  text-align: center;
}
.welcome-card label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.welcome-card input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  font-size: 15px; color: var(--ink);
  margin-bottom: 18px;
}
.welcome-card input:focus { outline: none; border-color: var(--accent); }
.welcome-card .btn { width: 100%; }
.welcome-lang {
  position: absolute;
  top: 14px;
  right: 14px;
}

/* ---- Layout ---- */
.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 56px 1fr;
  min-height: 100vh;
}
header.topbar {
  grid-column: 1 / -1;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  /* 3-column layout: brand left · status/language centered · user pill right. */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 18px;
  gap: 16px;
}
.topbar-center {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
header .topbar-beta-center {
  margin-left: 0;
}
header .user-pill {
  justify-self: end;
}
header .brand {
  justify-self: start;
}
header .brand {
  font-weight: 700; font-size: 16px;
  display: flex; align-items: center; gap: 10px;
  color: var(--ink); text-decoration: none;
  min-width: 0;
}
header .brand:hover { color: var(--accent); text-decoration: none; }
/* Small stamp mark in the topbar — image, sized to match the wordmark. */
header .brand img.mark { display: block; width: 26px; height: 26px; flex-shrink: 0; }
header .brand .brand-word { font-weight: 700; }

/* User pill on the right side — clickable, goes to /profile. Replaces
   the busy "Signed in as · Find · Profile" string. Avatar + name only. */
header .user-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink); text-decoration: none;
  background: var(--surface);
  font-size: 13.5px; font-weight: 500;
  transition: border-color .15s, background .15s, color .15s;
  max-width: 260px;
  min-width: 0;
}
header .user-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
  background: var(--bg);
}
header .user-pill .user-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.app-lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(247, 248, 251, 0.92);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.72);
  white-space: nowrap;
}
.app-lang-switch button {
  min-width: 36px;
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.app-lang-switch button:hover {
  color: var(--accent);
}
.app-lang-switch button.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(33,150,243,0.22);
}
.app-lang-switch button:focus-visible {
  outline: 2px solid rgba(33,150,243,0.42);
  outline-offset: 2px;
}

aside.nav {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
}
aside.nav a {
  display: block;
  padding: 9px 12px;
  color: var(--ink);
  border-radius: 7px;
  font-size: 14px; font-weight: 500;
  margin-bottom: 2px;
}
aside.nav a:hover { background: var(--bg); text-decoration: none; }
aside.nav a.active { background: rgba(27, 77, 199, 0.08); color: var(--accent); font-weight: 600; }
aside.nav .section {
  font-size: 11px; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--muted);
  padding: 14px 12px 6px;
  font-weight: 700;
}

main#main {
  padding: 26px 30px;
  overflow-y: auto;
}

/* ---- Typography ---- */
h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
h2 { font-size: 16px; font-weight: 600; margin: 22px 0 10px; }

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; gap: 12px;
}

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 18px 20px;
  margin-bottom: 14px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 8px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); color: var(--accent-ink); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn + .btn { margin-left: 8px; }

/* ---- Stats ---- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 14px 0 22px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
  padding: 16px 18px;
  font-size: 20px; font-weight: 700;
}
.stat-card small {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--muted); margin-top: 4px;
}

/* ---- Tables / Ledger ---- */
.ledger {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 11px;
  overflow: hidden;
  border-collapse: collapse;
}
.ledger th, .ledger td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.ledger th {
  background: var(--bg); font-size: 12px;
  color: var(--muted); font-weight: 600;
  letter-spacing: 0.3px;
}
.ledger tr:last-child td { border-bottom: none; }
.ledger tr:hover td { background: var(--bg); }

/* ---- Key/value ---- */
.kv {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px 16px;
}
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { font-size: 14px; word-break: break-word; }

/* ---- Form ---- */
form.contract-form fieldset {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 16px 16px; margin: 12px 0;
  background: var(--surface);
}
form.contract-form legend {
  font-size: 12px; color: var(--muted); font-weight: 700;
  padding: 0 6px;
}
.field-row { display: flex; flex-wrap: wrap; gap: 12px; }
form.contract-form label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--muted); font-weight: 600;
  margin: 6px 0;
}
form.contract-form label.grow { flex: 1; min-width: 160px; }
form.contract-form label.full { display: flex; }
form.contract-form input,
form.contract-form select,
form.contract-form textarea {
  font: inherit; font-size: 14px; color: var(--ink); font-weight: 400;
  padding: 8px 10px;
  border: 1px solid var(--line-strong); border-radius: 7px;
  background: var(--surface);
}
form.contract-form input:focus,
form.contract-form select:focus,
form.contract-form textarea:focus { outline: none; border-color: var(--accent); }
form.contract-form textarea { resize: vertical; width: 100%; }
.form-actions { margin-top: 18px; }
.contract-actions {
  display: grid;
  grid-template-columns: minmax(240px, 1.15fr) minmax(220px, 0.85fr);
  gap: 12px;
  align-items: stretch;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(33,150,243,0.045), rgba(33,150,243,0.015)),
    var(--surface);
}
.contract-actions .btn + .btn { margin-left: 0; }
.contract-actions .btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 4px;
  min-height: 62px;
  padding: 12px 14px;
  text-align: left;
  white-space: normal;
  line-height: 1.22;
}
.contract-actions .btn span {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.82);
}
.contract-actions .contract-action-secondary {
  background: #fff;
  border-color: rgba(33,150,243,0.32);
  color: var(--accent);
}
.contract-actions .contract-action-secondary:hover {
  background: rgba(33,150,243,0.06);
  color: var(--accent);
}
.contract-actions .contract-action-secondary span {
  color: var(--muted);
}
.contract-actions .contract-action-link {
  grid-column: 1 / -1;
  display: inline-flex;
  width: fit-content;
  min-height: 0;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
}
.contract-actions .contract-action-link:hover {
  background: transparent;
  color: var(--accent);
}

/* ---- Badges ---- */
.badge {
  display: inline-block;
  font-size: 11px; font-weight: 700;
  padding: 5px 11px; border-radius: 999px;
  letter-spacing: 0.4px;
}
.badge.ok { background: rgba(26, 138, 74, 0.1); color: var(--ok); }
.badge.bad { background: rgba(192, 57, 43, 0.1); color: var(--bad); }
.badge.warn { background: rgba(183, 121, 31, 0.12); color: var(--warn); }

/* ---- Pre ---- */
pre {
  background: #0e1422; color: #d6deef;
  border-radius: 9px; padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; line-height: 1.5;
  max-height: 340px; overflow: auto;
  margin-top: 12px;
}

.err { color: var(--bad); font-size: 14px; padding: 8px 0; }

/* ---- Contracts list toolbar ---- */
.contracts-toolbar {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 14px;
}
.contracts-toolbar input[type="search"] {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font: inherit; color: var(--ink);
  background: var(--surface);
}
.contracts-toolbar input[type="search"]:focus {
  outline: none; border-color: var(--accent);
}
.contracts-toolbar select {
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font: inherit; color: var(--ink);
  background: var(--surface);
}
.contracts-toolbar #contracts-count {
  margin-left: 4px;
  white-space: nowrap;
}

/* ---- Template picker ---- */
.picker-section {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 22px 0 10px;
}
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.template-card {
  display: block;
  padding: 16px 16px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
  box-shadow: var(--shadow);
}
.template-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(20, 33, 61, 0.08);
  text-decoration: none;
}
.template-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}
.template-tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}
.template-line {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

/* ---- Print: contract detail becomes a clean single-document proof page ---- */
.print-head { display: none; }
@media print {
  body { background: #fff; color: #111; }
  aside.nav, header.topbar, .no-print { display: none !important; }
  .layout { display: block; }
  main#main { padding: 0; }
  .print-head { display: block; margin-bottom: 8px; }
  .print-head h1 { font-size: 22px; }
  .card { border: 1px solid #999; box-shadow: none; page-break-inside: avoid; }
  .badge { border: 1px solid #444; }
  a { color: inherit; text-decoration: none; }
  pre { max-height: none; overflow: visible; background: #f4f4f4; color: #111; border: 1px solid #ccc; }
}

/* Mobile layout triggers up to 932px so iPhone Pro Max in landscape
   (which is 932px wide) also gets the mobile single-column layout with
   the horizontal-scrolling nav strip. Otherwise iPhone landscape used
   the 220px sidebar which left only ~370px of vertical space for content.
   iPad portrait (768px) and iPhone all orientations all land here.
   iPad landscape (1024px+) still gets the full desktop sidebar. */
@media (max-width: 932px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 56px auto 1fr; }
  aside.nav { border-right: none; border-bottom: 1px solid var(--line); display: flex; gap: 4px; padding: 8px; overflow-x: auto; }
  aside.nav a { white-space: nowrap; }
  aside.nav .section { display: none; }
  .stat-row { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dt { margin-top: 8px; }
  main#main { padding: 18px; }
  .contract-actions {
    grid-template-columns: 1fr;
    padding: 12px;
  }
  .contract-actions .btn {
    width: 100%;
    min-height: 56px;
  }
  .contract-actions .contract-action-link {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  /* Topbar at iPad-portrait / iPhone-landscape: keep wordmark, tighten spacing */
  header.topbar { padding: 0 14px; gap: 10px; }
  .topbar-center { gap: 8px; }
  header .brand { font-size: 15px; gap: 8px; }
  header .brand img.mark { width: 28px; height: 28px; }
  header .user-pill { padding: 4px 12px 4px 4px; font-size: 13px; max-width: 200px; }
  header .user-pill .user-name { max-width: 140px; }
  .beta-badge { font-size: 10px; padding: 1.5px 7px; margin-left: 4px; }

  /* Profile mobile: stack the avatar above the meta, give it breathing room */
  .profile-head { flex-direction: column; align-items: flex-start; gap: 14px; }
  .profile-avatar { width: 64px; height: 64px; font-size: 26px; }

  /* Verification rows: tighter padding, status pill below label on phones */
  .verif-row { flex-wrap: wrap; gap: 10px 14px; padding: 14px 0; }
  .verif-status { margin-left: auto; }

  /* Locker stat row stays one column at mobile — already inherited from base */

  /* Balance cards stay 2-up on phones but with tighter padding */
  .balance-row { gap: 8px !important; }
  .balance-card { padding: 14px 10px !important; }
  .balance-card .account-credit-num,
  .balance-card #credit-balance-big { font-size: 30px !important; }
  /* Dashboard "At a glance" — keep these BIG even on phones */
  #dash-stamps-left, #dash-locker-files, #dash-balance-usd {
    font-size: 52px !important;
    line-height: 1 !important;
  }
  /* Quick-stamp shortcut row */
  .quick-stamp-row { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
  .quick-stamp-card { padding: 12px !important; }

  /* Dashboard hero — tighten paddings/sizes but keep premium feel on phone */
  .dash-hero-card-content { padding: 18px 16px 16px; }
  .dash-hero-row { gap: 12px; }
  .dash-hero-avatar-lg { width: 60px; height: 60px; flex-basis: 60px; font-size: 24px; border-width: 2.5px; }
  .dash-hero-name { font-size: 26px; }
  .dash-hero-meta { font-size: 12.5px; gap: 6px; }
  .dash-hero-stats { padding: 12px 14px; margin-top: 14px; }
  .dash-hero-stat-num { font-size: 19px; }
  .dash-hero-stat-label { font-size: 10px; letter-spacing: 0.06em; }

  /* Action cards: keep 3-up but tighten */
  .dash-actions { gap: 8px; }
  .dash-action { padding: 12px 10px; border-radius: 12px; }
  .dash-action-title { font-size: 14px; }
  .dash-action-sub { font-size: 11px; }
  .dash-action-icon { width: 30px; height: 30px; margin-bottom: 6px; }
  .dash-action-icon svg { width: 18px; height: 18px; }

  /* Discovery grid: 2-col on phones */
  .dash-discovery { grid-template-columns: 1fr 1fr; gap: 8px; }
  .dash-disc { padding: 12px; }
}

/* Actual phones (≤ 600px wide): keep the wordmark visible (per request)
   but shrink it and tighten the user pill so the 3-column topbar
   (brand · BETA · pill) still fits without wrapping. */
@media (max-width: 600px) {
  header .brand .brand-word { display: inline; font-size: 14px; }
  header .brand img.mark { width: 24px; height: 24px; }
  header .user-pill { padding: 4px 10px 4px 4px; font-size: 12.5px; max-width: 140px; }
  header .user-pill .user-name { max-width: 80px; }
  header.topbar { padding: 0 12px; gap: 8px; }
  .topbar-center .beta-badge { display: none; }
  .app-lang-switch { padding: 2px; }
  .app-lang-switch button { min-width: 34px; min-height: 32px; }
  .welcome-lang { top: 12px; right: 12px; }
}

/* Very small phones (≤ 380px): hide the user-pill NAME (avatar stays)
   to free up center space for BETA + wordmark. */
@media (max-width: 380px) {
  header .user-pill .user-name { display: none; }
  header .user-pill { padding: 4px; }
  header .brand .brand-word { font-size: 13px; }
  .app-lang-switch button { min-width: 31px; min-height: 31px; font-size: 10.5px; }
}

/* ============================================================
   Dashboard hero card — premium gradient surface with avatar, name,
   alias, and inline glance stats. Replaces the sparse "Good
   afternoon Joel · Let's stamp your first proof" block.
   ============================================================ */
.dash-hero-card {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  margin: 6px 0 8px;
  box-shadow: 0 8px 28px rgba(27, 77, 199, 0.18), 0 2px 6px rgba(0,0,0,0.04);
  isolation: isolate;
}
.dash-hero-card-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 100% 0%, rgba(255,255,255,0.18) 0%, transparent 38%),
    radial-gradient(circle at 0% 100%, rgba(0,0,0,0.18) 0%, transparent 50%),
    linear-gradient(135deg, #1B4DC7 0%, #2196F3 55%, #4FC3F7 100%);
  z-index: 0;
}
.dash-hero-card-content {
  position: relative;
  z-index: 1;
  padding: 22px 22px 20px;
  color: #fff;
}
.dash-hero-row {
  display: flex;
  align-items: center;
  gap: 16px;
}
.dash-hero-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2196F3, #1545a8);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 22px;
  overflow: hidden;
  flex: 0 0 56px;
}
.dash-hero-avatar img { width: 100%; height: 100%; object-fit: cover; }
.dash-hero-avatar-lg {
  width: 72px; height: 72px; flex: 0 0 72px;
  font-size: 28px;
  border: 3px solid rgba(255,255,255,0.35);
  box-shadow: 0 4px 16px rgba(0,0,0,0.22);
}
.dash-hero-text-block { flex: 1; min-width: 0; }
.dash-hero-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  margin-bottom: 4px;
}
.dash-hero-name {
  margin: 0;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.05;
  color: #fff;
}
.dash-hero-meta {
  margin-top: 6px;
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.dash-hero-meta #dash-hero-handle { font-weight: 700; }
.dash-hero-sep { opacity: 0.5; }
.dash-hero-email { opacity: 0.85; word-break: break-all; }
.dash-hero-stats {
  margin-top: 18px;
  padding: 14px 18px;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 12px;
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  gap: 0;
  align-items: center;
}
.dash-hero-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.dash-hero-stat-num {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.01em;
  line-height: 1;
}
.dash-hero-stat-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.75);
}
.dash-hero-stat-divider {
  width: 1px;
  height: 28px;
  background: rgba(255,255,255,0.22);
}

.dash-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.dash-action {
  display: block;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 16px 14px;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  font: inherit;
  transition: transform 0.08s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.dash-action:hover { border-color: var(--accent); box-shadow: 0 4px 14px rgba(27, 77, 199, 0.08); text-decoration: none; }
.dash-action:active { transform: scale(0.97); }
.dash-action-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(27, 77, 199, 0.08);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}
.dash-action-icon svg { width: 22px; height: 22px; }
.dash-action-primary { background: linear-gradient(180deg, var(--accent), #1545a8); color: #fff; border-color: var(--accent); }
.dash-action-primary .dash-action-icon { background: rgba(255,255,255,0.18); color: #fff; }
.dash-action-primary:hover { border-color: var(--accent); color: #fff; }
.dash-action-title { font-weight: 700; font-size: 16px; }
.dash-action-sub { font-size: 12.5px; opacity: 0.7; margin-top: 2px; }

.dash-discovery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.dash-disc {
  display: block;
  text-decoration: none;
  color: var(--ink);
  padding: 14px;
  transition: transform 0.08s ease, border-color 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.dash-disc:hover { text-decoration: none; border-color: var(--accent); }
.dash-disc:active { transform: scale(0.97); }

/* ============================================================
   iOS-style bottom tab bar — phone-only navigation.
   Hidden on tablets+ (their sidebar/top strip stays). On phones
   the top horizontal strip is replaced by this thumb-reachable bar.
   Padded with env(safe-area-inset-bottom) so it clears the iPhone
   home indicator on notched devices.
   ============================================================ */
.tabbar { display: none; }   /* hidden on desktop / tablet by default */
@media (max-width: 700px) {
  /* Hide the old top horizontal strip — bottom tabbar replaces it */
  aside.nav { display: none; }
  .layout { grid-template-rows: 56px 1fr; }
  /* Give main content room above the bottom bar so nothing is covered */
  main#main { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px) + 12px); }

  .tabbar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    z-index: 60;
    /* Subtle shadow so it lifts off content as you scroll */
    box-shadow: 0 -1px 0 rgba(0,0,0,0.02), 0 -8px 24px rgba(0,0,0,0.04);
  }
  .tabbar .tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 4px;
    color: #6b7280;
    text-decoration: none;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
    border-radius: 10px;
    transition: color 0.12s ease, background 0.12s ease, transform 0.08s ease;
    -webkit-tap-highlight-color: transparent;
    /* Suppress iOS Safari's default long-press popup (the "share/copy
       link" callout). Without this, a long-press on the <a> tab is
       hijacked by iOS before our gesture timer can fire. */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    min-height: 50px;
  }
  /* Long-press progress ring on the primary (center) Stamp button. */
  .tabbar .tab-primary { position: relative; }
  .tabbar .tab-primary.lp-active .tab-icon-primary {
    box-shadow: 0 0 0 4px rgba(27, 77, 199, 0.18), 0 4px 12px rgba(27, 77, 199, 0.34);
    animation: srStampPulse 0.45s ease-out;
  }
  @keyframes srStampPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
  }
  .tabbar .tab .tab-icon {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .tabbar .tab .tab-icon svg { width: 24px; height: 24px; }
  .tabbar .tab.active { color: var(--accent); }
  .tabbar .tab.active .tab-icon svg { stroke-width: 2.4; }
  .tabbar .tab:active { transform: scale(0.94); background: rgba(27, 77, 199, 0.06); }
  /* Center primary action (Stamp) — slightly elevated, brand-blue accent */
  .tabbar .tab-primary { color: var(--accent); }
  .tabbar .tab-primary .tab-icon-primary {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(180deg, var(--accent) 0%, #1545a8 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(27, 77, 199, 0.34);
    margin-top: -10px;       /* lift above the bar */
    transition: transform 0.08s ease, box-shadow 0.12s ease;
  }
  .tabbar .tab-primary .tab-icon-primary svg {
    width: 26px; height: 26px;
    color: #fff;
  }
  .tabbar .tab-primary:active .tab-icon-primary {
    transform: scale(0.92);
    box-shadow: 0 2px 6px rgba(27, 77, 199, 0.4);
  }
}

/* ============================================================
   PROFILE PAGE — verification badges + identity card + roadmap.
   Same blue/green palette as the marketing site so the brand
   stays cohesive across surfaces.
   ============================================================ */
.profile-card { padding: 24px 26px; }
.profile-head {
  display: flex; align-items: center; gap: 18px;
}
.profile-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  background: linear-gradient(135deg, #2196F3 0%, #1565c0 100%);
  color: #fff; font-weight: 800; font-size: 30px;
  letter-spacing: -0.02em;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(33,150,243,0.30);
  flex-shrink: 0;
}
.profile-meta { flex: 1; min-width: 0; }
.profile-name { font-size: 22px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }

/* Verification rows — one per security factor */
.verif-card { padding: 8px 22px; }
.verif-row {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.verif-row:last-child { border-bottom: none; }
.verif-icon {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.verif-icon svg { width: 18px; height: 18px; }
.verif-icon.ok { background: rgba(26,138,74,0.12); color: #1A8A4A; }
.verif-icon.pending { background: rgba(106,117,137,0.10); color: #6A7589; }
.verif-text { flex: 1; min-width: 0; }
.verif-label { font-weight: 600; color: var(--ink); font-size: 15px; }
.verif-hint { margin-top: 2px; }
.verif-status {
  font-size: 11.5px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px;
}
.verif-status.ok      { background: rgba(26,138,74,0.12); color: #1A8A4A; }
.verif-status.pending { background: rgba(106,117,137,0.10); color: #6A7589; }

/* Verification rows are clickable actions — make that obvious AND
   override iOS native button rendering that interferes with taps */
button.verif-row.verif-action {
  width: 100%;
  display: flex;          /* explicit — overrides browser button default */
  align-items: center;
  gap: 14px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  padding: 18px 8px;
  margin: 0;
  border-radius: 8px;
  transition: background-color .15s, transform .12s;
  -webkit-appearance: none;        /* kill iOS gradient + native chrome */
  appearance: none;
  -webkit-tap-highlight-color: rgba(33,150,243,0.18);   /* iOS tap flash */
  touch-action: manipulation;       /* skip 300ms iOS dbl-tap-to-zoom delay */
  user-select: none;
  -webkit-user-select: none;
}
button.verif-row.verif-action:last-child { border-bottom: none; }
button.verif-row.verif-action:hover {
  background: var(--bg);
}
button.verif-row.verif-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button.verif-row.verif-action:active,
button.verif-row.verif-action.verif-tapped {
  background: rgba(33,150,243,0.14);
  transform: scale(0.985);
}

/* When a verification row is tapped, the target section pulses to
   confirm the click landed. Brief blue glow + lift. */
.section-flash {
  animation: sectionFlash 1.8s ease;
}
@keyframes sectionFlash {
  0%   { background: transparent; }
  20%  { background: rgba(33,150,243,0.18); padding-left: 6px; border-left: 3px solid var(--accent); }
  100% { background: transparent; padding-left: 0; border-left: 3px solid transparent; }
}

/* ============================================================
   Modal overlay used by the verification rows. Centered card,
   dimmed backdrop, slides up on open. iOS-safe.
   ============================================================ */
.sr-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,21,37,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: srModalFade .2s ease;
}
@keyframes srModalFade { from { opacity: 0; } to { opacity: 1; } }
.sr-modal {
  background: var(--surface, #fff);
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.40);
  animation: srModalSlide .25s cubic-bezier(.22,.61,.36,1);
}
@keyframes srModalSlide {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.sr-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line, #e6ecf3);
  background: var(--surface, #fff);
  flex-shrink: 0;
}
.sr-modal-head h3 {
  margin: 0; font-size: 18px; font-weight: 700;
  color: var(--ink, #0e1525);
}
.sr-modal-close {
  border: 0; background: transparent; cursor: pointer;
  font-size: 28px; line-height: 1; color: var(--muted, #6A7589);
  padding: 0 4px; margin: 0;
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  -webkit-appearance: none; appearance: none;
  -webkit-tap-highlight-color: rgba(0,0,0,0.1);
  touch-action: manipulation;
}
.sr-modal-close:hover { background: var(--bg, #f7f8fb); color: var(--ink, #0e1525); }
.sr-modal-body {
  padding: 22px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Roadmap card (Locker storage + future product hints) */
.roadmap-card {
  background: linear-gradient(135deg, rgba(33,150,243,0.06), rgba(33,150,243,0.02));
  border: 1px dashed rgba(33,150,243,0.40);
}
.roadmap-badge {
  display: inline-block;
  padding: 3px 10px;
  background: rgba(33,150,243,0.12);
  color: #1565c0;
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
}

/* Subtle button-primary fix in form-actions for the new Profile screen */
.btn.primary { background: #2196F3; color: #fff; border-color: transparent; }
.btn.primary:hover { background: #1976d2; color: #fff; }
.btn.small { padding: 4px 10px; font-size: 12px; }

/* Amber admin-notice card for "this needs a dashboard click" guidance */
.admin-notice {
  background: linear-gradient(135deg, #fff7e6, #ffffff);
  border: 1px solid #f59e0b !important;
  color: #5b4500;
  font-size: 14px;
  line-height: 1.55;
}
.admin-notice strong { color: #b45309; }

/* ============================================================
   BETA badge in the topbar — reminds users this is early access
   ============================================================ */
.beta-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  background: rgba(245,158,11,0.18);
  color: #b45309;
  border: 1px solid rgba(245,158,11,0.40);
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  vertical-align: middle;
  text-transform: uppercase;
}

/* Topbar avatar thumbnail (image or initials) */
.avatar-thumb {
  display: inline-block;
  width: 28px; height: 28px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 6px;
  object-fit: cover;
  border: 1.5px solid var(--line);
}
.avatar-thumb.avatar-thumb-fallback {
  background: linear-gradient(135deg, #2196F3 0%, #1565c0 100%);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  text-align: center;
  line-height: 25px;
  border-color: transparent;
}

/* Profile avatar with image variant (overrides the gradient bg) */
.profile-avatar.profile-avatar-img {
  background: transparent;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  padding: 0;
  overflow: hidden;
}
.profile-avatar.profile-avatar-img img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

/* Account bar: credit + alias side-by-side on the Profile page */
.account-bar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
@media (min-width: 720px) {
  .account-bar { grid-template-columns: 1fr 1fr; gap: 28px; }
}
.account-credit-num {
  font-size: 44px; font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 6px 0 4px;
}

/* Credit depletion bar — green > amber > red as it drains */
.credit-bar {
  margin-top: 10px;
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.credit-bar-fill {
  height: 100%;
  background: var(--ok, #1A8A4A);
  transition: width .4s ease, background-color .3s ease;
}

/* Alias claim/edit form with live availability indicator */
.alias-form {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.alias-form input {
  flex: 1; min-width: 180px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
}
.alias-form input:focus { outline: none; border-color: var(--accent); }

.alias-state {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.alias-state::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
}
.alias-state-pending   { background: var(--bg); color: var(--muted); }
.alias-state-pending::before   { background: var(--muted); }
.alias-state-checking  { background: var(--bg); color: var(--muted); }
.alias-state-checking::before  { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.alias-state-available { background: rgba(26,138,74,0.10); color: #1A8A4A; }
.alias-state-available::before { background: #1A8A4A; }
.alias-state-taken     { background: rgba(192,57,43,0.10); color: #C0392B; }
.alias-state-taken::before     { background: #C0392B; }
.alias-state-invalid   { background: rgba(245,158,11,0.12); color: #b45309; }
.alias-state-invalid::before   { background: #f59e0b; }
.alias-state-yours     { background: rgba(33,150,243,0.10); color: #1565c0; }
.alias-state-yours::before     { background: #1565c0; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Locker tabs (Stamps / Files / Transfers) — horizontally scrollable
   on phones so 3 tabs never collide with the screen edge. */
.locker-tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-top: 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.locker-tabs::-webkit-scrollbar { display: none; }
.locker-tab {
  padding: 10px 14px;
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 500;
  font-size: 14.5px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  flex-shrink: 0;
}
.locker-tab:hover { color: var(--accent); text-decoration: none; }
.locker-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.locker-tab-count {
  display: inline-block;
  background: var(--bg);
  color: var(--muted);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  margin-left: 4px;
}
.locker-tab.active .locker-tab-count {
  background: rgba(33,150,243,0.12);
  color: var(--accent);
}

/* File input on the locker upload card — make it touch-friendly on iPhone */
#locker-file-input {
  border: 1.5px dashed var(--line-strong, #d4dde9);
  border-radius: 10px;
  padding: 14px;
  width: 100%;
  background: var(--bg);
  cursor: pointer;
}
#locker-file-input::-webkit-file-upload-button {
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 10px 14px;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  margin-right: 12px;
  cursor: pointer;
}
