:root {
  color-scheme: light;
  --ink: #16201e;
  --muted: #5d6c68;
  --paper: #f6f4ef;
  --card: #fffefb;
  --forest: #173b36;
  --teal: #25665c;
  --mint: #dcebe5;
  --amber: #9b5b13;
  --amber-bg: #fff0d2;
  --red: #9c2f2f;
  --red-bg: #fde5e1;
  --line: #d9dfdb;
  --shadow: 0 8px 30px rgb(24 42 37 / 8%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); }
a { color: var(--teal); text-underline-offset: 0.18em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.9rem, 8vw, 3rem); letter-spacing: -0.045em; }
h2 { margin-bottom: 0; font-size: clamp(1.35rem, 5vw, 1.8rem); letter-spacing: -0.025em; }
h3 { margin-bottom: 0; }

.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 10; padding: .7rem 1rem; background: white; }
.skip-link:focus { top: 1rem; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem clamp(1rem, 4vw, 3rem); color: white; background: var(--forest); }
.eyebrow { margin-bottom: .2rem; color: inherit; font-size: .73rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; opacity: .76; }
.quick-nav { display: flex; gap: .3rem; padding: .55rem 1rem; overflow-x: auto; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 4; }
.quick-nav a { flex: 0 0 auto; padding: .5rem .72rem; color: var(--forest); font-size: .88rem; font-weight: 750; text-decoration: none; border-radius: 999px; }
.quick-nav a:hover, .quick-nav a:focus { background: var(--mint); }
.page-shell { display: grid; gap: 1rem; width: min(100% - 1.25rem, 1180px); margin: 1rem auto 3rem; }

