/* ============================================================
   LuxuryFlow — Soft Neumorphism Design System
   Embossed · Inset · Soft clay · Champagne accent
   ============================================================ */

:root {
  /* Soft clay base (light) */
  --bg: #e8ecf1;
  --bg-elevated: #e8ecf1;
  --bg-card: #e8ecf1;
  --bg-card-hover: #eef2f6;
  --bg-glass: #e8ecf1;
  --bg-inset: #e8ecf1;

  --border: transparent;
  --border-subtle: transparent;
  --border-gold: rgba(184, 148, 40, 0.35);

  --text: #2a3140;
  --text-muted: #6b7285;
  --text-dim: #9aa3b2;

  --gold: #c4a035;
  --gold-light: #d4b24a;
  --gold-dark: #9a7a22;
  --gold-glow: rgba(196, 160, 53, 0.25);

  --emerald: #2f9e6b;
  --ruby: #d14b4b;
  --sapphire: #3b82b0;
  --platinum: #7c6bc4;
  --silver: #7a8494;

  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  /* Neumorphic dual shadows */
  --neo-light: #ffffff;
  --neo-dark: #c5cad3;
  --shadow-out:
    8px 8px 16px var(--neo-dark),
    -8px -8px 16px var(--neo-light);
  --shadow-out-sm:
    4px 4px 10px var(--neo-dark),
    -4px -4px 10px var(--neo-light);
  --shadow-out-lg:
    12px 12px 24px var(--neo-dark),
    -12px -12px 24px var(--neo-light);
  --shadow-in:
    inset 6px 6px 12px var(--neo-dark),
    inset -6px -6px 12px var(--neo-light);
  --shadow-in-sm:
    inset 3px 3px 7px var(--neo-dark),
    inset -3px -3px 7px var(--neo-light);
  --shadow-pressed:
    inset 4px 4px 8px var(--neo-dark),
    inset -4px -4px 8px var(--neo-light);

  --shadow: var(--shadow-out);
  --shadow-gold: var(--shadow-out-sm);

  --font-display: "Cormorant Garamond", "Georgia", serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --header-h: 72px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --header-bg: #e8ecf1;
}

[data-theme="dark"] {
  --bg: #1c1f26;
  --bg-elevated: #1c1f26;
  --bg-card: #1c1f26;
  --bg-card-hover: #22262f;
  --bg-glass: #1c1f26;
  --bg-inset: #1c1f26;

  --text: #e8ecf4;
  --text-muted: #9aa3b5;
  --text-dim: #6b7385;

  --gold: #d4af37;
  --gold-light: #e8c65a;
  --gold-dark: #b89428;
  --gold-glow: rgba(212, 175, 55, 0.3);

  --emerald: #3dd68c;
  --ruby: #f87171;
  --sapphire: #7dd3fc;
  --platinum: #c4b5fd;
  --silver: #cbd5e1;

  --neo-light: #2a303a;
  --neo-dark: #12151a;
  --shadow-out:
    8px 8px 18px var(--neo-dark),
    -6px -6px 14px var(--neo-light);
  --shadow-out-sm:
    4px 4px 10px var(--neo-dark),
    -3px -3px 8px var(--neo-light);
  --shadow-out-lg:
    14px 14px 28px var(--neo-dark),
    -10px -10px 20px var(--neo-light);
  --shadow-in:
    inset 6px 6px 14px var(--neo-dark),
    inset -5px -5px 12px var(--neo-light);
  --shadow-in-sm:
    inset 3px 3px 7px var(--neo-dark),
    inset -3px -3px 7px var(--neo-light);
  --shadow-pressed:
    inset 5px 5px 10px var(--neo-dark),
    inset -4px -4px 8px var(--neo-light);

  --shadow: var(--shadow-out);
  --shadow-gold: var(--shadow-out-sm);
  --header-bg: #1c1f26;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.01em;
}

a { color: var(--gold-dark); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--gold); }

/* ----- Shell ----- */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.header {
  height: var(--header-h);
  background: var(--header-bg);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-out-sm);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.logo-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--gold-dark);
  background: var(--bg);
  box-shadow: var(--shadow-out-sm);
}

