/* =========================================================
   Design tokens
   ========================================================= */
:root {
  /* Brand */
  /* Brand colors taken from the client's VaxiCare logo */
  --color-primary: #102842;        /* logo navy */
  --color-primary-hover: #0a1c30;
  --color-primary-soft: #e8eef6;   /* light navy tint for active/selected states */
  --color-accent: #3498a8;         /* logo "Protecting Generations" teal (decorative / on navy) */
  --color-accent-strong: #1f7585;  /* darker teal, readable as text on white */

  /* Neutrals */
  --color-bg: #f4f7f9;
  --color-surface: #ffffff;
  --color-border: #dde4ea;
  --color-text: #1c2b36;
  --color-text-muted: #5b6b78;

  /* Status palette: fg = text/border, bg = badge fill */
  --status-overdue-fg: #b42318;
  --status-overdue-bg: #fdecea;
  --status-duesoon-fg: #8a5a00;
  --status-duesoon-bg: #fff4d6;
  --status-pending-fg: #1e7a3c;
  --status-pending-bg: #e5f5ea;
  --status-done-fg: #56616b;
  --status-done-bg: #eceff2;

  /* Feedback */
  --color-error: #b42318;

  /* Typography */
  --font-sans: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.25rem;
  --text-xl: 1.5rem;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  /* Shape & depth */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, 0.18);

  --header-height: 60px;
  --content-max: 1200px;
}

/* =========================================================
   Base
   ========================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  /* Column layout keeps the credits footer at the bottom of short pages */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  margin: 0;
  line-height: 1.25;
}

a {
  color: var(--color-primary);
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* =========================================================
   Layout
   ========================================================= */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 0 var(--space-5);
  background: var(--color-surface);
  border-top: 3px solid var(--color-accent);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

/* Logo emblem (navy square with the white VaxiCare circle) */
.brand-logo {
  flex: none;
  display: block;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
}

.brand-name {
  font-weight: 800;
  font-size: var(--text-lg);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-primary);
}

.app-header__user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.app-main {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-5);
}

/* Credits footer (every screen) */
.app-credits {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-1) var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  text-align: center;
}

.app-credits strong {
  color: var(--color-text);
  font-weight: 600;
}

/* Signed-in screens: leave room so the floating phone button never covers the credits */
body:not([data-route="login"]) .app-credits {
  padding-bottom: 88px;
}

/* =========================================================
   Components
   ========================================================= */

/* Card */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--color-primary);
  color: #fff;
}

.btn--primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.btn--secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn--secondary:hover:not(:disabled) {
  background: var(--color-bg);
}

.btn--ghost {
  background: transparent;
  color: var(--color-primary);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--color-primary-soft);
}

.btn--block {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-md);
}

/* Form fields */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}

.field label {
  font-size: var(--text-sm);
  font-weight: 600;
}

.field input {
  font: inherit;
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
}

.field input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.form-error {
  color: var(--color-error);
  font-size: var(--text-sm);
  margin: 0 0 var(--space-3);
}

/* Status badges — always text + color, never color alone */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid currentColor;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge--overdue { color: var(--status-overdue-fg); background: var(--status-overdue-bg); }
.badge--duesoon { color: var(--status-duesoon-fg); background: var(--status-duesoon-bg); }
.badge--pending { color: var(--status-pending-fg); background: var(--status-pending-bg); }
.badge--done    { color: var(--status-done-fg);    background: var(--status-done-bg); }

