/* Zencia OPD — admin dashboard. A floating icon sidebar + soft rounded cards,
   in the app's own teal/Zencia tokens rather than a borrowed accent color, so
   it still feels like the same product as the kiosk and doctor pages. */

body { background: var(--c-bg); }

.admin-shell { display: flex; min-height: 100vh; }

/* ---------- floating icon-rail sidebar ---------- */
.admin-nav {
  position: fixed; top: 50%; left: var(--s-5); transform: translateY(-50%);
  background: linear-gradient(165deg, var(--c-brand-dark) 0%, var(--c-brand) 55%, var(--c-brand-dark) 100%);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-2), 0 12px 28px -8px color-mix(in srgb, var(--c-brand) 55%, transparent);
  display: flex; flex-direction: column; align-items: center;
  padding: var(--s-5) 0; gap: 10px; width: 60px;
  max-height: calc(100vh - var(--s-6) * 2);
}
.admin-nav a {
  position: relative;
  width: 40px; height: 40px; border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.7); text-decoration: none; cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.admin-nav a svg { width: 19px; height: 19px; }
.admin-nav a:hover { background: rgba(255,255,255,.14); color: #fff; }
.admin-nav a.is-active {
  background: var(--c-surface); color: var(--c-brand);
  box-shadow: 0 6px 14px -4px rgba(0,0,0,.35);
  transform: scale(1.06);
}

/* Floating label bubble on hover - replaces the native title tooltip so it
   matches the pill's own rounding/shadow instead of the OS default. */
.admin-nav a::after {
  content: attr(data-label);
  position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%);
  background: var(--c-surface); color: var(--c-ink); font-size: var(--t-xs); font-weight: 650;
  padding: 5px 10px; border-radius: var(--r-sm); box-shadow: var(--shadow-2);
  white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity .12s ease, transform .12s ease;
}
.admin-nav a:hover::after { opacity: 1; transform: translateY(-50%) translateX(2px); }

.admin-nav .foot { margin-top: auto; }
.admin-nav .foot-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.5); display: block; }

/* ---------- main column ---------- */
/* .admin-nav is fixed (out of flow) so this needs its own left offset to
   clear the floating sidebar: its width (68px) + margin on both sides. */
.admin-main {
  flex: 1; min-width: 0; margin-left: calc(68px + var(--s-5) * 2);
  padding: var(--s-5) var(--s-6) var(--s-6) 0; display: flex; flex-direction: column; gap: var(--s-5);
}

.admin-head { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.admin-head h1 { font-size: var(--t-xl); }
.admin-head .who {
  font-size: var(--t-xs); color: var(--c-ink-3); padding-right: var(--s-3);
  margin-right: var(--s-1); border-right: 1px solid var(--c-line-soft);
}

.admin-content { display: none; flex-direction: column; gap: var(--s-5); }
.admin-content.active { display: flex; animation: section-in .28s ease-out; }
@keyframes section-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- entrance stagger + shared hover lift for dashboard cards ---------- */
.kpi-card, .soft-card, .doctor-card, .patient-card {
  animation: card-in .35s ease-out both;
}
.kpi-grid > *:nth-child(1), .dash-grid > *:nth-child(1) { animation-delay: 0ms; }
.kpi-grid > *:nth-child(2), .dash-grid > *:nth-child(2) { animation-delay: 40ms; }
.kpi-grid > *:nth-child(3) { animation-delay: 80ms; }
.kpi-grid > *:nth-child(4) { animation-delay: 120ms; }
.kpi-grid > *:nth-child(5) { animation-delay: 160ms; }
.kpi-grid > *:nth-child(6) { animation-delay: 200ms; }
@keyframes card-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .kpi-card, .soft-card, .doctor-card, .patient-card, .admin-content.active { animation: none; }
}

/* ---------- skeleton loading placeholder (replaces plain "Loading…" text) ---------- */
.skeleton-row {
  border-radius: var(--r-md); margin-bottom: var(--s-3);
  background: linear-gradient(100deg, var(--c-surface-2) 30%, var(--c-line-soft) 50%, var(--c-surface-2) 70%);
  background-size: 200% 100%; animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
.skeleton-row:last-child { margin-bottom: 0; }
@keyframes skeleton-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  .skeleton-row { animation: none; background: var(--c-surface-2); }
}

