@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/Outfit-400.woff2") format("woff2"), url("/fonts/Outfit-400.ttf") format("truetype");
}
@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/Outfit-500.woff2") format("woff2"), url("/fonts/Outfit-500.ttf") format("truetype");
}
@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/Outfit-600.woff2") format("woff2"), url("/fonts/Outfit-600.ttf") format("truetype");
}
@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/Outfit-700.woff2") format("woff2"), url("/fonts/Outfit-700.ttf") format("truetype");
}
@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/fonts/Outfit-800.woff2") format("woff2"), url("/fonts/Outfit-800.ttf") format("truetype");
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/PlusJakartaSans-400.woff2") format("woff2"), url("/fonts/PlusJakartaSans-400.ttf") format("truetype");
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/PlusJakartaSans-500.woff2") format("woff2"), url("/fonts/PlusJakartaSans-500.ttf") format("truetype");
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/PlusJakartaSans-600.woff2") format("woff2"), url("/fonts/PlusJakartaSans-600.ttf") format("truetype");
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/PlusJakartaSans-700.woff2") format("woff2"), url("/fonts/PlusJakartaSans-700.ttf") format("truetype");
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/fonts/PlusJakartaSans-800.woff2") format("woff2"), url("/fonts/PlusJakartaSans-800.ttf") format("truetype");
}

:root {
  --font-heading: "Outfit", "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-sub: "Outfit", "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --bg-page: #f5f7f4;
  --bg-page-gradient: radial-gradient(1200px circle at 10% 0%, rgba(56, 189, 248, 0.14) 0%, transparent 55%),
    radial-gradient(1000px circle at 92% 12%, rgba(34, 197, 94, 0.12) 0%, transparent 55%),
    linear-gradient(160deg, #f3f8fc 0%, #f5f7f4 52%, #eef6f1 100%);
  --person-accent: #0ea5e9;
  --person-rgb: 14, 165, 233;
  --person-rgb-2: 59, 130, 246;
  --person-rgb-3: 16, 185, 129;
  --person-avatar-gradient: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-elevated: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.85);
  --bg-glass-hover: #ffffff;

  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --border-light: #e2e8f0;
  --border-input: #cbd5e1;
  --border-glass: rgba(15, 23, 42, 0.12);

  /* Inviting Green (Ready to Take) */
  --green-surface: #f0fdf4;
  --green-border: #86efac;
  --green-accent: #16a34a;
  --green-accent-hover: #15803d;
  --green-badge-bg: #dcfce7;
  --green-badge-text: #166534;

  /* Clear, Friendly Red (Not Time Yet) */
  --red-surface: #fff1f2;
  --red-border: #fda4af;
  --red-accent: #e11d48;
  --red-badge-bg: #ffe4e6;
  --red-badge-text: #9f1239;

  /* Warm Warning Orange (Early Dose Caution) */
  --orange-surface: #fff7ed;
  --orange-border: #fdba74;
  --orange-accent: #ea580c;
  --orange-accent-hover: #c2410c;
  --orange-badge-bg: #ffedd5;
  --orange-badge-text: #9a3412;

  --radius-xl: 22px;
  --radius-lg: 15px;
  --radius-md: 10px;
  --shadow-soft: 0 10px 30px -6px rgba(15, 23, 42, 0.07), 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-card: 0 6px 18px -4px rgba(15, 23, 42, 0.06), 0 2px 6px rgba(15, 23, 42, 0.03);
  --tooltip-bg: #1e293b;
  --tooltip-text: #f8fafc;
  --tooltip-border: rgba(255, 255, 255, 0.14);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg-page: #0f141c;
  --bg-page-gradient: radial-gradient(1200px circle at 10% 0%, rgba(56, 189, 248, 0.16) 0%, transparent 55%),
    radial-gradient(1000px circle at 92% 12%, rgba(34, 197, 94, 0.12) 0%, transparent 55%),
    linear-gradient(160deg, #0d1522 0%, #0f141c 55%, #111b24 100%);
  --bg-card: #18202c;
  --bg-subtle: #232e3f;
  --bg-elevated: #1e2837;
  --bg-glass: rgba(15, 20, 28, 0.58);
  --bg-glass-hover: #273449;

  --text-main: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-inverse: #0f141c;

  --border-light: #2a3649;
  --border-input: #3b4b64;
  --border-glass: rgba(255, 255, 255, 0.12);

  /* Soft, Calm Dark-Mode Green */
  --green-surface: #13251f;
  --green-border: #255740;
  --green-accent: #22c55e;
  --green-accent-hover: #16a34a;
  --green-badge-bg: rgba(34, 197, 94, 0.18);
  --green-badge-text: #86efac;

  /* Soft, Calm Dark-Mode Red */
  --red-surface: #28171d;
  --red-border: #632637;
  --red-accent: #f43f5e;
  --red-badge-bg: rgba(244, 63, 94, 0.2);
  --red-badge-text: #fda4af;

  /* Soft, Calm Dark-Mode Orange */
  --orange-surface: #2a1c13;
  --orange-border: #7c3a16;
  --orange-accent: #f97316;
  --orange-accent-hover: #ea580c;
  --orange-badge-bg: rgba(249, 115, 22, 0.22);
  --orange-badge-text: #fdba74;

  --shadow-soft: 0 12px 32px rgba(0, 0, 0, 0.42);
  --shadow-card: 0 6px 20px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
}

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

body {
  background-color: var(--bg-page);
  background-image: var(--bg-page-gradient, none);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: "Outfit", "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: 110px;
  transition: background-color 0.3s ease, color 0.2s ease;
}

h1, h2, h3, h4, h5, h6,
.person-hero-name,
.section-title,
.med-name,
.modal-header h3,
.locked-title,
.admin-card-title,
.accordion-title,
.help-visual-header,
.auth-brand-title {
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
}

.brand-eyebrow,
.med-status-line,
.field-hint,
.locked-desc,
.accordion-subtitle,
.auth-brand-tagline,
.toast-subtitle,
.help-intro,
.help-diagram-svg text {
  font-family: var(--font-sub);
}

.app-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 16px 56px;
}

/* Header */
.app-header {
  position: relative;
  z-index: 15;
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(var(--person-rgb), 0.16) 0%, transparent 58%),
    radial-gradient(100% 120% at 100% 100%, rgba(var(--person-rgb-2), 0.11) 0%, transparent 55%),
    var(--bg-card);
  border: 1px solid rgba(var(--person-rgb), 0.26);
  border-radius: var(--radius-xl);
  padding: 12px 16px;
  margin-bottom: 13px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    0 12px 32px -8px rgba(var(--person-rgb), 0.14),
    var(--shadow-soft);
  transition: background 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
}

[data-theme="dark"] .app-header {
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(var(--person-rgb), 0.22) 0%, transparent 60%),
    radial-gradient(100% 120% at 100% 100%, rgba(var(--person-rgb-2), 0.14) 0%, transparent 55%),
    var(--bg-card);
  border-color: rgba(var(--person-rgb), 0.34);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 14px 34px -8px rgba(0, 0, 0, 0.45);
}

.app-header:has(.person-dropdown-menu:not(.hidden)),
.app-header:has(.profile-dropdown-menu:not(.hidden)) {
  z-index: 75;
}

.header-top {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 10px;
}

.person-hero {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.brand-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--text-muted);
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-settings-gear {
  position: relative;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  opacity: 0.8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s ease, opacity 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.btn-settings-gear svg {
  width: 15px;
  height: 15px;
}

.btn-settings-gear:hover {
  color: var(--text-main);
  opacity: 1;
  background: rgba(15, 23, 42, 0.06);
}

[data-theme="dark"] .btn-settings-gear:hover {
  background: rgba(255, 255, 255, 0.08);
}

#btn-open-family-modal,
#btn-profile-menu {
  color: #2563eb;
  opacity: 0.92;
}

#btn-open-family-modal:hover,
#btn-profile-menu:hover {
  color: #1d4ed8;
  opacity: 1;
}

[data-theme="dark"] #btn-open-family-modal,
[data-theme="dark"] #btn-profile-menu {
  color: #60a5fa;
  opacity: 0.95;
}

