/* ═══════════════════════════════════════════════════════════════════
   DonorGraph — Editorial Forest theme
   Refined cream / forest / gold palette
   Newsreader serif + Geist sans + Geist Mono
   Backwards compatible with existing class names
   ═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Newsreader:opsz,ital,wght@6..72,0,400;6..72,0,500;6..72,0,600;6..72,1,400;6..72,1,500&family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500&display=swap');

/* ── Design tokens ─────────────────────────────────────────────── */
:root {
  /* Paper / cream tones (warm, low-contrast surfaces) */
  --cream:    #F5F2EB;
  --cream-2:  #EFEBE1;
  --paper:    #FFFFFF;
  --paper-2:  #FBFAF6;

  /* Ink scale */
  --ink:      #16170F;
  --ink-2:    #3A3A31;
  --ink-3:    #6D6C61;
  --ink-4:    #9E9C8F;

  /* Hairline borders */
  --line:     rgba(20, 22, 14, 0.08);
  --line-2:   rgba(20, 22, 14, 0.14);

  /* Forest green primary */
  --forest:   #1A472A;
  --forest-2: #0F3019;
  --forest-3: #2C6840;
  --sage:     #E5EDE0;
  --sage-2:   #D4DFCC;

  /* Accent / status */
  --gold:       #A68018;
  --gold-soft:  #F3E8C2;
  --clay:       #B14A2C;
  --clay-soft:  #F3DCCF;
  --sky:        #2C5F7A;
  --danger:     #C0392B;
  --danger-bg:  #FEF0EE;
  --danger-bd:  rgba(192,57,43,0.2);

  /* ── Legacy aliases (preserve existing styles) */
  --bg:        var(--cream);
  --bg2:       var(--cream-2);
  --surface:   var(--paper);
  --surface2:  var(--paper-2);
  --ink2:      var(--ink-2);
  --ink3:      var(--ink-3);
  --accent:    var(--forest);
  --accent2:   var(--forest-3);
  --accent-bg: var(--sage);
  --accent-bd: rgba(26,71,42,0.22);
  --sage-bg:   var(--sage);
  --sage-bd:   rgba(26,71,42,0.18);
  --amber:     var(--gold);
  --amber-bg:  var(--gold-soft);
  --amber-bd:  rgba(166,128,24,0.22);
  --border:    var(--line-2);
  --border2:   var(--line);

  /* Typography */
  --serif:  'Newsreader', 'Source Serif Pro', Georgia, serif;
  --sans:   'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono:   'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Shadows (very subtle — let the hairline borders do the work) */
  --sh:    0 1px 2px rgba(20,22,14,0.04);
  --sh-md: 0 2px 8px rgba(20,22,14,0.06), 0 1px 2px rgba(20,22,14,0.04);
  --sh-lg: 0 12px 32px rgba(20,22,14,0.10), 0 4px 12px rgba(20,22,14,0.06);

  /* Density */
  --pad-y:    12px;
  --pad-x:    16px;
  --row-h:    52px;
  --gap:      14px;
  --card-pad: 20px;

  /* Layout */
  --sidebar-w:    220px;
  --topbar-h:     56px;
  --bottom-nav-h: 60px;
}

[data-density="compact"] {
  --pad-y:    8px;
  --pad-x:    12px;
  --row-h:    40px;
  --gap:      10px;
  --card-pad: 14px;
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'ss01', 'cv11';
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--sans); }
input, select, textarea { font-family: var(--sans); color: inherit; }
img { max-width: 100%; }

/* Editorial type utilities */
.serif        { font-family: var(--serif); letter-spacing: -0.02em; font-weight: 500; }
.serif em     { font-style: italic; color: var(--forest); font-weight: 500; }
.italic-emph  { font-style: italic; color: var(--forest); font-weight: 500; }
.eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
}
.mono { font-family: var(--mono); }

