:root {
  --bg: #f4f1fb;
  --card: #ffffff;
  --ink: #231942;
  --muted: #6f6690;
  --line: #e4dbf5;
  --primary: #6d4aff;
  --primary-soft: #efe9ff;
  --success-soft: #e7f8ef;
  --warning-soft: #fff6dc;
  --danger-soft: #ffe7ea;
  --info-soft: #e8f2ff;
  --shadow: 0 10px 24px rgba(61, 42, 108, 0.10);
  --radius: 20px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #faf7ff, #f2eefb 35%, #f4f1fb);
  color: var(--ink);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; min-height: 44px; }
label { display: block; font-size: 0.92rem; font-weight: 600; }
label input, label select, label textarea { margin-top: 8px; font-weight: 500; }

.app-shell { max-width: 760px; margin: 0 auto; min-height: 100vh; padding: 18px 16px 36px; }
.app-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.app-header h1 { margin: 2px 0 0; font-size: 1.55rem; }
.eyebrow { margin: 0; color: var(--primary); text-transform: uppercase; letter-spacing: .08em; font-size: .74rem; font-weight: 800; }
.muted { color: var(--muted); margin: 4px 0 0; }
.card {
  background: var(--card);
  border: 1px solid rgba(109, 74, 255, 0.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.highlight-card { background: linear-gradient(135deg, #fff, #f3eeff); }
.info-card { background: var(--info-soft); }
.section-head, .dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sticky-head { position: sticky; top: 0; z-index: 4; background: linear-gradient(180deg, #f4f1fb 72%, rgba(244,241,251,0)); padding-bottom: 10px; }
.quick-actions, .tool-grid { display: grid; gap: 10px; }
.quick-actions { grid-template-columns: 1fr auto; margin: 14px 0 16px; }
.stack-list { display: grid; gap: 12px; }
.view { display: none; }
.view.active { display: block; }
.primary-btn, .secondary-btn, .danger-btn, .icon-btn, .text-btn, .label-btn {
  border-radius: 14px; padding: 12px 14px; font-weight: 700;
}
.primary-btn { background: var(--primary); color: #fff; box-shadow: 0 8px 18px rgba(109,74,255,.25); }
.secondary-btn, .label-btn { background: var(--primary-soft); color: var(--primary); }
.danger-btn { background: #e84545; color: white; }
.icon-btn { background: var(--card); box-shadow: var(--shadow); min-width: 46px; min-height: 46px; font-size: 1.2rem; }
.text-btn { color: var(--primary); padding-left: 0; }
.small { padding: 10px 12px; font-size: .9rem; }
.facility-card, .patient-card, .entry-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.facility-card { display: grid; gap: 10px; }
.facility-top, .patient-top { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.facility-name, .patient-name { margin: 0; font-size: 1.08rem; font-weight: 800; }
.badge-row, .meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.badge {
  padding: 6px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700;
  background: var(--primary-soft); color: var(--primary);
}
.badge.success { background: var(--success-soft); color: #1d7a46; }
.badge.warning { background: var(--warning-soft); color: #8a6500; }
.badge.danger { background: var(--danger-soft); color: #b42335; }
.badge.info { background: var(--info-soft); color: #0b5cad; }
.patient-card.diabetic { border-left: 6px solid #ffb020; }
.patient-card.hospice { border-left: 6px solid #7b61ff; }
.patient-card.pending-alert { box-shadow: 0 0 0 2px rgba(232,69,69,.18), var(--shadow); }
.patient-card.a1c-alert { box-shadow: 0 0 0 2px rgba(255,176,32,.25), var(--shadow); }
.pill-count {
  min-width: 30px; height: 30px; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 800;
}
.mobile-dialog, .sheet-dialog { width: min(760px, 100%); border: none; border-radius: 24px 24px 0 0; padding: 0; max-height: 94vh; }
.mobile-dialog::backdrop, .sheet-dialog::backdrop { background: rgba(28, 23, 43, .44); }
.dialog-body { padding: 14px 16px 28px; overflow: auto; max-height: calc(94vh - 120px); }
.form-stack { display: grid; gap: 16px; }
.subsection { border-top: 1px solid var(--line); padding-top: 16px; }
.subsection h3 { margin: 0; }
.subsection-head { margin-bottom: 10px; }
.multi-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.two-col, .toggle-grid { display: grid; gap: 12px; }
.toggle-grid { grid-template-columns: repeat(2, 1fr); }
.toggle-pill {
  display: flex; align-items: center; gap: 10px; background: #faf8ff; border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px;
}
.inline-toggle { margin-top: 8px; }
.entry-list { display: grid; gap: 12px; }
.dialog-actions, .sheet-body { padding: 14px 16px 18px; }
.dialog-actions { display: flex; gap: 10px; align-items: center; background: #fff; border-top: 1px solid var(--line); }
.sticky-actions { position: sticky; bottom: 0; }
.grow { flex: 1; }
.hidden { display: none !important; }
.text-danger { color: #b42335; font-weight: 700; padding-left: 0; }
.small-note { margin-top: 14px; }
.facility-banner { margin: 4px 0 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.today-grid { display: grid; gap: 10px; margin-top: 12px; }
.today-item { background: rgba(255,255,255,.75); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.empty-state { text-align: center; padding: 28px 18px; color: var(--muted); }
@media (min-width: 640px) {
  .two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