.nav { display: flex; gap: 0.35rem; flex: 1; flex-wrap: wrap; }

.nav-link {
  border: none;
  background: var(--bg);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.2s var(--ease);
  box-shadow: var(--shadow-out-sm);
}

.nav-link:hover {
  color: var(--text);
}

.nav-link.active {
  color: var(--gold-dark);
  box-shadow: var(--shadow-pressed);
}

.nav-secondary { display: none !important; }

.header-right { display: flex; align-items: center; gap: 0.85rem; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem 0.35rem 0.35rem;
  border-radius: var(--radius-pill);
  background: var(--bg);
  box-shadow: var(--shadow-out-sm);
  font-size: 0.85rem;
  font-weight: 600;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gold-dark);
  background: var(--bg);
  box-shadow: var(--shadow-in-sm);
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.role-pill {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-pill);
  background: var(--bg);
  box-shadow: var(--shadow-in-sm);
  color: var(--gold-dark);
}
.role-pill.seller { color: var(--sapphire); }
.role-pill.admin { color: var(--platinum); }

.main {
  flex: 1;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

/* ----- Cards ----- */
.card {
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow-out);
  transition: box-shadow 0.25s var(--ease), transform 0.25s var(--ease);
}
.card:hover {
  border-color: transparent;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
}

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.18s var(--ease);
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-out-sm);
}
.btn:active {
  box-shadow: var(--shadow-pressed);
  transform: translateY(1px);
}

.btn-primary {
  color: var(--gold-dark);
  background: var(--bg);
}
.btn-primary:hover {
  color: var(--gold);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-ghost {
  box-shadow: var(--shadow-out-sm);
  color: var(--text-muted);
}
.btn-ghost:hover { color: var(--text); }

.btn-danger { color: var(--ruby); }

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }
.btn-icon {
  padding: 0.45rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

/* ----- Auth ----- */
.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--bg);
}

.auth-card {
  width: min(440px, 100%);
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem 1.75rem;
  box-shadow: var(--shadow-out-lg);
}

.auth-logo { text-align: center; margin-bottom: 1.75rem; }
.auth-logo .logo-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 0.85rem;
  font-size: 1.4rem;
  border-radius: 18px;
}
.auth-logo h1 {
  font-size: 2rem;
  color: var(--text);
}
.auth-logo p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.auth-tabs {
  display: flex;
  gap: 0.4rem;
  padding: 0.3rem;
  border-radius: var(--radius-pill);
  background: var(--bg);
  box-shadow: var(--shadow-in-sm);
  margin-bottom: 1.25rem;
}

.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-muted);
  padding: 0.55rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.2s;
}
.auth-tab.active {
  color: var(--gold-dark);
  box-shadow: var(--shadow-out-sm);
  background: var(--bg);
}

.auth-error {
  background: var(--bg);
  color: var(--ruby);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.85rem;
  box-shadow: var(--shadow-in-sm);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-dim);
  font-size: 0.75rem;
  margin: 1.25rem 0 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 2px;
  border-radius: 2px;
  background: var(--bg);
  box-shadow: var(--shadow-in-sm);
}

.auth-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.65rem;
}

.demo-logins {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
}

.btn-demo {
  border: none;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.4rem;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text);
  box-shadow: var(--shadow-out-sm);
  transition: all 0.18s;
}
.btn-demo:hover { color: var(--gold-dark); }
.btn-demo:active { box-shadow: var(--shadow-pressed); }
.btn-demo span {
  display: block;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 0.2rem;
}
.btn-demo.admin:hover { color: var(--platinum); }
.btn-demo.seller:hover { color: var(--sapphire); }

/* ----- Forms ----- */
.form-group { margin-bottom: 1rem; }

