/* ══════════════════════════════════════════════════════════════════
   SuarezHealth — SuarezCloud Design System
   Bootstrap 5 theme overrides + custom components
   Brand: SuarezCloud (navy / azure / white) + Cloudy mascot
   ══════════════════════════════════════════════════════════════════ */

/* ── Design tokens — SuarezCloud brand palette ── */
:root {
  /* Core brand colors (from design-tokens/colors.json) */
  --sh-ink:        #0E1D2F;   /* navy900 */
  --sh-ink-2:      #1E2A3E;   /* navy800 */
  --sh-paper:      #f8f9fb;
  --sh-paper-2:    #ffffff;
  --sh-line:       #dce4ee;
  --sh-line-2:     #c0ccd9;
  --sh-muted:      #6b7a8d;
  --sh-text:       #1a2533;
  --sh-azure:      #4DA3E3;   /* azure500 — brand accent */
  --sh-azure-2:    #2d89d4;
  --sh-azure-soft: #e8f4fd;
  --sh-teal:       #4DA3E3;   /* alias → azure for clinical contexts */
  --sh-teal-2:     #2d89d4;
  --sh-teal-soft:  #e8f4fd;
  --sh-sand:       #D9A96A;   /* sand400 — Cloudy accent */
  --sh-brown:      #8B5E34;   /* brown600 */
  --sh-coral:      #D9534F;   /* semantic error */
  --sh-coral-soft: #fef2f2;
  --sh-amber:      #F2B84B;   /* semantic warning */
  --sh-amber-soft: #fffbeb;
  --sh-danger:     #c0392b;
  --sh-success:    #2E9D67;   /* semantic success */
  --sh-success-soft: #ecfdf5;
  --sh-violet:     #7c3aed;
  --sh-violet-soft:#f5f3ff;

  /* Bootstrap mappings */
  --bs-primary:           var(--sh-ink);
  --bs-primary-rgb:       14, 29, 47;
  --bs-secondary:         var(--sh-muted);
  --bs-secondary-rgb:     107, 122, 141;
  --bs-success:           var(--sh-success);
  --bs-success-rgb:       46, 157, 103;
  --bs-danger:            var(--sh-coral);
  --bs-danger-rgb:        217, 83, 79;
  --bs-warning:           var(--sh-amber);
  --bs-warning-rgb:       242, 184, 75;
  --bs-info:              var(--sh-azure);
  --bs-info-rgb:          77, 163, 227;
  --bs-body-bg:           var(--sh-paper);
  --bs-body-color:        var(--sh-text);
  --bs-body-font-family:  'Poppins', 'Inter', 'Segoe UI', system-ui, sans-serif;
  --bs-body-font-size:    0.9375rem;
  --bs-border-color:      var(--sh-line);
  --bs-border-radius:     12px;
  --bs-border-radius-sm:  8px;
  --bs-border-radius-lg:  16px;
  --bs-link-color:        var(--sh-azure);
  --bs-link-hover-color:  var(--sh-azure-2);
  --bs-card-bg:           var(--sh-paper-2);
  --bs-card-border-color: var(--sh-line);
  --bs-card-border-radius: var(--bs-border-radius);
  --bs-card-cap-bg:       transparent;
  --bs-box-shadow:        0 1px 3px rgba(14,29,47,.06), 0 4px 16px -4px rgba(14,29,47,.1);

  /* Legacy aliases (keep inline template styles working) */
  --ink:       var(--sh-ink);
  --ink-2:     var(--sh-ink-2);
  --paper:     var(--sh-paper);
  --paper-2:   var(--sh-paper-2);
  --line:      var(--sh-line);
  --muted:     var(--sh-muted);
  --text:      var(--sh-text);
  --coral:     var(--sh-coral);
  --coral-soft:var(--sh-coral-soft);
  --amber:     var(--sh-amber);
  --teal:      var(--sh-azure);
  --teal-soft: var(--sh-azure-soft);
  --danger:    var(--sh-danger);
  --r:         12px;
  --r-sm:      8px;
  --shadow:    var(--bs-box-shadow);
}

/* ── Dark mode ── */
.app.dark {
  --sh-ink:        #d4e4f0;
  --sh-ink-2:      #93c5e8;
  --sh-paper:      #0b1520;
  --sh-paper-2:    #111e2d;
  --sh-line:       #1e3045;
  --sh-line-2:     #2a4460;
  --sh-muted:      #7a93a8;
  --sh-text:       #d4e4f0;
  --sh-teal:       #22d3ee;
  --sh-teal-2:     #06b6d4;
  --sh-teal-soft:  #0c2a35;
  --sh-coral:      #f87171;
  --sh-coral-soft: #2d1515;
  --sh-amber:      #fbbf24;
  --sh-amber-soft: #1f1a08;
  --sh-danger:     #f87171;
  --sh-success:    #34d399;
  --sh-success-soft: #0a2318;
  --sh-violet:     #a78bfa;
  --sh-violet-soft:#1a1130;
  --bs-body-bg:    var(--sh-paper);
  --bs-body-color: var(--sh-text);
  --bs-card-bg:    var(--sh-paper-2);
  --bs-border-color: var(--sh-line);
  --bs-box-shadow: 0 1px 3px rgba(0,0,0,.3), 0 8px 24px -8px rgba(0,0,0,.6);
  color-scheme: dark;
}

