/* ============================================
   patientScout by Digtinctive — Core Styles
   UX adapted from compCore design system
   ============================================ */

/* ── Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');
@import url('https://fonts.googleapis.com/icon?family=Material+Icons+Round');

/* ── Design Tokens (compCore palette) ── */
:root {
  /* Primary: deep blue-indigo (compCore gradient) */
  --primary:        hsl(225, 60%, 32%);
  --primary-vivid:  hsl(225, 65%, 45%);
  --primary-light:  hsl(225, 50%, 95%);
  --accent:         hsl(258, 50%, 55%);
  --accent-light:   hsl(258, 40%, 94%);

  /* Surface / Background */
  --bg:             hsl(220, 20%, 97%);
  --surface:        #ffffff;
  --surface-dim:    hsl(220, 15%, 95%);
  --card-border:    hsl(220, 15%, 90%);
  --card-border-strong: hsl(220, 15%, 84%);

  /* Sidebar */
  --sidebar-bg:     hsl(225, 35%, 18%);
  --sidebar-text:   hsl(220, 15%, 75%);
  --sidebar-active: hsl(225, 65%, 55%);
  --sidebar-hover:  hsl(225, 30%, 24%);

  /* Semantic */
  --success:   hsl(152, 60%, 38%);
  --success-bg: hsl(152, 50%, 94%);
  --warning:   hsl(38, 92%, 55%);
  --warning-bg: hsl(38, 80%, 95%);
  --danger:    hsl(0, 72%, 51%);
  --danger-bg: hsl(0, 60%, 96%);

  /* Text */
  --text:          hsl(224, 20%, 15%);
  --text-secondary: hsl(220, 10%, 40%);
  --text-muted:    hsl(220, 10%, 55%);

  /* Elevation */
  --shadow-card:     0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-elevated: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-modal:    0 20px 60px rgba(0,0,0,.15);

  /* Radius & transition */
  --radius:    12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: all .2s cubic-bezier(.4,0,.2,1);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}

#app { min-height: 100vh; }

a { color: var(--primary-vivid); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }

.fade-in { animation: fadeIn .4s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Utility ── */
.mt-md { margin-top: 1rem; }
.text-sm { font-size: .8rem; }
.text-muted { color: var(--text-muted); }
.num { font-variant-numeric: tabular-nums; }

/* ════════════════════════════════════════════
   LOGIN PAGE (compCore split-panel)
   ════════════════════════════════════════════ */

.login-page {
  display: flex;
  min-height: 100vh;
}

/* Left hero panel — deep gradient + orbs */
.login-brand-panel {
  display: none;
  flex: 1;
  flex-direction: column;
  justify-content: space-between;
  padding: 2.5rem;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, hsl(225,60%,32%), hsl(225,55%,28%), hsl(258,40%,24%));
}

/* Grid overlay */
.login-brand-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
                     linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 40px 40px;
  z-index: 0;
}

/* Glow orbs */
.login-brand-panel::after {
  content: '';
  position: absolute;
  top: -8rem; right: -8rem;
  width: 24rem; height: 24rem;
  border-radius: 50%;
  background: hsl(210,75%,50%);
  opacity: .15;
  filter: blur(80px);
  z-index: 0;
}

.login-brand-panel .brand-orb-bottom {
  position: absolute;
  bottom: -5rem; left: -5rem;
  width: 18rem; height: 18rem;
  border-radius: 50%;
  background: hsl(258,50%,55%);
  opacity: .1;
  filter: blur(80px);
  z-index: 0;
}

@media (min-width: 1024px) {
  .login-brand-panel { display: flex; }
}

/* Brand content */
.brand-pill {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .25rem .75rem; height: 1.5rem;
  border-radius: 999px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  font-size: 11px; font-weight: 500;
  color: rgba(255,255,255,.8);
  backdrop-filter: blur(8px);
}

.brand-title {
  position: relative; z-index: 1;
  font-size: 30px; font-weight: 600;
  line-height: 1.1; color: #fff;
  letter-spacing: -.02em;
}

.brand-subtitle {
  position: relative; z-index: 1;
  margin-top: .75rem; max-width: 28rem;
  font-size: 13px; line-height: 1.6;
  color: rgba(255,255,255,.65);
}

