:root {
  --bg: #f2f4ee; --card: #ffffff; --ink: #1f2a1f; --muted: #6b7466; --line: #dde2d6;
  --brand: #2f6b3a; --brand-ink: #ffffff; --soft: #e7efe5;
  --bad: #b3261e; --bad-soft: #fbe9e7; --warn: #a15c00; --warn-soft: #fff1d6;
  --egg: #b07a12; --ok: #2f6b3a; --ok-soft: #e3f1e1;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark;
    --bg: #141814; --card: #1e241e; --ink: #ebefe8; --muted: #9aa596; --line: #2e362d;
    --brand: #5fa86c; --brand-ink: #0d140e; --soft: #243024;
    --bad: #ff8a80; --bad-soft: #3a1f1d; --warn: #ffc266; --warn-soft: #3a2d14;
    --egg: #e6b552; --ok: #7ccb88; --ok-soft: #1f3322;
  }
}
:root[data-theme="dark"] { color-scheme: dark;
  --bg: #141814; --card: #1e241e; --ink: #ebefe8; --muted: #9aa596; --line: #2e362d;
  --brand: #5fa86c; --brand-ink: #0d140e; --soft: #243024;
  --bad: #ff8a80; --bad-soft: #3a1f1d; --warn: #ffc266; --warn-soft: #3a2d14;
  --egg: #e6b552; --ok: #7ccb88; --ok-soft: #1f3322;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--brand); color: var(--brand-ink);
}
.brand { font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { margin-right: 2px; }
.pill { border: 0; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.sync { background: var(--soft); color: var(--ink); }
main { max-width: 640px; margin: 0 auto; padding: 16px; }
h1 { font-size: 24px; margin: 4px 0 2px; }
h2 { font-size: 17px; margin: 0 0 10px; }
.sec { margin: 22px 0 10px; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); font-size: 14px; }
.bad { color: var(--bad); } .warn { color: var(--warn); }
.hello { margin-bottom: 12px; }
.hello div { color: var(--muted); font-size: 14px; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.kpi b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 13px; color: var(--muted); }
.kpi.bad b { color: var(--bad); } .kpi.egg b { color: var(--egg); }

.alert { margin-top: 12px; background: var(--warn-soft); color: var(--warn); border-radius: var(--radius); padding: 12px 14px; font-size: 14px; }
.alert b { display: block; margin-bottom: 4px; }
.alert div { margin: 2px 0; }

.card {
  display: block; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 10px; cursor: pointer;
}
.card:active { transform: scale(.99); }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.nm { font-weight: 700; font-size: 18px; }
.tag { font-size: 12px; background: var(--soft); padding: 3px 8px; border-radius: 999px; color: var(--muted); white-space: nowrap; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.row3 b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.row3 span { font-size: 12px; color: var(--muted); }
.meta { margin-top: 8px; font-size: 13px; color: var(--muted); }

.back { background: none; border: 0; color: var(--brand); font-weight: 600; padding: 4px 0; cursor: pointer; font-size: 16px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat span { display: block; font-size: 12px; color: var(--muted); }
.stat b { font-size: 18px; font-variant-numeric: tabular-nums; }
.stat.big { background: var(--soft); }
.stat.big b { font-size: 24px; }
.target { margin: 10px 0 4px; font-weight: 600; font-size: 15px; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-top: 14px; }
label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 12px; }
label input, label select { display: block; width: 100%; margin-top: 4px; }
input, select {
  border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 11px 12px; min-height: 46px; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 0; }
.step { margin-bottom: 12px; }
.step .lbl { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.ctl { display: grid; grid-template-columns: 56px 1fr 56px; gap: 8px; }
.ctl button { border: 1px solid var(--line); background: var(--soft); border-radius: 10px; font-size: 24px; font-weight: 700; cursor: pointer; }
.ctl input { text-align: center; font-size: 22px; font-weight: 700; }
.primary, .secondary, .danger {
  width: 100%; border: 0; border-radius: 12px; padding: 14px; font-weight: 700; font-size: 17px; cursor: pointer; margin-top: 4px;
}
.primary { background: var(--brand); color: var(--brand-ink); }
.secondary { background: var(--soft); color: var(--ink); margin-top: 8px; }
.danger { background: var(--bad-soft); color: var(--bad); margin-top: 8px; }
.small { width: auto; padding: 8px 12px; font-size: 14px; border-radius: 10px; border: 0; cursor: pointer; background: var(--soft); font-weight: 600; }
.small.bad { background: var(--bad-soft); color: var(--bad); }

.hist { list-style: none; padding: 0; margin: 0; }
.hist li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.hist li:first-child { border-top: 0; }
.hist .what { font-weight: 600; }
.hist .sub { font-size: 12px; color: var(--muted); }
.hist .void .what { text-decoration: line-through; color: var(--muted); }
.t-mortality { color: var(--bad); } .t-harvest { color: var(--brand); } .t-eggs { color: var(--egg); }

.empty { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted); margin-top: 12px; }

.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
tfoot td { font-weight: 700; border-bottom: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--ink); font-size: 16px; margin: 0; }
.switch input { width: 52px; min-height: 30px; height: 30px; accent-color: var(--brand); }
.facrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.facrow:first-of-type { border-top: 0; }
.facrow .btns { display: flex; gap: 6px; }
.archived .nm2 { color: var(--muted); text-decoration: line-through; }
.nm2 { font-weight: 600; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs button { flex: 1; border: 0; background: none; padding: 10px 4px 12px; font-size: 13px; color: var(--muted); cursor: pointer; }
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabs .ic { width: 24px; height: 24px; }
.tabs button.on { color: var(--brand); font-weight: 700; }

#toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 12px; font-size: 15px; max-width: calc(100% - 32px);
  opacity: 0; pointer-events: none; transition: .2s; z-index: 10; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.login { max-width: 380px; margin: 30px auto; }
.login .panel { margin-top: 18px; }
.tip { font-size: 13px; color: var(--muted); margin-top: 14px; line-height: 1.5; }
.install { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--soft); border-radius: var(--radius); padding: 12px 14px; margin-top: 12px; font-size: 14px; }

.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.sheet { background: var(--card); color: var(--ink); border-radius: 18px; padding: 18px; width: 100%; max-width: 440px; }
.sheet p { margin: 0 0 16px; font-size: 17px; }
.sheet-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet-btns button { margin-top: 0; }
.danger.solid { background: var(--bad); color: var(--card); }
button:focus-visible, .card:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
