:root {
  /* Sampled directly from the approved logo artwork (royal blue letterforms,
     aqua/cyan swoosh) and rounded to clean values; every other token below
     is verified for WCAG contrast against the surfaces it's meant to sit on. */
  --brand-blue: #4A5FEE;
  --brand-blue-dark: #33449E;
  --brand-blue-soft: #E8ECFE;
  --brand-cyan: #14A8E8;
  --brand-cyan-soft: #E1F5FC;
  --brand-cream: #FAF6EF;
  --brand-peach: #F0A878;
  --brand-peach-soft: #FCEEE2;

  --surface: #FFFFFF;
  --surface-muted: #F3EFE8;
  --surface-elevated: #FFFFFF;

  --text-primary: #20263A;
  --text-secondary: #5B6273;
  --border: #948C7E;

  --success: #237A52;
  --success-soft: #E7F5EE;
  --warning: #B87A1E;
  --warning-soft: #FBF1DE;
  --warning-text: #7A5416;
  --danger: #BC3B3B;
  --danger-soft: #FBE9E9;
  --danger-text: #8F2F2F;

  --focus-ring: var(--brand-blue);

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 10px rgba(32, 38, 58, 0.06), 0 8px 24px rgba(32, 38, 58, 0.05);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--brand-cream);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-weight: 700; margin: 0 0 8px; line-height: 1.3; }
p { line-height: 1.55; }
button, input, select, textarea { font-family: inherit; font-size: 1rem; }
a { color: var(--brand-blue-dark); }

/* Focus visibility everywhere — never rely on colour alone */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 96px;
  position: relative;
}

.screen { padding: 20px 20px 12px; }
.screen-centered {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 24px;
}

/* Brand image sizing. Each approved asset carries generous transparent
   padding around the visible mark (measured, not guessed), so every rule
   here sizes the whole image tall enough that the visible logo reads
   clearly, while width is always `auto` so the original aspect ratio is
   preserved exactly — nothing is ever stretched. */
.brand-teddy-hero {
  display: block;
  width: 68%;
  max-width: 300px;
  height: auto;
  margin: 0 auto 8px;
}
.brand-wordmark-hero {
  display: block;
  width: 58%;
  max-width: 240px;
  height: auto;
  margin: 0 auto 4px;
}
.brand-wordmark-desktop {
  height: 60px;
  width: auto;
  display: none;
}
.brand-teddy-compact {
  height: 48px;
  width: auto;
  display: block;
}
.brand-wordmark-compact {
  height: 52px;
  width: auto;
  display: block;
}
.brand-teddy-empty {
  height: 130px;
  width: auto;
  margin: 0 auto 8px;
}
@media (min-width: 480px) {
  .brand-teddy-compact { height: 56px; }
}
@media (min-width: 720px) {
  .brand-teddy-compact, .brand-wordmark-compact { display: none; }
  .brand-wordmark-desktop { display: block; }
}

