/* --- Design tokens --- */
:root {
  --bg: #f5f5f4;
  --surface: #ffffff;
  --surface-2: #fafaf9;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;
  --text: #1c1917;
  --text-muted: #78716c;
  --text-subtle: #a8a29e;

  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-soft: #ccfbf1;
  --accent-tint: #f0fdfa;

  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.10), 0 4px 6px rgba(15, 23, 42, 0.05);

  --radius: 8px;
  --radius-lg: 12px;
  --radius-sm: 6px;
}

/* Dark theme — same token names, different values, so every rule built on
   var(--...) automatically picks these up with no other CSS changes.
   Toggled via [data-theme="dark"] on <html>, set by the sidebar toggle
   button and persisted in localStorage (see app.js). */
:root[data-theme="dark"] {
  --bg: #1c1917;
  --surface: #292524;
  --surface-2: #201d1b;
  --border: #44403c;
  --border-strong: #57534e;
  --text: #f5f5f4;
  --text-muted: #a8a29e;
  --text-subtle: #78716c;

  --accent: #2dd4bf;
  --accent-hover: #5eead4;
  --accent-soft: #134e4a;
  --accent-tint: #0f2e2c;

  --success: #4ade80;
  --success-soft: #14532d;
  --warning: #fbbf24;
  --warning-soft: #451a03;
  --danger: #f87171;
  --danger-soft: #450a0a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5), 0 4px 6px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* --- Login --- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f766e 0%, #164e63 100%);
  padding: 24px;
}
.login-card {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 40px 32px; width: 100%; max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-brand .logo {
  width: 40px; height: 40px; border-radius: var(--radius);
  background: var(--accent); color: white;
  display: grid; place-items: center; font-weight: 700; font-size: 18px;
}
.login-brand h1 { font-size: 20px; letter-spacing: -0.01em; }
.login-brand .tag { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.login-card label { display: block; font-weight: 500; margin-bottom: 8px; }
.pin-display {
  height: 54px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface-2); display: flex; align-items: center; justify-content: center;
  gap: 12px; margin-bottom: 16px; font-size: 24px; letter-spacing: 8px;
  font-variant-numeric: tabular-nums;
}
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pin-pad button {
  height: 54px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 18px; font-weight: 500; color: var(--text);
  transition: background 0.1s;
}
.pin-pad button:hover { background: var(--border); }
.pin-pad button.pin-action { background: var(--accent); color: white; border-color: var(--accent); }
.pin-pad button.pin-action:hover { background: var(--accent-hover); }
.pin-pad button.pin-clear { color: var(--danger); }
.login-hint {
  margin-top: 20px; padding: 12px; background: var(--accent-tint);
  border: 1px solid var(--accent-soft); border-radius: var(--radius);
  font-size: 12px; color: #134e4a;
}
.login-hint strong { display: block; margin-bottom: 4px; }
.login-err {
  margin-top: 12px; padding: 10px 12px; background: var(--danger-soft);
  color: var(--danger); border-radius: var(--radius); font-size: 13px;
}

/* --- App shell --- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 12px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.sidebar .brand { flex-shrink: 0; }
.sidebar-nav-scroll {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; margin: 0 -4px; padding: 0 4px;
}
.sidebar-nav-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-nav-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.brand .logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent); color: white;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.brand .title { font-weight: 600; font-size: 15px; }
.brand .fac { font-size: 11px; color: var(--text-muted); }

.nav-section { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-subtle); padding: 12px 12px 6px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 12px; border-radius: var(--radius-sm); text-align: left;
  color: var(--text); font-size: 13px; font-weight: 500;
  position: relative;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-tint); color: var(--accent); }
.nav-item .icon { width: 16px; height: 16px; opacity: 0.7; flex-shrink: 0; }
.nav-item.active .icon { opacity: 1; }
.nav-item .badge {
  margin-left: auto; background: var(--danger); color: white;
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px;
  min-width: 18px; text-align: center;
}
.nav-item.sub {
  padding-left: 30px; font-size: 12px; font-weight: 400; color: var(--text-muted);
}
.nav-item.sub .icon { display: none; }
.nav-item.sub.active { color: var(--accent); font-weight: 500; }

.sidebar-foot {
  margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border);
}
.user-block {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  border-radius: var(--radius-sm);
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent);
  color: white; display: grid; place-items: center; font-weight: 600; font-size: 12px;
}
.user-block .name { font-weight: 600; font-size: 13px; }
.user-block .role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }
.clock-btn {
  width: 100%; margin-top: 10px; padding: 8px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--text);
}
.clock-btn.on { background: var(--success-soft); color: #14532d; border-color: #86efac; }
.clock-btn.off { background: var(--surface-2); color: var(--text); }
.logout-btn {
  width: 100%; margin-top: 6px; padding: 6px; border-radius: var(--radius-sm);
  font-size: 12px; color: var(--text-muted);
}
.logout-btn:hover { color: var(--danger); }
.theme-toggle-btn {
  width: 100%; margin-top: 6px; padding: 6px; border-radius: var(--radius-sm);
  font-size: 12px; color: var(--text-muted); text-align: left;
}
.theme-toggle-btn:hover { color: var(--text); background: var(--surface-2); }

/* --- Content area --- */
.main {
  padding: 24px 32px; overflow-x: hidden;
  height: 100vh; overflow-y: auto;
}
.main::-webkit-scrollbar { width: 8px; }
.main::-webkit-scrollbar-track { background: transparent; }
.main::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.main::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }
.page-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 20px; gap: 16px; }
.page-head h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.page-head .sub { color: var(--text-muted); font-size: 13px; }
.page-actions { display: flex; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  transition: all 0.1s;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }

/* --- Cards --- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; }

/* --- Tile launcher (Home) --- */
.tile-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px; max-width: 900px;
}
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; text-align: left; transition: all 0.15s; position: relative;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 110px;
}
.tile:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }
.tile .tile-icon {
  width: 36px; height: 36px; border-radius: var(--radius); background: var(--accent-tint);
  color: var(--accent); display: grid; place-items: center;
}
.tile .tile-name { font-weight: 600; font-size: 15px; color: var(--text); }
.tile .tile-sub { font-size: 12px; color: var(--text-muted); }
.tile .tile-badge {
  position: absolute; top: 12px; right: 12px;
  background: var(--danger); color: white; font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 12px;
}

/* --- Dashboard stat cards --- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px; display: flex; flex-direction: column; gap: 4px;
}
.stat .label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.stat .value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; }
.stat .foot { font-size: 11px; color: var(--text-subtle); }
.stat.warn .value { color: var(--warning); }
.stat.danger .value { color: var(--danger); }
.stat.ok .value { color: var(--success); }

/* --- Tables --- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }

/* Caps a list/table to roughly 5 visible rows, scrolling for the rest.
   Used on Inventory's three lists (on-hand, order history, disposition
   history) so a long history doesn't push the page into an endless scroll. */
.scroll-cap-5 { max-height: 260px; overflow-y: auto; }
.scroll-cap-5.table-wrap table thead { position: sticky; top: 0; background: var(--surface); z-index: 1; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
table.data th { background: var(--surface-2); font-weight: 600; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }

/* --- Pass Meds queue --- */
.dose-list { display: flex; flex-direction: column; gap: 8px; }
.dose-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px 16px; display: grid;
  grid-template-columns: 60px 1fr auto; gap: 14px; align-items: center;
}
.dose-item.overdue { border-left: 3px solid var(--danger); background: var(--danger-soft); }
.dose-item.due-soon { border-left: 3px solid var(--warning); background: var(--warning-soft); }
.dose-item.upcoming { border-left: 3px solid var(--border-strong); }
.dose-time { text-align: center; }
.dose-time .hhmm { font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
.dose-time .relative { font-size: 11px; color: var(--text-muted); }
.dose-time.overdue .relative { color: var(--danger); font-weight: 600; }
.dose-time.due-soon .relative { color: var(--warning); font-weight: 600; }
.dose-info .who { font-weight: 600; }
.dose-info .who .room { color: var(--text-muted); font-weight: 400; margin-left: 6px; font-size: 12px; }
.dose-info .med { font-size: 13px; color: var(--text); margin-top: 3px; }
.dose-info .med .drug { font-weight: 500; }
.dose-info .med .details { color: var(--text-muted); }
.dose-info .controlled-badge {
  display: inline-block; background: #fef3c7; color: #92400e;
  font-size: 10px; padding: 2px 6px; border-radius: 4px; margin-left: 6px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.dose-info .instr { font-size: 12px; color: var(--text-muted); font-style: italic; margin-top: 4px; }
.dose-actions { display: flex; gap: 6px; }

/* --- Resident cards --- */
.resident-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.resident-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px; display: flex; gap: 14px; align-items: center; text-align: left;
  transition: all 0.1s;
}
.resident-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.avatar {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  color: white; display: grid; place-items: center; font-weight: 600; font-size: 16px;
}
img.avatar { object-fit: cover; display: block; background: var(--surface-2); }
.resident-info .name { font-weight: 600; font-size: 15px; }
.resident-info .meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }

