/* /m/ — phone pages. Mobile-first: one column, 48px tap targets, light + dark. */
:root {
  --bg: #f4f6f6; --panel: #fff; --text: #1b2424; --muted: #5d6b6b; --line: #dde3e3;
  --accent: #0f766e; --accent-text: #fff; --accent-soft: #e0f2ef;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111717; --panel: #1b2323; --text: #e8eeee; --muted: #9aabab; --line: #2c3838;
    --accent: #2dd4bf; --accent-text: #062b27; --accent-soft: #163a36;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
main { max-width: 40rem; margin: 0 auto; padding: 1rem 1rem calc(2rem + env(safe-area-inset-bottom)); }
a { color: var(--accent); }

/* Bar + breadcrumbs: one sticky block, slim so the page keeps most of the screen. */
.top { position: sticky; top: 0; z-index: 2; }
html { scroll-padding-top: 6rem; }  /* #anchors land below the sticky top, not under it */
.bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(.1rem + env(safe-area-inset-top)) 1rem .1rem; background: var(--accent); color: var(--accent-text);
}
.bar .brand { font-weight: 700; }
.bar-link {
  color: var(--accent-text); text-decoration: none; font: inherit; font-weight: 600; padding: .5rem 0;
  min-height: 44px; display: inline-flex; align-items: center; background: none; border: 0; cursor: pointer;
}
.bar-nav { display: flex; align-items: center; gap: 1.25rem; }
.bar-nav form { margin: 0; }

.login { max-width: 24rem; margin: 2rem auto 0; }
.login h1 { font-size: 1.5rem; margin: 0 0 1.25rem; }
.login label { display: block; margin-bottom: 1rem; color: var(--muted); font-weight: 600; }
.login label input {
  display: block; width: 100%; margin-top: .35rem; min-height: 48px; padding: 0 1rem; font-size: 17px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text);
}
.error { background: #fde8e8; color: #8a1c1c; border-radius: 12px; padding: .75rem 1rem; }

.search { display: flex; gap: .5rem; }
.search input {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 1rem; font-size: 17px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text);
}
.search button, .button {
  min-height: 48px; padding: 0 1.1rem; border: 0; border-radius: 12px; font: inherit; font-weight: 600;
  background: var(--accent); color: var(--accent-text); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.button.secondary { background: var(--accent-soft); color: var(--text); }
.button.wide { width: 100%; margin-top: .5rem; }

.hint { color: var(--muted); margin: 1rem .25rem; }
.cards, .labs { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .5rem; }
.cards > li, .labs > li { min-width: 0; }  /* grid items may shrink: long lines truncate, no sideways scroll */
.card {
  display: flex; align-items: center; gap: .75rem; min-height: 64px; padding: .75rem 1rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; color: var(--text); text-decoration: none;
}
.card .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.card small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Initial-letter avatar: the spot a pet photo takes later (same size, same circle). */
.avatar {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 1.1rem;
}
.head .avatar { width: 64px; height: 64px; font-size: 1.6rem; }
#recent h2 { margin-top: 1.25rem; }
.chev { color: var(--muted); font-size: 1.5rem; }

.head { display: flex; align-items: center; gap: .9rem; margin-bottom: 1rem; }
.head h1 { margin: 0; font-size: 1.6rem; }
.head p { margin: .1rem 0 0; color: var(--muted); }
h2 { font-size: 1.1rem; margin: 1.5rem .25rem .5rem; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: .75rem 1rem; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .35rem 0; }
.row span, .row small { color: var(--muted); }
.row strong { text-align: right; overflow-wrap: anywhere; }
.labs .actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .5rem; }

