:root {
  --bg: #e2d5c6;
  --surface: #eee4d8;
  --ink: #241910;
  --muted: #5e4e42;
  --accent: #8b3a1a;
  --accent-dark: #5c2410;
  --warn: #b45309;
  --danger: #b42318;
  --border: #c9b49a;
  --shadow: 0 10px 30px rgba(36, 25, 16, 0.12);
  --radius: 14px;
  --btn-radius: 6px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(139, 58, 26, 0.2), transparent 40%),
    var(--bg);
  min-height: 100vh;
}

html:has(#app-view:not(.hidden)) {
  overflow: hidden;
  height: 100dvh;
}

body:has(#app-view:not(.hidden)) {
  overflow: hidden;
  height: 100dvh;
  width: 100%;
  position: fixed;
  inset: 0;
}

a { color: var(--accent); }

.shell {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 0 clamp(1rem, 3vw, 2.5rem);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
  margin-bottom: 0;
  padding-top: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  background-image: radial-gradient(circle at top left, rgba(139, 58, 26, 0.2), transparent 40%);
  position: relative;
  z-index: 150;
}

.shell > main {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding-top: 1rem;
  padding-bottom: 1.25rem;
}

.topbar-brand {
  min-width: 0;
}

.topbar-farm {
  font-size: 0.9rem;
  margin-top: 0.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.02em;
}

.brand-logo {
  display: block;
  width: auto;
  height: 2.4rem;
  max-width: 12rem;
  object-fit: contain;
  object-position: left center;
  flex-shrink: 0;
}

.auth-card .brand-logo {
  height: 3.5rem;
  max-width: 16rem;
  margin: 0 auto;
  object-position: center;
}

.tank-volume-preview {
  margin: 0.75rem 0 0;
  font-size: 0.95rem;
}

.tank-volume-preview strong {
  color: var(--accent-dark);
  font-size: 1.05rem;
}


.nav-menu-wrap {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.nav-menu-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--btn-radius);
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  cursor: pointer;
  font: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}

.nav-menu-btn:hover {
  border-color: var(--accent);
}

.nav-menu-btn.active {
  border-color: var(--accent);
  background: rgba(30, 58, 95, 0.1);
  color: var(--accent-dark);
}

.nav-home-icon {
  display: block;
}

.nav-menu-icon {
  font-size: 1.35rem;
  line-height: 1;
  font-weight: 700;
  margin-top: -0.15rem;
}

.nav-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  z-index: 200;
  min-width: 210px;
  max-width: min(280px, calc(100vw - 2.5rem));
  padding: 0.35rem 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(31, 42, 36, 0.14);
}

.nav-menu button,
.nav-menu a.nav-menu-link {
  display: block;
  width: 100%;
  padding: 0.55rem 1rem;
  border: none;
  background: none;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.nav-menu a.nav-menu-link {
  text-decoration: none;
  box-sizing: border-box;
}

.nav-menu button:hover,
.nav-menu a.nav-menu-link:hover {
  background: rgba(30, 58, 95, 0.1);
}

.nav-menu button.active {
  background: rgba(30, 58, 95, 0.14);
  color: var(--accent-dark);
  font-weight: 600;
}

.nav-menu-divider {
  height: 1px;
  margin: 0.35rem 0;
  background: var(--border);
}

.nav-menu-signout {
  color: var(--muted);
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--btn-radius);
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  font: inherit;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}

.grid {
  display: grid;
  gap: 1rem;
}

.dashboard-stats-bar {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
  margin-bottom: 1rem;
}

.dashboard-stats-bar:has(.dashboard-stats-row) {
  flex-direction: column;
}

.dashboard-stats-row {
  display: flex;
  align-items: stretch;
}

.dashboard-stats-row:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

.dashboard-stat-segment {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.85rem 0.5rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: background 0.15s;
}

.dashboard-stat-segment:not(:last-child) {
  border-right: 1px solid var(--border);
}

.dashboard-stat-segment:hover {
  background: rgba(30, 58, 95, 0.08);
}

.dashboard-stat-segment:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 1;
}

.dashboard-stat-segment strong {
  font-size: 1.6rem;
  line-height: 1.1;
}

.dashboard-stat-segment span {
  color: var(--muted);
  font-size: 0.9rem;
}

.dashboard-stat-segment-warn strong {
  color: var(--warn);
}

.dashboard-stat-segment:disabled {
  opacity: 0.55;
  cursor: default;
}

.dashboard-stat-segment:disabled:hover {
  background: transparent;
}

.dashboard-water-alert-row {
  cursor: pointer;
}

.dashboard-water-alert-row:hover,
.dashboard-water-alert-row:focus-visible {
  background: rgba(0, 0, 0, 0.04);
  outline: none;
}

.dashboard-water-alert-badge {
  pointer-events: none;
}

.dashboard-alert-indicators {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
}

.dashboard-alert-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--warn, #c9a227);
  border-radius: 8px;
  background: rgba(201, 162, 39, 0.08);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.dashboard-alert-chip:hover,
.dashboard-alert-chip:focus-visible {
  background: rgba(201, 162, 39, 0.16);
  outline: none;
}

.dashboard-alert-chip strong {
  font-size: 0.92rem;
}

.dashboard-alert-chip-issues {
  font-size: 0.82rem;
  color: var(--muted);
}

.dashboard-alert-card-warn {
  border-left: 4px solid var(--warn, #c9a227);
}

.dashboard-alert-hint {
  margin: -0.25rem 0 0.75rem;
}

.dashboard-focus-highlight {
  animation: dashboard-focus-pulse 1.8s ease;
}

@keyframes dashboard-focus-pulse {
  0%,
  100% {
    box-shadow: none;
  }
  20%,
  60% {
    box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.45);
  }
}

.dashboard-breeding-ready {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.dashboard-breeding-ready-header {
  margin-bottom: 0.35rem;
}

.dashboard-breeding-ready-title {
  margin: 0;
}

.dashboard-breeding-ready-title-pulse {
  display: inline-block;
  animation: dashboard-breeding-ready-title-pulse 1.6s ease-in-out infinite;
}

@keyframes dashboard-breeding-ready-title-pulse {
  0%,
  100% {
    color: var(--ink);
    transform: scale(1);
  }
  50% {
    color: var(--accent);
    transform: scale(1.04);
  }
}

.dashboard-breeding-ready-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
}

.dashboard-breeding-ready-icon {
  position: relative;
  display: block;
  width: 72px;
  height: 72px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 12px;
  line-height: 0;
}

.dashboard-breeding-ready-photo {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  object-fit: cover;
  background: #e8e2d7;
  border: 1px solid var(--border);
  display: block;
}

.dashboard-breeding-ready-icon:hover .dashboard-breeding-ready-photo,
.dashboard-breeding-ready-icon:focus-visible .dashboard-breeding-ready-photo {
  box-shadow: 0 0 0 2px var(--accent);
}

.dashboard-breeding-ready-icon:focus-visible {
  outline: none;
}

.dashboard-breeding-ready-sex {
  position: absolute;
  right: 4px;
  bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.2rem;
  border-radius: 6px;
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(31, 42, 36, 0.12);
  pointer-events: none;
}

.upcoming-kindles-table {
  table-layout: fixed;
}

.upcoming-kindles-col-due {
  width: 9.25rem;
}

.upcoming-kindles-col-actions {
  width: 6.75rem;
}

.upcoming-kindles-table th,
.upcoming-kindles-table td {
  padding-left: 0;
  padding-right: 0;
}

.upcoming-kindle-date {
  white-space: nowrap;
  vertical-align: middle;
  padding-right: 1.5rem;
}

.upcoming-kindle-pair {
  vertical-align: middle;
  padding-right: 1.25rem;
}

.upcoming-kindles-table .table-actions {
  width: 6.75rem;
  white-space: nowrap;
  vertical-align: middle;
  text-align: right;
  padding-left: 0.5rem;
}

.upcoming-kindles-table thead .table-actions {
  padding-right: 0;
}

.upcoming-kindles-table .table-actions .btn {
  margin-right: 0;
}

.upcoming-kindle-buck {
  font-weight: 500;
  line-height: 1.25;
}

.upcoming-kindle-doe {
  margin-top: 0.15rem;
  font-size: 0.9rem;
  color: var(--muted, #7a7268);
  line-height: 1.25;
}

h1, h2, h3 { margin: 0 0 0.75rem; }
.muted { color: var(--muted); }

.page-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 1rem;
  row-gap: 0.35rem;
  margin-bottom: 1rem;
}

.page-header h1,
.page-header h2,
.page-header h3,
.rabbit-detail-title-input {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
  min-width: 0;
}

.page-header-actions {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  flex-shrink: 0;
}

.page-header-close-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: var(--btn-radius);
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-size: 1.35rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.page-header-close-btn:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.page-header-menu-wrap {
  position: relative;
  flex-shrink: 0;
}

.page-header-menu-btn {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: var(--btn-radius);
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  cursor: pointer;
  font: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}

