/* ═══════════════════════════════════════════════════════════════════
   CognaSync — Field Notebook theme
   North Star: "The Field Notebook" — warm parchment, reed green,
   editorial serif + mono numerics. See DESIGN.md for full spec.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  /* Surfaces */
  --bg:          #F4F2ED;   /* Warm Parchment — page background */
  --surface:     #FAFAF8;   /* Ivory Card — elevated surfaces */
  --surface-alt: #F4F2ED;   /* same as bg for inset contexts */

  /* Borders (warm, never black) */
  --border:      #D3D1C7;   /* Vellum Border — standard */
  --border-mid:  rgba(0,0,0,0.20);
  --border-light:rgba(0,0,0,0.08);

  /* Text */
  --text:        #1A1A18;   /* Carbon Ink */
  --text-mid:    #2C2C2A;
  --text-muted:  #5F5E5A;   /* Pencil Gray */

  /* Accent — Reed Green (single brand color) */
  --accent:      #0F6E56;
  --accent-bg:   #0F6E56;
  --accent-fg:   #FAFAF8;

  /* Status — semantic only, never decorative */
  --green:       #0F6E56;   /* Reed Green (same as accent) */
  --green-light: #E1F5EE;   /* Reed Faint */
  --red:         #A32D2D;
  --red-light:   #FCEBEB;
  --amber:       #854F0B;
  --amber-light: #FAEEDA;

  /* Shadows — warm-tinted (Carbon Ink at opacity, never pure black) */
  --shadow-resting:  0 1px 2px rgba(26,26,24,0.05), 0 1px 3px rgba(26,26,24,0.04);
  --shadow-lifted:   0 2px 8px rgba(26,26,24,0.08), 0 4px 16px rgba(26,26,24,0.05);
  --shadow-elevated: 0 8px 32px rgba(26,26,24,0.12), 0 16px 48px rgba(26,26,24,0.06);

  /* Structure */
  --nav-h:       52px;
  --radius:      10px;      /* md radius — gently rounded, not sharp */
  --radius-sm:   6px;
  --radius-lg:   16px;
  --shadow:      var(--shadow-resting);
  --transition:  0.12s cubic-bezier(0.25, 1, 0.5, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-weight: 400;
  line-height: 1.2;
  color: var(--text);
}

a { color: var(--text); text-decoration: underline; }
a:hover { text-decoration: none; }
p { color: var(--text); }

/* ── Top navigation bar ─────────────────────────────────────────────── */

.top-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 0;
  z-index: 1000;
  white-space: nowrap;
  transition: box-shadow 0.2s cubic-bezier(0.25,1,0.5,1);
}
.top-nav.scrolled {
  box-shadow: var(--shadow-lifted);
  border-bottom-color: transparent;
}

.top-nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 32px;
  flex-shrink: 0;
  text-decoration: none;
}

.brand-mark {
  background: var(--text);
  color: var(--surface);
  font-family: 'DM Serif Display', serif;
  font-size: 12px;
  width: 28px; height: 28px;
  border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.brand-name {
  font-family: 'DM Serif Display', serif;
  font-size: 16px;
  color: var(--text);
  text-decoration: none;
}

.top-nav-links {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}

.top-nav-links::-webkit-scrollbar { display: none; }

.top-nav-item {
  display: flex;
  align-items: center;
  height: var(--nav-h);
  padding: 0 14px;
  font-size: 0.855rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
}

.top-nav-item:hover {
  color: var(--text);
  text-decoration: none;
  background: transparent;
}

.top-nav-item.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 500;
}

.top-nav-end {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: 16px;
  flex-shrink: 0;
}

.top-nav-user {
  font-size: 0.82rem;
  color: var(--text-muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-nav-logout {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.top-nav-logout:hover {
  color: var(--text);
  border-color: var(--border-mid);
  text-decoration: none;
  opacity: 0.88;
}

/* ── Layout ─────────────────────────────────────────────────────────── */

.main-content {
  padding: 40px 48px;
  max-width: 1140px;
}

.main-content.with-nav {
  margin-top: var(--nav-h);
}

@media (max-width: 768px) {
  .main-content { padding: 24px 20px; }
  .top-nav-links { gap: 0; }
  .top-nav-item { padding: 0 10px; font-size: 0.8rem; }
}

/* ── Page header ─────────────────────────────────────────────────────── */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 2rem;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.page-sub {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.back-link {
  display: block;
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-decoration: underline;
}

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

/* ── Buttons ─────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity var(--transition), transform 80ms, background var(--transition), border-color var(--transition);
  text-decoration: none;
  white-space: nowrap;
  background: var(--surface);
  color: var(--text);
}

.btn:hover { text-decoration: none; opacity: 0.88; }
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.btn-primary:hover { background: #085041; border-color: #085041; opacity: 1; }
.btn-primary:disabled { background: var(--border); border-color: var(--border); cursor: not-allowed; opacity: 0.5; }

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}

.btn-secondary:hover { background: var(--green-light); }

.btn-ghost {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

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

.btn-sm   { padding: 5px 12px; font-size: 0.81rem; border-radius: var(--radius-sm); }
.btn-full { width: 100%; justify-content: center; }

/* ── Forms ───────────────────────────────────────────────────────────── */

.form-group, .form-section { margin-bottom: 20px; }

.form-label, label {
  display: block;
  font-weight: 500;
  font-size: 0.855rem;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.label-hint { font-weight: 400; color: var(--text-muted); font-size: 0.8rem; }

.form-input, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], select, .form-textarea, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text);
  transition: box-shadow var(--transition);
  appearance: auto;
}

.form-input:focus, input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-lifted);
}

.form-textarea, textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
}

.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 160px; }
.form-actions { margin-top: 24px; }

.range-slider {
  width: 100%; padding: 0; height: 4px; border: none;
  background: transparent; accent-color: var(--text);
  cursor: pointer; margin: 8px 0;
}

.range-labels { display: flex; justify-content: space-between; font-size: 0.77rem; color: var(--text-muted); margin-top: 2px; }
.range-value  { font-weight: 500; }

/* ── Alerts ──────────────────────────────────────────────────────────── */

.alert {
  padding: 11px 15px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 16px;
  line-height: 1.55;
  border: 1px solid;
}

