/* ============================================================================
   KRAAL · Kwanare Farm OS (demo)  —  the portal shell and every page.

   CONTRACT (Stage 2 / 2.5, Track P):
   - Two neutrals + one accent. Ink is green-black ("veld at first light"),
     paper is bone. Brass accent = needs action + primary CTA + current period.
     Never on body text. Count it: <= 3 accent elements per viewport.
   - Surface ramp tinted toward the brand hue; no pure #000 / #fff anywhere.
   - Muted text derived from bone by alpha. Hairlines = bone at 9% / 16%.
   - Display: Bricolage Grotesque 700-800, tracking -0.02em. Body: Inter.
     IDs and figures: JetBrains Mono, tabular-nums. Micro-labels 11px / .32em caps.
   - Motion: enter/exit cubic-bezier(.23,1,.32,1); route change 350ms blur;
     press scale(.97) 160ms; counters count once; reduced-motion honoured.
   - Species carry fixed chart hues (dataviz-validated on #131a14, 2026-11-17):
     cattle #c98500 · game #3987e5 · small stock #199e70 · birds #9085e9.
   - Banned: repeat(auto-fit,minmax()), two primaries, emoji icons, spinners.
   ========================================================================== */
:root {
  --ink: #0b100c; --coal: #11170f; --card: #161e14; --card-2: #1c2519; --raise: #222c1f;
  --bone: #ede6d6;
  --muted: rgba(237, 230, 214, .62); --faint: rgba(237, 230, 214, .40);
  --acc: #d8b25a; --acc-bright: #f0cf7a; --acc-soft: rgba(216, 178, 90, .14); --acc-ink: #141005;
  --line: rgba(237, 230, 214, .09); --line-2: rgba(237, 230, 214, .16);
  --good: #2fbf71; --warn: #f0a33a; --bad: #ef5a5a; --info: #6ab7ff;
  --good-soft: rgba(47, 191, 113, .14); --warn-soft: rgba(240, 163, 58, .14); --bad-soft: rgba(239, 90, 90, .14); --info-soft: rgba(106, 183, 255, .14);
  --s-cattle: #c98500; --s-game: #3987e5; --s-small: #199e70; --s-birds: #9085e9;
  --wa: #25d366;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --radius: 16px; --radius-sm: 10px;
  --ease: cubic-bezier(.23, 1, .32, 1);
  --side: 252px; --top: 64px;
  --shadow: 0 1px 0 rgba(0,0,0,.2), 0 18px 40px -22px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ink); color: var(--bone);
  font: 15px/1.5 var(--body); -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
body::before {
  /* the dawn: one soft brass glow low on the horizon, fixed */
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(60% 40% at 50% 110%, rgba(216, 178, 90, .10), transparent 70%),
    radial-gradient(40% 30% at 10% -10%, rgba(47, 191, 113, .05), transparent 70%);
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: inline-block; vertical-align: middle; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--acc); color: var(--acc-ink); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono, .tag, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.kicker { margin: 0 0 4px; font-size: 11px; letter-spacing: .32em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.02em; margin: 0; font-weight: 700; line-height: 1.1; }
h2 { font-size: 20px; } h3 { font-size: 16px; }

/* ---------- loader ---------- */
#loader {
  position: fixed; inset: 0; z-index: 90; background: var(--ink);
  display: grid; place-content: center; justify-items: center; gap: 10px;
  transition: opacity .8s var(--ease);
}
#loader.hidden { opacity: 0; pointer-events: none; }
.ld-scene { overflow: visible; }
.ld-sun { fill: var(--acc); transform: translateY(22px); animation: ldSun 1s var(--ease) .1s forwards; }
.ld-ground { stroke: var(--line-2); stroke-width: 1.5; stroke-linecap: round; }
.ld-tags rect { fill: var(--line-2); animation: ldTag .4s var(--ease) forwards; }
.ld-tags rect:nth-child(1) { animation-delay: .55s } .ld-tags rect:nth-child(2) { animation-delay: .63s }
.ld-tags rect:nth-child(3) { animation-delay: .71s } .ld-tags rect:nth-child(4) { animation-delay: .79s }
.ld-tags rect:nth-child(5) { animation-delay: .87s } .ld-tags rect:nth-child(6) { animation-delay: .95s }
@keyframes ldSun { to { transform: translateY(0); } }
@keyframes ldTag { to { fill: var(--acc); } }
.ld-mark { font: 800 28px/1 var(--display); letter-spacing: -0.02em; }
.ld-status { font-size: 11px; letter-spacing: .32em; text-transform: uppercase; color: var(--faint); }
.ld-bar { width: 160px; height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.ld-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--acc), var(--acc-bright)); animation: ldFill 1.1s var(--ease) forwards; }
@keyframes ldFill { to { width: 100%; } }