/* Mini stat cards on login */
.brand-stats {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 1fr 1fr;
  gap: .75rem; max-width: 22rem; margin-top: 2rem;
}
.brand-stat-card {
  padding: .875rem;
  border-radius: var(--radius);
  background: rgba(255,255,255,.08);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.1);
}
.brand-stat-label {
  font-size: 10.5px; font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.5);
}
.brand-stat-value {
  margin-top: .25rem;
  font-size: 20px; font-weight: 600; color: #fff;
  font-variant-numeric: tabular-nums;
}
.brand-stat-desc {
  font-size: 11px; color: rgba(255,255,255,.5);
  margin-top: .125rem;
}

/* Footer */
.brand-footer-logo {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: .5rem;
  font-size: 11px; color: rgba(255,255,255,.4);
}
.brand-logo-img { height: 14px; filter: brightness(0) invert(1); opacity: .5; }
.brand-copyright {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 1rem;
  font-size: 11px; color: rgba(255,255,255,.4);
}
.brand-copyright a { color: rgba(255,255,255,.5); }

/* Right panel — form */
.login-form-section {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
  background: var(--bg);
}
.login-form-card {
  width: 100%; max-width: 24rem;
}
.mobile-brand {
  display: flex; align-items: center; gap: .5rem;
  margin-bottom: 2rem; font-size: .75rem; color: var(--text-muted);
}
.mobile-brand-logo { height: 14px; }

@media (min-width: 1024px) {
  .mobile-brand { display: none; }
}

.login-heading {
  font-size: 24px; font-weight: 600;
  letter-spacing: -.02em; color: var(--text);
}
.login-subtext {
  margin-top: .375rem; margin-bottom: 2rem;
  font-size: 13px; color: var(--text-muted);
}

.login-error {
  background: var(--danger-bg);
  color: var(--danger);
  font-size: .8rem; padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  border: 1px solid hsl(0,60%,90%);
}

.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--text);
  margin-bottom: .375rem;
}
.form-input {
  width: 100%;
  padding: .625rem .75rem;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 14px; color: var(--text);
  transition: var(--transition);
  font-family: inherit;
}
.form-input:focus {
  outline: none;
  border-color: var(--primary-vivid);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

/* Microsoft SSO button */
.btn-microsoft {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .625rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 14px; font-weight: 600;
  transition: var(--transition);
  box-shadow: var(--shadow-card);
}
.btn-microsoft:hover { background: var(--primary-vivid); box-shadow: var(--shadow-elevated); }
.btn-microsoft svg { width: 16px; height: 16px; }

.login-footer-note {
  margin-top: 1.5rem; text-align: center;
  font-size: 11px; color: var(--text-muted);
}

/* Login page — smaller font overrides */
.login-page .form-input { font-size: 13px; }
.login-page .btn-microsoft { font-size: 13px; }
.login-page .form-group label { font-size: 12px; }
.login-page .login-error { font-size: .75rem; }

/* SSO overlay */
.sso-overlay { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.5); backdrop-filter: blur(4px); }
.sso-overlay-card { background: var(--surface); border-radius: var(--radius-lg); padding: 2.5rem; text-align: center; width: 22rem; box-shadow: var(--shadow-modal); }
.sso-label { font-size: .82rem; color: var(--text-muted); margin-top: 1rem; }
.sso-email { font-size: 1rem; font-weight: 700; color: var(--text); margin-top: .25rem; }
.sso-bar-track { width: 100%; height: 4px; border-radius: 999px; background: var(--surface-dim); margin-top: 1.5rem; overflow: hidden; }
.sso-bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 999px; animation: sso-bar 2.5s ease-in-out forwards; }
.sso-redirect-text { font-size: .72rem; color: var(--text-muted); margin-top: .75rem; }
@keyframes sso-bar { 0%{width:0} 40%{width:60%} 80%{width:90%} 100%{width:100%} }

/* ════════════════════════════════════════════
   LAYOUT: SIDEBAR + MAIN (compCore pattern)
   ════════════════════════════════════════════ */

