:root {
  --navy: #0D2540;
  --navy-2: #173A5B;
  --teal: #2E7D7B;
  --teal-soft: #DDECEA;
  --green: #3F5F44;
  --green-soft: #E3E9E4;
  --cream: #F7F3EA;
  --cream-2: #EFE9DC;
  --stone: #8E979D;
  --ink: #182536;
  --muted: #647181;
  --white: #FFFFFF;
  --danger: #9F3C38;
  --warning: #A56D1A;
  --border: rgba(13, 37, 64, 0.12);
  --shadow: 0 18px 48px rgba(13, 37, 64, 0.13);
  --radius: 18px;
  --sidebar-width: 260px;
}

* { box-sizing: border-box; }

html {
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  background: var(--cream);
}

body {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  color: var(--ink);
  background: var(--cream);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button, a, select, summary, [role="button"] { touch-action: manipulation; }
img { display: block; max-width: 100%; }
.hidden { display: none !important; }

h1, h2, h3, h4, p { margin-top: 0; }
h1, h2, h3 { color: var(--navy); }
h1 { margin-bottom: 12px; font-size: clamp(2rem, 5vw, 3.3rem); line-height: 1.02; letter-spacing: -0.045em; }
h2 { margin-bottom: 8px; font-size: clamp(1.65rem, 3vw, 2.35rem); line-height: 1.08; letter-spacing: -0.035em; }
h3 { margin-bottom: 8px; font-size: 1.12rem; }
.muted { color: var(--muted); }
.eyebrow {
  margin-bottom: 8px;
  color: var(--teal);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.onboarding-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 12% 10%, rgba(46,125,123,.16), transparent 30%),
    radial-gradient(circle at 88% 90%, rgba(63,95,68,.12), transparent 28%),
    var(--cream);
}

.onboarding-card {
  width: min(100%, 560px);
  padding: clamp(26px, 5vw, 48px);
  background: rgba(255,255,255,.82);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.onboarding-logo {
  width: 88px;
  height: 88px;
  margin-bottom: 24px;
  border-radius: 22px;
}

.stack-form, .form-grid { display: grid; gap: 16px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

label {
  display: grid;
  gap: 7px;
  color: var(--navy);
  font-size: .88rem;
  font-weight: 800;
}

input, select, textarea {
  width: 100%;
  padding: 12px 13px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid rgba(13,37,64,.18);
  border-radius: 12px;
  outline: 0;
}

textarea { min-height: 104px; resize: vertical; }

input:focus, select:focus, textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(46,125,123,.13);
}

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 850;
  line-height: 1;
}