/* ---------- layout ---------- */
.app { position: relative; z-index: 1; display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100dvh; }
.side {
  position: sticky; top: 0; height: 100dvh; background: var(--coal); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px 14px; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 4px 8px; }
.brand__mark { width: 30px; height: 30px; }
.brand__text { display: flex; flex-direction: column; line-height: 1.05; }
.brand__name { font: 800 19px var(--display); letter-spacing: -0.02em; }
.brand__farm { font-size: 11px; letter-spacing: .32em; text-transform: uppercase; color: var(--faint); margin-top: 3px; }
.nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; padding-top: 6px; }
.nav__group { display: flex; flex-direction: column; gap: 2px; }
.nav__label { font-size: 10.5px; letter-spacing: .32em; text-transform: uppercase; color: var(--faint); padding: 0 10px 6px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--muted); font-weight: 500; font-size: 14px;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a:hover { background: var(--card); color: var(--bone); }
.nav a[aria-current="page"] { background: var(--card-2); color: var(--bone); box-shadow: inset 2px 0 0 var(--acc); }
.nav a .cnt { margin-left: auto; font: 600 11px var(--mono); color: var(--acc-ink); background: var(--acc); padding: 2px 7px; border-radius: 999px; }
.nav a .cnt--soft { background: var(--card-2); color: var(--muted); border: 1px solid var(--line-2); }
.side__foot { display: flex; flex-direction: column; gap: 10px; }
.farmbox { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); }
.farmbox__t { font-size: 13px; font-weight: 600; }
.farmbox__s { font-size: 12px; color: var(--faint); }
.side__by { font-size: 11px; color: var(--faint); padding: 0 10px; letter-spacing: .04em; }
.side__by span { color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.dot--good { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.dot--warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot--bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.dot--off { background: var(--faint); }

.work { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 20; height: var(--top);
  display: flex; align-items: center; gap: 12px; padding: 0 22px;
  background: rgba(11, 16, 12, .78); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.top__menu { display: none; }
.iconbtn {
  position: relative; width: 40px; height: 40px; border-radius: 12px; border: 1px solid transparent; background: transparent; color: var(--muted);
  display: inline-grid; place-items: center; transition: background .2s var(--ease), color .2s var(--ease), transform .16s var(--ease);
}
.iconbtn:hover { background: var(--card); color: var(--bone); }
.iconbtn:active { transform: scale(.97); }
.iconbtn__badge { position: absolute; top: 5px; right: 5px; font: 600 10px var(--mono); background: var(--acc); color: var(--acc-ink); border-radius: 999px; padding: 1px 5px; }
.search { position: relative; flex: 1 1 0; min-width: 0; max-width: 520px; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); color: var(--faint); }
.search:focus-within { border-color: var(--line-2); color: var(--muted); }
.search input { flex: 1; background: none; border: 0; outline: none; color: var(--bone); min-width: 0; }
.search input::placeholder { color: var(--faint); }
.search kbd { font: 500 11px var(--mono); border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 6px; color: var(--faint); }
.search__results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--card-2); border: 1px solid var(--line-2); border-radius: 12px;
  box-shadow: var(--shadow); overflow: hidden; z-index: 30; max-height: 360px; overflow-y: auto;
}
.search__results a { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 10px 14px; text-decoration: none; border-bottom: 1px solid var(--line); }
.search__results a:hover, .search__results a:focus { background: var(--raise); }
.search__results .faint { font-size: 12px; }
.syncpill {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 10px; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--card); color: var(--bone); font-size: 13px; font-weight: 500; transition: border-color .3s var(--ease), background .3s var(--ease);
  white-space: nowrap; flex: none;
}
.syncpill__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.syncpill__count { font: 600 11px var(--mono); background: var(--acc); color: var(--acc-ink); border-radius: 999px; padding: 1px 7px; }
.syncpill.is-off { border-color: rgba(240,163,58,.45); background: var(--warn-soft); }
.syncpill.is-off .syncpill__dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.syncpill.is-syncing .syncpill__dot { background: var(--info); box-shadow: 0 0 0 3px var(--info-soft); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.who__role { height: 36px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--card); color: var(--bone); padding: 0 32px 0 12px; font-size: 13px; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 15px, calc(100% - 12px) 15px; background-size: 5px 5px; background-repeat: no-repeat; max-width: 240px; text-overflow: ellipsis; }