/* ── Typography helpers ── */
.mono    { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-variant-numeric: tabular-nums; }
.serif   { font-family: 'Poppins', sans-serif; }
.eyebrow { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--sh-muted); font-weight: 700; }
h1.sh-title { font-weight: 700; font-size: 28px; line-height: 1.1; margin: 4px 0 16px; color: var(--sh-ink); letter-spacing: -.02em; }

/* ── App shell ── */
* { scrollbar-color: var(--sh-line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--sh-line-2); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--sh-muted); background-clip: padding-box; }
::selection { background: var(--sh-teal); color: #fff; }

body { background: var(--sh-paper); }
.app {
  max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh;
  position: relative; background: var(--sh-paper);
}
.sh-view { padding: 0 20px 110px; animation: sh-rise .3s cubic-bezier(.2,.8,.2,1); }
@keyframes sh-rise { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }

/* ── Accessibility: visible focus ring everywhere, keyboard-only ── */
:focus { outline: none; }
:focus-visible {
  outline: 2.5px solid var(--sh-teal); outline-offset: 2px; border-radius: 4px;
}
.btn:focus-visible, .sh-ic:focus-visible, .sh-kpi:focus-visible, .sh-row:focus-visible,
.sh-chip:focus-visible, .sh-nav a:focus-visible, .sh-check:focus-visible {
  outline: 2.5px solid var(--sh-teal); outline-offset: 2px;
}

/* ── Skip-to-content link (keyboard/screen-reader users) ── */
.sh-skip {
  position: absolute; left: 12px; top: -60px; z-index: 999;
  background: var(--sh-ink); color: #fff; padding: 10px 16px;
  border-radius: var(--r-sm); font-size: 13px; font-weight: 700;
  text-decoration: none; transition: top .15s;
}
.sh-skip:focus { top: 12px; }

/* ── Empty state (shared pattern for "nothing here yet" screens) ── */
.sh-empty {
  text-align: center; padding: 48px 20px 40px; color: var(--sh-muted);
}
.sh-empty .material-symbols-rounded {
  font-size: 40px; color: var(--sh-line-2); display: block; margin: 0 auto 12px;
}
.sh-empty .sh-empty-title { font-size: 15px; font-weight: 700; color: var(--sh-text); margin-bottom: 4px; }
.sh-empty .sh-empty-sub { font-size: 13px; line-height: 1.5; max-width: 320px; margin: 0 auto; }
.sh-empty .btn { margin-top: 16px; }

/* ── Skeleton loading placeholder ── */
.sh-skel {
  background: linear-gradient(90deg, var(--sh-line) 25%, var(--sh-line-2) 37%, var(--sh-line) 63%);
  background-size: 400% 100%; animation: sh-skel-shine 1.4s ease infinite;
  border-radius: 8px;
}
@keyframes sh-skel-shine { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ── Global interactive polish: press feedback ── */
.btn:active, .sh-kpi:active, .sh-row:active, .sh-chip:active, .sh-ic:active { transform: scale(.97); }
.btn, .sh-kpi, .sh-row, .sh-chip, .sh-ic { transition: transform .1s ease, border-color .15s, box-shadow .15s, background .15s, color .15s; }

@media (prefers-reduced-motion: reduce) {
  .sh-view, .sh-skel, .btn, .sh-kpi, .sh-row, .sh-chip, .sh-ic { animation: none !important; transition: none !important; }
}

/* ── Theme/lang toolbar (top-right) ── */
.sh-tt { position: absolute; top: 14px; right: 12px; z-index: 9; display: flex; align-items: center; gap: 4px; }
.sh-tt button { width:34px;height:34px;border-radius:50%;border:1.5px solid var(--sh-line);background:var(--sh-paper-2);color:var(--sh-muted);cursor:pointer;display:grid;place-items:center;transition:border-color .15s,color .15s; }
.sh-tt button:hover { border-color: var(--sh-teal); color: var(--sh-teal); }
.sh-tt select { height:32px;border:1.5px solid var(--sh-line);border-radius:16px;background:var(--sh-paper-2);color:var(--sh-muted);font-size:11px;cursor:pointer;padding:0 8px;font-family:inherit;font-weight:600; }

/* ── Language select (top bar inline) ── */
.sh-lang-select { height:32px;border:1.5px solid var(--sh-line);border-radius:16px;background:var(--sh-paper-2);color:var(--sh-muted);font-size:11px;cursor:pointer;padding:0 8px;font-family:inherit;font-weight:700; }

/* ── Contextual tips (collapsible) ── */
.sh-tips[open] .sh-tips-chevron { transform:rotate(180deg); }
.sh-tips-chevron { transition:transform .2s; }

/* ── Assistant example buttons ── */
.sh-example-btn { background:none;border:none;padding:2px 0;text-align:left;color:inherit;font-size:inherit;cursor:pointer;line-height:inherit; }
.sh-example-btn:hover { text-decoration:underline; }

/* ── Bootstrap button overrides ── */
.btn {
  border-radius: var(--r); padding: .625rem .875rem;
  font-family: 'Poppins'; font-weight: 600; font-size: 14px;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn-lg  { font-size: 15px; padding: .75rem 1.25rem; }
.btn-sm  { font-size: 12.5px; padding: .375rem .625rem; border-radius: var(--r-sm); }

.btn-primary { background: var(--sh-ink); border-color: var(--sh-ink); color: #fff; }
.btn-primary:hover, .btn-primary:focus { background: var(--sh-ink-2); border-color: var(--sh-ink-2); color: #fff; }

.btn-teal  { background: var(--sh-teal); border-color: var(--sh-teal); color: #fff; }
.btn-teal:hover { background: var(--sh-teal-2); border-color: var(--sh-teal-2); color: #fff; }

.btn-coral { background: var(--sh-coral); border-color: var(--sh-coral); color: #fff; }
.btn-coral:hover { background: var(--sh-danger); border-color: var(--sh-danger); color: #fff; }

.btn-outline-secondary { border-color: var(--sh-line-2); color: var(--sh-muted); background: transparent; }
.btn-outline-secondary:hover { background: var(--sh-line); color: var(--sh-ink); border-color: var(--sh-line-2); }

/* ── Bootstrap form overrides ── */
.form-control, .form-select {
  border-color: var(--sh-line); background: var(--sh-paper-2); color: var(--sh-text);
  font-family: 'Poppins'; font-size: 14.5px; border-radius: var(--r-sm);
  padding: .625rem .875rem; border-width: 1.5px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--sh-teal); box-shadow: 0 0 0 3px rgba(8,145,178,.12);
  background: var(--sh-paper-2); color: var(--sh-text);
}
.form-label { font-size: 12px; color: var(--sh-muted); font-weight: 700; margin-bottom: 4px; letter-spacing: .04em; text-transform: uppercase; }
.form-text  { font-size: 11.5px; color: var(--sh-muted); }

/* ── Bootstrap card overrides ── */
.card { box-shadow: var(--bs-box-shadow); border-color: var(--sh-line); border-width: 1.5px; }
.card-body { padding: 1rem 1.125rem; }
.card-header { border-bottom-color: var(--sh-line); padding: .75rem 1.125rem; font-weight: 600; font-size: 13px; color: var(--sh-muted); text-transform: uppercase; letter-spacing: .06em; }

/* ── Badge overrides ── */
.badge { font-weight: 600; font-size: 11px; padding: .25em .6em; border-radius: 6px; }

/* ── Alert overrides ── */
.alert-danger  { background: var(--sh-coral-soft); border-color: rgba(220,38,38,.3); color: var(--sh-danger); }
.alert-success { background: var(--sh-success-soft); border-color: rgba(5,150,105,.3); color: var(--sh-success); }
.alert-warning { background: var(--sh-amber-soft); border-color: rgba(217,119,6,.3); color: #92400e; }
.alert-info    { background: var(--sh-teal-soft); border-color: rgba(8,145,178,.3); color: var(--sh-teal-2); }

/* ── Table overrides ── */
.table { --bs-table-border-color: var(--sh-line); font-size: 13.5px; }
.table th { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--sh-muted); padding: .5rem .75rem; }
.table td { padding: .625rem .75rem; color: var(--sh-text); vertical-align: middle; }
.table-hover tbody tr:hover { background: color-mix(in srgb, var(--sh-teal) 4%, var(--sh-paper)); }

/* ══════════════════════════════════════════
   LAYOUT COMPONENTS
   ══════════════════════════════════════════ */

/* ── Top bar ── */
.sh-top {
  display:flex; align-items:center; justify-content:space-between;
  padding: 16px 0 12px; position: sticky; top: 0;
  background: linear-gradient(var(--sh-paper) 75%, transparent);
  z-index: 5;
}

/* ── Section header ── */
.sh-sect { display:flex; align-items:center; justify-content:space-between; margin: 20px 0 10px; }
.sh-sect h2 { font-weight: 700; font-size: 16px; color: var(--sh-ink); margin: 0; letter-spacing: -.01em; }
.sh-sect a  { font-size: 12.5px; color: var(--sh-teal); font-weight: 600; text-decoration: none; }
.sh-sect a:hover { color: var(--sh-teal-2); text-decoration: underline; }

/* ── Icon button ── */
.sh-ic {
  width:36px; height:36px; border-radius:50%;
  border: 1.5px solid var(--sh-line); background: var(--sh-paper-2);
  display: grid; place-items: center; color: var(--sh-muted);
  cursor: pointer; text-decoration: none; transition: border-color .15s, color .15s;
}
.sh-ic:hover { border-color: var(--sh-teal); color: var(--sh-teal); }
.sh-ic .material-symbols-rounded { font-size: 18px; }

/* ── Utility ── */
.text-teal    { color: var(--sh-teal)    !important; }
.text-coral   { color: var(--sh-coral)   !important; }
.text-success { color: var(--sh-success) !important; }
.text-muted   { color: var(--sh-muted)   !important; }
.text-danger  { color: var(--sh-danger)  !important; }
.text-amber   { color: var(--sh-amber)   !important; }
.bg-teal-soft    { background: var(--sh-teal-soft)    !important; }
.bg-coral-soft   { background: var(--sh-coral-soft)   !important; }
.bg-success-soft { background: var(--sh-success-soft) !important; }
.bg-amber-soft   { background: var(--sh-amber-soft)   !important; }
.fp { font-size:11px;font-weight:700;padding:3px 9px;border-radius:20px;color:var(--c);border:1.5px solid var(--c);background:transparent;white-space:nowrap;flex:none; }

/* ── Login / centered pages ── */
.sh-center { min-height:100dvh; display:flex; flex-direction:column; justify-content:center; padding:32px 24px; }
.sh-logo   { font-weight: 800; font-size: 26px; color: var(--sh-ink); letter-spacing: -.03em; }
.sh-logo span { color: var(--sh-teal); }
.sh-msg    { padding: 11px 14px; border-radius: var(--r-sm); font-size: 13.5px; margin-bottom: 12px; border: 1.5px solid; }
.sh-msg.err { background: var(--sh-coral-soft); border-color: rgba(220,38,38,.3); color: var(--sh-danger); }
.sh-msg.ok  { background: var(--sh-success-soft); border-color: rgba(5,150,105,.3); color: var(--sh-success); }

/* ══════════════════════════════════════════
   KPI CARDS
   ══════════════════════════════════════════ */
.sh-kpi {
  background: var(--sh-paper-2);
  border: 1.5px solid var(--sh-line);
  border-radius: var(--r);
  padding: 14px 15px 12px;
  display: flex; flex-direction: column; gap: 2px;
  position: relative; overflow: hidden;
  text-decoration: none; color: inherit;
  box-shadow: var(--bs-box-shadow);
  transition: border-color .15s, box-shadow .15s;
}
.sh-kpi:hover { border-color: var(--sh-teal); box-shadow: 0 2px 12px -4px rgba(8,145,178,.2); }
.sh-kpi::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--sh-teal); border-radius: 3px 0 0 3px;
}
.sh-kpi.warn::before { background: var(--sh-amber); }
.sh-kpi.hi::before   { background: var(--sh-coral); }
.sh-kpi.ok::before   { background: var(--sh-success); }
.sh-kpi .sh-kpi-l { font-size: 10.5px; color: var(--sh-muted); letter-spacing: .06em; text-transform: uppercase; font-weight: 700; }
.sh-kpi .sh-kpi-v { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 22px; font-weight: 600; color: var(--sh-ink); margin-top: 4px; line-height: 1; }
.sh-kpi .sh-kpi-u { font-size: 10.5px; color: var(--sh-muted); margin-top: 2px; }

/* ── KPI 2-column grid ── */
.sh-kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }

/* ══════════════════════════════════════════
   ROW ITEMS (list cards)
   ══════════════════════════════════════════ */
.sh-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--sh-paper-2);
  border: 1.5px solid var(--sh-line); border-radius: var(--r);
  margin-bottom: 8px; box-shadow: var(--bs-box-shadow);
  text-decoration: none; color: inherit;
  transition: border-color .15s;
}
.sh-row:hover { border-color: var(--sh-line-2); }
.sh-row .sh-gr { flex: 1; min-width: 0; }
.sh-row .sh-t  { font-weight: 600; color: var(--sh-text); font-size: 14px; line-height: 1.3; }
.sh-row .sh-s  { font-size: 12px; color: var(--sh-muted); margin-top: 1px; }

/* ── Emoji/icon badge ── */
.sh-em {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; font-size: 16px; flex: none;
}
.sh-em .material-symbols-rounded { font-size: 18px; }
.sh-em.teal    { background: var(--sh-teal-soft);    color: var(--sh-teal-2); }
.sh-em.coral   { background: var(--sh-coral-soft);   color: var(--sh-coral); }
.sh-em.amber   { background: var(--sh-amber-soft);   color: var(--sh-amber); }
.sh-em.success { background: var(--sh-success-soft); color: var(--sh-success); }
.sh-em.muted   { background: var(--sh-line);         color: var(--sh-muted); }
.sh-em.danger  { background: var(--sh-coral-soft);   color: var(--sh-danger); }
.sh-em.violet  { background: var(--sh-violet-soft);  color: var(--sh-violet); }

/* ── Medication row ── */
.sh-med-row { cursor: pointer; }
.sh-med-row.past-due { border-color: rgba(185,28,28,.4); background: var(--sh-coral-soft); }

/* ── Check circle — 44px tap target (most frequent tap in the app), visible dot stays 24px via ::before so the touch zone grows without the UI looking oversized ── */
.sh-check {
  width: 44px; height: 44px; border-radius: 50%;
  border: none; background: none; flex: none;
  display: grid; place-items: center;
}
.sh-check::before {
  content: ""; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--sh-line-2);
  transition: border-color .15s, background .15s;
}
.sh-check:hover::before { border-color: var(--sh-success); }
.sh-check.done::before  { background: var(--sh-success); border-color: var(--sh-success); }
.sh-check:hover { border-color: var(--sh-success); }
.sh-check.done  { background: var(--sh-success); border-color: var(--sh-success); color: #fff; }

/* ══════════════════════════════════════════
   PATIENT HEADER
   ══════════════════════════════════════════ */
.sh-patient-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; background: var(--sh-paper-2);
  border: 1.5px solid var(--sh-line); border-radius: var(--r);
  margin-bottom: 16px; box-shadow: var(--bs-box-shadow);
}
.sh-patient-avatar {
  width: 52px; height: 52px; border-radius: 50%; flex: none;
  background: var(--sh-teal); color: #fff;
  display: grid; place-items: center;
  font-size: 20px; font-weight: 700;
  border: 2.5px solid var(--sh-paper-2);
  box-shadow: 0 0 0 2px var(--sh-teal-soft);
  overflow: hidden;
}
.sh-patient-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sh-patient-info { flex: 1; min-width: 0; }
.sh-patient-name { font-size: 17px; font-weight: 700; color: var(--sh-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.sh-patient-meta { font-size: 12px; color: var(--sh-muted); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.sh-patient-badges { display: flex; gap: 5px; margin-top: 5px; flex-wrap: wrap; }
.sh-badge {
  font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 20px;
  letter-spacing: .04em; text-transform: uppercase;
}
.sh-badge.teal    { background: var(--sh-teal-soft);    color: var(--sh-teal-2); }
.sh-badge.coral   { background: var(--sh-coral-soft);   color: var(--sh-coral); }
.sh-badge.amber   { background: var(--sh-amber-soft);   color: var(--sh-amber); }
.sh-badge.muted   { background: var(--sh-line);         color: var(--sh-muted); }
.sh-badge.success { background: var(--sh-success-soft); color: var(--sh-success); }
.sh-badge.violet  { background: var(--sh-violet-soft);  color: var(--sh-violet); }
.sh-badge.navy    { background: color-mix(in srgb, var(--sh-ink) 10%, transparent); color: var(--sh-ink); }

/* ══════════════════════════════════════════
   APPOINTMENT CARD
   ══════════════════════════════════════════ */
.sh-appt-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; background: var(--sh-paper-2);
  border: 1.5px solid var(--sh-line); border-radius: var(--r);
  margin-bottom: 14px; box-shadow: var(--bs-box-shadow);
  text-decoration: none; color: inherit;
}
.sh-appt-date {
  display: flex; flex-direction: column; align-items: center;
  min-width: 46px; text-align: center;
  padding: 6px 8px; border-radius: 10px;
  background: var(--sh-teal-soft);
}
.sh-appt-date .sh-appt-day   { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 22px; font-weight: 600; color: var(--sh-teal-2); line-height: 1; }
.sh-appt-date .sh-appt-month { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--sh-teal); margin-top: 1px; }
.sh-appt-info .sh-appt-title { font-weight: 600; color: var(--sh-ink); font-size: 14px; }
.sh-appt-info .sh-appt-sub   { font-size: 12px; color: var(--sh-muted); margin-top: 2px; }

/* ══════════════════════════════════════════
   MEDICATION TIMELINE
   ══════════════════════════════════════════ */
.sh-meds-group-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 700; color: var(--sh-muted);
  text-transform: uppercase; letter-spacing: .08em;
  margin: 16px 0 6px; padding: 0 2px;
}
.sh-meds-group-label::after {
  content: ""; flex: 1; height: 1px; background: var(--sh-line);
}
.sh-meds-group-label .material-symbols-rounded { font-size: 14px; }

/* ══════════════════════════════════════════
   NAVIGATION — Bottom (mobile) / Sidebar (desktop)
   ══════════════════════════════════════════ */
.sh-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 480px; margin: 0 auto;
  display: flex; justify-content: space-around;
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  background: rgba(248,249,251,.94); backdrop-filter: blur(14px);
  border-top: 1.5px solid var(--sh-line); z-index: 100;
}
.app.dark .sh-nav { background: rgba(11,21,32,.94); }

.sh-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 10px; color: var(--sh-muted); font-weight: 700;
  padding: 4px 10px; border-radius: 10px; text-decoration: none;
  letter-spacing: .02em; text-transform: uppercase;
  transition: color .15s;
}
.sh-nav a .gi { font-size: 21px; transition: color .15s; }
.sh-nav a.act  { color: var(--sh-ink); }
.sh-nav a.act .gi { color: var(--sh-teal); }
.sh-nav a.fab .gi {
  background: var(--sh-teal); color: #fff;
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; margin-top: -20px;
  box-shadow: 0 6px 20px -4px rgba(8,145,178,.5); font-size: 22px;
  transition: background .15s;
}
.sh-nav a.fab:hover .gi { background: var(--sh-teal-2); }