/* ---------- greeting ---------- */
.greeting-card {
  background: var(--c-surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  padding: var(--s-6); display: flex; align-items: center; gap: var(--s-6); flex-wrap: wrap;
}
.greeting-card h1 { font-size: var(--t-2xl); line-height: 1.15; margin-bottom: var(--s-2); }
.greeting-card .emoji { font-size: var(--t-2xl); }
.greeting-card .greeting-sub {
  display: flex; align-items: center; gap: 7px;
  margin: 0; color: var(--c-ink-3); font-size: var(--t-sm);
}
.greeting-card .greeting-sub .live-dot {
  flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--c-green);
}
.greeting-card .greeting-sub .kpi-est { padding: 1px 5px; }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s-4); }
/* Fixed column counts for a known number of cards - avoids an auto-fit grid
   stranding one lonely card by itself on its own row once the count doesn't
   divide evenly into however many 240px columns happen to fit. */
.kpi-grid-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .kpi-grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .kpi-grid-4, .kpi-grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 900px) and (min-width: 641px) { .kpi-grid-3 { grid-template-columns: repeat(2, 1fr); } }
/* ---------- unacknowledged-alerts banner (doctor Home) ---------- */
.alert-banner {
  display: flex; align-items: center; gap: var(--s-4);
  background: var(--c-red-bg); border: 1px solid #f0bbb8; border-radius: var(--r-lg);
  padding: var(--s-4) var(--s-5); box-shadow: var(--shadow-1);
}
.alert-banner-icon {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: var(--c-red); color: #fff; display: flex; align-items: center; justify-content: center;
  animation: alert-banner-pulse 2s ease-in-out infinite;
}
.alert-banner-icon svg { width: 20px; height: 20px; }
@keyframes alert-banner-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c-red) 45%, transparent); }
  50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--c-red) 0%, transparent); }
}
@media (prefers-reduced-motion: reduce) { .alert-banner-icon { animation: none; } }
.alert-banner-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.alert-banner-body strong { font-size: var(--t-md); color: #7c1512; }
.alert-banner-body span { font-size: var(--t-sm); color: #9a4440; }

.kpi-section-label {
  font-size: var(--t-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--c-ink-3); margin: var(--s-2) 0 calc(-1 * var(--s-2));
}
.kpi-card {
  position: relative; overflow: hidden;
  background: var(--c-surface); border: 1px solid var(--c-line-soft); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1); padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-4);
  transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
  /* Button reset - a KPI card that navigates somewhere is a <button>, one
     that's purely informational stays a <div>; these rules are harmless
     no-ops on the latter. */
  width: 100%; text-align: left; font: inherit; color: inherit; cursor: default;
}
button.kpi-card { cursor: pointer; }
.kpi-card:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); border-color: var(--kpi-tint, var(--c-line)); }
.kpi-card:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 2px; }
button.kpi-card:active { transform: translateY(-1px) scale(.99); }
/* Soft radial glow in the tint color, tucked behind the corner - each card
   sets --kpi-tint inline so this rule works for every color without repeats. */
.kpi-card::before {
  content: ""; position: absolute; top: -30px; right: -30px; width: 110px; height: 110px;
  border-radius: 50%; background: var(--kpi-tint, transparent); opacity: .16; pointer-events: none;
}
.kpi-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); position: relative; }
.kpi-icon {
  width: 46px; height: 46px; border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(155deg, var(--kpi-tint, var(--c-brand)) 0%, color-mix(in srgb, var(--kpi-tint, var(--c-brand)) 70%, #000 8%) 100%);
  color: #fff; box-shadow: 0 6px 14px -6px var(--kpi-tint, var(--c-brand));
}
.kpi-icon svg { width: 22px; height: 22px; }
.kpi-label { font-size: var(--t-sm); color: var(--c-ink-2); font-weight: 550; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: var(--t-2xl); font-weight: 750; line-height: 1; letter-spacing: -.01em; position: relative; }
.kpi-est { font-size: var(--t-xs); font-weight: 700; color: var(--c-ink-3); background: var(--c-surface-2); border-radius: var(--r-sm); padding: 1px 6px; }

.kpi-trend {
  font-size: var(--t-xs); font-weight: 650; display: inline-flex; align-items: center; gap: 4px;
  align-self: flex-start; padding: 3px 9px; border-radius: var(--r-pill);
}
.kpi-trend.up { color: var(--c-green); background: var(--c-green-bg); }
.kpi-trend.down { color: var(--c-red); background: var(--c-red-bg); }
.kpi-trend.flat { color: var(--c-ink-3); background: var(--c-surface-2); }

.kpi-mini-spark { width: 100%; height: 32px; display: block; margin-top: -4px; }

/* ---------- generic soft card / panel ---------- */
.soft-card {
  background: var(--c-surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-4);
}
.soft-card > header { display: flex; align-items: center; gap: var(--s-3); }
.soft-card > header h3 { font-size: var(--t-md); flex: 1; }
.soft-card > header .hint-sm { font-size: var(--t-xs); color: var(--c-ink-3); }

.dash-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: var(--s-5); align-items: start; }
.dash-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--s-5); align-items: start; }
@media (max-width: 1100px) { .dash-grid, .dash-grid-3 { grid-template-columns: 1fr; } }

