/* Collis Family Planner — mobile-first CSS */

/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --katie:  #E8589F;
  --paul:   #E05252;
  --joshua: #4A8C5C;
  --violet: #C97CC9;
  --family: #7B5BA6;
  --anyone: #6B7280;

  --bg:       #F7F8FA;
  --surface:  #FFFFFF;
  --border:   #E5E7EB;
  --text:     #1F2937;
  --text-muted: #6B7280;
  --radius:   14px;
  --shadow:   0 2px 8px rgba(0,0,0,.08);
  --transition: .18s ease;
}

/* ── Dark mode ─────────────────────────────────────────────────────────────── */
body.theme-dark {
  --bg:         #0F1117;
  --surface:    #1A1D27;
  --border:     #2D3142;
  --text:       #E8EAF0;
  --text-muted: #8B92A8;
  --shadow:     0 2px 8px rgba(0,0,0,.4);
}
body.theme-dark .btn-secondary {
  background: #2D3142; color: var(--text); border-color: var(--border);
}
body.theme-dark .form-input,
body.theme-dark .form-select,
body.theme-dark .form-textarea {
  background: #2D3142; color: var(--text); border-color: var(--border);
}
body.theme-dark .person-select {
  background: #2D3142; color: var(--text);
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow-x: hidden;
  /* Prevent side-menu from creating horizontal scrollbar on initial load */
  max-width: 100vw;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, select, textarea { font: inherit; max-width: 100%; }

/* ── Person colour helpers ─────────────────────────────────────────────────── */
.person-katie  { --person-colour: var(--katie);  }
.person-paul   { --person-colour: var(--paul);   }
.person-joshua { --person-colour: var(--joshua); }
.person-violet { --person-colour: var(--violet); }
.person-family { --person-colour: var(--family); }

/* ── Top bar ───────────────────────────────────────────────────────────────── */
.top-bar {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
}
.top-bar-inner {
  display: flex; align-items: center; gap: 8px;
  height: 52px;
}
.top-bar-title {
  font-size: .9rem; font-weight: 700; color: var(--text);
  white-space: nowrap; text-decoration: none;
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  padding-left: 4px;
}

/* Top bar icon links (admin, settings) */
.top-bar-icon {
  font-size: 1.15rem; padding: 4px 5px; border-radius: 8px;
  opacity: .55; transition: var(--transition); flex-shrink: 0;
}
.top-bar-icon:hover, .top-bar-icon.active { opacity: 1; }

/* Person dropdown */
.person-select {
  margin-left: auto;
  padding: 5px 8px;
  border-radius: 20px;
  border: 2px solid var(--person-colour, var(--family));
  background: var(--surface);
  color: var(--text);
  font-size: .82rem; font-weight: 600;
  cursor: pointer;
  outline: none;
  min-width: 0;
  flex-shrink: 1;
}

/* ── Bottom nav ────────────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 1px; padding: 8px 2px 6px;
  font-size: .62rem; font-weight: 600; color: var(--text-muted);
  transition: var(--transition);
}
.nav-item .nav-icon { font-size: 1.2rem; line-height: 1; }
.nav-item.active { color: var(--person-colour, var(--family)); }
.nav-item:hover  { color: var(--person-colour, var(--family)); }

/* ── Burger button ─────────────────────────────────────────────────────────── */
.burger-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; border-radius: 10px;
  color: var(--text); flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  transition: var(--transition);
}
.burger-btn:hover, .burger-btn:active { background: var(--border); }

/* ── Side drawer ────────────────────────────────────────────────────────────── */
/* z-index 1000+ (not just 200/210) — Leaflet's own control container
   (zoom buttons, attribution strip) sits at z-index 1000 on any page with
   a Leaflet map (e.g. airspace.html, airspace_history.html), which is
   higher than this drawer's old 200/210 and let the map's controls render
   on top of the main nav menu when both were open at once. */
#side-backdrop {
  visibility: hidden; opacity: 0;
  position: fixed; inset: 0; z-index: 1010;
  background: rgba(0,0,0,0.45);
  transition: opacity .22s ease, visibility .22s ease;
}
#side-backdrop.open { visibility: visible; opacity: 1; }

