/* =========================================================
   Tokens
   ========================================================= */
:root {
  color-scheme: light;
  --bg: #f5f3f0;
  --surface: #ffffff;
  --surface-2: #faf8f6;
  --surface-3: #f1ede9;
  --border: #e7e1db;
  --border-strong: #d6cec6;
  --text: #1d1917;
  --text-2: #4a433f;
  --muted: #847a73;

  --brand: #8a1c2b;
  --brand-hover: #74141f;
  --brand-soft: #f7e8ea;
  --brand-ink: #7a1424;
  --bar-1: #7c0f1d;
  --bar-2: #9a2432;

  --green: #2f7a4f;  --green-bg: #e5f3ea;
  --amber: #a5620a;  --amber-bg: #fcf0dc;
  --red: #b42318;    --red-bg: #fde8e6;
  --blue: #2d5fa8;   --blue-bg: #e6eefb;
  --violet: #6b46b8; --violet-bg: #efe9fb;
  --teal: #13737a;   --teal-bg: #e0f3f3;
  --pink: #b03a76;   --pink-bg: #fbe6f0;
  --gray: #6b625c;   --gray-bg: #efebe7;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgb(40 20 15 / .05);
  --shadow: 0 1px 2px rgb(40 20 15 / .04), 0 4px 16px rgb(40 20 15 / .06);
  --shadow-lg: 0 24px 64px rgb(30 10 10 / .22);
  --font: 'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #131011; --surface: #1c1819; --surface-2: #211c1d; --surface-3: #2a2425;
    --border: #322b2c; --border-strong: #433a3b;
    --text: #f3eeec; --text-2: #d3cac7; --muted: #9c918e;
    --brand: #e0606f; --brand-hover: #ea7684; --brand-soft: #3a1c22; --brand-ink: #f19aa4;
    --bar-1: #4f0a14; --bar-2: #6d1320;
    --green: #6cc795; --green-bg: #183223; --amber: #e9b45e; --amber-bg: #372912;
    --red: #f2837a; --red-bg: #3d1a18; --blue: #86adf0; --blue-bg: #1a2741;
    --violet: #b59cf0; --violet-bg: #2a2142; --teal: #6fcfd3; --teal-bg: #133234;
    --pink: #ee8fbd; --pink-bg: #3a1a2a; --gray: #b3a9a5; --gray-bg: #2b2526;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / .3); --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 18px rgb(0 0 0 / .25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131011; --surface: #1c1819; --surface-2: #211c1d; --surface-3: #2a2425;
  --border: #322b2c; --border-strong: #433a3b;
  --text: #f3eeec; --text-2: #d3cac7; --muted: #9c918e;
  --brand: #e0606f; --brand-hover: #ea7684; --brand-soft: #3a1c22; --brand-ink: #f19aa4;
  --bar-1: #4f0a14; --bar-2: #6d1320;
  --green: #6cc795; --green-bg: #183223; --amber: #e9b45e; --amber-bg: #372912;
  --red: #f2837a; --red-bg: #3d1a18; --blue: #86adf0; --blue-bg: #1a2741;
  --violet: #b59cf0; --violet-bg: #2a2142; --teal: #6fcfd3; --teal-bg: #133234;
  --pink: #ee8fbd; --pink-bg: #3a1a2a; --gray: #b3a9a5; --gray-bg: #2b2526;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .3); --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 18px rgb(0 0 0 / .25);
}

/* =========================================================
   Base
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 14.5px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3, h4 { margin: 0; letter-spacing: -.015em; line-height: 1.2; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.ic { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; padding: 12px; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tone-text-amber { color: var(--amber); font-weight: 600; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

.container { max-width: 1240px; margin: 0 auto; padding: 28px 24px 80px; outline: none; }

/* =========================================================
   Top bar
   ========================================================= */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(100deg, var(--bar-1), var(--bar-2));
  box-shadow: 0 6px 24px rgb(80 10 20 / .18);
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 10px 24px;
  display: flex; align-items: center; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; font-size: 17px; letter-spacing: -.02em; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; flex: none; }