/* ---------- charts ---------- */
.chart-panel .kpi-value { font-size: var(--t-lg); }
.sparkline { width: 100%; height: 60px; display: block; }
.bar-chart { width: 100%; height: 60px; display: block; overflow: visible; }
.bar-chart .bar-grow { animation: bar-grow-in .5s cubic-bezier(.22,.8,.3,1.15) both; }
@keyframes bar-grow-in { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.bar-chart-labels {
  display: flex; justify-content: space-between; margin-top: 4px;
  font-size: 10px; color: var(--c-ink-3); text-align: center;
}
.bar-chart-labels span { flex: 1; }

/* ---------- calendar (compact, inside soft-card) ---------- */
.calendar table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); text-align: center; }
.calendar th { color: var(--c-ink-3); font-weight: 600; padding: 4px 0; font-size: var(--t-xs); }
.calendar td { padding: 5px 0; color: var(--c-ink-2); }
.calendar td.other-month { color: var(--c-ink-3); opacity: .35; }
.calendar td.today span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%; background: var(--c-brand); color: #fff; font-weight: 700;
}

/* ---------- today timeline (replaces a plain table) ---------- */
.timeline { display: flex; flex-direction: column; gap: var(--s-3); }
.timeline-item { display: flex; gap: var(--s-3); align-items: flex-start; }
.timeline-time { width: 74px; flex: none; font-size: var(--t-xs); color: var(--c-ink-3); padding-top: 10px; text-align: right; }
.timeline-dot-col { display: flex; flex-direction: column; align-items: center; flex: none; padding-top: 10px; }
.timeline-dot { width: 10px; height: 10px; border-radius: 50%; }
.timeline-line { flex: 1; width: 2px; background: var(--c-line-soft); margin-top: 4px; min-height: 24px; }
.timeline-item:last-child .timeline-line { display: none; }
.timeline-card {
  flex: 1; background: var(--c-surface-2); border-radius: var(--r-md); padding: var(--s-3) var(--s-4);
  display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  border: none; font: inherit; color: inherit; text-align: left; width: 100%; cursor: pointer;
  transition: background .12s ease;
}
.timeline-card:hover { background: var(--c-surface-3, #e7e9e4); }
.timeline-card:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 2px; }
.timeline-card strong { display: block; font-size: var(--t-sm); }
.timeline-card span.meta { font-size: var(--t-xs); color: var(--c-ink-3); }
.timeline-toggle-btn { align-self: center; margin-top: var(--s-2); }

/* ---------- notification-style feed (recent red flags) ---------- */
.feed { display: flex; flex-direction: column; gap: var(--s-3); }
.feed-item { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3); border-radius: var(--r-md); background: var(--c-surface-2); }

