/* ============================================================
   BirdMetrics — Stylesheet
   Thema: Modern Scandinavisch, wit met geel accent
   ============================================================ */

:root {
  /* Colors */
  --bg: #FFFFFF;
  --surface: #F7F7F7;
  --surface-2: #FAFAFA;
  --ink: #0A0A0A;
  --muted: #737373;
  --border: #E5E5E5;
  --accent: #F4B73B;
  --accent-hover: #E5A828;
  --accent-ink: #2A1F08;
  --success: #22C55E;
  --warn: #F59E0B;
  --danger: #DC2626;
  --danger-soft: #FEF2F2;

  /* Layout */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.08);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Sidebar */
  --sidebar-w: 240px;
}

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

/* hidden attribuut moet altijd display:none winnen, ook bij elementen met display:flex/grid */
[hidden] { display: none !important; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  background: transparent;
  color: var(--ink);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--ink);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface); }

.btn-block { width: 100%; }

/* ============================================================
   Form fields
   ============================================================ */

.field {
  display: block;
  margin-bottom: var(--space-md);
}
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  background: var(--bg);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(244,183,59,0.15);
}
.field-hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--space-md);
  font-size: 14px;
  cursor: pointer;
}
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.form-error {
  margin-top: var(--space-md);
  padding: 10px 14px;
  background: var(--danger-soft);
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 13px;
}

/* ============================================================
   Auth view
   ============================================================ */

.auth-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl) var(--space-md);
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow);
}

.auth-brand {
  text-align: center;
  margin-bottom: var(--space-lg);
}
.auth-brand img { margin: 0 auto var(--space-md); }
.auth-brand h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.auth-tagline {
  font-size: 13px;
  color: var(--muted);
}

.auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border);
}
.auth-tab {
  flex: 1;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.auth-tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.auth-form { display: none; }
.auth-form.is-active { display: block; }

.auth-foot {
  margin-top: var(--space-xl);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* ============================================================
   App view (shell)
   ============================================================ */

.app-view {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--space-lg) var(--space-md);
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 var(--space-sm);
  margin-bottom: var(--space-xl);
}
.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.3px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px var(--space-md);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.is-active {
  background: var(--bg);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow);
}
.nav-link svg { flex-shrink: 0; }

.sidebar-foot {
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}
.user-chip {
  font-size: 12px;
  color: var(--muted);
  padding: 0 var(--space-sm) var(--space-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  gap: var(--space-md);
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.topbar-logo { display: none; flex-shrink: 0; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}
.topbar-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-meta {
  font-size: 13px;
  color: var(--muted);
}

.icon-btn {
  display: none;
  width: 40px; height: 40px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--surface); }

.page {
  padding: var(--space-xl) var(--space-lg);
  flex: 1;
}

/* ============================================================
   Bottom nav (mobile only)
   ============================================================ */
.bottom-nav { display: none; }
.bottom-nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  text-decoration: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  flex: 1;
  min-width: 0;
  transition: color 0.15s;
}
.bottom-nav-link svg { flex-shrink: 0; }
.bottom-nav-link.is-active {
  color: var(--accent-ink);
}
.bottom-nav-link.is-active svg {
  stroke: var(--accent-ink);
}
.bottom-nav-link.is-active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: var(--accent);
  border-radius: 0 0 99px 99px;
}

.empty-state {
  max-width: 480px;
  margin: 60px auto;
  text-align: center;
}
.empty-state h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.3px;
}
.empty-state p {
  color: var(--muted);
  font-size: 14px;
}

/* ============================================================
   Toast
   ============================================================ */