.page-header-menu-btn:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.page-header-menu-btn[aria-expanded="true"] {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.page-header-menu-text-btn {
  width: auto;
  min-width: 2.5rem;
  padding: 0 0.85rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.page-header-menu-icon {
  font-size: 1.35rem;
  line-height: 1;
  font-weight: 700;
  margin-top: -0.15rem;
}

.page-header-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  z-index: 150;
  min-width: 200px;
  max-width: min(280px, calc(100vw - 2rem));
  width: max-content;
  margin: 0;
  padding: 0.35rem 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(31, 42, 36, 0.14);
}

.page-header-menu .action-menu-title {
  margin: 0;
  padding: 0.35rem 1rem 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.page-header-menu .action-menu-divider {
  height: 1px;
  margin: 0.35rem 0;
  background: var(--border);
}

.page-header-menu-item {
  display: block;
  width: 100%;
  padding: 0.55rem 1rem;
  border: none;
  background: none;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.page-header-menu-item:hover:not(:disabled) {
  background: rgba(30, 58, 95, 0.1);
}

.page-header-menu-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.page-header-menu-item-danger {
  color: var(--danger);
}

.page-header-menu-item-emphasis {
  color: var(--accent-dark);
  font-weight: 600;
}

.page-header-intro {
  grid-column: 1 / -1;
  grid-row: 2;
  margin: 0;
}

.card > .page-header {
  margin-bottom: 0.5rem;
}

form label {
  display: block;
  margin: 0.6rem 0 0.25rem;
  font-size: 0.9rem;
  color: var(--muted);
}

input, select, textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  background: #efe6da;
}

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

.row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.table th, .table td {
  text-align: left;
  padding: 0.55rem 0.35rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table-spread {
  table-layout: fixed;
}

.table-spread .table-actions {
  width: 11rem;
  text-align: right;
}

.thumb {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  background: #e8e2d7;
}

.rabbit-list-thumb-btn {
  position: relative;
  display: block;
  width: 56px;
  height: 56px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 12px;
  line-height: 0;
}

.rabbit-list-photo {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  object-fit: cover;
  background: #e8e2d7;
  display: block;
}

.rabbit-list-photo-sex {
  position: absolute;
  right: 3px;
  bottom: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.15rem;
  border-radius: 5px;
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  line-height: 1;
  pointer-events: none;
}

.rabbit-list-photo-sex .sex-symbol {
  min-width: auto;
  font-size: inherit;
}

.rabbit-list-thumb-btn:hover .rabbit-list-photo,
.rabbit-list-thumb-btn:focus-visible .rabbit-list-photo {
  box-shadow: 0 0 0 2px var(--accent, #1e3a5f);
}

.rabbit-list-thumb-btn:focus-visible {
  outline: none;
}

.rabbit-photo-section {
  flex: 0 1 280px;
  max-width: 280px;
}

.rabbit-photo-current {
  display: block;
  width: 100%;
  max-width: 280px;
  border-radius: 12px;
  object-fit: cover;
  aspect-ratio: 1;
}

.rabbit-photo-placeholder {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: #f5f1ea;
  font-size: 0.9rem;
}

.rabbit-photo-frame {
  position: relative;
  width: 100%;
}

.rabbit-photo-menu-wrap {
  position: absolute;
  right: 0.5rem;
  top: 0.5rem;
  z-index: 2;
}

.rabbit-photo-menu-btn {
  border: 1px solid var(--border);
  background: rgba(255, 253, 248, 0.94);
  color: var(--muted);
  border-radius: var(--btn-radius);
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  cursor: pointer;
  font: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}

.rabbit-photo-menu-btn:hover,
.rabbit-photo-menu-btn[aria-expanded="true"] {
  background: var(--surface);
  color: var(--text);
  border-color: var(--accent);
}

.rabbit-photo-menu-icon {
  font-size: 1.35rem;
  line-height: 1;
  font-weight: 700;
}

.rabbit-photo-menu.page-header-menu {
  right: 0;
  left: auto;
  top: 100%;
  min-width: 10.5rem;
}

.rabbit-photo-menu-panel .page-header-menu-item {
  display: block;
  width: 100%;
  text-align: left;
}

.rabbit-camera-panel {
  margin-top: 0.75rem;
  max-width: 320px;
}

.rabbit-camera-panel video {
  display: block;
  width: 100%;
  border-radius: 10px;
  background: #000;
}

.rabbit-camera-controls {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.genetics-form {
  margin-top: 0.5rem;
}

.add-rabbit-form .form-section-title {
  margin: 1.25rem 0 0.65rem;
  font-size: 1rem;
}

.add-rabbit-form .form-section-title:first-of-type {
  margin-top: 0;
}

.genetics-parent {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem 1rem;
  margin: 0 0 1rem;
}

.genetics-parent legend {
  font-weight: 600;
  padding: 0 0.35rem;
}

.genetics-mode {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.genetics-mode label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.genetics-panel .row {
  margin-bottom: 0.5rem;
}

.genetics-current {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
}

.pedigree-tree {
  font-size: 0.9rem;
  line-height: 1.45;
}

.pedigree-node {
  margin: 0.2rem 0;
}

.pedigree-children {
  margin-top: 0.35rem;
  padding-left: 0.5rem;
  border-left: 2px solid var(--border);
}

.pedigree-notes {
  font-size: 0.85rem;
  margin-top: 0.15rem;
}

.family-tree-modal {
  position: fixed;
  inset: 0;
  z-index: 450;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.family-tree-modal.hidden {
  display: none;
}

.family-tree-modal-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  padding: 0;
  margin: 0;
  background: rgba(31, 42, 36, 0.5);
  cursor: default;
}

.family-tree-modal-panel {
  position: relative;
  z-index: 1;
  width: min(1100px, calc(100% - 1.5rem));
  max-height: min(92vh, 900px);
  overflow: auto;
  margin: 0;
  padding: 1.25rem 1.5rem 1.5rem;
}

.family-tree-modal.family-tree-modal--wide {
  padding: 0.75rem;
}

.family-tree-modal.family-tree-modal--wide .family-tree-modal-panel {
  width: min(98vw, 1600px);
  max-height: 96vh;
}

.family-tree-modal-toolbar {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 1rem;
}

.family-tree-graph-summary {
  margin: 0 0 0.75rem;
}

.family-tree-graph-scroll {
  overflow: auto;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #faf8f4;
}

.family-graph-svg {
  display: block;
  min-width: 100%;
}

.family-graph-node.is-subject rect {
  filter: drop-shadow(0 2px 4px rgba(30, 58, 95, 0.18));
}

.family-tree-modal-close {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.family-tree-modal-title {
  margin: 0 2rem 1rem 0;
  font-size: 1.2rem;
}

.family-tree-modal-body {
  display: grid;
  gap: 1.5rem;
}

.family-tree-section-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: var(--accent-dark);
}

.family-tree-ancestors {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: 12rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.family-tree-gen {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  min-width: 11rem;
  padding: 0 0.85rem;
}

.family-tree-gen:first-child {
  padding-left: 0;
}

.family-tree-gen:not(:last-child) {
  border-right: 2px solid var(--border);
  margin-right: 0.85rem;
}

.family-tree-gen-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.65rem;
  text-align: center;
}

.family-tree-gen-slots {
  flex: 1;
  display: grid;
  grid-template-rows: repeat(var(--slot-count), minmax(4.5rem, 1fr));
  gap: 0.5rem;
  align-items: center;
  min-height: calc(var(--family-tree-max-rows, 1) * 4.75rem);
}

.family-tree-slot {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  justify-content: center;
  position: relative;
}

.family-tree-slot-role {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.family-tree-node {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  background: #efe6da;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: default;
}

button.family-tree-node {
  cursor: pointer;
}

button.family-tree-node:hover {
  border-color: var(--accent);
  box-shadow: 0 1px 4px rgba(31, 42, 36, 0.08);
}

.family-tree-node.sex-buck {
  border-left: 4px solid #5b8ec9;
}

.family-tree-node.sex-doe {
  border-left: 4px solid #c96b8e;
}

.family-tree-node.sex-unknown,
.family-tree-node.empty,
.family-tree-node.restricted,
.family-tree-node.circular {
  border-left: 4px solid #c8c0b4;
}

.family-tree-node.is-subject {
  border-color: var(--accent);
  background: #f3faf5;
  box-shadow: 0 2px 8px rgba(30, 58, 95, 0.12);
}

.family-tree-node.manual {
  background: #faf8f4;
}

.family-tree-node-photo {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.4rem;
  object-fit: cover;
  flex-shrink: 0;
  background: #ebe5da;
}

.family-tree-node-photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: var(--muted);
}

.family-tree-node-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.family-tree-node-name {
  font-size: 0.88rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.family-tree-node-meta,
.family-tree-node-farm {
  font-size: 0.76rem;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.family-tree-unknown {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}

.family-tree-descendants {
  list-style: none;
  margin: 0;
  padding: 0 0 0 1rem;
  border-left: 2px solid var(--border);
}

.family-tree-descendants > li {
  margin: 0.5rem 0;
}

.family-tree-descendant-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.family-tree-descendant-row .family-tree-node {
  max-width: 18rem;
}

.family-tree-descendant-role {
  font-size: 0.8rem;
}

@media (max-width: 640px) {
  .family-tree-modal-panel {
    width: calc(100% - 1rem);
    padding: 1rem;
  }

  .family-tree-gen {
    min-width: 9.5rem;
  }

  .family-tree-node-photo {
    width: 2.25rem;
    height: 2.25rem;
  }
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  background: #ebe5da;
}

.badge.warn { background: #fdecd5; color: var(--warn); }
.badge.danger { background: #fee4e2; color: var(--danger); }
.badge.ok { background: #d5e4f5; color: var(--accent-dark); }

.tank-managed-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
}

.stock-colonies-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.stock-tank-group {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 253, 248, 0.65);
  overflow: visible;
}

.stock-tank-heading {
  margin: 0;
  padding: 0.75rem 1rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-dark);
  background: rgba(30, 58, 95, 0.06);
  border-bottom: 1px solid var(--border);
}

.stock-tank-volume {
  font-weight: 600;
  color: var(--muted);
}

.stock-species-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.stock-species-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid rgba(30, 58, 95, 0.08);
  position: relative;
  z-index: 0;
}

.stock-species-row:has(.action-menu:not(.hidden)) {
  z-index: 25;
}

.stock-species-row:last-child {
  border-bottom: none;
}

.stock-species-label {
  min-width: 0;
  font-size: 0.95rem;
}

.stock-species-qty {
  color: var(--muted);
  font-weight: 600;
}

.stock-species-actions {
  flex-shrink: 0;
}

.stock-locate-modal-panel {
  width: min(520px, calc(100% - 2rem));
}

.stock-locate-tank-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stock-locate-tank-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.65);
}

.stock-locate-tank-label {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.92rem;
}

.stock-locate-tank-label .muted {
  font-size: 0.85rem;
}

.stock-locate-tank-row .btn {
  flex-shrink: 0;
  width: auto;
}

.stock-species-total-item:has(.action-menu:not(.hidden)) {
  z-index: 25;
}

.stock-locate-tank-row-list-only {
  justify-content: flex-start;
}

.tank-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tank-list-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 253, 248, 0.65);
  position: relative;
  z-index: 0;
}

.tank-list-item:has(.action-menu:not(.hidden)) {
  z-index: 25;
}

.tank-list-item-unmanaged {
  opacity: 0.85;
}

.tank-list-main {
  min-width: 0;
  flex: 1 1 auto;
}

.tank-list-heading {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-dark);
  line-height: 1.3;
}

.tank-list-volume {
  font-weight: 600;
  color: var(--muted);
}

.tank-list-stock {
  margin: 0.25rem 0 0;
  font-size: 0.92rem;
  color: var(--muted);
}

.tank-list-species {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
}

.tank-list-species-item {
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--ink);
}

.tank-list-species-qty {
  color: var(--muted);
  font-weight: 600;
}

.tank-capacity-gauge {
  margin-top: 0.65rem;
  max-width: 22rem;
}

.tank-capacity-gauge-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.3rem;
  font-size: 0.82rem;
}