[data-theme="dark"] #btn-profile-menu:hover,
[data-theme="dark"] #btn-open-family-modal:hover {
  color: #93c5fd;
  opacity: 1;
}

.btn-settings-gear::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(var(--tip-y, 85%) + 10px);
  bottom: auto;
  left: var(--tip-x, 50%);
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  border: 1px solid var(--tooltip-border);
  font-size: 0.73rem;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 7px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-3px);
  transition: opacity 0.14s ease, transform 0.14s ease;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.26);
  z-index: 80;
}

.btn-settings-gear:hover::after,
.btn-settings-gear:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.med-card-gear {
  background: transparent;
  border: none;
  padding: 4px;
  border-radius: 7px;
}

.med-card-gear svg {
  width: 15px;
  height: 15px;
}

.header-right-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px;
  flex-shrink: 0;
}

#btn-profile-menu::after {
  left: auto;
  right: 0;
  transform: translateY(-3px);
}

#btn-profile-menu:hover::after,
#btn-profile-menu:focus-visible::after {
  transform: translateY(0);
}

.header-utility-icons {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.header-logo-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  border-radius: 14px;
  transition: transform 0.14s ease;
}

.header-logo-wrap:hover {
  transform: translateY(-1px);
}

.header-logo-wrap:active {
  transform: scale(0.96);
}

.header-logo-wrap::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(var(--tip-y, 76%) + 12px);
  bottom: auto;
  left: var(--tip-x, 50%);
  transform: translateX(-50%) translateY(-3px);
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  border: 1px solid var(--tooltip-border);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.26);
  z-index: 80;
}

.header-logo-wrap:hover::after,
.header-logo-wrap:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.header-logo {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.btn-header-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 0.82rem;
  font-weight: 800;
  font-family: inherit;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.btn-family-badge:hover,
.btn-header-icon:hover {
  border-color: var(--border-input);
  color: var(--text-main);
}

.family-badge-caret {
  font-size: 0.7rem;
  opacity: 0.7;
}

.brand-logo-sm {
  width: 18px;
  height: 18px;
  border-radius: 5px;
}

.person-name-row {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.person-title-trigger {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: transparent;
  border: none;
  padding: 2px 4px 2px 0;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-main);
  text-align: left;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.person-title-trigger:hover {
  opacity: 0.9;
}

.person-title-trigger.is-single {
  cursor: default;
}

.person-title-trigger.is-single:hover {
  opacity: 1;
}

.person-hero-avatar {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--person-avatar-gradient, linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%));
  color: #ffffff;
  font-family: var(--font-heading);
  font-size: 0.98rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 4px 12px rgba(var(--person-rgb), 0.32);
  letter-spacing: -0.02em;
}

.person-hero-name {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--text-main);
  margin: 0;
}

.person-status-strip {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 0;
}

.hero-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.005em;
  border: 1px solid var(--border-light);
  background: var(--bg-glass);
  color: var(--text-secondary);
}

.hero-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: currentColor;
}

.hero-status-chip.is-ready {
  background: var(--green-badge-bg);
  border-color: var(--green-border);
  color: var(--green-badge-text);
}

.hero-status-chip.is-ready .hero-status-dot {
  background: var(--green-accent);
}

.hero-status-chip.is-overdue {
  background: rgba(234, 179, 8, 0.16);
  border-color: rgba(234, 179, 8, 0.45);
  color: #a16207;
}

[data-theme="dark"] .hero-status-chip.is-overdue {
  background: rgba(250, 204, 21, 0.18);
  border-color: rgba(250, 204, 21, 0.42);
  color: #fde047;
}

.hero-status-chip.is-waiting {
  background: var(--red-badge-bg);
  border-color: var(--red-border);
  color: var(--red-badge-text);
}

.hero-status-chip.is-waiting .hero-status-dot {
  background: var(--red-accent);
}

.hero-status-chip.is-total {
  background: rgba(var(--person-rgb), 0.10);
  border-color: rgba(var(--person-rgb), 0.24);
  color: var(--text-secondary);
}

.person-title-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  opacity: 0.78;
  margin-top: 4px;
  transition: transform 0.18s ease, color 0.15s ease, opacity 0.15s ease;
}

.person-title-chevron svg {
  width: 20px;
  height: 20px;
}

.person-title-trigger:hover .person-title-chevron {
  color: var(--text-main);
  opacity: 1;
}

.person-title-trigger[aria-expanded="true"] .person-title-chevron {
  transform: rotate(180deg);
  color: var(--text-main);
  opacity: 1;
}

.person-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.28);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  z-index: 120;
}

.person-dropdown-add {
  margin-top: 3px;
  padding-top: 9px !important;
  border-top: 1px solid var(--border-light) !important;
  color: var(--green-accent) !important;
  font-weight: 800 !important;
}

.person-add-plus-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--green-accent);
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.admin-page-view {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 32px;
}

.admin-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  box-shadow: var(--shadow-soft);
}

.admin-card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.admin-card-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0 0 12px 0;
}

.admin-card-header-row .admin-card-title {
  margin-bottom: 0;
}

.admin-pw-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  margin-left: 8px;
}

.admin-pw-badge.is-open {
  background: var(--green-badge-bg);
  color: var(--green-badge-text);
  border: 1px solid var(--green-border);
}

.admin-pw-badge.is-locked {
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

[data-theme="dark"] .admin-pw-badge.is-locked {
  color: #fbbf24;
}

.person-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.person-dropdown-item:hover {
  background: var(--bg-subtle);
}

.person-dropdown-item.active {
  background: var(--green-badge-bg);
  color: var(--green-badge-text);
}

.person-dropdown-item-left {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.person-dropdown-check {
  font-size: 0.88rem;
  font-weight: 800;
  opacity: 0.9;
}

.btn-add-plus {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--green-accent);
  color: #ffffff;
  border: none;
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(22, 163, 74, 0.25);
  transition: transform 0.12s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  flex-shrink: 0;
}

.btn-add-plus:hover {
  background: var(--green-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(22, 163, 74, 0.34);
}

.btn-add-plus:active {
  transform: scale(0.95);
}

.btn-add-plus::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(var(--tip-y, 82%) + 12px);
  bottom: auto;
  right: 0;
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  border: 1px solid var(--tooltip-border);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-3px);
  transition: opacity 0.14s ease, transform 0.14s ease;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.26);
  z-index: 80;
}

.btn-add-plus:hover::after,
.btn-add-plus:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

/* Household Person Bar */
.person-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
}

.person-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.person-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.person-pill:hover {
  border-color: var(--border-input);
  color: var(--text-main);
}

.person-pill.active {
  background: var(--green-badge-bg);
  border-color: var(--green-border);
  color: var(--green-badge-text);
  font-weight: 700;
}

.person-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green-accent);
}

/* Sections */
.section-block {
  margin-bottom: 32px;
}

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 0 2px;
}

.section-title-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.section-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  flex-shrink: 0;
}

.section-title {
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.015em;
}

.section-count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(var(--person-rgb), 0.14);
  border: 1px solid rgba(var(--person-rgb), 0.28);
  color: var(--text-main);
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1;
}

.section-heading-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Segmented View Switcher (Tiles vs List) */
.view-mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border-input);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
}

.view-mode-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.view-mode-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.view-mode-btn:hover {
  color: var(--text-main);
}

.view-mode-btn.active {
  background: var(--text-main);
  color: var(--text-inverse);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
}

.view-mode-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(var(--tip-y, 85%) + 11px);
  bottom: auto;
  left: var(--tip-x, 50%);
  transform: translateX(-50%) translateY(-3px);
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  border: 1px solid var(--tooltip-border);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 7px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.26);
  z-index: 80;
}

.view-mode-btn:hover::after,
.view-mode-btn:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.btn-multiselect-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-input);
  background: var(--bg-card);
  color: var(--text-secondary);
  border-radius: 50%;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.multiselect-toggle-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.btn-multiselect-toggle:hover {
  border-color: #2563eb;
  color: #2563eb;
}