#side-menu {
  position: fixed; top: 0; left: 0; bottom: 0; width: min(280px, 85vw); z-index: 1011;
  background: var(--surface);
  box-shadow: 6px 0 32px rgba(0,0,0,0.22);
  transform: translateX(-100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
}
#side-menu.open { transform: translateX(0); }

.side-menu-header {
  padding: 18px 18px 14px;
  font-size: .75rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .08em; color: var(--person-colour, var(--family));
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; background: var(--surface);
  position: sticky; top: 0;
}
.side-menu-close {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  font-size: 1rem; cursor: pointer; border-radius: 8px;
  color: var(--text-muted); background: var(--bg); border: 1px solid var(--border);
  transition: var(--transition);
}
.side-menu-close:hover { color: var(--text); }

.side-nav-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px; text-decoration: none;
  color: var(--text); font-size: .95rem; font-weight: 500;
  border-bottom: 1px solid var(--border);
  transition: background .12s; flex-shrink: 0;
}
.side-nav-item:hover  { background: var(--bg); }
.side-nav-item:active { background: var(--border); }
.side-nav-item.active {
  color: var(--person-colour, var(--family));
  background: var(--bg);
  font-weight: 700;
}
.side-nav-icon { font-size: 1.25rem; flex-shrink: 0; width: 28px; text-align: center; }

.side-nav-section {
  padding: 14px 20px 6px;
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-muted);
  flex-shrink: 0;
}

.side-nav-group { flex-shrink: 0; }
.side-nav-group-summary {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none; list-style: none;
}
.side-nav-group-summary::-webkit-details-marker { display: none; }
.side-nav-group-summary:hover { color: var(--text); }
.side-nav-group-chevron {
  font-size: .7rem; transition: transform .18s;
  padding-right: 20px;
}
.side-nav-group:not([open]) .side-nav-group-chevron { transform: rotate(-90deg); }

/* ── Home grid ──────────────────────────────────────────────────────────────── */
.home-grid-page {
  padding: 14px;
}
.home-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.home-tile {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; padding: 22px 8px 18px;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow);
  text-decoration: none; color: var(--text);
  transition: transform .12s ease, box-shadow .12s ease;
  border-bottom: 4px solid var(--person-colour, var(--family));
  min-height: 110px;
}
.home-tile:active { transform: scale(0.93); box-shadow: none; }
.home-tile-emoji { font-size: 2.4rem; line-height: 1; }
.home-tile-label {
  font-size: .72rem; font-weight: 700; text-align: center;
  color: var(--text-muted); line-height: 1.25;
  padding: 0 4px;
}

.home-grid-section-label {
  font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-muted);
  padding: 4px 2px; margin-top: 18px;
}
.home-grid-section-label + .home-grid { margin-top: 10px; }

.home-grid-group { margin-top: 18px; }
.home-grid-group:first-child { margin-top: 0; }
.home-grid-group .home-grid { margin-top: 10px; }
.home-grid-group-summary {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none; list-style: none;
  font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-muted);
  padding: 4px 2px;
}
.home-grid-group-summary::-webkit-details-marker { display: none; }
.home-grid-group-summary:hover { color: var(--text); }
.home-grid-group-chevron { font-size: .7rem; transition: transform .18s; }
.home-grid-group:not([open]) .home-grid-group-chevron { transform: rotate(-90deg); }

/* ── Page container ─────────────────────────────────────────────────────────── */
.page { padding: 12px; max-width: 680px; margin: 0 auto; }
.page-wide { padding: 12px; max-width: 1400px; margin: 0 auto; }