/* Sidebar */
.app-sidebar {
  position: fixed; inset-y: 0; left: 0; z-index: 40;
  width: 14rem;
  display: flex; flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid rgba(255,255,255,.08);
  transition: width .25s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
.app-sidebar.collapsed { width: 3.5rem; }

.sidebar-brand {
  padding: 1.25rem; display: flex; align-items: center; gap: .625rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand-icon {
  width: 2rem; height: 2rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--primary-vivid);
  color: #fff;
  font-size: 11px; font-weight: 700;
  box-shadow: 0 2px 8px rgba(59,130,246,.3);
  flex-shrink: 0;
}
.sidebar-brand-text h1 {
  font-size: 14px; font-weight: 600; color: #fff;
  letter-spacing: -.02em; line-height: 1.2;
}
.sidebar-brand-text p {
  font-size: 10.5px; color: var(--sidebar-text); opacity: .6;
}
.collapsed .sidebar-brand-text { display: none; }
.collapsed .sidebar-brand { justify-content: center; padding: 1.25rem .5rem; }

/* Nav section label */
.sidebar-section-label {
  padding: 0 1.25rem; margin-top: 1rem; margin-bottom: .5rem;
  font-size: 10px; font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(255,255,255,.35);
}
.collapsed .sidebar-section-label { display: none; }

/* Nav items */
.sidebar-nav { flex: 1; padding: .25rem .5rem; display: flex; flex-direction: column; gap: .125rem; }
.sidebar-item {
  display: flex; align-items: center; gap: .625rem;
  padding: .5rem .75rem; height: 2.25rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 13px; font-weight: 400;
  text-decoration: none;
  transition: var(--transition);
  position: relative;
  cursor: pointer;
}
.sidebar-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.sidebar-item.active {
  background: rgba(59,130,246,.15);
  color: #fff; font-weight: 500;
}
.sidebar-item.active::before {
  content: '';
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 1.5rem; border-radius: 999px;
  background: linear-gradient(180deg, var(--primary-vivid), hsl(258,50%,65%));
}
.sidebar-item .material-icons-round {
  font-size: 18px; flex-shrink: 0;
  opacity: .7;
}
.sidebar-item.active .material-icons-round { color: var(--sidebar-active); opacity: 1; }
.sidebar-item-label { white-space: nowrap; }
.collapsed .sidebar-item-label { display: none; }
.collapsed .sidebar-item { justify-content: center; padding: .5rem; }

/* Active dot */
.sidebar-active-dot {
  margin-left: auto;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--sidebar-active);
}
.collapsed .sidebar-active-dot { display: none; }

/* Sidebar footer */
.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: .75rem;
}
.sidebar-user-card {
  display: flex; align-items: center; gap: .625rem;
  padding: .75rem;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
}
.sidebar-user-avatar {
  width: 2rem; height: 2rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-vivid), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.sidebar-user-name { font-size: 12px; font-weight: 500; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-role { font-size: 10.5px; color: var(--sidebar-text); opacity: .6; }
.collapsed .sidebar-user-card { justify-content: center; padding: .5rem; }
.collapsed .sidebar-user-name, .collapsed .sidebar-user-role { display: none; }

.sidebar-signout {
  display: flex; align-items: center; justify-content: center; gap: .375rem;
  width: 100%; margin-top: .5rem;
  padding: .375rem .5rem;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--sidebar-text);
  font-size: 11px; font-weight: 500;
  transition: var(--transition);
}
.sidebar-signout:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-signout .material-icons-round { font-size: 14px; }

/* Sidebar toggle */
.sidebar-toggle {
  display: flex; align-items: center; justify-content: center; gap: .375rem;
  width: 100%; margin-top: .375rem;
  padding: .375rem; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--sidebar-text);
  font-size: 11px; transition: var(--transition); cursor: pointer;
}
.sidebar-toggle:hover { background: var(--sidebar-hover); color: #fff; }

/* Main content area */
.app-main {
  margin-left: 14rem;
  transition: margin-left .25s cubic-bezier(.4,0,.2,1);
  min-height: 100vh;
}
.sidebar-collapsed .app-main { margin-left: 3.5rem; }

/* Top header bar */
.app-header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: .5rem 1.5rem; height: 3.5rem;
  background: rgba(255,255,255,.7);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
}
.app-header-left { display: flex; align-items: center; gap: .75rem; }
.app-header-right { display: flex; align-items: center; gap: .75rem; }

/* Breadcrumb */
.breadcrumb { display: flex; align-items: center; gap: .375rem; font-size: 13px; color: var(--text-muted); }
.breadcrumb a { color: var(--text-muted); font-weight: 400; }
.breadcrumb a:hover { color: var(--primary-vivid); text-decoration: none; }
.breadcrumb-sep { color: var(--card-border); }
.breadcrumb-current { font-weight: 500; color: var(--text); }

/* ════════════════════════════════════════════
   HOME PAGE
   ════════════════════════════════════════════ */