/* Table */
.table-wrap {
  overflow-x: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th,
.table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.table th {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  background: var(--color-bg);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr.is-clickable {
  cursor: pointer;
}

.table tbody tr.is-clickable:hover {
  background: var(--color-primary-soft);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: rgba(16, 24, 40, 0.5);
}

.modal {
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 2 * var(--space-4));
  overflow-y: auto;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.modal__header,
.modal__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
}

.modal__header {
  border-bottom: 1px solid var(--color-border);
}

.modal__footer {
  border-top: 1px solid var(--color-border);
  justify-content: flex-end;
}

.modal__body {
  padding: var(--space-5);
}

/* Header navigation */
.app-nav {
  display: flex;
  gap: var(--space-1);
  margin-right: var(--space-3);
}

.nav-link {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-weight: 600;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.nav-link.is-active {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.app-header__staff {
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
}

/* =========================================================
   Login screen
   ========================================================= */
body[data-route="login"] .app-main {
  display: flex;
  flex-direction: column;
  max-width: none;
  padding: 0;
}

body[data-route="login"] #view-login {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

/* Fills the space above the credits footer */
.login {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-4);
  background:
    radial-gradient(circle at 15% 20%, rgba(16, 40, 66, 0.12), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(52, 152, 168, 0.14), transparent 45%),
    var(--color-bg);
}

.login__panel {
  width: 100%;
  max-width: 820px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

/* Solid logo navy so the logo image blends seamlessly into the panel */
.login__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-6);
  background: var(--color-primary);
  color: #fff;
  text-align: center;
}

.login__logo {
  display: block;
  width: 100%;
  max-width: 250px;
  height: auto;
}

.login__subtitle {
  margin: var(--space-2) 0 0;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent);
}

.login__form {
  padding: var(--space-6);
}

.login__heading {
  font-size: var(--text-xl);
  margin-bottom: var(--space-5);
}

.password-wrap {
  position: relative;
  display: flex;
}

.password-wrap input {
  flex: 1;
  padding-right: 72px;
}

.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  padding: var(--space-1) var(--space-3);
}

.login__hint {
  margin: var(--space-4) 0 0;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--color-primary-soft);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
}

.login__footer {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-align: center;
}

/* =========================================================
   Page scaffolding
   ========================================================= */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.page-title {
  font-size: var(--text-xl);
}

.page-subtitle {
  margin: var(--space-1) 0 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* Date simulator bar */
.sim-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  background: var(--color-surface);
  border: 1px dashed var(--color-accent);
  border-radius: var(--radius-md);
}

.sim-bar__date {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.sim-bar__label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.sim-bar__value {
  font-size: var(--text-md);
}

.sim-bar__note {
  flex: 1 1 260px;
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.sim-bar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.sim-pill {
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 700;
}

.sim-pill--real {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.sim-pill--ahead {
  background: var(--status-duesoon-bg);
  color: var(--status-duesoon-fg);
}

/* Summary stat cards (also act as filters) */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: var(--space-4);
  font: inherit;
  text-align: left;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--stat-accent, var(--color-primary));
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  color: var(--color-text);
}

.stat:hover {
  box-shadow: var(--shadow-md);
}

.stat.is-active {
  outline: 2px solid var(--stat-accent, var(--color-primary));
  outline-offset: -1px;
}

.stat__value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--stat-accent, var(--color-text));
}

.stat__label {
  font-weight: 600;
}

.stat__hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.stat--overdue { --stat-accent: var(--status-overdue-fg); }
.stat--duesoon { --stat-accent: var(--status-duesoon-fg); }
.stat--pending { --stat-accent: var(--status-pending-fg); }
.stat--total   { --stat-accent: var(--color-primary); }

/* Toolbar: filter chips + search */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.chip:hover {
  color: var(--color-text);
}

.chip.is-active {
  color: #fff;
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.chip__count {
  min-width: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  text-align: center;
}

.chip.is-active .chip__count {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.search {
  flex: 0 1 280px;
  min-width: 0;
  font: inherit;
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
}

.search:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

/* Table cells with a main line + muted sub line */
.cell-main {
  display: block;
  font-weight: 600;
}

.cell-sub {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.cell-sub--alert {
  margin-top: var(--space-1);
  color: var(--status-overdue-fg);
  font-weight: 600;
}

.cell-actions {
  text-align: right;
  white-space: nowrap;
}

.cell-actions .btn + .btn {
  margin-left: var(--space-2);
}

.cell-actions a.btn {
  text-decoration: none;
}

.visually-hidden-th {
  font-size: 0;
}

.empty {
  text-align: center;
  color: var(--color-text-muted);
}

/* =========================================================
   Patient detail
   ========================================================= */
.back-link {
  display: inline-block;
  margin-bottom: var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

.detail-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
}

.detail-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

/* Info card */
.info-card {
  position: sticky;
  top: calc(var(--header-height) + var(--space-4));
}

.info-card__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.avatar {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 700;
}

.info-card__name {
  font-size: var(--text-lg);
}

.info-card__id {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.info-next {
  padding: var(--space-3);
  margin-bottom: var(--space-4);
  background: var(--color-bg);
  border-radius: var(--radius-sm);
}

.info-next__label {
  margin: 0 0 var(--space-1);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.info-next__value {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  font-weight: 700;
}

.info-next__sub {
  margin: var(--space-1) 0 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.info-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-2) var(--space-3);
  margin: 0 0 var(--space-4);
  font-size: var(--text-sm);
}

.info-list dt {
  color: var(--color-text-muted);
}

.info-list dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.tag {
  padding: 1px var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-size: var(--text-xs);
  font-weight: 700;
}

.progress-block__row {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-sm);
  margin-bottom: var(--space-1);
}

.progress {
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--color-bg);
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--status-pending-fg);
  border-radius: inherit;
}

.progress-block__alert {
  margin: var(--space-2) 0 0;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--status-overdue-fg);
}