.panel, .trip-strip { background: var(--card); border: 1px solid var(--line); border-radius: 1rem; box-shadow: var(--shadow); }
.panel { padding: clamp(1rem, 3vw, 1.6rem); scroll-margin-top: 5rem; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.section-heading .eyebrow { color: var(--teal); }
.trip-strip { display: grid; gap: .9rem; padding: 1rem; color: white; background: linear-gradient(125deg, #173b36, #245a50); border: 0; }
.trip-strip div { display: grid; align-content: start; }
.trip-strip span { color: #c9ddd8; font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.trip-strip strong { font-size: .92rem; }
.trip-sidebar { display: grid; gap: .8rem; padding: 1rem; color: white; background: linear-gradient(145deg, #173b36, #245a50); border-radius: 1rem; box-shadow: var(--shadow); }
.trip-sidebar div { display: grid; }
.trip-sidebar span { color: #c9ddd8; font-size: .72rem; font-weight: 750; text-transform: uppercase; }
.trip-location { font-size: 1.05rem; }
.presence-panel { border: 2px solid #88b9ad; }
.presence-now, .presence-empty { display: flex; gap: .75rem; padding: .9rem; border-radius: .7rem; }
.presence-now { color: #114c42; background: #dcefe8; }
.presence-now p { margin: .15rem 0 0; }
.presence-empty { display: grid; background: #eef2f0; }
.presence-empty span { color: var(--muted); font-size: .84rem; }
.pulse { flex: 0 0 auto; width: .8rem; height: .8rem; margin-top: .35rem; background: #27806d; border-radius: 50%; box-shadow: 0 0 0 5px rgb(39 128 109 / 15%); }
.day-visitors { display: grid; gap: .5rem; margin-top: .7rem; }
.day-visitors article { display: grid; padding: .7rem; background: #fafbf9; border: 1px solid var(--line); border-radius: .6rem; }
.day-visitors small { color: var(--teal); font-weight: 750; }
.trip-itinerary { margin-top: 0; background: var(--card); box-shadow: var(--shadow); }
.itinerary-grid { display: grid; gap: .55rem; padding-top: .4rem; }
.itinerary-grid div { display: grid; padding: .6rem; background: #f3f7f5; border-radius: .5rem; }
.itinerary-grid span { font-size: .88rem; }
.itinerary-grid small { color: var(--muted); }

label { display: block; margin-bottom: .28rem; font-size: .84rem; font-weight: 750; }
input, select, textarea, button { font: inherit; }
input, select, textarea { width: 100%; min-height: 2.8rem; padding: .62rem .72rem; color: var(--ink); background: #fff; border: 1px solid #9ba9a4; border-radius: .55rem; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus, a:focus { outline: 3px solid #72bcb0; outline-offset: 2px; }
button, .button { display: inline-flex; align-items: center; justify-content: center; min-height: 2.8rem; padding: .62rem .9rem; color: white; font-weight: 800; text-decoration: none; background: var(--teal); border: 1px solid var(--teal); border-radius: .55rem; cursor: pointer; }
button:hover { filter: brightness(.92); }
.button.secondary, button.secondary { color: var(--forest); background: white; border-color: var(--line); }
.topbar .button.secondary { background: transparent; color: white; border-color: rgb(255 255 255 / 45%); }
.small { min-height: 2.25rem; padding: .38rem .65rem; font-size: .82rem; }
button.danger { color: var(--red); border-color: #d6a6a0; }
.stack { display: grid; gap: .65rem; }
.form-grid { display: grid; gap: .8rem; padding-top: .8rem; }
.form-grid .full { grid-column: 1 / -1; }
.inline-form { display: grid; gap: .7rem; align-items: end; }
.check { display: flex; align-items: center; gap: .5rem; margin: 0; }
.check input { width: 1.2rem; min-height: 1.2rem; accent-color: var(--teal); }
.cancel-form { margin-top: .65rem; padding-top: .65rem; border-top: 1px solid var(--line); }

details { margin-top: .8rem; padding: .7rem .8rem; background: #fbfcfa; border: 1px solid var(--line); border-radius: .7rem; }
summary { color: var(--forest); font-weight: 800; cursor: pointer; }
details[open] > summary { margin-bottom: .5rem; }
.subtle-details { background: transparent; border-style: dashed; }
.status, .tag { display: inline-flex; align-items: center; width: fit-content; padding: .22rem .52rem; border-radius: 999px; font-size: .7rem; font-weight: 850; letter-spacing: .03em; text-transform: uppercase; }
.status.good { color: #175248; background: var(--mint); }
.status.attention { color: #7d470d; background: var(--amber-bg); }
.tag { color: var(--forest); background: var(--mint); }
.tag.severity { color: #7d470d; background: var(--amber-bg); }

.today-grid { display: grid; gap: .65rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mini-slot { display: grid; gap: .3rem; min-height: 7.5rem; padding: .8rem; border-radius: .75rem; border: 1px solid var(--line); }
.mini-slot > strong, .period { text-transform: capitalize; }
.mini-slot.gap { background: var(--amber-bg); border-color: #e3b467; }
.mini-slot.claimed { background: #f5faf8; border-color: #a7c9bf; }
.mini-slot form { align-self: end; }
.next-visit { display: grid; gap: .15rem; margin-top: .8rem; padding: .9rem; background: var(--forest); color: white; border-radius: .75rem; }
.next-visit span { color: #cfdfda; }

.legend { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; color: var(--muted); font-size: .78rem; }
.dot { display: inline-block; width: .7rem; height: .7rem; margin-left: .3rem; border-radius: 50%; }
.gap-dot { background: #d99034; }.claimed-dot { background: #4f9687; }
.coverage-grid { display: grid; gap: .55rem; }
.date-row { margin: 1rem 0 .1rem; padding-bottom: .35rem; font-size: 1rem; border-bottom: 2px solid var(--forest); }
.coverage-slot { padding: .75rem; border: 1px solid var(--line); border-radius: .7rem; }
.coverage-slot.gap { background: #fffaf0; border-left: 5px solid #d99034; }
.coverage-slot.claimed { background: #f7fbf9; border-left: 5px solid #4f9687; }
.slot-summary { display: flex; justify-content: space-between; gap: 1rem; }
.slot-summary > div { display: grid; }
.slot-times { margin: .35rem 0 0; color: var(--muted); font-size: .82rem; }
.period { color: var(--muted); font-size: .76rem; font-weight: 800; }

.urgent-notice { margin-bottom: .8rem; padding: .8rem; color: #792524; background: var(--red-bg); border-left: 5px solid var(--red); border-radius: .5rem; }
.feed { display: grid; gap: .65rem; margin-top: .8rem; }
.feed-item { padding: .8rem; background: #f9faf8; border: 1px solid var(--line); border-radius: .7rem; }
.feed-item.urgent { background: var(--red-bg); border-color: #d88b82; }
.feed-item p { margin: .55rem 0; white-space: pre-wrap; }
.feed-item small { color: var(--muted); }
.contact-list details summary { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .4rem; }
.call-link { position: relative; z-index: 2; padding: .15rem .4rem; }
.placeholder-list { padding: .8rem; color: var(--muted); background: #f1f3f0; border-radius: .7rem; }
.placeholder-list p { margin-bottom: .3rem; font-weight: 700; }
.placeholder-list ul { margin: 0; padding-left: 1.2rem; }
.preserve { white-space: pre-wrap; }
.audit-list { margin: 0; padding: 0; list-style: none; }
.audit-list li { display: grid; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.audit-list time { color: var(--muted); font-size: .78rem; }
.empty-state { color: var(--muted); font-style: italic; }

.error-summary { margin: .7rem 0; padding: .75rem; color: #742321; background: var(--red-bg); border: 1px solid #d88b82; border-radius: .6rem; }
.error-summary ul { margin: .35rem 0 0; padding-left: 1.2rem; }
.error-summary a { color: inherit; }
.field-error { display: block; margin-top: .25rem; color: var(--red); font-weight: 750; }
[aria-invalid="true"] { border-color: var(--red); box-shadow: 0 0 0 1px var(--red); }

.auth-shell { display: grid; min-height: calc(100vh - 4rem); place-items: center; padding: 1rem; background: radial-gradient(circle at top right, #d6e6df, transparent 40%), var(--paper); }
.standalone-shell { display: grid; gap: 1rem; width: min(100% - 1.25rem, 960px); margin: 1rem auto 3rem; }
.visitors-heading { margin: 1rem 0 .55rem; font-size: 1rem; }
.report-links { display: flex; flex-wrap: wrap; gap: .75rem; }
.filter-grid { display: grid; gap: .7rem; align-items: end; }
.visit-list { display: grid; gap: .7rem; }
.visit-list > article { padding: .9rem; border: 1px solid var(--line); border-radius: .7rem; background: #fafbf9; }
.visit-list dl { display: grid; gap: .4rem; margin: .6rem 0; }
.visit-list dl div { display: grid; }
.visit-list dt { color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.visit-list dd { margin: 0; }
.timeline { display: grid; gap: .7rem; padding: 0; list-style: none; }
.timeline li { display: grid; grid-template-columns: 5rem 1fr; gap: .7rem; padding-bottom: .7rem; border-bottom: 1px solid var(--line); }
.timeline time { color: var(--teal); font-weight: 850; }
.timeline div { display: grid; }
.timeline small { color: var(--muted); }
.medical-boundary { padding: 1rem; color: #71211f; background: var(--red-bg); border: 2px solid #c66f66; border-radius: .8rem; }
.medical-boundary p { margin: .35rem 0 0; }
.header-actions { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.print-shell { width: min(100% - 2rem, 1100px); margin: 2rem auto; }
.print-heading { margin-bottom: 1.4rem; }
.observation-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.observation-table th, .observation-table td { padding: .55rem; text-align: left; vertical-align: top; border: 1px solid var(--line); }
.observation-table th { background: #edf2ef; }
.auth-card { width: min(100%, 26rem); padding: clamp(1.2rem, 5vw, 2rem); background: var(--card); border: 1px solid var(--line); border-radius: 1rem; box-shadow: var(--shadow); }
.auth-card .eyebrow { color: var(--teal); }
.fine-print { margin: 1rem 0 0; color: var(--muted); font-size: .8rem; }
.site-footer { padding: 1.4rem 1rem; text-align: center; color: var(--muted); font-size: .78rem; }
.site-footer p { margin: 0; }

@media (min-width: 680px) {
  .page-shell { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; }
  .trip-strip, .trip-itinerary, .wide, .identity-panel, #today, #activity { grid-column: 1 / -1; }
  .trip-strip { grid-template-columns: 1.6fr repeat(3, 1fr); }
  .itinerary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) auto auto; }
  .inline-form { grid-template-columns: minmax(15rem, 1fr) auto; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid > button { align-self: end; }
  .coverage-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .date-row { grid-column: 1 / -1; }
  .today-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 940px) {
  .page-shell { grid-template-columns: 17rem repeat(2, minmax(0, 1fr)); align-items: start; }
  .trip-sidebar { position: sticky; top: 4.5rem; grid-column: 1; grid-row: 1 / span 20; }
  .page-shell > :not(.trip-sidebar) { grid-column: 2 / -1; }
  .standalone-shell.with-sidebar { width: min(100% - 1.25rem, 1180px); grid-template-columns: 17rem minmax(0, 1fr); align-items: start; }
  .standalone-shell.with-sidebar > :not(.trip-sidebar) { grid-column: 2; }
  .day-visitors { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media print {
  .print-hide, .site-footer { display: none !important; }
  body { background: white; }
  .print-shell { width: 100%; margin: 0; }
  .observation-table { font-size: 9pt; }
  .observation-table tr { break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