.tank-capacity-gauge-title {
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.tank-capacity-gauge-values {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--ink);
}

.tank-capacity-gauge-track {
  height: 0.55rem;
  border-radius: 999px;
  background: rgba(30, 58, 95, 0.12);
  overflow: hidden;
}

.tank-capacity-gauge-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2f6b4f, #3d8b66);
  transition: width 0.25s ease;
}

.tank-capacity-gauge.is-high .tank-capacity-gauge-fill {
  background: linear-gradient(90deg, #b45309, #d97706);
}

.tank-capacity-gauge.is-over .tank-capacity-gauge-fill {
  background: linear-gradient(90deg, #b42318, #dc2626);
}

.tank-capacity-gauge.is-over .tank-capacity-gauge-values {
  color: var(--danger);
}

.tank-capacity-gauge-unknown {
  margin: 0.65rem 0 0;
  font-size: 0.85rem;
}

.tank-list-stock-over {
  color: var(--danger);
  font-weight: 600;
}

.tank-list-item-over {
  border-color: rgba(180, 60, 50, 0.45);
}

.tank-capacity-preview {
  margin: 0.75rem 0 0;
  font-size: 0.92rem;
}

.tank-list-actions {
  flex-shrink: 0;
}

.rabbits-page-toolbar {
  margin: 0;
}

.rabbits-page-toolbar .btn {
  margin: 0;
}

.rabbit-filters-panel {
  margin-bottom: 0.75rem;
}

.rabbit-filters-panel .rabbit-filter-summary {
  margin: 0;
}

.rabbit-filter-compact {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}

.rabbit-filters {
  margin-bottom: 0.75rem;
}

.rabbit-filters-row {
  align-items: end;
  gap: 0.75rem 1rem;
}

.rabbit-filters-row > div {
  flex: 1 1 140px;
  min-width: 120px;
}

.rabbit-filters-actions {
  flex: 0 0 auto;
  align-self: end;
}

.rabbit-filter-summary {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}

.hidden { display: none !important; }

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.auth-card {
  width: min(420px, 100%);
}

.tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }

.toast {
  position: fixed;
  right: 1rem;
  bottom: 2.5rem;
  background: var(--ink);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  opacity: 0;
  transform: translateY(8px);
  transition: 0.2s ease;
  z-index: 20;
  max-width: 320px;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

.app-revision {
  position: fixed;
  right: 0.65rem;
  bottom: 0.45rem;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  opacity: 0.9;
  z-index: 15;
  pointer-events: none;
  user-select: none;
}

.risk-list { margin: 0.5rem 0 0; padding-left: 1.1rem; }
.risk-list li { margin: 0.25rem 0; }

.cages-tabs { margin-bottom: 1rem; }

.cages-tabs-row {
  display: contents;
}

.cages-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.cages-add-btn,
.action-icon-btn {
  flex-shrink: 0;
  min-width: 2.35rem;
  padding: 0.45rem 0.75rem;
  font-size: 1.25rem;
  line-height: 1;
  font-weight: 600;
}

.view-icon-btn,
.edit-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 400;
}

.action-icon {
  display: block;
}

.layout-area-tabs {
  flex-wrap: wrap;
}

.layout-editor .layout-area-tabs,
.layout-editor .layout-tier-tabs {
  margin-bottom: 0.75rem;
}

.layout-frame {
  display: flex;
  flex-direction: column;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--btn-radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
  min-height: 0;
}

.layout-tab-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem 0.65rem;
  background: rgba(30, 58, 95, 0.08);
  flex-shrink: 0;
}

.layout-tab-bar-top {
  border-bottom: 1px solid var(--border);
}

.layout-tab-bar-tiers {
  border-bottom: 1px solid var(--border);
}

.layout-tab-bar-bottom {
  border-top: 1px solid var(--border);
}

.layout-area-tabs,
.layout-tier-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  width: 100%;
}

.layout-editor .layout-toolbar { margin-bottom: 1rem; }

.layout-shell {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-start;
}