/* Section cards */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.section-title {
  font-size: var(--text-lg);
}

.section-card > .section-title {
  margin-bottom: var(--space-4);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Overview grid */
.ov-wrap {
  overflow-x: auto;
}

.ov-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 4px;
  font-size: var(--text-sm);
}

.ov-table thead th {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  font-weight: 700;
  text-align: center;
  padding: 0 var(--space-2);
}

.ov-table thead th:first-child,
.ov-table tbody th {
  text-align: left;
}

.ov-table tbody th {
  padding-right: var(--space-3);
  font-weight: normal;
  white-space: nowrap;
}

.ov-cell {
  min-width: 76px;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  text-align: center;
  border: 1px solid transparent;
}

.ov-cell__dose {
  display: none;
  font-size: 10px;
  font-weight: 700;
  opacity: 0.8;
}

.ov-cell__age {
  display: block;
  font-size: var(--text-xs);
  opacity: 0.85;
}

.ov-cell__status {
  display: block;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
}

.ov-cell--overdue { background: var(--status-overdue-bg); color: var(--status-overdue-fg); border-color: currentColor; }
.ov-cell--duesoon { background: var(--status-duesoon-bg); color: var(--status-duesoon-fg); border-color: currentColor; }
.ov-cell--pending { background: var(--status-pending-bg); color: var(--status-pending-fg); }
.ov-cell--done    { background: var(--status-done-bg);    color: var(--status-done-fg); }
.ov-cell--none    { color: var(--color-border); }

/* Timeline */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--color-border);
}

.tl-item {
  position: relative;
  display: flex;
  gap: var(--space-4);
  padding-bottom: var(--space-4);
}

.tl-item:last-child {
  padding-bottom: 0;
}

.tl-item__dot {
  position: relative;
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  border-radius: 50%;
  border: 3px solid var(--color-surface);
  background: var(--dot, var(--color-border));
  box-shadow: 0 0 0 2px var(--dot, var(--color-border));
}

.tl-item--overdue { --dot: var(--status-overdue-fg); }
.tl-item--duesoon { --dot: var(--status-duesoon-fg); }
.tl-item--pending { --dot: var(--status-pending-fg); }
.tl-item--done    { --dot: var(--status-done-fg); }

.tl-item--pending .tl-item__dot {
  background: var(--color-surface);
}

.tl-item__body {
  flex: 1;
  min-width: 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--dot);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}

.tl-item--done .tl-item__body {
  background: var(--color-bg);
}

.tl-item--overdue .tl-item__body {
  background: var(--status-overdue-bg);
}

.tl-item--duesoon .tl-item__body {
  background: var(--status-duesoon-bg);
}

.tl-item__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.tl-item__title {
  font-weight: 700;
}

.tl-item__meta,
.tl-item__when {
  margin: var(--space-1) 0 0;
  font-size: var(--text-sm);
}

.tl-item__meta {
  color: var(--color-text-muted);
}

.tl-item__muted {
  color: var(--color-text-muted);
}

.tl-item__alert {
  color: var(--status-overdue-fg);
  font-weight: 700;
}