/* ---------- previous-visits panel (doctor visit detail) ---------- */
#detailPreviousVisitsList { display: flex; flex-direction: column; gap: var(--s-2); }
.prev-visit-row {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; text-align: left;
  padding: var(--s-2) var(--s-3); border: 1px solid var(--c-line-soft); border-radius: var(--r-md);
  background: var(--c-surface); cursor: pointer; font: inherit; color: inherit;
  transition: border-color .15s ease, background .15s ease;
}
.prev-visit-row:hover { border-color: var(--c-brand); background: var(--c-surface-2); }
.prev-visit-when { flex: 0 0 auto; font-size: var(--t-xs); color: var(--c-ink-3); min-width: 90px; }
.prev-visit-complaint { flex: 1; min-width: 0; font-size: var(--t-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-icon { width: 34px; height: 34px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; }
.feed-icon svg { width: 17px; height: 17px; }
.feed-item strong { display: block; font-size: var(--t-sm); }
.feed-item p { margin: 2px 0 0; font-size: var(--t-xs); color: var(--c-ink-2); }
.feed-item .when { font-size: var(--t-xs); color: var(--c-ink-3); white-space: nowrap; }

/* ---------- Alerts page (D4): severity-led feed, not a flat list ---------- */
.alert-summary { display: flex; gap: var(--s-3); flex-wrap: wrap; margin: var(--s-3) 0; }
.alert-summary .stat-pill {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: var(--r-lg);
  background: var(--c-surface-2); font-size: var(--t-sm); font-weight: 600; color: var(--c-ink-2);
}
.alert-summary .stat-pill strong { font-size: var(--t-md); font-weight: 800; color: var(--c-ink); }
.alert-summary .stat-pill.red { background: var(--c-red-bg); color: var(--c-red); }
.alert-summary .stat-pill.red strong { color: var(--c-red); }
.alert-summary .stat-pill.orange { background: var(--c-orange-bg); color: var(--c-orange); }
.alert-summary .stat-pill.orange strong { color: var(--c-orange); }

.alert-filters { display: flex; gap: 6px; margin-bottom: var(--s-3); flex-wrap: wrap; }
.alert-filter {
  border: 1px solid var(--c-line); background: var(--c-surface); color: var(--c-ink-2);
  border-radius: var(--r-lg); padding: 6px 14px; font-size: var(--t-sm); font-weight: 600; cursor: pointer;
}
.alert-filter:hover { border-color: var(--c-brand); color: var(--c-ink); }
.alert-filter.is-active { background: var(--c-ink); color: #fff; border-color: var(--c-ink); }

.alert-item { position: relative; border-left: 4px solid var(--c-line); }
.alert-item.emergency { border-left-color: var(--c-red); background: color-mix(in srgb, var(--c-red-bg) 55%, var(--c-surface-2)); }
.alert-item.urgent { border-left-color: var(--c-orange); background: color-mix(in srgb, var(--c-orange-bg) 55%, var(--c-surface-2)); }
.alert-item.is-acknowledged { opacity: .62; }
.alert-item.is-acknowledged.emergency, .alert-item.is-acknowledged.urgent { background: var(--c-surface-2); }
.alert-item .alert-body { flex: 1; min-width: 0; }
.alert-item .alert-title { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.alert-item .alert-flags { margin: 3px 0 0; font-size: var(--t-xs); color: var(--c-ink-2); }
.alert-item .when { display: block; margin-top: 3px; }
.alert-item .alert-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.alert-item .alert-actions .btn { white-space: nowrap; }
.alert-item.emergency:not(.is-acknowledged) .btn-primary { background: var(--c-red); border-color: var(--c-red); }
.alert-item.emergency:not(.is-acknowledged) .btn-primary:hover { background: color-mix(in srgb, var(--c-red) 85%, black); }

/* ---------- donut / ring stat ---------- */
.ring-card { display: flex; align-items: center; gap: var(--s-4); }
.ring-svg { width: 84px; height: 84px; flex: none; }
.ring-svg circle { fill: none; stroke-width: 8; }
.ring-track { stroke: var(--c-surface-2); }
.ring-value { transform: rotate(-90deg); transform-origin: 50% 50%; stroke-linecap: round; transition: stroke-dasharray .5s ease; }
.ring-label-group { display: flex; flex-direction: column; }
.ring-pct { font-size: var(--t-xl); font-weight: 700; }
.ring-desc { font-size: var(--t-sm); color: var(--c-ink-2); }
.ring-sub { font-size: var(--t-xs); color: var(--c-ink-3); margin-top: 2px; }
.ring-card-btn {
  width: 100%; border: none; background: transparent; font: inherit; color: inherit;
  cursor: pointer; text-align: left; border-radius: var(--r-md); padding: var(--s-2);
  margin: calc(-1 * var(--s-2)); transition: background .12s ease;
}
.ring-card-btn:hover { background: var(--c-surface-2); }
.ring-card-btn:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 2px; }

/* ---------- CTA card (real system status, styled like the reference's promo card) ---------- */
.status-card {
  background: var(--c-brand); color: #fff; border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-3); justify-content: center;
}
.status-card h3 { color: #fff; font-size: var(--t-md); }
.status-card p { color: rgba(255,255,255,.85); margin: 0; font-size: var(--t-sm); }
.status-card .dot-row { display: flex; align-items: center; gap: 8px; font-size: var(--t-sm); }
.status-card .dot { width: 9px; height: 9px; border-radius: 50%; }
.status-card .dot.ok { background: #6ee7b7; }
.status-card .dot.bad { background: #fca5a5; }

/* Compact horizontal variant for the Settings page - the default stacked
   layout leaves a lot of empty vertical space for just 3 short status
   lines. Additive modifier, so Home's own status-card usage is untouched. */
.status-card-compact {
  flex-direction: row; flex-wrap: wrap; align-items: center;
  padding: var(--s-4) var(--s-5); gap: var(--s-3) var(--s-6);
}
.status-card-compact h3 { margin: 0; white-space: nowrap; }
.status-card-compact .status-dots-row { display: flex; flex-wrap: wrap; gap: var(--s-3) var(--s-5); flex: 1; }
.status-card-compact #statusFootnote {
  margin: 0 0 0 auto; font-size: var(--t-xs); opacity: .75; white-space: nowrap;
}

/* ---------- Settings page: hospital-settings field grouping ---------- */
.settings-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
@media (max-width: 720px) { .settings-field-row { grid-template-columns: 1fr; } }

.lang-toggle-group { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.lang-toggle {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px;
  border-radius: var(--r-pill); border: 1px solid var(--c-line); background: var(--c-surface);
  font-size: var(--t-sm); font-weight: 550; color: var(--c-ink-2); cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.lang-toggle:hover { border-color: var(--c-ink-3); }
.lang-toggle input { accent-color: var(--c-brand); margin: 0; }
.lang-toggle:has(input:checked) {
  background: var(--c-brand-soft); border-color: var(--c-brand); color: var(--c-brand-dark);
}

.retention-field { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--s-4); }
.retention-field .input { max-width: 140px; flex: none; }
.retention-field .banner { flex: 1; min-width: 220px; margin: 0; }

/* ---------- week visit list (duration bars) ---------- */
.visit-rows { display: flex; flex-direction: column; gap: var(--s-3); }
.visit-row-item { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: var(--s-4); align-items: center; }
.visit-row-item .who { font-size: var(--t-sm); font-weight: 600; }
.visit-row-item .who span { display: block; font-size: var(--t-xs); font-weight: 400; color: var(--c-ink-3); }
.visit-row-bar { height: 6px; border-radius: 3px; background: var(--c-surface-2); overflow: hidden; }
.visit-row-bar i { display: block; height: 100%; background: var(--c-brand); }

.placeholder-panel { text-align: center; padding: var(--s-7) var(--s-5); color: var(--c-ink-2); }
.placeholder-panel svg { width: 40px; height: 40px; color: var(--c-ink-3); margin-bottom: var(--s-3); }

/* ---------- patient cards ---------- */
.patient-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s-4); }
.patients-grid-toggle-btn { grid-column: 1 / -1; justify-self: center; margin-top: var(--s-2); }

.patient-card {
  background: var(--c-surface); border: 1px solid var(--c-line-soft); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1); padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-3);
  text-align: left; font: inherit; color: inherit; cursor: pointer;
  transition: box-shadow .15s ease, border-color .15s ease, transform .15s ease;
}
.patient-card:hover { border-color: var(--c-brand); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.patient-card:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 2px; }

.patient-card-head { display: flex; align-items: center; gap: var(--s-3); }
.patient-avatar {
  flex: none; width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--c-brand-soft); color: var(--c-brand-dark);
  font-weight: 700; font-size: var(--t-sm); letter-spacing: .02em;
}
.patient-card-head .who { flex: 1; min-width: 0; }
.patient-card-head .who strong { display: block; font-size: var(--t-base); }
.patient-card-head .who span { display: block; font-size: var(--t-xs); color: var(--c-ink-3); }

.patient-card dl.patient-facts {
  margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 5px var(--s-3); font-size: var(--t-sm);
}
.patient-card dl.patient-facts dt { color: var(--c-ink-3); }
.patient-card dl.patient-facts dd {
  margin: 0; color: var(--c-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.patient-card-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); margin-top: auto; padding-top: var(--s-2); border-top: 1px solid var(--c-line-soft); }
.patient-card-foot .visits-count { font-size: var(--t-xs); color: var(--c-ink-3); }

.error { color: var(--c-red); font-size: var(--t-sm); }

@media (max-width: 860px) {
  .admin-shell { flex-direction: column; }
  .admin-nav {
    position: static; transform: none; flex-direction: row; width: auto; margin: var(--s-3); border-radius: var(--r-lg);
    overflow-x: auto; padding: var(--s-2); max-height: none;
  }
  .admin-main { margin-left: 0; padding: 0 var(--s-4) var(--s-4); }
  .greeting-card { padding: var(--s-5); }
}

/* ---------- clinical policy (read-only mirror) ---------- */
.clinical-hero {
  background: var(--c-brand-soft); border-radius: var(--r-lg);
  padding: var(--s-6); display: flex; align-items: flex-start; gap: var(--s-5); flex-wrap: wrap;
}
.clinical-hero-icon {
  flex: none; width: 52px; height: 52px; border-radius: var(--r-lg);
  background: linear-gradient(155deg, var(--c-brand-dark) 0%, var(--c-brand) 100%);
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 14px -6px var(--c-brand);
}
.clinical-hero-icon svg { width: 26px; height: 26px; }
.clinical-hero h3 { font-size: var(--t-lg); margin-bottom: 6px; }
.clinical-hero p { margin: 0; color: var(--c-ink-2); max-width: 68ch; line-height: 1.55; }

.redflag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--s-3); }
.redflag-tile {
  display: flex; align-items: flex-start; gap: var(--s-3);
  background: var(--c-surface); border: 1px solid var(--c-line-soft); border-radius: var(--r-lg);
  padding: var(--s-4); transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.redflag-tile:hover { border-color: var(--c-red); box-shadow: var(--shadow-1); transform: translateY(-1px); }
.redflag-icon {
  flex: none; width: 40px; height: 40px; border-radius: var(--r-md); margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  background: var(--c-red-bg); color: var(--c-red);
}
.redflag-icon svg { width: 20px; height: 20px; }
.redflag-tile strong { display: block; font-size: var(--t-sm); }
.redflag-tile p { margin: 3px 0 0; font-size: var(--t-xs); color: var(--c-ink-3); line-height: 1.4; }

.guarantee-list { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3) var(--s-5); }
@media (max-width: 720px) { .guarantee-list { grid-template-columns: 1fr; } }
.guarantee-item { display: flex; gap: var(--s-3); align-items: flex-start; }
.guarantee-icon {
  flex: none; width: 30px; height: 30px; border-radius: 50%; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  background: var(--c-green-bg); color: var(--c-green);
}
.guarantee-icon svg { width: 16px; height: 16px; }
.guarantee-item strong { display: block; font-size: var(--t-sm); }
.guarantee-item p { margin: 2px 0 0; font-size: var(--t-xs); color: var(--c-ink-2); line-height: 1.5; }