.btn-multiselect-toggle.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.btn-multiselect-toggle::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(var(--tip-y, 82%) + 12px);
  bottom: auto;
  left: var(--tip-x, 50%);
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  border: 1px solid var(--tooltip-border);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 7px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-3px);
  transition: opacity 0.14s ease, transform 0.14s ease;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.26);
  z-index: 80;
}

.btn-multiselect-toggle:hover::after,
.btn-multiselect-toggle:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

body.has-multiselect-dock {
  padding-bottom: 92px;
}

.multiselect-dock {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: min(620px, calc(100vw - 24px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1.5px solid #2563eb;
  border-radius: 999px;
  padding: 10px 14px;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.28);
  z-index: 88;
}

.multiselect-dock-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.multiselect-selectall-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-input);
  color: var(--text-main);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.multiselect-selectall-pill:hover {
  border-color: #2563eb;
}

.multiselect-selectall-check {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.8px solid var(--border-input);
  background: var(--bg-card);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.multiselect-selectall-pill.is-all-selected .multiselect-selectall-check {
  background: #2563eb;
  border-color: #2563eb;
}

.multiselect-count {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.multiselect-dock-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.btn-multiselect-action {
  padding: 8px 15px;
  font-size: 0.82rem;
  border-radius: 999px;
}

.btn-multiselect-action:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-multiselect-done {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 0.86rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.btn-multiselect-done:hover {
  background: var(--border-light);
  color: var(--text-main);
}

.med-card.is-multiselect {
  cursor: pointer;
  user-select: none;
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}

.med-card.is-multiselect:active {
  transform: scale(0.99);
}

.med-card.is-multiselect.is-selected {
  box-shadow: 0 0 0 2.5px #2563eb, var(--shadow-md);
}

.med-select-checkbox {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border-input);
  background: var(--bg-card);
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.med-select-checkbox.checked {
  background: #2563eb;
  border-color: #2563eb;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

.multiselect-dose-pill {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 700;
}

.modal-bullet-list {
  margin: 8px 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dose-given-bullet-list {
  margin: 4px 0 0;
  padding-left: 18px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-main);
}

.log-dose-summary-row.is-batch-doses .log-dose-current {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
}

.sync-footer-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 8px;
  margin: -18px 0 10px;
}

.btn-history-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-history-icon:hover,
.btn-history-icon.active {
  background: var(--bg-card);
  border-color: var(--border-light);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.btn-history-icon svg {
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.btn-history-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(var(--tip-y, 82%) + 11px);
  bottom: auto;
  right: 0;
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  border: 1px solid var(--tooltip-border);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 7px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-3px);
  transition: opacity 0.14s ease, transform 0.14s ease;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.26);
  z-index: 80;
}

.btn-history-icon:hover::after,
.btn-history-icon:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green-accent);
}

.sync-indicator.offline .sync-dot {
  background: #f59e0b;
}

.sync-indicator.syncing .sync-dot {
  background: var(--text-muted);
  animation: pulseDot 1.1s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

/* Responsive 1-Column -> 2-Column Medications Layout with Vertical In-Place Expansion */
.meds-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

@media (min-width: 700px) {
  .meds-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }
}

.med-card {
  position: relative;
  border-radius: 18px;
  padding: 15px 17px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-light);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    var(--shadow-card);
  transition:
    box-shadow 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease;
}

[data-theme="dark"] .med-card {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    var(--shadow-card);
}

.med-card.is-expanded {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    0 12px 28px -10px rgba(15, 23, 42, 0.14),
    0 3px 8px rgba(15, 23, 42, 0.05);
}

[data-theme="dark"] .med-card.is-expanded {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.09),
    0 14px 32px -10px rgba(0, 0, 0, 0.5);
}

/* NEUTRAL CARD: Checking / Syncing */
.med-card.is-syncing {
  background: var(--bg-card);
  border: 1.5px solid var(--border-light);
}