/* ── Secondary nav (hidden mobile; sidebar on desktop) ── */
.sh-nav-secondary { display: none; }
.sh-nav-group-label { display: none; }

/* ── "More" button (mobile only) ── */
/* Cloudy brand block hidden on mobile (shown only in desktop sidebar) */
.sh-nav-brand { display: none; }

.sh-nav-more-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 10px; color: var(--sh-muted); font-weight: 700;
  padding: 4px 10px; border-radius: 10px;
  background: none; border: none; cursor: pointer;
  font-family: 'Poppins', sans-serif; letter-spacing: .02em; text-transform: uppercase;
}
.sh-nav-more-btn .gi { font-size: 21px; }
.sh-nav-more-btn[aria-expanded="true"] { color: var(--sh-ink); }
.sh-nav-more-btn[aria-expanded="true"] .gi { color: var(--sh-teal); }
.sh-nav-fab-gap { width: 44px; display: inline-block; }

/* ── More drawer backdrop ── */
.sh-more-backdrop {
  display: none; position: fixed; inset: 0; z-index: 199;
  background: rgba(15,43,61,.3); backdrop-filter: blur(3px);
}
.sh-more-backdrop.open { display: block; }

/* ── More drawer (slide-up sheet) ── */
.sh-more-drawer {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 480px; margin: 0 auto; z-index: 200;
  background: var(--sh-paper-2);
  border-radius: 20px 20px 0 0;
  border-top: 1.5px solid var(--sh-line);
  padding: 0 20px calc(env(safe-area-inset-bottom) + 80px);
  box-shadow: 0 -12px 40px -8px rgba(15,43,61,.15);
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.2,.8,.2,1);
}
.sh-more-drawer.open { transform: translateY(0); }
.sh-more-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--sh-line-2); margin: 14px auto 18px; }