/* ---------- D3 patient detail header (doctor.html) ---------- */
.detail-header {
  display: flex; align-items: flex-start; gap: var(--s-4);
  background: var(--c-surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  padding: var(--s-5); margin-bottom: var(--s-5); flex-wrap: wrap;
  border-left: 4px solid transparent;
}
/* An unseen EMERGENCY is the single most urgent state in this app - the
   whole card carries that, not just the small triage pill in the corner. */
.detail-header.is-emergency {
  border-left-color: var(--c-red);
  background: linear-gradient(to right, var(--c-red-bg) 0%, var(--c-surface) 220px);
}
.detail-avatar {
  flex: none; width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(155deg, var(--c-brand-dark), var(--c-brand));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--t-md);
}
.detail-identity { flex: 1; min-width: 200px; }
.detail-identity h2 { font-size: var(--t-lg); margin-bottom: 4px; }
.detail-meta-row { display: flex; align-items: center; gap: var(--s-3); font-size: var(--t-sm); color: var(--c-ink-2); }
.detail-medical-flags {
  margin: var(--s-2) 0 0; padding: 5px 10px; border-radius: var(--r-sm); display: inline-block;
  background: var(--c-orange-bg); color: var(--c-orange); font-size: var(--t-xs); font-weight: 650;
}
.detail-seen-pill {
  font-size: var(--t-xs); font-weight: 650; padding: 2px 9px; border-radius: var(--r-pill);
  background: var(--c-surface-2); color: var(--c-ink-3);
}
.detail-seen-pill.is-seen { background: var(--c-green-bg); color: var(--c-green); }
/* Unseen + EMERGENCY is the one combination that must never blend into the
   background - same red family as the triage badge itself, not a neutral chip. */