/* ── Medicines monthly grid (desktop) ──────────────────────────────────────── */
.month-grid-wrap { overflow-x: auto; }
.month-grid {
  border-collapse: collapse; width: 100%; font-size: .78rem;
}
.month-grid th, .month-grid td {
  border: 1px solid var(--border); padding: 2px; text-align: center; vertical-align: middle;
}
.month-grid th {
  background: var(--bg); font-weight: 600; color: var(--text-muted);
  position: sticky; top: 0; z-index: 1;
}
.month-grid td.med-name-cell {
  text-align: left; padding: 6px 10px; white-space: nowrap;
  position: sticky; left: 0; background: var(--surface); z-index: 1;
  font-weight: 600;
}
.month-grid th.day-col, .month-grid td.day-cell { width: 30px; min-width: 30px; }
.month-grid td.day-cell.weekend { background: var(--bg); }
.month-grid td.day-cell.today-col { outline: 2px solid var(--person-colour, var(--family)); outline-offset: -2px; }
.dose-dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 5px; margin: 1px;
  font-size: .72rem; cursor: pointer; border: none; padding: 0;
  background: var(--bg); color: var(--text-muted);
}
.dose-dot.taken   { background: #DCFCE7; color: #15803D; }
.dose-dot.missed  { background: #FEE2E2; color: #B91C1C; font-weight: 700; }
.dose-dot.future  { background: transparent; color: var(--border); cursor: default; }
.dose-dot.not-due { background: transparent; border: none; }
.dose-dot:hover:not(.not-due):not(.future) { filter: brightness(0.92); }
.month-nav-desktop-only { display: none; }
@media (min-width: 900px) {
  .month-nav-desktop-only { display: inline-flex; }
}

/* ── Alert cards ─────────────────────────────────────────────────────────────── */
.alert-card {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius);
  margin-bottom: 12px; border-left: 4px solid transparent;
}
.alert-danger  { background: #FEF2F2; border-color: #EF4444; }
.alert-warning { background: #FFFBEB; border-color: #F59E0B; }
.alert-icon { font-size: 1.4rem; line-height: 1; flex-shrink: 0; }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: 700; font-size: .9rem; color: #991B1B; }
.alert-warning .alert-title { color: #92400E; }
.alert-desc  { font-size: .8rem; color: #7F1D1D; margin-top: 2px; line-height: 1.4; }
.alert-warning .alert-desc { color: #78350F; }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}
.card-title {
  font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-muted);
  margin-bottom: 10px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}

/* ── Section headings ───────────────────────────────────────────────────────── */
.section-label {
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-muted);
  margin: 20px 0 8px;
}

/* ── Weather strip ──────────────────────────────────────────────────────────── */
.weather-strip {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff; border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px;
}
.weather-strip-top {
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
}
.weather-main { font-size: 2rem; line-height: 1; flex-shrink: 0; }
.weather-info { flex: 1; min-width: 0; }
.weather-temp { font-size: 1.4rem; font-weight: 700; }
.weather-desc { font-size: .82rem; opacity: .9; }
.weather-forecast {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 6px;
}
.forecast-day {
  text-align: center;
  background: rgba(255,255,255,.15); border-radius: 8px; padding: 6px 4px;
  font-size: .72rem;
}
.forecast-day .day-name { font-weight: 700; opacity: .9; font-size: .68rem; }
.forecast-day .day-emoji { font-size: 1.2rem; margin: 2px 0; }
.forecast-day .day-temp { opacity: .85; }
.forecast-day .day-rain { opacity: .8; font-size: .65rem; }

/* ── Event cards ─────────────────────────────────────────────────────────────── */
.event-list { display: flex; flex-direction: column; gap: 8px; }
.event-card {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  background: var(--surface); border-radius: 10px;
  border-left: 4px solid var(--event-colour, var(--border));
  box-shadow: var(--shadow);
}
.event-card.highlight { outline: 2px solid var(--event-colour, var(--border)); }
.event-time { font-size: .75rem; color: var(--text-muted); white-space: nowrap; min-width: 48px; padding-top: 1px; }
.event-body { flex: 1; min-width: 0; }
.event-title { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-attendees { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }
.event-badge {
  font-size: .65rem; font-weight: 700; letter-spacing: .05em;
  padding: 2px 7px; border-radius: 12px; white-space: nowrap;
}
.badge-now    { background: #22C55E; color: #fff; }
.badge-soon   { background: #F59E0B; color: #fff; }
.badge-later  { background: var(--border); color: var(--text-muted); }
.badge-ended  { background: var(--border); color: var(--text-muted); opacity: .6; }

/* Calendar colour coding */
.colour-grape    { --event-colour: #8B5CF6; }
.colour-tomato   { --event-colour: #EF4444; }
.colour-basil    { --event-colour: #16A34A; }
.colour-flamingo { --event-colour: #EC4899; }
.colour-banana   { --event-colour: #EAB308; }
.colour-peacock  { --event-colour: #0EA5E9; }
.colour-default  { --event-colour: #8B5CF6; }
.colour-birthday { --event-colour: #F97316; }

/* ── Event task panel ────────────────────────────────────────────────────────── */
.event-wrapper { margin-bottom: 8px; }
.event-wrapper .event-card { margin-bottom: 0; }
.event-tasks-btn {
  flex-shrink: 0; font-size: .85rem; padding: 4px 8px;
  border-radius: 8px; color: var(--text-muted);
  background: var(--bg); border: 1px solid var(--border);
  cursor: pointer; white-space: nowrap; line-height: 1.3;
  transition: var(--transition);
}
.event-tasks-btn:hover { color: var(--person-colour, var(--family)); border-color: var(--person-colour, var(--family)); }
.event-tasks-btn.has-tasks { color: var(--person-colour, var(--family)); }
.task-badge { font-size: .68rem; margin-left: 3px; font-weight: 700; }
.event-tasks-panel {
  background: var(--bg); border-radius: 0 0 var(--radius) var(--radius);
  border: 1px solid var(--border); border-top: none;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 8px;
}
.event-tasks-list { display: flex; flex-direction: column; gap: 4px; }
.event-task-item {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0; border-bottom: 1px solid var(--border);
}
.event-task-item:last-child { border-bottom: none; }
.event-task-item.done .event-task-title { text-decoration: line-through; color: var(--text-muted); }
.event-task-title { flex: 1; font-size: .85rem; }
.event-task-del {
  font-size: .75rem; color: var(--text-muted); padding: 2px 5px;
  border-radius: 4px; opacity: 0.5; transition: opacity .12s;
}
.event-task-del:hover { opacity: 1; color: var(--danger, #EF4444); }
.event-tasks-add { display: flex; gap: 6px; align-items: center; }
.task-check.checked { background: var(--person-colour, var(--family)); border-color: var(--person-colour, var(--family)); }
.task-check.checked::after { content: "✓"; color: #fff; font-size: .7rem; font-weight: 700; }

/* ── Before-you-leave ────────────────────────────────────────────────────────── */
.checklist { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.checklist li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: #FFFBEB;
  border: 1px solid #FDE68A; border-radius: 8px;
  font-size: .88rem; font-weight: 500;
}
.checklist li::before { content: "✓"; color: #D97706; font-weight: 700; }

/* ── Task items ──────────────────────────────────────────────────────────────── */
.task-date-heading {
  font-size: .78rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em;
  margin-bottom: 6px;
}
.task-date-heading--spaced { margin-top: 16px; }
.task-list { display: flex; flex-direction: column; gap: 6px; }
.task-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--surface);
  border-radius: 10px; box-shadow: var(--shadow);
  transition: var(--transition);
  border-left: 3px solid var(--assignee-colour, var(--border));
}
.task-item.highlight { outline: 2px solid #6366F1; }
.task-item.transferred-away { opacity: .6; }
.task-item.completed-item.style-fade {
  opacity: .45; text-decoration: line-through;
}
.task-item.completed-item.style-collapse { display: none; }

.task-check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; cursor: pointer;
  transition: var(--transition);
}
.task-check.checked {
  background: #22C55E; border-color: #22C55E; color: #fff;
}
.task-check:hover { border-color: #22C55E; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: .9rem; font-weight: 500; }
.task-meta  { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }
.task-actions {
  display: flex; gap: 4px;
}
.task-actions button {
  font-size: .7rem; padding: 3px 8px; border-radius: 6px;
  border: 1px solid var(--border); color: var(--text-muted);
  transition: var(--transition);
}
.task-actions button:hover { background: var(--border); color: var(--text); }
.exec-transfer-btn {
  font-size: .72rem; color: var(--paul); font-weight: 600;
  padding: 4px 10px; border: 1.5px dashed var(--paul);
  border-radius: 8px; width: 100%; margin-top: 6px;
  text-align: center;
}

/* Completed count badge (collapse style) */
.completed-count {
  font-size: .8rem; color: var(--text-muted); padding: 6px 12px;
  text-align: center; cursor: pointer;
}

/* ── Task tiles (icon-grid layout for /tasks) ───────────────────────────────── */
.task-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}
.task-tile.task-item {
  flex-direction: column; align-items: stretch; text-align: center;
  padding: 12px 8px 10px; gap: 6px;
  border-left: none; border-bottom: 4px solid var(--assignee-colour, var(--border));
  position: relative; min-height: 112px;
}
.task-tile .task-tile-icon { font-size: 1.9rem; line-height: 1; }
.task-tile .task-check {
  position: absolute; top: 6px; right: 6px; width: 20px; height: 20px;
  background: var(--bg); z-index: 1;
}
.task-tile .task-body { flex: none; min-width: 0; }
.task-tile .task-title { font-size: .78rem; line-height: 1.25; }
.task-tile .task-meta { justify-content: center; }
.task-tile .task-actions {
  justify-content: center; margin-top: auto; padding-top: 4px;
}
.task-tile.completed-item.style-fade { opacity: .4; }

/* ── Icon picker (chore/task icon field) ────────────────────────────────────── */
.icon-picker {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px;
  max-height: 168px; overflow-y: auto;
  padding: 8px; border: 1.5px solid var(--border); border-radius: 10px;
}
.icon-picker-btn {
  font-size: 1.3rem; line-height: 1; padding: 6px 0; border-radius: 8px;
  border: 1.5px solid transparent; background: transparent; cursor: pointer;
  transition: var(--transition);
}
.icon-picker-btn:hover { background: var(--border); }
.icon-picker-btn.selected { border-color: var(--person-colour, var(--family)); background: var(--card-bg); }

/* ── Holiday kit list ───────────────────────────────────────────────────────── */
.kit-sections { display: flex; flex-direction: column; gap: 18px; }
.kit-group-title { font-size: .82rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.kit-item-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.kit-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; background: var(--surface);
  border-radius: 8px; box-shadow: var(--shadow);
}
.kit-item.packed .kit-item-title { opacity: .45; text-decoration: line-through; }
.kit-item-title { flex: 1; min-width: 0; font-size: .88rem; font-weight: 500; word-break: break-word; }
.kit-item-actions { display: flex; gap: 3px; flex-shrink: 0; }
.kit-add-row { display: flex; gap: 8px; }
.kit-add-row .kit-add-input { flex: 1; }

.kit-food-day { margin-bottom: 20px; }
.kit-food-day:last-child { margin-bottom: 0; }
.kit-food-day-title {
  font-size: .85rem; font-weight: 700; color: var(--text);
  padding-bottom: 6px; margin-bottom: 10px; border-bottom: 2px solid var(--border);
}
.kit-food-meals { display: flex; flex-direction: column; gap: 14px; }
@media (min-width: 640px) {
  .kit-food-meals { flex-direction: row; }
  .kit-food-meals .kit-group { flex: 1; min-width: 0; }
}

/* ── Medicines ──────────────────────────────────────────────────────────────── */
.med-list { display: flex; flex-direction: column; gap: 8px; }
.med-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--surface);
  border-radius: 10px; box-shadow: var(--shadow);
}
.med-item.needs-reorder { border-left: 3px solid #EF4444; }
.med-pill-icon {
  font-size: 1.5rem; line-height: 1;
}
.med-info { flex: 1; min-width: 0; }
.med-name { font-weight: 600; font-size: .9rem; }
.med-stock { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.med-stock.low { color: #EF4444; font-weight: 600; }
.med-schedule-badge {
  font-size: .68rem; font-weight: 700; padding: 2px 7px;
  border-radius: 10px; background: #EFF6FF; color: #2563EB;
  white-space: nowrap;
}
.med-schedule-badge.late {
  background: #FEF3C7; color: #D97706;
}
.med-item.is-late {
  border-left: 3px solid #F59E0B;
}
.med-item.needs-reorder.is-late {
  border-left: 3px solid #EF4444;
}
.take-btn {
  padding: 7px 14px; border-radius: 8px; font-size: .82rem; font-weight: 600;
  border: 2px solid #22C55E; color: #22C55E; transition: var(--transition);
}
.take-btn.taken {
  background: #22C55E; color: #fff; border-color: #22C55E;
}
.take-btn:hover { background: #22C55E; color: #fff; }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: 5px; color: var(--text-muted); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: .9rem; color: var(--text);
  background: var(--surface); transition: var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--person-colour, var(--family));
}
.form-textarea { resize: vertical; min-height: 80px; }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px; border-radius: 10px;
  font-size: .88rem; font-weight: 600;
  border: none; transition: var(--transition);
}
.btn-primary {
  background: var(--person-colour, var(--family)); color: #fff;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary {
  background: var(--border); color: var(--text);
}
.btn-secondary:hover { background: #D1D5DB; }
.btn-danger { background: #FEE2E2; color: #EF4444; }
.btn-danger:hover { background: #EF4444; color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .78rem; border-radius: 7px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Meal grid ──────────────────────────────────────────────────────────────── */
.meal-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.meal-day-header {
  font-size: .8rem; font-weight: 700; color: var(--text-muted);
  padding: 6px 0 2px; text-transform: uppercase; letter-spacing: .05em;
}
.meal-slot {
  background: var(--surface); border-radius: 10px;
  border: 1.5px dashed var(--border); padding: 10px 12px;
  min-height: 52px; cursor: pointer; transition: var(--transition);
}
.meal-slot:hover { border-color: var(--person-colour, var(--family)); }
.meal-slot.filled { border-style: solid; border-color: var(--border); }
.meal-slot-type { font-size: .68rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); }
.meal-slot-name { font-size: .88rem; font-weight: 500; margin-top: 2px; }

/* ── Shopping list ──────────────────────────────────────────────────────────── */
.shopping-category { margin-bottom: 12px; }
.shopping-category-title {
  font-size: .75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-muted); margin-bottom: 6px;
}
.search-section-label {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--person-colour, var(--family));
  padding: 10px 2px 4px; margin-top: 4px;
}
.search-section-label:first-child { padding-top: 4px; margin-top: 0; }
.shopping-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; background: var(--surface);
  border-radius: 8px; margin-bottom: 4px;
}
.shopping-item.checked .shopping-item-name {
  text-decoration: line-through; opacity: .45;
}
.shopping-item-name { flex: 1; font-size: .88rem; }
.shopping-item-qty  { font-size: .78rem; color: var(--text-muted); }

/* ── Settings ────────────────────────────────────────────────────────────────── */
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.settings-row:last-child { border-bottom: none; }
.settings-row > div:first-child { flex: 1; min-width: 0; }
.settings-label { font-size: .9rem; font-weight: 500; }
.settings-desc  { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }

/* Toggle switch */
.toggle {
  position: relative; display: inline-block; width: 46px; height: 26px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border); border-radius: 26px; transition: var(--transition);
}
.toggle-slider::before {
  content: ""; position: absolute; width: 20px; height: 20px;
  left: 3px; bottom: 3px; background: #fff; border-radius: 50%;
  transition: var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--person-colour, var(--family)); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Tile reorder buttons */
.tile-order-btn {
  border: none; background: var(--bg); color: var(--text-muted);
  width: 22px; height: 18px; line-height: 18px; padding: 0;
  font-size: .6rem; border-radius: 4px; cursor: pointer;
}
.tile-order-btn:active { background: var(--border); }

/* ── Admin sections ──────────────────────────────────────────────────────────── */
.admin-section { margin-bottom: 24px; }
.admin-section-title {
  font-size: .85rem; font-weight: 700; color: var(--text);
  padding: 8px 0; border-bottom: 2px solid var(--border); margin-bottom: 12px;
}
.device-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; background: var(--surface);
  border-radius: 8px; margin-bottom: 4px; box-shadow: var(--shadow);
}
.device-name { flex: 1; font-size: .88rem; font-weight: 500; }
.device-mac  { font-size: .72rem; color: var(--text-muted); font-family: monospace; }

/* ── Chips / pills ───────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 12px;
  font-size: .72rem; font-weight: 600; background: var(--border); color: var(--text-muted);
}
.chip-katie  { background: #FDF2F8; color: var(--katie); }
.chip-paul   { background: #FEF2F2; color: var(--paul); }
.chip-joshua { background: #F0FDF4; color: var(--joshua); }
.chip-violet { background: #FDF4FF; color: var(--violet); }
.chip-anyone { background: #F3F4F6; color: var(--anyone); }

/* ── Notifications ──────────────────────────────────────────────────────────── */
.notif-list { display: flex; flex-direction: column; gap: 8px; }
.notif-card {
  padding: 10px 12px; background: var(--surface);
  border-radius: 10px; box-shadow: var(--shadow);
  border-left: 3px solid var(--border);
}
.notif-card.urgency-low      { border-left-color: var(--text-muted); }
.notif-card.urgency-default  { border-left-color: var(--person-colour, var(--family)); }
.notif-card.urgency-high     { border-left-color: #F59E0B; }
.notif-card.urgency-critical { border-left-color: #EF4444; background: rgba(239,68,68,.06); }
.notif-card.highlight { outline: 2px solid #6366F1; }
.notif-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 4px;
}
.notif-time { font-size: .72rem; color: var(--text-muted); }
.notif-clear-btn {
  font-size: .85rem; line-height: 1; color: var(--text-muted);
  padding: 3px 6px; border-radius: 6px; transition: var(--transition);
}
.notif-clear-btn:hover { background: var(--border); color: var(--text); }
.notif-title { font-size: .9rem; font-weight: 600; }
.notif-body  { font-size: .85rem; color: var(--text-muted); margin-top: 3px; white-space: pre-wrap; }
.notif-actions { display: flex; gap: 8px; margin-top: 8px; }

/* ── Toast / flash ───────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  z-index: 999; display: flex; flex-direction: column; gap: 6px; pointer-events: none;
}
.toast {
  padding: 10px 18px; border-radius: 10px; font-size: .88rem;
  font-weight: 600; color: #fff; box-shadow: 0 4px 16px rgba(0,0,0,.2);
  animation: slideUp .2s ease, fadeOut .3s ease 2.5s forwards;
  pointer-events: auto;
}
.toast-success { background: #22C55E; }
.toast-error   { background: #EF4444; }

@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; pointer-events: none; } }

/* ── Empty states ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 28px 16px; color: var(--text-muted);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 8px; }
.empty-state-text { font-size: .9rem; }

/* ── Modal ───────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200;
  display: none; align-items: flex-end; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal-sheet {
  background: var(--surface); border-radius: 20px 20px 0 0;
  width: 100%; max-width: 680px; padding: 20px 20px 40px;
  max-height: 85dvh; overflow-y: auto;
}
.modal-title {
  font-size: 1.05rem; font-weight: 700; margin-bottom: 16px;
}
.modal-close {
  float: right; font-size: 1.4rem; line-height: 1; color: var(--text-muted); cursor: pointer;
}

/* ── PIN keypad overlay ─────────────────────────────────────────────────────── */
.pin-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: var(--bg);
  display: none; flex-direction: column;
  align-items: center; justify-content: center; gap: 28px;
}
.pin-overlay.open { display: flex; }
.pin-overlay-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.pin-dots { display: flex; gap: 14px; }
.pin-dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent; transition: background .1s;
}
.pin-dot.filled { background: var(--person-colour, var(--family)); border-color: var(--person-colour, var(--family)); }
.pin-grid {
  display: grid; grid-template-columns: repeat(3, 72px);
  grid-template-rows: repeat(4, 72px); gap: 12px;
}
.pin-key {
  font-size: 1.5rem; font-weight: 600;
  border-radius: 50%; border: none;
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s, background .1s;
}
.pin-key:active { transform: scale(.92); background: var(--border); }
.pin-key-back { font-size: 1.2rem; }
.pin-key-ok {
  background: var(--person-colour, var(--family));
  color: #fff;
}
.pin-cancel {
  font-size: .9rem; color: var(--text-muted);
  background: none; border: none; cursor: pointer; padding: 8px 20px;
}

/* ── Cancelled events ────────────────────────────────────────────────────────── */
.event-card.cancelled {
  opacity: .45;
  filter: grayscale(.6);
}
.event-card.cancelled .event-title {
  text-decoration: line-through;
}
.badge-cancelled {
  background: #FEE2E2; color: #EF4444;
  font-size: .65rem; font-weight: 700;
  padding: 2px 7px; border-radius: 12px; white-space: nowrap;
}
.first-seen {
  font-size: .68rem; color: var(--text-muted);
  margin-top: 2px;
}

/* ── Term-time indicator ─────────────────────────────────────────────────────── */
.term-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 12px;
  font-size: .7rem; font-weight: 700;
  background: #EFF6FF; color: #2563EB;
}

/* ── PRN log rows ────────────────────────────────────────────────────────────── */
.prn-med-btn {
  padding: 10px 16px; border-radius: 10px; font-size: .88rem; font-weight: 600;
  cursor: pointer; transition: var(--transition); flex: 1; min-width: 130px;
}
.prn-med-btn:active { filter: brightness(.92); }
.prn-med-btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.prn-log-group { margin-bottom: 14px; }
.prn-log-group:last-child { margin-bottom: 0; }
.prn-log-group-title {
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); margin-bottom: 4px;
}
.prn-log-empty { color: var(--text-muted); font-size: .85rem; padding: 4px 0; }
.prn-log-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; border-bottom: 1px solid var(--border); font-size: .83rem;
}
.prn-log-row:last-child { border-bottom: none; }
.prn-log-icon { font-size: 1rem; flex-shrink: 0; }
.prn-log-label { flex: 1; font-weight: 500; }
.prn-log-person {
  font-size: .72rem; font-weight: 600; padding: 2px 7px;
  border-radius: 10px; background: var(--border); color: var(--text-muted); white-space: nowrap;
}
.prn-log-time { color: var(--text-muted); font-size: .78rem; white-space: nowrap; }
.prn-next-dose {
  font-size: .72rem; font-weight: 700; padding: 2px 7px;
  border-radius: 10px; background: #FEF3C7; color: #D97706; white-space: nowrap;
}
.prn-edit-time-btn {
  background: none; border: none; color: var(--text-muted);
  font-size: .8rem; cursor: pointer; padding: 2px 4px; border-radius: 4px; flex-shrink: 0;
}
.prn-edit-time-btn:hover { color: var(--text); background: var(--border); }
.prn-delete-btn {
  margin-left: auto; background: none; border: none; color: var(--text-muted);
  font-size: .8rem; cursor: pointer; padding: 2px 4px; border-radius: 4px; flex-shrink: 0;
}
.prn-delete-btn:hover { color: #dc2626; background: #fee2e2; }

/* ── Dark mode alert overrides ───────────────────────────────────────────────── */
body.theme-dark .alert-danger  { background: rgba(239,68,68,.12); }
body.theme-dark .alert-warning { background: rgba(245,158,11,.12); }
body.theme-dark .alert-title   { color: #FCA5A5; }
body.theme-dark .alert-desc    { color: #FECACA; }
body.theme-dark .alert-warning .alert-title { color: #FDE68A; }
body.theme-dark .alert-warning .alert-desc  { color: #FEF3C7; }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 479px) {
  .top-bar-title { display: none; }
  .settings-row { gap: 8px; }
  .form-input, .form-select { font-size: .85rem; }
}
@media (min-width: 600px) {
  .page { padding: 20px; }
  .meal-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Celebration overlay (Joshua — task complete) ────────────────────────────── */
.celebration-overlay {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; opacity: 0;
  transition: opacity .25s ease;
  overflow: hidden;
}
.celebration-overlay.open { opacity: 1; }
.celebration-message {
  font-size: 1.6rem; font-weight: 800; color: var(--joshua);
  background: var(--surface); padding: 18px 28px; border-radius: 20px;
  box-shadow: var(--shadow); text-align: center;
  transform: scale(.7);
  animation: celebration-pop .5s cubic-bezier(.34,1.56,.64,1) forwards;
}
@keyframes celebration-pop {
  0%   { transform: scale(.4); opacity: 0; }
  60%  { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.confetti-piece {
  position: absolute; top: -10px;
  width: 9px; height: 14px;
  opacity: .9; border-radius: 2px;
  animation-name: confetti-fall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}
@keyframes confetti-fall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(540deg); opacity: 0; }
}
