/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:        #0f2744;
  --navy-mid:    #1a3a5c;
  --navy-light:  #2a5a8c;
  --blue:        #2b7fff;
  --blue-soft:   #ddeeff;
  --green:       #1a9e6e;
  --green-soft:  #d4f2e7;
  --amber:       #c07a10;
  --amber-soft:  #fef0d0;
  --red:         #d63030;
  --red-soft:    #fde8e8;
  --gray-50:     #f7f8fa;
  --gray-100:    #eef0f4;
  --gray-200:    #dde0e8;
  --gray-400:    #9ba3b5;
  --gray-600:    #5c6678;
  --gray-900:    #1a1e2a;
  --text:        #1a1e2a;
  --text-muted:  #5c6678;
  --text-hint:   #9ba3b5;
  --surface:     #ffffff;
  --surface-2:   #f7f8fa;
  --border:      #dde0e8;
  --border-soft: #eef0f4;
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   16px;
  --radius-xl:   20px;
  --ring-track:  #dde0e8;
  --ring-fill:   #2b7fff;
  --font:        'DM Sans', system-ui, sans-serif;
  --font-mono:   'DM Mono', monospace;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=DM+Mono:wght@400&display=swap');

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 16px;
  color: var(--text);
  background: var(--navy);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* ── App Shell ────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--surface);
  position: relative;
  overflow: hidden;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
#app-header {
  background: var(--navy);
  color: white;
  padding: 48px 20px 16px;
  flex-shrink: 0;
}

.header-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.header-app-name {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  margin-bottom: 4px;
}

.header-title {
  font-size: 22px;
  font-weight: 600;
  color: white;
  line-height: 1.2;
}

.header-sub {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  margin-top: 3px;
}

/* ── Main Content ─────────────────────────────────────────────────────────── */
#main-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 24px;
  background: var(--gray-50);
  -webkit-overflow-scrolling: touch;
}

.screen { display: none; }

/* ── Bottom Nav ───────────────────────────────────────────────────────────── */
#bottom-nav {
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border-soft);
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  flex-shrink: 0;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-hint);
  font-size: 10px;
  font-family: var(--font);
  font-weight: 500;
  transition: color 0.15s;
}

.nav-item.active { color: var(--blue); }

.nav-icon {
  font-size: 20px;
  line-height: 1;
}

/* ── Cards & Surfaces ─────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-card);
}

/* ── Screen Titles ────────────────────────────────────────────────────────── */
.screen-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}
.screen-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}
.screen-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-hint);
  margin: 20px 0 8px;
}

/* ── Today Screen ─────────────────────────────────────────────────────────── */
.today-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.today-date {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}
.today-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}
.adherence-ring {
  position: relative;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
}
.ring-svg {
  width: 52px;
  height: 52px;
  transform: rotate(-90deg);
}
.ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}

.bucket-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-hint);
  margin: 16px 0 6px;
}

.dose-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s;
}
.dose-card.card-taken  { border-color: #9fe1cb; background: #f4fdf9; }
.dose-card.card-partial { border-color: #fac775; background: #fffbf2; }
.dose-card.card-missed  { border-color: #f7c1c1; background: #fff8f8; }
.dose-card.card-due    { border-color: var(--blue); background: #f0f7ff; }

.dose-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}
.dose-body { flex: 1; min-width: 0; }
.dose-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dose-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.dose-note {
  font-size: 11px;
  color: var(--text-hint);
  margin-top: 3px;
  font-style: italic;
}
.dose-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}
.dose-time {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.status-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
}
.chip-taken   { background: var(--green-soft); color: #0d6b4a; }
.chip-partial { background: var(--amber-soft); color: #8a5500; }
.chip-missed  { background: var(--red-soft);   color: #a82020; }
.chip-upcoming { background: var(--gray-100);  color: var(--text-hint); }

.log-btn {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--gray-200);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-family: var(--font);
}
.log-btn.log-btn-due {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-soft);
}

/* ── History Screen ───────────────────────────────────────────────────────── */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.cal-nav-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  line-height: 1;
}
.cal-month-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.cal-legend {
  display: flex;
  gap: 14px;
  margin-bottom: 10px;
  font-size: 11px;
  color: var(--text-muted);
}
.leg-item { display: flex; align-items: center; gap: 5px; }
.leg-dot {
  width: 10px; height: 10px;
  border-radius: 3px;
}
.leg-full    { background: #9fe1cb; }
.leg-partial { background: #fac775; }
.leg-missed  { background: #f7c1c1; }

.cal-grid { margin-bottom: 16px; }
.cal-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-bottom: 3px; }
.cal-headers { margin-bottom: 4px; }
.cal-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
  transition: background 0.1s;
}
.cal-hdr  { font-size: 10px; font-weight: 600; color: var(--text-hint); cursor: default; aspect-ratio: auto; padding: 2px 0; }
.cal-day:hover { background: var(--gray-100); }
.day-full    { background: #d4f2e7; color: #0d6b4a; }
.day-partial { background: #fef0d0; color: #8a5500; }
.day-missed  { background: #fde8e8; color: #a82020; }
.cal-today   { font-weight: 700; border: 2px solid var(--blue); }
.cal-selected { outline: 2px solid var(--blue); outline-offset: 1px; }

.detail-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
}
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.detail-date-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.detail-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-top: 1px solid var(--border-soft);
  font-size: 13px;
}
.detail-row:first-of-type { border-top: none; }
.detail-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.detail-name { flex: 1; color: var(--text); }
.detail-time { font-size: 12px; color: var(--text-muted); }
.chip {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
}
.chip-edited { font-size: 10px; opacity: 0.7; }

/* ── Edit Flow ────────────────────────────────────────────────────────────── */
.edit-flow-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  padding: 16px;
  margin-top: 8px;
  box-shadow: var(--shadow-card);
}
.edit-step-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
}
.step-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gray-200);
  flex-shrink: 0;
}
.step-dot.step-active { background: var(--blue); width: 20px; border-radius: 4px; }
.step-dot.step-done   { background: var(--green); }
.step-line {
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}
.step-line.step-line-done { background: var(--green); }
.step-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 4px;
  white-space: nowrap;
}