.detail-seen-pill.needs-attention { background: var(--c-red); color: #fff; font-weight: 700; }
.detail-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: var(--s-3); }
.detail-triage-badge { font-size: var(--t-sm); padding: 7px 16px; }

@media (max-width: 640px) {
  .detail-header { flex-direction: column; }
  .detail-side { align-items: flex-start; width: 100%; }
  .detail-side .row-wrap { justify-content: flex-start !important; }
}

/* ---------- transcript (doctor.html detail view) ----------
   .msg (styles.css) already has max-width:78% and align-self left/right for
   assistant vs patient - but align-self only does anything inside a flex
   container, and this page never loaded flow.css (the file that used to
   supply that). Without it every bubble silently stretched to the same
   78%-wide, left-aligned block regardless of who said it. */
.transcript-view { display: flex; flex-direction: column; gap: var(--s-3); }

/* ---------- staff / doctors ---------- */
.staff-toolbar { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }

.filter-tabs { display: flex; gap: 4px; background: var(--c-surface-2); border-radius: var(--r-pill); padding: 3px; }
.filter-tab {
  border: none; background: transparent; color: var(--c-ink-2); font: inherit; font-size: var(--t-sm);
  font-weight: 550; padding: 6px 14px; border-radius: var(--r-pill); cursor: pointer; white-space: nowrap;
}
.filter-tab:hover { color: var(--c-ink); }
.filter-tab.is-active { background: var(--c-brand); color: #fff; box-shadow: var(--shadow-1); }

.doctor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: var(--s-4); }
.doctor-card {
  background: var(--c-surface); border: 1px solid var(--c-line-soft); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1); display: flex; flex-direction: column; overflow: hidden; position: relative;
  transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
}
.doctor-card:hover { box-shadow: var(--shadow-2); transform: translateY(-3px); border-color: var(--c-brand); }
.doctor-card.is-dim { opacity: .6; }
.doctor-card.is-dim:hover { transform: none; border-color: var(--c-line-soft); }