.sh-more-drawer a {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 4px; border-bottom: 1px solid var(--sh-line);
  text-decoration: none; color: var(--sh-text); font-size: 14.5px; font-weight: 500;
}
.sh-more-drawer a:last-child { border-bottom: none; }
.sh-more-drawer a .gi { font-size: 20px; color: var(--sh-muted); flex: none; }
.sh-more-drawer .sh-nav-group-label {
  display: block; font-size: 9.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--sh-muted); padding: 14px 4px 2px; opacity: .6; border-bottom: none;
}

/* ══════════════════════════════════════════
   SPECIALTY COMPONENTS
   ══════════════════════════════════════════ */

/* ── Chat bar (assistant) ── */
.sh-chatbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 480px; margin: 0 auto;
  display: flex; gap: 8px; align-items: center;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--sh-paper); border-top: 1.5px solid var(--sh-line); z-index: 20;
}
.sh-chatbar input {
  flex: 1; min-width: 0; padding: 12px 16px;
  border: 1.5px solid var(--sh-line); border-radius: 24px;
  background: var(--sh-paper-2); font-family: inherit;
  font-size: 15px; color: var(--sh-text);
  transition: border-color .15s, box-shadow .15s;
}
.sh-chatbar input:focus { outline: none; border-color: var(--sh-teal); box-shadow: 0 0 0 3px rgba(8,145,178,.12); }
.sh-chatbar .sh-sendbtn {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  border: none; background: var(--sh-teal); color: #fff;
  display: grid; place-items: center; cursor: pointer;
  transition: background .15s, transform .08s;
}
.sh-chatbar .sh-sendbtn:hover  { background: var(--sh-teal-2); }
.sh-chatbar .sh-sendbtn:active { transform: scale(.94); }

