/* Mouse House — mobile-first design system */
:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #f0f1f8;
  --border: #e4e6f0;
  --text: #1b1d29;
  --text-soft: #5c6178;
  --text-faint: #9296ad;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef0ff;
  --pink: #ec4899;
  --blue: #3b82f6;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(24, 26, 48, .06), 0 6px 20px rgba(24, 26, 48, .05);
  --shadow-lg: 0 12px 40px rgba(24, 26, 48, .18);
  --nav-h: 64px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14151d;
    --surface: #1e2030;
    --surface-2: #262a3d;
    --border: #313550;
    --text: #eceef7;
    --text-soft: #a6abc4;
    --text-faint: #737893;
    --primary-soft: #262a52;
    --shadow: 0 1px 3px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scrollbar-gutter: stable; }
html, body { height: 100%; }
html.modal-open, html.modal-open body { overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 16px; } /* 16px prevents iOS zoom */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 11px 16px; font-size: 15px; font-weight: 600; color: #fff;
  background: var(--primary); transition: transform .05s, background .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.ghost { background: transparent; color: var(--text-soft); }
.btn.danger { background: var(--red); }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }

/* ---------- Auth ---------- */
.auth-wrap {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px; padding-bottom: calc(24px + env(safe-area-inset-bottom));
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border-radius: 20px; box-shadow: var(--shadow); padding: 28px 24px;
  border: 1px solid var(--border);
}
.auth-logo { font-size: 44px; text-align: center; }
.auth-card h1 { text-align: center; font-size: 22px; margin: 6px 0 2px; }
.auth-card .sub { text-align: center; color: var(--text-soft); margin-bottom: 22px; font-size: 14px; }
.seg {
  display: flex; background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 4px; margin-bottom: 18px;
}
.seg button {
  flex: 1; border: none; background: transparent; padding: 9px; border-radius: 8px;
  font-weight: 600; color: var(--text-soft); font-size: 14px;
}
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
}
.field textarea { min-height: 78px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
/* Searchable combobox (sire/dam pickers) */
.combo { position: relative; }
.combo-input { width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: 16px; }
.combo-input:focus { outline: none; border-color: var(--primary); }
.combo-list { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30; max-height: 240px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }
.combo-item { padding: 11px 13px; cursor: pointer; font-size: 15px; }
.combo-item:not(:last-child) { border-bottom: 1px solid var(--border); }
.combo-item:hover { background: var(--primary-soft); }
.combo-empty { padding: 11px 13px; color: var(--text-faint); font-size: 14px; }
.form-error { background: #fde8e8; color: var(--red); padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 14px; }
@media (prefers-color-scheme: dark) { .form-error { background: #3a1b1b; } }

/* ---------- App shell ---------- */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 12px;
}
.topbar .brand { font-weight: 800; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.topbar .lab-name { color: var(--text-faint); font-weight: 600; font-size: 13px; }
.topbar .spacer { flex: 1; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}

.main { flex: 1; padding: 16px; padding-bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); max-width: 1100px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.page-head h2 { font-size: 21px; }
.page-head .count { color: var(--text-faint); font-weight: 600; font-size: 14px; }

/* ---------- Bottom nav (mobile) ---------- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; padding-bottom: env(safe-area-inset-bottom);
  overflow-x: auto; scrollbar-width: none;
}
.bottomnav::-webkit-scrollbar { display: none; }
.bottomnav button {
  flex: 1 0 auto; min-width: 64px; border: none; background: none;
  padding: 8px 6px 6px; height: var(--nav-h);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-faint); font-size: 10.5px; font-weight: 600;
}
.bottomnav button .ic { font-size: 20px; line-height: 1; }
.bottomnav button.active { color: var(--primary); }

/* ---------- Cards / lists ---------- */
.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .grid.two { grid-template-columns: 1fr 1fr; } }
@media (min-width: 720px) { .grid.three { grid-template-columns: repeat(3, 1fr); } }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
}
.card.tap { cursor: pointer; transition: transform .06s, box-shadow .15s; }
.card.tap:active { transform: scale(.995); }

.list-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 13px 14px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px; cursor: pointer;
}
.list-item:active { background: var(--surface-2); }
.li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 7px; }
.li-sub { color: var(--text-soft); font-size: 13px; margin-top: 2px; }
.li-icon {
  width: 42px; height: 42px; border-radius: 11px; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0;
}
.stack { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Stat tiles ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
@media (min-width: 620px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
.stat .n { font-size: 26px; font-weight: 800; line-height: 1.1; }
.stat .l { color: var(--text); font-size: 16px; font-weight: 800; margin-top: 2px; text-transform: capitalize; }
.stat .ic { font-size: 18px; }

/* ---------- Badges / chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-soft);
}
.badge.male { background: #e0edff; color: #1d4ed8; }
.badge.female { background: #ffe3f1; color: #be185d; }
/* Sex badges hold a single ♂/♀ glyph — center it explicitly (iOS glyph metrics are unreliable) */
.badge.male, .badge.female { justify-content: center; min-width: 24px; line-height: 1; padding: 3.5px 8px; }
.badge.green { background: #dcfce7; color: #15803d; }
.badge.amber { background: #fef3c7; color: #b45309; }
.badge.red { background: #fee2e2; color: #b91c1c; }
.badge.gray { background: var(--surface-2); color: var(--text-soft); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }
@media (prefers-color-scheme: dark) {
  .badge.male { background: #1e3a5f; color: #93c5fd; }
  .badge.female { background: #4a1d38; color: #f9a8d4; }
  .badge.green { background: #14432a; color: #86efac; }
  .badge.amber { background: #422f0b; color: #fcd34d; }
  .badge.red { background: #4a1d1d; color: #fca5a5; }
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Search / filter bar ---------- */
.toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input, .toolbar select {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 14px;
}
.toolbar input.search { flex: 1; min-width: 140px; }

/* ---------- Modal / sheet ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(15,17,34,.5);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease;
}
@media (min-width: 640px) { .modal-overlay { align-items: center; padding: 24px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes slideup { from { transform: translateY(30px); opacity: .6; } }
.modal {
  background: var(--surface); width: 100%; max-width: 520px;
  border-radius: 20px 20px 0 0; box-shadow: var(--shadow-lg);
  max-height: 92dvh; display: flex; flex-direction: column; animation: slideup .2s ease;
}
@media (min-width: 640px) { .modal { border-radius: 20px; max-height: 88dvh; } }
.modal-head {
  padding: 16px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; position: sticky; top: 0;
}
.modal-head h3 { font-size: 18px; flex: 1; }
.modal-head .x { border: none; background: var(--surface-2); width: 32px; height: 32px; border-radius: 50%; font-size: 18px; color: var(--text-soft); }
.modal-head .back { border: none; background: var(--surface-2); width: 32px; height: 32px; border-radius: 50%; font-size: 18px; color: var(--text-soft); flex-shrink: 0; }
.modal-body { padding: 18px; overflow-y: auto; overflow-x: hidden; }
.modal-foot { padding: 14px 18px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); display: flex; gap: 10px; }
.modal-foot .btn { flex: 1; }

/* ---------- Detail rows ---------- */
.detail-row { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.detail-row:last-child { border-bottom: none; }
.detail-row .k { color: var(--text-soft); font-size: 13px; flex-shrink: 0; }
.detail-row .v { font-weight: 600; text-align: right; min-width: 0; overflow-wrap: anywhere; }
/* Tiny "→" jump-to-referenced-entity button in detail rows */
.navlink { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; padding: 0; margin-left: 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--primary); font-size: 13px; line-height: 1; cursor: pointer; vertical-align: middle; }
.navlink:hover { background: var(--primary-soft); border-color: var(--primary); }
.section-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); margin: 18px 0 8px; }

/* ---------- Data table (scrolls horizontally on narrow screens) ---------- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { text-align: left; padding: 8px 10px; white-space: nowrap; border-bottom: 1px solid var(--border); }
table.tbl th { color: var(--text-soft); font-weight: 700; background: var(--surface-2); }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr { cursor: pointer; }
table.tbl tbody tr:active { background: var(--surface-2); }
table.tbl select, table.tbl input { padding: 5px 6px; font-size: 15px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); min-width: 62px; }
table.tbl tbody tr.apply-row { cursor: default; background: var(--primary-soft); }
table.tbl tbody tr.apply-row td { font-weight: 600; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 44px 20px; color: var(--text-soft); }
.empty .ic { font-size: 46px; opacity: .6; }
.empty p { margin-top: 10px; }

/* ---------- Genotype editor ---------- */
.geno-row { display: flex; gap: 8px; margin-bottom: 8px; }
.geno-row select { flex: 1; }
.geno-row .x { flex-shrink: 0; width: 40px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm); color: var(--red); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 90;
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); animation: slideup .2s ease;
}

/* ---------- Desktop: sidebar layout ---------- */
@media (min-width: 900px) {
  .bottomnav {
    position: fixed; top: 0; bottom: 0; left: 0; right: auto; width: 210px;
    flex-direction: column; border-top: none; border-right: 1px solid var(--border);
    padding-top: 70px; overflow-y: auto;
  }
  .bottomnav button {
    flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 12px;
    height: auto; padding: 12px 20px; font-size: 14px; min-width: 0;
  }
  .bottomnav button .ic { font-size: 18px; }
  .bottomnav button.active { background: var(--primary-soft); }
  .topbar { padding-left: 20px; }
  .shell { padding-left: 210px; }
  .topbar { position: sticky; }
  .main { padding: 24px; }
}

.spinner { width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.muted { color: var(--text-faint); }
.fab-hidden { display: none; }

/* Toggle switches (litter tagged / weaned) */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); margin-top: 10px; }
.switch-row .switch-label { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); }
.switch-row .switch-state { font-size: 13px; color: var(--text-faint); font-weight: 500; }
.switch { position: relative; flex: none; width: 46px; height: 26px; border-radius: 999px; background: var(--border); border: none; padding: 0; cursor: pointer; transition: background .18s ease; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s ease; }
.switch.on { background: var(--primary); }
.switch.on::after { transform: translateX(20px); }
.switch:disabled { opacity: .5; cursor: default; }

/* Calendar (litter tagging/weaning due dates) — kept short so the due list below stays visible */
.cal-head { display: flex; align-items: center; gap: 8px; margin: 10px 0 8px; }
.cal-title { flex: 1; text-align: center; font-weight: 700; font-size: 15px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-bottom: 4px; }
.cal-dow { text-align: center; font-size: 10px; color: var(--text-faint); font-weight: 700; padding: 2px 0; }
.cal-day { height: 44px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border);
  position: relative; cursor: pointer; min-width: 0; }
.cal-day.blank { background: transparent; border: none; cursor: default; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-day.sel { background: var(--primary-soft); border-color: var(--primary); }
.cal-day .d { position: absolute; top: 2px; right: 4px; font-size: 10px; font-weight: 600; color: var(--text-soft); line-height: 1; }
.cal-day .marks { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); font-size: 10px; line-height: 1; letter-spacing: -2px; }

/* Active-filter indicator dot on the litters "Filter by" button */
.filter-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); vertical-align: middle; margin-left: 5px; }

/* "N tasks" sub-count under the Calendar tile label on the home page */
.stat .cal-count { font-size: 13px; color: var(--text-faint); font-weight: 600; margin-top: 2px; }

/* Overdue tagging/weaning alert next to litter badges */
.overdue { font-size: 13px; line-height: 1; vertical-align: middle; }

/* ---------- Bulk select & edit ---------- */
/* Selected rows/cards get a primary outline + tint. */
.list-item.selectable, .card.tap.selectable { position: relative; }
.list-item.selected, .card.selected {
  outline: 2px solid var(--primary); outline-offset: -2px;
  background: var(--primary-soft);
}
/* Floating action bar shown while selecting; on mobile it sits just above the
   bottom nav, on desktop it sits at the very bottom, right of the sidebar. */
.bulk-bar {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  z-index: 40; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 16px; flex-wrap: wrap;
  background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -6px 20px rgba(24, 26, 48, .08);
}
.sel-all-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; }
@media (min-width: 900px) { .bulk-bar { bottom: 0; left: 210px; } }
.bulk-bar .sel-count { font-weight: 700; font-size: 15px; }
.bulk-left { display: flex; gap: 12px; align-items: center; }
.bulk-actions { display: flex; gap: 8px; align-items: center; }
/* Header action group (holds the Select toggle + the "+ Add" button) */
.head-actions { display: flex; gap: 8px; align-items: center; flex: none; }
/* "Show all" toggle at the top of a Filter by sheet */
.filter-showall { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); font-weight: 600; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.filter-showall input { width: 16px; height: 16px; }
/* Compact "My recent activity" rows: icon · summary · time · undo */
.act-list { display: flex; flex-direction: column; gap: 6px; }
.act-row {
  display: flex; align-items: center; gap: 9px; font-size: 13px;
  padding: 7px 10px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.act-ic { flex: none; font-size: 14px; line-height: 1; }
.act-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.act-time { flex: none; color: var(--text-faint); font-size: 12px; white-space: nowrap; }
.act-undo {
  flex: none; width: 28px; height: 28px; padding: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-soft); font-size: 14px; line-height: 1;
}
.act-undo:hover { background: var(--surface-2); color: var(--text); }

/* A checkbox filter row inside a Filter by sheet (e.g. "only live mice") */
.filter-check { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); font-weight: 600; margin-bottom: 14px; }
.filter-check input { width: 16px; height: 16px; }