.tl-item__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.tl-today {
  position: relative;
  display: flex;
  align-items: center;
  margin: 0 0 var(--space-4);
  padding-left: 36px;
}

.tl-today::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 2px dashed var(--color-accent);
}

.tl-today__label {
  position: relative;
  padding: 2px var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--color-primary);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* =========================================================
   Modal extras
   ========================================================= */
body.has-modal {
  overflow: hidden;
}

.modal--wide {
  max-width: 780px;
}

.modal__title {
  font-size: var(--text-lg);
}

.modal__close {
  width: 36px;
  height: 36px;
  font-size: 1.5rem;
  line-height: 1;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
}

.modal__close:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.modal__footer .btn + .btn {
  margin-left: var(--space-2);
}

/* =========================================================
   Reminder preview
   ========================================================= */
.reminder-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: var(--space-5);
  align-items: start;
}

.reminder-preview__channel {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.sim-notice {
  margin: 0;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--status-duesoon-bg);
  color: var(--status-duesoon-fg);
  font-size: var(--text-sm);
}

/* Segmented toggle */
.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-pill);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}

.seg__btn {
  padding: var(--space-1) var(--space-4);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
}

.seg__btn.is-active {
  background: var(--color-surface);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

/* =========================================================
   Phone mock (SMS / WhatsApp)
   ========================================================= */
.phone {
  --phone-bg: #f2f2f7;
  --phone-bar: #f9f9fb;
  --phone-bar-text: #1c1c1e;
  --bubble-bg: #e5e5ea;
  --bubble-text: #1c1c1e;
  position: relative;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  padding: 10px;
  border-radius: 36px;
  background: #1c1c1e;
  box-shadow: var(--shadow-md);
}

.phone--whatsapp {
  --phone-bg: #efeae2;
  --phone-bar: #075e54;
  --phone-bar-text: #ffffff;
  --bubble-bg: #ffffff;
  --bubble-text: #111b21;
}

.phone__notch {
  position: absolute;
  top: 10px;
  left: 50%;
  z-index: 1;
  width: 90px;
  height: 18px;
  transform: translateX(-50%);
  border-radius: 0 0 12px 12px;
  background: #1c1c1e;
}

.phone__bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 28px var(--space-3) var(--space-2);
  border-radius: 26px 26px 0 0;
  background: var(--phone-bar);
  color: var(--phone-bar-text);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

/* Hospital "profile picture" in the chat header: the VaxiCare emblem */
.phone__avatar {
  flex: none;
  display: block;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
}

.phone__contact {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.phone__contact strong {
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.phone__contact small {
  font-size: 11px;
  opacity: 0.75;
}

.phone__screen {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-height: 360px;
  max-height: 460px;
  overflow-y: auto;
  padding: var(--space-3);
  border-radius: 0 0 26px 26px;
  background: var(--phone-bg);
}

.phone__empty {
  margin: auto;
  font-size: var(--text-sm);
  color: #8e8e93;
  text-align: center;
}

.msg-date {
  align-self: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: #6b6b70;
  background: rgba(255, 255, 255, 0.7);
}

.msg {
  align-self: flex-start;
  max-width: 88%;
  padding: var(--space-2) var(--space-3) var(--space-1);
  border-radius: 16px 16px 16px 4px;
  background: var(--bubble-bg);
  color: var(--bubble-text);
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

.phone--whatsapp .msg {
  border-radius: 0 10px 10px 10px;
}

.msg__text {
  margin: 0;
  overflow-wrap: anywhere;
}

.msg__meta {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-1);
  margin-top: 2px;
  font-size: 10px;
  color: #8e8e93;
}

.msg__ticks {
  color: #53bdeb;
  letter-spacing: -3px;
}

.msg.is-new {
  animation: msg-pop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

@keyframes msg-pop {
  from { opacity: 0; transform: translateY(12px) scale(0.92); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .msg.is-new {
    animation: none;
  }
}

/* =========================================================
   Toast notifications
   ========================================================= */
/* Bottom-right, above the guardian phone button, so toasts never cover the
   date simulator or header controls during a demo. Newest at the bottom. */
.toast-root {
  position: fixed;
  bottom: 88px;
  right: var(--space-5);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 360px;
  max-width: calc(100vw - 2 * var(--space-4));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  font: inherit;
  text-align: left;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--toast-accent, var(--color-primary));
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

button.toast {
  cursor: pointer;
}

button.toast:hover {
  background: var(--color-bg);
}

.toast.is-leaving {
  animation: toast-out 0.25s ease-in forwards;
}

.toast--info    { --toast-accent: var(--color-primary); }
.toast--duesoon { --toast-accent: var(--status-duesoon-fg); }
.toast--overdue { --toast-accent: var(--status-overdue-fg); }
.toast--success { --toast-accent: var(--status-pending-fg); }

.toast__icon {
  flex: none;
  font-size: 1.1rem;
  line-height: 1.4;
}

.toast__content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: var(--text-sm);
}

.toast__title {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--toast-accent, var(--color-primary));
}

.toast__text {
  overflow-wrap: anywhere;
}

.toast__hint {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.toast__close {
  flex: none;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--color-text-muted);
  padding: 2px 4px;
  border-radius: 4px;
}

.toast__close:hover {
  background: var(--color-border);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: none; }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateX(24px); }
}

@media (prefers-reduced-motion: reduce) {
  .toast,
  .toast.is-leaving {
    animation: none;
  }
}

/* =========================================================
   Guardian phone: floating button + drawer
   ========================================================= */
.phone-fab {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  z-index: 150;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
}

.phone-fab:hover {
  background: var(--color-primary-hover);
}

.fab__badge {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  background: var(--status-overdue-fg);
  color: #fff;
  font-size: var(--text-xs);
  animation: badge-pulse 1.6s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(180, 35, 24, 0.5); }
  50%      { box-shadow: 0 0 0 6px rgba(180, 35, 24, 0); }
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 160;
  width: 380px;
  max-width: 100vw;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  overflow-y: auto;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  animation: drawer-in 0.3s ease-out;
}