/* Chat bubbles */
.sh-chat-msg { display: flex; gap: 10px; margin-bottom: 14px; }
.sh-chat-msg.user { flex-direction: row-reverse; }
.sh-chat-bubble {
  max-width: 82%; padding: 10px 14px; border-radius: 16px;
  font-size: 14px; line-height: 1.55; color: var(--sh-text);
  border: 1.5px solid var(--sh-line); background: var(--sh-paper-2);
}
.sh-chat-msg.user .sh-chat-bubble {
  background: var(--sh-teal); border-color: var(--sh-teal);
  color: #fff; border-radius: 16px 16px 4px 16px;
}
.sh-chat-msg.assistant .sh-chat-bubble { border-radius: 16px 16px 16px 4px; }

/* ── PIN pad ── */
.sh-pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 16px; max-width: 340px; }
.sh-pinpad button {
  height: 76px; font-size: 28px; font-weight: 500; font-family: 'JetBrains Mono', 'Fira Code', monospace;
  border: 1.5px solid var(--sh-line); background: var(--sh-paper-2); border-radius: 14px;
  cursor: pointer; color: var(--sh-text); transition: transform .08s, background .12s, color .12s;
  -webkit-user-select: none; user-select: none;
}
.sh-pinpad button:active { transform: scale(.93); background: var(--sh-ink); color: #fff; border-color: var(--sh-ink); }
.sh-pindots { display: flex; gap: 16px; justify-content: center; margin: 22px 0; }
.sh-pindots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--sh-ink); transition: .15s; }
.sh-pindots span.f { background: var(--sh-ink); transform: scale(1.05); }