.main { padding: 28px 30px 60px; max-width: 1480px; width: 100%; margin: 0 auto; animation: routeIn .35s var(--ease); }
.main.is-leaving { opacity: 0; filter: blur(8px); transition: opacity .18s var(--ease), filter .18s var(--ease); }
@keyframes routeIn { from { opacity: 0; filter: blur(8px); transform: translateY(6px); } to { opacity: 1; filter: blur(0); transform: none; } }

/* ---------- page head ---------- */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 24px; flex-wrap: wrap; }
.head h1 { font-size: clamp(1.9rem, 2.6vw, 2.7rem); font-weight: 800; }
.head h1 em { font-style: normal; color: var(--acc); }
.head__sub { margin: 6px 0 0; color: var(--muted); max-width: 64ch; }
.head__actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  border: 1px solid var(--line-2); background: var(--card); color: var(--bone); text-decoration: none; white-space: nowrap;
  transition: background .2s var(--ease), border-color .2s var(--ease), transform .16s var(--ease), color .2s var(--ease);
}
.btn:hover { background: var(--card-2); border-color: var(--line-2); }
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; }
.btn--primary { background: var(--acc); color: var(--acc-ink); border-color: transparent; }
.btn--primary:hover { background: var(--acc-bright); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn--ghost:hover { background: var(--card); color: var(--bone); }
.btn--wa { background: rgba(37, 211, 102, .14); border-color: rgba(37, 211, 102, .35); }
.btn--sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn--big { height: 56px; font-size: 16px; padding: 0 22px; border-radius: 14px; width: 100%; justify-content: center; }
.btn--danger { color: var(--bad); border-color: rgba(239,90,90,.35); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--line-2); background: var(--card-2); color: var(--muted); white-space: nowrap; }
.pill svg { width: 12px; height: 12px; }
.pill--good { color: var(--good); background: var(--good-soft); border-color: rgba(47,191,113,.3); }
.pill--warn { color: var(--warn); background: var(--warn-soft); border-color: rgba(240,163,58,.3); }
.pill--bad { color: var(--bad); background: var(--bad-soft); border-color: rgba(239,90,90,.3); }
.pill--info { color: var(--info); background: var(--info-soft); border-color: rgba(106,183,255,.3); }
.pill--acc { color: var(--acc); background: var(--acc-soft); border-color: rgba(216,178,90,.35); }
.pill--sp { color: var(--bone); }
.pill--sp i { width: 8px; height: 8px; border-radius: 2px; background: var(--sp); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; padding: 3px; background: var(--card); gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); height: 28px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--card-2); color: var(--bone); border: 1px solid var(--line-2); }