/* Corner avatar dropdown (Settings / Log out) */
.user-menu {
  position: fixed; z-index: 80; min-width: 224px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.user-menu .um-head { display: flex; gap: 10px; align-items: center; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.user-menu .um-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu .um-email { font-size: 12px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu .um-item { display: block; width: 100%; text-align: left; background: none; border: none; padding: 11px 12px; border-radius: var(--radius-sm); font-size: 14px; color: var(--text); cursor: pointer; }
.user-menu .um-item:hover { background: var(--surface-2); }
#avatarBtn { cursor: pointer; }

/* "Or apply to all N…" retire/delete actions inside the Bulk edit sheet */
.bulk-more { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.bulk-more-actions { display: flex; gap: 8px; margin-top: 10px; }
/* Bulk-edit sheet: a field is a checkbox toggle above its control. */
.bulk-field .bulk-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); }
.bulk-field .bulk-toggle input { width: 16px; height: 16px; }
.bulk-field select[disabled], .bulk-field input[disabled] { opacity: .45; }

/* Genotype chips (Wean flow) — each unique genotype gets its own hue via --gh */
.geno-chip { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: hsl(var(--gh) 70% 50% / .15); color: hsl(var(--gh) 55% 38%); border: 1px solid hsl(var(--gh) 65% 50% / .45); }
@media (prefers-color-scheme: dark) {
  .geno-chip { background: hsl(var(--gh) 70% 55% / .22); color: hsl(var(--gh) 75% 74%); border-color: hsl(var(--gh) 70% 55% / .5); }
}

/* ---------- Setup wizard ---------- */
.wizard-overlay {
  position: fixed; inset: 0; z-index: 70; background: rgba(15,17,34,.55);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease;
}
@media (min-width: 640px) { .wizard-overlay { align-items: center; padding: 24px; } }
.wizard-card {
  background: var(--surface); width: 100%; max-width: 620px;
  border-radius: 20px 20px 0 0; box-shadow: var(--shadow-lg);
  max-height: 94dvh; display: flex; flex-direction: column; animation: slideup .2s ease;
}
@media (min-width: 640px) { .wizard-card { border-radius: 20px; max-height: 90dvh; } }
.wizard-head {
  padding: 16px 18px 12px; display: flex; align-items: flex-start; gap: 10px;
  border-bottom: 1px solid var(--border);
}
.wizard-title { flex: 1; min-width: 0; }
.wizard-title .wt-name { font-size: 18px; font-weight: 800; }
.wizard-title .wt-sub { font-size: 13px; color: var(--text-soft); margin-top: 2px; }
.wizard-head .x { border: none; background: var(--surface-2); width: 32px; height: 32px; border-radius: 50%; font-size: 18px; color: var(--text-soft); flex-shrink: 0; }

.wizard-steps { display: flex; gap: 6px; padding: 12px 18px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.wstep { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-faint); white-space: nowrap; }
.wstep .wdot {
  width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--text-soft); flex-shrink: 0;
}
.wstep.active .wdot { background: var(--primary); color: #fff; }
.wstep.done .wdot { background: var(--green); color: #fff; }
.wstep.active .wlbl { color: var(--text); font-weight: 700; }

.wizard-body { padding: 18px; overflow-y: auto; overflow-x: hidden; flex: 1; }
.wizard-foot { padding: 14px 18px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); display: flex; gap: 10px; }
.wizard-foot .btn { flex: 1; }
.wiz-form .field { margin-bottom: 14px; }

/* source picker */
.wiz-sources { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.wiz-src {
  flex: 1; min-width: 96px; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text-soft); font-weight: 700; font-size: 14px;
}
.wiz-src.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.wiz-note {
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; margin: 10px 0;
}
@media (prefers-color-scheme: dark) { .wiz-note { background: #3a2a12; border-color: #6b4a1f; color: #f5c98a; } }

/* per-entity uploader */
.wiz-entity { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 12px; }
.wiz-entity-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wiz-file { position: relative; overflow: hidden; }
.wiz-filename { font-size: 13px; color: var(--text-soft); margin-top: 8px; }

.wiz-map { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 10px; }
.wiz-map-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; align-items: center; padding: 4px 0; }
.wiz-map-row label { font-size: 13px; color: var(--text-soft); overflow-wrap: anywhere; }
.wiz-map-row select { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.wiz-req { color: var(--red); font-weight: 800; }
.wiz-reftag { display: inline-block; font-size: 11px; color: var(--primary); background: var(--primary-soft); border-radius: 6px; padding: 0 6px; font-weight: 700; }

/* report + stats */
.wiz-report { margin-top: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; background: var(--surface-2); }
.wiz-report-head { font-weight: 800; margin-bottom: 10px; }
.wiz-stats { display: flex; flex-wrap: wrap; gap: 10px; }
.wiz-stat { flex: 1; min-width: 74px; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 8px; }
.wiz-stat .n { font-size: 22px; font-weight: 800; color: var(--primary); line-height: 1.1; }
.wiz-stat .l { font-size: 11px; color: var(--text-soft); text-transform: uppercase; letter-spacing: .03em; margin-top: 2px; }
.wiz-warns { margin-top: 10px; font-size: 13px; }
.wiz-warns summary { cursor: pointer; color: var(--amber); font-weight: 700; }
.wiz-warns ul { margin: 8px 0 0 18px; color: var(--text-soft); max-height: 160px; overflow-y: auto; }

.wiz-done { text-align: center; padding: 16px 0; }
.wiz-done-ic { font-size: 46px; }
.wiz-done-h { font-size: 20px; font-weight: 800; margin: 8px 0 4px; }
.wiz-error { margin-bottom: 14px; }

@media (max-width: 480px) { .wiz-map-row { grid-template-columns: 1fr; gap: 3px; } }