.home-topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; justify-content: space-between; align-items: center;
  padding: .85rem 1.75rem;
  background: var(--primary);
  color: #fff;
}
.home-topbar-left { display: flex; align-items: center; gap: .75rem; }
.home-topbar-right { display: flex; align-items: center; gap: .75rem; }
.home-topbar-title { font-size: 1.05rem; font-weight: 700; letter-spacing: -.02em; }
.home-topbar-tag {
  font-size: .65rem; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(255,255,255,.15);
  letter-spacing: .02em;
}
.home-topbar-user { font-size: .82rem; font-weight: 500; }
.brand-logo { display: flex; align-items: center; }

.home-page { max-width: 80rem; margin: 0 auto; padding: 2rem 1.5rem; }

.home-hero {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 2rem; padding-bottom: 2rem;
  border-bottom: 1px solid var(--card-border);
}
.home-hero h1 {
  font-size: 1.8rem; font-weight: 700;
  letter-spacing: -.03em; color: var(--text);
  line-height: 1.2;
}
.home-hero p { margin-top: .5rem; font-size: .9rem; color: var(--text-muted); max-width: 36rem; line-height: 1.6; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .375rem;
  padding: .5rem 1rem; font-size: .88rem; font-weight: 600;
  border: none; border-radius: var(--radius-sm);
  transition: var(--transition);
  cursor: pointer; font-family: inherit;
}
.btn-primary {
  background: var(--primary); color: #fff;
  box-shadow: var(--shadow-card);
}
.btn-primary:hover { background: var(--primary-vivid); box-shadow: var(--shadow-elevated); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-outline {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
}
.btn-outline:hover { background: var(--surface-dim); border-color: var(--card-border-strong); }

.btn-sm { padding: .375rem .75rem; font-size: .75rem; }
.btn-xs { padding: .25rem .5rem; font-size: .7rem; border-radius: 6px; }

.btn-icon { padding: .375rem; border: none; background: transparent; border-radius: var(--radius-sm); color: var(--text-muted); transition: var(--transition); }
.btn-icon:hover { background: var(--surface-dim); }
.btn-icon-danger:hover { background: var(--danger-bg); color: var(--danger); }

.home-new-btn { padding: .625rem 1.25rem; }

/* ── KPI Cards (compCore MetricCard) ── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem; margin: 1.5rem 0;
}
.kpi-card {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}
.kpi-card:hover {
  box-shadow: var(--shadow-elevated);
  border-color: var(--card-border-strong);
}
.kpi-info { display: flex; flex-direction: column; }
.kpi-label {
  font-size: 12px; font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
}
.kpi-value {
  font-size: 28px; font-weight: 600;
  letter-spacing: -.02em; color: var(--text);
  margin-top: .25rem;
  font-variant-numeric: tabular-nums;
}
.kpi-desc {
  font-size: 12.5px; color: var(--text-muted);
  margin-top: .25rem;
}
.kpi-change {
  font-size: 11px; font-weight: 500;
  color: var(--text-muted); margin-top: .25rem;
}
.kpi-change.up { color: var(--success); }
.kpi-icon {
  width: 2rem; height: 2rem; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.kpi-icon .material-icons-round { font-size: 1rem; }

/* ── Cards ── */
.card {
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-elevated); border-color: var(--card-border-strong); }
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--card-border);
}
.card-header h3 {
  font-size: .92rem; font-weight: 600;
  color: var(--text); letter-spacing: -.01em;
}
.card-body { padding: 1.25rem; }

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; margin-top: 1rem; }

/* ── Data tables ── */
.data-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.data-table th {
  padding: .625rem 1rem;
  font-size: 12px; font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  background: var(--surface-dim);
  text-align: left;
  border-bottom: 1px solid var(--card-border);
}
.data-table td {
  padding: .5rem 1rem;
  border-bottom: 1px solid hsl(220,15%,93%);
  vertical-align: middle;
}
.data-table tbody tr { transition: var(--transition); }
.data-table tbody tr:hover { background: hsl(225,50%,97%); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* Clickable + selected rows */
.data-table tbody tr.clickable-row { cursor: pointer; }
.data-table tbody tr.clickable-row:hover { background: hsl(225,50%,95%); }
.data-table tbody tr.row-selected {
  background: hsl(225,50%,95%) !important;
  box-shadow: inset 3px 0 0 var(--primary-vivid);
}

/* ── Tags & Badges ── */
.tag {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .75rem; font-weight: 500;
  background: var(--surface-dim);
  color: var(--text-secondary);
}
.tag-purple { background: var(--accent-light); color: var(--accent); }
.tag-blue { background: var(--primary-light); color: var(--primary-vivid); }

/* Score badges */
.score-badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 999px;
  font-size: .75rem; font-weight: 600;
  white-space: nowrap;
}
.score-very-high { background: var(--success-bg); color: var(--success); }
.score-high { background: hsl(210,60%,94%); color: hsl(210,70%,40%); }
.score-medium { background: var(--warning-bg); color: hsl(38,80%,35%); }
.score-low { background: var(--danger-bg); color: var(--danger); }