.brand-mark img { width: 36px; height: 36px; display: block; filter: drop-shadow(0 1px 2px rgb(0 0 0 / .25)); }
.nav { display: flex; gap: 4px; margin: 0 auto; padding: 4px; border-radius: 12px; background: rgb(0 0 0 / .14); }
.nav a {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 9px;
  color: rgb(255 255 255 / .82); font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav a .ic { width: 16px; height: 16px; opacity: .85; }
.nav a:hover { color: #fff; background: rgb(255 255 255 / .1); }
.nav a.active { background: #fff; color: #7c0f1d; box-shadow: 0 2px 8px rgb(0 0 0 / .15); }
:root[data-theme="dark"] .nav a.active { background: rgb(255 255 255 / .92); }
.theme-toggle { color: #fff; background: rgb(255 255 255 / .12); border-color: transparent; }
.theme-toggle:hover { background: rgb(255 255 255 / .2); color: #fff; }
.when-dark { display: none; }
:root[data-theme="dark"] .when-dark { display: block; }
:root[data-theme="dark"] .when-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .when-dark { display: block; }
  :root:not([data-theme="light"]) .when-light { display: none; }
}

/* =========================================================
   Buttons & inputs
   ========================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn .ic { width: 16px; height: 16px; }
.btn.sm { height: 31px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgb(120 20 30 / .25), inset 0 1px 0 rgb(255 255 255 / .12); }
:root[data-theme="dark"] .btn-primary { color: #1c0b0e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { color: #1c0b0e; } }
.btn-primary:hover { background: var(--brand-hover); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-soft { background: var(--brand-soft); color: var(--brand-ink); }
.btn-soft:hover { filter: brightness(.97); }
.btn-danger { background: var(--red); color: #fff; }
.danger-text { color: var(--red) !important; }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 8px; border-color: transparent; background: transparent; color: var(--muted); }
.icon-btn.sm:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm .ic { width: 16px; height: 16px; }

.link { display: inline-flex; align-items: center; gap: 2px; color: var(--brand-ink); font-weight: 600; font-size: 13px; background: none; border: 0; padding: 0; }
.link .ic { width: 15px; height: 15px; }
.link:hover { text-decoration: underline; }

input, select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }
select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23847a73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }

/* =========================================================
   Page structure
   ========================================================= */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 28px; font-weight: 800; }
.sub { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); margin-bottom: 20px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 10px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h2 { font-size: 15.5px; font-weight: 700; }
.pill-count { font-size: 12px; font-weight: 700; background: var(--surface-3); color: var(--text-2); padding: 2px 9px; border-radius: 99px; margin-right: auto; margin-left: 8px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
/* Grid/flex children may shrink below their content's natural width (otherwise phones get sideways scrolling) */
.grid-2 > *, .stats > *, .detail-grid > *, .card-grid > *, .acq-main > *, .form-grid > *, .choice-grid > *, .sp-grid > * { min-width: 0; }
.grid-2 > .panel { margin-bottom: 20px; }
.stack > .panel { margin-bottom: 20px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar select { width: auto; min-width: 170px; }
.search { position: relative; flex: 1; min-width: 220px; }
.search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 17px; height: 17px; pointer-events: none; }
.search input { padding-left: 38px; }

.segmented { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: 11px; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; font-weight: 600; font-size: 13.5px; color: var(--muted); }
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* chips */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 99px;
  border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--text-2);
}
.chip .ic { width: 14px; height: 14px; color: var(--muted); }
.chip b { color: var(--text); }
button.chip:hover { border-color: var(--border-strong); }
.chip.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip.active .ic { color: inherit; }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { width: 34px; height: 20px; border-radius: 99px; background: var(--border-strong); position: relative; transition: background .15s; }
.switch span::after { content: ''; position: absolute; width: 16px; height: 16px; top: 2px; left: 2px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: var(--shadow-sm); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700; white-space: nowrap; letter-spacing: .01em; }
.tone-green { color: var(--green); background: var(--green-bg); }
.tone-amber { color: var(--amber); background: var(--amber-bg); }
.tone-red { color: var(--red); background: var(--red-bg); }
.tone-blue { color: var(--blue); background: var(--blue-bg); }
.tone-violet { color: var(--violet); background: var(--violet-bg); }
.tone-teal { color: var(--teal); background: var(--teal-bg); }
.tone-pink { color: var(--pink); background: var(--pink-bg); }
.tone-gray { color: var(--gray); background: var(--gray-bg); }

/* avatars by category */
.avatar { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; font-weight: 800; font-size: 15px; flex: none; letter-spacing: -.02em; }
.avatar.sm { width: 34px; height: 34px; border-radius: 10px; font-size: 12.5px; }
.avatar.xl { width: 72px; height: 72px; border-radius: 20px; font-size: 24px; }
.cat-reptile { background: var(--green-bg); color: var(--green); }
.cat-amphibian { background: var(--teal-bg); color: var(--teal); }
.cat-invertebrate { background: var(--violet-bg); color: var(--violet); }
.cat-mammal { background: var(--amber-bg); color: var(--amber); }
.cat-bird { background: var(--blue-bg); color: var(--blue); }
.cat-fish { background: var(--blue-bg); color: var(--blue); }
.cat-other { background: var(--gray-bg); color: var(--gray); }

/* =========================================================
   Dashboard
   ========================================================= */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s, border-color .15s;
  display: flex; flex-direction: column; gap: 6px;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.stat-top { display: flex; justify-content: space-between; align-items: center; }
.stat-label { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-icon { width: 32px; height: 32px; border-radius: 9px; background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center; }
.stat-icon .ic { width: 17px; height: 17px; }
.stat-value { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-foot { font-size: 12.5px; color: var(--muted); }
.stat-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.stat-warn .stat-icon { background: var(--amber-bg); color: var(--amber); }
.stat-warn .stat-value { color: var(--amber); }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 34px; flex: 1; max-width: 130px; }
.spark span { flex: 1; height: var(--h); background: color-mix(in srgb, var(--brand) 55%, transparent); border-radius: 2px; min-height: 2px; }
.spark span:last-child { background: var(--brand); }

.due-list, .stock-list, .doc-mini { list-style: none; margin: 0; padding: 0; }
.due-list li, .stock-list li, .doc-mini li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.due-list li:first-child, .stock-list li:first-child, .doc-mini li:first-child { border-top: 0; padding-top: 2px; }
.due-who { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.due-who b, .stock-list b, .doc-mini b { display: block; font-weight: 700; }
.due-who small, .stock-list small, .doc-mini small { display: block; color: var(--muted); font-size: 12.5px; }
.due-who:hover b { color: var(--brand-ink); }
.due-when { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.with-icon { display: flex; align-items: center; gap: 8px; }
.h-icon { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; }
.h-icon .ic { width: 15px; height: 15px; }
.panel-head:has(+ .panel-sub) { margin-bottom: 2px; }
.panel-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 12px; }
.compliance { grid-template-columns: 1.45fr 1fr; align-items: start; }
.panel-alert { border-color: color-mix(in srgb, var(--red) 35%, var(--border)); }

.reg-list { list-style: none; margin: 0; padding: 0; }
.reg-list li { display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.reg-list li:first-child { border-top: 0; padding-top: 2px; }
.reg-species { display: flex; align-items: center; gap: 10px; min-width: 0; }
.reg-species b { display: block; font-weight: 700; }
.reg-species small { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.reg-species .col-id { padding: 0 7px; font-size: 11px; }
.reg-animals { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding-left: 44px; }
.reg-animals .chip:hover { border-color: var(--border-strong); color: var(--text); }
.reg-count { text-align: right; color: var(--muted); font-size: 13px; white-space: nowrap; }
.reg-count b { color: var(--text); font-size: 16px; font-variant-numeric: tabular-nums; }
/* ---------- Husbandry (care sheets) ---------- */
.husb-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 20px; align-items: start; }
.husb-list { padding: 12px; position: sticky; top: 76px; max-height: calc(100vh - 96px); display: flex; flex-direction: column; gap: 10px; }
.husb-list .search { width: 100%; }
.husb-items { overflow: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -4px; padding: 0 4px; }
.husb-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; border-radius: 10px; background: none; color: inherit; text-align: left; cursor: pointer; font: inherit; }
.husb-item:hover { background: var(--surface-2); }
.husb-item.active { background: var(--brand-soft, var(--surface-2)); box-shadow: inset 3px 0 0 var(--brand); }
.husb-item b { display: block; font-size: 13.5px; }
.husb-item small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.husb-item .grow { min-width: 0; }
.husb-done { color: var(--green); display: inline-flex; }
.husb-done .ic { width: 16px; height: 16px; }
.husb-head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.husb-head h2 { margin: 0; font-size: 20px; }
.husb-head .sci { margin: 2px 0 4px; color: var(--text-2); }
.husb-head .grow { min-width: 0; flex: 1; }
.husb-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.husb-more { margin-top: 12px; }
/* care sheet card (species-card style) */
.care-title { text-transform: uppercase; letter-spacing: .01em; font-weight: 800; }
.care-sci { margin: 2px 0 4px; font-size: 16px; font-weight: 600; color: var(--text-2); }
.care-facts { margin: 0 0 16px; display: grid; gap: 8px; }
.care-facts div { font-size: 14px; line-height: 1.45; }
.care-facts dt { display: inline; font-weight: 800; text-transform: uppercase; letter-spacing: .02em; margin-right: 6px; }
.care-facts dd { display: inline; margin: 0; white-space: pre-line; }
.care-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.care-tile { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 4px; text-align: center;
             padding: 12px 8px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.care-tile .ic { width: 26px; height: 26px; color: var(--brand-ink); }
.care-tile b { font-size: 13.5px; overflow-wrap: anywhere; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.care-tile small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.diff-bars { display: inline-flex; align-items: flex-end; gap: 3px; height: 26px; }
.diff-bars i { width: 7px; border-radius: 2px; background: var(--border); }
.diff-bars i:nth-child(1) { height: 8px; } .diff-bars i:nth-child(2) { height: 13px; } .diff-bars i:nth-child(3) { height: 19px; } .diff-bars i:nth-child(4) { height: 25px; }
.diff-bars.lvl-1 i:nth-child(-n+1), .diff-bars.lvl-2 i:nth-child(-n+2), .diff-bars.lvl-3 i:nth-child(-n+3), .diff-bars.lvl-4 i { background: var(--brand-ink); }
.care-card.compact .care-facts { margin-top: 10px; }
.care-card.compact .care-tiles { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
/* diet tag picker */
.tag-box { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 42px; padding: 5px 8px; border: 1px solid var(--border-strong, var(--border));
           border-radius: 10px; background: var(--surface); cursor: text; }
.tag-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-ink); font-size: 13px; font-weight: 600; }
.tag button { display: inline-flex; border: 0; background: none; color: inherit; padding: 2px; border-radius: 50%; cursor: pointer; }
.tag button:hover { background: rgb(0 0 0 / .08); }
.tag .ic { width: 13px; height: 13px; }
.tag-input { flex: 1; min-width: 140px; border: 0 !important; box-shadow: none !important; padding: 4px !important; height: auto !important; background: none !important; }
.tag-avail { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag-avail .chip { cursor: pointer; }
.tag-avail .chip .muted { margin-left: 4px; font-size: 11.5px; }
.read-only .tag button, .read-only .tag-avail, .read-only .tag-input { display: none; }
/* fill from screenshot */
.ocr-zone { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 12px 14px; border: 1.5px dashed var(--border-strong, var(--border));
            border-radius: 12px; background: var(--surface-2); }
.ocr-zone > .ic { width: 22px; height: 22px; color: var(--brand-ink); flex: none; }
.ocr-zone > .grow > b { display: block; font-size: 13.5px; }
.ocr-zone small { color: var(--muted); font-size: 12.5px; }
.ocr-zone.drag { border-color: var(--brand); background: var(--brand-soft); }
.ocr-zone.busy { opacity: .85; }
.ocr-status { flex-basis: 100%; font-size: 13px; line-height: 1.5; padding: 8px 10px; border-radius: 8px; background: var(--surface); }
.ocr-status .ic { width: 15px; height: 15px; vertical-align: -3px; margin-right: 6px; }
.ocr-status.ok { color: var(--green); }
.ocr-status.warn { color: var(--amber, #a15c07); }
.ocr-status.err { color: var(--red); }
.ocr-status details { margin-top: 6px; color: var(--text-2); }
.ocr-status pre { white-space: pre-wrap; font-size: 12px; max-height: 180px; overflow: auto; background: var(--surface-2); padding: 8px; border-radius: 6px; }
.ocr-filled { border-color: #d4a017 !important; box-shadow: 0 0 0 3px rgb(212 160 23 / .22) !important; }
.husb-more summary { cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--brand-ink); }
.card-foot .link { margin-left: auto; }
@media (max-width: 860px) {
  .husb-layout { grid-template-columns: 1fr; }
  .husb-list { position: static; max-height: 260px; }
}
@media print {
  body.print-sheet .topbar, body.print-sheet .page-head, body.print-sheet .husb-list,
  body.print-sheet .husb-actions, body.print-sheet .tabbar, body.print-sheet .toast-stack { display: none !important; }
  body.print-sheet .husb-layout { display: block; }
  body.print-sheet .husb-sheet { border: 0; box-shadow: none; padding: 0; }
}

.reg-count .died { display: block; font-size: 12px; color: var(--muted); }

.permit-alerts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.pa-row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); text-align: left; transition: background .15s, border-color .15s; }
.pa-row:hover { background: var(--surface-2); border-color: var(--border-strong); }
.pa-row b { display: block; font-size: 13.5px; }
.pa-row small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pa-icon { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.pa-icon .ic { width: 16px; height: 16px; }
.pa-when { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.pa-when small { font-size: 11.5px; }
@media (max-width: 1020px) { .compliance { grid-template-columns: minmax(0, 1fr); } }
/* Phones: 16px form fields stop iOS Safari zooming in on every tap into a field */
@media (max-width: 760px) {
  input, select, textarea { font-size: 16px; }
  .scan-input { font-size: 15px; }
  .table.articles input, .cell-input { font-size: 16px; }
}
/* Animal page on narrow screens: one column, most-used sections first */
@media (max-width: 1020px) {
  .detail-grid { display: flex; flex-direction: column; gap: 0; }
  .detail-grid > .stack { display: contents; }
  .detail-grid .panel { margin-bottom: 16px; }
  .m-photos { order: 1; } .m-permits { order: 2; } .m-details { order: 3; } .m-weight { order: 4; }
  .m-history { order: 5; } .m-husbandry { order: 6; } .m-docs { order: 7; } .m-danger { order: 8; }
}
@media (max-width: 760px) { .reg-animals { padding-left: 0; } }
.feeder-ico, .doc-ico { width: 34px; height: 34px; border-radius: 10px; background: var(--surface-3); color: var(--text-2); display: grid; place-items: center; flex: none; }
.feeder-ico .ic, .doc-ico .ic { width: 17px; height: 17px; }
.feeder-ico.lg { width: 44px; height: 44px; border-radius: 13px; }
.feeder-ico.lg .ic { width: 21px; height: 21px; }

/* =========================================================
   Timeline / events
   ========================================================= */
.event-list { list-style: none; margin: 0; padding: 0; }
.event-row { display: flex; align-items: flex-start; gap: 12px; padding: 10px 8px; border-radius: 10px; position: relative; }
.event-row:hover { background: var(--surface-2); }
.event-icon { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.event-icon .ic { width: 16px; height: 16px; }
.event-main { flex: 1; min-width: 0; padding-top: 5px; }
.event-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-weight: 600; }
.event-detail { color: var(--muted); font-weight: 500; font-size: 13.5px; }
.event-detail b { color: var(--text); font-weight: 700; }
.event-notes { color: var(--text-2); font-size: 13.5px; margin-top: 2px; }
.event-when { color: var(--muted); font-size: 12.5px; padding-top: 7px; white-space: nowrap; }
.row-actions { opacity: 0; transition: opacity .15s; padding-top: 1px; }
.event-row:hover .row-actions, .event-row:focus-within .row-actions { opacity: 1; }
.strong-link { font-weight: 700; }
.strong-link:hover { color: var(--brand-ink); text-decoration: underline; }
.dot { color: var(--muted); }

.timeline .tl-group { position: relative; }
.timeline .tl-group + .tl-group { margin-top: 10px; }
.tl-date { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 8px; position: sticky; top: 64px; background: var(--surface); z-index: 1; }
.timeline .event-list { position: relative; }
.timeline .event-list::before { content: ''; position: absolute; left: 23px; top: 18px; bottom: 18px; width: 2px; background: var(--border); border-radius: 2px; }
.timeline .event-icon { position: relative; z-index: 1; box-shadow: 0 0 0 4px var(--surface); }
.timeline .event-row:hover .event-icon { box-shadow: 0 0 0 4px var(--surface-2); }

/* =========================================================
   Cards
   ========================================================= */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 14px;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
a.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.card-top { display: flex; align-items: flex-start; gap: 12px; }
.card h3 { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.sci { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); min-height: 43px; }
.sex { font-size: 14px; font-weight: 700; }
.sex-male { color: var(--blue); }
.sex-female { color: var(--pink); }
.sex-unknown { color: var(--muted); font-size: 12px; }
.group-pill { font-size: 11.5px; font-weight: 800; padding: 1px 7px; border-radius: 99px; background: var(--blue-bg); color: var(--blue); font-variant-numeric: tabular-nums; }

.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.mini-stats div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.mini-stats dt { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.mini-stats dd { margin: 2px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.param-row { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--text-2); font-size: 13px; font-weight: 600; }
.param-row span { display: inline-flex; align-items: center; gap: 5px; }
.param-row .ic { width: 15px; height: 15px; color: var(--muted); }

/* feeders */
.qty { display: flex; align-items: baseline; gap: 8px; }
.qty-num { font-size: 30px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.qty-unit { color: var(--muted); font-size: 13px; font-weight: 600; flex: 1; }
.meter { position: relative; height: 8px; border-radius: 99px; background: var(--surface-3); overflow: visible; }
.meter span { display: block; height: 100%; border-radius: inherit; background: var(--green); transition: width .3s; }
.meter.low span { background: var(--amber); }
.meter i { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text-2); opacity: .35; border-radius: 2px; }
.feeder-card.is-low { border-color: color-mix(in srgb, var(--amber) 45%, var(--border)); }
.stepper { display: inline-flex; align-items: center; gap: 2px; }

/* documents */
.card-grid.docs { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.doc-card { padding: 0; overflow: hidden; gap: 0; }
.doc-thumb { height: 120px; background: linear-gradient(135deg, var(--surface-3), var(--surface-2)); display: grid; place-items: center; position: relative; color: var(--muted); border-bottom: 1px solid var(--border); }
.doc-thumb .ic { width: 38px; height: 38px; stroke-width: 1.5; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-thumb .ext { position: absolute; bottom: 12px; font-size: 10.5px; font-weight: 800; letter-spacing: .08em; background: var(--brand); color: #fff; padding: 2px 7px; border-radius: 5px; }
.doc-body { padding: 14px 16px 0; display: flex; flex-direction: column; gap: 6px; }
.doc-body h3 { display: block; font-size: 15px; }
.doc-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.doc-card .card-foot { margin: 12px 16px 0; padding: 8px 0 10px; }
.permit-box { margin-top: 6px; padding: 10px 12px; border-radius: 10px; background: var(--violet-bg); border: 1px solid color-mix(in srgb, var(--violet) 22%, transparent); display: flex; flex-direction: column; gap: 3px; }
.permit-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.permit-issuer { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; color: var(--violet); text-transform: uppercase; letter-spacing: .04em; }
.permit-issuer .ic { width: 13px; height: 13px; }
.permit-num { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-weight: 700; font-size: 14px; }
.permit-box .link { align-self: flex-start; margin-top: 2px; }
.form-intro { margin-bottom: 16px; }
.form-heading { margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--border); gap: 2px; }
.form-heading h4 { font-size: 15px; font-weight: 800; margin: 0; }

/* ---- sign-in, user menu, users & groups ---- */
body.signed-out .nav, body.signed-out .settings-link, body.signed-out .user-menu { display: none; }
body.signed-out .theme-toggle { margin-left: auto; }
.auth-wrap { min-height: calc(100vh - 160px); display: grid; place-items: center; padding: 24px 0; }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.auth-card h1 { font-size: 24px; font-weight: 800; }
.auth-card > .muted { margin-top: -10px; }
.auth-mark { width: 56px; height: 56px; }
.auth-mark img { width: 56px; height: 56px; filter: none; }
.auth-card .form-error { margin: 0; }
.auth-submit, .auth-sso { width: 100%; height: 44px; }
.auth-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; }
.auth-or::before, .auth-or::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.user-menu { position: relative; margin-left: 8px; }
.user-btn { width: 38px; height: 38px; border-radius: 50%; border: 2px solid rgb(255 255 255 / .55); background: rgb(255 255 255 / .16); color: #fff; font-weight: 800; font-size: 13px; }
.user-btn:hover { background: rgb(255 255 255 / .26); }
.user-pop { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 30; }
.user-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.user-head b { display: block; }
.user-head small { color: var(--muted); font-size: 12px; }
.user-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 10px; border: 0; background: none; border-radius: 9px; font-size: 14px; text-align: left; color: var(--text); }
.user-item:hover { background: var(--surface-3); }
.user-item .ic { width: 16px; height: 16px; color: var(--muted); }
.settings-link + .theme-toggle, .user-menu + .settings-link { margin-left: 8px; }
.panel-head.pad { padding: 16px 20px 0; }
.perm-table td, .perm-table th { white-space: nowrap; }
.perm-grid { display: flex; flex-direction: column; gap: 6px; }
.perm-grid.is-admin { opacity: .45; pointer-events: none; }
.perm-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 10px; border-radius: 10px; background: var(--surface-2); }
.perm-row > span { font-weight: 600; font-size: 13.5px; }
.seg { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: 9px; gap: 2px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: block; padding: 5px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg input:focus-visible + span { outline: 2px solid var(--brand); }
.check-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 200px; overflow: auto; }
.check { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 99px; cursor: pointer; font-size: 13.5px; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }
.check:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.check:has(input:disabled) { opacity: .75; cursor: default; }
form.read-only input:disabled, form.read-only select:disabled, form.read-only textarea:disabled { opacity: 1; background: var(--surface-2); color: var(--text); cursor: default; }
@media (max-width: 760px) {
  .perm-row { flex-direction: column; align-items: flex-start; }
}

/* ---- label printing ---- */
.label-opts { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.copies { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.copies input { width: 70px; height: 34px; }
.copies select { height: 34px; width: auto; }
.copies select.needs-value { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-bg); }
.copies .req { color: var(--red); }
.specimen-required { display: flex; align-items: center; gap: 6px; margin: -4px 0 10px; font-size: 13px; font-weight: 600; color: var(--red); }
.specimen-required .ic { width: 15px; height: 15px; }
.label-preview { width: 100%; height: 300px; border: 1px solid var(--border); border-radius: 12px; background: #e7e3df; display: block; }
.print-help { margin-top: 12px; font-size: 13.5px; color: var(--text-2); }
.print-help summary { cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; color: var(--brand-ink); }
.print-help summary .ic { width: 15px; height: 15px; }
.print-help ol { margin: 8px 0 6px; padding-left: 20px; }
.print-help li { margin: 3px 0; }
.print-frame { position: fixed; right: 0; bottom: 0; width: 1px; height: 1px; border: 0; opacity: 0; pointer-events: none; }

/* ---- basic animal access (photos, names, IDs) ---- */
.basic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.basic-grid > * { min-width: 0; }
.basic-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s; display: flex; flex-direction: column; }
.basic-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.basic-photo { aspect-ratio: 4 / 3; background: var(--surface-3); display: grid; place-items: center; }
.basic-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.basic-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.basic-body b { font-size: 15px; }
.basic-body i { color: var(--text-2); font-size: 13px; }
.basic-body .code-chip { margin-top: 4px; }
.basic-detail { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.basic-hero { border-radius: 18px; overflow: hidden; background: var(--surface-3); aspect-ratio: 4 / 3; display: grid; place-items: center; }
.basic-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.basic-info { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.basic-info h1 { font-size: 28px; font-weight: 800; }
.basic-info .photo-grid { width: 100%; }
.basic-h { display: flex; align-items: center; gap: 8px; margin: 14px 0 4px; font-size: 15px; }
@media (max-width: 760px) { .basic-detail { grid-template-columns: 1fr; } }

/* ---- animal IDs & scanning ---- */
.code-chip { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); letter-spacing: .02em; white-space: nowrap; }
.code-chip.lg { font-size: 13px; padding: 3px 9px; }
.animal-card .card-top { flex-wrap: wrap; }
.id-settings { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.id-settings .field { width: 140px; }
.id-settings input { text-transform: uppercase; font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-weight: 700; }
.batch .batch-common { margin-bottom: 14px; }
.scan-box { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 2px solid var(--brand); border-radius: 14px; background: var(--brand-soft); }
.scan-box > .ic { width: 26px; height: 26px; color: var(--brand-ink); flex: none; }
.scan-input { flex: 1; height: 44px; font-size: 17px; font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; letter-spacing: .03em; border-color: transparent; background: var(--surface); }
.scan-cam { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.scan-cam video { width: 100%; max-height: 260px; object-fit: cover; border-radius: 12px; background: #111; }
.scan-feedback { min-height: 28px; display: flex; align-items: center; gap: 6px; margin: 8px 2px 4px; font-size: 14px; }
.scan-feedback .ic { width: 17px; height: 17px; }
.scan-feedback.ok { color: var(--green); }
.scan-feedback.warn { color: var(--amber); }
.scan-feedback.err { color: var(--red); }
.scan-feedback b { color: var(--text); }
.scan-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.batch-list { max-height: 340px; overflow: auto; border: 1px solid var(--border); border-radius: 12px; }
.batch-list .table th { position: sticky; top: 0; background: var(--surface-2); z-index: 1; }
.batch-list tr.flash td { animation: rowflash 1.2s ease-out; }
@keyframes rowflash { from { background: var(--green-bg); } to { background: transparent; } }
.cell-input { width: 90px; height: 30px; text-align: right; padding: 0 8px; }
.batch-empty { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 26px; color: var(--muted); }
.batch-empty .ic { width: 22px; height: 22px; }
.batch-count { font-weight: 600; }

/* ---- settings ---- */
.settings-link + .theme-toggle { margin-left: 8px; }
.settings-link.active { background: #fff; color: #7c0f1d; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1.5px solid var(--border); border-radius: 12px; cursor: pointer; transition: border-color .15s, background .15s; }
.choice:hover { border-color: var(--border-strong); }
.choice.on { border-color: var(--brand); background: var(--brand-soft); }
.choice input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--brand); }
.choice b { display: block; font-size: 14.5px; }
.choice small { display: block; color: var(--text-2); font-size: 13px; margin-top: 3px; line-height: 1.45; }
.sp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.sp-card { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; background: var(--surface); }
.sp-photo { aspect-ratio: 4 / 3; background: var(--surface-3); display: grid; place-items: center; }
.sp-photo-btn { border: 0; padding: 0; width: 100%; height: 100%; cursor: zoom-in; background: none; }
.sp-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sp-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); }
.sp-empty .ic { width: 28px; height: 28px; }
.sp-body { padding: 10px 12px 4px; display: flex; flex-direction: column; gap: 1px; }
.sp-body b { font-size: 14.5px; }
.sp-body small { font-size: 12.5px; color: var(--text-2); }
.sp-body small.muted { color: var(--muted); }
.sp-actions { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 12px 12px; margin-top: auto; align-items: center; }
.sp-actions .icon-btn { margin-left: auto; }
.pick-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.pick-label { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 8px; font-size: 12px; font-weight: 600; color: #fff; background: linear-gradient(transparent, rgb(0 0 0 / .65)); text-align: left; }
.species-photo-note { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.species-photo-note .ic { width: 13px; height: 13px; fill: #f5b301; color: #f5b301; }
.species-photo-note a { color: var(--brand-ink); text-decoration: underline; }

/* ---- animal photos ---- */
.avatar.has-photo { padding: 0; overflow: hidden; background: var(--surface-3); }
.avatar.has-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-photo { border: 0; padding: 0; background: none; border-radius: 20px; cursor: zoom-in; }
.hero-photo:hover .avatar { box-shadow: 0 0 0 3px var(--brand-soft); }
.tone-text-red { color: var(--red); font-weight: 600; }
.photos-panel { transition: box-shadow .15s, border-color .15s; }
.photos-panel.drag { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.photos-panel .panel-head .pill-count { margin-right: 0; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.photo-tile { position: relative; aspect-ratio: 1; border: 0; padding: 0; border-radius: 10px; overflow: hidden; background: var(--surface-3); cursor: zoom-in; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.photo-tile:hover img { transform: scale(1.04); }
.photo-badge { position: absolute; top: 6px; left: 6px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: rgb(0 0 0 / .55); color: #ffd25e; }
.photo-badge .ic { width: 12px; height: 12px; fill: currentColor; }
.photo-badge.cam { left: auto; right: 6px; color: #fff; }
.photo-badge.cam .ic { fill: none; }
.photo-empty { display: flex; align-items: center; gap: 10px; padding: 18px; border: 1.5px dashed var(--border-strong); border-radius: 12px; color: var(--muted); font-size: 13.5px; }
.photo-empty .ic { width: 22px; height: 22px; flex: none; }

.dialog.dialog-camera { width: min(760px, calc(100vw - 32px)); }
.cam-stage { position: relative; border-radius: 14px; overflow: hidden; background: #111; aspect-ratio: 4 / 3; display: grid; place-items: center; }
.cam-stage video, .cam-stage .cam-shot { width: 100%; height: 100%; object-fit: contain; display: block; }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cam-flash.go { animation: flash .35s ease-out; }
@keyframes flash { from { opacity: .85; } to { opacity: 0; } }
.cam-bar { display: flex; align-items: center; gap: 12px; margin-top: 14px; min-height: 64px; }
.cam-device { width: auto; max-width: 240px; }
.cam-capture { width: 64px; height: 64px; border-radius: 50%; border: 4px solid var(--brand); background: var(--surface); box-shadow: inset 0 0 0 4px var(--surface), inset 0 0 0 32px var(--brand); transition: transform .1s; }
.cam-capture:hover:not(:disabled) { transform: scale(1.05); }
.cam-capture:active:not(:disabled) { transform: scale(.94); }
.cam-capture:disabled { opacity: .4; cursor: not-allowed; }
.cam-count { min-width: 60px; text-align: right; }
.cam-review { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.cam-review .cam-caption { flex: 1 1 220px; }

.dialog.dialog-viewer { width: min(1100px, calc(100vw - 32px)); max-height: calc(100vh - 32px); background: #111; color: #eee; }
.viewer { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.viewer-stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; background: #0c0c0c; }
.viewer-stage img { max-width: 100%; max-height: calc(100vh - 140px); object-fit: contain; display: block; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgb(255 255 255 / .14); color: #fff; display: grid; place-items: center; }
.viewer-nav:hover { background: rgb(255 255 255 / .26); }
.viewer-nav.prev { left: 12px; } .viewer-nav.next { right: 12px; }
.viewer-close { position: absolute; top: 10px; right: 10px; background: rgb(0 0 0 / .5); border-color: transparent; color: #fff; }
.viewer-close:hover { background: rgb(0 0 0 / .7); color: #fff; }
.viewer-bar { display: flex; align-items: center; gap: 8px; padding: 12px 14px; background: var(--surface); color: var(--text); flex-wrap: wrap; }
.viewer-caption { height: 34px; border-color: transparent; background: transparent; font-weight: 600; padding-left: 6px; }
.viewer-caption:hover { border-color: var(--border); }
.viewer-meta { padding-left: 6px; }
.viewer-bar [data-v="primary"] .ic { fill: #f5b301; color: #f5b301; }

.permit-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.permit-row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); text-align: left; transition: background .15s, border-color .15s, transform .1s; }
.permit-row:hover { background: var(--surface-2); border-color: var(--border-strong); }
.permit-row:active { transform: translateY(1px); }
.permit-row small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.permit-row .row-chevron { color: var(--muted); width: 18px; height: 18px; }
.dialog.dialog-lg { width: min(820px, calc(100vw - 32px)); }
.permit-popup .dialog-head h2 { font-size: 19px; }
.permit-popup .dialog-head p + p { margin-top: 1px; }
.popup-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: -6px 0 14px; }
.permit-popup .ap-article { margin-bottom: 18px; }
.popup-h { display: flex; align-items: center; gap: 8px; font-size: 15.5px; font-weight: 800; margin: 0 0 10px; }
.popup-h .pill-count { margin: 0; }
.permit-popup .conditions-text { max-height: none; overflow: visible; }
.animal-permit { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.animal-permit.is-expired { border-color: color-mix(in srgb, var(--red) 30%, var(--border)); }
.ap-head { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.ap-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 2px; }
.ap-title .mono { font-size: 14.5px; }
.ap-actions { display: flex; gap: 6px; }
.ap-article { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px 14px; padding: 10px 12px; border-radius: 10px; background: var(--violet-bg); }
.ap-article dt { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--violet); }
.ap-article dd { margin: 1px 0 0; font-size: 13px; font-weight: 600; }
.ap-article div:first-child dd { font-style: italic; }
.ap-conditions > summary, .ap-sub > summary { cursor: pointer; font-weight: 700; font-size: 13.5px; color: var(--brand-ink); padding: 2px 0; }
.ap-conditions[open] > summary { margin-bottom: 8px; }
.ap-sub { margin-top: 10px; }
.ap-sub > summary { font-size: 13px; color: var(--text-2); }
.ap-auth { font-size: 13px; padding: 10px 12px; border-left: 3px solid var(--violet); background: var(--surface-2); border-radius: 0 8px 8px 0; margin-bottom: 10px; color: var(--text-2); }
.conditions-text { font-size: 13.5px; line-height: 1.55; color: var(--text-2); max-height: 520px; overflow: auto; padding-right: 6px; }
.conditions-text p { margin: 0 0 8px; }
.conditions-text .c-item { display: grid; grid-template-columns: 26px 1fr; gap: 2px; }
.conditions-text .c-item b { color: var(--text); }
.conditions-text .c-item.sub { margin-left: 26px; grid-template-columns: 22px 1fr; margin-bottom: 3px; }
.conditions-text ul { margin: -2px 0 10px 26px; padding-left: 16px; }
.conditions-text li { margin-bottom: 3px; }
.conditions-text a { color: var(--brand-ink); text-decoration: underline; word-break: break-all; }

.change-box { display: flex; gap: 10px; margin-top: 10px; padding: 12px 14px; border-radius: 12px; background: var(--blue-bg); font-size: 13.5px; color: var(--text-2); }
.change-box > .ic { color: var(--blue); width: 18px; height: 18px; margin-top: 1px; flex: none; }
.change-box.warn { background: var(--red-bg); }
.change-box.warn > .ic { color: var(--red); }
.change-stats { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 6px 0 2px; }
.change-box details { margin-top: 6px; }
.change-box summary { cursor: pointer; font-weight: 600; color: var(--brand-ink); font-size: 13px; }
.change-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 18px; margin-top: 8px; max-height: 220px; overflow: auto; }
.change-group h5 { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.change-group ul { margin: 0; padding-left: 16px; font-size: 13px; }
.change-group li { margin: 2px 0; }
.change-group.added h5 { color: var(--green); }
.change-group.removed h5 { color: var(--red); }
.change-group.removed li { text-decoration: line-through; color: var(--muted); }
.change-group.changed h5 { color: var(--amber); }
.change-box .old { text-decoration: line-through; color: var(--muted); }
.dialog:has(.articles-field) { width: min(1120px, calc(100vw - 32px)); }
.articles-field { gap: 8px; margin-top: 6px; }
.articles-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.articles-head .pill-count { margin: 0; }
.articles-title { font-size: 14px; font-weight: 700; }
.articles-head .tone-text-green { display: inline-flex; align-items: center; gap: 4px; }
.articles-head .tone-text-green .ic { width: 14px; height: 14px; }
.articles-head .search.sm { flex: 0 1 200px; }
.articles-scroll { border: 1px solid var(--border); border-radius: 12px; max-height: 380px; overflow: auto; }
.table.articles { min-width: 900px; table-layout: fixed; }
.table.articles th:nth-child(1) { width: 24%; }
.table.articles th:nth-child(2) { width: 11%; }
.table.articles th:nth-child(3) { width: 18%; }
.table.articles th:nth-child(4), .table.articles th:nth-child(5), .table.articles th:nth-child(6) { width: 14%; }
.table.articles th:nth-child(7) { width: 44px; }
.table.articles thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); }
.table.articles td { padding: 2px 4px; position: relative; }
.table.articles td.actions { padding: 2px 4px; }
.table.articles input { height: 30px; border: 1px solid transparent; border-radius: 7px; padding: 0 7px; font-size: 13px; background: transparent; }
.table.articles input:hover { border-color: var(--border); }
.table.articles input:focus { border-color: var(--brand); background: var(--surface); }
.table.articles .sci-input { font-style: italic; }
.table.articles td:has(.in-coll) input { padding-left: 24px; }
.in-coll { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--green); display: grid; }
.in-coll .ic { width: 14px; height: 14px; stroke-width: 2.6; }
.art-empty { padding: 14px; text-align: center; }
.permit-intro { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--green-bg); color: var(--text-2); font-size: 13.5px; }
.permit-intro > .ic { color: var(--green); width: 18px; height: 18px; margin-top: 1px; }
.permit-intro.unverified { background: var(--amber-bg); }
.permit-intro.unverified > .ic { color: var(--amber); }
.permit-intro .small { color: var(--muted); margin-top: 3px; }
.permit-intro-actions { display: flex; gap: 16px; margin-top: 8px; flex-wrap: wrap; }
.permit-intro-actions .link { gap: 5px; }
.permit-intro-actions .ic { width: 14px; height: 14px; }

/* table */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.clickable { cursor: pointer; transition: background .1s; }
.table tr.clickable:hover { background: var(--surface-2); }
.table td.actions { width: 1%; padding: 8px 10px; }

/* =========================================================
   Animal detail
   ========================================================= */
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 600; font-size: 13.5px; margin-bottom: 14px; }
.back-link:hover { color: var(--text); }
.back-link .ic { width: 16px; height: 16px; }
.hero { display: flex; align-items: center; gap: 18px; margin-bottom: 24px; flex-wrap: wrap; }
.hero-main { flex: 1; min-width: 220px; }
.hero-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hero-title h1 { font-size: 30px; font-weight: 800; }
.detail-grid { display: grid; grid-template-columns: 360px 1fr; gap: 20px; align-items: start; }
.kv { margin: 0; display: grid; gap: 0; }
.kv div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13.5px; }
.kv div:first-child { border-top: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }
.notes { margin-top: 12px; padding: 12px; background: var(--surface-2); border-radius: 10px; font-size: 13.5px; color: var(--text-2); white-space: pre-wrap; }
.param-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.param-tiles div { display: flex; flex-direction: column; gap: 3px; padding: 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.param-tiles .ic { color: var(--brand-ink); width: 17px; height: 17px; }
.param-tiles b { font-size: 14px; }
.param-tiles small { color: var(--muted); font-size: 11.5px; }
.danger-zone { text-align: center; }

.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-dasharray: 3 4; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .line { fill: none; stroke: var(--brand); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: color-mix(in srgb, var(--brand) 12%, transparent); }
.chart .pt { fill: var(--surface); stroke: var(--brand); stroke-width: 2; }

/* =========================================================
   Empty / loading
   ========================================================= */
.empty { text-align: center; padding: 36px 16px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty > .ic { width: 40px; height: 40px; padding: 9px; border-radius: 12px; background: var(--surface-3); color: var(--text-2); margin-bottom: 6px; }
.empty h3 { color: var(--text); font-size: 16px; }
.empty .btn { margin-top: 10px; }
.loading { display: flex; justify-content: center; gap: 6px; padding: 80px 0; }
.loading span { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); animation: bounce 1s infinite ease-in-out; opacity: .4; }
.loading span:nth-child(2) { animation-delay: .15s; }
.loading span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(.7); opacity: .3; } 40% { transform: scale(1); opacity: 1; } }
.enter { animation: enter .28s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* =========================================================
   Dialog
   ========================================================= */
.dialog {
  border: 0; padding: 0; border-radius: 18px; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.dialog-sm { width: min(400px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgb(20 10 10 / .45); backdrop-filter: blur(3px); }
.dialog[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.dialog-body { padding: 22px 24px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.dialog-head h2 { font-size: 19px; font-weight: 800; }
.dialog-head p { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.dialog-head .icon-btn { width: 34px; height: 34px; border-color: transparent; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.half { grid-column: span 1; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.req { color: var(--brand); }
.hint { color: var(--muted); font-size: 12px; }
.form-error { margin-top: 14px; padding: 10px 12px; border-radius: 10px; background: var(--red-bg); color: var(--red); font-size: 13.5px; font-weight: 600; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; align-items: center; }
.confirm { text-align: center; }
.confirm p { font-size: 15px; margin: 10px 0 0; }
.confirm .dialog-actions { justify-content: center; }
.confirm-icon { width: 48px; height: 48px; border-radius: 14px; margin: 0 auto; display: grid; place-items: center; background: var(--red-bg); color: var(--red); }

.dropzone { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px; border: 1.5px dashed var(--border-strong); border-radius: 12px; cursor: pointer; text-align: center; color: var(--muted); transition: border-color .15s, background .15s; }
.dropzone .ic { width: 24px; height: 24px; color: var(--brand-ink); }
.dropzone .dz-text { font-weight: 600; color: var(--text); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-soft); }
.dropzone.has-file { border-style: solid; border-color: var(--green); background: var(--green-bg); }
.field label.dropzone { font-size: 12.5px; font-weight: 500; }

/* toasts */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { display: flex; align-items: center; gap: 9px; padding: 11px 16px; border-radius: 12px; background: var(--text); color: var(--surface); font-weight: 600; font-size: 14px; box-shadow: var(--shadow-lg); animation: pop .2s ease-out; transition: opacity .3s, transform .3s; }
.toast .ic { width: 17px; height: 17px; color: var(--green); }
.toast-error .ic { color: var(--red); }
.toast.out { opacity: 0; transform: translateY(6px); }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1020px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .nav a { padding: 8px 10px; }
  .nav a .ic { display: none; }
}
@media (max-width: 760px) {
  .container { padding: 20px 16px 96px; }
  .topbar-inner { padding: 10px 16px; }
  .grid-2 { grid-template-columns: 1fr; gap: 0; }
  .page-head h1 { font-size: 24px; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; margin: 0; border-radius: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 20px rgb(0 0 0 / .08); justify-content: space-around; gap: 0;
  }
  .nav a { flex-direction: column; gap: 3px; font-size: 10.5px; padding: 6px 4px; color: var(--muted); flex: 1; min-width: 0; }
  .nav a .ic { display: block; width: 20px; height: 20px; }
  .nav a:hover { background: transparent; color: var(--text); }
  .nav a.active { background: var(--brand-soft); color: var(--brand-ink); box-shadow: none; }
  .theme-toggle { margin-left: auto; }
  .tl-date { top: 54px; }
  .toasts { bottom: 84px; left: 16px; right: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.half { grid-column: 1 / -1; }
  .toolbar select { flex: 1; min-width: 0; }
  .search { min-width: 100%; }
  .due-when { display: none; }
  .row-actions { opacity: 1; }
}
@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px; }
  .stat-value { font-size: 24px; }
  .spark { display: none; }
  .param-tiles { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* =========================================================
   Catalogue of Life taxon picker
   ========================================================= */
.dialog:has(.taxon) { width: min(720px, calc(100vw - 32px)); }
.taxon { gap: 10px; }
.taxon-row { display: grid; grid-template-columns: auto 1fr 1.2fr; gap: 18px; align-items: end; }
.taxon-rank { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.taxon-rank legend { font-size: 13px; font-weight: 600; color: var(--text-2); padding: 0; margin-bottom: 6px; }
.radio { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; white-space: nowrap; }
.radio input { appearance: none; width: 18px; height: 18px; margin: 0; padding: 0; border-radius: 50%; border: 1.5px solid var(--border-strong); background: var(--surface); display: grid; place-items: center; cursor: pointer; transition: border-color .15s; }
.radio input::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--surface); transform: scale(0); transition: transform .15s; }
.radio input:checked { background: var(--brand); border-color: var(--brand); }
.radio input:checked::after { transform: scale(1); }
.radio input:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; box-shadow: none; }
.taxon-genus, .taxon-species { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.taxon-genus label, .taxon-species label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.taxon-genus input, .taxon-species select { border-radius: 99px; }
.taxon-species select:disabled { opacity: .65; cursor: not-allowed; }
.ac { position: relative; }
.ac-spin { position: absolute; right: 12px; top: 50%; width: 15px; height: 15px; margin-top: -7.5px; border: 2px solid var(--border-strong); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ac-list { position: absolute; z-index: 5; top: calc(100% + 4px); left: 0; right: -40px; margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); max-height: 260px; overflow: auto; }
.ac-list li { padding: 7px 10px; border-radius: 8px; cursor: pointer; display: flex; flex-direction: column; }
.ac-list li b { font-style: italic; font-weight: 700; }
.ac-list li small { color: var(--muted); font-size: 11.5px; }
.ac-list li[aria-selected="true"], .ac-list li[data-i]:hover { background: var(--brand-soft); }
.ac-list .ac-empty { color: var(--muted); font-size: 13px; cursor: default; }
.taxon-card { border: 1px solid var(--border); background: var(--surface-2); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.tc-main { display: flex; align-items: center; gap: 12px; }
.tc-common { font-size: 16px; font-weight: 800; }
.tc-sci { font-size: 13px; color: var(--text-2); }
.tc-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--border); }
.tc-meta .ic { width: 14px; height: 14px; vertical-align: -2px; }
.col-id { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--brand-ink); background: var(--brand-soft); padding: 2px 9px; border-radius: 99px; }
.col-id b { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; }
.col-id:hover { text-decoration: underline; }
.col-id .ic { width: 12px; height: 12px; }
.species-card .col-id { margin-top: 6px; }
.tone-text-green { color: var(--green); font-weight: 600; }
.taxon-msg a { color: var(--brand-ink); text-decoration: underline; }
.taxon-msg.warn { color: var(--amber); font-weight: 600; }
@media (max-width: 640px) {
  .taxon-row { grid-template-columns: 1fr; }
  .taxon-rank { flex-direction: row; gap: 18px; flex-wrap: wrap; }
  .taxon-rank legend { width: 100%; }
  .ac-list { right: 0; }
}

/* =========================================================
   Acquisition dialog
   ========================================================= */
.dialog-xl { width: min(1080px, calc(100vw - 32px)); }
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 13px; }
.badge .ic { width: 12px; height: 12px; }
button.badge { border: 0; cursor: pointer; font-family: inherit; }

.acq { padding: 22px 26px 24px; position: relative; }
.acq-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.acq-title { font-size: 21px; font-weight: 800; }
.acq-sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.close-x { width: 36px; height: 36px; border-color: transparent; color: var(--brand); }
.close-x:hover { background: var(--brand-soft); color: var(--brand); }

.acq-top { display: grid; grid-template-columns: 1.15fr 1fr .8fr auto; gap: 18px; align-items: end; }
.acq-top .field { grid-column: auto; }
.with-add { display: flex; align-items: center; gap: 8px; }
.with-add select { flex: 1; min-width: 0; }
.add-circle {
  width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--brand); color: var(--brand); background: transparent; transition: background .15s, color .15s;
}
.add-circle .ic { width: 16px; height: 16px; stroke-width: 2.6; }
.add-circle:hover { background: var(--brand); color: #fff; }
.save-fab {
  width: 50px; height: 50px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--brand); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 35%, transparent);
  transition: transform .12s, background .15s; position: relative; margin-bottom: -5px;
}
.save-fab .ic { width: 22px; height: 22px; }
.save-fab:hover { background: var(--brand-hover); transform: translateY(-1px); }
.save-fab:disabled { opacity: .6; }
.save-fab.dirty::after { content: ''; position: absolute; top: 2px; right: 2px; width: 11px; height: 11px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 2px var(--surface); }
:root[data-theme="dark"] .save-fab { color: #1c0b0e; }

.acq-main { display: grid; grid-template-columns: 1fr 290px; gap: 28px; margin-top: 26px; }
.acq-left { min-width: 0; }
.acq-actions { display: flex; justify-content: center; margin-bottom: 14px; }
.acq-actions button {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 28px; border: 0;
  background: var(--surface-3); color: var(--text-2); font-weight: 600; font-size: 14px; transition: background .15s, color .15s;
}
.acq-actions button:first-child { border-radius: 99px 0 0 99px; border-right: 1px solid var(--border); }
.acq-actions button:last-child { border-radius: 0 99px 99px 0; }
.acq-actions button .ic { width: 17px; height: 17px; }
.acq-actions button:not(:disabled):hover { background: var(--brand-soft); color: var(--brand-ink); }
.acq-actions button:disabled { color: var(--muted); opacity: .6; cursor: not-allowed; }

.acq-card { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; }
.acq-tabs { display: flex; gap: 26px; padding: 0 22px; border-bottom: 1px solid var(--border); }
.acq-tabs button { border: 0; background: none; padding: 13px 2px 10px; font-weight: 600; font-size: 14.5px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 6px; }
.acq-tabs button[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }
.tab-count:not(:empty) { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); }
.acq-tabs button[aria-selected="true"] .tab-count { background: var(--brand-soft); color: var(--brand-ink); }
.acq-locked { display: none; align-items: center; gap: 8px; margin: 12px 14px 0; padding: 10px 12px; border-radius: 10px; background: var(--amber-bg); color: var(--amber); font-size: 13px; font-weight: 600; }
.acq-locked .ic { width: 16px; height: 16px; }
.acq.is-new .acq-locked { display: flex; }
.acq.is-new .tbl-toolbar { opacity: .5; pointer-events: none; }

.acq-panel { margin: 12px; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.tbl-toolbar { display: flex; align-items: center; gap: 14px; padding: 9px 10px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.search.sm { flex: 0 1 220px; min-width: 150px; }
.search.sm input { height: 32px; border-radius: 99px; font-size: 13px; padding-left: 32px; }
.search.sm .ic { width: 15px; height: 15px; left: 11px; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--text-2); font-size: 13px; font-weight: 600; padding: 4px 6px; border-radius: 7px; }
.link-btn .ic { width: 15px; height: 15px; }
.link-btn:hover { background: var(--surface-3); color: var(--text); }
.pager { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.pager b { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border: 1px solid var(--border-strong); border-radius: 99px; color: var(--text); font-weight: 600; margin: 0 2px; }
.pg { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface-2); display: grid; place-items: center; color: var(--text-2); }
.pg .ic { width: 14px; height: 14px; }
.pg:disabled { opacity: .45; cursor: default; }
.table.compact th { padding: 10px 12px; background: var(--surface); color: var(--text); font-size: 12.5px; text-transform: none; letter-spacing: 0; border-bottom: 1px solid var(--border); }
.table.compact td { padding: 9px 12px; font-size: 13.5px; vertical-align: middle; }
.table.compact th + th, .table.compact td + td { border-left: 1px solid var(--border); }
.table.compact td.actions { width: 1%; padding: 4px 6px; }
.table.compact tr.filler td { height: 40px; }
.table.compact tr:last-child td { border-bottom: 0; }
.empty-row td { color: var(--muted); text-align: center; padding: 18px 12px !important; font-size: 13px; border-left: 0 !important; }
.acq-table { max-height: 380px; overflow: auto; }

.acq-side { display: flex; flex-direction: column; gap: 16px; }
.switch-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; padding: 4px 0; }
.switch-line b { display: block; font-weight: 600; font-size: 14px; }
.switch-line small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.acq-side .field label { font-size: 13.5px; }
.acq-side textarea { border-radius: 14px; min-height: 96px; }
.acq-totals { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); display: grid; gap: 6px; font-size: 13.5px; }
.acq-totals div { display: flex; justify-content: space-between; }
.acq-totals dt { color: var(--muted); }
.acq-totals dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.acq-totals .grand { padding-top: 7px; margin-top: 2px; border-top: 1px dashed var(--border-strong); }
.acq-totals .grand dt { color: var(--text); font-weight: 700; }
.acq-totals .grand dd { font-weight: 800; font-size: 15px; }
.acq-side-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: auto; }
.acq-side-actions .btn { min-width: 116px; }

@media (max-width: 900px) {
  .acq { padding: 18px 16px; }
  .acq-top { grid-template-columns: 1fr 1fr; }
  .acq-top .field:first-child { grid-column: 1 / -1; }
  .save-fab { position: absolute; top: 16px; right: 60px; width: 40px; height: 40px; margin: 0; }
  .save-fab .ic { width: 18px; height: 18px; }
  .acq-head { padding-right: 52px; }
  .acq-main { grid-template-columns: 1fr; gap: 20px; }
  .acq-actions button { padding: 9px 18px; }
  .tbl-toolbar .search.sm { flex: 1 1 100%; }
}
.ocr-diff { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); color: var(--text); }
.ocr-diff ul { margin: 4px 0 8px; padding-left: 18px; }
/* name ideas under the Name field */
.name-ideas { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.name-ideas-chips { display: flex; flex-wrap: wrap; gap: 5px; flex: 1; min-width: 0; }
.name-ideas .chip { cursor: pointer; padding: 3px 9px; font-size: 12.5px; }
.name-ideas .chip:hover, .name-ideas .chip.active { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
.name-ideas .icon-btn { flex: none; align-self: flex-start; }
/* Settings → Notifications */
.notify-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) minmax(0, 0.8fr); gap: 12px; margin-top: 12px; }
.notify-alerts { display: grid; gap: 8px; margin-top: 14px; }
.notify-alert { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.notify-alert .inline-check span { display: flex; flex-direction: column; }
.notify-alert small { color: var(--muted); font-size: 12px; }
.notify-topic { display: flex; align-items: center; gap: 8px; }
.notify-topic input { width: 200px; height: 34px; }
.inline-check { display: inline-flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.inline-check input { margin-top: 3px; }
.notify-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.notify-actions .muted { margin-left: auto; }
@media (max-width: 760px) { .notify-grid { grid-template-columns: 1fr; } .notify-topic input { width: 100%; } .notify-topic { width: 100%; } }
.inline-check input[type="checkbox"] { width: 17px; height: 17px; min-height: 0; flex: none; padding: 0; margin: 2px 0 0; accent-color: var(--brand); }
.notify-grid > .field { grid-column: auto; }
/* Settings → Share links */
.share-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.share-list li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.share-list li .grow { flex: 1; min-width: 200px; }
.share-list li small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.share-list li.inactive { opacity: .6; }
.share-scope { display: grid; gap: 6px; padding-top: 6px; }
.share-species-list { display: grid; gap: 6px; max-height: 240px; overflow: auto; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; }
.share-qr { display: grid; place-items: center; padding: 10px; }
.share-qr img { width: 240px; height: 240px; background: #fff; border-radius: 12px; padding: 8px; }
.share-qr-url { text-align: center; word-break: break-all; color: var(--muted); }
/* Distribution map (animal page) */
.dist-map { position: relative; border-radius: 12px; overflow: hidden; background: var(--teal-bg); border: 1px solid var(--border); }
.dist-map svg { display: block; width: 100%; height: auto; }
.dist-map path { fill: var(--surface); stroke: var(--border-strong, var(--border)); stroke-width: .5; vector-effect: non-scaling-stroke; }
.dist-map path.rec, .dist-legend .sw.rec { fill: var(--brand); background: var(--brand); }
.dist-map path.lvl-1, .dist-legend .lvl-1 { fill-opacity: .3; opacity: 1; }
.dist-legend .sw.lvl-1 { opacity: .3; } .dist-legend .sw.lvl-2 { opacity: .5; } .dist-legend .sw.lvl-3 { opacity: .75; } .dist-legend .sw.lvl-4 { opacity: 1; }
.dist-map path.lvl-2 { fill-opacity: .5; } .dist-map path.lvl-3 { fill-opacity: .75; } .dist-map path.lvl-4 { fill-opacity: 1; }
.dist-map path.native, .dist-legend .sw.native { fill: var(--teal); background: var(--teal); fill-opacity: .55; }
.dist-legend .sw.native { opacity: .55; }
.dist-map path:hover { stroke: var(--text); stroke-width: 1; }
.dist-zoom { position: absolute; right: 8px; bottom: 8px; background: var(--surface) !important; }
.dist-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.dist-legend span { display: inline-flex; align-items: center; gap: 3px; }
.dist-legend .sw { display: inline-block; width: 12px; height: 10px; border-radius: 2px; margin-right: 1px; }
.dist-countries { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.dist-countries .chip b { margin-left: 4px; }
.dist-native { font-size: 13px; margin: 10px 0 0; color: var(--text-2); }
.dist-src { margin: 8px 0 0; }
.inline-check input[type="radio"] { width: 17px; height: 17px; min-height: 0; flex: none; padding: 0; margin: 2px 0 0; accent-color: var(--brand); }
.share-scope .inline-check { align-items: center; }

/* care sheet lookup (Wikipedia / AI) */
.lookup-zone { margin-top: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.lookup-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.lookup-head > .ic { width: 22px; height: 22px; color: var(--brand-ink); flex: none; }
.lookup-head .grow { flex: 1 1 220px; }
.lookup-head b { display: block; font-size: 13.5px; }
.lookup-head small { color: var(--muted); font-size: 12.5px; }
.lookup-results:empty { display: none; }
.lookup-results { display: grid; gap: 10px; margin-top: 10px; }
.lookup-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: grid; gap: 8px; }
.lookup-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 13.5px; }
.lookup-title .ic { width: 16px; height: 16px; color: var(--brand-ink); }
.lookup-title .link { margin-left: auto; }
.lookup-text { margin: 0; font-size: 13px; line-height: 1.5; white-space: pre-line; }
.lookup-sec summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.lookup-sec[open] { display: grid; gap: 6px; }
.lookup-sec .btn { justify-self: start; }
.lookup-plants { display: grid; gap: 6px; }
.lookup-plants > b { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.lookup-plants > b .ic { width: 15px; height: 15px; color: var(--green); }
.lookup-plants .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.lookup-plants .chip { cursor: pointer; font-style: italic; }
.lookup-plants .chip .ic { width: 12px; height: 12px; }
.lookup-plants .chip.added { opacity: .5; }
.lookup-plants > .btn { justify-self: start; }
.lookup-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.lookup-table th, .lookup-table td { padding: 5px 0; vertical-align: top; border-top: 1px solid var(--border); }
.lookup-table th { text-align: left; font-weight: 600; color: var(--text-2); width: 32%; padding-right: 8px; }
.lookup-table td:last-child { text-align: right; width: 70px; padding-left: 8px; }
.lookup-table .ic { width: 12px; height: 12px; }
.lookup-sources { margin: 0; padding-left: 18px; font-size: 12.5px; }
.lookup-busy { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); }

/* growth panel */
.growth-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 12px; }
.growth-stats > div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; display: grid; gap: 1px; }
.growth-stats small { color: var(--muted); font-size: 12px; }
.growth-stats b { font-size: 17px; }
.growth-stats span { font-size: 12px; color: var(--text-2); }
.growth-stats span.up { color: var(--green); }
.growth-stats span.down { color: var(--red); }
.growth-chart h3 { font-size: 13px; margin: 6px 0 2px; color: var(--text-2); }
.growth-sheds { margin-top: 10px; }
.premolt-on { display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin-bottom: 12px; border-radius: 10px; background: var(--violet-bg); color: var(--violet); font-size: 13px; }
.premolt-on .ic { width: 18px; height: 18px; flex: none; }
.premolt-on span { flex: 1; }
/* USB scale in Scan & log */
.scale-box { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; background: var(--surface-2); }
.scale-box > .ic { width: 22px; height: 22px; color: var(--muted); flex: none; }
.scale-box .grow { flex: 1 1 220px; display: grid; }
.scale-box small { color: var(--muted); font-size: 12.5px; }
.scale-box .scale-reading { font-size: 15px; font-variant-numeric: tabular-nums; }
.scale-box.live > .ic { color: var(--brand-ink); }
.scale-box.steady { border-color: var(--green); }
.scale-box.steady .scale-reading { color: var(--green); }

/* breeding */
.section-title { font-size: 15px; margin: 18px 0 10px; color: var(--text-2); }
.clutch-card { display: grid; gap: 10px; }
.clutch-card .avatar .ic { width: 20px; height: 20px; }
.clutch-parents { margin: 2px 0 0; font-size: 13.5px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.clutch-dates { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 6px; margin: 0; }
.clutch-dates div { background: var(--surface-2); border-radius: 8px; padding: 6px 8px; }
.clutch-dates dt { font-size: 11.5px; color: var(--muted); }
.clutch-dates dd { margin: 0; font-size: 13px; font-weight: 600; }
.clutch-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.clutch-foot .ic { width: 13px; height: 13px; vertical-align: -2px; }
.clutch-mini { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.clutch-mini li { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.clutch-mini .grow { flex: 1; display: grid; }

/* care tasks */
.task-list { list-style: none; margin: 0; padding: 0; display: grid; }
.task-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); }
.task-row:first-child { border-top: 0; }
.task-row .grow { flex: 1; min-width: 0; display: grid; }
.task-row small { font-size: 12.5px; }
.task-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.task-presets .chip { cursor: pointer; }

/* sales */
.sale-lines td { vertical-align: middle; }
.sale-lines .cell-input { width: 90px; }
.sale-add { display: flex; gap: 8px; align-items: center; margin: 8px 0 4px; }
.sale-add select { flex: 1; min-width: 0; }
.sale-sums { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 12px; }
.sale-totals { margin: 12px 0 0; display: grid; gap: 4px; font-size: 14px; }
.sale-totals div { display: flex; justify-content: space-between; }
.sale-totals .grand { font-weight: 700; font-size: 16px; border-top: 1px solid var(--border); padding-top: 6px; }
.form-subhead { font-size: 13px; margin: 14px 0 6px; color: var(--text-2); }
.money-up { color: var(--green); }
.money-down { color: var(--red); }
.acq-totals .profit-line dd { color: var(--green); font-weight: 700; }
.acq-totals .profit-line.loss dd { color: var(--red); }
.sale-sums > .field { grid-column: auto; }
.sale-totals + .field { margin-top: 14px; }

/* reports */
.report-bars .bar-out, .dist-legend .sw.bar-out { fill: var(--bar-1); background: var(--bar-1); opacity: .85; }
.report-bars .bar-in, .dist-legend .sw.bar-in { fill: var(--green); background: var(--green); }
.panel-head.padded, .padded { padding: 14px 16px; }
.table tfoot th { border-top: 2px solid var(--border); font-weight: 700; }

/* quick log (phone) */
.quick { display: grid; gap: 14px; max-width: 640px; margin: 0 auto; }
.quick-find { display: grid; gap: 10px; }
.quick-scan { justify-content: center; padding: 14px; font-size: 16px; }
.quick-scan .ic { width: 22px; height: 22px; }
.quick-cam { display: grid; gap: 8px; }
.quick-cam video { width: 100%; max-height: 50vh; object-fit: cover; border-radius: 12px; background: #000; }
.quick-msg:empty { display: none; }
.quick-msg { color: var(--amber); font-size: 14px; }
.quick-results, .quick-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.quick-animal { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px;
                background: var(--surface); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.quick-animal .grow { flex: 1; display: grid; min-width: 0; }
.quick-animal small { color: var(--muted); font-size: 12.5px; }
.quick-animal > .ic { width: 16px; height: 16px; color: var(--muted); }
.quick-who { display: flex; align-items: center; gap: 12px; }
.quick-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; }
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.quick-act { display: grid; justify-items: center; gap: 6px; padding: 14px 6px; border: 1px solid var(--border); border-radius: 12px;
             background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; }
.quick-act .ic { width: 24px; height: 24px; color: var(--brand-ink); }
.quick-act:active { transform: scale(.97); }
.offline-bar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 12px;
               background: var(--amber); color: #fff; font-size: 13.5px; font-weight: 600; }
.offline-bar .ic { width: 16px; height: 16px; }

/* temperature & humidity */
.climate-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.climate-grid.compact { margin-top: 10px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.climate-tile { display: grid; gap: 6px; text-align: left; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2);
                color: inherit; font: inherit; cursor: pointer; }
.climate-tile.bad { border-color: var(--red); background: color-mix(in srgb, var(--red) 8%, var(--surface)); }
.climate-tile.stale { opacity: .7; }
.climate-name { display: grid; }
.climate-name small, .climate-when { color: var(--muted); font-size: 12px; }
.climate-values { display: flex; gap: 14px; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.climate-values span { display: inline-flex; align-items: center; gap: 4px; }
.climate-values .ic { width: 16px; height: 16px; color: var(--muted); }
.climate-values .off { color: var(--red); }
.readings-chart .limit { stroke: var(--amber); stroke-dasharray: 4 4; stroke-width: 1.2; }
.readings-chart .line-hum { stroke: var(--teal); }
.sensor-range { margin-bottom: 6px; }
.form-subhead .ic { width: 14px; height: 14px; vertical-align: -2px; }
.manual-reading { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.manual-reading input { width: 90px; }
.sensor-token { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.sensor-token .ic { width: 14px; height: 14px; color: var(--green); vertical-align: -2px; }
.sensor-howto { margin-bottom: 12px; display: grid; gap: 8px; }
.sensor-new-token { background: var(--surface-2); padding: 8px 10px; border-radius: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sensor-new-token code { word-break: break-all; }
.howto-steps { margin: 0; padding-left: 20px; font-size: 13.5px; display: grid; gap: 4px; }
.code-block { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 12px; overflow-x: auto; white-space: pre; margin: 0; }
.sensor-howto > .btn { justify-self: start; }

/* change history */
.history-list { list-style: none; margin: 0; padding: 0; display: grid; }
.history-row { padding: 9px 0; border-top: 1px solid var(--border); display: grid; gap: 4px; }
.history-row:first-child { border-top: 0; }
.history-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13.5px; }
.history-top .grow { flex: 1; min-width: 160px; }
.history-changes { list-style: none; margin: 0 0 0 4px; padding: 0 0 0 10px; border-left: 2px solid var(--border); display: grid; gap: 2px; font-size: 12.5px; }
.history-changes s { color: var(--muted); }
details.history-panel > summary { cursor: pointer; list-style: none; }
details.history-panel > summary::-webkit-details-marker { display: none; }
details.history-panel > summary h2::before { content: '▸ '; color: var(--muted); }
details.history-panel[open] > summary h2::before { content: '▾ '; }
details.history-panel[open] > summary { margin-bottom: 8px; }

/* enclosures */
.enclosure-card { display: grid; gap: 10px; align-content: start; }
.enclosure-card .avatar .ic { width: 20px; height: 20px; }
.enclosure-animals { display: flex; flex-wrap: wrap; gap: 6px; }
.enclosure-animals .chip .muted { margin-left: 4px; font-size: 11.5px; }
.enclosure-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.pick-list { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 2px; max-height: 55vh; overflow-y: auto; }
.pick-list li { padding: 6px 4px; border-bottom: 1px solid var(--border); }
.pick-list small { display: block; }
.card-grid + .panel { margin-top: 16px; }
/* tab strips scroll sideways on phones instead of widening the page */
@media (max-width: 700px) {
  .segmented { display: flex; max-width: 100%; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .segmented::-webkit-scrollbar { display: none; }
  .segmented button { flex: none; white-space: nowrap; }
  .page-head > div, .page-actions { min-width: 0; max-width: 100%; }
  .page-actions { flex-wrap: wrap; }
}

/* racks */
.card-grid > .rack-card { grid-column: 1 / -1; }
.rack-scroll { overflow-x: auto; }
.rack-cell { display: grid; align-content: start; gap: 1px; min-height: 64px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px;
             background: var(--surface); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.rack-cell.used { border-color: var(--brand-soft, var(--border)); background: color-mix(in srgb, var(--brand) 6%, var(--surface)); }
.rack-cell.missing { visibility: hidden; }
.rack-cell .rack-pos { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .03em; }
.rack-cell b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rack-cell small { font-size: 11.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* the rack drawing: frame, shelves (one per row), tubs standing on each shelf */
.rack-frame { display: grid; min-width: min-content; padding: 0 10px; border: 4px solid var(--text-2); border-radius: 6px; background: var(--surface-2); }
.rack-shelf { position: relative; display: grid; grid-template-columns: repeat(var(--cols), minmax(110px, 1fr)); gap: 10px; align-items: end;
              padding: 12px 4px 0 22px; border-bottom: 4px solid var(--text-2); }
.rack-shelf:last-child { border-bottom: 0; padding-bottom: 8px; }
.rack-row-label { position: absolute; left: 2px; bottom: 6px; font-size: 11px; font-weight: 800; color: var(--muted); }
.rack-shelf .rack-cell { border-width: 2px; border-color: var(--border-strong, var(--border)); border-radius: 6px 6px 3px 3px; }
.rack-frame.preview .rack-shelf { grid-template-columns: repeat(var(--cols), minmax(34px, 1fr)); gap: 6px; padding: 8px 2px 0 18px; }
.rack-frame.preview .rack-cell { min-height: 28px; padding: 2px; place-items: center; font-size: 10.5px; font-weight: 700; color: var(--muted); cursor: default; }
.rack-preview { display: grid; gap: 6px; margin-bottom: 4px; }

.enclosure-card .badge .ic { width: 12px; height: 12px; vertical-align: -2px; margin-right: 3px; }
.enclosure-card .card-top .badge { margin-top: 4px; display: inline-flex; align-items: center; }

/* feeder photos */
button.feeder-ico { border: 0; padding: 0; cursor: pointer; font: inherit; }
.feeder-ico.has-photo { overflow: hidden; background: var(--surface-2); }
.feeder-ico.has-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.feeder-photo-big { display: block; width: 100%; max-height: 60vh; object-fit: contain; border-radius: 10px; background: var(--surface-2); }
.feeder-photo-empty { display: grid; place-items: center; gap: 8px; padding: 40px; border: 1.5px dashed var(--border); border-radius: 10px; }
.feeder-photo-empty .ic { width: 40px; height: 40px; color: var(--muted); }
.feeder-ico.lg.has-photo { width: 56px; height: 56px; }

.feeder-photo-drop { border-radius: 12px; transition: box-shadow .15s; }
.feeder-photo-drop.drag { box-shadow: 0 0 0 3px var(--brand); }
.feeder-photo-hint { display: flex; align-items: center; gap: 6px; margin: 10px 0 0; }
.feeder-photo-hint .ic { width: 14px; height: 14px; flex: none; }

/* Scan & log: usual feeder */
.usual-ask { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; font-size: 12.5px; color: var(--text-2); }
.usual-set { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 12.5px; color: var(--text-2); font-weight: 400; }
.feeder-cell { min-width: 150px; max-width: 220px; }

.paste-box { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 12px 14px; border: 1.5px dashed var(--border-strong, var(--border));
             border-radius: 10px; color: var(--muted); font-size: 13px; cursor: text; caret-color: transparent; outline: none; }
.paste-box:focus { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); }
.paste-box .ic { width: 16px; height: 16px; flex: none; }
.paste-box img { display: none; }
.feeder-photo-status { margin: 8px 0 0; font-size: 13px; color: var(--text-2); }
.feeder-photo-status.bad { color: var(--red); }



/* storage test: one card per storage, live steps */
.storage-cards { display: grid; gap: 12px; }
.storage-store { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.storage-head { display: flex; align-items: flex-start; gap: 12px; }
.storage-head .grow { flex: 1; min-width: 0; }
.storage-head code { word-break: break-all; }
.storage-steps { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; counter-reset: s; }
.storage-steps li { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.storage-steps li > span { min-width: 130px; }
.storage-steps li small { color: var(--muted); }
.storage-steps .ic { width: 16px; height: 16px; flex: none; }
.storage-steps .waiting { color: var(--muted); }
.storage-steps .running .ic { color: var(--brand-ink); animation: spin 1s linear infinite; }
.storage-steps .running small { color: var(--brand-ink); }
.storage-steps .ok .ic { color: var(--green); }
.storage-steps .failed { color: var(--red); }
.storage-steps .failed small { color: var(--red); font-weight: 600; }
.storage-steps .skipped { color: var(--muted); opacity: .6; }
.storage-verdict { margin: 10px 0 0; font-size: 13px; font-weight: 600; }
.storage-verdict.ok { color: var(--green); }
.storage-verdict.bad { color: var(--red); }
@keyframes spin { to { transform: rotate(360deg); } }

/* usual meal tile */
.param-tiles .usual-tile { display: grid; justify-items: center; gap: 2px; border: 0; background: var(--surface-2); border-radius: 10px; padding: 10px 6px;
                           color: inherit; font: inherit; cursor: pointer; text-align: center; }
.param-tiles .usual-tile:hover { background: var(--brand-soft); }
.param-tiles .usual-tile b { font-size: 13px; }
/* feeding pick list */
.picklist .segmented { margin-bottom: 12px; }
.pick-totals { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-bottom: 14px; }
.pick-totals > div { display: grid; grid-template-columns: 40px auto 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center;
                     padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.pick-totals img, .pick-totals .feeder-ico { grid-row: 1 / 3; width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }
.pick-totals b { font-size: 17px; }
.pick-totals small { grid-column: 2 / 4; color: var(--muted); font-size: 12px; }
.pick-totals .short { border-color: var(--red); }
.pick-totals .short small { color: var(--red); font-weight: 600; }
.pick-totals .none { grid-template-columns: auto 1fr; }
.pick-totals .none small { grid-column: 1 / 3; }
.pick-table input[type="checkbox"] { width: 18px; height: 18px; }
.param-tiles { grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); }
.param-tiles .usual-tile { display: flex; flex-direction: column; align-items: flex-start; justify-items: start; gap: 3px; padding: 10px; text-align: left; border: 1px solid var(--border); }
.param-tiles { grid-template-columns: repeat(3, 1fr); }
.param-tiles .usual-tile { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 8px; }
.param-tiles .usual-tile small { margin-left: auto; }

/* feeder picker (dropdown with photos) */
.fsel-btn { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 5px 10px 5px 6px; border: 1px solid var(--border-strong, var(--border));
            border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.fsel-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.fsel-btn.compact { min-height: 34px; padding: 3px 8px 3px 4px; min-width: 170px; }
.fsel-btn > .ic:last-child { width: 14px; height: 14px; margin-left: auto; transform: rotate(90deg); color: var(--muted); flex: none; }
.fsel-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fsel-name small { color: var(--muted); }
.fsel-thumb { width: 28px; height: 28px; border-radius: 7px; object-fit: cover; flex: none; background: var(--surface-2); }
.fsel-thumb.lg { width: 42px; height: 42px; border-radius: 9px; }
.fsel-ico { display: grid; place-items: center; color: var(--muted); }
.fsel-ico .ic { width: 55%; height: 55%; }
.fsel-pop { position: absolute; z-index: 1000; display: grid; gap: 6px; padding: 6px; border: 1px solid var(--border); border-radius: 12px;
            background: var(--surface); box-shadow: 0 12px 32px rgb(0 0 0 / .18); }
.fsel-search { width: 100%; }
.fsel-list { display: grid; gap: 2px; max-height: 300px; overflow-y: auto; }
.fsel-opt { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.fsel-opt:hover, .fsel-opt:focus { background: var(--surface-2); outline: none; }
.fsel-opt.on { background: var(--brand-soft); }
.fsel-txt { flex: 1; min-width: 0; display: grid; }
.fsel-txt small { color: var(--muted); font-size: 12px; }
.fsel-stock { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.fsel-stock.low { color: var(--amber); font-weight: 600; }

/* paired device: chip, lock screen */
.device-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: rgb(255 255 255 / .15); color: #fff; font-size: 13px; font-weight: 600; }
.device-chip .ic { width: 14px; height: 14px; }
#lock-screen { position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center; padding: 20px;
               background: linear-gradient(135deg, var(--bar-1), var(--bar-2)); }
.lock-card { width: min(360px, 100%); display: grid; justify-items: center; gap: 8px; padding: 28px 22px; border-radius: 22px; background: var(--surface); box-shadow: 0 20px 60px rgb(0 0 0 / .35); }
.lock-card h1 { margin: 6px 0 0; font-size: 22px; text-align: center; }
.lock-card .muted { margin: 0; }
.lock-logo { width: 56px; height: 56px; }
.pin-dots { display: flex; gap: 12px; margin: 10px 0 2px; min-height: 16px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border-strong, var(--border)); }
.pin-dots i.on { background: var(--brand); border-color: var(--brand); }
.pin-input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.pin-msg { min-height: 18px; margin: 0; color: var(--red); font-size: 13px; text-align: center; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 72px); gap: 12px; margin-top: 4px; }
.pin-pad button { height: 64px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: 600 22px/1 inherit; cursor: pointer; }
.pin-pad button:active { transform: scale(.96); background: var(--brand-soft); }
.pin-pad .ok { background: var(--brand); color: #fff; border-color: transparent; }
.pin-pad .ok .ic { width: 24px; height: 24px; }
#lock-screen.shake .lock-card { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
/* Settings → Devices: pairing */
.pair-qr { display: grid; place-items: center; }
.pair-qr svg { width: 220px; height: 220px; }
.pair-link { display: flex; gap: 8px; margin-top: 10px; }
.pair-link input { flex: 1; min-width: 0; font-size: 12.5px; }
.pair-left { text-align: center; margin: 6px 0; }


/* device form: document kinds dropdown with checkboxes */
.kinds-dd { position: relative; }
.kinds-btn { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--border-strong, var(--border));
             border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.kinds-btn span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kinds-btn.empty span { color: var(--red); }
.kinds-btn .ic { width: 14px; height: 14px; transform: rotate(90deg); color: var(--muted); flex: none; }
.kinds-pop { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; display: grid; gap: 2px; padding: 6px; border: 1px solid var(--border);
             border-radius: 10px; background: var(--surface); box-shadow: 0 12px 30px rgb(0 0 0 / .16); }
.kinds-pop .inline-check { padding: 6px 8px; border-radius: 7px; font-weight: 400; cursor: pointer; }
.kinds-pop .inline-check:hover { background: var(--surface-2); }
.kinds-pop .kinds-all { border-bottom: 1px solid var(--border); border-radius: 7px 7px 0 0; margin-bottom: 2px; }

/* Animals: gallery view */
.view-switch { margin-left: auto; }
.view-switch button { display: inline-flex; align-items: center; gap: 6px; }
.view-switch .ic { width: 15px; height: 15px; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.gallery-tile { display: grid; gap: 8px; text-decoration: none; color: inherit; }
.gallery-photo { display: block; aspect-ratio: 1 / 1; border-radius: 14px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border);
                 box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s; }
.gallery-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-tile:hover .gallery-photo { transform: translateY(-2px); box-shadow: 0 10px 24px rgb(0 0 0 / .12); }
.gallery-none { width: 100%; height: 100%; display: grid; place-items: center; font-size: 42px; font-weight: 800; opacity: .75; }
.gallery-name { font-weight: 700; font-size: 15px; text-align: center; line-height: 1.25; }
@media (max-width: 700px) {
  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .gallery-name { font-size: 13.5px; }
  .view-switch { margin-left: 0; }
}
@media (max-width: 700px) {
  .toolbar > select { flex: 1 1 40%; min-width: 0; }
  .toolbar > .view-switch { width: 100%; }
  .toolbar > .view-switch button { flex: 1; justify-content: center; }
}