.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  border: none;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-in);
  outline: none;
  transition: box-shadow 0.2s;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  box-shadow:
    var(--shadow-in),
    0 0 0 2px rgba(196, 160, 53, 0.25);
}
.form-input::placeholder { color: var(--text-dim); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

/* ----- Stats / rates ----- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 0;
}

.stat-card {
  background: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow-out);
  position: relative;
  overflow: hidden;
}
.stat-card:hover { transform: none; }
.stat-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.6;
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}
.stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}
.stat-value.positive { color: var(--emerald); }
.stat-value.negative { color: var(--ruby); }
.stat-value.gold { color: var(--gold-dark); }

.rates-row {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.rate-card {
  background: var(--bg);
  border: none;
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.15rem;
  box-shadow: var(--shadow-out);
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.2s;
}
.rate-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-out-lg);
}
.rate-card.selected {
  outline: none;
  box-shadow: var(--shadow-pressed);
}
.rate-card.rate-flash .rate-value {
  animation: ratePulse 0.8s ease;
}

.rate-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.metal-badge {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
  font-size: 0.9rem;
}

.metal-symbol {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 800;
  background: var(--bg);
  box-shadow: var(--shadow-in-sm);
}
.metal-symbol.gold { color: var(--gold-dark); }
.metal-symbol.silver { color: var(--silver); }
.metal-symbol.platinum { color: var(--platinum); }

.rate-value {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 600;
  color: var(--gold-dark);
  line-height: 1.15;
}

.rate-change { font-size: 0.8rem; font-weight: 600; }
.rate-change.up { color: var(--emerald); }
.rate-change.down { color: var(--ruby); }

/* ----- Tabs ----- */
.tabs {
  display: inline-flex;
  gap: 0.35rem;
  padding: 0.3rem;
  border-radius: var(--radius-pill);
  background: var(--bg);
  box-shadow: var(--shadow-in-sm);
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.tab {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.18s;
}
.tab.active {
  color: var(--gold-dark);
  background: var(--bg);
  box-shadow: var(--shadow-out-sm);
}
.tab:hover:not(.active) { color: var(--text); }

/* ----- Tables ----- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow-in-sm);
  padding: 0.35rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
th {
  text-align: left;
  padding: 0.7rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
td {
  padding: 0.7rem 0.75rem;
  border-top: 1px solid rgba(128, 128, 128, 0.08);
  color: var(--text);
}
tr:hover td { background: rgba(128, 128, 128, 0.04); }

/* ----- Marketplace ----- */
.listings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.listing-card {
  background: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 1.15rem;
  box-shadow: var(--shadow-out);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 180px;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
}
.listing-card::after { display: none; }
.listing-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-out-lg);
}
.listing-card.seller { box-shadow: var(--shadow-out), inset 3px 0 0 var(--emerald); }
.listing-card.buyer { box-shadow: var(--shadow-out), inset 3px 0 0 var(--sapphire); }

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-pill);
  background: var(--bg);
  box-shadow: var(--shadow-in-sm);
}
.badge-seller { color: var(--emerald); }
.badge-buyer { color: var(--sapphire); }
.badge-good { color: var(--emerald); }
.badge-warn { color: var(--ruby); }

/* ----- Pages ----- */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-gold { color: var(--gold-dark); }
.text-emerald { color: var(--emerald); }
.text-ruby { color: var(--ruby); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 400;
  background: var(--bg);
  color: var(--text);
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-out);
  font-size: 0.88rem;
  font-weight: 600;
  animation: slideIn 0.3s var(--ease);
  max-width: 320px;
}
.toast.success { box-shadow: var(--shadow-out), inset 3px 0 0 var(--emerald); }
.toast.error { box-shadow: var(--shadow-out), inset 3px 0 0 var(--ruby); }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.page { display: none; }
.page.active { display: block; animation: fadePage 0.28s var(--ease); }

@keyframes fadePage {
  from { opacity: 0; }
  to { opacity: 1; }
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.page-title {
  font-size: 1.85rem;
  color: var(--text);
}
.page-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.2rem;
}

/* Legacy summary (if any) */
.summary-panel {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-out);
}
.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  font-size: 0.9rem;
}
.summary-row .label { color: var(--text-muted); }
.summary-row.total {
  margin-top: 0.5rem;
  padding-top: 0.65rem;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(128,128,128,0.12);
}

/* Seller banner */
.seller-banner {
  background: var(--bg);
  box-shadow: var(--shadow-in-sm);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Theme options */
.theme-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.theme-option {
  border: none;
  background: var(--bg);
  box-shadow: var(--shadow-out-sm);
  border-radius: var(--radius-pill);
  padding: 0.55rem 1rem;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
}
.theme-option.active {
  color: var(--gold-dark);
  box-shadow: var(--shadow-pressed);
}

/* Profile */
.profile-hero {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  flex-wrap: wrap;
}
.profile-avatar-lg {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: var(--shadow-out);
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold-dark);
  overflow: hidden;
}
.profile-avatar-lg img { width: 100%; height: 100%; object-fit: cover; }