/* GREEN CARD: Clear / Ready to Take */
.med-card.is-green {
  background:
    radial-gradient(115% 130% at 0% 0%, rgba(34, 197, 94, 0.25) 0%, rgba(16, 185, 129, 0.08) 50%, transparent 74%),
    radial-gradient(95% 115% at 100% 100%, rgba(16, 185, 129, 0.22) 0%, transparent 65%),
    linear-gradient(145deg, #ecfdf3 0%, #d1fae5 52%, #dcfce7 100%);
  border: 1.5px solid #34d399;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 8px 22px -6px rgba(22, 163, 74, 0.18),
    0 2px 6px rgba(15, 23, 42, 0.04);
}

[data-theme="dark"] .med-card.is-green {
  background:
    radial-gradient(115% 130% at 0% 0%, rgba(34, 197, 94, 0.3) 0%, transparent 62%),
    radial-gradient(95% 115% at 100% 100%, rgba(16, 185, 129, 0.24) 0%, transparent 62%),
    linear-gradient(145deg, #132e22 0%, #0e241b 52%, #122b20 100%);
  border-color: #10b981;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 10px 26px -6px rgba(0, 0, 0, 0.45);
}

/* OVERDUE CARD: > 1 Hour Past Scheduled Time */
.med-card.is-green.is-overdue {
  background:
    radial-gradient(115% 130% at 0% 0%, rgba(234, 179, 8, 0.26) 0%, transparent 62%),
    radial-gradient(95% 115% at 100% 100%, rgba(34, 197, 94, 0.2) 0%, transparent 65%),
    linear-gradient(145deg, #fefce8 0%, #fef3c7 48%, #d1fae5 100%);
  border: 2px solid #eab308;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 8px 22px -6px rgba(202, 138, 4, 0.2),
    0 2px 6px rgba(15, 23, 42, 0.04);
}

[data-theme="dark"] .med-card.is-green.is-overdue {
  background:
    radial-gradient(115% 130% at 0% 0%, rgba(250, 204, 21, 0.26) 0%, transparent 60%),
    radial-gradient(95% 115% at 100% 100%, rgba(16, 185, 129, 0.22) 0%, transparent 62%),
    linear-gradient(145deg, #282814 0%, #17271f 100%);
  border-color: #eab308;
}

/* RED CARD: Cooldown / Waiting */
.med-card.is-red {
  background:
    radial-gradient(115% 130% at 0% 0%, rgba(244, 63, 94, 0.22) 0%, rgba(251, 113, 133, 0.08) 50%, transparent 74%),
    radial-gradient(95% 115% at 100% 100%, rgba(249, 115, 22, 0.19) 0%, transparent 65%),
    linear-gradient(145deg, #fff1f3 0%, #ffe4e8 50%, #ffedd5 100%);
  border: 1.5px solid #fb7185;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 8px 22px -6px rgba(225, 29, 72, 0.16),
    0 2px 6px rgba(15, 23, 42, 0.04);
}

[data-theme="dark"] .med-card.is-red {
  background:
    radial-gradient(115% 130% at 0% 0%, rgba(244, 63, 94, 0.28) 0%, transparent 62%),
    radial-gradient(95% 115% at 100% 100%, rgba(249, 115, 22, 0.22) 0%, transparent 62%),
    linear-gradient(145deg, #2e161f 0%, #231118 52%, #2a1619 100%);
  border-color: #f43f5e;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 10px 26px -6px rgba(0, 0, 0, 0.45);
}

/* Top Header Row inside Each Card */
.med-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.med-head-main {
  min-width: 0;
  flex: 1;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.med-title {
  font-size: 1.16rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

/* Quiet Single-Line Subtitle with Tiny Schedule Icon */
.med-subline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 0.81rem;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.35;
}

.med-sub-cadence {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  font-weight: 600;
}

.med-sub-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  opacity: 0.72;
}

.med-sub-dot {
  opacity: 0.5;
}

.med-sub-dose {
  color: var(--text-main);
  font-weight: 700;
}

.med-sub-type {
  color: var(--text-secondary);
}

.med-sub-type.is-req {
  color: var(--text-main);
  font-weight: 700;
}

.med-tile-tools {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.med-card-gear {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.med-card-gear:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-glass);
  color: var(--text-main);
}

.med-card-gear svg {
  width: 14px;
  height: 14px;
  pointer-events: none;
}

/* Bottom Status & Action Row */
.med-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 2px;
}

.med-time-left {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  flex: 1;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
}

.med-time-left [data-role="time-left-text"] {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.32;
  min-width: 0;
}

.compact-status-main {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-main);
}

.compact-status-main.is-ready {
  color: var(--green-badge-text);
}

.compact-status-main.is-overdue {
  color: #b45309;
  font-weight: 800;
}

[data-theme="dark"] .compact-status-main.is-overdue {
  color: #facc15;
}

.compact-status-main.is-wait {
  color: var(--red-badge-text);
}

.compact-status-sub {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.is-syncing .med-time-left {
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  margin-top: 5px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
}

.is-syncing .status-dot {
  background: var(--text-muted);
  animation: pulseDot 1.1s infinite ease-in-out;
}

.is-green .status-dot {
  background: var(--green-accent);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.med-card.is-green.is-overdue .status-dot {
  background: #eab308;
  box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.22);
}

[data-theme="dark"] .med-card.is-green.is-overdue .status-dot {
  background: #facc15;
}

.is-red .status-dot {
  background: var(--red-accent);
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.16);
}

.btn-clear-overdue {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  border: none;
  background: rgba(234, 179, 8, 0.15);
  color: #b45309;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.12s ease, color 0.15s ease;
  flex-shrink: 0;
}

[data-theme="dark"] .btn-clear-overdue {
  background: rgba(250, 204, 21, 0.18);
  color: #facc15;
}

.btn-clear-overdue:hover {
  background: rgba(234, 179, 8, 0.28);
  color: #854d0e;
}

[data-theme="dark"] .btn-clear-overdue:hover {
  background: rgba(250, 204, 21, 0.28);
  color: #fde047;
}

.btn-clear-overdue svg {
  width: 15px;
  height: 15px;
  pointer-events: none;
}

.btn-clear-overdue::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(var(--tip-y, 85%) + 10px);
  bottom: auto;
  right: 0;
  transform: translateY(-3px);
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  border: 1px solid var(--tooltip-border);
  font-size: 0.73rem;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 7px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.26);
  z-index: 80;
}

.btn-clear-overdue:hover::after,
.btn-clear-overdue:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

/* Primary Log Dose Action Area */
.med-compact-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-log-compact {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  padding: 8px 15px;
  font-size: 0.86rem;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.1s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn-log-compact:active {
  transform: scale(0.97);
}

.is-syncing .btn-log-compact {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-light);
}

.is-green .btn-log-compact {
  background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
  color: #ffffff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 3px 10px rgba(22, 163, 74, 0.28);
}

.is-green .btn-log-compact:hover {
  background: linear-gradient(180deg, #16a34a 0%, #15803d 100%);
}

.is-red .btn-log-compact {
  background: linear-gradient(180deg, #f97316 0%, #ea580c 100%);
  color: #ffffff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 3px 10px rgba(234, 88, 12, 0.26);
}

.is-red .btn-log-compact:hover {
  background: linear-gradient(180deg, #ea580c 0%, #c2410c 100%);
}

.btn-expand-toggle {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  padding: 0;
}

.btn-expand-toggle:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-glass);
  color: var(--text-main);
}

.btn-expand-toggle svg {
  width: 15px;
  height: 15px;
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.med-card.is-expanded .btn-expand-toggle svg {
  transform: rotate(180deg);
}

/* Smooth Progress Bar when Red / Waiting */
.compact-wait-bar-track {
  width: 100%;
  height: 4px;
  background: rgba(225, 29, 72, 0.14);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 2px;
}

.compact-wait-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #fb7185 0%, var(--red-accent) 100%);
  border-radius: 999px;
  transition: width 0.5s linear;
}

/* Vertical In-Place Expandable Details Drawer */
.med-details-drawer {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  pointer-events: none;
  transition:
    grid-template-rows 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.18s ease;
}

.med-card.is-expanded .med-details-drawer {
  grid-template-rows: 1fr;
  opacity: 1;
  pointer-events: auto;
}

.med-details-drawer-inner {
  overflow: hidden;
  min-height: 0;
  margin-top: 0;
  padding-top: 0;
  border-top: 1px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition:
    margin-top 0.2s cubic-bezier(0.22, 1, 0.36, 1),
    padding-top 0.2s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.18s ease;
}

.med-card.is-expanded .med-details-drawer-inner {
  margin-top: 4px;
  padding-top: 12px;
  border-top-color: var(--border-glass);
}

/* Notes Banner inside Expanded Drawer */
.med-notes-banner {
  padding: 8px 11px;
  border-radius: 10px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.4;
}

.med-notes-banner strong {
  color: var(--text-main);
}

/* Simple Vertical Schedule & Timing Lines */
.med-timing-lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.med-timing-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px;
}

.med-timing-line strong {
  color: var(--text-main);
  font-weight: 700;
}

.med-timing-line .timing-reg {
  color: var(--text-secondary);
  font-weight: 500;
}

/* Recent Doses List inside Expanded Drawer */
.med-drawer-doses {
  padding-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.med-drawer-doses-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.med-drawer-doses-label {
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.btn-show-all-doses {
  background: transparent;
  border: none;
  padding: 2px 4px;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.14s ease, background-color 0.14s ease;
}

.btn-show-all-doses:hover {
  color: var(--text-main);
  background: var(--bg-glass);
}

.med-dose-event-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 0.83rem;
}

.med-dose-event-info {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px;
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.35;
}

.dose-time-text {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.79rem;
}

.med-dose-event-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.btn-dose-mini {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.74rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.14s ease;
}

.btn-dose-mini:hover {
  border-color: var(--border-input);
  color: var(--text-main);
}

.btn-dose-mini.danger {
  color: var(--red-badge-text);
  border-color: var(--red-border);
}

.med-drawer-empty-doses {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

.log-dose-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 9px 12px;
}

.log-dose-current {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.log-dose-label {
  font-weight: 600;
}

.log-dose-badge {
  color: var(--text-main);
  font-weight: 800;
}

.btn-change-dose {
  background: var(--bg-card);
  border: 1px solid var(--border-input);
  color: var(--text-main);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-change-dose:hover,
.btn-change-dose.active {
  background: var(--text-main);
  color: var(--text-inverse);
  border-color: var(--text-main);
}

.log-dose-picker-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
}

.card-dose-picker-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.chip-divider-dot {
  color: var(--text-muted);
  font-weight: 700;
  padding: 0 2px;
  user-select: none;
}

.btn-enter-time {
  background: var(--bg-glass);
  color: var(--text-main);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 0.84rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease;
}

.btn-enter-time:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-input);
}

/* Optional Quick Amount Pills inside Expanded Drawer */
.card-optional-amounts {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.amount-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-right: 2px;
}

.pill-amount {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.12s ease;
}

.pill-amount:hover {
  background: var(--bg-glass-hover);
  color: var(--text-main);
}

.pill-amount.selected {
  background: var(--text-main);
  border-color: var(--text-main);
  color: var(--text-inverse);
}

/* Empty State with Quick-Add Template Picker */
.empty-card {
  background: var(--bg-card);
  border: 1.5px dashed var(--border-input);
  border-radius: var(--radius-xl);
  padding: 28px 22px;
  text-align: center;
}

.empty-title {
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.empty-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.empty-quick-row {
  display: flex;
  gap: 8px;
  max-width: 440px;
  margin: 0 auto 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.empty-select {
  flex: 1;
  min-width: 220px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-subtle);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-main);
}

/* Collapsible History Section */
.history-collapsible {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.history-accordion-header {
  width: 100%;
  background: transparent;
  border: none;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background-color 0.15s ease;
}

.history-accordion-header:hover {
  background: var(--bg-subtle);
}

.history-accordion-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.history-accordion-chevron {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.history-accordion-chevron svg {
  width: 18px;
  height: 18px;
  transition: transform 0.2s ease;
}

.history-collapsible.is-open .history-accordion-chevron svg {
  transform: rotate(180deg);
}

.history-drawer {
  padding: 0 20px 18px;
  border-top: 1px solid var(--border-light);
}

.history-drawer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
}

/* History List */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Locked / Auth Screen (Always Light Mode, Trakker Green Background) */
body.is-auth-screen {
  --bg-page: #16a34a;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-elevated: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.85);
  --bg-glass-hover: #ffffff;
  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;
  --border-light: #e2e8f0;
  --border-input: #cbd5e1;
  --border-glass: rgba(15, 23, 42, 0.12);
  --green-surface: #f0fdf4;
  --green-border: #86efac;
  --green-accent: #16a34a;
  --green-accent-hover: #15803d;
  --green-badge-bg: #dcfce7;
  --green-badge-text: #166534;
  --red-surface: #fff1f2;
  --red-border: #fda4af;
  --red-accent: #e11d48;
  --red-badge-bg: #ffe4e6;
  --red-badge-text: #9f1239;
  background-color: #16a34a !important;
  color: #0f172a;
  color-scheme: light;
}

.locked-card {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: var(--radius-xl);
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 18px 44px rgba(10, 46, 22, 0.24);
  margin: 24px auto;
}

.auth-card-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin-bottom: 4px;
}

.auth-brand-logo {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
}

.auth-brand-text-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  font-family: "Outfit", "Plus Jakarta Sans", sans-serif;
}

.auth-brand-title {
  display: inline-flex;
  align-items: center;
  font-size: 1.45rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.025em;
  line-height: 1;
}

.auth-brand-green {
  color: #16a34a;
}

.auth-brand-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  margin-left: 3px;
  margin-bottom: 10px;
}