.alert-success { background: var(--green-light); color: var(--green);  border-color: #90C8A8; }
.alert-error   { background: var(--red-light);   color: var(--red);    border-color: #E0A0A0; }
.alert-crisis  { background: var(--amber-light);  color: var(--amber);  border-color: #C8B060; font-weight: 500; white-space: pre-line; }

.hidden { display: none !important; }

.flash-container { position: fixed; top: calc(var(--nav-h) + 12px); right: 16px; z-index: 9999; max-width: 360px; }
.flash {
  padding: 11px 15px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 0.855rem;
  border: 1px solid;
}
.flash-success { background: var(--green-light); color: var(--green); border-color: #90C8A8; }
.flash-error   { background: var(--red-light);   color: var(--red);   border-color: #E0A0A0; }

/* ── Auth ────────────────────────────────────────────────────────────── */

.auth-page { background: var(--bg); }

.auth-shell {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 32px 16px;
}

.auth-brand { text-align: center; margin-bottom: 32px; }

.auth-logo {
  background: var(--accent);
  color: var(--accent-fg);
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  width: 52px; height: 52px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
}

.auth-title { font-size: 1.75rem; margin-bottom: 4px; }
.auth-subtitle { color: var(--text-muted); font-size: 0.9rem; }

.auth-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-resting);
}

.auth-card-title { font-size: 1.35rem; margin-bottom: 24px; }
.auth-form .form-group { margin-bottom: 16px; }
.auth-switch { text-align: center; margin-top: 20px; font-size: 0.855rem; color: var(--text-muted); }

.auth-invite-banner {
  display: flex; align-items: flex-start; gap: 12px;
  background: #eff6ff; border: 1px solid #93c5fd;
  border-radius: var(--radius); padding: 14px 16px;
  width: 100%; max-width: 420px; margin-bottom: 16px;
  font-size: 0.9rem; color: #1e40af;
}
.invite-banner-icon { font-size: 1.2rem; flex-shrink: 0; }
.invite-banner-body { line-height: 1.5; }
.invite-message {
  margin: 6px 0 0; font-style: italic; color: #3b82f6;
  background: rgba(147,197,253,0.18); border-radius: 4px; padding: 4px 8px;
}

/* ── Home ────────────────────────────────────────────────────────────── */

.streak-badge {
  display: flex; flex-direction: column; align-items: center;
  background: var(--accent); color: var(--accent-fg);
  border-radius: var(--radius-lg);
  padding: 12px 20px; min-width: 80px;
}

.streak-number { font-family: 'DM Serif Display', serif; font-size: 2rem; line-height: 1; }
.streak-label  { font-size: 0.72rem; opacity: 0.75; }

.quick-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin-bottom: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.quick-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: none;
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  padding: 18px;
  text-decoration: none;
  color: var(--text);
  transition: var(--transition);
}

.quick-card:hover {
  background: var(--bg);
  text-decoration: none;
}

.quick-card--done { background: var(--green-light); }
.quick-card--done:hover { background: #daf0e6; }

.quick-card-icon {
  font-size: 1.3rem;
  width: 36px; height: 36px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--bg);
}

.quick-card-body  { flex: 1; }
.quick-card-title { font-weight: 500; font-size: 0.9rem; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick-card-sub   { font-size: 0.79rem; color: var(--text-muted); }
.quick-card-arrow { font-size: 1rem; color: var(--text-muted); }

.section-header {
  display: flex; align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}

.section-title { font-size: 1.15rem; }
.section-meta  { font-size: 0.79rem; color: var(--text-muted); }

.home-summary-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.summary-excerpt { color: var(--text-mid); font-size: 0.9rem; line-height: 1.75; margin-bottom: 16px; }

/* ── Home medication widget ──────────────────────────────────────────── */
.home-med-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.med-dose-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.med-dose-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
}

.med-dose-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.med-dose-name { font-weight: 500; font-size: 0.9rem; }
.med-dose-amount { font-size: 0.78rem; color: var(--text-muted); }

.med-dose-item--taken { border-color: var(--green); background: var(--green-light); }

.med-dose-status { display: flex; align-items: center; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.med-taken-checkmark { font-size: 1rem; font-weight: 500; color: var(--green); flex-shrink: 0; }
.med-taken-time  { font-size: 0.75rem; color: var(--green); font-weight: 500; white-space: nowrap; }
.med-time-input  { width: 90px; padding: 4px 8px; font-size: 0.8rem; border-radius: 6px; border: 1px solid var(--border); }
.med-remove-btn  { color: var(--text-muted); font-size: 0.75rem; }

/* ── Journal ─────────────────────────────────────────────────────────── */

.journal-modes {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.mode-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
  white-space: nowrap;
}
.mode-tab:hover { border-color: var(--accent); color: var(--accent); background: var(--green-light); }
.mode-tab.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.mode-tab .mode-icon { font-size: 1rem; line-height: 1; }

.journal-panel { max-width: 780px; }
.journal-textarea { min-height: 200px; font-size: 1rem; line-height: 1.75; }
.char-counter { text-align: right; font-size: 0.77rem; color: var(--text-muted); margin-top: 4px; }

.analysis-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; margin-top: 24px;
}

.analysis-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 640px) { .analysis-grid { grid-template-columns: 1fr; } }

.analysis-heading { font-size: 0.97rem; font-family: 'DM Serif Display', serif; margin-bottom: 10px; color: var(--text-muted); }
.analysis-text    { font-size: 0.89rem; line-height: 1.75; white-space: pre-wrap; word-break: break-word; }
.analysis-text--ai { background: var(--bg); padding: 14px; border: 1px solid var(--border-light); border-radius: var(--radius); }

.prompt-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.prompt-label    { font-size: 0.77rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 8px; }
.prompt-question { font-family: 'DM Serif Display', serif; font-size: 1.2rem; margin-bottom: 12px; }

.guided-container { max-width: 600px; }
.guided-progress  { margin-bottom: 20px; }
.progress-bar     { height: 2px; background: var(--border-light); border-radius: 0; margin-bottom: 6px; }
.progress-fill    { height: 100%; background: var(--accent); transition: width 0.3s cubic-bezier(0.25,1,0.5,1); }
.guided-question  { font-family: 'DM Serif Display', serif; font-size: 1.3rem; margin-bottom: 16px; line-height: 1.4; }
.guided-nav       { display: flex; gap: 10px; margin-top: 16px; }

/* ── Check-in (legacy Jinja form) ────────────────────────────────────── */

.checkin-container {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; margin-bottom: 32px; max-width: 680px;
}

.time-tabs { display: flex; gap: 0; margin-bottom: 24px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; width: fit-content; }
.time-tab {
  padding: 7px 16px; border: none; border-right: 1px solid var(--border);
  background: var(--surface); font-family: 'DM Sans', sans-serif;
  font-size: 0.84rem; cursor: pointer; color: var(--text-muted); transition: var(--transition);
}
.time-tab:last-child { border-right: none; }
.time-tab:hover  { background: var(--green-light); color: var(--accent); }
.time-tab.active { background: var(--accent); color: var(--accent-fg); }

.checkin-form .form-section { border-bottom: 1px solid var(--border-light); padding-bottom: 20px; }
.checkin-form .form-section:last-of-type { border-bottom: none; }
.meds-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.med-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.med-row .med-name { flex: 2; min-width: 120px; }
.med-row .med-dose { flex: 1; min-width: 80px; }
.med-taken-label { display: flex; align-items: center; gap: 4px; font-size: 0.84rem; white-space: nowrap; }
.med-taken-label input { width: auto; }
.btn-remove-med { background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; padding: 0 4px; line-height: 1; }
.btn-remove-med:hover { color: var(--red); }

/* ── Medications ─────────────────────────────────────────────────────── */

.med-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; margin-bottom: 20px;
}