/* ---------- cards & grids ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; min-width: 0; transition: transform .25s var(--ease), border-color .25s var(--ease); }
.card--hover:hover { transform: translateY(-4px); border-color: var(--line-2); }
.card h2 { margin-bottom: 4px; }
.card__sub { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card--flat { padding: 0; overflow: hidden; }
.grid { display: grid; gap: 18px; }
.grid--kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--2 { grid-template-columns: 7fr 5fr; }
.grid--21 { grid-template-columns: 2fr 1fr; }
.grid--31 { grid-template-columns: 3fr 2fr; }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 18px; }
.kpi { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px; }
.kpi__top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; }
.kpi__chip { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--card-2); color: var(--bone); }
.kpi__chip svg { width: 18px; height: 18px; }
.kpi__chip--sp { background: color-mix(in srgb, var(--sp) 18%, transparent); color: var(--sp); }
.kpi__num { font: 600 34px/1 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi__num small { font-size: 16px; color: var(--muted); font-weight: 500; }
.kpi__delta { font-size: 12.5px; color: var(--muted); }
.kpi__delta.up { color: var(--good); } .kpi__delta.down { color: var(--bad); }
.kpi--acc { border-color: rgba(216,178,90,.4); background: linear-gradient(180deg, var(--acc-soft), transparent 60%), var(--card); }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list__ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--card-2); color: var(--muted); flex: none; }
.list__ico svg { width: 17px; height: 17px; }
.list__ico--warn { color: var(--warn); background: var(--warn-soft); }
.list__ico--bad { color: var(--bad); background: var(--bad-soft); }
.list__ico--acc { color: var(--acc); background: var(--acc-soft); }
.list__ico--good { color: var(--good); background: var(--good-soft); }
.list__ico--info { color: var(--info); background: var(--info-soft); }
.list__t { font-weight: 600; font-size: 14px; }
.list__s { color: var(--muted); font-size: 12.5px; }
.list a.list__t { text-decoration: none; }
.list a.list__t:hover { text-decoration: underline; }
.feed li { grid-template-columns: 56px minmax(0,1fr); align-items: start; }
.feed time { font: 500 12px var(--mono); color: var(--faint); padding-top: 2px; }

/* ---------- tables ---------- */
.tablewrap { overflow: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.tbl th, .tbl td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.tbl th { position: sticky; top: 0; background: var(--card-2); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); font-weight: 600; z-index: 1; cursor: pointer; user-select: none; }
.tbl th[aria-sort="ascending"]::after { content: ' ↑'; color: var(--acc); }
.tbl th[aria-sort="descending"]::after { content: ' ↓'; color: var(--acc); }
.tbl tbody tr { transition: background .15s var(--ease); cursor: pointer; }
.tbl tbody tr:hover { background: var(--card-2); }
.tbl td.num { text-align: right; }
.tbl .tag { font-weight: 600; }
.tbl tr:last-child td { border-bottom: 0; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .lbl { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
.input, .select, textarea.input { height: 40px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--coal); color: var(--bone); padding: 0 12px; min-width: 0; }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }
.input:focus, .select:focus, textarea.input:focus { border-color: var(--acc); outline: none; }
.select { appearance: none; -webkit-appearance: none; padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px; background-size: 5px 5px; background-repeat: no-repeat; }
.input--big { height: 56px; font-size: 18px; border-radius: 14px; }
.state { padding: 36px 20px; text-align: center; color: var(--muted); }
.state strong { display: block; color: var(--bone); font-size: 16px; margin-bottom: 6px; }
.skel { background: linear-gradient(90deg, var(--card) 25%, var(--card-2) 50%, var(--card) 75%); background-size: 200% 100%; animation: skel 1.2s infinite; border-radius: var(--radius); }
@keyframes skel { to { background-position: -200% 0; } }
.ribbon { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--faint); border: 1px dashed var(--line-2); border-radius: 999px; padding: 3px 10px; }