.auth-brand-tagline {
  font-size: 0.75rem;
  font-weight: 500;
  color: #64748b;
  line-height: 1;
  margin-top: -1px;
}

.locked-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 6px;
}

.locked-desc {
  font-size: 0.9rem;
  color: #64748b;
  margin-bottom: 16px;
}

.unlock-form {
  display: flex;
  gap: 8px;
  max-width: 340px;
  margin: 0 auto;
}

.unlock-form input {
  flex: 1;
  border: 1px solid var(--border-input);
  background: var(--bg-elevated);
  color: var(--text-main);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.92rem;
}

.unlock-error {
  color: var(--red-badge-text);
  font-size: 0.84rem;
  font-weight: 600;
  margin-top: 8px;
}

/* Person Picker Screen (shown at / or /<family> when no /<person> is in the URL) */
.person-picker-card {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 36px 26px 28px;
  text-align: center;
  box-shadow: var(--shadow-soft);
  margin: 24px auto;
}

.person-picker-brand {
  gap: 4px;
  margin-bottom: 8px;
}

.verifying-graphic-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 42px 24px;
  text-align: center;
  box-shadow: var(--shadow-soft);
  margin: 24px auto;
}

.general-light-graphic-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 12px;
}

.general-light-graphic-svg {
  width: 210px;
  height: 140px;
  display: block;
}

.general-light-graphic-caption {
  font-family: var(--font-sub);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
}

.person-picker-logo {
  width: 68px;
  height: 68px;
}

.person-picker-brand-title {
  font-size: 1.85rem;
  color: var(--text-main);
}

.person-picker-brand-title .auth-brand-dot {
  width: 9px;
  height: 9px;
  margin-bottom: 13px;
}

.person-picker-brand-tagline {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.person-picker-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 20px;
}

.person-picker-family-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--green-badge-bg);
  color: var(--green-badge-text);
  border: 1px solid var(--green-border);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.person-picker-title {
  font-size: 1.38rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0;
}

.person-picker-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
}

.person-picker-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 440px;
  margin: 0 auto;
  text-align: left;
}

.person-picker-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 18px;
  border-radius: 18px;
  background:
    radial-gradient(120% 130% at 0% 0%, rgba(var(--picker-person-rgb, 14, 165, 233), 0.14) 0%, transparent 60%),
    var(--bg-subtle);
  border: 1.5px solid rgba(var(--picker-person-rgb, 14, 165, 233), 0.28);
  color: var(--text-main);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.person-picker-item:hover {
  border-color: var(--picker-person-accent, var(--green-accent));
  background:
    radial-gradient(120% 130% at 0% 0%, rgba(var(--picker-person-rgb, 14, 165, 233), 0.2) 0%, transparent 60%),
    var(--bg-card);
  box-shadow: 0 8px 24px -4px rgba(var(--picker-person-rgb, 14, 165, 233), 0.22);
  transform: translateY(-2px);
}

.person-picker-item:active {
  transform: scale(0.99);
}

.person-picker-item-left {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.person-picker-avatar {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
  flex-shrink: 0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 4px 12px rgba(15, 23, 42, 0.16);
}

.person-picker-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.person-picker-name {
  font-family: var(--font-heading);
  font-size: 1.18rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.person-picker-meta {
  font-family: var(--font-sub);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.picker-stat-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
}

.picker-stat-tag.is-ready {
  background: var(--green-badge-bg);
  border-color: var(--green-border);
  color: var(--green-badge-text);
}

.picker-stat-tag.is-overdue {
  background: rgba(234, 179, 8, 0.16);
  border-color: rgba(234, 179, 8, 0.45);
  color: #a16207;
}

[data-theme="dark"] .picker-stat-tag.is-overdue {
  background: rgba(250, 204, 21, 0.18);
  border-color: rgba(250, 204, 21, 0.4);
  color: #fde047;
}

.picker-stat-tag.is-waiting {
  background: var(--red-badge-bg);
  border-color: var(--red-border);
  color: var(--red-badge-text);
}

.person-picker-ready-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green-accent);
  display: inline-block;
  flex-shrink: 0;
}

.person-picker-arrow {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 800;
  flex-shrink: 0;
  transition: transform 0.15s ease, background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.person-picker-item:hover .person-picker-arrow {
  background: var(--green-accent);
  border-color: var(--green-accent);
  color: #ffffff;
  transform: translateX(2px);
}

.person-picker-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

/* Modal Tabs */
.modal-tabs {
  display: flex;
  gap: 6px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.26);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.modal-tab {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-tab.active {
  background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.25);
}

.modal-tab.modal-tab-icon {
  flex: 0 0 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 6px;
  color: #15803d;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

[data-theme="dark"] .modal-tab.modal-tab-icon {
  color: #4ade80;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(34, 197, 94, 0.35);
}

.modal-tab.modal-tab-icon:hover {
  background: #dcfce7;
  color: #166534;
}

[data-theme="dark"] .modal-tab.modal-tab-icon:hover {
  background: rgba(34, 197, 94, 0.2);
}

.default-login-person-box {
  background: linear-gradient(145deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1.5px solid #86efac;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 4px;
}

[data-theme="dark"] .default-login-person-box {
  background: linear-gradient(145deg, #132a20 0%, #0f221a 100%);
  border-color: #256348;
}

.modal-tab.modal-tab-icon svg {
  width: 17px;
  height: 17px;
}

.modal-tab.modal-tab-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(var(--tip-y, 82%) + 11px);
  bottom: auto;
  right: 0;
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  border: 1px solid var(--tooltip-border);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 7px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-3px);
  transition: opacity 0.14s ease, transform 0.14s ease;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.26);
  z-index: 80;
}

.modal-tab.modal-tab-icon:hover::after,
.modal-tab.modal-tab-icon:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text-main);
}

/* Family Members Management inside Family Modal */
.family-members-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.family-members-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.section-sub-label {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-main);
}

.family-members-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.member-manage-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 11px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
}

.member-manage-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: nowrap;
}

.member-manage-name {
  font-weight: 700;
  font-size: 0.96rem;
  color: var(--text-main);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-manage-pills-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.user-opens-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

[data-theme="dark"] .user-opens-pill {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.4);
}

.member-manage-url-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  min-width: 0;
  width: 100%;
}

.member-manage-url {
  display: inline-flex;
  align-items: baseline;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.member-manage-url .url-head {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex-shrink: 1;
}

.member-manage-url .url-tail {
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-copy-url-icon {
  position: relative;
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  border-radius: 5px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s ease, background 0.15s ease;
}

.btn-copy-url-icon svg {
  width: 14px;
  height: 14px;
}

.btn-copy-url-icon:hover {
  color: var(--text-main);
  background: var(--bg-glass-hover);
}

.btn-copy-url-icon.is-copied {
  color: var(--green-accent);
}

.btn-copy-url-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(var(--tip-y, 82%) + 10px);
  bottom: auto;
  left: var(--tip-x, 50%);
  transform: translate(-50%, -3px);
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  border: 1px solid var(--tooltip-border);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.26);
  z-index: 80;
}