.med-cards { display: flex; flex-direction: column; gap: 0; margin-top: 16px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

.med-detail-card { border-bottom: 1px solid var(--border); background: var(--surface); }
.med-detail-card:last-child { border-bottom: none; }

.med-detail-header {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; background: var(--bg);
  border-bottom: 1px solid var(--border-light); flex-wrap: wrap;
}

.med-detail-name { font-weight: 500; font-size: 0.93rem; flex: 1; }
.med-detail-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.med-dose-badge { background: var(--text); color: var(--surface); padding: 2px 9px; border-radius: var(--radius); font-size: 0.79rem; font-weight: 500; }
.med-freq-tag   { border: 1px solid var(--border-light); color: var(--text-muted); padding: 2px 9px; border-radius: var(--radius); font-size: 0.75rem; }

.btn-remove-card {
  background: none; border: 1px solid var(--border-light); border-radius: var(--radius);
  color: var(--text-muted); font-size: 1.1rem; width: 26px; height: 26px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: var(--transition); flex-shrink: 0; margin-left: auto;
}
.btn-remove-card:hover { background: var(--red-light); border-color: #E0A0A0; color: var(--red); }

.med-info-tabs { display: flex; border-bottom: 1px solid var(--border-light); }
.med-tab {
  padding: 7px 13px; border: none; border-right: 1px solid var(--border-light);
  background: none; font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem; color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: var(--transition);
}
.med-tab:last-child { border-right: none; }
.med-tab:hover  { color: var(--accent); background: var(--green-light); }
.med-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }

.med-tab-pane       { padding: 14px 16px; }
.med-tab-pane.hidden { display: none; }
.med-info-loading   { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 0.82rem; }

.effects-list { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.effect-item  { border: 1px solid var(--border-light); padding: 3px 9px; border-radius: var(--radius); font-size: 0.8rem; }
.onset-note   { font-size: 0.8rem; color: var(--text-muted); margin-top: 8px; }

.interaction-warn-text {
  font-size: 0.85rem; line-height: 1.7; background: var(--amber-light);
  border: 1px solid #C8B060; border-radius: var(--radius); padding: 11px 13px;
}

.dose-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.dose-chip  { border: 1px solid var(--border); padding: 2px 9px; border-radius: var(--radius); font-size: 0.78rem; font-weight: 500; }

.interactions-panel { background: var(--amber-light); border: 1px solid #C8B060; border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px; }
.interactions-heading { font-weight: 500; font-size: 0.87rem; margin-bottom: 12px; color: var(--amber); display: flex; align-items: center; gap: 8px; }
.warn-icon { font-size: 1rem; }
.interaction-alert { border-radius: var(--radius); padding: 11px 13px; margin-bottom: 8px; font-size: 0.84rem; }
.interaction-alert:last-child { margin-bottom: 0; }
.interaction-alert--caution { background: #FBF5DC; border: 1px solid #C8B060; }
.interaction-alert--serious  { background: var(--red-light); border: 1px solid #E0A0A0; }
.ia-drugs   { font-weight: 500; font-size: 0.87rem; margin-bottom: 4px; }
.ia-warning { line-height: 1.55; margin-bottom: 4px; }
.ia-note    { font-size: 0.76rem; color: var(--text-muted); font-style: italic; }

.ref-info-panel { margin-top: 16px; }
.ref-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.ref-card-name { font-family: 'DM Serif Display', serif; font-size: 1.3rem; margin-bottom: 4px; }
.ref-card-onset { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 16px; }
.ref-card-section-title {
  font-weight: 500; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); margin: 14px 0 7px; padding-bottom: 4px;
  border-bottom: 1px solid var(--border-light);
}

.med-current, .med-add-section, .med-log-section, .med-reference-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; margin-bottom: 20px;
}
.med-grid { display: flex; flex-wrap: wrap; gap: 0; margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.med-card { border-right: 1px solid var(--border-light); padding: 13px 16px; min-width: 140px; background: var(--surface); }
.med-card:last-child { border-right: none; }
.med-card-name { font-weight: 500; font-size: 0.9rem; text-transform: capitalize; }
.med-card-dose { font-size: 0.82rem; font-weight: 500; margin-top: 2px; }
.med-card-freq { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.med-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.med-tag  { border: 1px solid var(--border); padding: 3px 10px; border-radius: var(--radius); font-size: 0.8rem; }
.med-add-form, .med-log-form { max-width: 600px; }

/* ── Summary ─────────────────────────────────────────────────────────── */

.summary-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 16px; }
.summary-card--new { border-width: 2px; }
.summary-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.summary-dates { font-weight: 500; font-size: 0.88rem; }
.summary-meta  { font-size: 0.79rem; color: var(--text-muted); }
.summary-badge { background: var(--text); color: var(--surface); font-size: 0.73rem; padding: 2px 9px; border-radius: var(--radius); }
.summary-body  { font-size: 0.9rem; line-height: 1.85; white-space: pre-wrap; }

.loading-panel { text-align: center; padding: 40px; color: var(--text-muted); }

.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

.spinner-sm {
  display: inline-block;
  width: 12px; height: 12px;
  border: 1.5px solid var(--border-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state-panel { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.25; }

/* ── Trends ──────────────────────────────────────────────────────────── */

.period-selector { display: flex; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; width: fit-content; }
.period-btn {
  padding: 6px 14px; border: none; border-right: 1px solid var(--border);
  font-family: 'DM Sans', sans-serif; font-size: 0.82rem; font-weight: 500;
  cursor: pointer; background: var(--surface); color: var(--text-muted);
  text-decoration: none; transition: var(--transition);
}
.period-btn:last-child { border-right: none; }
.period-btn:hover      { background: var(--green-light); color: var(--accent); text-decoration: none; }
.period-btn.active     { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

.stats-row { display: flex; gap: 0; flex-wrap: wrap; margin-bottom: 28px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.stat-card { background: var(--surface); border-right: 1px solid var(--border-light); padding: 16px 20px; flex: 1; min-width: 110px; text-align: center; }
.stat-card:last-child { border-right: none; }
.stat-card-alert { background: #fff8f8; border-bottom: 2px solid #dc2626; }
.stat-card-alert .stat-value { color: #dc2626; }
.stat-card-alert .stat-label { color: #b91c1c; }
/* Flip cards — grid stacking lets the taller face drive card height */
.flip-card { cursor: pointer; perspective: 600px; }
.flip-card-inner { display: grid; transform-style: preserve-3d; transition: transform 0.38s ease; }
.flip-card.flipped .flip-card-inner { transform: rotateY(180deg); }
.flip-card-front, .flip-card-back { grid-area: 1/1; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 14px 10px 10px; }
.flip-card-back { transform: rotateY(180deg); background: var(--surface); font-size: 10.5px; color: var(--text-muted); line-height: 1.55; text-align: center; }
.flip-card-alert .flip-card-back { background: #fff8f8; }
.flip-card-back strong { display: block; font-size: 11px; color: #111; margin-bottom: 5px; font-weight: 500; }
.flip-hint { font-size: 9px; color: var(--text-muted); opacity: 0.45; margin-top: 5px; letter-spacing: .03em; }
.stat-label { font-size: 0.73rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.stat-value { font-family: 'DM Serif Display', serif; font-size: 1.7rem; }
.stat-sub   { font-size: 0.73rem; color: var(--text-muted); }

.insights-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 22px; margin-bottom: 24px; }
.insights-list  { padding-left: 18px; font-size: 0.89rem; line-height: 1.85; }

.charts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.charts-grid-primary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 16px; }
.chart-card  { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.chart-title { font-size: 0.94rem; margin-bottom: 6px; color: var(--text-muted); font-family: 'DM Sans', sans-serif; font-weight: 500; }
.chart-title-row { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.chart-title-avg { font-size: 0.78rem; color: var(--text-muted); }
.chart-title-trend { font-size: 0.72rem; font-weight: 500; padding: 1px 6px; border-radius: 3px; }
.chart-trend-up-good  { background: #e6f4ea; color: #1a7f3c; }
.chart-trend-down-bad { background: #fdecea; color: #c0392b; }
.chart-trend-up-bad   { background: #fdecea; color: #c0392b; }
.chart-trend-down-good{ background: #e6f4ea; color: #1a7f3c; }
.chart-trend-stable   { background: #f0f0f0; color: #888; }
.chart-density-banner { font-size: 11px; color: var(--amber); background: var(--amber-light); border: 1px solid #e8c96a; border-radius: 2px; padding: 4px 8px; margin-bottom: 10px; letter-spacing: .01em; }
.chart-empty-ph { font-size: 0.8rem; color: var(--text-muted); text-align: center; padding: 48px 0; border: 1px dashed var(--border); border-radius: var(--radius); }

/* Stat card trend indicators */
.stat-trend { font-size: 0.68rem; font-weight: 500; letter-spacing: 0.02em; margin-top: 4px; min-height: 14px; }
.stat-trend-good { color: #1a7f3c; }
.stat-trend-bad  { color: #c0392b; }
.stat-trend-neutral { color: var(--text-muted); }

/* Collapsible trends sections */
.trends-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.trends-section-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; cursor: pointer; user-select: none;
  border-bottom: 1px solid transparent; transition: background 0.15s;
}
.trends-section-hdr:hover { background: var(--bg); }
.trends-section-hdr.open { border-bottom-color: var(--border-light); }
.trends-section-title { font-size: 0.9rem; font-weight: 500; color: var(--text); }
.trends-section-meta  { font-size: 0.75rem; color: var(--text-muted); margin-left: 10px; }
.trends-section-chevron { font-size: 0.75rem; color: var(--text-muted); transition: transform 0.2s; }
.trends-section-hdr.open .trends-section-chevron { transform: rotate(180deg); }
.trends-section-body { padding: 20px; }

@media (max-width: 640px) {
  .charts-grid-primary { grid-template-columns: 1fr; }
}

/* ── Settings ────────────────────────────────────────────────────────── */

.settings-sections { max-width: 600px; }
.settings-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 16px; }
.settings-card--danger { border-color: #E0A0A0; }
.settings-heading { font-size: 1.05rem; margin-bottom: 16px; }
.settings-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border-light); font-size: 0.875rem; gap: 12px; }
.settings-row:last-child { border-bottom: none; }
.settings-label { color: var(--text-muted); }
.settings-value { font-weight: 500; }

/* ── Tables ──────────────────────────────────────────────────────────── */

.data-table { width: 100%; border-collapse: collapse; font-size: 0.855rem; }
.data-table th { text-align: left; font-weight: 500; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); padding: 9px 12px; border-bottom: 2px solid var(--border); }
.data-table td { padding: 9px 12px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }

.provider-table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.patient-row:hover { background: var(--bg); cursor: pointer; }
.patient-name { font-weight: 500; }

.score-badge { display: inline-block; padding: 1px 7px; border-radius: var(--radius); font-size: 0.78rem; font-weight: 500; border: 1px solid; }
.score-mood   { border-color: var(--border-light); }
.score-stress { border-color: var(--border-light); color: var(--text-mid); }

/* ── Collapsibles ────────────────────────────────────────────────────── */

.past-section {
  margin-top: 48px;
  max-width: 780px;
}
.past-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.past-section-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.1rem;
  color: var(--text);
}
.past-section-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: 999px;
  padding: 1px 8px;
}
.entries-stack { display: flex; flex-direction: column; gap: 0; }

/* ── Journal entry cards ─────────────────────────────────────────────── */

.journal-entry-card {
  border-bottom: 1px solid var(--border-light);
  padding: 16px 0;
  cursor: pointer;
  user-select: none;
}
.journal-entry-card:last-child { border-bottom: none; }
.journal-entry-card:hover { background: var(--bg); margin: 0 -16px; padding: 16px; }
.journal-entry-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.journal-entry-meta { display: flex; align-items: center; gap: 10px; }
.entry-date { font-size: 0.79rem; color: var(--text-muted); }
.entry-type-badge { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; border: 1px solid var(--border-light); padding: 2px 7px; border-radius: var(--radius); color: var(--text-muted); }
.entry-chevron { font-size: 1.2rem; color: var(--text-muted); transition: transform 0.2s ease; line-height: 1; }
.journal-entry-card.open .entry-chevron { transform: rotate(90deg); }
.journal-entry-preview { font-size: 0.875rem; line-height: 1.65; color: var(--text-muted); }
.journal-entry-card.open .journal-entry-preview { display: none; }
.journal-entry-full { display: none; }
.journal-entry-card.open .journal-entry-full { display: block; }
.journal-full-text { font-size: 0.875rem; line-height: 1.75; white-space: pre-wrap; margin-bottom: 16px; }
.journal-reflection { margin-top: 12px; }
.journal-reflection-label { font-size: 0.72rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 6px; }
.analysis-content { background: var(--bg); border: 1px solid var(--border-light); padding: 12px; border-radius: var(--radius); font-size: 0.855rem; line-height: 1.75; white-space: pre-wrap; }

/* ── Provider ────────────────────────────────────────────────────────── */

.patient-overview { display: flex; gap: 0; flex-wrap: wrap; margin-bottom: 32px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.overview-card { background: var(--surface); border-right: 1px solid var(--border-light); padding: 16px 20px; flex: 1; min-width: 110px; text-align: center; }
.overview-card:last-child { border-right: none; }
.overview-label { font-size: 0.73rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.overview-value { font-family: 'DM Serif Display', serif; font-size: 1.5rem; }
.detail-section { margin-bottom: 36px; }

/* ── Utilities ───────────────────────────────────────────────────────── */

.text-muted  { color: var(--text-muted); }
.text-green  { color: var(--green); }
.capitalize  { text-transform: capitalize; }
.empty-state { color: var(--text-muted); font-size: 0.875rem; }

/* ── Provider shell layout ───────────────────────────────────────────── */

.pv-shell {
  display: flex;
  min-height: calc(100vh - var(--nav-h));
}

body.pv-body .main-content {
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* Appointment workspace: natural page scrolling with sticky sidebars */
body.pv-body-appt .pv-shell {
  align-items: flex-start;
}

.pv-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  align-self: flex-start;
}

.pv-sidebar-head {
  padding: 18px 14px 14px;
  border-bottom: 1px solid var(--border-light);
}

.pv-search {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-light);
  background: var(--bg);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  color: var(--text);
  outline: none;
}

.pv-patient-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.pv-patient-item {
  padding: 10px 11px;
  border: 1px solid transparent;
  cursor: pointer;
  margin-bottom: 2px;
  transition: all 0.12s;
  text-decoration: none;
  display: block;
  color: inherit;
}

.pv-patient-item:hover   { background: var(--bg); border-color: var(--border-light); }
.pv-patient-item.active  { background: var(--bg); border-color: var(--border); }

.pv-patient-name { font-weight: 500; font-size: 13px; color: var(--text); margin-bottom: 3px; }

.pv-patient-sub {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pv-main {
  flex: 1;
  padding: 28px 36px 60px;
  background: var(--bg);
}

/* Appointment workspace: main panel fills full page height */
body.pv-body-appt .pv-main {
  min-height: calc(100vh - var(--nav-h));
}

/* Patient header */
.pv-patient-hdr {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 22px 26px;
  margin-bottom: 20px;
}

.pv-hdr-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.pv-hdr-name {
  font-family: 'DM Serif Display', serif;
  font-size: 26px;
  font-weight: 400;
  color: var(--text);
  margin: 0 0 3px;
}

.pv-hdr-sub  { font-size: 12px; color: var(--text-muted); }
.pv-hdr-actions { display: flex; gap: 8px; }

.pv-hdr-meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

.pv-meta-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 5px;
  display: block;
  font-weight: 500;
}

.pv-meta-value { font-size: 15px; font-weight: 500; color: var(--text); }

/* Controls bar */
.pv-controls {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 16px 22px;
  margin-bottom: 20px;
  display: flex;
  gap: 28px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.pv-control-group { display: flex; flex-direction: column; gap: 7px; }

.pv-control-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 500;
}

.pv-period-btns { display: flex; border: 1px solid var(--border); }

.pv-period-btn {
  padding: 5px 13px;
  font-size: 12px;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  background: var(--surface);
  color: var(--text-muted);
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: all 0.12s;
}

.pv-period-btn:last-child { border-right: none; }
.pv-period-btn.active, .pv-period-btn:hover { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

.pv-confidence-row { display: flex; align-items: center; gap: 10px; }
.pv-confidence-val { font-size: 12px; font-weight: 500; min-width: 34px; }

/* Alert banner */
.pv-alert-banner { border: 1px solid var(--border); margin-bottom: 20px; overflow: hidden; }

.pv-alert-item {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 13px;
}

.pv-alert-item:last-child { border-bottom: none; }
.pv-alert-item.urgent  { background: var(--red-light);   border: 1.5px solid var(--red);   border-radius: var(--radius-sm); margin-bottom: 4px; }
.pv-alert-item.warning { background: var(--amber-light); border: 1.5px solid var(--amber);  border-radius: var(--radius-sm); margin-bottom: 4px; }
.pv-alert-item.info    { background: var(--surface);     border: 0.5px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 4px; }

.pv-alert-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  min-width: 72px;
  padding-top: 1px;
}

.pv-alert-label.urgent  { color: var(--red); }
.pv-alert-label.warning { color: var(--amber); }
.pv-alert-label.info    { color: var(--text-muted); }

/* Data panels */
.pv-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.pv-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 18px 20px;
}

.pv-panel-title  { font-family: 'DM Serif Display', serif; font-size: 16px; font-weight: 400; margin: 0 0 3px; }
.pv-panel-sub    { font-size: 11px; color: var(--text-muted); margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border-light); }

.pv-panel-full {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 18px 22px;
  margin-bottom: 20px;
}

/* Medications */
.pv-med-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

.pv-med-row:last-child { border-bottom: none; }
.pv-med-name  { font-size: 13px; font-weight: 500; color: var(--text); min-width: 160px; }
.pv-med-dose  { font-size: 11px; color: var(--text-muted); }

.pv-adherence-bar {
  flex: 1;
  height: 5px;
  background: var(--border-light);
  overflow: hidden;
}

.pv-adherence-fill     { height: 100%; background: var(--accent); }
.pv-adherence-fill.low { background: var(--red); }
.pv-adherence-fill.mid { background: var(--amber); }
.pv-adherence-pct      { font-size: 12px; font-weight: 500; min-width: 34px; text-align: right; }

/* Summary cards */
.pv-summary-card {
  background: var(--bg);
  border: 1px solid var(--border-light);
  padding: 14px 16px;
  margin-bottom: 10px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--text-muted);
}
.md-summary p { margin: 0 0 8px; font-size: 13px; line-height: 1.7; color: #333; }
.md-summary p:last-child { margin-bottom: 0; }
.md-summary ul, .md-summary ol { margin: 0 0 10px; padding-left: 20px; }
.md-summary li { font-size: 13px; line-height: 1.65; color: #333; margin-bottom: 3px; }
.md-summary strong { font-weight: 500; color: #111; }
.md-summary hr { border: none; border-top: 1px solid var(--border-light); margin: 12px 0; }
.md-summary-header { font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .07em; color: #111; padding: 12px 0 5px; border-bottom: 1px solid var(--border-light); margin-bottom: 8px; }
.md-summary-header:first-child { padding-top: 0; }

.pv-summary-card.new {
  border: 1.5px solid var(--accent);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-resting);
}

.pv-summary-meta {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  font-weight: 500;
}

@media (max-width: 1100px) {
  .pv-grid-2   { grid-template-columns: 1fr; }
  .pv-hdr-meta { grid-template-columns: repeat(2, 1fr); }
  .pv-sidebar  { width: 200px; }
}

/* ══════════════════════════════════════════════════════════════════════
   MOBILE — hamburger nav
   ══════════════════════════════════════════════════════════════════════ */

.nav-hamburger {
  display: none;
  background: none;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  width: 34px; height: 34px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  padding: 7px;
  flex-shrink: 0;
  transition: var(--transition);
}

.nav-hamburger span {
  display: block;
  width: 18px; height: 1.5px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-hamburger.open span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

.top-nav-mobile-menu {
  display: none;
  position: fixed;
  top: var(--nav-h);
  left: 0; right: 0;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  z-index: 998;
  padding: 6px 0 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.10);
}

.top-nav-mobile-menu.open { display: block; }

.mobile-nav-link {
  display: block;
  padding: 13px 24px;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition);
}

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

.mobile-nav-link.active {
  color: var(--accent);
  font-weight: 500;
  background: var(--green-light);
}

.mobile-nav-divider {
  height: 1px;
  background: var(--border-light);
  margin: 6px 0;
}

/* ══════════════════════════════════════════════════════════════════════
   MOBILE — provider sidebar toggle
   ══════════════════════════════════════════════════════════════════════ */

.pv-sidebar-toggle {
  display: none;
}

/* ══════════════════════════════════════════════════════════════════════
   MOBILE — 768px breakpoint (phones + small tablets)
   ══════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* ── Nav ── */
  .top-nav { padding: 0 14px; gap: 0; }
  .top-nav-brand { margin-right: auto; }
  .top-nav-links { display: none; }
  .top-nav-end { gap: 8px; margin-left: 10px; }
  .top-nav-user { display: none; }
  .top-nav-logout { display: none; }   /* in mobile menu instead */
  .nav-hamburger { display: flex; }

  /* ── Main content ── */
  .main-content { padding: 20px 16px; }
  .page-title { font-size: 1.6rem; }
  .page-header { margin-bottom: 20px; }

  /* ── Auth ── */
  .auth-card { padding: 24px 20px; }

  /* ── Quick cards ── */
  .quick-cards { grid-template-columns: repeat(2, 1fr); }

  /* ── Stats row — horizontal scroll on mobile ── */
  .stats-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .stats-row::-webkit-scrollbar { display: none; }
  .stat-card { min-width: 90px; flex: 0 0 90px; }

  /* ── Charts ── */
  .charts-grid { grid-template-columns: 1fr; }

  /* ── Forms ── */
  .form-row { flex-direction: column; }
  .form-row .form-group { min-width: 100%; }

  /* ── Settings ── */
  .settings-sections { max-width: 100%; }

  /* ── Flash messages ── */
  .flash-container { left: 12px; right: 12px; max-width: none; }

  /* ── Home medication widget ── */
  .home-med-widget { padding: 16px; }
  .med-dose-item   { padding: 10px 12px; }

  /* ── Provider shell — stack sidebar on top ── */
  body.pv-body .main-content {
    height: auto;
    overflow: visible;
  }

  .pv-shell {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  /* Sidebar toggle button — shown on mobile */
  .pv-sidebar-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--surface);
    border: none;
    border-bottom: 1px solid var(--border);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    text-align: left;
    color: var(--text);
    position: sticky;
    top: var(--nav-h);
    z-index: 50;
  }

  .pv-sidebar-toggle #pv-toggle-label { flex: 1; }
  .pv-toggle-arrow { color: var(--text-muted); font-size: 12px; }

  /* Sidebar — hidden by default, revealed by toggle */
  .pv-sidebar {
    display: none;
    width: 100%;
    max-height: 280px;
    height: auto;
    border-right: none;
    border-bottom: 2px solid var(--border);
    overflow-y: auto;
    position: static;
    align-self: auto;
  }

  .pv-sidebar.open { display: flex; }

  .pv-sidebar-head { padding: 12px 12px 10px; }

  .pv-main {
    padding: 16px 14px 48px;
    overflow-y: visible;
  }

  /* Provider header */
  .pv-patient-hdr { padding: 16px; }
  .pv-hdr-top { flex-direction: column; gap: 10px; }
  .pv-hdr-actions { align-self: flex-start; }
  .pv-hdr-name { font-size: 22px; }
  .pv-hdr-meta { grid-template-columns: repeat(2, 1fr); gap: 12px; }

  /* Controls */
  .pv-controls {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
  }

  /* Charts grid */
  .pv-grid-2 { grid-template-columns: 1fr; }

  /* Panels */
  .pv-panel-full { padding: 14px 14px; }
  .pv-panel      { padding: 14px 14px; }

  /* Med row — wrap on small screens */
  .pv-med-row { flex-wrap: wrap; }
  .pv-med-name { min-width: 100%; }

  /* Check-in table — horizontal scroll */
  .pv-panel-full .provider-table-wrap,
  .pv-panel-full table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   MOBILE — 600px breakpoint (medication widget stacking)
   ══════════════════════════════════════════════════════════════════════ */

@media (max-width: 600px) {
  .med-dose-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .med-dose-info  { width: 100%; }
  .med-dose-status {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
  }
  .med-time-input {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
  }
  .med-log-btn {
    flex: 1 1 auto;
    min-height: 44px;
    justify-content: center;
  }
  .med-remove-btn {
    flex: 0 0 100%;
    text-align: center;
    min-height: 36px;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   MOBILE — 480px breakpoint (small phones)
   ══════════════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
  html { font-size: 15px; }
  .top-nav { padding: 0 12px; }
  .main-content { padding: 16px 12px; }
  .page-title { font-size: 1.35rem; }

  .auth-shell { padding: 20px 12px; }
  .auth-card { padding: 20px 14px; }

  .quick-cards { grid-template-columns: 1fr 1fr; gap: 1px; }
  .quick-card  { padding: 14px 12px; gap: 10px; }
  .quick-card-icon { width: 30px; height: 30px; font-size: 1.1rem; }

  .stat-card { min-width: 76px; flex: 0 0 76px; }
  .stat-value { font-size: 1.4rem; }

  .pv-main { padding: 12px 10px 48px; }
  .pv-hdr-meta { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .pv-panel-full { padding: 12px 12px; }

  .btn-sm { padding: 6px 10px; font-size: 0.78rem; }

  /* Med widget touch targets */
  .med-log-btn    { min-height: 44px; }
  .med-remove-btn { min-height: 40px; }
}


/* ═══════════════════════════════════════════════════════════════════════
   PROVIDER DASHBOARD — Patient List Grid
   ═══════════════════════════════════════════════════════════════════════ */

.pd-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.pd-page-hdr {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.pd-page-title {
  font-family: 'DM Serif Display', serif;
  font-size: 28px;
  font-weight: 400;
  margin: 0 0 4px;
  color: var(--text);
}

.pd-page-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.pd-page-hdr-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pd-search {
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--border-light);
  background: var(--surface);
  color: var(--text);
  width: 220px;
  font-family: 'DM Sans', sans-serif;
}

.pd-search:focus {
  outline: none;
  border-color: var(--border);
  box-shadow: 0 0 0 2px var(--border-light);
}

/* Filter bar */
.pd-filter-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.pd-filter-btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 14px;
  border: 1px solid var(--border-light);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.pd-filter-btn:hover,
.pd-filter-btn.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

/* Patient grid */
.pd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.pd-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  padding: 20px;
  box-shadow: var(--shadow-resting);
}

.pd-card:hover {
  border-color: var(--border-mid);
  box-shadow: var(--shadow-lifted);
  text-decoration: none;
}

.pd-card-crisis {
  border: 1.5px solid #dc2626;
  background: var(--red-light);
}

.pd-card-alert {
  border: 1.5px solid var(--amber);
  background: var(--amber-light);
}

.pd-card-hdr {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.pd-card-avatar {
  width: 38px;
  height: 38px;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 500;
  flex-shrink: 0;
}

.pd-card-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.pd-card-email {
  font-size: 11px;
  color: var(--text-muted);
}

.pd-badge {
  font-size: 14px;
  line-height: 1;
}

.pd-badge-crisis { color: #dc2626; }

/* Stats in card */
.pd-card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border-light);
}

.pd-stat { text-align: center; }

.pd-stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.pd-stat-val {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

.pd-stat-low  { color: #dc2626; }
.pd-stat-good { color: var(--green); }

/* Meds chips */
.pd-card-meds {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 14px;
}

.pd-med-chip {
  font-size: 10px;
  border: 1px solid var(--border-light);
  padding: 2px 7px;
  color: var(--text-muted);
  background: var(--surface);
}

.pd-med-chip-more {
  font-weight: 500;
  color: var(--text);
}

/* Card footer */
.pd-card-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.pd-card-arrow {
  font-size: 14px;
  color: var(--text);
  opacity: 0.4;
  transition: opacity var(--transition), transform var(--transition);
}

.pd-card:hover .pd-card-arrow {
  opacity: 1;
  transform: translateX(3px);
}

/* Empty / no results */
.pd-empty {
  text-align: center;
  padding: 80px 20px;
}

.pd-empty-icon { font-size: 40px; margin-bottom: 16px; }

.pd-empty-title {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  font-weight: 400;
  margin-bottom: 10px;
}

.pd-empty-sub {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 400px;
  margin: 0 auto;
  line-height: 1.7;
}

.pd-no-results {
  text-align: center;
  padding: 40px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════════════
   PATIENT OVERVIEW — Header & Stats Bar
   ═══════════════════════════════════════════════════════════════════════ */

.pv-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.pv-breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
}

.pv-breadcrumb a:hover { color: var(--text); text-decoration: underline; }
.pv-breadcrumb-sep { opacity: .5; }

.ph-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.ph-header-left {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.ph-avatar {
  width: 48px;
  height: 48px;
  background: var(--text);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 500;
  flex-shrink: 0;
}

.ph-name {
  font-family: 'DM Serif Display', serif;
  font-size: 24px;
  font-weight: 400;
  margin: 0 0 4px;
}

.ph-email { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }

.ph-meds {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.ph-header-right { display: flex; gap: 8px; align-items: flex-start; }

/* Stats bar */
.ph-stats-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border: 1px solid var(--border-light);
  margin-bottom: 20px;
  background: var(--surface);
}

.ph-stat {
  padding: 16px 20px;
  border-right: 1px solid var(--border-light);
  text-align: center;
}

.ph-stat:last-child { border-right: none; }

.ph-stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 6px;
}

.ph-stat-val {
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
}

.ph-stat-warn { color: #dc2626; }

/* Sparkline wrapper */
.ph-sparkline-wrap {
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  margin-bottom: 20px;
}

/* ═══════════════════════════════════════════════════════════════════════
   APPOINTMENT HISTORY TIMELINE
   ═══════════════════════════════════════════════════════════════════════ */

.ah-section {
  background: var(--surface);
  border: 1px solid var(--border-light);
  padding: 24px;
  margin-bottom: 20px;
}

.ah-section-hdr {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.ah-timeline {
  position: relative;
  padding-left: 24px;
}

.ah-timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--border-light);
}

.ah-item {
  position: relative;
  margin-bottom: 20px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.ah-item-dot {
  position: absolute;
  left: -24px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border-light);
  border: 2px solid var(--surface);
  box-sizing: border-box;
}

.ah-item-active .ah-item-dot  { background: var(--text); }
.ah-item-done .ah-item-dot    { background: var(--green); }
.ah-item-cancelled .ah-item-dot { background: var(--text-muted); }

.ah-item-body {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border-light);
  padding: 14px 16px;
}

.ah-item-active .ah-item-body  { border: 1.5px solid var(--accent); background: var(--green-light); }
.ah-item-done .ah-item-body    { border: 1.5px solid var(--border); background: var(--surface); }
.ah-item-cancelled .ah-item-body { border: 1px solid var(--border-light); opacity: .7; }

.ah-item-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.ah-item-date {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.ah-item-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 2px 8px;
  margin-left: 8px;
}

.ah-badge-active    { background: var(--text); color: #fff; }
.ah-badge-completed { background: var(--green-light); color: var(--green); border: 1px solid var(--green); }
.ah-badge-cancelled { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border-light); }

.ah-item-preview {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.65;
}

.ah-empty {
  padding: 24px;
  background: var(--bg);
  border: 1px dashed var(--border-light);
  text-align: center;
}

/* ═══════════════════════════════════════════════════════════════════════
   APPOINTMENT WORKSPACE
   ═══════════════════════════════════════════════════════════════════════ */

/* Header */
.aw-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.aw-header-left {}
.aw-header-name {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  font-weight: 400;
  margin-bottom: 4px;
}

.aw-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Tabs */
.aw-tabs {
  display: flex;
  border-bottom: 2px solid var(--border-light);
  margin-bottom: 24px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.aw-tab {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 20px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color var(--transition);
}

.aw-tab:hover  { color: var(--text); }
.aw-tab.active { color: var(--text); border-bottom-color: var(--text); font-weight: 500; }

.aw-tab-pane { display: none; }
.aw-tab-pane.active { display: block; }

/* Appointment stepper */
.aw-stepper {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 24px;
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.aw-step {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  transition: background var(--transition);
}

.aw-step:hover { background: var(--bg); }

.aw-step-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.aw-step.active .aw-step-badge {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}

.aw-step-info { min-width: 0; }

.aw-step-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color var(--transition);
  white-space: nowrap;
  line-height: 1.25;
}

.aw-step.active .aw-step-label {
  color: var(--text);
  font-weight: 500;
}

.aw-step-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
}

.aw-step-line {
  flex-shrink: 0;
  height: 1px;
  width: 28px;
  background: var(--border-light);
  margin: 0 2px;
}

/* Guided Q&A */
.gq-section {
  margin-bottom: 24px;
}

.gq-section-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.gq-suggestion {
  background: var(--surface);
  border: 1px solid var(--border-light);
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.gq-suggestion:hover { border-color: var(--border); background: var(--bg); }

.gq-suggestion-cat {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 80px;
  padding-top: 2px;
}

.gq-suggestion-text {
  flex: 1;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}

.gq-suggestion-add {
  font-size: 11px;
  color: var(--green);
  font-weight: 500;
  white-space: nowrap;
  padding-top: 2px;
}

.gq-active-list { margin-bottom: 20px; }

.gq-item {
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.gq-item-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.gq-item-cat {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
}

.gq-item-remove {
  background: none;
  border: none;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
}

.gq-item-remove:hover { color: #dc2626; }

.gq-item-q {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.55;
  margin-bottom: 10px;
}

.gq-item-answer {
  width: 100%;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  box-sizing: border-box;
}

.gq-item-answer:focus { outline: none; border-color: var(--border); }

.gq-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.gq-custom-input {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border-light);
  background: var(--surface);
  color: var(--text);
}

.gq-custom-input:focus { outline: none; border-color: var(--border); }

/* Question Library */
.gq-library {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 20px;
  margin-top: 16px;
  max-height: 500px;
  overflow-y: auto;
}

.gq-library-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.gq-lib-cat { margin-bottom: 16px; }

.gq-lib-cat-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.gq-lib-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  margin-bottom: 4px;
  cursor: pointer;
  background: var(--bg);
  transition: border-color var(--transition);
}

.gq-lib-item:hover { border-color: var(--border); }

.gq-lib-text { font-size: 13px; color: var(--text); line-height: 1.5; }

.gq-lib-add {
  font-size: 11px;
  font-weight: 500;
  color: var(--green);
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  padding: 4px 8px;
}

/* Notes & Care Plan textareas */
.aw-field-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.aw-textarea {
  width: 100%;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  line-height: 1.65;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  box-sizing: border-box;
}

.aw-textarea:focus { outline: none; border-color: var(--border); }

/* Action items */
.aw-actions-list {
  margin-bottom: 16px;
}

.aw-action-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  background: var(--surface);
  margin-bottom: 6px;
}

.aw-action-done .aw-action-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.aw-action-check { width: 16px; height: 16px; accent-color: var(--green); flex-shrink: 0; cursor: pointer; }
.aw-action-text  { flex: 1; font-size: 13px; }
.aw-action-remove {
  background: none; border: none; font-size: 11px;
  color: var(--text-muted); cursor: pointer; padding: 2px 6px;
}
.aw-action-remove:hover { color: #dc2626; }

.aw-action-templates { margin-top: 4px; }

.aw-action-template-btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  padding: 4px 10px;
  border: 1px solid var(--border-light);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.aw-action-template-btn:hover { background: var(--text); color: #fff; border-color: var(--text); }

/* Scheduler */
.aw-schedule-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  padding: 24px;
  margin-bottom: 20px;
}

.aw-schedule-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 16px;
}

.aw-date-input {
  width: 100%;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  background: var(--surface);
  color: var(--text);
  box-sizing: border-box;
}

.aw-select {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  background: var(--surface);
  color: var(--text);
  box-sizing: border-box;
}

.aw-schedule-current {
  margin-top: 20px;
  padding: 16px;
  background: var(--green-light);
  border: 1px solid var(--green);
}

/* ─── Responsive overrides ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .pd-grid               { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .ph-stats-bar          { grid-template-columns: repeat(3, 1fr); }
  .ph-stat:nth-child(3)  { border-right: none; }
  .ph-stat:nth-child(4)  { border-top: 1px solid var(--border-light); }
  .ph-stat:nth-child(5)  { border-top: 1px solid var(--border-light); }
  .aw-schedule-grid      { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .pd-page               { padding: 16px 12px 48px; }
  .pd-grid               { grid-template-columns: 1fr; }
  .pd-card-stats         { grid-template-columns: repeat(2, 1fr); }
  .ph-stats-bar          { grid-template-columns: repeat(2, 1fr); }
  .ph-stat               { border-right: none; border-bottom: 1px solid var(--border-light); }
  .ah-section-hdr        { flex-direction: column; }
  .aw-tabs               { gap: 0; }
  .aw-tab                { padding: 8px 12px; font-size: 12px; }
  .aw-step               { padding: 8px 8px; gap: 8px; }
  .aw-step-badge         { width: 26px; height: 26px; font-size: 11px; }
  .aw-step-label         { font-size: 12px; }
  .aw-step-sub           { display: none; }
  .aw-step-line          { width: 14px; }
  .gq-suggestion         { flex-direction: column; gap: 6px; }
}


/* ═══════════════════════════════════════════════════════════════════════
   APPOINTMENT WORKSPACE — 3-column layout + Journal Sidebar
   ═══════════════════════════════════════════════════════════════════════ */

/* When the appointment body class is set, make pv-shell a 3-col flex */
body.pv-body-appt .pv-shell {
  display: flex;
  flex-direction: row;
}

/* Journal sidebar — right panel, sticky alongside scrolling main */
.js-sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease, opacity 0.2s ease;
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  align-self: flex-start;
}

.js-sidebar-collapsed {
  width: 0;
  opacity: 0;
  overflow: hidden;
  border-left: none;
}

/* Sidebar header */
.js-sidebar-head {
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface);
  position: relative;
  flex-shrink: 0;
}

.js-sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
  padding-right: 28px;
}

.js-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--text);
  color: #fff;
  font-size: 10px;
  font-weight: 500;
  border-radius: 10px;
}

.js-sidebar-meta {
  font-size: 10px;
  color: var(--text-muted);
  font-family: monospace;
  letter-spacing: .02em;
}

/* Collapse button — top right of sidebar header */
.js-collapse-btn {
  position: absolute;
  top: 14px;
  right: 10px;
  width: 22px;
  height: 22px;
  background: none;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  padding: 0;
}

.js-collapse-btn:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}

/* Scrollable entry list */
.js-entry-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

/* Individual journal entry */
.js-entry {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--transition);
}

.js-entry:last-child { border-bottom: none; }

.js-entry:hover { background: var(--bg); }

.js-entry-hdr {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.js-entry-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.js-entry-date {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.js-entry-type {
  font-size: 10px;
  text-transform: capitalize;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border-light);
  padding: 1px 6px;
  display: inline-block;
  width: fit-content;
}

.js-entry-chevron {
  font-size: 16px;
  color: var(--text-muted);
  transition: transform 0.15s ease;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 1px;
}

/* Preview (collapsed state) */
.js-entry-preview {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Full body (expanded state) */
.js-entry-body {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}

.js-entry-full {
  font-size: 12px;
  color: var(--text);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

/* AI reflection block inside expanded entry */
.js-entry-ai {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border: 0.5px solid var(--border-light);
  border-radius: var(--radius-sm);
}

.js-entry-ai-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.js-entry-ai-text {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.65;
  font-style: italic;
}

/* Empty state */
.js-empty {
  padding: 32px 16px;
  text-align: center;
}

.js-empty-icon {
  font-size: 28px;
  margin-bottom: 12px;
  opacity: .5;
}

.js-empty-text {
  font-size: 12px;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 8px;
}

.js-empty-sub {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Collapsed expand tab — vertical strip shown when sidebar is hidden */
.js-expand-tab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-right: none;
  padding: 12px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 100;
  transition: background var(--transition);
}

.js-expand-tab:hover { background: var(--bg); }

.js-expand-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  white-space: nowrap;
}

/* ── Responsive: hide journal sidebar on small screens ─────────────── */
@media (max-width: 1100px) {
  .js-sidebar { width: 240px; }
}

@media (max-width: 900px) {
  /* On tablet, sidebar sits below the main content as a drawer */
  body.pv-body-appt .pv-shell {
    flex-direction: column;
  }

  .js-sidebar {
    width: 100%;
    max-height: 320px;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .js-sidebar-collapsed {
    width: 100%;
    max-height: 0;
    border-top: none;
  }

  .js-expand-tab {
    position: static;
    transform: none;
    flex-direction: row;
    width: 100%;
    border: none;
    border-top: 1px solid var(--border);
    padding: 8px 14px;
    justify-content: flex-start;
  }

  .js-expand-label {
    writing-mode: horizontal-tb;
    transform: none;
    font-size: 12px;
  }
}