.layout-side {
  flex: 0 0 200px;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.layout-shelf h3 {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.layout-cage-props {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  background: rgba(30, 58, 95, 0.05);
}

.layout-cage-props h3 {
  font-size: 0.95rem;
  margin: 0 0 0.35rem;
}

.layout-cage-props-name {
  margin: 0 0 0.5rem;
  font-weight: 600;
}

.layout-unplaced {
  min-height: 100px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: rgba(255, 253, 248, 0.8);
}

.layout-unplaced.drop-target {
  border-color: var(--accent);
  background: rgba(30, 58, 95, 0.08);
}

.layout-unplaced .layout-empty {
  margin: 0;
  font-size: 0.85rem;
}

.layout-canvas-wrap {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  max-width: 100%;
}

.layout-view {
  width: 100%;
}

.layout-editor .layout-canvas-wrap {
  padding: 1.35rem 0.75rem 0.75rem 2rem;
}

.layout-view .layout-canvas-wrap {
  display: block;
  width: 100%;
  padding: 0.65rem;
  background: rgba(30, 58, 95, 0.04);
  box-sizing: border-box;
}

.layout-view .layout-area-tabs,
.layout-view .layout-tier-tabs {
  margin-bottom: 0;
}

.layout-grid,
.layout-floor {
  position: relative;
  display: block;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent calc(var(--layout-grid-step, 50px) - 1px),
      rgba(30, 58, 95, 0.08) calc(var(--layout-grid-step, 50px) - 1px),
      rgba(30, 58, 95, 0.08) var(--layout-grid-step, 50px)
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent calc(var(--layout-grid-step, 50px) - 1px),
      rgba(30, 58, 95, 0.08) calc(var(--layout-grid-step, 50px) - 1px),
      rgba(30, 58, 95, 0.08) var(--layout-grid-step, 50px)
    ),
    rgba(255, 255, 255, 0.55);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: min(100%, 320px);
  box-sizing: border-box;
}

.layout-floor.drop-target,
.layout-grid.drop-target {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.layout-rulers {
  position: absolute;
  pointer-events: none;
  font-size: 0.62rem;
  color: var(--muted);
  z-index: 1;
}

.layout-rulers-x {
  left: 0;
  right: 0;
  top: -1.1rem;
  height: 1rem;
}

.layout-rulers-y {
  top: 0;
  bottom: 0;
  left: -1.6rem;
  width: 1.5rem;
}

.layout-ruler-x,
.layout-ruler-y {
  position: absolute;
  transform: translate(-50%, 0);
}

.layout-ruler-y {
  transform: translate(0, -50%);
}

.layout-cage-footprint-label strong {
  color: var(--accent-dark);
}

.layout-cell {
  display: none;
}

.layout-cage {
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 0.3rem 0.4rem;
  cursor: grab;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.2;
  user-select: none;
  box-shadow: var(--shadow);
  position: relative;
}

.layout-cage.selected {
  outline: 3px solid var(--accent-dark);
  outline-offset: 1px;
}

.layout-cage.placed {
  z-index: 2;
  position: absolute;
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.layout-cage.tier-2.placed { z-index: 3; }
.layout-cage.tier-3.placed { z-index: 4; }

.layout-drop-preview {
  border: 2px dashed var(--accent);
  border-radius: 8px;
  background: rgba(30, 58, 95, 0.12);
  box-sizing: border-box;
  z-index: 20;
  opacity: 0.8;
}

.layout-unplaced .layout-cage {
  align-self: flex-start;
}

.layout-tier-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent-dark);
  background: rgba(255, 253, 248, 0.9);
  border-radius: 4px;
  padding: 0 0.2rem;
}

.layout-cage-size {
  font-size: 0.7rem;
  color: var(--muted);
}

.layout-cage.over {
  border-color: var(--warn);
}

.layout-cage.dragging {
  opacity: 0.45;
  cursor: grabbing;
  pointer-events: none;
}

.layout-cage-name {
  font-weight: 600;
  word-break: break-word;
}

.layout-cage-count {
  color: var(--muted);
  font-size: 0.75rem;
}

.layout-cage-count.warn {
  color: var(--warn);
  font-weight: 600;
}

.layout-cage.has-solo-photo {
  padding: 0;
  overflow: hidden;
  justify-content: flex-end;
}

.layout-cage-photo {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  object-fit: cover;
  display: block;
}

.layout-cage.has-solo-photo .layout-cage-name,
.layout-cage.has-solo-photo .layout-cage-size,
.layout-cage.has-solo-photo .layout-cage-count {
  padding: 0 0.3rem 0.15rem;
}

.layout-cage.has-solo-photo .layout-tier-badge {
  z-index: 1;
}

.layout-grid.view-mode {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  background: rgba(30, 58, 95, 0.06);
}

.layout-grid.view-mode .layout-tier-badge {
  display: none;
}

.layout-grid.view-mode .layout-cell {
  display: none;
}

.layout-grid.view-mode .layout-cage {
  font-size: clamp(0.6rem, 1.1vmin, 0.8rem);
  line-height: 1.15;
  padding: 0.15rem 0.2rem;
  border-width: 1px;
  border-radius: 5px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.layout-grid.view-mode .layout-cage-size,
.layout-floor.view-mode .layout-cage-size {
  display: block;
  font-size: clamp(0.48rem, 0.85vmin, 0.62rem);
}

.layout-grid.view-mode .layout-cage-name {
  font-size: clamp(0.55rem, 1vmin, 0.72rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.layout-grid.view-mode .layout-cage-count {
  font-size: clamp(0.5rem, 0.95vmin, 0.68rem);
}

.layout-grid.view-mode .layout-cage.has-solo-photo {
  justify-content: flex-end;
}

.layout-grid.view-mode .layout-cage-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  flex: none;
  object-fit: cover;
  z-index: 0;
  opacity: 0.9;
}

.layout-grid.view-mode .layout-cage.has-solo-photo .layout-cage-name,
.layout-grid.view-mode .layout-cage.has-solo-photo .layout-cage-count {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 0.05rem 0.15rem;
  background: rgba(255, 253, 248, 0.82);
}

.layout-room-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.layout-tier-actions {
  margin-top: -0.35rem;
}

.layout-view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.layout-shell-view {
  flex-wrap: nowrap;
}

.layout-filter-unassigned {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.5rem 0 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
}

.layout-filter-unassigned input {
  margin: 0;
}

.layout-cage-detail {
  min-width: 0;
}

.layout-cage-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.layout-cage-modal-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  padding: 0;
  margin: 0;
  background: rgba(31, 42, 36, 0.45);
  cursor: default;
}

.layout-cage-modal-panel {
  position: relative;
  z-index: 1;
  width: min(420px, calc(100% - 2rem));
  max-height: min(85vh, 640px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1rem 1.25rem;
  background: var(--surface);
  box-shadow: 0 12px 40px rgba(31, 42, 36, 0.2);
}

.layout-cage-detail-toolbar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.layout-cage-modal-edit,
.layout-cage-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  border: 1px solid var(--border);
  background: #efe6da;
  color: var(--accent-dark);
  border-radius: var(--btn-radius);
  cursor: pointer;
  padding: 0;
  box-shadow: 0 2px 8px rgba(30, 58, 95, 0.12);
  flex-shrink: 0;
}

.layout-cage-modal-close {
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1;
}

.layout-cage-modal-edit svg {
  display: block;
}

.layout-cage-modal-edit:hover,
.layout-cage-modal-close:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: rgba(30, 58, 95, 0.08);
}

.layout-cage-modal-edit:focus-visible,
.layout-cage-modal-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mate-rest-confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 450;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.mate-rest-confirm-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  padding: 0;
  margin: 0;
  background: rgba(31, 42, 36, 0.45);
  cursor: default;
}

.mate-rest-confirm-panel {
  position: relative;
  z-index: 1;
  width: min(400px, calc(100% - 2rem));
  margin: 0;
}

.mate-rest-confirm-message {
  margin: 0 0 1rem;
  line-height: 1.45;
}

.mate-rest-confirm-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.layout-cage-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.layout-cage-detail-name {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.2;
  flex: 1 1 auto;
  min-width: 0;
}

.layout-cage-detail-count {
  font-size: 0.9rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.layout-cage-detail-count.warn {
  color: var(--warn);
  font-weight: 600;
}

.layout-cage-detail-body {
  margin-bottom: 0.25rem;
}

.layout-cage-detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.layout-cage-detail-row-label {
  flex: 1 1 auto;
  min-width: 0;
}

.layout-cage-detail-row-value {
  flex: 0 0 auto;
  text-align: right;
}

.layout-cage-detail-stock-meta {
  font-size: 0.85rem;
}

.layout-cage-detail-row:last-child {
  border-bottom: none;
}

.layout-cage-detail-row.empty {
  color: var(--muted);
  font-size: 0.9rem;
  letter-spacing: 0.06em;
}

.layout-cage-detail-rabbit-info {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.layout-cage-detail-rabbit-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  font-size: 0.9rem;
  line-height: 1.3;
}

.layout-cage-rabbit-actions {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  flex-shrink: 0;
}

.btn.btn-mate-blocked {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: var(--border);
  color: var(--muted);
  background: var(--surface);
}

.layout-rabbit-meta {
  font-size: 0.85rem;
}

.layout-rabbit-status {
  font-size: 0.85rem;
  color: var(--accent-dark);
  font-weight: 500;
}

.layout-cage-detail-actions {
  margin-top: 0.75rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.add-to-cage-panel {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.add-to-cage-form select {
  width: 100%;
  margin: 0.35rem 0 0.5rem;
}

.add-to-cage-form-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.add-rabbit-breeding-status.hidden {
  display: none;
}

.doe-breeding-status-form {
  margin: 0.75rem 0 0;
}

.doe-breeding-status-form label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
}

.doe-breeding-status-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.doe-breeding-status-row select {
  flex: 1 1 160px;
}

.life-stage-form {
  margin: 0.75rem 0 0;
}

.life-stage-form label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
}

.life-stage-form-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.life-stage-form-row select {
  flex: 1 1 160px;
}

.temperament-form {
  margin: 0.5rem 0;
}

.temperament-form label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
}

.temperament-form-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.temperament-form-row select {
  flex: 1 1 160px;
}

.dob-form {
  margin: 0.5rem 0;
}

.dob-form label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
}

.dob-form-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.dob-form-row input[type="date"] {
  flex: 1 1 160px;
}

.rabbit-dates-row {
  margin: 0.5rem 0 0;
}

.rabbit-dates-field {
  margin: 0;
}

.rabbit-dates-field label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
}

.rabbit-dates-field input[type="date"] {
  width: 100%;
  box-sizing: border-box;
}

.rabbit-dates-hint {
  margin: 0.35rem 0 0.5rem;
}

.birth-litter-form {
  margin: 0.5rem 0;
}

.birth-litter-form > label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
}

.birth-litter-form-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.birth-litter-field {
  flex: 0 0 auto;
}

.birth-litter-field .sub-label {
  display: block;
  margin-bottom: 0.15rem;
  font-size: 0.75rem;
  color: var(--muted, #5c6670);
}

.birth-litter-field input[type="number"] {
  width: 5rem;
  max-width: 100%;
}

.birth-litter-form-row .btn {
  margin-left: auto;
}

.rabbit-history-header,
.rabbit-profile-section-header {
  margin-top: 1.25rem;
}

.rabbit-section-toggle {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  text-align: left;
}

.rabbit-section-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.3;
}

.rabbit-section-toggle-icon {
  font-size: 0.72rem;
  color: var(--muted);
  flex-shrink: 0;
  width: 1rem;
  text-align: center;
  line-height: 1;
}

.rabbit-section-toggle:hover .rabbit-section-toggle-icon,
.rabbit-section-toggle:focus-visible .rabbit-section-toggle-icon {
  color: var(--text);
}

.rabbit-section-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.rabbit-profile-section-body {
  margin-top: 0.35rem;
}