/* Tier badges */
.tier-badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  font-size: .7rem; font-weight: 600;
}
.tier-high { background: var(--danger-bg); color: var(--danger); }
.tier-medium-high { background: var(--warning-bg); color: hsl(38,80%,35%); }
.tier-medium { background: hsl(210,60%,94%); color: hsl(210,70%,40%); }

/* ── Patient detail profile ── */
.patient-profile {
  display: flex; align-items: center; gap: 1rem;
}
.patient-avatar {
  width: 2.5rem; height: 2.5rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), hsl(225,40%,88%));
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: var(--primary);
  flex-shrink: 0;
}
.patient-meta { flex: 1; min-width: 0; }
.patient-meta h4 { font-size: .9rem; font-weight: 600; letter-spacing: -.01em; }
.patient-tags { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .25rem; }
.patient-score-lg { text-align: right; flex-shrink: 0; }
.patient-score-lg .score-num {
  font-size: 1.5rem; font-weight: 700;
  color: var(--primary); letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.patient-score-lg .score-label { font-size: .7rem; color: var(--text-muted); margin-top: 2px; }

/* ── Check list (Why reasons) ── */
.check-list { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.check-list li {
  display: flex; align-items: flex-start; gap: .5rem;
  font-size: .84rem; color: var(--text-secondary);
  line-height: 1.4;
}
.check-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.check-icon.pass { color: var(--success); }
.check-icon.warn { color: var(--warning); }

/* ── NBA list ── */
.nba-list { list-style: none; display: flex; flex-direction: column; gap: .75rem; }
.nba-item { display: flex; align-items: flex-start; gap: .75rem; }
.nba-num {
  width: 1.5rem; height: 1.5rem; flex-shrink: 0;
  border-radius: 50%;
  background: var(--primary-light); color: var(--primary-vivid);
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700;
}
.nba-text { font-size: .86rem; color: var(--text-secondary); line-height: 1.4; }

/* ── Charts (CSS-only) ── */

/* Factor bars */
.factor-item {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  align-items: center; gap: .75rem;
  padding: .375rem 0;
}
.factor-name { font-size: .8rem; color: var(--text-secondary); }
.factor-bar-track {
  height: 6px; border-radius: 999px;
  background: var(--surface-dim);
  overflow: hidden;
}
.factor-bar-fill {
  height: 100%; border-radius: 999px;
  background: var(--primary-vivid);
  transition: width .6s ease-out;
}
.factor-pct { font-size: .7rem; font-weight: 600; color: var(--text); min-width: 2rem; text-align: right; }

/* Chart explainer text */
.chart-explainer {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--card-border);
  font-size: .8rem;
  line-height: 1.55;
  color: var(--text-muted);
  background: var(--surface-dim);
}

/* Score bar */
.score-bar-track {
  height: 8px; border-radius: 999px;
  background: var(--surface-dim);
  overflow: hidden;
}
.score-bar-fill {
  height: 100%; border-radius: 999px;
  transition: width .6s ease-out;
}
.score-bar-labels {
  display: flex; justify-content: space-between;
  font-size: .6rem; color: var(--text-muted);
  margin-top: 4px;
}

/* Vertical bar chart */
.bar-chart {
  display: flex; align-items: stretch;
  gap: .5rem;
  height: 200px;
  padding: .5rem 0;
}
.bar-col {
  display: flex; flex-direction: column; align-items: center;
  flex: 1;
}
.bar-value {
  font-size: .72rem; font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.bar-col-track {
  flex: 1; width: 100%;
  display: flex; align-items: flex-end; justify-content: center;
}
.bar-fill {
  width: 70%; max-width: 48px;
  border-radius: 6px 6px 0 0;
  transition: height .5s ease-out;
  min-height: 4px;
}
.bar-label {
  font-size: .62rem; color: var(--text-muted);
  text-align: center;
  margin-top: 6px;
  line-height: 1.25;
  white-space: pre-line;
  flex-shrink: 0;
}

/* Donut chart */
.donut-chart {
  width: 140px; height: 140px;
  border-radius: 50%;
  position: relative;
  margin: 0 auto;
}
.donut-chart .donut-center {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.donut-val {
  font-size: 1.3rem; font-weight: 700;
  color: var(--text); display: block;
}
.donut-label {
  font-size: .65rem; color: var(--text-muted); display: block;
}

/* Line-of-Therapy / Stage timeline */
.lot-timeline {
  display: flex; align-items: flex-start;
  gap: 0; padding: .5rem 0;
}
.lot-node {
  display: flex; flex-direction: column;
  align-items: center;
  flex: 1; text-align: center;
}
.lot-dot {
  width: 2rem; height: 2rem;
  border-radius: 50%;
  color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,.15);
}
.lot-label-text {
  font-size: .68rem; color: var(--text-secondary);
  margin-top: .375rem; line-height: 1.35;
  max-width: 10rem;
}
.lot-connector {
  width: 2rem; height: 3px;
  background: var(--card-border);
  align-self: flex-start;
  margin-top: calc(1rem + 2px); /* align with center of dot */
  flex-shrink: 0;
}

/* Model performance (inline) */
.model-perf-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.model-perf-item { text-align: center; }
.model-perf-value { font-size: 1.3rem; font-weight: 700; color: var(--primary); }
.model-perf-label { font-size: .7rem; color: var(--text-muted); margin-top: .125rem; }

/* ── Wizard steps bar ── */
.wizard-steps-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--card-border);
  padding: .75rem 1.5rem;
  overflow-x: auto;
}
.wizard-steps-inner {
  display: flex; align-items: center; gap: 0;
  min-width: max-content;
}
.wizard-step-group {
  display: flex; align-items: center;
}
.wizard-step {
  display: flex; align-items: center; gap: .375rem;
  padding: .4rem .9rem;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--surface);
  font-size: .78rem; font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap; cursor: default;
  transition: var(--transition);
}
.wizard-step:disabled { opacity: .5; }
.wizard-step.active {
  background: var(--primary); color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(59,130,246,.25);
}
.wizard-step.done {
  background: var(--success-bg); color: var(--success);
  border-color: hsl(152,40%,85%);
  cursor: pointer; opacity: 1;
}
.wizard-step.done:hover { background: hsl(152,45%,88%); }
.wizard-step .material-icons-round { font-size: .85rem; }
.wizard-step-label { white-space: nowrap; }
.wizard-step-line {
  width: 1.5rem; height: 2px;
  background: var(--card-border);
  margin: 0 .125rem;
  flex-shrink: 0;
}
.wizard-step-line.done { background: var(--success); }
.wizard-step-arrow { color: var(--card-border); font-size: .7rem; }