/* Mobile menu */
.mobile-menu-btn {
  display: none;
  border: none;
  background: var(--bg);
  box-shadow: var(--shadow-out-sm);
  border-radius: 12px;
  width: 40px;
  height: 40px;
  place-items: center;
  cursor: pointer;
  color: var(--text);
}

/* FX strip */
.fx-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  padding: 0.7rem 1.1rem;
  margin-bottom: 1rem;
  background: var(--bg);
  border: none;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-in-sm);
  font-size: 0.85rem;
}
.fx-item strong { color: var(--gold-dark); margin-left: 0.25rem; }

.unit-toggle {
  display: inline-flex;
  padding: 0.25rem;
  border-radius: var(--radius-pill);
  background: var(--bg);
  box-shadow: var(--shadow-in-sm);
  border: none;
}
.unit-btn {
  border: none;
  background: transparent;
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
  border-radius: var(--radius-pill);
}
.unit-btn.active {
  background: var(--bg);
  color: var(--gold-dark);
  box-shadow: var(--shadow-out-sm);
}

.edge-pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--bg);
  box-shadow: var(--shadow-in-sm);
}
.edge-pill.good { color: var(--emerald); }
.edge-pill.bad { color: var(--ruby); }
.edge-pill.neutral { color: var(--gold-dark); }

.verified-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--emerald);
}

.alert-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0;
  font-size: 0.85rem;
  box-shadow: inset 0 -1px 0 rgba(128,128,128,0.08);
}
.alert-row.triggered { opacity: 0.7; }

/* Desk nav */
.desk-nav {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
  padding: 0.3rem;
  background: var(--bg);
  border: none;
  border-radius: var(--radius-pill);
  width: fit-content;
  max-width: 100%;
  flex-wrap: wrap;
  box-shadow: var(--shadow-in-sm);
}
.desk-nav-btn {
  border: none;
  background: transparent;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.desk-nav-btn:hover { color: var(--text); }
.desk-nav-btn.active {
  background: var(--bg);
  color: var(--gold-dark);
  box-shadow: var(--shadow-out-sm);
}

/* Quick actions */
.quick-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.55rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: 0.25rem;
}
.quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.75rem 0.65rem;
  border: none;
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  box-shadow: var(--shadow-out-sm);
  transition: all 0.18s;
  flex: 1 0 auto;
  min-width: 4.5rem;
}
.quick-btn:hover { color: var(--gold-dark); }
.quick-btn:active { box-shadow: var(--shadow-pressed); }
.quick-icon {
  font-size: 1.2rem;
  color: var(--gold-dark);
}

/* Rate pulse */
@keyframes ratePulse {
  0% { color: var(--gold-light); transform: scale(1.04); }
  100% { color: inherit; transform: scale(1); }
}