/* ── App shell ─────────────────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  min-height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  background: rgba(255,255,255,0.85);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
  padding: 0 16px; gap: 10px;
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon {
  width: 30px; height: 30px;
  background: var(--forest);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--cream);
}
.logo-name {
  font-family: var(--serif);
  font-size: 19px; font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.logo-badge {
  font-family: var(--mono);
  font-size: 9px;
  background: var(--sage); color: var(--forest);
  padding: 2px 7px; border-radius: 999px;
  font-weight: 500; letter-spacing: 0.06em;
  border: 1px solid rgba(26,71,42,0.18);
  text-transform: uppercase;
}
.topbar-search { flex: 1; max-width: 380px; position: relative; }
.topbar-search svg {
  position: absolute; left: 11px; top: 50%;
  transform: translateY(-50%); color: var(--ink-3);
  pointer-events: none;
}
.topbar-search input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: 8px; font-size: 13px; color: var(--ink);
  outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
.topbar-search input:focus {
  background: var(--paper);
  border-color: rgba(26,71,42,0.4);
  box-shadow: 0 0 0 3px rgba(26,71,42,0.10);
}
.topbar-search input::placeholder { color: var(--ink-4); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.t-icon-btn {
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--line); background: transparent;
  display: flex; align-items: center; justify-content: center;
  position: relative; transition: background .15s, border-color .15s;
  color: var(--ink-2);
}
.t-icon-btn:hover { background: var(--cream-2); border-color: var(--line-2); }
.notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--clay); border: 1.5px solid var(--paper);
}
.user-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--paper);
  transition: border-color .15s;
}
.user-pill:hover { border-color: var(--line-2); }
.user-av {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--sage); color: var(--forest);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600;
  font-family: var(--serif);
}
.user-pill-name { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.ham-btn {
  display: none; background: none; border: none;
  padding: 6px; color: var(--ink-2);
  align-items: center; justify-content: center;
}

/* ── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  background: var(--paper-2);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  display: flex; flex-direction: column;
  gap: 1px; overflow-y: auto;
}
.nav-section {
  font-family: var(--mono);
  font-size: 9.5px; font-weight: 500;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-4); padding: 14px 10px 6px;
  margin-top: 4px;
}
.nav-section:first-child { margin-top: 0; padding-top: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 7px;
  font-size: 13px; color: var(--ink-2);
  transition: background .12s, color .12s; border: none; background: none;
  width: 100%; text-align: left; text-decoration: none;
  font-weight: 400;
}
.nav-item:hover { background: var(--cream-2); color: var(--ink); }
.nav-item.active {
  background: var(--sage);
  color: var(--forest); font-weight: 500;
}
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.85; }
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto;
  font-family: var(--mono);
  background: rgba(26,71,42,0.10); color: var(--forest);
  font-size: 10px; font-weight: 500;
  padding: 1px 6px; border-radius: 999px;
}
.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.usage-card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 8px; padding: 12px; margin-top: 6px;
}
.usage-label {
  font-family: var(--mono);
  font-size: 9.5px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.usage-bar {
  height: 4px; background: var(--cream-2);
  border-radius: 2px; overflow: hidden; margin-bottom: 5px;
}
.usage-fill {
  height: 100%;
  background: var(--forest);
  border-radius: 2px;
}
.usage-text {
  font-family: var(--mono);
  font-size: 10px; color: var(--ink-3);
  display: flex; justify-content: space-between;
}

/* ── Main ──────────────────────────────────────────────────────── */
.main {
  overflow-y: auto;
  padding: 24px 28px;
  background: var(--cream);
  min-width: 0;
}

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(20,22,14,0.45);
  z-index: 149;
}
.sidebar-overlay.show { display: block; }

.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: var(--paper);
  border-top: 1px solid var(--line);
  z-index: 100;
  padding: 0 4px;
}
.bottom-nav-items { display: flex; align-items: stretch; height: 100%; }
.bnav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; border: none; background: none;
  color: var(--ink-3); font-size: 10px;
  text-decoration: none; padding: 4px 2px;
  transition: color .15s;
}
.bnav-item svg { width: 20px; height: 20px; }
.bnav-item.active { color: var(--forest); font-weight: 500; }
.bnav-item:hover { color: var(--forest); }