.edit-info-banner {
  background: #fffbf0;
  border: 1px solid #fac775;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 12px;
  color: #7a5200;
  margin-bottom: 14px;
  line-height: 1.5;
}
.edit-row {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  padding: 10px 12px;
  margin-bottom: 8px;
  transition: border-color 0.15s, background 0.15s;
}
.edit-row-changed { border-color: #85b7eb; background: #f0f7fd; }
.edit-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}
.edit-med-name { flex: 1; font-weight: 600; color: var(--text); }
.edit-picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.edit-current {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 60px;
}
.edit-arrow { font-size: 12px; color: var(--text-hint); }
.edit-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.picker-chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--gray-50);
  cursor: pointer;
  font-family: var(--font);
  color: var(--text);
  transition: all 0.1s;
}
.pc-taken   { background: var(--green-soft); border-color: #6dd1aa; color: #0d6b4a; }
.pc-partial { background: var(--amber-soft); border-color: #e6b84e; color: #8a5500; }
.pc-missed  { background: var(--red-soft);   border-color: #f09595; color: #a82020; }

.confirm-summary {
  background: var(--gray-50);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.confirm-summary-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}
.confirm-change-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--border-soft);
  font-size: 12px;
}
.confirm-change-row:first-of-type { border-top: none; }
.confirm-name { flex: 1; color: var(--text); }
.confirm-time { color: var(--text-muted); }
.confirm-before { color: var(--text-hint); text-decoration: line-through; }
.confirm-after  { font-weight: 600; }
.confirm-arrow  { color: var(--text-hint); font-size: 11px; }
.taken  { color: #0d6b4a; }
.partial { color: #8a5500; }
.missed  { color: #a82020; }

.edit-success { text-align: center; padding: 8px 0; }
.success-icon-wrap { margin: 16px 0 12px; }
.success-circle {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}
.success-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.success-sub {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 16px;
}

/* ── Medications Screen ───────────────────────────────────────────────────── */
.med-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  margin-bottom: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.med-card-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}
.med-swatch {
  width: 14px; height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
}
.med-info { flex: 1; min-width: 0; }
.med-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.med-detail {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.med-instructions {
  font-size: 11px;
  color: var(--text-hint);
  margin-top: 2px;
}
.med-actions { display: flex; gap: 6px; }

.med-inline-form {
  border-top: 1px solid var(--border-soft);
  padding: 14px;
  background: var(--gray-50);
}
.form-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 14px;
}

.add-fab {
  width: 100%;
  padding: 13px;
  border-radius: var(--radius-lg);
  border: 2px dashed var(--gray-200);
  background: none;
  color: var(--blue);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
  transition: border-color 0.15s, background 0.15s;
}
.add-fab:hover { background: var(--blue-soft); border-color: var(--blue); }
.fab-icon { font-size: 18px; font-weight: 400; }

/* ── Stats Screen ─────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 4px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  padding: 14px;
  box-shadow: var(--shadow-card);
}
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-blue  { color: var(--blue); }
.stat-green { color: var(--green); }
.stat-red   { color: var(--red); }
.stat-sub   { font-size: 11px; color: var(--text-hint); margin-top: 4px; }

.med-stat-row { margin-bottom: 12px; }
.med-stat-top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 5px;
}
.med-stat-name { color: var(--text); font-weight: 500; }
.med-stat-pct  { font-weight: 700; }
.progress-bar-bg {
  height: 6px;
  border-radius: 3px;
  background: var(--gray-100);
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.settings-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  margin-bottom: 8px;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border-soft);
  font-size: 13px;
}
.setting-row:first-child { border-top: none; }
.setting-label { color: var(--text); }
.setting-value { color: var(--text-muted); font-size: 12px; }
.val-on { color: var(--green); font-weight: 600; }
.val-off { color: var(--red); }
.setting-select {
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  cursor: pointer;
}

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
.form-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(43,127,255,0.1);
}
.form-error {
  font-size: 12px;
  color: var(--red);
  margin-bottom: 10px;
}
.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.time-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.time-input { max-width: 140px; }

.color-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 4px 0;
}
.color-dot {
  width: 26px; height: 26px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s, border-color 0.1s;
}
.color-dot:hover { transform: scale(1.1); }
.color-dot.selected { border-color: var(--text); transform: scale(1.1); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-primary {
  padding: 11px 20px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--navy);
  color: white;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--navy-mid); }
.btn-primary:active { background: var(--navy-light); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
  padding: 11px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
}
.btn-ghost:hover { background: var(--gray-50); }

.icon-btn {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
}
.icon-btn:hover { background: var(--gray-50); }
.icon-btn.danger { color: var(--red); border-color: #f7c1c1; }
.icon-btn.danger:hover { background: var(--red-soft); }

.link-btn {
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font);
  padding: 0;
}

/* ── Log Modal ────────────────────────────────────────────────────────────── */
#log-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,20,40,0.5);
  z-index: 100;
  align-items: flex-end;
  justify-content: center;
}
#log-modal.open { display: flex; }
#log-modal-inner {
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 12px 20px max(24px, env(safe-area-inset-bottom));
  width: 100%;
  max-width: 480px;
}
.modal-pill {
  width: 36px; height: 4px;
  border-radius: 2px;
  background: var(--gray-200);
  margin: 0 auto 16px;
}
.modal-med-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 3px;
}
.modal-med-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 18px;
}
.log-options { display: flex; flex-direction: column; gap: 8px; }
.log-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--gray-50);
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  color: var(--text);
  text-align: left;
  transition: all 0.1s;
}
.opt-icon { font-size: 16px; width: 20px; text-align: center; }
.log-option.selected.opt-taken   { background: var(--green-soft); border-color: #6dd1aa; }
.log-option.selected.opt-partial { background: var(--amber-soft); border-color: #e6b84e; }
.log-option.selected.opt-missed  { background: var(--red-soft);   border-color: #f09595; }
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

/* ── Confirm Modal ────────────────────────────────────────────────────────── */
#confirm-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,20,40,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#confirm-modal.open { display: flex; }
.confirm-dialog {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 24px 20px;
  width: 100%;
  max-width: 340px;
}
#confirm-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}
#confirm-message {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 20px;
}
.confirm-btns { display: flex; gap: 8px; }

/* ── Empty States ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
}
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-sub   { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
#main-content::-webkit-scrollbar { width: 3px; }
#main-content::-webkit-scrollbar-track { background: transparent; }
#main-content::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 3px; }

/* ── Med Type Badges ──────────────────────────────────────────────────────── */
.med-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.med-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-required {
  background: var(--blue-soft);
  color: var(--blue);
}

.badge-optional {
  background: var(--amber-soft);
  color: var(--amber);
}

/* ── Medication Type Toggle (form) ────────────────────────────────────────── */
.type-toggle-row {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.type-toggle-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 12px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  font-family: var(--font);
  transition: border-color 0.15s, background 0.15s;
}

.type-toggle-btn:hover {
  border-color: var(--gray-400);
}

.type-toggle-active-req {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.type-toggle-active-opt {
  border-color: var(--amber);
  background: var(--amber-soft);
}

.toggle-icon {
  font-size: 20px;
}

.toggle-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.toggle-desc {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* ── Optional / As-Needed Section ────────────────────────────────────────── */
.optional-section-label {
  margin-top: 24px;
}

.optional-med-card {
  background: var(--surface);
  border-left: 3px solid var(--amber);
}

.optional-count-badge {
  font-size: 13px;
  font-weight: 700;
  border: 2px solid;
  border-radius: 20px;
  padding: 2px 10px;
  margin-bottom: 6px;
  text-align: center;
  min-width: 38px;
}

.optional-taken-list {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.optional-taken-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
}

.opt-entry-time {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.opt-entry-note {
  flex: 1;
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opt-remove-btn {
  background: none;
  border: none;
  color: var(--text-hint);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s;
}

.opt-remove-btn:hover {
  color: var(--red);
}

/* ── History Detail — As Needed divider ──────────────────────────────────── */
.detail-section-divider {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--amber);
  padding: 8px 0 4px;
  border-top: 1px solid var(--border-soft);
  margin-top: 6px;
}

/* ── Stats — Optional usage bar ──────────────────────────────────────────── */
.stat-optional-bar-bg {
  height: 6px;
  background: var(--amber-soft);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}

.stat-optional-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
  opacity: 0.7;
}