/* ── Top nav (wizard/dashboard) ── */
.top-nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: .85rem 1.75rem;
  background: var(--primary);
  color: #fff;
}
.nav-left { display: flex; align-items: center; gap: .625rem; }
.nav-right { display: flex; align-items: center; gap: .875rem; }
.nav-brand { display: flex; align-items: center; gap: .5rem; font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }
.logo-icon {
  width: 2rem; height: 2rem;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center;
}
.logo-icon .material-icons-round { font-size: 1.2rem; }
.nav-model-tag {
  font-size: .72rem; font-weight: 500;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(255,255,255,.12);
}
.user-avatar {
  width: 2.25rem; height: 2.25rem;
  font-size: .78rem;
}
.nav-btn {
  padding: .375rem; border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius-sm); background: transparent;
  color: #fff; transition: var(--transition);
}
.nav-btn:hover { background: rgba(255,255,255,.1); }
.user-avatar {
  width: 2rem; height: 2rem;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255,255,255,.2), rgba(255,255,255,.05));
  border: 1px solid rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700;
}

/* ── Copilot search ── */
.copilot-bar {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  background: var(--surface);
  margin: 1rem 0;
}
.copilot-input {
  flex: 1; border: none; background: transparent;
  font-size: .82rem; color: var(--text);
  outline: none;
}
.copilot-input::placeholder { color: var(--text-muted); }

/* ── Dashboard body ── */
.dashboard { min-height: calc(100vh - 8rem); }
.dash-content { max-width: 80rem; margin: 0 auto; padding: 1.5rem; }
.dash-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin: 0 0 1.5rem;
}
.dash-title {}
.dash-header h1 { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; }
.dash-header p { font-size: .88rem; color: var(--text-muted); margin-top: .25rem; }
.dash-actions { display: flex; gap: .5rem; }
.dash-body { padding: 0 1.5rem 2rem; }

/* Read-only banner */
.readonly-banner {
  background: var(--warning-bg);
  color: hsl(38,80%,30%);
  text-align: center;
  padding: .5rem;
  font-size: .75rem;
  font-weight: 500;
  border-bottom: 1px solid hsl(38,60%,85%);
}