.toast {
  position: fixed;
  bottom: var(--space-lg);
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 18px;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  animation: toast-in 0.2s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============================================================
   Mobile — bottom nav layout
   ============================================================ */

@media (max-width: 768px) {
  .app-view {
    grid-template-columns: 1fr;
  }
  /* Sidebar volledig verbergen op mobiel */
  .sidebar {
    display: none;
  }
  /* Topbar wordt header met logo + uitlog */
  .topbar {
    padding: var(--space-md);
    position: sticky;
    top: 0;
    z-index: 10;
  }
  .topbar-logo { display: block; }
  .topbar-title { font-size: 17px; }
  .topbar-meta { display: none; }
  .icon-btn { display: flex; }

  .page {
    padding: var(--space-lg) var(--space-md);
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }

  /* Bottom nav verschijnt */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding: 4px 0;
    padding-bottom: calc(4px + env(safe-area-inset-bottom));
    z-index: 50;
  }
  .bottom-nav-link {
    position: relative;
  }

  .auth-card { padding: var(--space-lg); }
  .auth-brand h1 { font-size: 22px; }
  /* Voorkom iOS auto-zoom op input focus */
  .field input, .field select, .field textarea { font-size: 16px; }
}

@media (max-width: 480px) {
  .topbar { padding: 12px var(--space-md); }
  .auth-card { padding: var(--space-md); }
}

/* ============================================================
   FASE 2 — KWEEK
   ============================================================ */

.muted-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.kweek-filters {
  flex: 1;
}

/* Pair grid + cards */
.pair-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: var(--space-md);
}
.pair-card {
  display: block;
  padding: var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.pair-card:hover {
  background: var(--bg);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.pair-couple-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  gap: 12px;
  align-items: center;
  margin-bottom: var(--space-md);
}
.couple-side {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.couple-thumb {
  width: 48px; height: 48px;
  border-radius: 50%;
  overflow: hidden;
  background: #DBEAFE;
  display: flex; align-items: center; justify-content: center;
  color: #1E40AF;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}
.couple-thumb-f { background: #FCE7F3; color: #9F1239; }
.couple-thumb img { width: 100%; height: 100%; object-fit: cover; }
.couple-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.couple-x {
  color: var(--muted);
  font-size: 18px;
  font-weight: 300;
}

/* Status pill */
.pair-status {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 99px;
  white-space: nowrap;
}
.pair-status-active { background: var(--surface-2); color: var(--muted); }
.pair-status-warn { background: #FEF3C7; color: #92400E; }
.pair-status-success { background: #D1FAE5; color: #065F46; }
.pair-status-inactive { background: var(--surface-2); color: var(--muted); opacity: 0.7; }

/* Nest summary inside pair-card */
.nest-summary {
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}
.nest-summary-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}

/* Egg row */
.egg-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.egg-row-mini { gap: 4px; }

.egg {
  width: 22px; height: 28px;
  border-radius: 50% 50% 45% 45% / 60% 60% 40% 40%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  flex-shrink: 0;
  user-select: none;
}
.egg-lg {
  width: 36px; height: 44px;
  font-size: 16px;
  cursor: pointer;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: transform 0.1s;
}
.egg-lg:hover { transform: scale(1.08); }
.egg-lg.egg-promoted::after {
  content: '★';
  position: absolute;
  margin-top: -28px; margin-left: 16px;
  color: var(--accent);
  font-size: 12px;
}

.egg-gelegd { background: var(--surface-2); color: var(--muted); }
.egg-bevrucht { background: #FEF3C7; color: #92400E; border-color: #FCD34D; }
.egg-uitgekomen { background: #D1FAE5; color: #065F46; border-color: #6EE7B7; }
.egg-dood { background: var(--danger-soft); color: var(--danger); border-color: #FECACA; opacity: 0.7; }
.egg-onbekend { background: var(--surface); border-style: dashed; }

.egg-add {
  width: 36px; height: 44px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}
.egg-add:hover { border-color: var(--accent); color: var(--accent-ink); }

/* Pair detail hero */
.pair-hero {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--space-md);
  align-items: center;
  padding: var(--space-lg);
  background: var(--surface);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-md);
}
.pair-hero-bird {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}
.pair-hero-photo {
  width: 100px; height: 100px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg);
  margin-bottom: var(--space-sm);
  display: flex; align-items: center; justify-content: center;
}
.pair-hero-photo img { width: 100%; height: 100%; object-fit: cover; }
.pair-hero-photo .big-icon { font-size: 40px; color: var(--muted); }
.pair-hero-name {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.2px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pair-hero-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.pair-hero-x {
  font-size: 28px;
  color: var(--muted);
  font-weight: 300;
}

.pair-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  align-items: center;
  margin-bottom: var(--space-md);
}

.pair-notes {
  padding: var(--space-md);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: var(--space-lg);
  white-space: pre-wrap;
}

/* Nest block */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: var(--space-xl) 0 var(--space-md);
}
.section-head h3 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.nest-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}
.nest-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}
.nest-head h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}
.nest-sub {
  font-size: 12px;
  color: var(--muted);
}
.nest-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}
.nest-notes {
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  white-space: pre-wrap;
}