.rabbit-profile-section-body.hidden {
  display: none;
}

.rabbit-detail-topbar {
  margin: -0.25rem 0 0.75rem;
}

.rabbit-detail-topbar.page-header {
  margin-bottom: 0.75rem;
}

.rabbit-detail-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.rabbit-detail-info {
  min-width: 0;
}

.rabbit-detail-title {
  margin: 0;
}

.rabbit-detail-title-input {
  margin: 0;
  min-width: 0;
  width: 100%;
  font: inherit;
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.25;
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--btn-radius);
  padding: 0.15rem 0.35rem;
}

.rabbit-detail-title-input:hover,
.rabbit-detail-title-input:focus {
  border-color: var(--border);
  background: var(--surface);
  outline: none;
}

.rabbit-profile-save-btn.hidden {
  display: none;
}

.rabbit-profile-form-sink {
  display: none;
}

.rabbit-inactive-notice {
  margin: 0 0 0.75rem;
}

.rabbit-loan-return {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1rem;
}

.rabbit-loan-return .rabbit-inactive-notice {
  margin: 0;
}

.rabbit-rename-form {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}

.rabbit-rename-form input {
  width: 100%;
  max-width: 24rem;
}

#rabbit-detail:not(:empty) {
  margin-bottom: 1rem;
}

.rabbit-age-label {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
}

.rabbit-timeline {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  border-left: 2px solid var(--border);
}

.breeding-datetime-row input[type="time"] {
  min-width: 8.5rem;
}

.breeding-list-table th:last-child,
.breeding-list-table td.table-actions {
  width: 2.75rem;
  text-align: right;
  white-space: nowrap;
}

.breeding-list-table tr.breeding-list-row-success td {
  background: rgba(30, 58, 95, 0.14);
}

.breeding-list-table tr.breeding-list-row-failed td {
  background: rgba(199, 80, 80, 0.12);
}

.breeding-list-table tr.breeding-list-row-success:hover td {
  background: rgba(30, 58, 95, 0.22);
}

.breeding-list-table tr.breeding-list-row-failed:hover td {
  background: rgba(199, 80, 80, 0.18);
}

.breeding-list-table td.table-actions .btn {
  padding: 0.35rem 0.5rem;
}

.breeding-notes-cell {
  max-width: 16rem;
  font-size: 0.9rem;
}

.breeding-note-line + .breeding-note-line {
  margin-top: 0.35rem;
}

.breeding-notes-row textarea {
  min-height: 4rem;
}

.breeding-completed-table .breeding-summary-cell {
  font-size: 0.95rem;
}

.breeding-detail-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.breeding-detail-modal-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  padding: 0;
  margin: 0;
  background: rgba(31, 42, 36, 0.45);
  cursor: default;
}

.breeding-detail-modal-panel {
  position: relative;
  z-index: 1;
  width: min(520px, calc(100% - 2rem));
  max-height: min(85vh, 640px);
  overflow: auto;
  margin: 0;
}

.breeding-detail-modal-close {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.breeding-detail-dl {
  display: grid;
  gap: 0.65rem 1rem;
  margin: 0 0 1rem;
}

.breeding-detail-dl > div {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 0.5rem 1rem;
  align-items: start;
}

.breeding-detail-dl dt {
  margin: 0;
  font-weight: 600;
  color: var(--muted);
}

.breeding-detail-dl dd {
  margin: 0;
}

.breeding-detail-notes h4 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.breeding-detail-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0;
}

.pairing-history-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}

.pairing-history-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.pairing-history-item:last-child {
  border-bottom: none;
}

.pairing-note {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
}

.rabbit-timeline-item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.5rem 0 0.5rem 0.75rem;
  margin-left: 0.35rem;
  position: relative;
}

.rabbit-timeline-item .rabbit-timeline-delete {
  margin-left: auto;
}

.rabbit-timeline-item::before {
  content: "";
  position: absolute;
  left: -0.45rem;
  top: 0.85rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
}

.rabbit-timeline-item.type-health::before {
  background: var(--danger);
}

.rabbit-timeline-item.type-mated::before,
.rabbit-timeline-item.type-kindled::before,
.rabbit-timeline-item.type-born::before {
  background: var(--accent-dark);
}

.rabbit-timeline-date {
  flex: 0 0 6.5rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.rabbit-timeline-body {
  flex: 1 1 auto;
  min-width: 0;
}

.rabbit-timeline-summary {
  font-size: 0.92rem;
}

.rabbit-timeline-details {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
}

.rabbit-timeline-delete {
  flex-shrink: 0;
  padding: 0.1rem 0.45rem;
  line-height: 1.2;
  font-size: 1.1rem;
}

.add-history-form textarea {
  width: 100%;
  min-height: 3rem;
}

.weight-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  height: 5rem;
  margin: 0.5rem 0 0.75rem;
  padding: 0.5rem 0.25rem 0;
  border-bottom: 1px solid var(--border);
}

.weight-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  min-width: 0;
}

.weight-bar {
  width: 100%;
  max-width: 2.5rem;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  min-height: 4px;
}