/* ── Run Prompt (pre-run state) ── */
.run-prompt {
  text-align: center;
  padding: 3rem 2rem;
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.run-prompt-icon { margin-bottom: 1rem; }
.run-prompt h2 {
  font-size: 1.15rem; font-weight: 700;
  letter-spacing: -.02em; color: var(--text);
  margin-bottom: .375rem;
}
.run-prompt p {
  font-size: .85rem; color: var(--text-muted);
  max-width: 28rem; margin: 0 auto;
  line-height: 1.5;
}
.run-prompt-metrics {
  display: flex; justify-content: center; gap: 1.5rem;
  margin-top: 1.5rem;
}
.run-metric { text-align: center; }
.run-metric-val {
  font-size: 1.1rem; font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.run-metric-label {
  font-size: .65rem; font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-top: .125rem;
}

/* ── Loading spinner ── */
.run-loading-spinner {
  width: 2.5rem; height: 2.5rem;
  border: 3px solid var(--surface-dim);
  border-top-color: var(--primary-vivid);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Results banner (post-run stats) ── */
.run-results-banner {
  display: flex; flex-wrap: wrap;
  gap: 1rem;
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  margin-bottom: 1.5rem;
}
.run-stat {
  flex: 1; min-width: 120px;
  text-align: center;
  padding: .5rem;
}
.run-stat-val {
  font-size: 1.25rem; font-weight: 700;
  color: var(--primary); letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.run-stat-label {
  font-size: .65rem; font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-top: .125rem;
}

/* ── Wizard bottom actions ── */
.wizard-actions {
  display: flex; justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--card-border);
}

/* ── Pagination ── */
.data-pagination {
  display: flex; align-items: center; justify-content: center;
  gap: .75rem; padding: .75rem 1rem;
  border-top: 1px solid var(--card-border);
}

/* ── Modal overlay ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
  animation: fadeIn .2s ease-out;
}
.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--card-border);
  padding: 1.75rem;
  width: 100%; max-width: 28rem;
  box-shadow: var(--shadow-modal);
}

/* ── Toast ── */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999;
  padding: .75rem 1.25rem;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: .82rem;
  box-shadow: var(--shadow-elevated);
  animation: fadeIn .3s ease-out;
}

/* ════════════════════════════════════════════
   HOME-SPECIFIC SECTIONS
   ════════════════════════════════════════════ */

.home-section { margin-top: 2rem; }
.home-section-header {
  display: flex; align-items: center; gap: .5rem;
  margin-bottom: 1rem;
}
.home-section-header h2 {
  font-size: 1rem; font-weight: 700;
  display: flex; align-items: center; gap: .375rem;
  letter-spacing: -.01em;
}
.wip-count {
  background: var(--warning-bg); color: hsl(38,80%,35%);
  font-size: .65rem; font-weight: 700;
  padding: 1px 8px; border-radius: 999px;
}

/* WIP cards */
.wip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.wip-card {
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.wip-card:hover { box-shadow: var(--shadow-elevated); border-color: var(--card-border-strong); transform: translateY(-1px); }
.wip-card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: .75rem; }
.wip-icon { color: var(--warning); }
.wip-delete {
  padding: .25rem; border: none; background: transparent;
  color: var(--text-muted); border-radius: 4px;
  transition: var(--transition);
}
.wip-delete:hover { background: var(--danger-bg); color: var(--danger); }
.wip-card-title { font-size: .85rem; font-weight: 600; color: var(--text); }
.wip-step-badge {
  display: inline-flex; align-items: center; gap: .375rem;
  margin-top: .375rem; padding: 2px 8px;
  border-radius: 999px;
  font-size: .65rem; font-weight: 500;
  background: var(--warning-bg); color: hsl(38,80%,35%);
}
.wip-pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--warning);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
.wip-card-time { font-size: .7rem; color: var(--text-muted); margin-top: .375rem; }
.wip-resume-btn {
  display: flex; align-items: center; gap: .25rem;
  margin-top: .75rem; padding: .375rem .75rem;
  border: 1px solid var(--primary-vivid); border-radius: var(--radius-sm);
  background: var(--primary-light); color: var(--primary-vivid);
  font-size: .72rem; font-weight: 600;
  transition: var(--transition);
}
.wip-resume-btn:hover { background: var(--primary); color: #fff; }

/* Import section */
.import-section { margin-top: 2rem; }
.import-card {
  padding: 2rem;
  border-radius: var(--radius);
  border: 2px dashed var(--card-border);
  background: var(--surface);
  text-align: center;
  transition: var(--transition);
}
.import-card:hover { border-color: var(--primary-vivid); background: var(--primary-light); }
.import-card-icon { margin-bottom: .75rem; color: var(--text-muted); }

/* Dataset selector */
.dataset-selector { display: flex; flex-direction: column; gap: .25rem; }
.dataset-selector select { min-width: 220px; }

/* 3-file import grid */
.import-3-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.import-source-card {
  display: flex; flex-direction: column; align-items: center;
  gap: .75rem;
  padding: 1.5rem 1rem;
  border-radius: var(--radius);
  border: 2px dashed var(--card-border);
  background: var(--surface);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}
.import-source-card:hover {
  border-color: var(--primary-vivid);
  background: var(--primary-light);
}
.import-source-card.uploaded {
  border-style: solid;
  border-color: var(--success);
  background: var(--success-bg);
}
.import-source-icon {
  width: 2.5rem; height: 2.5rem;
  border-radius: 50%;
  background: var(--surface-dim);
  display: flex; align-items: center; justify-content: center;
}
.import-source-icon .material-icons-round {
  font-size: 1.25rem; color: var(--text-muted);
}
.import-source-card.uploaded .import-source-icon {
  background: var(--success-bg);
}
.import-source-card.uploaded .import-source-icon .material-icons-round {
  color: var(--success);
}
.import-source-info h4 {
  font-size: .88rem; font-weight: 600; color: var(--text);
}
.import-source-info p {
  font-size: .75rem; color: var(--text-muted);
  margin-top: .125rem;
}
.import-source-card.uploaded .import-source-info p {
  color: var(--success);
}

@media (max-width: 768px) {
  .import-3-grid { grid-template-columns: 1fr; }
}

/* Saved analyses */
.saved-analyses { margin-top: 2rem; }
.saved-analyses h2 {
  font-size: 1rem; font-weight: 700; margin-bottom: 1rem;
  display: flex; align-items: center; gap: .375rem;
}

/* ── AI Insights Grid ── */
.insights-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.insight-card {
  transition: var(--transition);
}
.insight-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-elevated);
}
.insight-priority {
  display: inline-flex; align-items: center; gap: .25rem;
  font-size: .72rem; font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ── Revenue Calculator ── */
.rev-input-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.rev-input-group label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--text); margin-bottom: .25rem;
}
.rev-input-row {
  display: flex; align-items: center; gap: 0;
}
.rev-input-row .form-input {
  border-radius: 0; flex: 1;
}
.rev-input-row .form-input:first-child,
.rev-input-row .rev-prefix + .form-input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.rev-input-row .form-input:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.rev-input-row .form-input:only-child { border-radius: var(--radius-sm); }
.rev-prefix, .rev-suffix {
  padding: .625rem .625rem;
  background: var(--surface-dim);
  border: 1px solid var(--card-border);
  font-size: 13px; font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}