.empty-state-sm {
  padding: var(--space-lg);
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

.info-box {
  padding: 10px 14px;
  background: #FEF3C7;
  border: 1px solid #FCD34D;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #78350F;
  margin: var(--space-md) 0;
}
.info-box-warn { background: var(--danger-soft); border-color: #FECACA; color: var(--danger); }

/* Status picker grid in egg menu */
.status-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.status-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
}
.status-btn:hover { background: var(--bg); border-color: var(--accent); }
.status-btn.is-active {
  background: var(--bg);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(244,183,59,0.2);
}
.status-btn .egg { width: 28px; height: 36px; font-size: 14px; }

.modal-sm { max-width: 460px; }

.kv-tight {
  margin-bottom: var(--space-sm);
  gap: 6px 14px;
  font-size: 13px;
}

/* ============================================================
   FASE 4 — STAMBOOM + COI
   ============================================================ */

.detail-subsection-h {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: var(--space-lg) 0 var(--space-md);
}

.coi-box {
  padding: var(--space-md);
  border-radius: var(--radius);
  margin-bottom: var(--space-md);
  border: 1px solid var(--border);
  background: var(--surface);
}
.coi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 600;
}
.coi-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin: 4px 0 2px;
}
.coi-desc {
  font-size: 12px;
  color: var(--muted);
}
.coi-none .coi-value { color: var(--muted); }
.coi-low { background: #ECFDF5; border-color: #6EE7B7; }
.coi-low .coi-value { color: #065F46; }
.coi-low .coi-desc { color: #047857; }
.coi-mid { background: #FEF3C7; border-color: #FCD34D; }
.coi-mid .coi-value { color: #92400E; }
.coi-mid .coi-desc { color: #B45309; }
.coi-high { background: #FED7AA; border-color: #FB923C; }
.coi-high .coi-value { color: #9A3412; }
.coi-high .coi-desc { color: #C2410C; }
.coi-critical { background: var(--danger-soft); border-color: #FCA5A5; }
.coi-critical .coi-value { color: var(--danger); }
.coi-critical .coi-desc { color: var(--danger); }

/* Pedigree tree — 4 cols × 3 rows grid */
.pedigree {
  display: grid;
  gap: 6px;
  margin-bottom: var(--space-md);
}
.pedigree-row { display: grid; gap: 6px; }
.pedigree-gen-2 { grid-template-columns: repeat(4, 1fr); }
.pedigree-gen-1 { grid-template-columns: repeat(2, 1fr); }
.pedigree-gen-0 { grid-template-columns: 1fr; max-width: 50%; margin: 0 auto; }

.tree-cell {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  text-decoration: none;
  color: inherit;
  min-height: 56px;
  transition: background 0.15s, border-color 0.15s;
}
.tree-cell:hover { background: var(--bg); border-color: var(--accent); }
.tree-cell-empty {
  background: transparent;
  border-style: dashed;
  opacity: 0.6;
}
.tree-cell-self {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.tree-cell .role {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
}
.tree-cell-self .role { color: rgba(42,31,8,0.7); }
.tree-cell .tree-name {
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tree-cell .tree-ring {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--muted);
  margin-top: 2px;
}
.tree-cell-self .tree-ring { color: rgba(42,31,8,0.7); }

/* Relatives chips */
.relatives-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
  margin-bottom: var(--space-md);
}
.relative-chip {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.relative-chip:hover { background: var(--bg); border-color: var(--accent); }
.relative-thumb {
  width: 40px; height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.relative-thumb img { width: 100%; height: 100%; object-fit: cover; }
.relative-info { min-width: 0; }
.relative-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.relative-meta {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.relative-sex {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}

/* Mobile tweaks */
@media (max-width: 600px) {
  .pair-grid { grid-template-columns: 1fr; }
  .pair-couple-row {
    grid-template-columns: 1fr auto 1fr;
    grid-template-rows: auto auto;
    gap: 8px;
  }
  .pair-status {
    grid-column: 1 / -1;
    justify-self: start;
  }
  .couple-thumb { width: 40px; height: 40px; font-size: 16px; }
  .couple-name { font-size: 13px; }

  .pair-hero { padding: var(--space-md); }
  .pair-hero-photo { width: 80px; height: 80px; }
  .pair-hero-photo .big-icon { font-size: 32px; }
  .pair-hero-name { font-size: 14px; }
  .pair-hero-x { font-size: 22px; }

  .egg-lg { width: 40px; height: 48px; font-size: 18px; }
  .egg-add { width: 40px; height: 48px; }

  .status-grid { grid-template-columns: 1fr 1fr; }

  .section-head { flex-direction: column; align-items: stretch; gap: 8px; }
  .section-head .btn { width: 100%; }

  /* Pedigree mobile — 2 cols voor grootouders */
  .pedigree-gen-2 { grid-template-columns: repeat(2, 1fr); }
  .pedigree-gen-1 { grid-template-columns: repeat(2, 1fr); }
  .pedigree-gen-0 { max-width: 80%; }
  .tree-cell { padding: 6px 8px; min-height: 50px; }
  .tree-cell .role { font-size: 8px; }
  .tree-cell .tree-name { font-size: 11px; }
  .tree-cell .tree-ring { font-size: 8px; }

  .coi-value { font-size: 26px; }
  .relatives-list { grid-template-columns: 1fr; }
}

/* ============================================================
   List header (zoek + actie)
   ============================================================ */
.list-header {
  display: flex;
  gap: var(--space-md);
  align-items: center;
  margin-bottom: var(--space-lg);
}
.search-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--ink);
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(244,183,59,0.15);
}

/* ============================================================
   Vogel grid + kaarten
   ============================================================ */
.bird-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-md);
}
.bird-card {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  align-items: center;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.bird-card:hover {
  background: var(--bg);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.bird-photo {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
}
.bird-photo img { width: 100%; height: 100%; object-fit: cover; }
.bird-photo-empty {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
}
.bird-info { min-width: 0; }
.bird-name {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bird-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bird-ring {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-ink);
  background: rgba(244,183,59,0.18);
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  margin-top: 4px;
}
.bird-sex-badge {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  flex-shrink: 0;
}
.sex-m { background: #DBEAFE; color: #1E40AF; }
.sex-f { background: #FCE7F3; color: #9F1239; }
.sex-u { background: var(--surface-2); color: var(--muted); }

/* ============================================================
   Modal
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  animation: fadeIn 0.15s;
}
.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 32px);
  max-width: 600px;
  max-height: calc(100vh - 64px);
  background: var(--bg);
  border-radius: var(--radius-lg);
  z-index: 101;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.15s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: translate(-50%, -50%) scale(0.96); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
.modal-close {
  background: transparent;
  border: none;
  font-size: 28px;
  color: var(--muted);
  cursor: pointer;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.modal-close:hover { background: var(--surface); color: var(--ink); }
.modal-body {
  padding: var(--space-lg);
  overflow-y: auto;
  flex: 1;
}
.modal-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #FECACA;
}
.btn-danger:hover:not(:disabled) {
  background: #FEE2E2;
  border-color: #FCA5A5;
}
.modal-actions .btn-danger {
  margin-right: auto;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

/* Ringnummer input + auto-knop */
.ring-input-row {
  display: flex;
  gap: 8px;
}
.ring-input-row input { flex: 1; font-family: var(--font-mono); font-size: 14px; }

/* Photo upload */
.photo-upload {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: var(--space-md);
}
.photo-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: var(--space-sm);
}
.photo-preview:empty { margin-top: 0; }
.photo-thumb {
  position: relative;
  width: 80px; height: 80px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-remove {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(0,0,0,0.7);
  color: white;
  border: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.photo-remove:hover { background: rgba(0,0,0,0.9); }

/* ============================================================
   Detail page
   ============================================================ */
.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  gap: var(--space-md);
}
.back-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.15s;
}
.back-link:hover { color: var(--ink); }

.detail-photo-hero {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-lg);
  max-height: 480px;
}
.detail-photo-hero img {
  width: 100%; height: 100%; object-fit: cover;
  cursor: zoom-in;
}
.detail-photo-empty {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 80px;
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
}

.detail-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.detail-sub {
  color: var(--muted);
  font-size: 15px;
  margin-bottom: var(--space-lg);
}

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 24px;
  font-size: 14px;
  margin-bottom: var(--space-xl);
  align-items: baseline;
}
.kv .k { color: var(--muted); font-weight: 500; }
.kv .v { color: var(--ink); }
.kv .v code {
  font-family: var(--font-mono);
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--accent-ink);
}

.detail-section {
  font-size: 16px;
  font-weight: 600;
  margin: var(--space-lg) 0 var(--space-md);
  letter-spacing: -0.2px;
}
.photo-stack {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.photo-stack img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  cursor: zoom-in;
  transition: transform 0.1s;
}
.photo-stack img:hover { transform: scale(1.02); }

/* ============================================================
   Lightbox
   ============================================================ */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 102;
  display: flex; align-items: center; justify-content: center;
}
.lightbox img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  user-select: none;
}
.lightbox-counter {
  position: absolute;
  bottom: 24px;
  left: 50%; transform: translateX(-50%);
  background: rgba(255,255,255,0.15);
  color: white;
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 13px;
  backdrop-filter: blur(8px);
}
.lightbox-close,
.lightbox-nav {
  position: absolute;
  background: rgba(255,255,255,0.1);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px);
  transition: background 0.15s;
}
.lightbox-close {
  top: 24px; right: 24px;
  width: 44px; height: 44px;
  font-size: 24px;
  line-height: 1;
}
.lightbox-nav {
  top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px;
  font-size: 28px;
  line-height: 1;
}
.lightbox-prev { left: 24px; }
.lightbox-next { right: 24px; }
.lightbox-close:hover, .lightbox-nav:hover { background: rgba(255,255,255,0.2); }

/* ============================================================
   Mobile responsive
   ============================================================ */
@media (max-width: 600px) {
  .form-grid-2 { grid-template-columns: 1fr; }
  .bird-grid { grid-template-columns: 1fr; gap: 10px; }
  .bird-card {
    grid-template-columns: 64px 1fr auto;
    gap: 10px;
    padding: 10px;
  }
  .bird-photo { width: 64px; height: 64px; }
  .bird-photo-empty { font-size: 24px; }
  .bird-name { font-size: 14px; }
  .bird-sub { font-size: 11px; }
  .bird-ring { font-size: 10px; padding: 1px 5px; }

  .list-header { flex-direction: column; align-items: stretch; gap: var(--space-sm); }
  .list-header .btn { width: 100%; }

  .modal {
    width: 100%; height: 100%;
    max-height: 100%;
    max-width: none;
    border-radius: 0;
    top: 0; left: 0;
    transform: none;
    animation: slideUp 0.2s ease-out;
  }
  @keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
  .modal-actions {
    position: sticky;
    bottom: 0;
    background: var(--bg);
    margin: var(--space-md) calc(-1 * var(--space-lg)) calc(-1 * var(--space-lg));
    padding: var(--space-md) var(--space-lg);
    padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom));
  }

  .detail-photo-hero { aspect-ratio: 4/3; border-radius: var(--radius); }
  .detail-title { font-size: 22px; }
  .detail-sub { font-size: 13px; }
  .kv { gap: 8px 16px; font-size: 13px; }
  .photo-stack { grid-template-columns: repeat(3, 1fr); }

  .lightbox-close { top: 16px; right: 16px; width: 40px; height: 40px; }
  .lightbox-nav { width: 40px; height: 40px; }
  .lightbox-prev { left: 12px; }
  .lightbox-next { right: 12px; }

  .empty-state { margin: 40px auto; padding: 0 var(--space-md); }
  .empty-state h2 { font-size: 18px; }
}