.lede { color: var(--text-secondary); font-size: 1.02rem; margin-bottom: 28px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.spacer-sm { height: 8px; }
.spacer-md { height: 16px; }

label { display: block; font-size: 0.9rem; font-weight: 600; color: var(--text-secondary); margin: 4px 0 6px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="time"], input[type="datetime-local"], select {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
}
input::placeholder { color: #8B8477; }
input[readonly] { background: var(--surface-muted); color: var(--text-secondary); }

.field-error { color: var(--danger-text); font-size: 0.85rem; margin-top: 4px; min-height: 1.1em; }

.btn {
  appearance: none;
  min-height: 50px;
  padding: 12px 20px;
  font-weight: 700;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--brand-blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-blue-dark); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-secondary { background: var(--brand-blue-soft); color: var(--brand-blue-dark); }
.btn-secondary:hover:not(:disabled) { background: #DCE2FC; }
.btn-ghost { background: transparent; color: var(--text-secondary); font-weight: 700; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-muted); }
.btn-danger-outline { background: var(--danger-soft); color: var(--danger-text); border: 1.5px solid var(--danger); }
.btn-block { width: 100%; }
.btn-inline { width: auto; }
.btn-sm { min-height: 40px; padding: 8px 14px; font-size: 0.9rem; }

.link-btn {
  background: none; border: none; color: var(--brand-blue-dark);
  font-weight: 700; cursor: pointer; padding: 6px 2px; min-height: 32px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-weight: 700;
  font-size: 0.92rem;
  min-height: 44px;
  cursor: pointer;
}
.pill.active { background: var(--brand-blue); border-color: var(--brand-blue); color: #fff; }
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }

.toggle-row { display: flex; gap: 8px; }
.toggle-row .pill { flex: 1; justify-content: center; }

.top-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 20px 8px;
}

.greeting { font-size: 1.3rem; font-weight: 700; margin-bottom: 2px; }
.subtle { color: var(--text-secondary); font-size: 0.92rem; }

.child-switcher { display: flex; gap: 8px; overflow-x: auto; padding: 4px 20px 12px; }

.med-card {
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 14px;
  background: var(--success-soft);
  border: 1px solid transparent;
}
.med-card.status-wait { background: var(--warning-soft); }
.med-card.status-max { background: var(--danger-soft); }
.med-title { font-weight: 700; font-size: 1.08rem; text-transform: capitalize; }
.med-count { font-weight: 700; font-size: 1.5rem; margin: 6px 0 2px; }
.med-sub { color: var(--text-secondary); font-size: 0.86rem; }
.status-line { margin-top: 10px; font-weight: 700; font-size: 0.95rem; display: flex; align-items: center; gap: 8px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.status-ok .status-dot { background: var(--success); }
.status-wait .status-dot { background: var(--warning); }
.status-max .status-dot { background: var(--danger); }

.age-note {
  margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 0.85rem; line-height: 1.4; font-weight: 600;
  background: var(--warning-soft); color: var(--warning-text);
}
.age-note.caution { background: var(--danger-soft); color: var(--danger-text); }

.emergency-block {
  margin-top: 12px; background: var(--danger); color: #fff;
  padding: 12px 14px; border-radius: var(--radius-md);
  font-size: 0.86rem; line-height: 1.45; font-weight: 600;
}

.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-secondary);
}
.empty-state .icon { font-size: 2rem; margin-bottom: 8px; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-muted) 25%, #EAE4D8 37%, var(--surface-muted) 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: var(--radius-md);
  height: 84px;
}
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
@keyframes skeleton-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.loading-mark {
  height: 48px;
  width: auto;
  animation: loading-mark-pulse 1.8s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) { .loading-mark { animation: none; } }
@keyframes loading-mark-pulse { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }

.toast-region {
  position: fixed;
  left: 0; right: 0; bottom: 90px;
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; pointer-events: none; z-index: 60;
}
.toast {
  background: var(--text-primary); color: #fff;
  padding: 10px 18px; border-radius: 999px;
  font-weight: 600; font-size: 0.9rem;
  box-shadow: var(--shadow);
  max-width: 90%;
}
.toast.error { background: var(--danger); }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-width: 560px; margin: 0 auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  z-index: 40;
}
.nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px;
  border: none; background: none;
  color: var(--text-secondary);
  font-size: 0.72rem; font-weight: 700;
  border-radius: var(--radius-sm);
  min-height: 52px;
}
.nav-item[aria-current="page"] { color: var(--brand-blue-dark); background: var(--brand-blue-soft); }
.nav-item .nav-icon { font-size: 1.25rem; }

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(32,38,58,0.45);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 80;
}
@media (min-width: 560px) { .modal-overlay { align-items: center; } }
.modal-box {
  background: var(--surface-elevated);
  width: 100%; max-width: 520px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(32,38,58,0.2);
  max-height: 88vh;
  overflow-y: auto;
}
@media (min-width: 560px) { .modal-box { border-radius: var(--radius-lg); box-shadow: var(--shadow); } }
.modal-title { font-weight: 700; font-size: 1.15rem; margin-bottom: 10px; }
.modal-title.danger { color: var(--danger-text); }
.modal-message { margin-bottom: 18px; line-height: 1.5; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; }
.modal-actions .btn-danger-outline:hover:not(:disabled) { background: #F7D8D8; }

.history-filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }

.timeline-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 10px;
  border-left: 4px solid var(--brand-blue);
}
.timeline-item.override { border-left-color: var(--danger); }
.timeline-item .meta { color: var(--text-secondary); font-size: 0.82rem; margin-top: 4px; }
.override-badge {
  display: inline-block;
  background: var(--danger-soft); color: var(--danger-text);
  font-size: 0.72rem; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  margin-left: 8px;
}

.section-title { font-size: 0.82rem; font-weight: 700; letter-spacing: 0.03em; color: var(--text-secondary); margin: 20px 0 10px; }

footer.disclaimer {
  color: var(--text-secondary);
  font-size: 0.78rem;
  text-align: center;
  padding: 18px 24px 8px;
  line-height: 1.5;
}