.button-primary { color: white; background: var(--teal); }
.button-primary:hover { background: #276F6D; }
.button-secondary { color: white; background: var(--navy); }
.button-ghost { color: var(--navy); background: transparent; border-color: var(--border); }
.button-danger { color: white; background: var(--danger); }
.button-full { width: 100%; }
.button-small { min-height: 34px; padding: 8px 10px; font-size: .82rem; }
.button:disabled { opacity: .55; cursor: not-allowed; }

.app-shell {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, var(--sidebar-width)) minmax(0, 1fr);
  overflow-x: hidden;
  overflow-x: clip;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  width: var(--sidebar-width);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 16px 18px;
  color: white;
  background: var(--navy);
  border-right: 1px solid rgba(255,255,255,.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 20px;
  color: white;
  text-decoration: none;
}

.brand img { width: 44px; height: 44px; border-radius: 12px; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 1.1rem; }
.brand span { color: #AFC1CF; font-size: .72rem; font-weight: 700; }

.main-nav { display: grid; gap: 6px; }

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  color: #D8E2E9;
  background: transparent;
  border: 0;
  border-radius: 12px;
  text-align: left;
  font-weight: 750;
}

.nav-item:hover, .nav-item.active {
  color: white;
  background: rgba(46,125,123,.28);
}

.nav-icon {
  width: 28px;
  display: inline-grid;
  place-items: center;
  font-size: 1.15rem;
}

.local-badge {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px;
}

.local-badge strong, .local-badge small { display: block; }
.local-badge strong { font-size: .82rem; }
.local-badge small { margin-top: 2px; color: #AFC1CF; font-size: .72rem; }
.status-dot { width: 9px; height: 9px; margin-top: 4px; background: #87C8C2; border-radius: 50%; box-shadow: 0 0 0 4px rgba(135,200,194,.12); }
.local-badge[data-state="working"] .status-dot {
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(210,169,91,.16);
}
.local-badge[data-state="error"] .status-dot {
  background: #E1847D;
  box-shadow: 0 0 0 4px rgba(225,132,125,.16);
}

.workspace {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  grid-column: 2;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 74px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px clamp(18px, 3vw, 34px);
  background: rgba(247,243,234,.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.topbar-title { flex: 1; min-width: 0; }
.topbar-title p, .topbar-title span { display: block; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-title p { color: var(--navy); font-weight: 900; }
.topbar-title span { color: var(--muted); font-size: .78rem; }

.topbar-actions { min-width: 0; display: flex; align-items: center; gap: 10px; }

.icon-button, .profile-button {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  background: white;
  color: var(--navy);
}

.icon-button { width: 40px; height: 40px; border-radius: 11px; font-size: 1.3rem; }
.profile-button { width: 42px; height: 42px; border-radius: 50%; font-size: .78rem; font-weight: 900; }
.menu-button { display: none; }

.main-content {
  min-width: 0;
  padding: clamp(18px, 3vw, 36px);
  overflow-x: hidden;
  overflow-x: clip;
}
.view { display: none; }
.view.active { width: 100%; max-width: 100%; min-width: 0; display: block; }

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.page-header p { max-width: 720px; margin: 6px 0 0; color: var(--muted); }

.header-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  min-height: 146px;
  padding: 20px;
  background: rgba(255,255,255,.74);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat-card .label { color: var(--muted); font-size: .78rem; font-weight: 800; }
.stat-card .value { display: block; margin: 12px 0 5px; color: var(--navy); font-size: 2.3rem; font-weight: 900; line-height: 1; }
.stat-card .note { color: var(--teal); font-size: .78rem; font-weight: 750; }

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, .7fr);
  gap: 18px;
}

.panel {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 20px;
  background: rgba(255,255,255,.74);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-header h3 { margin: 0; }
.panel-header small { color: var(--muted); }

.list { width: 100%; max-width: 100%; min-width: 0; display: grid; gap: 10px; }
.list-item {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px;
  overflow: hidden;
  background: var(--white);
  border: 1px solid rgba(13,37,64,.08);
  border-radius: 13px;
}

.list-item-main { max-width: 100%; min-width: 0; flex: 1 1 0%; overflow: hidden; }
.list-item-main strong, .list-item-main span { display: block; }
.list-item-main strong {
  overflow: hidden;
  color: var(--navy);
  line-height: 1.28;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
  word-break: break-word;
}
.list-item-main span {
  margin-top: 2px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: .78rem;
  word-break: break-word;
}
.list-item-actions { min-width: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.list-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: white;
  background: var(--teal);
  border-radius: 11px;
  font-weight: 900;
}
.list-icon.green { background: var(--green); }
.list-icon.navy { background: var(--navy); }
.list-icon.warning { background: var(--warning); }

.empty-state {
  padding: 34px 20px;
  color: var(--muted);
  background: rgba(255,255,255,.46);
  border: 1px dashed rgba(13,37,64,.2);
  border-radius: 16px;
  text-align: center;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(130px, 190px));
  gap: 10px;
  margin-bottom: 18px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.animal-card {
  padding: 18px;
  background: rgba(255,255,255,.78);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.animal-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.animal-avatar {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--navy);
  border-radius: 15px;
  font-size: 1.35rem;
  font-weight: 900;
}
.animal-card h3 { margin: 14px 0 4px; }
.animal-card .meta { color: var(--muted); font-size: .82rem; }
.animal-card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(13,37,64,.08);
}
.animal-card-footer .button { flex: 0 0 auto; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  color: var(--navy);
  background: var(--teal-soft);
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 850;
}

.badge.green { color: var(--green); background: var(--green-soft); }
.badge.gray { color: #56616B; background: #E8ECEE; }
.badge.warning { color: #7B4E10; background: #F5E7CE; }
.badge.danger { color: #832D29; background: #F3DBD9; }

.data-table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 13px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.data-table th { color: var(--muted); font-size: .72rem; letter-spacing: .07em; text-transform: uppercase; }
.data-table td { font-size: .88rem; }
.data-table tbody tr:hover { background: rgba(255,255,255,.55); }

.task-check {
  width: 20px;
  height: 20px;
  accent-color: var(--teal);
}

.progress-track { height: 8px; background: #E5E9EA; border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--teal); border-radius: 999px; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.settings-card {
  padding: 20px;
  background: rgba(255,255,255,.74);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.settings-card h3 { margin-bottom: 4px; }
.settings-card p { color: var(--muted); font-size: .88rem; }
.sync-summary {
  margin-top: 14px;
  padding: 13px;
  color: var(--navy);
  background: var(--teal-soft);
  border: 1px solid rgba(46,125,123,.2);
  border-radius: 12px;
  font-size: .86rem;
  font-weight: 800;
}
.sync-summary[data-state="working"] { background: #F5E7CE; }
.sync-summary[data-state="error"] {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(139,52,47,.2);
}
.action-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow: hidden;
  background: rgba(6,21,36,.64);
  backdrop-filter: blur(6px);
  overscroll-behavior: contain;
}

.modal {
  width: min(100%, 760px);
  max-width: 100%;
  min-width: 0;
  max-height: min(90vh, 920px);
  overflow: auto;
  padding: 24px;
  background: var(--cream);
  border-radius: 24px;
  box-shadow: 0 30px 90px rgba(0,0,0,.28);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

body.modal-open { overflow: hidden; }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.modal-header h2 { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.detail-field { padding: 12px; background: rgba(255,255,255,.6); border: 1px solid var(--border); border-radius: 12px; }
.detail-field small, .detail-field strong { display: block; }
.detail-field small { color: var(--muted); }
.detail-field strong { margin-top: 3px; color: var(--navy); }


.pedigree-import-grid {
  display: grid;
  gap: 16px;
}

.pedigree-source-box {
  padding: 16px;
  background: rgba(255,255,255,.64);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.pedigree-source-preview {
  min-height: 140px;
  display: grid;
  place-items: center;
  margin-top: 12px;
  padding: 12px;
  overflow: hidden;
  color: var(--muted);
  background: white;
  border: 1px dashed rgba(13,37,64,.2);
  border-radius: 14px;
  text-align: center;
}

.pedigree-source-preview img {
  max-height: 360px;
  object-fit: contain;
  border-radius: 10px;
}

.pedigree-source-preview object {
  width: 100%;
  height: 420px;
  border: 0;
  border-radius: 10px;
}

.pedigree-generation {
  padding: 14px;
  background: rgba(255,255,255,.55);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.pedigree-generation > summary {
  padding: 3px;
  color: var(--navy);
  font-weight: 900;
}

.ancestor-grid {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 12px;
  margin-top: 14px;
}

.ancestor-card {
  padding: 14px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.ancestor-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.ancestor-card-header strong {
  color: var(--navy);
}

.ancestor-fields {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 10px;
}

.ancestor-fields label {
  font-size: .78rem;
}

.match-hint {
  min-height: 22px;
  margin-top: 8px;
  color: var(--warning);
  font-size: .78rem;
  font-weight: 800;
}

.match-hint button {
  margin-left: 6px;
  padding: 3px 7px;
  color: white;
  background: var(--warning);
  border: 0;
  border-radius: 7px;
  font-size: .72rem;
  font-weight: 900;
}

.pedigree-warning {
  padding: 12px;
  color: #704815;
  background: #F7E9CF;
  border: 1px solid #E4C78F;
  border-radius: 12px;
  font-size: .84rem;
}

.pedigree-document-card {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 12px;
}

.pedigree-document-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--navy);
  border-radius: 14px;
  font-size: 1.35rem;
}

.modal.modal-wide {
  width: min(100%, 1180px);
}

@media (max-width: 760px) {
  .ancestor-grid,
  .ancestor-fields {
    grid-template-columns: 1fr;
  }

  .pedigree-document-card {
    grid-template-columns: 48px 1fr;
  }

  .pedigree-document-card .list-item-actions {
    grid-column: 1 / -1;
    width: 100%;
  }

  .pedigree-document-card .list-item-actions .button {
    min-height: 44px;
    flex: 1 1 0;
  }

  .animal-card,
  .view > .panel .list > .list-item {
    content-visibility: auto;
    contain-intrinsic-size: auto 140px;
  }

  .modal-backdrop {
    backdrop-filter: none;
  }
}

.pedigree-preview-scroll {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
  margin-top: 14px;
  padding: 4px 2px 10px;
}
.pedigree-preview-tree {
  min-width: 820px;
  display: grid;
  grid-template-columns: minmax(190px,.95fr) 34px minmax(190px,1fr) 34px minmax(190px,1fr);
  grid-template-rows: repeat(4,minmax(78px,auto));
  align-items: stretch;
}
.pedigree-preview-node {
  align-self: center;
  min-width: 0;
}
.pedigree-preview-card {
  padding: 10px 11px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 7px;
  box-shadow: 0 2px 8px rgba(13,37,64,.045);
}
.pedigree-preview-card.subject {
  border-color: rgba(46,125,123,.56);
  border-left: 4px solid var(--teal);
}
.pedigree-preview-card.unknown {
  background: rgba(255,255,255,.5);
  border-style: dashed;
}
.pedigree-preview-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.pedigree-preview-heading small {
  display: block;
  color: var(--muted);
  font-size: .64rem;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.pedigree-preview-heading strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--navy);
  font-size: .9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pedigree-preview-sex {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 850;
  text-transform: uppercase;
}
.pedigree-preview-details {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 3px 10px;
  margin-top: 7px;
}
.pedigree-preview-details span {
  overflow: hidden;
  color: var(--muted);
  font-size: .7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pedigree-preview-details b {
  color: var(--navy);
  font-size: .62rem;
  letter-spacing: .035em;
}
.pedigree-preview-branch {
  position: relative;
  align-self: stretch;
}
.pedigree-preview-branch::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 25%;
  bottom: 25%;
  border-left: 1px solid var(--border-strong);
}
.pedigree-preview-branch::after {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 50%;
  border-top: 1px solid var(--border-strong);
}
.pedigree-preview-arm {
  position: absolute;
  left: 50%;
  right: 0;
  border-top: 1px solid var(--border-strong);
}
.pedigree-preview-arm.top { top: 25%; }
.pedigree-preview-arm.bottom { top: 75%; }
html[data-theme="dark"] .pedigree-preview-card {
  background: #102638;
  border-color: rgba(211,226,235,.16);
}
html[data-theme="dark"] .pedigree-preview-card.unknown { background: rgba(16,38,56,.55); }
html[data-theme="dark"] .pedigree-preview-heading strong,
html[data-theme="dark"] .pedigree-preview-details b { color: #F1F5F7; }

.toast-region {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 200;
  display: grid;
  gap: 8px;
}

.toast {
  min-width: 260px;
  max-width: 380px;
  padding: 13px 15px;
  color: white;
  background: var(--navy);
  border-radius: 13px;
  box-shadow: var(--shadow);
  font-weight: 750;
  animation: toast-in .2s ease-out;
}

.toast.success { background: var(--green); }
.toast.error { background: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}


.feedback-button {
  min-height: 40px;
  padding: 9px 13px;
  color: white;
  background: var(--green);
  border-color: var(--green);
}

.feedback-button:hover,
.feedback-button:focus-visible {
  background: #344f39;
}

.feedback-short {
  display: none;
}

.feedback-status {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 750;
}

.feedback-status.success {
  color: var(--green);
}

.feedback-status.error {
  color: var(--danger);
}

.feedback-privacy {
  padding: 12px;
  color: var(--muted);
  background: rgba(255,255,255,.55);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: .82rem;
}

@media (max-width: 620px) {
  .feedback-button {
    width: 42px;
    min-width: 42px;
    padding: 0;
  }

  .feedback-label {
    display: none;
  }

  .feedback-short {
    display: inline;
    font-size: 1.05rem;
  }
}


.topbar-operation {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}

.operation-logo {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  object-fit: contain;
  padding: 3px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.branding-preview {
  min-height: 152px;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(255,255,255,.52);
  border: 1px dashed rgba(13,37,64,.24);
  border-radius: 16px;
}

.branding-preview img {
  max-width: 220px;
  max-height: 120px;
  object-fit: contain;
}

.photo-upload-card {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  padding: 16px;
  background: rgba(255,255,255,.52);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.photo-preview {
  width: 132px;
  height: 132px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: white;
  background: var(--navy);
  border: 1px solid var(--border);
  border-radius: 18px;
  font-size: 3rem;
}

.species-outline {
  width: 1.55em;
  height: 1.1em;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.photo-preview .species-outline,
.animal-detail-photo .species-outline {
  width: 2.15em;
  height: 1.55em;
}

.photo-preview img,
.animal-avatar img,
.animal-detail-photo img,
.print-animal-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-upload-copy p {
  margin: 5px 0 12px;
  color: var(--muted);
  font-size: .84rem;
}

.photo-upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.animal-avatar {
  overflow: hidden;
}

.animal-avatar.has-photo {
  padding: 0;
  background: var(--cream-2);
}

.animal-detail-hero {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  margin-bottom: 18px;
}

.animal-detail-photo {
  width: 150px;
  height: 150px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: white;
  background: var(--navy);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 3.5rem;
}

.animal-detail-photo.has-photo {
  background: var(--cream-2);
}

.brand-file-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: .8rem;
}

@media (max-width: 620px) {
  .photo-upload-card,
  .animal-detail-hero {
    grid-template-columns: 1fr;
  }

  .photo-preview,
  .animal-detail-photo {
    width: 118px;
    height: 118px;
  }

  .operation-logo {
    width: 36px;
    height: 36px;
  }
}

@media (max-width: 1120px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .cards-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .toolbar { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .workspace { grid-column: 1; }
  .sidebar {
    transform: translateX(-102%);
    transition: transform .2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-button { display: inline-grid; }
  .dashboard-grid, .settings-grid { grid-template-columns: 1fr; }
  .form-grid.two, .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .topbar { gap: 8px; padding-inline: 12px; }
  .topbar-actions { gap: 6px; }
  .feedback-button,
  #quick-add-button {
    width: 42px;
    min-width: 42px;
    padding: 0;
  }
  .feedback-label { display: none; }
  .feedback-short { display: inline; font-size: 1.05rem; }
  #quick-add-button { font-size: 0; }
  #quick-add-button::before { content: "+"; font-size: 1.2rem; }
}

@media (max-width: 620px) {
  .main-content { padding: 18px 14px 90px; }
  .topbar { padding-inline: 14px; }
  .topbar .button-ghost { display: none; }
  .page-header { align-items: stretch; flex-direction: column; }
  .header-actions .button { flex: 1; }
  .stats-grid, .cards-grid, .toolbar { grid-template-columns: 1fr; }
  .modal-backdrop {
    place-items: end center;
    padding: 0;
  }
  .modal {
    width: 100%;
    max-height: calc(100vh - env(safe-area-inset-top, 0px));
    max-height: calc(100dvh - env(safe-area-inset-top, 0px));
    padding: 18px 18px calc(18px + env(safe-area-inset-bottom, 0px));
    border-radius: 20px 20px 0 0;
  }
  .modal-header {
    position: sticky;
    top: -18px;
    z-index: 4;
    margin: -18px -18px 18px;
    padding: 18px;
    background: var(--cream);
    border-bottom: 1px solid var(--border);
  }
  .modal-actions {
    flex-wrap: wrap;
  }
  .modal-actions .button {
    min-height: 44px;
    flex: 1 1 145px;
  }
  .pedigree-source-action {
    align-items: stretch;
    flex-direction: column;
  }
  .pedigree-source-action .button {
    min-height: 44px;
    justify-content: center;
  }
  .pedigree-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}


/* v0.2.1 cleaner interface, guided pedigree workflow, and appearance controls */
.nav-group-label {
  margin: 18px 12px 6px;
  color: #8297A8;
  font-size: .66rem;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.sidebar-collapse {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 9px 12px;
  color: #D8E2E9;
  background: transparent;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 12px;
  font-weight: 800;
}

.sidebar-collapse:hover { background: rgba(255,255,255,.07); }
.collapse-icon { width: 22px; font-size: 1.25rem; line-height: 1; }

body.sidebar-collapsed { --sidebar-width: 84px; }
body.sidebar-collapsed .sidebar { width: 84px; padding-inline: 10px; }
body.sidebar-collapsed .brand { justify-content: center; padding-inline: 0; }
body.sidebar-collapsed .brand > div,
body.sidebar-collapsed .nav-item span:last-child,
body.sidebar-collapsed .nav-group-label,
body.sidebar-collapsed .collapse-label,
body.sidebar-collapsed .local-badge > div { display: none; }
body.sidebar-collapsed .nav-item,
body.sidebar-collapsed .sidebar-collapse { justify-content: center; padding-inline: 8px; }
body.sidebar-collapsed .nav-icon { width: 32px; }
body.sidebar-collapsed .collapse-icon { transform: rotate(180deg); }
body.sidebar-collapsed .local-badge { justify-content: center; }

.theme-toggle { font-size: 1.05rem; }

.main-content { max-width: 1540px; width: 100%; margin: 0 auto; }
.stats-grid,
.dashboard-grid,
.settings-grid,
.cards-grid,
.toolbar,
.budget-filters,
.budget-layout,
.finance-snapshot,
.production-report-filters,
.task-toolbar,
.pedigree-intro,
.pedigree-stepper,
.review-summary-grid,
.breeding-report-summary,
.offspring-grid,
.form-grid,
.detail-grid,
.ancestor-grid,
.ancestor-fields {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.stats-grid > *,
.dashboard-grid > *,
.settings-grid > *,
.cards-grid > *,
.toolbar > *,
.budget-filters > *,
.budget-layout > *,
.finance-snapshot > *,
.production-report-filters > *,
.task-toolbar > *,
.pedigree-intro > *,
.pedigree-stepper > *,
.review-summary-grid > *,
.breeding-report-summary > *,
.offspring-grid > *,
.form-grid > *,
.detail-grid > *,
.ancestor-grid > *,
.ancestor-fields > * {
  max-width: 100%;
  min-width: 0;
}
.stat-card,
.animal-card,
.settings-card,
.detail-field,
.review-summary-card,
.pedigree-intro-card,
.ancestor-card {
  max-width: 100%;
  min-width: 0;
}
.stat-card .label,
.stat-card .note,
.panel-header,
.panel-header > *,
.animal-card h3,
.animal-card .meta,
.settings-card p,
.detail-field strong,
.review-summary-card strong,
.pedigree-intro-card span {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.page-header { margin-bottom: 30px; }
.page-header h2 { margin-bottom: 7px; }
.stats-grid { gap: 16px; }
.stat-card,
.panel,
.animal-card,
.settings-card {
  box-shadow: 0 8px 26px rgba(13,37,64,.055);
}
.stat-card { min-height: 132px; padding: 20px 22px; }
.stat-card .value { font-size: 2.15rem; }
.dashboard-grid { gap: 20px; }
.panel { padding: 22px; }
.list { gap: 8px; }
.list-item { border-color: rgba(13,37,64,.065); }

.pedigree-intro {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.pedigree-intro-card {
  padding: 18px;
  background: rgba(255,255,255,.66);
  border: 1px solid var(--border);
  border-radius: 17px;
}
.pedigree-intro-card strong,
.pedigree-intro-card span { display: block; }
.pedigree-intro-card strong { color: var(--navy); }
.pedigree-intro-card span { margin-top: 4px; color: var(--muted); font-size: .84rem; }

.draft-panel { margin-bottom: 20px; }
.draft-card { border-left: 4px solid var(--warning); }

.pedigree-stepper {
  display: grid;
  grid-template-columns: repeat(5, minmax(0,1fr));
  gap: 8px;
  margin: 0 0 22px;
}
.pedigree-step-button {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px;
  color: var(--muted);
  background: rgba(255,255,255,.5);
  border: 1px solid var(--border);
  border-radius: 13px;
  text-align: left;
  font-size: .78rem;
  font-weight: 850;
}
.pedigree-step-button span:first-child {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: var(--navy);
  background: var(--cream-2);
  border-radius: 9px;
}
.pedigree-step-button.active {
  color: var(--navy);
  background: var(--teal-soft);
  border-color: rgba(46,125,123,.32);
}
.pedigree-step-button.active span:first-child { color: white; background: var(--teal); }
.pedigree-step-button.complete span:first-child { color: white; background: var(--green); }

.wizard-panel { display: grid; gap: 18px; }
.wizard-panel[hidden] { display: none; }
.wizard-heading { margin-bottom: 2px; }
.wizard-heading p { margin: 5px 0 0; color: var(--muted); }
.wizard-footer {
  position: sticky;
  bottom: -24px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 24px -24px -24px;
  padding: 16px 24px;
  background: rgba(247,243,234,.96);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(14px);
}
.wizard-spacer { flex: 1; }

.file-drop {
  min-height: 170px;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  background: rgba(255,255,255,.52);
  border: 2px dashed rgba(46,125,123,.32);
  border-radius: 18px;
  text-align: center;
  cursor: pointer;
}
.file-drop:hover,
.file-drop.dragging { background: var(--teal-soft); border-color: var(--teal); }
.file-drop.busy { cursor: wait; opacity: .72; }
.file-drop strong { display: block; color: var(--navy); font-size: 1rem; }
.file-drop small { display: block; margin-top: 5px; }
.file-actions { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }

.ancestor-card {
  padding: 16px;
  background: rgba(255,255,255,.64);
  box-shadow: none;
}
.ancestor-card.linked { border-color: rgba(63,95,68,.38); background: var(--green-soft); }
.ancestor-manual { margin-top: 12px; }
.ancestor-manual summary {
  color: var(--teal);
  font-size: .84rem;
  font-weight: 850;
  cursor: pointer;
}
.ancestor-manual .ancestor-fields { margin-top: 12px; }
.ancestor-tools { display: flex; justify-content: flex-end; margin-top: 10px; }
.text-button {
  padding: 4px 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  font-size: .78rem;
  font-weight: 800;
}
.text-button:hover { color: var(--danger); }

.review-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 10px;
}
.review-summary-card {
  padding: 14px;
  background: rgba(255,255,255,.62);
  border: 1px solid var(--border);
  border-radius: 13px;
}
.review-summary-card small,
.review-summary-card strong { display: block; }
.review-summary-card small { color: var(--muted); }
.review-summary-card strong { margin-top: 3px; color: var(--navy); }

/* Dark mode uses a deliberately balanced HerdHarbor palette, not a simple inversion. */
html[data-theme="dark"] body,
html[data-theme="dark"] .workspace,
html[data-theme="dark"] .main-content { color: #E8EEF2; background: #071827; }
html[data-theme="dark"] .topbar { background: rgba(7,24,39,.94); border-color: rgba(211,226,235,.1); }
html[data-theme="dark"] .topbar-title p,
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] label,
html[data-theme="dark"] summary,
html[data-theme="dark"] .list-item-main strong,
html[data-theme="dark"] .animal-card h3,
html[data-theme="dark"] .pedigree-intro-card strong,
html[data-theme="dark"] .review-summary-card strong,
html[data-theme="dark"] .file-drop strong { color: #F3EFE5; }
html[data-theme="dark"] .muted,
html[data-theme="dark"] .page-header p,
html[data-theme="dark"] .list-item-main span,
html[data-theme="dark"] .animal-card .meta,
html[data-theme="dark"] .panel-header small,
html[data-theme="dark"] .pedigree-intro-card span,
html[data-theme="dark"] .wizard-heading p,
html[data-theme="dark"] .file-drop,
html[data-theme="dark"] .review-summary-card small,
html[data-theme="dark"] .text-button { color: #AAB8C3; }
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .animal-card,
html[data-theme="dark"] .settings-card,
html[data-theme="dark"] .list-item,
html[data-theme="dark"] .onboarding-card,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .detail-field,
html[data-theme="dark"] .pedigree-cell,
html[data-theme="dark"] .pedigree-intro-card,
html[data-theme="dark"] .review-summary-card,
html[data-theme="dark"] .ancestor-card,
html[data-theme="dark"] .file-drop,
html[data-theme="dark"] .pedigree-step-button { background: #102A41; border-color: rgba(208,225,235,.12); }
html[data-theme="dark"] .ancestor-card.linked { background: #18352D; }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea { color: #EEF3F6; background: #0A2033; border-color: rgba(208,225,235,.18); color-scheme: dark; }
html[data-theme="dark"] .button-ghost,
html[data-theme="dark"] .icon-button,
html[data-theme="dark"] .profile-button { color: #EEF3F6; background: #102A41; border-color: rgba(208,225,235,.15); }
html[data-theme="dark"] .data-table th,
html[data-theme="dark"] .data-table td { border-color: rgba(208,225,235,.1); }
html[data-theme="dark"] .data-table tbody tr:hover { background: rgba(255,255,255,.035); }
html[data-theme="dark"] .wizard-footer { background: rgba(7,24,39,.96); border-color: rgba(208,225,235,.12); }
html[data-theme="dark"] .pedigree-warning { color: #E7D2A5; background: #332B1D; border-color: rgba(231,210,165,.2); }
html[data-theme="dark"] .empty-state { color: #AAB8C3; background: rgba(16,42,65,.55); border-color: rgba(208,225,235,.18); }
html[data-theme="dark"] .badge { color: #D8EEEC; background: #18433F; }
html[data-theme="dark"] .badge.green { color: #DCEADB; background: #24452E; }
html[data-theme="dark"] .badge.gray { color: #D2DBE0; background: #263A49; }
html[data-theme="dark"] .pedigree-source-preview { background: #0A2033; border-color: rgba(208,225,235,.12); }


html[data-theme="dark"] .operation-logo,
html[data-theme="dark"] .branding-preview,
html[data-theme="dark"] .photo-upload-card,
html[data-theme="dark"] .photo-preview,
html[data-theme="dark"] .animal-detail-photo {
  background: #102A41;
  border-color: rgba(208,225,235,.14);
}

html[data-theme="dark"] .photo-upload-copy p,
html[data-theme="dark"] .brand-file-note {
  color: #AAB8C3;
}

@media (max-width: 1000px) {
  .pedigree-stepper { grid-template-columns: 1fr; }
  .pedigree-step-button { min-height: 44px; }
  .pedigree-intro { grid-template-columns: 1fr; }
  .review-summary-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 860px) {
  body.sidebar-collapsed { --sidebar-width: 260px; }
  body.sidebar-collapsed .sidebar { width: 260px; padding-inline: 16px; }
  body.sidebar-collapsed .brand { justify-content: flex-start; padding-inline: 8px; }
  body.sidebar-collapsed .brand > div,
  body.sidebar-collapsed .nav-item span:last-child,
  body.sidebar-collapsed .nav-group-label,
  body.sidebar-collapsed .collapse-label,
  body.sidebar-collapsed .local-badge > div { display: block; }
  body.sidebar-collapsed .nav-item,
  body.sidebar-collapsed .sidebar-collapse { justify-content: flex-start; padding-inline: 12px; }
  body.sidebar-collapsed .collapse-icon { transform: none; }
  .sidebar-collapse { display: none; }
}

@media (max-width: 620px) {
  .theme-toggle { width: 40px; min-width: 40px; }
  .wizard-footer { flex-wrap: wrap; margin-inline: -18px; margin-bottom: -18px; padding: 14px 18px; }
  .wizard-spacer { display: none; }
  .wizard-footer .button { flex: 1 1 42%; }
  .review-summary-grid { grid-template-columns: 1fr; }
  .file-drop { min-height: 140px; padding: 18px; }
}


/* v0.2.2 budgeting and cost-per-head */
.budget-filters {
  display: grid;
  grid-template-columns: minmax(170px, .7fr) minmax(170px, .7fr) minmax(170px, .7fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 18px;
}

.budget-filters label {
  margin: 0;
}

.budget-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
  gap: 18px;
  margin-bottom: 18px;
}

.budget-progress-card {
  display: grid;
  gap: 14px;
}

.budget-progress-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(130px, 2fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.budget-progress-row:first-child {
  border-top: 0;
}

.budget-progress-meta strong,
.budget-progress-meta span {
  display: block;
}

.budget-progress-meta span {
  color: var(--muted);
  font-size: .76rem;
}

.budget-progress-value {
  color: var(--navy);
  font-size: .82rem;
  font-weight: 900;
  text-align: right;
}

.budget-meter {
  height: 10px;
  overflow: hidden;
  background: var(--cream-2);
  border-radius: 999px;
}

.budget-meter > span {
  display: block;
  height: 100%;
  background: var(--teal);
  border-radius: 999px;
}

.budget-meter > span.over {
  background: var(--danger);
}

.cost-table {
  display: grid;
  gap: 8px;
}

.cost-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) repeat(3, minmax(90px, .6fr));
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.cost-row.header {
  color: var(--muted);
  background: transparent;
  border: 0;
  font-size: .7rem;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.cost-row strong {
  color: var(--navy);
}

.cost-row span:not(:first-child) {
  text-align: right;
}

.transaction-amount {
  font-weight: 900;
  white-space: nowrap;
}

.transaction-amount.income {
  color: var(--green);
}

.transaction-amount.expense {
  color: var(--danger);
}

.budget-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: .78rem;
}

.sale-animal-picker {
  display: grid;
  gap: 9px;
  max-height: 340px;
  margin: 12px 0;
  padding: 10px;
  overflow: auto;
  background: var(--cream-2);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.sale-animal-choice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
}

.sale-animal-choice input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.sale-animal-choice span,
.sale-animal-choice small { display: block; }
.sale-animal-choice small { margin-top: 2px; color: var(--muted); }

.sale-price-row {
  grid-template-columns: auto minmax(0, 1fr) minmax(105px, 140px);
}

.sale-total-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 12px 0 18px;
  padding: 14px 16px;
  color: white;
  background: var(--navy);
  border-radius: 13px;
}

.sale-total-preview strong { font-size: 1.3rem; }

.finance-snapshot {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
  padding: 14px;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  background: linear-gradient(135deg, rgba(46,125,123,.1), rgba(63,95,68,.08));
  border: 1px solid rgba(46,125,123,.18);
  border-radius: 17px;
}

.finance-snapshot > div {
  padding: 10px 12px;
  background: rgba(255,255,255,.52);
  border-radius: 12px;
}

.finance-snapshot small,
.finance-snapshot strong {
  display: block;
}

.finance-snapshot small {
  color: var(--muted);
}

.finance-snapshot strong {
  margin-top: 3px;
  color: var(--navy);
  font-size: 1.05rem;
}

.transaction-scope-fields {
  display: contents;
}

@media (max-width: 980px) {
  .budget-layout {
    grid-template-columns: 1fr;
  }

  .finance-snapshot {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }
}

@media (max-width: 760px) {
  .budget-filters {
    grid-template-columns: 1fr 1fr;
  }

  .budget-progress-row {
    grid-template-columns: 1fr;
  }

  .budget-progress-value,
  .cost-row span:not(:first-child) {
    text-align: left;
  }

  .cost-row {
    grid-template-columns: 1fr 1fr;
  }

  .cost-row.header {
    display: none;
  }
}

@media (max-width: 520px) {
  .budget-filters,
  .finance-snapshot,
  .cost-row {
    grid-template-columns: 1fr;
  }
}

/* v0.3.06 production reports and faster entry */
.production-quick-bar,
.production-period-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.production-quick-bar {
  margin-bottom: 14px;
  padding: 12px;
  background: linear-gradient(135deg, rgba(46,125,123,.1), rgba(63,95,68,.07));
  border: 1px solid rgba(46,125,123,.18);
  border-radius: 14px;
}

.production-quick-label {
  margin-right: 4px;
  color: var(--navy);
  font-size: .78rem;
  font-weight: 900;
}

.production-report-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
  margin: 14px 0;
}

.production-period-bar { margin-bottom: 16px; }

.production-period-bar .button.active {
  color: white;
  background: var(--navy);
  border-color: var(--navy);
}

.production-stat-grid { margin-bottom: 16px; }
.production-stat-grid .stat-card { min-height: 124px; }
.production-stat-grid .stat-card .value { font-size: 1.8rem; }

.production-alerts {
  display: grid;
  gap: 9px;
  margin-bottom: 16px;
}

.production-alert {
  padding: 11px 13px;
  color: #704815;
  background: #F7E9CF;
  border: 1px solid #E4C78F;
  border-radius: 12px;
  font-size: .82rem;
  font-weight: 750;
}

.production-alert.danger {
  color: #832D29;
  background: #F3DBD9;
  border-color: rgba(159,60,56,.24);
}

.production-report-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.production-report-section h4 {
  margin: 0 0 4px;
  color: var(--navy);
}

.production-report-section > p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: .78rem;
}

html[data-theme="dark"] .production-quick-label,
html[data-theme="dark"] .production-report-section h4 { color: #F3EFE5; }
html[data-theme="dark"] .production-alert { color: #E7D2A5; background: #332B1D; border-color: rgba(231,210,165,.2); }
html[data-theme="dark"] .production-alert.danger { color: #F2C5C2; background: #3E2022; border-color: rgba(242,197,194,.2); }

@media (max-width: 900px) {
  .production-report-filters { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 560px) {
  .production-report-filters { grid-template-columns: 1fr; }
  .production-quick-bar .button,
  .production-period-bar .button { flex: 1 1 42%; }
  .production-quick-label { flex-basis: 100%; }
}


/* v0.2.15 portrait-only PWA and conflict-safe cloud sync */
html[data-theme="dark"] {
  color-scheme: dark;
  --cream: #071827;
  --cream-2: #193247;
  --ink: #E8EEF2;
  --muted: #B8C5CE;
  --white: #102A41;
  --border: rgba(208,225,235,.16);
  --shadow: 0 18px 48px rgba(0,0,0,.34);
}

html[data-theme="dark"] .eyebrow,
html[data-theme="dark"] .stat-card .note,
html[data-theme="dark"] .ancestor-manual summary {
  color: #82D0CC;
}

html[data-theme="dark"] .stat-card .value,
html[data-theme="dark"] .detail-field strong,
html[data-theme="dark"] .ancestor-card-header strong,
html[data-theme="dark"] .pedigree-step-button,
html[data-theme="dark"] .budget-progress-meta strong,
html[data-theme="dark"] .budget-progress-value,
html[data-theme="dark"] .cost-row strong,
html[data-theme="dark"] .finance-snapshot strong {
  color: #F3F6F8;
}

html[data-theme="dark"] .stat-card .label,
html[data-theme="dark"] .detail-field small,
html[data-theme="dark"] .settings-card p,
html[data-theme="dark"] .feedback-status,
html[data-theme="dark"] .feedback-privacy,
html[data-theme="dark"] .budget-progress-meta span,
html[data-theme="dark"] .cost-row.header,
html[data-theme="dark"] .budget-note,
html[data-theme="dark"] .finance-snapshot small,
html[data-theme="dark"] .data-table th {
  color: #B8C5CE;
}

html[data-theme="dark"] .pedigree-source-box,
html[data-theme="dark"] .pedigree-generation,
html[data-theme="dark"] .feedback-privacy,
html[data-theme="dark"] .cost-row,
html[data-theme="dark"] .finance-snapshot > div {
  color: #E8EEF2;
  background: #102A41;
  border-color: rgba(208,225,235,.16);
}

html[data-theme="dark"] .finance-snapshot {
  color: #E8EEF2;
  background: linear-gradient(135deg, rgba(46,125,123,.2), rgba(63,95,68,.16));
  border-color: rgba(130,208,204,.28);
}

html[data-theme="dark"] .budget-meter,
html[data-theme="dark"] .progress-track {
  background: #213B50;
}

html[data-theme="dark"] .badge.warning {
  color: #FFE2A8;
  background: #5A3D18;
}

html[data-theme="dark"] .badge.danger {
  color: #FFD4D1;
  background: #5B2826;
}

html[data-theme="dark"] .transaction-amount.income,
html[data-theme="dark"] .feedback-status.success {
  color: #9BD3A5;
}

html[data-theme="dark"] .transaction-amount.expense,
html[data-theme="dark"] .feedback-status.error,
html[data-theme="dark"] .text-button:hover {
  color: #FF9B96;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #8FA2B0;
  opacity: 1;
}

.hh-pwa-update {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 12000;
  width: min(560px, calc(100% - 28px));
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  align-items: center;
  padding: 15px 16px;
  color: #FFFFFF;
  background: #0D2540;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(0,0,0,.28);
  transform: translateX(-50%);
}

.hh-pwa-update strong,
.hh-pwa-update span { grid-column: 1; }
.hh-pwa-update span { color: #D9E4EA; font-size: .88rem; }
.hh-pwa-update > div {
  grid-column: 2;
  grid-row: 1 / 3;
  display: flex;
  gap: 8px;
}
.hh-pwa-update button {
  min-height: 42px;
  padding: 9px 14px;
  color: #0D2540;
  background: #FFFFFF;
  border: 0;
  border-radius: 10px;
  font-weight: 850;
}
.hh-pwa-update [data-hh-update-later] { color: #FFFFFF; background: transparent; border: 1px solid rgba(255,255,255,.45); }

@media (max-width: 520px) {
  .hh-pwa-update { grid-template-columns: 1fr; }
  .hh-pwa-update > div {
    grid-column: 1;
    grid-row: auto;
    margin-top: 7px;
  }
  .hh-pwa-update button { flex: 1; }
}

/* v0.4.0 breeding and birth management */
.task-today-panel { margin: 0 0 18px; }
.task-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(140px, 190px));
  gap: 10px;
  margin-bottom: 12px;
}
.task-filter-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: .8rem;
}
.task-filter-summary strong { color: var(--navy); }
.task-check {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  accent-color: var(--teal);
}
.task-repeat-note {
  margin: 12px 0 16px;
  padding: 10px 12px;
  color: var(--muted);
  background: var(--teal-soft);
  border-radius: 12px;
  font-size: .8rem;
}
html[data-theme="dark"] .task-filter-summary strong { color: var(--cream); }
html[data-theme="dark"] .settings-card p,
html[data-theme="dark"] .settings-card li,
html[data-theme="dark"] .modal p,
html[data-theme="dark"] .modal li,
html[data-theme="dark"] .detail-field small,
html[data-theme="dark"] .data-table caption,
html[data-theme="dark"] .brand-file-note { color: #B9C7D0; }
html[data-theme="dark"] .settings-card a,
html[data-theme="dark"] .modal a { color: #8FD1CC; }
html[data-theme="dark"] .button-danger { color: #FFFFFF; }
html[data-theme="dark"] .modal-header { background: #071827; }
html[data-theme="dark"] .pedigree-document-icon { color: #FFFFFF; background: #173B5B; }
html[data-theme="dark"] .pedigree-source-action { color: #F3EFE5; background: #102A41; border-color: rgba(208,225,235,.18); }

@media (max-width: 1120px) {
  .task-toolbar { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 700px) {
  .task-toolbar { grid-template-columns: 1fr; }
  .task-filter-summary { align-items: flex-start; flex-direction: column; }
  .task-list-item { align-items: flex-start; flex-wrap: wrap; }
  .task-list-item .list-item-main { min-width: calc(100% - 44px); }
  .task-list-item .list-item-actions { width: 100%; justify-content: flex-end; }
}

/* v0.4.0 breeding, birth, and offspring workflow */
.breeding-toolbar-panel {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.breeding-toolbar-panel label { min-width: 180px; }
.table-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.breeding-report-panel { margin-top: 18px; }
.breeding-report-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 18px;
}
.breeding-report-summary span {
  display: grid;
  gap: 2px;
  padding: 12px;
  color: var(--muted);
  background: var(--cream-2);
  border: 1px solid var(--border);
  border-radius: 13px;
  font-size: .78rem;
}
.breeding-report-summary b { color: var(--navy); font-size: 1.15rem; }
.compact-table th, .compact-table td { padding-block: 9px; }
.offspring-creator-header {
  display: grid;
  grid-template-columns: minmax(150px, 210px) 1fr;
  gap: 16px;
  align-items: end;
  margin-bottom: 16px;
}
.offspring-grid { display: grid; gap: 9px; }
.offspring-row {
  display: grid;
  grid-template-columns: 36px minmax(180px, 1.35fr) minmax(130px, 1fr) minmax(120px, .7fr);
  gap: 10px;
  align-items: end;
  padding: 11px;
  background: var(--cream-2);
  border: 1px solid var(--border);
  border-radius: 13px;
}
.offspring-number {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  align-self: center;
  color: white;
  background: var(--navy);
  border-radius: 50%;
  font-size: .78rem;
  font-weight: 850;
}
html[data-theme="dark"] .breeding-report-summary b { color: var(--cream); }

@media (max-width: 760px) {
  .breeding-toolbar-panel, .offspring-creator-header { align-items: stretch; grid-template-columns: 1fr; flex-direction: column; }
  .breeding-report-summary { grid-template-columns: 1fr 1fr; }
  .offspring-row { grid-template-columns: 34px 1fr; }
  .offspring-row label { grid-column: 2; }
  .offspring-number { grid-row: 1 / 4; }
  .sale-price-row { grid-template-columns: auto minmax(0, 1fr); }
  .sale-price-row input[data-sale-price] { grid-column: 2; }
}

/* Alpha tablet containment and responsive card contract */
.panel,
.stat-card,
.animal-card,
.settings-card,
.detail-field,
.review-summary-card,
.pedigree-intro-card,
.pedigree-generation,
.pedigree-document-card,
.ancestor-card,
.photo-upload-card,
.budget-progress-row,
.cost-row,
.sale-animal-choice,
.sale-total-preview,
.production-alert,
.task-list-item,
.offspring-row,
.file-drop,
.sync-summary,
.feedback-status,
.feedback-privacy {
  max-width: 100%;
  min-width: 0;
}

.panel > *,
.stat-card > *,
.animal-card > *,
.settings-card > *,
.pedigree-document-card > *,
.photo-upload-card > *,
.budget-progress-row > *,
.cost-row > *,
.sale-animal-choice > *,
.sale-total-preview > *,
.task-list-item > *,
.offspring-row > * {
  max-width: 100%;
  min-width: 0;
}

.activity-list .list-item { align-items: flex-start; }
.activity-list .list-item-main,
.sale-animal-choice span,
.sale-animal-choice small,
.production-alert,
.feedback-status,
.feedback-privacy {
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media (max-width: 1180px) {
  .dashboard-grid,
  .budget-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .panel-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }
}

@media (min-width: 521px) and (max-width: 1180px) {
  .budget-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 561px) and (max-width: 1180px) {
  .production-report-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 701px) and (max-width: 1180px) {
  .task-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* v1.2.0 educational symptom guide */
.symptom-safety-banner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 18px;
  padding: 18px 20px;
  color: #5F241F;
  background: #FFF0ED;
  border: 1px solid rgba(159, 60, 56, .24);
  border-left: 5px solid var(--danger);
  border-radius: 16px;
}
.symptom-safety-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--danger);
  border-radius: 12px;
  font-weight: 900;
}
.symptom-safety-banner strong { display: block; margin-bottom: 4px; color: #5F241F; }
.symptom-safety-banner p { margin: 0; line-height: 1.55; }
.symptom-lookup-panel { margin-bottom: 20px; }
.symptom-lookup-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 14px;
}
.symptom-guide-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.symptom-guide-filters label { display: grid; gap: 7px; }
.symptom-guide-filters label span {
  color: var(--muted);
  font-size: .75rem;
  font-weight: 850;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.symptom-guide-filters .symptom-search-field { grid-column: span 2; }
.symptom-red-flags { margin-bottom: 18px; }
.symptom-red-flags summary { color: var(--danger); font-weight: 900; cursor: pointer; }
.symptom-red-flags ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 28px;
  margin: 14px 0 0;
  padding-left: 20px;
}
.symptom-results-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}
.symptom-results-heading h3 { margin: 0; }
.symptom-results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.symptom-card {
  min-width: 0;
  padding: 20px;
  background: rgba(255, 255, 255, .72);
  border: 1px solid var(--border);
  border-radius: 17px;
  box-shadow: 0 8px 26px rgba(13,37,64,.055);
}
.symptom-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.symptom-card h3 { margin: 3px 0 0; font-size: 1.05rem; }
.symptom-species { color: var(--muted); font-size: .74rem; font-weight: 850; text-transform: uppercase; }
.symptom-urgency {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 900;
  white-space: nowrap;
}
.symptom-urgency.emergency { color: #7B2522; background: #FFE1DD; }
.symptom-urgency.soon { color: #70470F; background: #FFF0CC; }
.symptom-urgency.monitor { color: #2E5636; background: #E3F0E4; }
.symptom-card h4 { margin: 14px 0 6px; color: var(--navy); font-size: .8rem; }
.symptom-card ul { margin: 0; padding-left: 19px; color: var(--muted); }
.symptom-card li + li { margin-top: 4px; }
.symptom-card .symptom-action { margin: 0; color: var(--ink); line-height: 1.55; }
.symptom-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.symptom-card-footer a { color: var(--teal); font-size: .76rem; font-weight: 800; }
.symptom-custom-note { margin-bottom: 18px; }
.symptom-reference-note { margin-top: 20px; color: var(--muted); font-size: .78rem; line-height: 1.55; }

html[data-theme="dark"] .symptom-safety-banner { color: #FFD8D2; background: #3A1E20; border-color: rgba(255, 183, 174, .22); }
html[data-theme="dark"] .symptom-safety-banner strong { color: #FFE5E1; }
html[data-theme="dark"] .symptom-card { background: #102A41; border-color: rgba(208,225,235,.12); }
html[data-theme="dark"] .symptom-card h4,
html[data-theme="dark"] .symptom-card .symptom-action { color: #EEF3F6; }

@media (max-width: 900px) {
  .symptom-guide-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .symptom-guide-filters .symptom-search-field { grid-column: span 2; }
  .symptom-results { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
  .symptom-safety-banner { grid-template-columns: minmax(0, 1fr); }
  .symptom-lookup-form,
  .symptom-guide-filters { grid-template-columns: minmax(0, 1fr); }
  .symptom-guide-filters .symptom-search-field { grid-column: auto; }
  .symptom-red-flags ul { grid-template-columns: minmax(0, 1fr); }
  .symptom-card-header,
  .symptom-card-footer { align-items: stretch; flex-direction: column; }
  .symptom-urgency { align-self: flex-start; }
}

  