@keyframes drawer-in {
  from { transform: translateX(100%); }
  to   { transform: none; }
}

/* Wide screens: the page shifts left so the drawer sits beside it and the
   date simulator stays clickable; toasts move clear of the drawer. */
@media (min-width: 861px) {
  body.has-drawer {
    padding-right: 380px;
  }

  body.has-drawer .toast-root {
    right: calc(380px + var(--space-4));
    bottom: var(--space-5);
  }
}

.drawer__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.drawer__title {
  font-size: var(--text-lg);
}

.drawer__subtitle {
  margin: 2px 0 0;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.drawer__controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.drawer__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.drawer__phone .phone__screen {
  min-height: 420px;
  max-height: calc(100vh - 330px);
}

.drawer__note {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-align: center;
}

.select {
  width: 100%;
  font: inherit;
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
}

.btn--sm {
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
}

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

/* =========================================================
   Reminder log
   ========================================================= */
.toolbar__right {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  flex: 0 1 520px;
}

.toolbar__right .search {
  flex: 1 1 220px;
}

.select--inline {
  width: auto;
  flex: 0 1 220px;
}

.log-summary {
  margin: 0 0 var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.log-summary:empty {
  display: none;
}

/* Keep dates, names and phone numbers on one line */
.table--log td:nth-child(-n + 3) .cell-main,
.table--log td:nth-child(-n + 3) .cell-sub {
  white-space: nowrap;
}

.table--log th,
.table--log td {
  padding-left: var(--space-3);
  padding-right: var(--space-3);
}

.log-msg summary {
  cursor: pointer;
  color: var(--color-primary);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
}

.log-msg__text {
  margin: var(--space-2) 0 0;
  padding: var(--space-2) var(--space-3);
  max-width: 300px;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: var(--text-xs);
  line-height: 1.5;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
}

.status-pill {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-size: var(--text-xs);
  font-weight: 700;
}

.status-pill--below {
  display: table;
  margin-top: var(--space-1);
}

.table--log .badge {
  white-space: normal;
}

.table--log .cell-actions .btn {
  white-space: normal;
}

.badge--solid {
  color: #fff;
  background: var(--status-overdue-fg);
  border-color: var(--status-overdue-fg);
}

.empty p + p {
  margin-top: 0;
}

/* =========================================================
   Accessibility helpers
   ========================================================= */
.skip-link {
  position: absolute;
  left: var(--space-3);
  top: -100px;
  z-index: 300;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  top: var(--space-3);
}

.app-main:focus {
  outline: none;
}

.plain-list {
  margin: var(--space-2) 0 0;
  padding-left: var(--space-5);
}

.plain-list li + li {
  margin-top: var(--space-1);
}

.modal__body > p:first-child {
  margin-top: 0;
}

.modal__body > :last-child {
  margin-bottom: 0;
}

@media (prefers-reduced-motion: reduce) {
  .drawer,
  .fab__badge {
    animation: none;
  }
}

/* Utilities */
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: var(--text-sm); }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 640px) {
  /* Credits stack on two lines; the separator dot would dangle */
  .app-credits {
    flex-direction: column;
    gap: 2px;
  }

  .app-credits__sep {
    display: none;
  }

  /* Overview grid: one row of dose chips per vaccine instead of a wide table */
  .ov-table,
  .ov-table tbody {
    display: block;
  }

  .ov-table thead {
    display: none;
  }

  .ov-table tr {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: var(--space-3);
  }

  .ov-table tbody th {
    flex: 1 1 100%;
    padding: 0;
  }

  .ov-table tbody th .cell-main,
  .ov-table tbody th .cell-sub {
    display: inline;
  }

  .ov-table tbody th .cell-sub {
    margin-left: var(--space-2);
  }

  .ov-cell {
    flex: 0 1 calc(20% - 4px);
    min-width: 0;
    padding: 4px 2px;
  }

  .ov-cell__age,
  .ov-cell__status {
    font-size: 10px;
  }

  .ov-cell--none {
    display: none;
  }

  .ov-cell__dose {
    display: block;
  }

  .app-header {
    padding: 0 var(--space-4);
  }

  .app-main {
    padding: var(--space-4);
  }

  .card {
    padding: var(--space-4);
  }

  .login__panel {
    grid-template-columns: 1fr;
  }

  .login__brand,
  .login__form {
    padding: var(--space-5);
  }

  .app-header__staff {
    display: none;
  }

  .toast-root {
    right: var(--space-2);
    left: var(--space-2);
    bottom: 76px;
    width: auto;
    max-width: none;
  }

  /* The full-screen drawer already shows messages arriving */
  body.has-drawer .toast-root {
    display: none;
  }

  .phone-fab {
    right: var(--space-4);
    bottom: var(--space-4);
  }

  .drawer {
    width: 100vw;
  }
}

