:root {
  --bg-page: #f5f7f4;
  --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: 20px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --shadow-soft: 0 4px 20px rgba(15, 23, 42, 0.05);
  --shadow-card: 0 2px 10px rgba(15, 23, 42, 0.04);
  --tooltip-bg: #1e293b;
  --tooltip-text: #f8fafc;
  --tooltip-border: rgba(255, 255, 255, 0.14);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg-page: #0f141c;
  --bg-card: #18202c;
  --bg-subtle: #232e3f;
  --bg-elevated: #1e2837;
  --bg-glass: rgba(15, 20, 28, 0.55);
  --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 8px 28px rgba(0, 0, 0, 0.35);
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

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

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

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

/* Header */
.app-header {
  position: relative;
  z-index: 15;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 15px 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-soft);
}

.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: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.person-hero {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.btn-settings-gear {
  position: relative;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  opacity: 0.78;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s ease, opacity 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: transparent;
}

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

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

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

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

.btn-settings-gear::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 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(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.24);
  z-index: 50;
}

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

.med-card-gear {
  background: transparent;
  border: none;
  padding: 2px;
}

.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;
}

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

.header-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  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: inline-flex;
  align-items: center;
  gap: 10px;
}

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

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

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

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

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

.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;
  bottom: calc(100% + 8px);
  right: 0;
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  border: 1px solid var(--tooltip-border);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.24);
  z-index: 60;
}

.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;
  margin-bottom: 10px;
  padding: 0 2px;
}

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

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

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

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

.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;
  bottom: calc(100% + 7px);
  left: 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(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.24);
  z-index: 60;
}

.btn-multiselect-toggle:hover::after,
.btn-multiselect-toggle:focus-visible::after {
  opacity: 1;
  transform: 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;
  bottom: calc(100% + 6px);
  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(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.24);
  z-index: 50;
}

.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; }
}

/* Single Unified Medications List */
.meds-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.med-card {
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  transition: all 0.15s ease;
  position: relative;
  background: var(--bg-card);
  border: 1.5px solid var(--border-light);
}

/* NEUTRAL CARD: Checking / Syncing (Default — Neither Green nor Red) */
.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: var(--green-surface);
  border: 1.5px solid var(--green-border);
}

/* OVERDUE CARD: > 1 Hour Past Scheduled Time (Green Card with 3px Border & Yellow Overdue Indicator) */
.med-card.is-green.is-overdue {
  border-width: 3px;
}

/* RED CARD: Not Time to Take Yet */
.med-card.is-red {
  background: var(--red-surface);
  border: 1.5px solid var(--red-border);
}

/* Compact Summary Row (Always Visible) */
.med-compact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.med-compact-info {
  min-width: 0;
  flex: 1;
  cursor: pointer;
}

.med-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.med-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.01em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.med-time-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  font-weight: 700;
  margin-top: 3px;
}

.med-time-left [data-role="time-left-text"] {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.32;
}

.compact-taken-line {
  color: var(--text-secondary);
  font-weight: 600;
}

.compact-next-line {
  color: var(--red-badge-text);
  font-weight: 700;
}

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

.is-green .med-time-left {
  color: var(--green-badge-text);
}

.med-card.is-green.is-overdue .med-time-left {
  color: #ca8a04;
}

[data-theme="dark"] .med-card.is-green.is-overdue .med-time-left {
  color: #facc15;
}

.is-red .med-time-left {
  color: var(--red-badge-text);
}

.status-dot {
  width: 8px;
  height: 8px;
  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);
}

.med-card.is-green.is-overdue .status-dot {
  background: #eab308;
}

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

.btn-clear-overdue {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  margin-left: 3px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #ca8a04;
  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 {
  color: #facc15;
}

.btn-clear-overdue:hover {
  background: rgba(234, 179, 8, 0.22);
  color: #a16207;
  transform: scale(1.1);
}

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

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

.btn-clear-overdue::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  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;
  transition: opacity 0.15s ease, transform 0.15s ease;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.24);
  z-index: 50;
}

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

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