.btn-copy-url-icon:hover::after,
.btn-copy-url-icon:focus-visible::after,
.btn-copy-url-icon.is-copied::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.member-bg-picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.member-bg-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.member-bg-swatches {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.bg-swatch-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border-input);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.bg-swatch-btn:hover {
  transform: scale(1.1);
}

.bg-swatch-btn.active {
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--text-main);
  transform: scale(1.08);
}

.bg-swatch-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.bg-swatch-custom {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px dashed var(--border-input);
  background: var(--bg-card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  cursor: pointer;
}

.bg-swatch-custom.active {
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--text-main);
}

.bg-swatch-custom input[type="color"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  border: none;
}

.member-manage-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-member-action {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #15803d;
  border-radius: 8px;
  padding: 5px 11px;
  font-size: 0.76rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.12s ease;
}

[data-theme="dark"] .btn-member-action {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.38);
  color: #86efac;
}

.btn-member-action:hover {
  background: #dcfce7;
  border-color: #4ade80;
  color: #166534;
}

[data-theme="dark"] .btn-member-action:hover {
  background: rgba(34, 197, 94, 0.25);
  color: #bbf7d0;
}

.btn-member-action.danger {
  background: var(--bg-card);
  color: var(--red-badge-text);
  border-color: var(--red-border);
}

.btn-member-action.danger:hover {
  background: var(--red-surface);
}

.add-member-inline-form {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.add-member-inline-form input {
  flex: 1;
  border: 1px solid var(--border-input);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--text-main);
}

.btn-add-member {
  white-space: nowrap;
  padding: 9px 14px;
}

.btn-secondary.btn-add-member {
  background: #f0fdf4;
  border-color: #86efac;
  color: #15803d;
  font-weight: 700;
}

[data-theme="dark"] .btn-secondary.btn-add-member {
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.36);
  color: #86efac;
}

.btn-secondary.btn-add-member:hover {
  background: #dcfce7;
  border-color: #4ade80;
  color: #166534;
}

.modal-divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 4px 0;
}

.invite-success-box {
  background: var(--green-surface);
  border: 1px solid var(--green-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.invite-success-title {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--green-badge-text);
  margin-bottom: 4px;
}

.invited-families-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

/* Help Modal Guide */
.help-modal-sheet {
  max-width: 620px;
}

.help-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.help-intro {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  color: var(--text-main);
}

.help-visual-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.help-visual-header {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-main);
}

.help-diagram-svg {
  width: 100%;
  height: auto;
  display: block;
  font-family: inherit;
}

.help-svg-med-card {
  fill: var(--bg-card);
  stroke: var(--border-input);
  stroke-width: 1.5;
}

.help-svg-icon-circle {
  fill: var(--bg-subtle);
}

.help-svg-toolbar-pill {
  fill: var(--bg-subtle);
}

.help-svg-fg {
  color: var(--text-main);
  fill: var(--text-main);
}

.help-svg-med-title {
  fill: var(--text-main);
  font-size: 16.5px;
  font-weight: 800;
}

.help-svg-person-title {
  fill: var(--text-main);
  font-size: 20px;
  font-weight: 800;
}

.help-svg-status-text {
  fill: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
}

.help-svg-callout-box {
  fill: var(--bg-card);
  stroke-width: 1.8;
}

.help-svg-callout-box.stroke-blue {
  stroke: #2563eb;
}

.help-svg-callout-box.stroke-green {
  stroke: #16a34a;
}

.help-svg-callout-box.stroke-amber {
  stroke: #d97706;
}

.help-svg-callout-box.stroke-purple {
  stroke: #7c3aed;
}

.help-svg-callout-title {
  font-size: 12.5px;
  font-weight: 800;
}

.help-svg-callout-title.fill-blue {
  fill: #2563eb;
}

.help-svg-callout-title.fill-green {
  fill: #16a34a;
}

.help-svg-callout-title.fill-amber {
  fill: #d97706;
}

.help-svg-callout-title.fill-purple {
  fill: #7c3aed;
}

.help-svg-callout-sub {
  fill: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
}

.help-status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@media (max-width: 500px) {
  .help-status-grid {
    grid-template-columns: 1fr;
  }
}

.help-status-pill {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--border-light);
  background: var(--bg-subtle);
  font-size: 0.8rem;
}

.help-status-pill strong {
  color: var(--text-main);
  font-size: 0.84rem;
}

.help-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.help-section h4 {
  font-size: 0.94rem;
  font-weight: 800;
  color: var(--text-main);
}

.help-section ul {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.help-section code {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 0.8rem;
  color: var(--text-main);
}

.history-row {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.history-med {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
}

.history-dose-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 600;
}

.history-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.history-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-subtle {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.btn-subtle:hover {
  border-color: var(--border-input);
  color: var(--text-main);
}

/* Floating Post-Log Toast */
.toast-card {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: min(470px, calc(100vw - 24px));
  background: var(--bg-card);
  border: 1.5px solid var(--green-border);
  border-radius: 16px;
  padding: 10px 14px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
  z-index: 90;
}

.toast-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: nowrap;
}

.toast-message {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.toast-text-col {
  min-width: 0;
}

.toast-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--green-badge-bg);
  color: var(--green-badge-text);
  font-weight: 800;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.toast-title {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--text-main);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast-subtitle {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast-buttons {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: nowrap;
}

.btn-toast-close {
  margin-left: 2px;
}

.btn-toast-action {
  background: var(--bg-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-light);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.76rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.12s ease;
}

.btn-toast-action:hover,
.btn-toast-action.active {
  background: var(--text-main);
  color: var(--text-inverse);
  border-color: var(--text-main);
}

.toast-time-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}

.toast-dt-input {
  width: auto;
  min-width: 195px;
}

/* 12-Hour Time Entry Box (Separate Hour, Min, Yellow/Blue AM/PM Toggle) */
.time-12h-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  transition: opacity 0.15s ease, filter 0.15s ease;
}

.time-12h-bar.is-disabled {
  opacity: 0.38;
  filter: grayscale(0.75);
  pointer-events: none;
}

.schedule-style-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  padding: 3px;
  height: 44px;
  align-items: stretch;
}

.sched-toggle-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0 8px;
  transition: all 0.15s ease;
}

.sched-toggle-btn.active {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.28);
}

.interval-entry-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.interval-entry-row input {
  flex: 1;
  min-width: 0;
}

.interval-unit-toggle {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
  flex-shrink: 0;
}

.unit-toggle-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.unit-toggle-btn:hover {
  color: var(--text-main);
}

.unit-toggle-btn.active {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.28);
}

.time-12h-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.time-12h-box {
  width: 58px !important;
  text-align: center;
  font-weight: 800;
  font-size: 1rem !important;
  padding: 8px 6px !important;
  border-radius: var(--radius-md);
}

.time-12h-box-sm {
  width: 48px !important;
  font-size: 0.88rem !important;
  padding: 5px 4px !important;
}

.time-12h-sep {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text-secondary);
  user-select: none;
}

.btn-ampm-toggle {
  min-width: 56px;
  height: 40px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-ampm-toggle.btn-ampm-sm {
  min-width: 48px;
  height: 32px;
  font-size: 0.78rem;
  padding: 0 10px;
}

/* AM = Yellow */
.btn-ampm-toggle.is-am {
  background: #facc15;
  color: #422006;
  border: 1.5px solid #ca8a04;
  box-shadow: 0 2px 6px rgba(234, 179, 8, 0.24);
}

.btn-ampm-toggle.is-am:hover {
  background: #fde047;
}

/* PM = Blue */
.btn-ampm-toggle.is-pm {
  background: #2563eb;
  color: #ffffff;
  border: 1.5px solid #1d4ed8;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.28);
}

.btn-ampm-toggle.is-pm:hover {
  background: #1d4ed8;
}

.date-picker-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 145px;
}