.weight-bar-label {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.weight-trend-summary {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}

.weight-trend-summary.up,
.weight-change.up {
  color: #2d6a3e;
}

.weight-trend-summary.down,
.weight-change.down {
  color: #a33;
}

.weight-table td {
  vertical-align: middle;
}

.weight-form .row {
  gap: 1rem;
}

.farm-rules-list {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

.farm-rules-list li {
  margin: 0.25rem 0;
}

.farm-rules-form .farm-rules-field {
  margin-bottom: 1rem;
}

.farm-rules-field-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 12rem;
}

.farm-rules-field-row input {
  flex: 1;
}

.farm-rules-hint {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
}

.network-loans-subhead {
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
}

.network-loans-subhead:first-of-type {
  margin-top: 0.5rem;
}

.network-loans-table {
  margin-bottom: 0.25rem;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.calendar-title {
  margin: 0;
  font-size: 1.15rem;
  text-align: center;
  flex: 1;
}

.cal-grid-head {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25rem;
  margin-bottom: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25rem;
}

.cal-cell {
  min-height: 3.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  padding: 0.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.cal-cell-empty {
  border: none;
  background: transparent;
  min-height: 0;
}

.cal-cell:hover:not(.cal-cell-empty) {
  border-color: var(--accent);
}

.cal-today {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.cal-selected:not(.cal-day-cycle) {
  background: rgba(30, 58, 95, 0.12);
  border-color: var(--accent-dark);
}

.cal-cell.cal-day-mated:not(.cal-day-cycle) {
  background: rgba(30, 58, 95, 0.22);
  border-color: var(--accent-dark);
}

.cal-cell.cal-day-cycle {
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

.cal-cell.cal-day-cycle-2 {
  animation-duration: 4s;
}

.cal-cell.cal-day-cycle-3 {
  animation-duration: 6s;
}

.cal-cell.cal-day-cycle.cal-selected {
  box-shadow: inset 0 0 0 2px var(--accent-dark);
}

@keyframes cal-hl-cycle-health-due-expected-kindle {
  0%,
  49.999% {
    background-color: rgba(199, 80, 80, 0.2);
    border-color: #c75050;
  }
  50%,
  100% {
    background-color: rgba(122, 90, 199, 0.24);
    border-color: #7a5ac7;
  }
}

@keyframes cal-hl-cycle-health-due-mated {
  0%,
  49.999% {
    background-color: rgba(199, 80, 80, 0.2);
    border-color: #c75050;
  }
  50%,
  100% {
    background-color: rgba(30, 58, 95, 0.22);
    border-color: var(--accent-dark);
  }
}

@keyframes cal-hl-cycle-expected-kindle-mated {
  0%,
  49.999% {
    background-color: rgba(122, 90, 199, 0.24);
    border-color: #7a5ac7;
  }
  50%,
  100% {
    background-color: rgba(30, 58, 95, 0.22);
    border-color: var(--accent-dark);
  }
}

@keyframes cal-hl-cycle-health-due-expected-kindle-mated {
  0%,
  33.332% {
    background-color: rgba(199, 80, 80, 0.2);
    border-color: #c75050;
  }
  33.333%,
  66.666% {
    background-color: rgba(122, 90, 199, 0.24);
    border-color: #7a5ac7;
  }
  66.667%,
  100% {
    background-color: rgba(30, 58, 95, 0.22);
    border-color: var(--accent-dark);
  }
}

.cal-cell.cal-day-cycle-2.cal-day-cycle-health-due-expected-kindle {
  animation-name: cal-hl-cycle-health-due-expected-kindle;
}

.cal-cell.cal-day-cycle-2.cal-day-cycle-health-due-mated {
  animation-name: cal-hl-cycle-health-due-mated;
}

.cal-cell.cal-day-cycle-2.cal-day-cycle-expected-kindle-mated {
  animation-name: cal-hl-cycle-expected-kindle-mated;
}

.cal-cell.cal-day-cycle-3.cal-day-cycle-health-due-expected-kindle-mated {
  animation-name: cal-hl-cycle-health-due-expected-kindle-mated;
}

@media (prefers-reduced-motion: reduce) {
  .cal-cell.cal-day-cycle {
    animation: none;
  }

  .cal-cell.cal-day-cycle-2.cal-day-cycle-health-due-expected-kindle {
    background-color: rgba(199, 80, 80, 0.2);
    border-color: #c75050;
  }

  .cal-cell.cal-day-cycle-2.cal-day-cycle-health-due-mated {
    background-color: rgba(199, 80, 80, 0.2);
    border-color: #c75050;
  }

  .cal-cell.cal-day-cycle-2.cal-day-cycle-expected-kindle-mated {
    background-color: rgba(122, 90, 199, 0.24);
    border-color: #7a5ac7;
  }

  .cal-cell.cal-day-cycle-3.cal-day-cycle-health-due-expected-kindle-mated {
    background-color: rgba(199, 80, 80, 0.2);
    border-color: #c75050;
  }
}

.cal-cell.cal-day-expected-kindle:not(.cal-day-cycle) {
  background: rgba(122, 90, 199, 0.24);
  border-color: #7a5ac7;
}

.cal-cell.cal-day-health-due:not(.cal-day-cycle) {
  background: rgba(199, 80, 80, 0.2);
  border-color: #c75050;
}

.cal-cell.cal-day-mated.cal-selected:not(.cal-day-cycle) {
  background: rgba(30, 58, 95, 0.3);
  border-color: var(--accent-dark);
}

.cal-cell.cal-day-expected-kindle.cal-selected:not(.cal-day-cycle) {
  background: rgba(122, 90, 199, 0.32);
  border-color: #6a4ab7;
}

.cal-cell.cal-day-health-due.cal-selected:not(.cal-day-cycle) {
  background: rgba(199, 80, 80, 0.28);
  border-color: #b54545;
}

.cal-day-num {
  font-size: 0.85rem;
  font-weight: 600;
}

.cal-dots {
  display: flex;
  gap: 2px;
  margin-top: 0.2rem;
  flex-wrap: wrap;
  justify-content: center;
}

.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.cal-dot.type-mated {
  background: #5a7fc7;
}

.cal-dot.type-mated-successful {
  background: var(--accent-dark);
}

.cal-dot.type-expected_kindle {
  background: #7a5ac7;
}

.cal-dot.type-kindled {
  background: #c75a8a;
}

.cal-dot.type-born {
  background: #7a5ac7;
}

.cal-dot.type-weight {
  background: #8a6a3d;
}

.cal-dot.type-health,
.cal-dot.type-health_followup {
  background: #c75050;
}

.cal-dot.type-water_reading {
  background: #2196f3;
}

.cal-dot.type-mortality,
.cal-dot.type-brood_failed {
  background: var(--danger, #c75050);
}

.cal-dot.type-brood,
.cal-dot.type-brood_hatched {
  background: #8bc34a;
}

.cal-dot.type-stock_transfer {
  background: #ff9800;
}

.cal-dot.type-stock_added {
  background: #4caf50;
}

.cal-dot.type-task_due {
  background: #c9a227;
}

.cal-dot.type-task_completed {
  background: #607d8b;
}

.cal-day-mortality {
  outline: 2px solid color-mix(in srgb, var(--danger, #c75050) 55%, transparent);
}

.cal-day-task-due {
  outline: 2px solid color-mix(in srgb, #c9a227 55%, transparent);
}

.cal-day-brood-hatched {
  outline: 2px solid color-mix(in srgb, #8bc34a 55%, transparent);
}

.cal-event-meta {
  display: block;
  font-size: 0.85rem;
  margin-top: 0.15rem;
}

.cal-day-detail {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.cal-day-detail h4 {
  margin: 0 0 0.75rem;
}

.cal-event-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cal-event-item {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.cal-event-item:last-child {
  border-bottom: none;
}

.cal-event-type {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-right: 0.5rem;
}

.cal-event-summary {
  font-weight: 500;
}

.cal-event-rabbit {
  margin-left: 0.5rem;
  padding: 0.1rem 0.45rem;
  font-size: 0.8rem;
}

.cal-event-details {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
}

.table-actions {
  white-space: nowrap;
}

.table-actions .btn {
  margin-right: 0.35rem;
}

.table-actions .action-menu-wrap {
  display: inline-flex;
  vertical-align: middle;
  margin-left: 0;
}

.rabbits-table th:nth-child(1),
.rabbits-table td:nth-child(1) {
  width: 1%;
  padding-right: 0.65rem;
  vertical-align: top;
}

.rabbits-table-photo-col {
  width: 1%;
}

.rabbit-list-details-col {
  width: auto;
}

.rabbit-list-details-col .rabbit-sort-heading + .rabbit-sort-heading {
  margin-left: 1rem;
}

.rabbit-list-details-cell {
  vertical-align: top;
  width: 100%;
}

.rabbit-list-name {
  font-weight: 500;
  line-height: 1.2;
}

.rabbit-list-breed {
  margin-top: 0.15rem;
  font-size: 0.85rem;
  color: var(--muted, #7a7268);
  line-height: 1.2;
}

.rabbit-list-status {
  margin-top: 0.2rem;
  font-size: 0.85rem;
  line-height: 1.2;
  color: var(--text, #1f2a24);
}

.rabbit-sort-heading {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.rabbit-sort-btn {
  border: none;
  background: transparent;
  padding: 0.1rem 0.15rem;
  line-height: 1;
  cursor: pointer;
  color: #d4cdc2;
  vertical-align: middle;
}

.rabbit-sort-btn:hover {
  color: #a8a095;
}

.rabbit-sort-btn-active {
  color: var(--accent);
}

.rabbit-sort-btn-active:hover {
  color: var(--accent-dark);
}

.rabbit-sort-icon {
  display: block;
  font-size: 0.65rem;
}

.sex-symbol {
  display: inline-block;
  min-width: 1.25rem;
}

.rabbit-stock-leave-wrap {
  position: relative;
}

.rabbit-stock-leave-wrap .action-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.25rem);
  z-index: 50;
  margin-top: 0;
  width: min(260px, calc(100vw - 2rem));
}

.rabbit-detail-topbar .page-header-actions {
  grid-column: 2;
  grid-row: 1;
}

.table-actions .btn:last-child {
  margin-right: 0;
}

.cages-list-table th:not(:first-child),
.cages-list-table td:not(:first-child) {
  text-align: center;
}

.cages-list-table .cage-rabbits-cell {
  justify-content: center;
  max-width: none;
  margin: 0 auto;
}

.cages-list-table .table-actions {
  width: 3.5rem;
  text-align: center;
  white-space: nowrap;
}

.cage-list-actions-wrap {
  display: inline-flex;
  justify-content: center;
  margin-left: 0;
}

.cage-list-actions-menu {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 30;
  min-width: 8.5rem;
  margin-top: 0.25rem;
}

.tank-list-actions .action-menu-wrap:has(.action-menu:not(.hidden)),
.stock-species-actions .action-menu-wrap:has(.action-menu:not(.hidden)) {
  flex: none;
  align-items: flex-end;
}

.tank-list-actions .action-menu-wrap:has(.action-menu:not(.hidden)) .action-menu,
.stock-species-actions .action-menu-wrap:has(.action-menu:not(.hidden)) .action-menu {
  width: auto;
  min-width: 8.5rem;
}

.cage-list-actions-menu .page-header-menu-item {
  display: block;
  width: 100%;
  text-align: left;
}

.cage-rabbits-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  max-width: 12rem;
}

.cage-rabbit-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  background: #e8e2d7;
  flex-shrink: 0;
}

.cage-rabbits-cell-over .cage-rabbit-thumb {
  box-shadow: 0 0 0 2px var(--warn);
}

.team-table select {
  min-width: 6rem;
}

.team-member-self td {
  background: rgba(30, 58, 95, 0.06);
}

.layout-cage-detail h3 {
  margin: 0 0 0.35rem;
}

.layout-cage-view {
  cursor: pointer;
}

.layout-cage-view:hover {
  border-color: var(--accent-dark);
  box-shadow: 0 4px 14px rgba(31, 42, 36, 0.12);
}

.layout-cage-view.selected {
  outline: 3px solid var(--accent-dark);
  outline-offset: 1px;
}

.layout-grid.view-mode .layout-cage.layout-cage-locate-highlight {
  overflow: visible;
  z-index: 30;
}

.layout-cage.layout-cage-locate-highlight {
  background: rgba(30, 58, 95, 0.42) !important;
  border-color: var(--accent-dark) !important;
  outline: 3px solid var(--accent-dark);
  outline-offset: 1px;
  box-shadow:
    0 0 0 2px rgba(30, 58, 95, 0.45),
    0 0 16px rgba(30, 58, 95, 0.35);
  z-index: 30;
  animation: layout-cage-locate-glow 2.55s ease-in-out infinite;
}

.layout-cage-locate-pulse {
  position: absolute;
  inset: -3px;
  border: 2px solid var(--accent-dark);
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  animation: layout-cage-locate-radar 2.55s cubic-bezier(0.15, 0.5, 0.35, 1) infinite;
}

@keyframes layout-cage-locate-radar {
  0% {
    transform: scale(1);
    opacity: 0.9;
  }
  65%,
  100% {
    transform: scale(3.2);
    opacity: 0;
  }
}

@keyframes layout-cage-locate-glow {
  0%,
  100% {
    box-shadow:
      0 0 0 2px rgba(30, 58, 95, 0.45),
      0 0 14px rgba(30, 58, 95, 0.35);
  }
  50% {
    box-shadow:
      0 0 0 5px rgba(30, 58, 95, 0.55),
      0 0 24px rgba(30, 58, 95, 0.55);
  }
}

.layout-cage-rabbit-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.layout-cage-rabbit-item:last-child {
  border-bottom: none;
}

.action-menu-wrap {
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-left: auto;
}

.action-menu-wrap:has(.action-menu:not(.hidden)) {
  flex: 1 1 100%;
  align-items: stretch;
}

.action-menu-wrap:has(.action-menu:not(.hidden)) .action-menu {
  width: 100%;
}

.action-menu {
  width: min(100%, 260px);
  margin-top: 0.35rem;
  padding: 0.35rem 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.action-menu-title {
  margin: 0;
  padding: 0.35rem 0.75rem 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.action-menu-item {
  display: block;
  width: 100%;
  padding: 0.45rem 0.75rem;
  border: none;
  background: none;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.action-menu-item:hover:not(:disabled) {
  background: rgba(30, 58, 95, 0.1);
}

.action-menu-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.action-menu-divider {
  height: 1px;
  margin: 0.35rem 0;
  background: var(--border);
}

.action-menu-sub {
  padding: 0.5rem 0.75rem 0.35rem;
  border-top: 1px solid var(--border);
}

.action-menu-sub label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
}

.action-menu-sub select {
  width: 100%;
  margin-bottom: 0.5rem;
}

.action-menu-sub-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.layout-rabbit-thumb-btn {
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 8px;
}

.layout-rabbit-thumb-btn:hover .layout-rabbit-thumb,
.layout-rabbit-thumb-btn:focus-visible .layout-rabbit-thumb {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
}

.layout-rabbit-thumb-btn:focus-visible {
  outline: none;
}

.layout-rabbit-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.health-finding {
  margin-top: 0.25rem;
  font-size: 0.9rem;
  max-width: 16rem;
}

.health-closed-date {
  font-size: 0.8rem;
  margin-top: 0.15rem;
}

.health-issues-closed-heading {
  margin-top: 1.5rem;
}

.health-close-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.health-close-modal-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  padding: 0;
  margin: 0;
  background: rgba(31, 42, 36, 0.45);
  cursor: default;
}

.health-close-modal-panel {
  position: relative;
  z-index: 1;
  width: min(440px, calc(100% - 2rem));
  max-height: min(85vh, 520px);
  overflow: auto;
  margin: 0;
}

.tank-ideal-water-modal-panel {
  width: min(640px, calc(100% - 2rem));
  max-height: min(90vh, 720px);
}

.ideal-water-section-title {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-dark);
}

.ideal-water-by-species-title {
  margin-top: 1.25rem;
}

.ideal-water-table {
  width: 100%;
  margin-bottom: 0.5rem;
}

.ideal-water-table th {
  width: 42%;
  font-weight: 600;
  color: var(--muted);
  padding: 0.35rem 0.5rem 0.35rem 0;
  vertical-align: top;
}

.ideal-water-table td {
  padding: 0.35rem 0;
  font-variant-numeric: tabular-nums;
}

.ideal-water-table tr.ideal-water-param-conflict td {
  color: var(--danger);
  font-weight: 600;
}

.ideal-water-conflicts {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.ideal-water-species-block {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.ideal-water-species-block:first-of-type {
  margin-top: 0.5rem;
}

.ideal-water-species-name {
  margin: 0 0 0.45rem;
  font-size: 0.92rem;
  font-weight: 700;
}

.ideal-water-species-list {
  margin: 0.75rem 0 0;
  padding-left: 1.1rem;
}

.ideal-water-no-data {
  margin: 0;
  font-size: 0.9rem;
}

.ideal-water-notes {
  margin: 0.5rem 0 0;
  font-size: 0.88rem;
  line-height: 1.45;
}

.water-conditions-recorded {
  margin: 0 0 0.75rem;
}

.water-compare-table th,
.water-compare-table td {
  width: 33%;
}

.water-compare-table tr.water-compare-warn td:first-of-type {
  border-left: 3px solid var(--warn, #c9a227);
}

.water-compare-table tr.water-compare-warn td:nth-child(2) {
  color: var(--warn-text, #8a6116);
  font-weight: 600;
}

.tank-remove-fish-mortality {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border, #ddd);
}

.mortality-log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.mortality-log-table th,
.mortality-log-table td {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border, #eee);
  vertical-align: top;
}

.mortality-log-table .mortality-log-qty {
  text-align: center;
  font-weight: 600;
}

.mortality-log-notes {
  font-size: 0.82rem;
  color: var(--muted, #666);
  margin-top: 0.2rem;
}

.water-suggestions-panel {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border, #ddd);
}

.water-suggestions-intro {
  margin: 0 0 0.75rem;
}

.water-suggestions-summary {
  margin: 0 0 0.75rem;
}

.water-suggestions-steps {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

.water-suggestions-steps li {
  margin-bottom: 0.75rem;
}

.water-suggestions-steps p {
  margin: 0.25rem 0 0;
}

.water-suggestions-caution {
  margin: 0.75rem 0 0;
}

.find-rabbit-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.find-rabbit-modal.hidden {
  display: none;
}

.find-rabbit-modal-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  padding: 0;
  margin: 0;
  background: rgba(31, 42, 36, 0.45);
  cursor: default;
}

.find-rabbit-modal-panel {
  position: relative;
  z-index: 1;
  width: min(480px, calc(100% - 2rem));
  max-height: min(85vh, 560px);
  overflow: auto;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.find-rabbit-modal-close {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: var(--btn-radius);
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
}

.find-rabbit-search-label {
  display: block;
  font-size: 0.9rem;
}

.find-rabbit-search {
  width: 100%;
  box-sizing: border-box;
}

.find-rabbit-results {
  min-height: 2rem;
}

.find-rabbit-hint,
.find-rabbit-more {
  margin: 0;
  font-size: 0.9rem;
}

.find-rabbit-results-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.find-rabbit-result {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--btn-radius);
  background: var(--surface);
  padding: 0.45rem 0.55rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.find-rabbit-result:hover,
.find-rabbit-result:focus {
  border-color: var(--primary);
  background: var(--surface-alt, #f8f9fa);
  outline: none;
}

.find-rabbit-result-photo {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-alt, #eee);
}

.find-rabbit-result-body {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.find-rabbit-result-name {
  font-size: 0.95rem;
}

.find-rabbit-result-meta {
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rabbit-photo-analysis-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.rabbit-photo-analysis-modal.hidden {
  display: none;
}

.rabbit-photo-analysis-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  padding: 0;
  margin: 0;
  background: rgba(31, 42, 36, 0.45);
  cursor: default;
}

.rabbit-photo-analysis-panel {
  position: relative;
  z-index: 1;
  width: min(440px, calc(100% - 2rem));
  max-height: min(85vh, 520px);
  overflow: auto;
  margin: 0;
}

.rabbit-photo-analysis-close {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: var(--btn-radius);
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
}

.rabbit-photo-analysis-intro {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}

.rabbit-photo-analysis-results {
  margin: 0;
  display: grid;
  gap: 0.65rem;
}

.rabbit-photo-analysis-results div {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0.5rem;
  align-items: baseline;
}

.rabbit-photo-analysis-results dt {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.rabbit-photo-analysis-results dd {
  margin: 0;
  font-weight: 600;
}

.rabbit-photo-analysis-notes {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
}

.rabbit-photo-analysis-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.recommended-bucks-modal {
  position: fixed;
  inset: 0;
  z-index: 420;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.recommended-bucks-modal.hidden {
  display: none;
}

.recommended-bucks-modal-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  padding: 0;
  margin: 0;
  background: rgba(31, 42, 36, 0.45);
  cursor: default;
}

.recommended-bucks-modal-panel {
  position: relative;
  z-index: 1;
  width: min(640px, calc(100% - 2rem));
  max-height: min(88vh, 780px);
  margin: 0;
  margin-bottom: 0;
  padding: 1.1rem 1.15rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: hidden;
}

.recommended-bucks-modal-close {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: var(--btn-radius);
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
}

.recommended-bucks-modal-head {
  flex: 0 0 auto;
  padding-right: 2.5rem;
}

.recommended-bucks-modal-head h3 {
  margin: 0 0 0.35rem;
}

.recommended-bucks-modal-subtitle {
  margin: 0 0 0.65rem;
}

.recommended-bucks-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}

.recommended-bucks-toggle input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  min-width: 1rem;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
  cursor: pointer;
}

.recommended-bucks-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.15rem;
}

.recommended-bucks-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.recommended-buck-card {
  border: 1px solid var(--border);
  border-radius: var(--btn-radius);
  padding: 0.85rem 0.9rem;
  background: var(--surface);
}

.recommended-buck-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.recommended-buck-card-header-left {
  min-width: 0;
  flex: 1 1 auto;
}

.recommended-buck-name {
  display: block;
  font-size: 1.05rem;
  line-height: 1.25;
}

.recommended-buck-farm {
  margin-top: 0.2rem;
  font-size: 0.85rem;
  line-height: 1.35;
}

.recommended-buck-score-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  flex-shrink: 0;
}

.recommended-buck-score {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
}

.buck-rec-label {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

.buck-rec-label-best {
  background: #d4edda;
  color: #155724;
}

.buck-rec-label-good {
  background: #d1ecf1;
  color: #0c5460;
}

.buck-rec-label-caution {
  background: #fff3cd;
  color: #856404;
}

.buck-rec-label-avoid {
  background: #f8d7da;
  color: #721c24;
}

.recommended-buck-meta {
  margin-bottom: 0.65rem;
}

.recommended-buck-meta > div {
  grid-template-columns: 7.5rem 1fr;
}

.recommended-buck-reasons {
  margin: 0 0 0.75rem;
  padding-left: 1.15rem;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.recommended-buck-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.recommended-buck-actions .btn {
  width: auto;
}

.recommended-bucks-modal-footer {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border);
}

.recommended-bucks-modal-footer .btn {
  width: auto;
}

@media (max-width: 700px) {
  .topbar-farm {
    white-space: normal;
  }

  .rabbit-list-thumb-btn {
    width: 72px;
    height: 72px;
  }

  .rabbit-list-photo-sex {
    min-width: 1.25rem;
    height: 1.25rem;
    font-size: 0.78rem;
  }

  .rabbits-table td,
  .rabbits-table th {
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
  }

  .rabbit-detail-body {
    gap: 1rem;
  }

  .rabbit-photo-section {
    width: 100%;
    max-width: none;
    flex: none;
  }

  .rabbit-photo-current,
  .rabbit-photo-placeholder {
    width: 100%;
    max-width: none;
    max-height: min(85vw, 420px);
    margin: 0 auto;
  }

  .rabbit-camera-panel {
    max-width: none;
    width: 100%;
  }
}

@media (min-width: 701px) {
  .rabbit-detail-body {
    flex-direction: row;
    align-items: flex-start;
  }

  .rabbit-detail-info {
    flex: 1 1 auto;
  }
}

.water-chart-wrap {
  margin-top: 0.5rem;
}

.water-chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 120px;
  padding: 0.5rem;
  background: var(--surface-2, rgba(0, 0, 0, 0.04));
  border-radius: 6px;
}

.water-chart-bar {
  flex: 1 1 4px;
  min-width: 4px;
  max-width: 12px;
  background: var(--accent, #1e3a5f);
  border-radius: 2px 2px 0 0;
  opacity: 0.85;
}

.species-image-picker {
  margin-top: 0.75rem;
}

.species-image-picker-intro {
  margin: 0 0 0.75rem;
  font-size: 0.92rem;
}

.species-image-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.species-image-picker-option {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  padding: 0.5rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface, #fffdf8);
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.species-image-picker-option:hover,
.species-image-picker-option:focus-visible {
  border-color: var(--accent, #1e3a5f);
  outline: none;
}

.species-image-picker-option.is-selected {
  border-color: var(--accent, #1e3a5f);
  box-shadow: 0 0 0 2px rgba(30, 58, 95, 0.15);
}

.species-image-picker-option:disabled {
  opacity: 0.7;
  cursor: wait;
}

.species-image-picker-option img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  background: #f5f1ea;
}

.species-image-picker-label {
  font-size: 0.82rem;
  line-height: 1.25;
  font-weight: 600;
}

.species-image-picker-source {
  font-size: 0.75rem;
}

.species-image-picker-actions {
  margin-top: 0.75rem;
}

@media (max-width: 700px) {
  #add-species-card form,
  #edit-species-card form {
    padding-bottom: 1.5rem;
  }

  [data-species-form-save] {
    min-height: 2.75rem;
  }
}

.grid.stats {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin-bottom: 1rem;
}

.stat {
  font-size: 1.75rem;
  font-weight: 650;
  margin-top: 0.25rem;
}

.form-grid {
  display: grid;
  gap: 0.75rem 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-grid [hidden] {
  display: none !important;
}

.form-grid textarea {
  min-height: 4rem;
}

.form-grid .checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.form-grid .stock-cost-help,
.form-grid .stock-cost-board,
.form-grid .stock-measure-actions,
.form-grid .stock-measure-note,
.form-grid .stock-custom-measures,
.form-grid .stock-production-extras {
  grid-column: 1 / -1;
}

.stock-production-extras h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.custom-measure-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0.5rem 0;
}

.custom-measure-row {
  display: grid;
  grid-template-columns: minmax(7rem, 1fr) auto minmax(5.5rem, 0.7fr) minmax(6.5rem, 0.8fr) auto;
  gap: 0.45rem;
  align-items: end;
}

.production-extra-row {
  display: grid;
  grid-template-columns: minmax(10rem, 1.4fr) minmax(5.5rem, 0.7fr) minmax(6.5rem, 0.8fr) auto;
  gap: 0.45rem;
  align-items: end;
}

.stock-cost-board {
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
}

.stock-measure-table {
  margin: 0;
}

.stock-measure-table th,
.stock-measure-table td {
  white-space: nowrap;
}

.ing-head,
.ing-row {
  display: grid;
  grid-template-columns: minmax(14rem, 1.8fr) 4.5rem 7.2rem 5.5rem 6.5rem auto;
  gap: 0.45rem;
  margin-bottom: 0.45rem;
  align-items: center;
}
.ing-row-custom {
  grid-template-columns: minmax(12rem, 1.3fr) minmax(7rem, 1fr) 4.5rem 7.2rem 5.5rem 6.5rem auto;
}
.ing-head {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.ing-row select { min-width: 0; width: 100%; }
.ing-line-cost { font-size: 0.82rem; white-space: nowrap; }

.portions-block {
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}

.packaging-block {
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}

.packaging-block h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.portions-block h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.feeds-block,
.yield-block {
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}

.feeds-block h3,
.yield-block h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.profit-box {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.profit-box strong { display: block; font-size: 1.15rem; }

.menu-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.media-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.media-thumbs figure { margin: 0; width: 120px; }
.media-thumbs img { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; display: block; }
.media-thumb-btn {
  display: block;
  width: 100%;
  padding: 0;
  margin: 0 0 0.35rem;
  border: 0;
  background: none;
  cursor: zoom-in;
  border-radius: 8px;
  line-height: 0;
}
.media-thumb-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.menu-list-thumb .menu-thumb { margin: 0; }
.menu-video { width: min(100%, 420px); max-height: 240px; border-radius: 10px; }

.photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.photo-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(22, 12, 8, 0.78);
}
.photo-lightbox-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: 96vw;
  max-height: 92vh;
}
.photo-lightbox-panel img {
  display: block;
  max-width: 96vw;
  max-height: calc(92vh - 3rem);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  background: #1a100c;
}

.menu-list-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.85rem;
}
.menu-list-filter {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}
.menu-list-filter:hover {
  border-color: var(--accent);
}
.menu-list-filter.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff8f2;
}
.menu-row-actions {
  white-space: nowrap;
  text-align: right;
}
.menu-row-actions-inner {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  justify-content: flex-end;
  vertical-align: middle;
}

.combo-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
  margin: 0.85rem 0 0;
  background: var(--bg);
}
.combo-card .checkbox-label { margin-bottom: 0.5rem; }
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
  margin-bottom: 0.75rem;
  background: var(--bg);
}
.choice-group-fields {
  display: grid;
  grid-template-columns: minmax(8rem, 1fr) 8rem minmax(10rem, 1.2fr) auto;
  gap: 0.6rem;
  align-items: end;
}
.choice-group-fields label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.choice-option-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 0.35rem 0.75rem;
  margin-top: 0.75rem;
}
.choice-or-hint {
  margin: 0.45rem 0 0.35rem;
  font-size: 0.82rem;
}
.choice-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
}
@media (max-width: 900px) {
  .ing-head { display: none; }
  .ing-row { grid-template-columns: 1fr 1fr; }
  .choice-group-fields { grid-template-columns: 1fr 1fr; }
}

.indicator-heading { margin: 1rem 0 0.35rem; font-size: 1rem; }
.indicator-group {
  border: 0;
  padding: 0;
  margin: 0.75rem 0 0;
}
.indicator-group legend {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 0;
}
.indicator-pick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.35rem;
}
.indicator-opt {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.88rem;
}
.indicator-opt:has(input:checked) {
  border-color: var(--accent);
  background: rgba(139, 69, 19, 0.08);
}
.ind-row {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.28rem;
  margin-left: 0.4rem;
  vertical-align: middle;
}
.ind {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ind-svg {
  width: 1.15rem;
  height: 1.15rem;
}
.ind-svg path:not([fill="none"]) {
  fill: currentColor;
}
.ind-svg [stroke] {
  stroke: currentColor;
}
.ind-heat_mild { color: #2f9e44; }
.ind-heat_medium { color: #d99212; }
.ind-heat_hot { color: #d64532; }
.ind-heat_fire { color: #9b1c1c; }
.ind-beef { color: #8b5a2b; }
.ind-pork { color: #c46b7a; }
.ind-chicken { color: #c9a227; }
.ind-lamb { color: #9a8b78; }
.ind-fish { color: #3d8ebd; }
.ind-game { color: #6b4a2b; }
.ind-carnivore { color: #9a5c38; }
.ind-vegetarian { color: #4cae50; }
.ind-vegan { color: #2d8a3e; }
.ind-gluten_free { color: #c4a35a; }
.ind-dairy { color: #6b7c93; }
.ind-nuts { color: #b86a2b; }