/* --- Login: staff picker --- */
.login-card.wide { max-width: 640px; }
.login-facility {
  text-align: center; font-size: 13px; color: var(--text-muted);
  margin-bottom: 20px; padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.login-prompt {
  text-align: center; font-size: 14px; color: var(--text-muted);
  margin-bottom: 16px;
}
.staff-picker {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 10px; margin-bottom: 16px;
}
.staff-picker-card {
  padding: 14px 8px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); cursor: pointer; text-align: center;
  transition: all 0.1s; display: flex; flex-direction: column;
  align-items: center; gap: 6px;
}
.staff-picker-card:hover {
  border-color: var(--accent); background: var(--accent-tint);
  transform: translateY(-1px);
}
.staff-picker-card .avatar { width: 44px; height: 44px; font-size: 14px; }
.staff-picker-card .sp-name { font-weight: 600; font-size: 13px; }
.staff-picker-card .sp-role {
  font-size: 10px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.staff-picker-card .sp-pin {
  font-size: 10px; color: var(--accent); font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 2px 6px; background: var(--accent-tint); border-radius: 4px;
}
.selected-staff-block {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; margin-bottom: 16px;
  background: var(--surface-2); border-radius: var(--radius-lg);
}
.selected-staff-block .avatar { width: 48px; height: 48px; font-size: 16px; }
.back-to-picker {
  background: none; border: none; color: var(--accent);
  font-size: 13px; cursor: pointer; padding: 4px 0;
  display: flex; align-items: center; gap: 4px; margin-bottom: 12px;
}
.back-to-picker:hover { text-decoration: underline; }
.login-loading {
  text-align: center; padding: 24px; color: var(--text-muted); font-size: 13px;
}

/* --- Facility switcher (sidebar dropdown for multi-home) --- */
.facility-switcher {
  padding: 0 16px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.facility-switcher.single .fac-single-name {
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface-2);
  border-radius: 6px;
}
.facility-select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
}
.facility-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

/* --- Facility breakdown table on dashboard --- */
.facility-breakdown {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.facility-breakdown thead th {
  text-align: left; padding: 8px 12px; background: var(--surface-2);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); font-weight: 600;
}
.facility-breakdown tbody td {
  padding: 10px 12px; border-top: 1px solid var(--border);
}
.facility-breakdown tbody tr:hover { background: var(--surface-2); }