/* Karat grid */
.karat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  align-items: start;
}
.karat-card .card-title { margin-bottom: 0.75rem; }
.karat-card table { width: 100%; font-size: 0.85rem; }
.karat-card th,
.karat-card td {
  padding: 0.4rem 0.35rem;
  text-align: left;
}
.karat-card th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Deal ticket */
.deal-panel {
  background: var(--bg);
  border: none;
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.4rem 1.2rem;
  box-shadow: var(--shadow-out);
  position: sticky;
  top: calc(var(--header-h) + 1rem);
}
.deal-panel-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.1rem;
}
.deal-kicker {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-dark);
}
.deal-metal {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
}
.deal-hero {
  text-align: center;
  padding: 1.1rem 0.75rem 1.25rem;
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow-in-sm);
  margin-bottom: 1rem;
}
.deal-hero-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.deal-hero-value {
  font-family: var(--font-display);
  font-size: 2.15rem;
  font-weight: 600;
  color: var(--gold-dark);
  line-height: 1.2;
  margin: 0.25rem 0;
  word-break: break-all;
}
.deal-hero-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.deal-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.deal-metric {
  text-align: center;
  padding: 0.65rem 0.35rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  box-shadow: var(--shadow-out-sm);
}
.deal-metric-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 0.25rem;
}
.deal-metric-value {
  font-size: 0.9rem;
  font-weight: 700;
}
.deal-metric-value.gold { color: var(--gold-dark); }
.deal-rates {
  padding: 0.85rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  box-shadow: var(--shadow-in-sm);
}
.deal-rate-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  padding: 0.3rem 0;
  color: var(--text-muted);
}
.deal-rate-row strong { color: var(--text); font-weight: 700; }
.deal-rate-bar-wrap {
  height: 8px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow: var(--shadow-in-sm);
  margin: 0.65rem 0 0.75rem;
  overflow: hidden;
}
.deal-rate-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--emerald), var(--gold));
  transition: width 0.35s var(--ease), background 0.35s;
}
.deal-rate-bar.over {
  background: linear-gradient(90deg, var(--gold), var(--ruby));
}
.deal-edge-badge {
  min-height: 1.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
}
.deal-edge-badge .good { color: var(--emerald); }
.deal-edge-badge .bad { color: var(--ruby); }
.deal-footnote {
  margin-top: 0.85rem;
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.4;
}

/* Auth extras */
.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  cursor: pointer;
}
.check-row input { accent-color: var(--gold); }
.role-pick { display: flex; flex-direction: column; gap: 0.5rem; }
.role-pick-option {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.75rem 0.85rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--bg);
  box-shadow: var(--shadow-out-sm);
}
.role-pick-option:has(input:checked) {
  box-shadow: var(--shadow-pressed);
  color: var(--gold-dark);
}
.role-pick-option strong { display: block; font-size: 0.9rem; }
.role-pick-option small {
  display: block;
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 0.15rem;
}
.hp-field {
  position: absolute;
  left: -9999px;
  height: 0;
  overflow: hidden;
  opacity: 0;
}
.captcha-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.role-notes {
  margin-top: 1.25rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--bg);
  box-shadow: var(--shadow-in-sm);
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
}
.role-notes h4 {
  font-size: 0.8rem;
  color: var(--gold-dark);
  margin-bottom: 0.4rem;
  font-family: var(--font-body);
  font-weight: 700;
}
.role-notes ul { padding-left: 1.1rem; margin: 0; }
.role-notes li { margin-bottom: 0.35rem; }

.inv-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}
.inv-toolbar .form-input,
.inv-toolbar .form-select {
  flex: 1;
  min-width: 140px;
}
.inv-summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  padding: 0.65rem 1rem;
  background: var(--bg);
  border: none;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-in-sm);
}
.inv-summary-bar strong { color: var(--text); }

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(42, 49, 64, 0.35);
  backdrop-filter: blur(4px);
}
.modal-overlay.hidden {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
}
.modal-overlay {
  pointer-events: auto;
}

.modal-card {
  width: min(420px, 100%);
  max-height: min(85vh, 640px);
  overflow: auto;
  background: var(--bg);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-out-lg);
  padding: 1.15rem 1.25rem 1.25rem;
  animation: modalIn 0.2s var(--ease);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.modal-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
}
.modal-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}
.purity-modal-spot {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  box-shadow: var(--shadow-in-sm);
}
.purity-modal-spot strong {
  color: var(--gold-dark);
  font-size: 1.1rem;
}
.shortcut-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.shortcut-list li {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  font-size: 0.9rem;
  box-shadow: inset 0 -1px 0 rgba(128,128,128,0.08);
}
kbd {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 8px;
  border: none;
  background: var(--bg);
  color: var(--gold-dark);
  box-shadow: var(--shadow-out-sm);
}
.btn-copy-mini {
  border: none;
  background: var(--bg);
  color: var(--gold-dark);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: inherit;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-out-sm);
}
body.modal-open { overflow: hidden; }