.med-compact-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-log-compact {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.08s ease, background-color 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: var(--green-accent);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.22);
}

.is-green .btn-log-compact:hover {
  background: var(--green-accent-hover);
}

.is-red .btn-log-compact {
  background: var(--orange-accent);
  color: #ffffff;
  border: none;
  box-shadow: 0 2px 8px rgba(234, 88, 12, 0.24);
}

.is-red .btn-log-compact:hover {
  background: var(--orange-accent-hover);
}

.btn-expand-toggle {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border-glass);
  background: var(--bg-glass);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.2s ease;
  padding: 0;
}

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

.btn-expand-toggle svg {
  width: 18px;
  height: 18px;
  transition: transform 0.2s ease;
}

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

/* Expandable Details Drawer (Animated Open/Close) */
.med-details-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;
}

.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;
  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;
}

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

.med-details-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

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

.med-edit-btn:hover {
  background: var(--bg-glass-hover);
  color: var(--text-main);
}

.med-subtitle {
  font-size: 0.86rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.med-timing-lines {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
}

.med-timing-line {
  font-size: 0.9rem;
  color: var(--text-main);
  line-height: 1.4;
}

.med-timing-line strong {
  font-weight: 800;
}

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

.med-notes {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

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

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

.med-card.is-expanded .compact-wait-bar-track {
  display: none;
}

.wait-bar-track {
  width: 100%;
  height: 6px;
  background: rgba(225, 29, 72, 0.16);
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0 12px;
}

.wait-bar-fill {
  height: 100%;
  background: var(--red-accent);
  border-radius: 999px;
  transition: width 0.5s linear;
}

.drawer-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.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;
}

/* Administered Doses List inside Medication Details Drawer */
.med-drawer-doses {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-glass);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.med-drawer-doses-label {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text-main);
}

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

.med-dose-event-info {
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.4;
}

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

.btn-dose-mini {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.84rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.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);
}

.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) */
body.is-auth-screen {
  --bg-page: #f5f7f4;
  --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: #f5f7f4 !important;
  color: #0f172a;
  color-scheme: light;
}

.locked-card {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-xl);
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.07);
  margin: 24px auto;
}

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

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

.auth-brand-title {
  font-size: 1.38rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.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;
}

/* Modal Tabs */
.modal-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-subtle);
  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: var(--bg-card);
  color: var(--text-main);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.modal-tab.modal-tab-icon {
  flex: 0 0 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 6px;
}

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

.modal-tab.modal-tab-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 7px);
  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(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.24);
  z-index: 50;
}

.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: wrap;
}

.member-manage-name {
  font-weight: 700;
  font-size: 0.96rem;
  color: var(--text-main);
}

.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;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translate(-50%, 4px);
  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.15s ease, transform 0.15s ease;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.24);
  z-index: 50;
}

.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: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.76rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.12s ease;
}

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

.btn-member-action.danger {
  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;
}

.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: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  border-radius: var(--radius-xl);
  width: min(500px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  padding: 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.32);
}

.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.7rem;
  font-weight: 700;
  margin-left: 6px;
}

.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);
  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 var(--border-input);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  overflow: hidden;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.accordion-panel.is-open {
  border-color: #94a3b8;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

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

.accordion-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  background: #e2e8f0;
  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: #243044;
}

.accordion-header:hover {
  background: #d5deea;
}

[data-theme="dark"] .accordion-header:hover {
  background: #2d3c54;
}

.accordion-panel.is-open > .accordion-header {
  background: #dbe6f2;
  border-bottom-color: var(--border-input);
}

[data-theme="dark"] .accordion-panel.is-open > .accordion-header {
  background: #2b3a52;
  border-bottom-color: var(--border-input);
}

.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) {
  .form-row-2 {
    grid-template-columns: 1fr;
  }
  .toast-amount-form {
    width: 100%;
    margin-left: 0;
  }
  .input-sm {
    flex: 1;
  }
}