/* ── Page headers ──────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap; gap: 14px;
  margin-bottom: 20px;
}
.page-title {
  font-family: var(--serif);
  font-size: 28px; font-weight: 500;
  color: var(--ink); letter-spacing: -0.025em;
  line-height: 1.1;
}
.page-title em { font-style: italic; color: var(--forest); font-weight: 500; }
.page-sub { font-size: 13.5px; color: var(--ink-3); margin-top: 6px; }

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--sh);
}
.card-header {
  padding: 14px var(--card-pad);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
  justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
}
.card-title {
  font-family: var(--serif);
  font-size: 15px; font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.card-body { padding: var(--card-pad); }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 14px;
  border-radius: 7px; font-size: 13px;
  font-weight: 500; border: 1px solid transparent;
  white-space: nowrap; transition: background .15s, border-color .15s, color .15s;
  font-family: var(--sans);
  letter-spacing: -0.005em;
  cursor: pointer;
}
.btn svg { width: 13px; height: 13px; opacity: 0.9; }
.btn-primary {
  background: var(--forest); color: var(--cream);
  border-color: var(--forest);
}
.btn-primary:hover { background: var(--forest-2); border-color: var(--forest-2); }
.btn-ghost {
  background: var(--paper); color: var(--ink-2);
  border-color: var(--line-2);
}
.btn-ghost:hover { background: var(--cream-2); color: var(--ink); }
.btn-danger {
  background: var(--danger-bg); color: var(--danger);
  border-color: var(--danger-bd);
}
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 6px; }
.btn-lg { padding: 11px 20px; font-size: 14px; border-radius: 8px; }
.btn-full { width: 100%; }

/* ── Form ──────────────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field-label {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-3); margin-bottom: 6px;
}
.field-input, .field-select, .field-textarea {
  width: 100%; padding: 10px 12px;
  background: var(--paper); border: 1px solid var(--line-2);
  border-radius: 7px; font-size: 13.5px;
  color: var(--ink); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field-input:focus, .field-select:focus, .field-textarea:focus {
  border-color: rgba(26,71,42,0.45);
  box-shadow: 0 0 0 3px rgba(26,71,42,0.10);
}
.field-input::placeholder, .field-textarea::placeholder { color: var(--ink-4); }
.field-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236D6C61' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.field-textarea { resize: vertical; min-height: 80px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-hint { font-size: 11.5px; color: var(--ink-3); margin-top: 5px; }

/* ── Pills / chips ─────────────────────────────────────────────── */
.pill, .chip {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 500; white-space: nowrap;
  border: 1px solid;
}
.pill-green, .chip {
  background: var(--sage); color: var(--forest);
  border-color: rgba(26,71,42,0.18);
}
.pill-sage  { background: var(--sage); color: var(--forest); border-color: rgba(26,71,42,0.18); }
.pill-amber, .chip-gold {
  background: var(--gold-soft); color: var(--gold);
  border-color: rgba(166,128,24,0.22);
}
.pill-slate { background: var(--cream-2); color: var(--ink-3); border-color: var(--line); }
.pill-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-bd); }
.chip-clay { background: var(--clay-soft); color: var(--clay); border-color: rgba(177,74,44,0.22); }
.chip-paper { background: var(--paper); color: var(--ink-2); border-color: var(--line-2); }

/* ── Score badges (legacy, kept for compatibility) ──────────────── */
.score-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  font-family: var(--serif);
  font-size: 14px; font-weight: 600; flex-shrink: 0;
  letter-spacing: -0.02em;
}
.score-hi { background: var(--sage); color: var(--forest); border: 1px solid rgba(26,71,42,0.18); }
.score-md { background: var(--gold-soft); color: var(--gold); border: 1px solid rgba(166,128,24,0.22); }
.score-lo { background: var(--cream-2); color: var(--ink-3); border: 1px solid var(--line); }

/* ── Score band (new — for donor profile hero) ─────────────────── */
.score-band {
  background: var(--paper-2);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 18px 24px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 24px;
  align-items: center;
}
.score-cell { display: flex; flex-direction: column; gap: 4px; }
.score-cell + .score-cell { border-left: 1px solid var(--line); padding-left: 24px; }
.score-cell-lbl {
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-3);
}
.score-cell-val {
  font-family: var(--serif);
  font-size: 26px; font-weight: 500;
  letter-spacing: -0.025em; color: var(--ink);
  line-height: 1;
}
.score-cell-val em { font-style: italic; color: var(--forest); }
.score-cell-sub { font-size: 11.5px; color: var(--ink-3); }

/* ── Avatars ───────────────────────────────────────────────────── */
.av {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; flex-shrink: 0;
  background: var(--sage); color: var(--forest);
  font-family: var(--serif);
  font-weight: 600;
}
.av-sm { width: 24px; height: 24px; font-size: 10px; }
.av-md { width: 36px; height: 36px; font-size: 13px; }
.av-lg { width: 52px; height: 52px; font-size: 18px; }
.av-xl { width: 72px; height: 72px; font-size: 26px; letter-spacing: -0.02em; }

/* ── Stats grid ────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px; margin-bottom: 20px;
}
.stat-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px; padding: 14px 16px;
  box-shadow: var(--sh);
}
.stat-top {
  display: flex; align-items: flex-start;
  justify-content: space-between; margin-bottom: 8px;
}
.stat-label {
  font-family: var(--mono);
  font-size: 10px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-3);
}
.stat-icon {
  width: 28px; height: 28px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  background: var(--sage); color: var(--forest);
}
.stat-value {
  font-family: var(--serif);
  font-size: 26px; font-weight: 500;
  color: var(--ink); line-height: 1;
  letter-spacing: -0.025em;
}
.stat-value em { font-style: italic; color: var(--forest); }
.stat-delta { font-family: var(--mono); font-size: 11px; color: var(--forest-3); margin-top: 6px; }
.stat-neutral { color: var(--ink-3) !important; }

/* ── Tables ────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 10px 14px;
  text-align: left;
  font-family: var(--mono);
  font-size: 10px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-3); border-bottom: 1px solid var(--line-2);
  background: var(--paper-2); white-space: nowrap;
}
.data-table td {
  padding: 11px 14px; font-size: 13px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink-2);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--paper-2); }
.data-table tr.selected td { background: var(--sage); color: var(--forest); }
.data-table .donor-name {
  font-weight: 500; color: var(--ink);
}
.data-table .donor-name em {
  font-style: italic; font-family: var(--serif); color: var(--forest); font-weight: 500;
}
.data-table .num { font-family: var(--mono); color: var(--ink); }

[data-density="compact"] .data-table td { padding: 6px 12px; font-size: 12.5px; }
[data-density="compact"] .data-table th { padding: 7px 12px; }

/* ── Wealth bar ────────────────────────────────────────────────── */
.wbar {
  height: 3px; background: var(--cream-2);
  border-radius: 2px; margin-top: 4px; overflow: hidden;
}
.wbar-fill {
  height: 100%; border-radius: 2px;
  background: var(--forest);
}