/* Mobile tab bar */
.mobile-tabbar {
  display: none;
  position: fixed;
  left: 50%;
  bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 2490;
  width: min(380px, calc(100% - 1.25rem));
  background: var(--bg);
  border: none;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-out-lg);
  padding: 0.4rem;
  gap: 0.25rem;
  pointer-events: auto !important;
}
.tabbar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.5rem 0.35rem;
  min-height: 48px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  pointer-events: auto !important;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.tabbar-item.active {
  color: var(--gold-dark);
  background: var(--bg);
  box-shadow: var(--shadow-pressed);
}
.tabbar-icon { font-size: 1.1rem; line-height: 1; pointer-events: none; }
.tabbar-item span { pointer-events: none; }

/* Print */
@media print {
  body * { visibility: hidden !important; }
  #receipt-print, #receipt-print * { visibility: visible !important; }
  #receipt-print {
    position: absolute;
    left: 0; top: 0;
    width: 100%;
    padding: 1.5rem;
    background: white;
    color: black;
  }
  .no-print { display: none !important; }
}
.receipt-print {
  max-width: 420px;
  font-family: var(--font-body);
  line-height: 1.4;
}
.receipt-print h2 { font-family: var(--font-display); margin-bottom: 0.5rem; }
.receipt-print .r-row { display: flex; justify-content: space-between; padding: 0.25rem 0; }
.receipt-print .r-total {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  font-weight: 700;
  box-shadow: inset 0 2px 0 #333;
}

/* Responsive */
@media (max-width: 960px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .rates-row { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .karat-grid { grid-template-columns: 1fr; }
  .deal-panel { position: static; }
}

@media (max-width: 768px) {
  .mobile-tabbar { display: flex; }
  .header .nav-link.nav-main { display: none !important; }
  .mobile-menu-btn { display: grid; }
  .app-shell { padding-bottom: 5.5rem; }
  .demo-logins { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .main { padding: 1rem 0.9rem 4rem; }
  .page-title { font-size: 1.5rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}


/* ========== Bento box layout (neumorphic) ========== */
.bento {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
  align-items: stretch;
}

.bento-cell {
  min-width: 0;
}

.bento-fx {
  grid-column: span 12;
}

.bento-rates {
  grid-column: span 12;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 1rem;
}

.bento-rates .rate-card:first-child {
  /* Gold — hero tile */
  padding: 1.5rem 1.35rem;
}
.bento-rates .rate-card:first-child .rate-value {
  font-size: 2.35rem;
}

.bento-stats {
  grid-column: span 12;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.bento-positions {
  grid-column: span 7;
}

.bento-history {
  grid-column: span 5;
}

.bento-actions {
  grid-column: span 12;
}

/* Nested cards inside bento shouldn't double-gap oddly */
.bento .card {
  height: 100%;
}

/* Rates page bento */
#page-rates .karat-grid {
  grid-template-columns: 1fr 1fr;
}

#page-rates .rates-row {
  grid-template-columns: 1.3fr 1fr;
}

/* Buy page: form + deal as bento */
#page-buy .grid-2 {
  grid-template-columns: 1.2fr 0.9fr;
  gap: 1.15rem;
}

/* Soft bento rhythm on main */
.main {
  max-width: 1120px;
}

@media (max-width: 960px) {
  .bento-rates { grid-template-columns: 1fr; }
  .bento-stats { grid-template-columns: repeat(2, 1fr); }
  .bento-positions,
  .bento-history,
  .bento-actions { grid-column: span 12; }
}

@media (max-width: 560px) {
  .bento-stats { grid-template-columns: 1fr; }
  .bento { gap: 0.85rem; }
}


/* Floating desk bar — Inventory / Buy / Sell (above page content, clickable) */
.desk-tabbar {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 2500;
  display: none;
  width: min(420px, calc(100% - 1.25rem));
  background: var(--bg);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-out-lg);
  padding: 0.4rem;
  gap: 0.3rem;
  pointer-events: auto !important;
  -webkit-user-select: none;
  user-select: none;
}
.desk-tabbar.visible {
  display: flex !important;
  pointer-events: auto !important;
}
.desk-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.55rem 0.4rem;
  min-height: 48px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.18s var(--ease);
  pointer-events: auto !important;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.desk-tab:active {
  color: var(--gold-dark);
  box-shadow: var(--shadow-pressed);
}
.desk-tab.active {
  color: var(--gold-dark);
  background: var(--bg);
  box-shadow: var(--shadow-pressed);
}
.desk-tab-icon { font-size: 1.15rem; line-height: 1; pointer-events: none; }
.desk-tab span { pointer-events: none; }