.doctor-card-banner { height: 64px; }
.doctor-card-status {
  position: absolute; top: var(--s-3); right: var(--s-3);
  background: var(--c-surface); box-shadow: var(--shadow-1);
}
.doctor-card-body { padding: 0 var(--s-5) var(--s-5); display: flex; flex-direction: column; gap: var(--s-2); flex: 1; }
.doctor-card-avatar { margin-top: -34px; margin-bottom: var(--s-1); }
.doctor-avatar {
  width: 60px; height: 60px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(155deg, var(--c-brand-dark), var(--c-brand)); color: #fff;
  font-weight: 700; font-size: var(--t-md); letter-spacing: .02em;
  border: 3px solid var(--c-surface); box-shadow: 0 0 0 1px var(--c-line-soft);
}
.doctor-avatar-photo { object-fit: cover; background: var(--c-surface-2); }
.doctor-card-name { display: block; font-size: var(--t-md); font-weight: 700; letter-spacing: -.01em; }
.doctor-card-username { display: block; font-size: var(--t-xs); color: var(--c-ink-3); margin-top: -4px; }

.doctor-card-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2);
  padding: var(--s-3) 0; margin: var(--s-2) 0; border-top: 1px solid var(--c-line-soft); border-bottom: 1px solid var(--c-line-soft);
}
.doctor-stat { text-align: center; }
.doctor-stat strong { display: block; font-size: var(--t-md); font-weight: 700; }
.doctor-stat span { display: block; font-size: var(--t-xs); color: var(--c-ink-3); margin-top: 2px; }

.doctor-card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); margin-top: auto; }
.doctor-card-actions .btn {
  border-radius: var(--r-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: var(--t-xs); padding: 8px 8px;
}
.btn-outline-danger { background: transparent; border-color: #f0bbb8; color: var(--c-red); }
.btn-outline-danger:hover { background: var(--c-red-bg); border-color: var(--c-red); }