/* Tablet: 2×2 stats, table becomes stacked cards, detail stacks */
@media (max-width: 860px) {
  .reminder-preview {
    grid-template-columns: 1fr;
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .info-card {
    position: static;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search {
    flex: 1 1 100%;
  }

  .table-wrap:has(.table--responsive) {
    background: transparent;
    border: none;
    box-shadow: none;
  }

  .table--responsive thead {
    display: none;
  }

  .table--responsive,
  .table--responsive tbody,
  .table--responsive tr,
  .table--responsive td {
    display: block;
    width: 100%;
  }

  .table--responsive tr {
    margin-bottom: var(--space-3);
    padding: var(--space-2) 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
  }

  .table--responsive td {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 0 var(--space-3);
    padding: var(--space-2) var(--space-4);
    border-bottom: none;
  }

  /* Label in column 1, all cell content stacked in column 2 */
  .table--responsive td > * {
    grid-column: 2;
    justify-self: start;
  }

  .table--responsive td::before {
    grid-row: 1 / span 3;
    content: attr(data-label);
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    padding-top: 2px;
  }

  .table--responsive td.cell-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    padding-top: var(--space-3);
  }

  .table--responsive td.cell-actions::before {
    display: none;
  }

  .cell-actions .btn + .btn {
    margin-left: 0;
  }
}

@media (max-width: 860px) {
  .app-header {
    height: auto;
    min-height: var(--header-height);
    flex-wrap: wrap;
    padding-top: var(--space-2);
    padding-bottom: var(--space-2);
  }

  .app-nav {
    margin-right: 0;
  }
}