.time-12h-date {
  width: 100% !important;
  flex: 1;
  min-width: 145px;
}

.date-today-label {
  display: none;
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-elevated);
  color: var(--text-main);
  font-size: 0.92rem;
  font-weight: 600;
  padding-right: 24px;
  pointer-events: none;
  line-height: 1.2;
}

.date-picker-wrap.is-today .date-today-label {
  display: inline-block;
}

.date-picker-wrap.is-today .time-12h-date::-webkit-datetime-edit,
.date-picker-wrap.is-today .time-12h-date::-webkit-datetime-edit-fields-wrapper,
.date-picker-wrap.is-today .time-12h-date::-webkit-datetime-edit-text,
.date-picker-wrap.is-today .time-12h-date::-webkit-datetime-edit-month-field,
.date-picker-wrap.is-today .time-12h-date::-webkit-datetime-edit-day-field,
.date-picker-wrap.is-today .time-12h-date::-webkit-datetime-edit-year-field {
  color: transparent;
  -webkit-text-fill-color: transparent;
  opacity: 0;
}

.fixed-times-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 6px;
}

.fixed-time-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 8px 10px;
}

.btn-add-fixed-time {
  align-self: flex-start;
}

.fixed-days-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.day-pill {
  flex: 1 1 42px;
  background: var(--bg-subtle);
  border: 1.5px solid var(--border-input);
  color: var(--text-secondary);
  border-radius: 10px;
  padding: 7px 6px;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: all 0.14s ease;
  user-select: none;
}

.day-pill:hover {
  border-color: var(--text-secondary);
  color: var(--text-main);
}

.day-pill.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.28);
}

.dose-entry-main-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dose-entry-main-row input {
  flex: 1;
}

.btn-add-dose-plus {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: #2563eb;
  color: #ffffff;
  border: none;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28);
  transition: background 0.15s ease, transform 0.12s ease;
}

.btn-add-dose-plus:hover {
  background: #1d4ed8;
  transform: scale(1.04);
}

.extra-doses-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.extra-dose-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.extra-dose-row input {
  flex: 1;
}

.btn-remove-extra-dose {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.btn-remove-extra-dose:hover {
  background: var(--red-badge-bg);
  color: var(--red-badge-text);
  border-color: var(--red-border);
}

/* Themed Orange Early-Dose Confirm Modal */
.modal-sheet-orange {
  background: var(--orange-surface);
  border: 2px solid var(--orange-border);
}

.orange-modal-title {
  color: var(--orange-badge-text) !important;
}

.orange-confirm-body {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--orange-badge-text);
  background: var(--orange-badge-bg);
  border: 1px solid var(--orange-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 12px;
  line-height: 1.45;
}

.btn-orange {
  background: var(--orange-accent);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(234, 88, 12, 0.25);
}

.btn-orange:hover {
  background: var(--orange-accent-hover);
}

.warning-callout.is-orange {
  background: var(--orange-surface);
  border-color: var(--orange-border);
  color: var(--orange-badge-text);
}

.btn-undo {
  background: var(--red-badge-bg);
  color: var(--red-badge-text);
  border: none;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.btn-close-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 6px;
}

.btn-close-icon:hover {
  color: var(--text-main);
}

.toast-amount-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}

.toast-quick-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.toast-amount-form {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.input-sm {
  border: 1px solid var(--border-light);
  background: var(--bg-subtle);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.8rem;
  font-family: inherit;
  color: var(--text-main);
  width: 175px;
}

.btn-save-sm {
  background: var(--text-main);
  color: var(--text-inverse);
  border: none;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-sheet {
  background:
    radial-gradient(120% 70% at 0% 0%, rgba(34, 197, 94, 0.14) 0%, rgba(16, 185, 129, 0.04) 48%, transparent 72%),
    radial-gradient(100% 60% at 100% 0%, rgba(16, 185, 129, 0.1) 0%, transparent 60%),
    var(--bg-card);
  border: 1.5px solid rgba(34, 197, 94, 0.42);
  color: var(--text-main);
  border-radius: var(--radius-xl);
  width: min(500px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  padding: 22px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 20px 50px rgba(0, 0, 0, 0.32);
}

[data-theme="dark"] .modal-sheet {
  background:
    radial-gradient(120% 70% at 0% 0%, rgba(34, 197, 94, 0.2) 0%, transparent 65%),
    var(--bg-card);
  border-color: rgba(34, 197, 94, 0.42);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 22px 54px rgba(0, 0, 0, 0.55);
}

.modal-sheet.modal-sheet-orange {
  background: var(--orange-surface);
  border: 2px solid var(--orange-border);
}

.modal-sheet.modal-sheet-danger {
  background: var(--bg-card);
  border: 2px solid var(--red-border);
}

.modal-sheet-sm {
  width: min(430px, 100%);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.med-name-entry-row {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.med-name-entry-row input {
  flex: 1;
  min-width: 0;
}

.btn-quickfill-dropdown {
  width: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-input);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: all 0.15s ease;
}

.btn-quickfill-dropdown svg {
  width: 17px;
  height: 17px;
  transition: transform 0.15s ease;
}

.btn-quickfill-dropdown:hover,
.btn-quickfill-dropdown.active {
  background: rgba(37, 99, 235, 0.12);
  border-color: #2563eb;
  color: #2563eb;
}

.btn-quickfill-dropdown.active svg {
  transform: rotate(180deg);
}

[data-theme="dark"] .btn-quickfill-dropdown:hover,
[data-theme="dark"] .btn-quickfill-dropdown.active {
  background: rgba(59, 130, 246, 0.22);
  border-color: #60a5fa;
  color: #93c5fd;
}

.quickfill-med-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 250px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.26);
  padding: 5px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quickfill-med-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-main);
  padding: 8px 10px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.86rem;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.quickfill-med-item:hover {
  background: rgba(37, 99, 235, 0.1);
}

[data-theme="dark"] .quickfill-med-item:hover {
  background: rgba(59, 130, 246, 0.2);
}

.quickfill-med-item-name {
  font-weight: 700;
}

.quickfill-med-item-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-field label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-main);
}

.form-field input,
.form-field select {
  border: 1px solid var(--border-input);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--text-main);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.68;
  font-weight: 400;
}

.field-label-with-help {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.help-tooltip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.btn-inline-help {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: 1px solid var(--border-input);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 800;
  font-family: inherit;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  padding: 0;
  transition: all 0.15s ease;
}

.help-tooltip-wrap:hover .btn-inline-help,
.help-tooltip-wrap:focus-within .btn-inline-help {
  background: rgba(37, 99, 235, 0.14);
  border-color: #2563eb;
  color: #2563eb;
}

[data-theme="dark"] .help-tooltip-wrap:hover .btn-inline-help,
[data-theme="dark"] .help-tooltip-wrap:focus-within .btn-inline-help {
  background: rgba(59, 130, 246, 0.22);
  border-color: #60a5fa;
  color: #93c5fd;
}

.help-tooltip-bubble {
  position: absolute;
  left: -40px;
  top: calc(100% + 8px);
  width: min(300px, 76vw);
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.77rem;
  font-weight: 400;
  line-height: 1.45;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.36);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
  z-index: 75;
}

.help-tooltip-wrap:hover .help-tooltip-bubble,
.help-tooltip-wrap:focus-within .help-tooltip-bubble {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

#med-modal .form-field input:focus,
#med-modal .form-field select:focus {
  outline: 2px solid #2563eb;
  border-color: transparent;
}

.btn-show-all-doses {
  margin-top: 4px;
  align-self: flex-start;
  border: 1px solid var(--border-glass);
  background: var(--bg-glass);
  color: var(--text-main);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.84rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-show-all-doses:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-input);
}

.med-all-doses-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 2px;
}

.form-field input:focus,
.form-field select:focus {
  outline: 2px solid var(--green-accent);
  border-color: transparent;
}