.app-shell.desk-pad { padding-bottom: 5.75rem; }

@media (max-width: 768px) {
  .desk-tabbar.visible {
    bottom: calc(4.25rem + env(safe-area-inset-bottom, 0px));
  }
  .app-shell.desk-pad { padding-bottom: calc(9.75rem + env(safe-area-inset-bottom, 0px)); }
}

/* ===== Rates market layout (gold/silver PH style) ===== */
.rates-market {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.market-block {
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-out);
  padding: 1.35rem 1.4rem 1.5rem;
}

.market-block-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.1rem;
}
.market-block-header h2 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 600;
}
.market-block-header .date {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.purity-hero-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  margin-bottom: 1rem;
}
.purity-hero {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-out-sm);
  padding: 1rem 0.9rem;
  text-align: center;
}
.purity-hero .ph-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.purity-hero .ph-price {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--gold-dark);
  margin: 0.35rem 0 0.2rem;
}
.purity-hero .ph-change {
  font-size: 0.8rem;
  font-weight: 700;
}
.purity-hero .ph-change.up { color: var(--emerald); }
.purity-hero .ph-change.down { color: var(--ruby); }

.market-blurb {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1.15rem;
}

.worth-box {
  background: var(--bg);
  box-shadow: var(--shadow-in-sm);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1.15rem;
}
.worth-box h3 {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  font-family: var(--font-display);
}
.worth-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.65rem;
  align-items: end;
}
.worth-result {
  margin-top: 0.75rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gold-dark);
}

.rate-table-card {
  margin-bottom: 1rem;
}
.rate-table-card h4 {
  font-size: 0.88rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}
.rate-table-card .table-wrap {
  box-shadow: var(--shadow-in-sm);
}

.history-table .chg-up { color: var(--emerald); }
.history-table .chg-down { color: var(--ruby); }

@media (max-width: 720px) {
  .purity-hero-row { grid-template-columns: 1fr; }
  .worth-row { grid-template-columns: 1fr; }
}


/* ========== Mobile compatibility ========== */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  overflow-x: hidden;
  overscroll-behavior-y: contain;
}
button, a, .nav-link, .desk-tab, .tabbar-item, .quick-btn, .btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.form-input, .form-select, .form-textarea {
  font-size: 16px; /* prevents iOS zoom on focus */
  max-width: 100%;
}
.main {
  padding-left: max(0.9rem, env(safe-area-inset-left));
  padding-right: max(0.9rem, env(safe-area-inset-right));
}
.header {
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  padding-top: env(safe-area-inset-top, 0px);
}

@media (max-width: 768px) {
  .header {
    height: auto;
    min-height: var(--header-h);
    flex-wrap: wrap;
    padding-top: max(0.5rem, env(safe-area-inset-top));
    padding-bottom: 0.5rem;
  }
  .header-right { gap: 0.4rem; }
  .user-chip span#user-name { max-width: 5.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .page-title { font-size: 1.4rem; }
  .rate-value { font-size: 1.55rem; }
  .bento-rates .rate-card:first-child .rate-value { font-size: 1.75rem; }
  .deal-panel { position: static; }
  .stats-grid, .bento-stats { grid-template-columns: repeat(2, 1fr); }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .auth-card { width: min(100%, 420px); padding: 1.5rem 1.15rem; }
  .demo-logins { grid-template-columns: 1fr; }
  .purity-hero .ph-price { font-size: 1.25rem; }
  .modal-card { width: min(100%, 420px); max-height: min(88vh, 640px); }
}

@media (max-width: 400px) {
  .desk-tab, .tabbar-item { font-size: 0.65rem; }
}

.rates-metal-tabs {
  margin-bottom: 1rem;
}

.rates-credit {
  margin-top: 2rem;
  padding: 1.1rem 1rem 1.4rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.55;
  border-top: none;
}
.rates-credit a {
  color: var(--gold-dark);
  font-weight: 600;
  text-decoration: none;
}
.rates-credit a:hover { text-decoration: underline; }