/* ── Toggle switch ─────────────────────────────────────────────── */
.toggle {
  width: 38px; height: 22px;
  background: var(--cream-2); border-radius: 11px;
  position: relative; cursor: pointer;
  transition: background .2s; flex-shrink: 0;
  border: 1px solid var(--line);
}
.toggle.on { background: var(--forest); border-color: var(--forest); }
.toggle-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: white; transition: left .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.toggle.on .toggle-thumb { left: 19px; }
.toggle-row {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.toggle-row:last-child { border-bottom: none; padding-bottom: 0; }
.toggle-info .toggle-title { font-size: 13.5px; font-weight: 500; color: var(--ink); }
.toggle-info .toggle-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* ── Skeletons ─────────────────────────────────────────────────── */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--cream-2) 25%, var(--cream) 50%, var(--cream-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
.skel-line { height: 14px; margin-bottom: 8px; }
.skel-title { height: 22px; width: 60%; margin-bottom: 14px; }
.skel-stat { height: 70px; border-radius: 10px; }

/* ── Empty state ───────────────────────────────────────────────── */
.empty-state { padding: 56px 24px; text-align: center; }
.empty-icon {
  width: 56px; height: 56px; border-radius: 14px;
  background: var(--paper-2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  color: var(--ink-3);
}
.empty-title {
  font-family: var(--serif);
  font-size: 17px; font-weight: 500; color: var(--ink); margin-bottom: 6px;
  letter-spacing: -0.015em;
}
.empty-sub { font-size: 13.5px; color: var(--ink-3); }

/* ── Toast ─────────────────────────────────────────────────────── */
#dg-toast {
  position: fixed; bottom: 80px; right: 20px;
  background: var(--ink); color: var(--cream);
  padding: 12px 18px; border-radius: 10px;
  font-size: 13px; font-weight: 500;
  z-index: 999; max-width: 320px;
  transform: translateY(80px); opacity: 0;
  transition: all .3s ease;
  display: flex; align-items: center; gap: 8px;
  box-shadow: var(--sh-lg);
}
#dg-toast.show { transform: translateY(0); opacity: 1; }
#dg-toast.success { border-left: 3px solid var(--forest-3); }
#dg-toast.error   { border-left: 3px solid var(--clay); }
#dg-toast.info    { border-left: 3px solid var(--gold); }

/* ── Utility helpers used throughout new pages ─────────────────── */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; }
.gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; } .gap-24 { gap: 24px; }
.wrap { flex-wrap: wrap; }
.mute { color: var(--ink-3); }
.mute-2 { color: var(--ink-4); }
.divider {
  height: 1px; background: var(--line); margin: 16px 0;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .score-band { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: -250px; top: 0; bottom: 0;
    width: 240px; z-index: 150;
    transition: left .25s ease;
    padding-top: calc(var(--topbar-h) + 10px);
  }
  .sidebar.open { left: 0; box-shadow: 4px 0 24px rgba(20,22,14,0.18); }
  .ham-btn { display: flex; }
  .topbar-search { display: none; }
  .user-pill-name { display: none; }
  .main { padding: 16px; padding-bottom: calc(var(--bottom-nav-h) + 16px); }
  .bottom-nav { display: block; }
  .page-title { font-size: 22px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .score-band { grid-template-columns: 1fr 1fr; gap: 16px; padding: 14px; }
  .score-cell + .score-cell { border-left: none; padding-left: 0; }
  .hide-mobile { display: none !important; }
  .field-row { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; gap: 8px; }
}
@media (max-width: 480px) {
  .main { padding: 12px; padding-bottom: calc(var(--bottom-nav-h) + 12px); }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-value { font-size: 22px; }
  .page-title { font-size: 20px; }
  #dg-toast { bottom: 70px; right: 10px; left: 10px; }
}

/* ── Loading overlay (preserved from v8) ───────────────────────── */
.page-loading {
  position: fixed; inset: 0;
  background: var(--cream);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.3s ease-out;
}
.page-loading.fade-out { opacity: 0; pointer-events: none; }
.page-loading-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--line-2);
  border-top-color: var(--forest);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