.field-hint {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.quick-time-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.chip-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.chip-btn.active {
  background: var(--text-main);
  color: var(--text-inverse);
  border-color: var(--text-main);
}

.warning-callout {
  background: var(--red-surface);
  border: 1px solid var(--red-border);
  color: var(--red-badge-text);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  font-weight: 600;
  margin-bottom: 14px;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}

.modal-actions-right {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.btn-primary {
  background: var(--green-accent);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.btn-primary:hover {
  background: var(--green-accent-hover);
}

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.btn-secondary:hover {
  border-color: var(--border-input);
  color: var(--text-main);
}

.btn-delete {
  background: var(--red-badge-bg);
  color: var(--red-badge-text);
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.modal-sheet-danger {
  border: 2px solid var(--red-border);
  box-shadow: 0 22px 54px rgba(220, 38, 38, 0.25);
}

.danger-modal-title {
  color: var(--red-badge-text) !important;
}

.btn-danger-solid {
  background: #dc2626;
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn-danger-solid:hover {
  background: #b91c1c;
}

.header-user-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.btn-header-text {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-header-text:hover {
  border-color: var(--border-input);
  color: var(--text-main);
}

.btn-link-subtle {
  background: transparent;
  border: none;
  color: #2563eb;
  font-size: 0.84rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 4px 8px;
  text-decoration: underline;
}

[data-theme="dark"] .btn-link-subtle {
  color: #60a5fa;
}

.auth-success-msg {
  background: var(--green-badge-bg);
  color: var(--green-badge-text);
  border: 1px solid var(--green-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 0.84rem;
  font-weight: 600;
  margin: 4px 0;
}

.share-link-warning-box {
  background: var(--orange-badge-bg);
  color: var(--orange-badge-text);
  border: 1px solid var(--orange-border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 0.8rem;
  line-height: 1.4;
  margin-top: 8px;
}

.med-requests-banner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.med-req-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--orange-surface);
  border: 1.5px solid var(--orange-border);
  border-radius: var(--radius-lg);
  padding: 11px 14px;
}

.med-req-info {
  font-size: 0.85rem;
  color: var(--text-main);
  line-height: 1.35;
}

.med-req-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.med-req-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-req-approve {
  background: var(--green-accent);
  color: #ffffff;
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.btn-req-approve:hover {
  background: var(--green-accent-hover);
}

.btn-req-reject {
  background: var(--red-badge-bg);
  color: var(--red-badge-text);
  border: 1px solid var(--red-border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.user-role-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  margin-left: 6px;
}

.user-role-badge.is-superuser {
  background: rgba(124, 58, 237, 0.16);
  color: #7c3aed;
  border: 1px solid rgba(124, 58, 237, 0.35);
}

[data-theme="dark"] .user-role-badge.is-superuser {
  color: #c4b5fd;
}

.user-role-badge.is-admin {
  background: rgba(37, 99, 235, 0.15);
  color: #2563eb;
  border: 1px solid rgba(37, 99, 235, 0.35);
}

[data-theme="dark"] .user-role-badge.is-admin {
  color: #93c5fd;
}

.user-role-badge.is-family,
.user-role-pill.role-family {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

.user-role-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  margin-left: 0;
}

.user-role-pill.role-superuser {
  background: rgba(124, 58, 237, 0.16);
  color: #7c3aed;
  border: 1px solid rgba(124, 58, 237, 0.35);
}

[data-theme="dark"] .user-role-pill.role-superuser {
  color: #c4b5fd;
}

.user-role-pill.role-admin {
  background: rgba(37, 99, 235, 0.15);
  color: #2563eb;
  border: 1px solid rgba(37, 99, 235, 0.35);
}

[data-theme="dark"] .user-role-pill.role-admin {
  color: #93c5fd;
}

/* Header Profile Icon & Dropdown Menu */
.profile-dropdown-wrap {
  position: relative;
  display: inline-flex;
}

.btn-profile-trigger {
  width: 30px;
  height: 30px;
}

.btn-profile-trigger svg {
  width: 16px;
  height: 16px;
}

.profile-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: auto;
  right: 0;
  min-width: 215px;
  background: var(--bg-card);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.22);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 60;
}

.profile-menu-account {
  padding: 7px 10px 8px;
  margin-bottom: 3px;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-menu-item {
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 9px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease;
}

.profile-menu-item:hover {
  background: var(--bg-subtle);
}

.profile-menu-icon {
  width: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.profile-menu-danger {
  color: var(--red-badge-text);
  margin-top: 2px;
  border-top: 1px solid var(--border-light);
  border-radius: 0 0 9px 9px;
  padding-top: 9px;
}

/* Collapsible Add-User Form & Member Edit Drawer */
.add-user-collapsible-form {
  padding: 12px !important;
  margin-top: 4px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 10px !important;
}

.add-user-form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.member-edit-drawer {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  pointer-events: none;
  transition: grid-template-rows 0.2s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.16s ease;
}

.member-edit-drawer.is-open {
  grid-template-rows: 1fr;
  opacity: 1;
  pointer-events: auto;
}

.member-edit-drawer-inner {
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 0;
  padding-top: 0;
  border-top: 1px solid transparent;
  transition: margin-top 0.2s cubic-bezier(0.22, 1, 0.36, 1),
    padding-top 0.2s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.16s ease;
}

.member-edit-drawer.is-open > .member-edit-drawer-inner {
  margin-top: 4px;
  padding-top: 8px;
  border-top-color: var(--border-light);
}

.member-edit-actions-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.family-accordion-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.accordion-panel {
  border: 1.5px solid #86efac;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  overflow: hidden;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

[data-theme="dark"] .accordion-panel {
  border-color: #256348;
}

.accordion-panel.is-open {
  border-color: #22c55e;
  box-shadow: 0 4px 14px -4px rgba(22, 163, 74, 0.18);
}

[data-theme="dark"] .accordion-panel.is-open {
  border-color: #10b981;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.accordion-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  background: linear-gradient(145deg, #f0fdf4 0%, #dcfce7 100%);
  border: none;
  border-bottom: 1.5px solid transparent;
  cursor: pointer;
  user-select: none;
  text-align: left;
  color: var(--text-main);
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

[data-theme="dark"] .accordion-header {
  background: linear-gradient(145deg, #132a20 0%, #0f221a 100%);
}

.accordion-header:hover {
  background: linear-gradient(145deg, #dcfce7 0%, #bbf7d0 100%);
}

[data-theme="dark"] .accordion-header:hover {
  background: linear-gradient(145deg, #163528 0%, #122b20 100%);
}

.accordion-panel.is-open > .accordion-header {
  background: linear-gradient(145deg, #dcfce7 0%, #bbf7d0 100%);
  border-bottom-color: #86efac;
}

[data-theme="dark"] .accordion-panel.is-open > .accordion-header {
  background: linear-gradient(145deg, #163528 0%, #122b20 100%);
  border-bottom-color: #256348;
}

.accordion-header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.accordion-title {
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-main);
  transition: color 0.18s ease;
}

.accordion-panel.is-open .accordion-title {
  color: var(--green-accent);
}

.accordion-subtitle {
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.3;
}

.accordion-chevron {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), color 0.18s ease;
}

.accordion-panel.is-open .accordion-chevron {
  transform: rotate(180deg);
  color: var(--green-accent);
}

.accordion-body {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  pointer-events: none;
  background: var(--bg-card);
  transition: grid-template-rows 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.18s ease;
}

.accordion-panel.is-open > .accordion-body {
  grid-template-rows: 1fr;
  opacity: 1;
  pointer-events: auto;
}

.accordion-body-inner {
  overflow: hidden;
  min-height: 0;
  padding: 0 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: padding 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.accordion-panel.is-open > .accordion-body > .accordion-body-inner {
  padding: 14px;
}

.section-add-btn-row {
  display: flex;
  justify-content: flex-start;
}

.hidden {
  display: none !important;
}

@media (max-width: 540px) {
  .person-hero-name {
    font-size: 1.68rem;
  }
  .person-hero-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.92rem;
  }
  .header-logo {
    width: 40px;
    height: 40px;
  }
  .form-row-2 {
    grid-template-columns: 1fr;
  }
  .toast-amount-form {
    width: 100%;
    margin-left: 0;
  }
  .input-sm {
    flex: 1;
  }
}