/* --- Modal section headers (for larger forms like Staff add/edit) --- */
.modal-section-head {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
  margin: 20px 0 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.chart-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 12px 16px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 16px;
  transition: border-color 0.1s;
}
.chart-card:hover { border-color: var(--accent-soft); }
.chart-card .cc-info { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; }
.chart-card .cc-actions { display: flex; gap: 6px; flex-shrink: 0; }
@media (max-width: 720px) {
  .chart-card { flex-direction: column; align-items: stretch; }
  .chart-card .cc-actions { justify-content: stretch; }
  .chart-card .cc-actions .btn { flex: 1; }
}
.badge {
  font-size: 10px; padding: 2px 6px; border-radius: 4px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.badge.fall { background: var(--warning-soft); color: #92400e; }
.badge.dnr { background: var(--danger-soft); color: #991b1b; }
.badge.diabetes { background: #dbeafe; color: #1e40af; }

/* --- Resident detail --- */
.resident-header {
  display: flex; gap: 20px; align-items: center; margin-bottom: 20px;
}
.resident-header .avatar { width: 72px; height: 72px; font-size: 24px; }
.resident-header h1 { font-size: 24px; }
.resident-header .meta { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

.detail-cols { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 900px) { .detail-cols { grid-template-columns: 1fr; } }

.timeline-item {
  padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--border);
  margin-bottom: 8px; background: var(--surface-2);
}
.timeline-item .head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.timeline-item .title { font-weight: 600; font-size: 13px; }
.timeline-item .when { font-size: 11px; color: var(--text-muted); }
.timeline-item .detail { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.timeline-item .notes { font-size: 13px; margin-top: 6px; color: var(--text); }
.timeline-item .kind {
  display: inline-block; font-size: 10px; padding: 1px 5px; border-radius: 4px;
  font-weight: 600; text-transform: uppercase; margin-right: 6px;
}
.kind.med { background: var(--accent-tint); color: var(--accent); }
.kind.adl { background: #e0e7ff; color: #4338ca; }
.kind.note { background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); }
.kind.vital { background: #fce7f3; color: #9d174d; }
.kind.incident { background: var(--danger-soft); color: var(--danger); }

.info-list { list-style: none; }
.info-list li { display: flex; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.info-list li:last-child { border-bottom: none; }
.info-list .label { color: var(--text-muted); width: 130px; flex-shrink: 0; }
.info-list .value { color: var(--text); }

/* --- Forms --- */
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-row label { font-weight: 500; font-size: 12px; color: var(--text-muted); }
.form-row input, .form-row select, .form-row textarea {
  padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint);
}
.form-row textarea { min-height: 80px; resize: vertical; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-check { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 13px; }
.form-check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* --- Modal --- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 24px; width: 100%; max-width: 520px; max-height: 90vh;
  overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal.modal-lg { max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h2 { font-size: 17px; font-weight: 600; }
.modal-close { color: var(--text-muted); font-size: 22px; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* --- Empty states --- */
.empty {
  padding: 60px 20px; text-align: center; color: var(--text-muted);
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
  background: var(--surface);
}
.empty .icon { font-size: 32px; margin-bottom: 12px; opacity: 0.4; }
.empty h3 { font-size: 15px; color: var(--text); margin-bottom: 4px; }

/* --- Toast --- */
#toast-root { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text); color: white; padding: 12px 18px; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); font-size: 13px; min-width: 260px; max-width: 400px;
  line-height: 1.4;
  animation: slide-in 0.2s ease-out;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slide-in { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* --- Utility --- */
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.mono { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 12px; align-items: center; }
.wrap { flex-wrap: wrap; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; }
.pill { padding: 2px 8px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 11px; font-weight: 500; }
.pill.given { background: var(--success-soft); color: #14532d; border-color: #86efac; }
.pill.refused { background: var(--danger-soft); color: #991b1b; border-color: #fca5a5; }
.pill.held { background: var(--warning-soft); color: #92400e; border-color: #fcd34d; }
.pill.missed { background: var(--danger-soft); color: #991b1b; border-color: #fca5a5; }
.pill.due { background: var(--accent-tint); color: var(--accent); border-color: var(--accent-soft); }

@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .main { padding: 16px; }
  .dose-item { grid-template-columns: 1fr; gap: 8px; }
  .dose-actions { justify-content: flex-start; }
}
