/* Mansfield Wildlife Rescue: phone-first, big tap targets, plain language. */
:root {
  --green: #2f5d3a;
  --green-dark: #224529;
  --green-soft: #e7f0e4;
  --bark: #6b4f2e;
  --bg: #f6f4ee;
  --card: #ffffff;
  --text: #1f2a22;
  --muted: #5d6a60;
  --line: #dcd8cc;
  --red: #b3261e;
  --red-soft: #fbe9e7;
  --amber: #8a5a00;
  --amber-soft: #fff4d6;
  --radius: 12px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--green); }
h1 { font-size: 1.5rem; margin: .2em 0 .6em; }
h2 { font-size: 1.2rem; margin: 0 0 .5em; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--green); color: #fff; padding: 10px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; }
.brand-logo { height: 40px; width: auto; background: #fff; border-radius: 8px; padding: 2px; }
.brand-mark { font-size: 28px; line-height: 1; }
.brand-name { font-size: 1.05rem; }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.who { color: #d7e6d4; font-size: .95rem; }
.who strong { color: #fff; }
.logout { margin: 0; }
.topbar .link-btn { min-height: 44px; padding: 8px 12px; border: 2px solid rgba(255,255,255,.5); border-radius: 10px; text-decoration: none; font-weight: 700; }
.topbar .link-btn { color: #fff; }

.tabs {
  display: flex; gap: 4px; overflow-x: auto; background: var(--green-dark); padding: 0 8px;
}
.tabs a {
  color: #d7e6d4; text-decoration: none; padding: 14px 18px; white-space: nowrap; font-weight: 600;
  border-bottom: 3px solid transparent;
}
.tabs a.on { color: #fff; border-bottom-color: #f0c674; }

.page { max-width: 1240px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 460px; margin: 0 auto; }
.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px 16px 40px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px;
}
.empty { text-align: center; }
.big-emoji { font-size: 48px; margin: 0; }

label { display: block; font-weight: 600; margin-bottom: 14px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px;
  font: inherit; font-weight: 400; padding: 12px; min-height: 48px;
  border: 1px solid #b9b4a6; border-radius: 10px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 3px solid #a8c9a0; border-color: var(--green); }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
label.check input { width: 24px; height: 24px; min-height: 0; margin: 0; flex: none; accent-color: var(--green); }
fieldset.choice { border: 0; padding: 0; margin: 0 0 14px; }
fieldset.choice legend { font-weight: 600; margin-bottom: 6px; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: .9rem; margin-top: 4px; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 1.05em; }

.btn, summary.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 10px 18px; border-radius: 10px; border: 2px solid var(--green);
  background: var(--green); color: #fff; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--green-dark); }
.btn.big { width: 100%; font-size: 1.1rem; min-height: 54px; }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: .95rem; }
.btn.secondary { background: #fff; color: var(--green); }
.btn.secondary:hover { background: var(--green-soft); }
.btn.danger { background: var(--red); border-color: var(--red); }
.btn.danger-outline { background: #fff; color: var(--red); border-color: var(--red); }
.link-btn { background: none; border: 0; padding: 8px; font: inherit; color: var(--green); text-decoration: underline; cursor: pointer; }

.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 600; }
.flash.ok { background: var(--green-soft); color: var(--green-dark); }
.flash.error { background: var(--red-soft); color: var(--red); }
.flash.warn { background: var(--amber-soft); color: var(--amber); }

.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.rows { list-style: none; padding: 0; margin: 0; }
.rows > li {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px;
}
.rows > li > a {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; color: inherit; text-decoration: none; min-height: 56px;
}
.rows > li > a:hover { background: #fbfaf6; }
.rows > li.off { opacity: .6; }
.rows.items > li { padding: 14px 16px; display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; }
.row-main { flex: 1 1 220px; }
.row-buttons { display: flex; gap: 8px; }
.row-buttons form { margin: 0; }
.row-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.count { font-weight: 700; font-size: 1.2rem; color: var(--green); min-width: 2ch; text-align: right; }
.tag { display: inline-block; font-size: .8rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #ece9df; color: var(--muted); }
.tag.trustee { background: #f0e2c8; color: var(--bark); }
.tag.warn { background: var(--amber-soft); color: var(--amber); }
.ticklist { margin: 6px 0 0; padding-left: 20px; }
.edit-form { width: 100%; }

details.add > summary { list-style: none; }
details.add > summary::-webkit-details-marker { display: none; }
details.add[open] > summary { margin-bottom: 16px; background: #fff; color: var(--green); }

.actions form { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 16px; }
.actions form:last-child { margin-bottom: 0; }
.inline-edit label { flex: 1 1 200px; margin: 0; }

.handover { border: 2px solid var(--green); background: var(--green-soft); }
.handover dl { margin: 0 0 8px; }
.handover dt { font-weight: 600; font-size: .9rem; color: var(--muted); }
.handover dd { margin: 0 0 10px; font-size: 1.3rem; font-weight: 700; overflow-wrap: anywhere; }

@media (min-width: 700px) {
  .page { padding: 24px; }
}

/* ---------- Stage 2: animals ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hint.inline { display: inline; margin: 0; }
.pre { white-space: pre-line; }
.two { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
@media (min-width: 560px) { .two { grid-template-columns: 1fr 1fr; } }
.search { margin: 0 0 16px; }
.count-pill { display: inline-block; min-width: 1.8em; padding: 0 .4em; border-radius: 999px; background: var(--green-soft); color: var(--green-dark); font-size: .9em; text-align: center; }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { margin: 0; font-weight: 500; }
.pill input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pill span {
  display: inline-flex; align-items: center; min-height: 44px; padding: 8px 14px;
  border: 2px solid #b9b4a6; border-radius: 999px; background: #fff; cursor: pointer;
}
.pill input:checked + span { background: var(--green); border-color: var(--green); color: #fff; font-weight: 700; }
.pill input:focus-visible + span { outline: 3px solid #a8c9a0; }
.pill.cond-critical input:checked + span { background: var(--red); border-color: var(--red); }
.pill.cond-poor input:checked + span { background: #c2570c; border-color: #c2570c; }
.other-reason { margin-top: 10px; }
[hidden] { display: none !important; }

details.sub { margin-bottom: 14px; }
details.sub > summary { cursor: pointer; font-weight: 600; padding: 8px 0; }

.tag.cond-good { background: var(--green-soft); color: var(--green-dark); }
.tag.cond-fair { background: #ece9df; color: var(--muted); }
.tag.cond-poor { background: #fde7d6; color: #9a3f00; }
.tag.cond-critical { background: var(--red-soft); color: var(--red); }
.tag.big { font-size: .95rem; padding: 4px 12px; }
.tag.outcome-released { background: var(--green-soft); color: var(--green-dark); }
.tag.outcome-died, .tag.outcome-euthanised { background: #e6e3dc; color: #444; }

.enclosure-group { margin-bottom: 18px; }
.enclosure-name { font-size: 1.05rem; margin: 0 0 8px; color: var(--bark); }
.animal-cards { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 560px) { .animal-cards { grid-template-columns: 1fr 1fr; } }
.animal-card {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--line); border-left: 6px solid #cfcab9; border-radius: var(--radius);
  color: inherit; text-decoration: none;
}
.animal-card:hover { background: #fbfaf6; }
.cond-border-good { border-left-color: #6aa364; }
.cond-border-poor { border-left-color: #e0823a; }
.cond-border-critical { border-left-color: var(--red); }
.animal-top { display: flex; justify-content: space-between; align-items: center; }
.animal-title { font-size: 1.1rem; }
.ref { font-family: ui-monospace, Consolas, monospace; font-weight: 700; color: var(--muted); font-size: .9rem; }
.big-ref { font-size: 1rem; }

.summary-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.summary-head h1 { margin: 0 0 8px; }
.where { background: var(--green-soft); border-radius: 10px; padding: 10px 14px; margin: 6px 0 14px; }
.where-label { display: block; font-size: .85rem; color: var(--green-dark); font-weight: 600; }
.where-name { font-size: 1.3rem; color: var(--green-dark); }
.facts { display: grid; grid-template-columns: 1fr; margin: 0 0 12px; }
.facts dt { font-size: .85rem; color: var(--muted); font-weight: 600; margin-top: 8px; }
.facts dd { margin: 0; }
@media (min-width: 560px) { .facts { grid-template-columns: max-content 1fr; gap: 6px 18px; } .facts dt { margin-top: 0; } }

.row-form { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; margin-bottom: 16px; }
.row-form select, .row-form input { flex: 1 1 200px; margin: 0; }
.card .row-form { margin-bottom: 0; }
#notes textarea { margin-bottom: 10px; }
.timeline { list-style: none; padding: 0; margin: 14px 0 0; }
.timeline li { padding: 10px 0; border-top: 1px solid var(--line); }
.timeline .when { display: block; font-size: .85rem; color: var(--muted); font-weight: 600; }
.coming { background: #fbfaf6; border-style: dashed; }
.discharge-form { margin-top: 16px; }
#discharge details > summary { list-style: none; }
#discharge details > summary::-webkit-details-marker { display: none; }

/* ---------- Tablets and laptops (the rescue's devices) ---------- */
@media (min-width: 700px) {
  .animal-cards { grid-template-columns: repeat(2, 1fr); }
  .tabs { padding: 0 16px; }
}
@media (min-width: 960px) {
  .animal-cards { grid-template-columns: repeat(3, 1fr); }
  .animal-layout { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 0 20px; align-items: start; }
  .form-wide { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; align-items: start; }
  .form-wide .span-all { grid-column: 1 / -1; }
}
@media (min-width: 1250px) {
  .animal-cards { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 600px) {
  .who { display: none; }
}

/* ---------- Stage 3: feeds ---------- */
.hint.top { margin: 0 0 12px; }
.feed-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.feed-btn { min-height: 56px; padding: 10px 20px; font-size: 1.05rem; }
.more-feeds { margin-bottom: 12px; }
.more-feeds > summary { cursor: pointer; font-weight: 600; padding: 8px 0; color: var(--green-dark); }
.fed-earlier { margin-bottom: 8px; }
.new-feed { margin: 8px 0 4px; }
.feed-list { list-style: none; padding: 0; margin: 16px 0 0; }
.day-head { font-weight: 700; color: var(--bark); padding: 12px 0 4px; border-bottom: 2px solid var(--line); }
.feed-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--line); }
.feed-main { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.feed-time { font-family: ui-monospace, Consolas, monospace; font-weight: 700; color: var(--green-dark); }
.feed-actions { display: flex; align-items: center; gap: 6px; }
.feed-actions form { margin: 0; }
.eaten { display: flex; gap: 4px; }
.eat {
  min-height: 40px; padding: 6px 10px; border-radius: 8px; border: 1px solid #c9c4b5;
  background: #fff; color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer;
}
.eat.on.eat-all { background: var(--green); border-color: var(--green); color: #fff; font-weight: 700; }
.eat.on.eat-some { background: #e0a43a; border-color: #e0a43a; color: #fff; font-weight: 700; }
.eat.on.eat-none { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; }
.link-btn.remove { color: var(--red); font-size: .85rem; }

.status-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.status { font-size: .8rem; font-weight: 700; padding: 3px 8px; border-radius: 6px; }
.status.ok { background: var(--green-soft); color: var(--green-dark); }
.status.warn { background: var(--amber-soft); color: var(--amber); }

/* ---------- Stage 4: medication ---------- */
.sub-head { font-size: 1rem; color: var(--bark); margin: 14px 0 6px; }
.chip { display: inline-block; font-size: .75rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .02em; }
.chip.overdue { background: var(--red); color: #fff; }
.chip.due { background: #e0a43a; color: #fff; }
.dose-plan, .course-list { list-style: none; padding: 0; margin: 0 0 8px; }
.slot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
.slot form { margin: 0 0 0 auto; }
.slot-time { font-family: ui-monospace, Consolas, monospace; font-weight: 800; font-size: 1.05rem; }
.slot-what { flex: 1 1 180px; }
.slot-done { color: var(--green-dark); font-weight: 700; font-size: .9rem; margin-left: auto; }
.slot-overdue { border-color: var(--red); background: var(--red-soft); }
.slot-due { border-color: #e0a43a; background: var(--amber-soft); }
.slot-given { opacity: .75; }
.course-list li { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.course-list form { margin: 0; }
.med-actions { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.med-form > summary { list-style: none; display: flex; width: 100%; white-space: nowrap; }
.med-form > summary::-webkit-details-marker { display: none; }
.med-form[open] > summary { background: var(--green-soft); }
.med-form form { margin-top: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #fbfaf6; }
.dose-row { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 560px) { .dose-row { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); } }
.custom-times { margin-top: 10px; }
.status.bad { background: var(--red); color: #fff; }
.status.info { background: #e6eef7; color: #1f4b7a; }

.round-summary { font-size: 1.05rem; }
.toggle { display: inline-flex; border: 2px solid var(--green); border-radius: 10px; overflow: hidden; margin-bottom: 16px; }
.toggle a { padding: 10px 16px; text-decoration: none; font-weight: 700; color: var(--green); min-height: 44px; display: flex; align-items: center; }
.toggle a.on { background: var(--green); color: #fff; }
table.round { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.round th { text-align: left; font-size: .85rem; color: var(--muted); background: #f1efe7; padding: 10px 12px; }
table.round td { padding: 12px; border-top: 1px solid var(--line); vertical-align: middle; }
table.round td form { margin: 0; }
table.round tr.slot-overdue td { background: var(--red-soft); }
table.round tr.slot-due td { background: var(--amber-soft); }
table.round .chip { margin-left: 6px; }
.print-only { display: none; }

@media print {
  .topbar, .tabs, .foot, .no-print, .flash { display: none !important; }
  .print-only { display: table-cell; min-width: 140px; }
  body { background: #fff; font-size: 12pt; }
  .page { max-width: none; padding: 0; }
  table.round tr td { background: #fff !important; }
  .chip { border: 1px solid #000; color: #000 !important; background: #fff !important; }
}

/* ---------- Stage 5: daily checklist ---------- */
#checklist .head-row h2 { margin: 0; }
.progress { font-weight: 800; padding: 4px 12px; border-radius: 999px; background: var(--amber-soft); color: var(--amber); }
.progress.all { background: var(--green-soft); color: var(--green-dark); }
.checklist { list-style: none; padding: 0; margin: 12px 0 6px; display: grid; gap: 8px; }
.checklist form { margin: 0; }
.check-row {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 56px; padding: 10px 14px;
  border: 2px solid #c9c4b5; border-radius: 12px; background: #fff; color: var(--text);
  font: inherit; font-size: 1.05rem; text-align: left; cursor: pointer;
}
.check-row:hover { border-color: var(--green); }
.check-row:disabled { cursor: default; opacity: .8; }
.check-row .box {
  flex: none; width: 32px; height: 32px; border-radius: 8px; border: 2px solid #9d978a;
  display: grid; place-items: center; font-weight: 900; font-size: 1.2rem; color: #fff;
}
.check-row.done { background: var(--green-soft); border-color: #9cc596; }
.check-row.done .box { background: var(--green); border-color: var(--green); }
.check-row.done .check-text { color: var(--green-dark); font-weight: 700; }
.check-text { flex: 1; }
.check-who { font-size: .85rem; color: var(--muted); white-space: nowrap; }
#checklist .row-form { margin-top: 12px; }
.grid-scroll { overflow-x: auto; }
.tick-grid { border-collapse: collapse; margin-top: 8px; font-size: .9rem; }
.tick-grid th, .tick-grid td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.tick-grid tbody th { text-align: left; font-weight: 600; }
.tick-grid thead th { color: var(--muted); font-size: .8rem; }
.tick-grid td.yes { color: var(--green); font-weight: 900; }
.tick-grid td.no { color: #c0bba9; }

/* ---------- Stage 6: help, records ---------- */
.section-gap { margin-top: 24px; }
.help-grid { display: grid; gap: 0 16px; }
@media (min-width: 960px) { .help-grid { grid-template-columns: 1fr 1fr; } }
.help-grid ul { padding-left: 20px; margin: 0; }
.help-grid li { margin-bottom: 6px; }