/* ── Chips / tags ── */
.sh-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.sh-chip  {
  font-size: 12.5px; padding: 6px 14px; border-radius: 30px;
  border: 1.5px solid var(--sh-line); background: var(--sh-paper-2);
  color: var(--sh-muted); cursor: pointer; font-weight: 600;
  transition: background .12s, border-color .12s, color .12s;
}
.sh-chip:hover { border-color: var(--sh-teal); color: var(--sh-teal); }
.sh-chip.on { background: var(--sh-ink); color: #fff; border-color: var(--sh-ink); }

/* ── Measure input row ── */
.sh-measure { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.sh-measure .sh-nm { flex: 1; font-weight: 600; font-size: 14px; }
.sh-measure .sh-uu { font-size: 11.5px; color: var(--sh-muted); width: 46px; }
.sh-measure input  { width: 88px; text-align: center; font-family: 'JetBrains Mono', 'Fira Code', monospace; padding: 10px; border: 1.5px solid var(--sh-line); border-radius: var(--r-sm); background: var(--sh-paper-2); font-size: 16px; }

/* ── Frequency badge ── */
.sh-freq { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 6px; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.sh-freq.daily     { background: var(--sh-teal-soft);    color: var(--sh-teal-2); }
.sh-freq.prn       { background: var(--sh-line);         color: var(--sh-muted); }
.sh-freq.cond      { background: var(--sh-coral-soft);   color: var(--sh-coral); }
.sh-freq.alternate { background: var(--sh-violet-soft);  color: var(--sh-violet); }
.sh-freq.weekly    { background: var(--sh-amber-soft);   color: var(--sh-amber); }
.sh-freq.course    { background: var(--sh-success-soft); color: var(--sh-success); }

/* ── Compliance cell (weekly/monthly meds grid) ── */
.sh-comp { width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center; font-size: 12px; }
.sh-comp.taken   { background: var(--sh-success-soft); color: var(--sh-success); }
.sh-comp.missed  { background: var(--sh-coral-soft);   color: var(--sh-coral); }
.sh-comp.pending { background: var(--sh-amber-soft);   color: var(--sh-amber); }
.sh-comp.na      { background: var(--sh-line);         color: var(--sh-muted); }

/* ── Stock level bar ── */
.sh-stock-bar { height: 6px; border-radius: 3px; background: var(--sh-line); overflow: hidden; margin-top: 4px; }
.sh-stock-bar-fill { height: 100%; border-radius: 3px; background: var(--sh-success); transition: width .3s; }
.sh-stock-bar-fill.low { background: var(--sh-coral); }
.sh-stock-bar-fill.warn { background: var(--sh-amber); }

/* ── Calendar ── */
.sh-cal { width: 100%; border-collapse: separate; border-spacing: 3px; }
.sh-cal th { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--sh-muted); text-align: center; padding: 4px 0 8px; }
.sh-cal td { text-align: center; }
.sh-cal-day {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; font-size: 13px; font-weight: 500;
  cursor: pointer; color: var(--sh-text); position: relative;
  border: 1.5px solid transparent; transition: background .12s, border-color .12s;
}
.sh-cal-day:hover  { background: var(--sh-teal-soft); border-color: var(--sh-teal); }
.sh-cal-day.today  { background: var(--sh-teal); color: #fff; font-weight: 700; }
.sh-cal-day.has-appt::after { content: ""; position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%); width: 5px; height: 5px; border-radius: 50%; background: var(--sh-coral); }
.sh-cal-day.today.has-appt::after { background: #fff; }
.sh-cal-day.other-month { color: var(--sh-muted); opacity: .4; }

/* ── Document gallery ── */
.sh-doc-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.sh-doc-card {
  border: 1.5px solid var(--sh-line); border-radius: var(--r);
  padding: 12px; background: var(--sh-paper-2);
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: var(--bs-box-shadow); text-decoration: none; color: inherit;
}
.sh-doc-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; }
.sh-doc-icon.pdf   { background: var(--sh-coral-soft);   color: var(--sh-coral); }
.sh-doc-icon.img   { background: var(--sh-teal-soft);    color: var(--sh-teal); }
.sh-doc-icon.other { background: var(--sh-line);         color: var(--sh-muted); }
.sh-doc-name { font-size: 13px; font-weight: 600; color: var(--sh-ink); line-height: 1.3; }
.sh-doc-meta { font-size: 11px; color: var(--sh-muted); }

/* ── Bed grid (facilities) ── */
.sh-bed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; }
.sh-bed {
  padding: 10px 6px; border-radius: 10px; text-align: center;
  border: 1.5px solid var(--sh-line); background: var(--sh-paper-2);
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: border-color .12s;
}
.sh-bed .material-symbols-rounded { font-size: 20px; display: block; margin-bottom: 4px; }
.sh-bed.free     { color: var(--sh-success); border-color: rgba(5,150,105,.3); background: var(--sh-success-soft); }
.sh-bed.occupied { color: var(--sh-coral);   border-color: rgba(220,38,38,.3);   background: var(--sh-coral-soft); }
.sh-bed.reserved { color: var(--sh-amber);   border-color: rgba(217,119,6,.3);   background: var(--sh-amber-soft); }

/* ── Notification feed ── */
.sh-notif {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; border-bottom: 1px solid var(--sh-line);
  font-size: 13.5px; color: var(--sh-text);
}
.sh-notif:last-child { border-bottom: none; }
.sh-notif.unread { background: var(--sh-teal-soft); }
.sh-notif-icon { flex: none; margin-top: 1px; }
.sh-notif-body { flex: 1; min-width: 0; }
.sh-notif-time { font-size: 11px; color: var(--sh-muted); margin-top: 2px; }

/* ══════════════════════════════════════════
   RESPONSIVE LAYOUT
   ══════════════════════════════════════════ */

@media (min-width: 640px) {
  .app { max-width: 680px; }
  .sh-nav { max-width: 680px; }
  .sh-chatbar { max-width: 680px; }
  .sh-more-drawer { max-width: 680px; }
  .sh-view { padding-left: 28px; padding-right: 28px; }
  h1.sh-title { font-size: 32px; }
  .sh-center { padding: 48px 56px; }
  .sh-pinpad { gap: 18px; max-width: 380px; }
  .sh-pinpad button { height: 88px; }
}

@media (min-width: 1024px) {
  /* Switch to sidebar layout */
  .app:has(>.sh-nav) {
    max-width: 100%; display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    align-items: start;
  }

  /* Sidebar nav */
  .app:has(>.sh-nav)>.sh-nav {
    grid-column: 1; grid-row: 1;
    position: sticky; top: 0; left: auto; right: auto; bottom: auto;
    height: 100dvh; max-width: none; margin: 0;
    flex-direction: column; justify-content: flex-start; align-items: stretch;
    gap: 2px; padding: 0 12px 20px;
    border-top: none; border-right: 1.5px solid var(--sh-line);
    background: var(--sh-paper-2); backdrop-filter: none;
    overflow-y: auto;
  }
  .app.dark:has(>.sh-nav)>.sh-nav { background: var(--sh-paper-2); }

  /* Sidebar brand header — desktop only */
  .sh-nav-brand {
    display: flex; flex-direction: column; align-items: center;
    padding: 20px 12px 14px; margin-bottom: 4px;
    border-bottom: 1.5px solid var(--sh-line); flex: none;
    gap: 6px;
  }
  .sh-nav-cloudy {
    width: 90px; height: auto;
    filter: drop-shadow(0 4px 12px rgba(14,29,47,.15));
    transition: transform .2s;
  }
  .sh-nav-cloudy:hover { transform: scale(1.04); }

  /* Sidebar nav links */
  .app:has(>.sh-nav)>.sh-nav a {
    flex-direction: row; gap: 10px; font-size: 13.5px; font-weight: 600;
    padding: 9px 14px; border-radius: 10px;
    justify-content: flex-start; white-space: nowrap;
    text-transform: none; letter-spacing: 0;
    color: var(--sh-muted); transition: background .12s, color .12s;
  }
  .app:has(>.sh-nav)>.sh-nav a .gi { font-size: 18px; }
  .app:has(>.sh-nav)>.sh-nav a:hover { background: var(--sh-line); color: var(--sh-ink); }
  .app:has(>.sh-nav)>.sh-nav a.act {
    background: var(--sh-teal-soft); color: var(--sh-teal-2);
  }
  .app:has(>.sh-nav)>.sh-nav a.act .gi { color: var(--sh-teal); }

  /* FAB → full-width button in sidebar */
  .app:has(>.sh-nav)>.sh-nav a.fab {
    order: -1; background: var(--sh-teal); color: #fff;
    border-radius: var(--r); margin: 10px 0 6px;
    padding: 10px 14px; font-size: 13.5px; font-weight: 700;
    justify-content: center; text-transform: none; letter-spacing: 0;
  }
  .app:has(>.sh-nav)>.sh-nav a.fab .gi {
    background: none; color: #fff; width: auto; height: auto;
    border-radius: 0; margin: 0; box-shadow: none; font-size: 18px;
  }
  .app:has(>.sh-nav)>.sh-nav a.fab:hover { background: var(--sh-teal-2); }

  /* Main content area */
  .app:has(>.sh-nav)>.sh-view {
    grid-column: 2; grid-row: 1; max-width: none; padding: 28px 48px 60px;
  }
  .app:not(:has(>.sh-nav)) { max-width: 820px; }
  .app:has(>.sh-nav) .sh-tt { right: 12px; }

  /* Show secondary items inline in sidebar */
  .sh-nav-more-btn    { display: none; }
  .sh-more-backdrop   { display: none !important; }
  .sh-more-drawer     { display: none !important; }
  .sh-nav-secondary   { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
  .sh-nav-secondary a {
    display: flex; flex-direction: row; align-items: center; gap: 10px;
    font-size: 13px; color: var(--sh-muted); font-weight: 600;
    padding: 8px 14px; border-radius: 10px; text-decoration: none; white-space: nowrap;
    transition: background .12s, color .12s;
  }
  .sh-nav-secondary a .gi { font-size: 18px; }
  .sh-nav-secondary a:hover { background: var(--sh-line); color: var(--sh-ink); }
  .sh-nav-group-label {
    display: block; font-size: 9px; font-weight: 800; text-transform: uppercase;
    letter-spacing: .1em; color: var(--sh-muted); padding: 14px 14px 4px; opacity: .5;
  }

  /* Chat bar offset for sidebar */
  .app:has(>.sh-nav) .sh-chatbar { left: 260px; right: 0; max-width: none; margin: 0; }

  h1.sh-title { font-size: 34px; }
  .sh-center  { padding: 60px; max-width: 520px; margin: 0 auto; }

  /* KPI grid: up to 4 columns on desktop */
  .sh-kpi-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  /* Legacy Bootstrap grid KPIs */
  .row.g-2.mb-3 .col { flex: 1 1 180px; max-width: 280px; }
}

@media (min-width: 1400px) {
  .app:has(>.sh-nav)>.sh-nav   { width: 280px; }
  .app:has(>.sh-nav)            { grid-template-columns: 280px minmax(0, 1fr); }
  .app:has(>.sh-nav) .sh-chatbar { left: 280px; }
  .app:has(>.sh-nav)>.sh-view  { padding-left: 64px; padding-right: 64px; }
}