.rev-prefix { border-right: none; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.rev-suffix { border-left: none; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.rev-hint {
  display: block;
  font-size: 11px; color: var(--text-muted);
  margin-top: .25rem;
}

/* Revenue waterfall */
.rev-waterfall { display: flex; flex-direction: column; gap: 1rem; }
.rev-wf-row {
  display: grid; grid-template-columns: 8rem 1fr 6rem;
  align-items: center; gap: .75rem;
}
.rev-wf-label { font-size: .8rem; font-weight: 500; color: var(--text-secondary); }
.rev-wf-bar-track {
  height: 1.25rem; border-radius: var(--radius-sm);
  background: var(--surface-dim); overflow: hidden;
}
.rev-wf-bar {
  height: 100%; border-radius: var(--radius-sm);
  transition: width .5s ease-out;
  min-width: 4px;
}
.rev-wf-val {
  font-size: .85rem; font-weight: 600;
  color: var(--text); text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Patient funnel */
.rev-funnel { display: flex; flex-direction: column; gap: .625rem; }
.rev-funnel-step {
  display: flex; align-items: center; gap: .75rem;
}
.rev-funnel-bar {
  height: 1.5rem; border-radius: var(--radius-sm);
  transition: width .5s ease-out;
  min-width: 8px;
}
.rev-funnel-step span {
  font-size: .8rem; font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .grid-2, .grid-2-1 { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .kpi-row { grid-template-columns: 1fr; }
  .home-hero { flex-direction: column; }
}