/* Binnengekomen: external results (X-ray, …) waiting to be linked to an animal. */
.page-title { font-size: 1.4rem; margin: .25rem .25rem .25rem; overflow-wrap: anywhere; }
.notice {
  display: flex; flex-direction: column; gap: .1rem; margin-top: 1rem; padding: .85rem 1rem;
  border-radius: 14px; background: var(--accent); color: var(--accent-text); text-decoration: none;
}
.shots { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .5rem; }
.shots img { display: block; width: 100%; height: auto; border-radius: 12px; background: #000; }
.mailtext { margin-top: 1rem; white-space: normal; overflow-wrap: anywhere; }
.linked { margin: 1rem 0; }
.choices .card { cursor: pointer; }
.choices input[type=radio] { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
.choices .card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.kind { display: block; margin: 1rem .25rem .25rem; color: var(--muted); font-weight: 600; }
.kind select {
  display: block; width: 100%; margin-top: .35rem; min-height: 48px; padding: 0 .75rem; font-size: 17px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text);
}
.link-form { margin-bottom: .5rem; }

/* Navigation: the brand (top left) is always the way home; sub-pages show a trail. */
.bar .brand {
  color: var(--accent-text); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center;
}
.crumbs {
  display: flex; flex-wrap: nowrap; align-items: center; gap: .4rem; margin: 0;
  /* full-width row, text lined up with the 40rem page column */
  padding: 0 max(1rem, calc((100% - 40rem) / 2 + 1rem));
  background: var(--bg); border-bottom: 1px solid var(--line);
  font-size: .95rem; color: var(--muted); white-space: nowrap; overflow: hidden;
}
.crumbs a { color: var(--accent); text-decoration: none; padding: .5rem 0; flex: none; }
.crumbs .sep { flex: none; }
.crumbs [aria-current] { overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* Activity: Today on the landing page, the Activity page, History on the card. */
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 1.5rem .25rem .5rem; }
.section-head h2 { margin: 0; }
.section-head a { color: var(--accent); text-decoration: none; padding: .5rem 0; }
.dot {
  display: inline-block; width: 10px; height: 10px; margin-right: .4rem; border-radius: 50%;
  background: #e0592a; vertical-align: middle;
}
.activity { list-style: none; margin: 0; padding: .25rem 1rem; }
.activity li + li { border-top: 1px solid var(--line); }
.activity a, .activity li > div {
  display: flex; gap: .75rem; align-items: baseline; padding: .6rem 0; color: var(--text); text-decoration: none;
}
.activity .time { flex: none; width: 3.2rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.activity .what { min-width: 0; display: flex; flex-direction: column; }
.activity small { color: var(--muted); overflow-wrap: anywhere; }
.pager { display: flex; justify-content: space-between; gap: .5rem; margin-top: 1rem; }
.pager .button:only-child { margin-left: auto; }
/* Today rows: time beside the name; what/who wraps instead of being cut off. */
#today .title, .results .title { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
#today .when, .results .when { flex: none; color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
#today .card small { white-space: normal; overflow-wrap: anywhere; }
/* Results: filters (2 columns on a phone) and the type tag on each row */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem .75rem; }
.filters label { display: flex; flex-direction: column; gap: .2rem; font-size: .9rem; color: var(--muted); min-width: 0; }
.filters select, .filters input { width: 100%; box-sizing: border-box; min-height: 44px; font-size: 1rem; }
.filters .actions { grid-column: 1 / -1; display: flex; gap: .5rem; }
.results .tag { display: inline-block; padding: 0 .4rem; border-radius: .4rem; background: var(--accent-soft); color: var(--text); font-size: .8rem; }

/* Owners: animals with nobody to call or bill get a red outline until linked
   (or confirmed as stray / walk-in). */
:root { --warn: #c2410c; }
@media (prefers-color-scheme: dark) { :root { --warn: #fb923c; } }
.card.needs-owner, .panel.needs-owner { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn) inset; }
.warn { color: var(--warn) !important; font-weight: 600; }
.warn-row { align-items: center; }
.owner-pick { width: 100%; font: inherit; text-align: left; cursor: pointer; }
.owner-pick .chev { font-size: 1rem; color: var(--accent); }
.owner-form label { display: block; margin-bottom: .75rem; color: var(--muted); font-weight: 600; }
.owner-form input {
  display: block; width: 100%; margin-top: .35rem; min-height: 48px; padding: 0 .75rem; font-size: 17px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text);
}
.owner-form .error { display: block; margin-top: .25rem; color: var(--warn); font-weight: 400; }
.choices input[type=checkbox] { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
.choices .card:has(input[type=checkbox]:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }

/* Duplicates: our own number beside every name (two Maxes stay apart), flag + compare. */
.num { color: var(--muted); font-weight: 400; font-size: .85em; font-variant-numeric: tabular-nums; }
.notice.dup, .notice.quiet { background: var(--accent-soft); color: var(--text); }
.notice.quiet span { color: var(--accent); }
.badge {
  display: inline-block; margin-left: .4rem; padding: .05rem .5rem; border-radius: 999px;
  background: #d92d20; color: #fff; font-size: .85rem; font-weight: 700; vertical-align: .1em;
}
.notice.dup span { color: var(--accent); }
.compare { width: 100%; border-collapse: collapse; margin-top: 1rem; table-layout: fixed; }
.compare th, .compare td { text-align: left; padding: .45rem .35rem; border-top: 1px solid var(--line); overflow-wrap: anywhere; vertical-align: top; }
.compare thead th { border-top: 0; }
.compare tbody th { color: var(--muted); font-weight: 600; width: 30%; }
.compare tr.differs td { color: var(--warn); font-weight: 600; }
.merge-form { margin-top: 1rem; }

/* Visits board + new visit (consult slice 1) */
.title-row { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.badge { margin-left: auto; background: var(--warn); color: #fff; border-radius: 999px; padding: .15rem .6rem; font-size: .8rem; white-space: nowrap; }
.visit-form label { display: block; margin: .6rem 0; }
.visit-form input:not([type=radio]), .visit-form select { width: 100%; box-sizing: border-box; }
.visit-form .button { margin-top: .5rem; }
.new-animal { margin: .75rem 0; }
.new-animal summary { cursor: pointer; color: var(--accent); font-weight: 600; }

/* Consult screen */
.steps { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0; align-items: flex-start; }
.steps .cancel summary { list-style: none; cursor: pointer; }
.steps .cancel summary::-webkit-details-marker { display: none; }
.steps .cancel[open] { display: flex; flex-wrap: wrap; gap: .5rem; width: 100%; }
.steps .cancel input { flex: 1; min-width: 10rem; }
.order-list { list-style: none; margin: 0; padding: 0; }
.orders .order { display: flex; align-items: center; gap: .5rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.orders .order .text { flex: 1; }
.orders .order.done .text { color: var(--muted); }
.orders .order.cancelled .text { text-decoration: line-through; color: var(--muted); }
.add-order { display: flex; gap: .5rem; margin-top: .5rem; }
.add-order input { flex: 1; min-width: 0; }
.terms { display: flex; flex-wrap: wrap; gap: .4rem; margin: .3rem 0; }
.term { border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 999px; padding: .45rem .8rem; min-height: 40px; font: inherit; }
.term.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.term-row { margin: .6rem 0; }
.term-label { font-weight: 600; display: block; }
.term-search { width: 100%; box-sizing: border-box; margin-top: .25rem; }
.vitals { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: .5rem; }
.vitals label, .note label { display: block; font-size: .9rem; }
.vitals input, .note input, .note textarea { width: 100%; box-sizing: border-box; font: inherit; }
.save-state { display: block; font-size: .8rem; color: var(--muted); }
.save-state.ok { color: var(--accent); }
.save-state.err { color: var(--warn); }
.notice.error { background: var(--panel); border: 2px solid var(--warn); color: var(--warn); font-weight: 600; }
.link { background: none; border: 0; color: var(--accent); text-decoration: underline; padding: .25rem; font: inherit; cursor: pointer; }
.also { color: var(--accent); }

/* Animal: flags (alerts red, sterilized) on the card and in the consult header; Edit details */
.flags { display: flex; flex-wrap: wrap; gap: .3rem; margin: .35rem 0 0; }
.chip { display: inline-block; padding: .1rem .55rem; border-radius: 999px; background: var(--accent-soft); color: var(--text); font-size: .85rem; }
.chip.alert { background: #fde8e8; color: #8a1c1c; font-weight: 600; }
.chip.muted { color: var(--muted); }
.chip.pick { border: 1px solid var(--line); min-height: 36px; cursor: pointer; font: inherit; font-size: .9rem; }
.picks { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0 0 .5rem; }
.animal-form fieldset { border: 0; padding: 0; margin: .9rem 0; }
.animal-form legend { font-weight: 600; margin-bottom: .3rem; }
.animal-form textarea { width: 100%; box-sizing: border-box; font: inherit; padding: .6rem; border: 1px solid var(--line); border-radius: 12px; }
.animal-form .two { display: grid; grid-template-columns: 2fr 1fr; gap: .75rem; }
.visit-form label.check, .visit-form label.sterilized { display: inline-flex; align-items: center; gap: .5rem; min-height: 44px; margin: 0 1.25rem 0 0; }
.visit-form label.check input, .visit-form label.sterilized input { width: 22px; height: 22px; margin: 0; flex: none; }
.sterilized-set { display: flex; flex-wrap: wrap; align-items: center; }

/* Deceased closes the record; visits + weight trend on the card */
.chip.dead { background: #2b2b2b; color: #fff; font-weight: 600; }
.card.deceased { opacity: .6; }
.card.deceased strong::before { content: "† "; }
.visits .title { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.visits .chip.open { background: var(--accent); color: var(--accent-text); }
.weight { margin: .25rem .25rem .5rem; color: var(--muted); }
.weight strong { color: var(--text); }
.spark { vertical-align: middle; color: var(--accent); margin-left: .35rem; }
.deceased-form { margin-top: 1.5rem; }
.deceased-form summary { color: var(--muted); cursor: pointer; padding: .5rem 0; min-height: 44px; }
.sterilized-set legend { width: 100%; }

/* Home shortcuts: one fixed row of icons, a red count on the icon's corner. */
.shortcuts { display: grid; grid-template-columns: repeat(5, 1fr); gap: .25rem; margin-top: 1rem; }
.shortcut {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: .3rem;
  min-height: 64px; padding: .6rem .1rem .5rem; border-radius: 14px; background: var(--panel);
  border: 1px solid var(--line); color: var(--text); text-decoration: none;
  font-size: .75rem; font-weight: 600; text-align: center; line-height: 1.15;
}
.shortcut .icon { color: var(--accent); flex: none; }
.shortcut:active { background: var(--accent-soft); }
.shortcut .count {
  position: absolute; top: .25rem; right: calc(50% - 1.6rem); min-width: 1.25rem; padding: 0 .3rem;
  border-radius: 999px; background: #d92d20; color: #fff; font-size: .75rem; line-height: 1.25rem;
  font-weight: 700; box-sizing: border-box;
}