/* Auth as modal over public rates home — NEVER in document flow */
.auth-screen.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 4000;
  min-height: 0;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 1.25rem;
  background: rgba(30, 35, 45, 0.55);
  backdrop-filter: blur(8px);
}
.auth-screen.auth-modal.hidden {
  display: none !important;
}
.auth-screen.auth-modal .auth-card {
  position: relative;
  margin: auto;
  max-height: none;
  overflow: visible;
}
body.auth-open { overflow: hidden; }
.auth-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 2;
}
.guest-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.guest-actions.hidden,
.user-chip.hidden,
#logout-btn.hidden {
  display: none !important;
}


/* Live feed status */
body.rates-stale .rate-value {
  opacity: 0.92;
}
.live-stale-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ruby);
  background: var(--bg);
  box-shadow: var(--shadow-in-sm);
  border-radius: var(--radius-pill);
  padding: 0.25rem 0.65rem;
  margin-left: 0.5rem;
}
.live-stale-badge.hidden { display: none !important; }
#fx-live-meta, #rates-meta, #last-fetched {
  font-variant-numeric: tabular-nums;
}

.app-build-badge {
  position: fixed;
  right: 0.75rem;
  bottom: 0.5rem;
  z-index: 100;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--bg);
  box-shadow: var(--shadow-out-sm);
  border-radius: var(--radius-pill);
  padding: 0.25rem 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  pointer-events: none;
  opacity: 0.85;
}
.feed-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  display: inline-block;
}
.feed-dot.ok { background: var(--emerald); }
.feed-dot.stale { background: #e6a23c; }
.feed-dot.err { background: var(--ruby); }
@media (max-width: 768px) {
  .app-build-badge { bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px)); font-size: 0.62rem; }
}
.inv-under-melt { color: var(--ruby); font-weight: 700; }

a.desk-tab, a.tabbar-item { text-decoration: none; color: inherit; }


/* ========== Seamless scroll (one pane, neo scrollbar, docks) ========== */
:root { --dock-h: 0px; }

html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  overscroll-behavior: none;
}

.app-shell {
  height: 100%;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.header {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.main {
  flex: 1 1 auto;
  min-height: 0;
  width: min(1180px, 100%);
  margin: 0 auto;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  scroll-padding-top: 0.75rem;
  padding: 1.35rem 1.25rem calc(var(--dock-h) + 1.75rem + env(safe-area-inset-bottom, 0px));
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--neo-dark) transparent;
}

.main::-webkit-scrollbar { width: 10px; }
.main::-webkit-scrollbar-track {
  background: transparent;
  margin: 8px 0 12px;
}
.main::-webkit-scrollbar-thumb {
  background: var(--bg);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
  box-shadow: inset 2px 2px 4px var(--neo-dark), inset -2px -2px 4px var(--neo-light);
}
.main::-webkit-scrollbar-thumb:hover {
  box-shadow: var(--shadow-pressed);
}

.quick-actions::-webkit-scrollbar { height: 0; }
.table-wrap::-webkit-scrollbar { height: 8px; }
.table-wrap::-webkit-scrollbar-thumb {
  background: var(--bg);
  border-radius: 999px;
  box-shadow: var(--shadow-in-sm);
}

.app-shell.desk-pad { --dock-h: 5.75rem; padding-bottom: 0; }

@media (max-width: 768px) {
  :root { --dock-h: 5.35rem; }
  .app-shell { padding-bottom: 0; }
  .app-shell.desk-pad { --dock-h: 10.15rem; padding-bottom: 0; }
  .main { padding-left: max(0.9rem, env(safe-area-inset-left)); padding-right: max(0.9rem, env(safe-area-inset-right)); }
}

.toast {
  bottom: calc(var(--dock-h) + 1rem + env(safe-area-inset-bottom, 0px));
}

.app-build-badge {
  bottom: calc(var(--dock-h) + 0.35rem);
  opacity: 0.45;
  pointer-events: none;
}

/* Soft fade so content tucks under header / docks */
.header::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -18px;
  height: 18px;
  pointer-events: none;
  background: linear-gradient(to bottom, var(--bg), transparent);
}

body.auth-open .main,
body.modal-open .main {
  overflow: hidden;
}