/* ---------- drawer / dialogs / toasts ---------- */
.drawer { position: fixed; inset: 0; z-index: 60; display: flex; justify-content: flex-end; background: rgba(5, 8, 6, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.drawer[hidden] { display: none; }
.drawer__panel { width: min(640px, 100%); height: 100%; background: var(--coal); border-left: 1px solid var(--line-2); display: flex; flex-direction: column; animation: slideIn .32s var(--ease); box-shadow: var(--shadow); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 24px 14px; border-bottom: 1px solid var(--line); }
.drawer__head h2 { font-size: 24px; font-weight: 800; }
.drawer__body { padding: 20px 24px 40px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.drawer .card { background: var(--card); }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
.kv div { display: flex; flex-direction: column; gap: 2px; }
.kv dt { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
.kv dd { margin: 0; font-weight: 500; }
.kv dd.tag { font-size: 14px; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 1px; background: var(--line-2); }
.timeline li { position: relative; padding: 0 0 14px 28px; }
.timeline li::before { content: ''; position: absolute; left: 3px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--card-2); border: 2px solid var(--muted); }
.timeline li.acc::before { border-color: var(--acc); background: var(--acc); }
.timeline li.warn::before { border-color: var(--warn); }
.timeline .t { font-weight: 600; font-size: 14px; }
.timeline .s { color: var(--muted); font-size: 12.5px; }
.timeline time { font: 500 12px var(--mono); color: var(--faint); margin-left: 8px; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.actions .btn { justify-content: center; }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo { position: relative; aspect-ratio: 4/3; border-radius: 10px; overflow: hidden; background: var(--card-2); border: 1px solid var(--line); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo__ph { width: 100%; height: 100%; display: grid; place-items: center; color: var(--faint); }
.photo__ph svg { width: 28px; height: 28px; }
.photo__cap { position: absolute; left: 6px; right: 6px; bottom: 6px; font: 500 10.5px var(--mono); padding: 3px 7px; border-radius: 6px; background: rgba(11,16,12,.78); color: var(--bone); display: flex; justify-content: space-between; gap: 6px; }
.photo__cap.good { color: var(--good); } .photo__cap.warn { color: var(--warn); }
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; width: min(520px, calc(100% - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: 12px; background: var(--raise); border: 1px solid var(--line-2); box-shadow: var(--shadow); animation: toastIn .3s var(--ease); font-size: 14px; }
.toast svg { width: 18px; height: 18px; flex: none; }
.toast--good svg { color: var(--good); } .toast--warn svg { color: var(--warn); } .toast--bad svg { color: var(--bad); } .toast--info svg { color: var(--info); }
.toast.out { opacity: 0; transform: translateY(8px); transition: opacity .3s var(--ease), transform .3s var(--ease); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ---------- charts (dataviz) ---------- */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-text { fill: var(--faint); font: 500 11px var(--mono); }
.chart .bar { transition: opacity .2s var(--ease); }
.chart .bar.dim { opacity: .45; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: .12; }
.chart .marker { stroke: var(--card); stroke-width: 2; }
.chart .dlabel { fill: var(--bone); font: 600 11px var(--mono); }
.chart .donut-total { fill: var(--bone); font: 600 26px var(--mono); text-anchor: middle; }
.chart .donut-lbl { fill: var(--faint); font: 600 10px var(--body); text-anchor: middle; letter-spacing: .2em; text-transform: uppercase; }
.tip { position: absolute; z-index: 5; pointer-events: none; background: var(--raise); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; box-shadow: var(--shadow); white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); }
.tip b { font-family: var(--mono); font-weight: 600; }
.tip .row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.tip .row i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend b { color: var(--bone); font-family: var(--mono); font-weight: 600; }
.donut-wrap { display: grid; grid-template-columns: 180px 1fr; gap: 16px; align-items: center; }
.donut-wrap .legend { display: grid; grid-template-columns: 1fr 1fr; margin: 0; }
.sp-cattle { --sp: var(--s-cattle); } .sp-game { --sp: var(--s-game); } .sp-small { --sp: var(--s-small); } .sp-birds { --sp: var(--s-birds); }

/* ---------- specific blocks ---------- */
.synccard { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; }
.synccard__big { font: 800 22px var(--display); letter-spacing: -0.02em; }
.synccard__state { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--good-soft); color: var(--good); }
.synccard__state svg { width: 26px; height: 26px; }
.synccard.off .synccard__state { background: var(--warn-soft); color: var(--warn); }
.synccard__devs { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.synccard__devs b { color: var(--bone); font-family: var(--mono); font-weight: 600; }
.needs li { grid-template-columns: auto minmax(0,1fr) auto; }
.capture { display: grid; grid-template-columns: 7fr 5fr; gap: 20px; align-items: start; }
.capture .big-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.capture__animal { display: flex; gap: 14px; align-items: center; padding: 14px 16px; background: var(--card-2); border-radius: 12px; border: 1px solid var(--line-2); }
.capture__animal .tag { font-size: 18px; font-weight: 600; }
.dropzone { border: 1.5px dashed var(--line-2); border-radius: 14px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .2s var(--ease), background .2s var(--ease); background: var(--coal); }
.dropzone:hover, .dropzone.over { border-color: var(--acc); background: var(--acc-soft); }
.dropzone svg { width: 28px; height: 28px; color: var(--faint); margin-bottom: 6px; }
.dropzone input { display: none; }
.exif { display: grid; grid-template-columns: 96px 1fr; gap: 14px; align-items: center; padding: 12px; background: var(--card-2); border-radius: 12px; border: 1px solid var(--line-2); }
.exif img { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; }
.exif__t { font-weight: 600; }
.exif__s { color: var(--muted); font-size: 12.5px; }
.msg { display: grid; grid-template-columns: 40px minmax(0,1fr); gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.msg:first-child { border-top: 0; }
.msg__av { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--card-2); font: 600 13px var(--mono); color: var(--muted); }
.msg__from { font-weight: 600; font-size: 14px; display: flex; gap: 8px; align-items: baseline; }
.msg__from time { font: 500 11.5px var(--mono); color: var(--faint); }
.msg__text { margin: 4px 0 8px; color: var(--bone); }
.msg__photo { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: center; padding: 10px; background: var(--card-2); border-radius: 12px; border: 1px solid var(--line); margin-bottom: 8px; }
.msg__photo .ph { width: 120px; height: 90px; border-radius: 8px; background: linear-gradient(135deg, var(--raise), var(--card)); display: grid; place-items: center; color: var(--faint); }
.msg__photo .ph svg { width: 26px; height: 26px; }
.msg__meta { font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.msg__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.wa-note { border: 1px solid rgba(37,211,102,.28); padding: 10px 14px; background: rgba(37,211,102,.06); border-radius: 10px; color: var(--muted); font-size: 13px; }
.caveat { border: 1px solid rgba(240,163,58,.4); background: var(--warn-soft); border-radius: 12px; padding: 12px 14px; font-size: 13px; color: var(--bone); }
.caveat b { color: var(--warn); }
.matrix { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.matrix div { padding: 6px 8px; border-radius: 8px; font: 600 11.5px var(--mono); text-align: center; border: 1px solid var(--line); }
.matrix .ok { color: var(--good); background: var(--good-soft); }
.matrix .soon { color: var(--warn); background: var(--warn-soft); }
.matrix .due { color: var(--bad); background: var(--bad-soft); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs button { border: 0; background: none; color: var(--muted); padding: 10px 14px; font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--bone); border-bottom-color: var(--acc); }
.board { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.board__col { background: var(--coal); border: 1px solid var(--line); border-radius: 14px; padding: 12px; min-height: 160px; }
.board__col h3 { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--faint); margin-bottom: 10px; display: flex; justify-content: space-between; }
.egg { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; margin-bottom: 8px; font-size: 12.5px; }
.egg .tag { font-size: 12px; }
.egg .faint { font-size: 11.5px; }
.pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; text-align: center; }
.pair .bird { padding: 10px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--line); }
.pair .bird .tag { font-size: 13px; font-weight: 600; }
.pair .x { color: var(--faint); font: 600 14px var(--mono); }
.geno { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.geno span { font: 500 11px var(--mono); background: var(--card-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 2px 6px; color: var(--muted); }
.geno span.sl { border-color: rgba(144,133,233,.5); color: var(--s-birds); }
.outcome { display: grid; grid-template-columns: 1fr auto auto; gap: 8px 14px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.outcome:first-child { border-top: 0; }
.outcome .bar { height: 6px; border-radius: 3px; background: var(--card-2); width: 120px; overflow: hidden; }
.outcome .bar i { display: block; height: 100%; background: var(--s-birds); border-radius: 3px; }
.intcard { display: grid; grid-template-columns: 44px minmax(0,1fr); gap: 14px; }
.intcard__logo { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font: 800 13px var(--display); background: var(--card-2); border: 1px solid var(--line-2); letter-spacing: -0.02em; }
.intcard h3 { font-size: 17px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.intcard p { margin: 4px 0 10px; color: var(--muted); font-size: 13.5px; }
.code { font: 500 12px/1.7 var(--mono); background: var(--coal); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--muted); overflow-x: auto; white-space: pre; }
.code b { color: var(--acc); font-weight: 600; }
.roles { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.roles th, .roles td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: center; }
.roles th:first-child, .roles td:first-child { text-align: left; }
.roles th { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
.roles .y { color: var(--good); } .roles .n { color: var(--faint); } .roles .r { color: var(--info); }
.devices li { grid-template-columns: auto minmax(0,1fr) auto; }
.log { font: 500 12.5px/1.8 var(--mono); background: var(--coal); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; max-height: 280px; overflow: auto; color: var(--muted); }
.log .ok { color: var(--good); } .log .wait { color: var(--warn); } .log .t { color: var(--faint); }
.conflict { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.conflict .opt { padding: 12px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--card-2); }
.conflict .opt .lbl { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--faint); font-weight: 600; margin-bottom: 6px; }
.report-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.report-row:first-child { border-top: 0; }
.sparks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.spark { padding: 14px 16px; }
.spark .lbl { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
.spark .val { font: 600 24px var(--mono); margin: 4px 0; }
.mobcard { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; }
.mobcard .big { font: 600 30px var(--mono); letter-spacing: -0.02em; }
.ebv { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ebv div { padding: 10px; background: var(--card-2); border-radius: 10px; border: 1px solid var(--line); text-align: center; }
.ebv .lbl { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
.ebv .v { font: 600 18px var(--mono); margin-top: 2px; }
.ebv .acc { font-size: 11px; color: var(--muted); }
.bottombar { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(5,8,6,.6); z-index: 40; }
.scrim[hidden] { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .grid--kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--2, .grid--21, .grid--31 { grid-template-columns: 1fr; }
  .grid--3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .capture { grid-template-columns: 1fr; }
  .board { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .sparks { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  :root { --top: 58px; }
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; z-index: 50; width: min(300px, 86vw); transform: translateX(-104%); transition: transform .35s var(--ease); box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .top { padding: 0 12px; gap: 8px; }
  .top__menu { display: inline-grid; }
  .who { display: none; }
  .search kbd { display: none; }
  .syncpill__text { display: none; }
  .main { padding: 18px 14px 92px; }
  .head h1 { font-size: 1.8rem; }
  .grid--3 { grid-template-columns: 1fr; }
  .grid--kpi { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
  .kpi__num { font-size: 28px; }
  .card { padding: 16px; }
  .bottombar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); background: rgba(17,23,15,.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line-2); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .bottombar a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; text-decoration: none; color: var(--faint); font-size: 10.5px; font-weight: 600; letter-spacing: .04em; border-radius: 10px; }
  .bottombar a svg { width: 22px; height: 22px; }
  .bottombar a[aria-current="page"] { color: var(--bone); }
  .bottombar__primary { color: var(--acc-ink) !important; }
  .bottombar__primary svg { background: var(--acc); border-radius: 12px; padding: 4px; width: 34px !important; height: 34px !important; margin-top: -10px; box-shadow: 0 6px 18px -6px rgba(216,178,90,.6); }
  .bottombar__primary span { color: var(--acc); }
  /* tables become cards */
  .tablewrap { border: 0; background: transparent; overflow: visible; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; white-space: normal; }
  .tbl thead { display: none; }
  .tbl tr { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
  .tbl td { padding: 4px 0; border: 0; display: flex; justify-content: space-between; gap: 12px; }
  .tbl td::before { content: attr(data-l); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
  .tbl td.num { text-align: right; }
  .drawer__panel { width: 100%; }
  .actions { grid-template-columns: repeat(2, 1fr); }
  .board { grid-template-columns: 1fr; }
  .matrix { grid-template-columns: repeat(2, 1fr); }
  .capture .big-row { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr 1fr; }
  .ebv { grid-template-columns: repeat(2, 1fr); }
  .synccard { grid-template-columns: auto 1fr; }
  .synccard > .btn { grid-column: 1 / -1; }
  .conflict { grid-template-columns: 1fr; }
  .pair { grid-template-columns: 1fr; } .pair .x { display: none; }
  .msg__photo { grid-template-columns: 1fr; }
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .donut-wrap .legend { width: 100%; }
  .card__head { flex-wrap: wrap; }
  .top .iconbtn { width: 36px; flex: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  #loader { transition: opacity .2s; }
}
@media print {
  .side, .top, .bottombar, .head__actions, .toolbar { display: none !important; }
  .app { grid-template-columns: 1fr; }
  body { background: #fff; color: #000; }
}
