/* ── Theme tokens ─────────────────────────────────────────────────────────── */
:root {
  --bg-base:       #0f1117;
  --bg-surface:    #1a1d2e;
  --bg-raised:     #1f2339;
  --bg-sunken:     #0d1017;
  --bg-overlay:    #141728;

  --border:        #2d3452;
  --border-subtle: #242840;
  --border-faint:  #1e2235;

  --text-primary:  #f1f5f9;
  --text-heading:  #f1f5f9;
  --text-body:     #e2e8f0;
  --text-muted:    #94a3b8;
  --text-faint:    #64748b;
  --text-ghost:    #64748b;
  --text-dim:      #6b7280;

  --accent:        #6366f1;
  --accent-hover:  #4f46e5;
  --accent-subtle: rgba(99,102,241,0.08);
  --accent-faint:  rgba(99,102,241,0.04);

  --shadow-md:     0 8px 24px rgba(0,0,0,0.35);
  --shadow-lg:     0 16px 40px rgba(0,0,0,0.5);

  /* scrollbar */
  --scroll-track:  #1a1d2e;
  --scroll-thumb:  #334155;

  /* notif bell */
  --notif-border:  #0f1117;
}

[data-theme="light"] {
  --bg-base:       #f1f5f9;
  --bg-surface:    #ffffff;
  --bg-raised:     #f8fafc;
  --bg-sunken:     #e8edf4;
  --bg-overlay:    #f0f4f8;

  --border:        #cbd5e1;
  --border-subtle: #dde3ed;
  --border-faint:  #e2e8f0;

  --text-primary:  #0f172a;
  --text-heading:  #0f172a;
  --text-body:     #1e293b;
  --text-muted:    #475569;
  --text-faint:    #64748b;
  --text-ghost:    #94a3b8;
  --text-dim:      #64748b;

  --accent:        #4f46e5;
  --accent-hover:  #4338ca;
  --accent-subtle: rgba(79,70,229,0.08);
  --accent-faint:  rgba(79,70,229,0.04);

  --shadow-md:     0 4px 16px rgba(15,23,42,0.08);
  --shadow-lg:     0 12px 32px rgba(15,23,42,0.14);

  --scroll-track:  #e8edf4;
  --scroll-thumb:  #94a3b8;

  --notif-border:  #f1f5f9;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-base);
  color: var(--text-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--scroll-track); }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 3px; }

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

.hidden { display: none !important; }
.muted  { color: var(--text-faint); }
.bold   { font-weight: 600; }
.sm     { font-size: 13px; }
.center { text-align: center; }
.mt-8   { margin-top: 8px; }

/* ── Generate Assessment button row ──────────────────────────────────────────────── */
.assess-btn-row { display: flex; gap: 10px; align-items: stretch; margin-top: 8px; }
.assess-btn-row .btn-primary  { flex: 1; }
.btn-cancel-assess {
  flex: 1;
  background: #dc2626;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-cancel-assess:hover:not(:disabled) { background: #b91c1c; }
.btn-cancel-assess:disabled { opacity: 0.5; cursor: not-allowed; }
.mt-16  { margin-top: 16px; }
.mb-12  { margin-bottom: 12px; }
.mb-16  { margin-bottom: 16px; }
.p-16   { padding: 16px; }
.req    { color: #ef4444; margin-left: 2px; }

/* ── Animations ───────────────────────────────────────────────────────────── */
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes fadeUp   { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse    { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes bellShake{ 0%,100%{transform:rotate(0)} 20%{transform:rotate(-12deg)} 40%{transform:rotate(12deg)} 60%{transform:rotate(-8deg)} 80%{transform:rotate(8deg)} }

.fade-up { animation: fadeUp 0.3s ease-out both; }

/* ── Form elements ────────────────────────────────────────────────────────── */
input, select, textarea {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-body);
  outline: none;
  transition: border-color 0.15s, background 0.2s, color 0.2s;
}
/* Radios and checkboxes are not text fields — undo the full-width box above,
   otherwise the control stretches and pushes its label away. */
input[type="radio"], input[type="checkbox"] {
  width: auto; flex: none; padding: 0; margin: 0; border: none; border-radius: 0;
  accent-color: var(--accent); cursor: pointer;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--text-ghost); }
select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
select option, select optgroup { background: var(--bg-surface); color: var(--text-body); }
textarea { resize: vertical; line-height: 1.6; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.field-err { display: block; font-size: 12px; color: #ef4444; margin-top: 4px; }
.input-wrap { position: relative; }
.input-wrap input { padding-right: 56px; }
.toggle-pw { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text-faint); font-size: 13px; cursor: pointer; font-family: inherit; width: auto; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.section-label { font-size: 11px; font-weight: 600; color: var(--text-ghost); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 8px; border: none;
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: opacity 0.15s, filter 0.15s; width: 100%;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:not(:disabled):hover { filter: brightness(1.08); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-success { background: #059669; color: #fff; }
.btn-danger  { background: #dc2626; color: #fff; }
.btn-amber   { background: #d97706; color: #fff; }
.btn-ghost   { background: var(--bg-raised); color: var(--text-muted); border: 1px solid var(--border); }
.btn-sm      { padding: 7px 14px; font-size: 13px; width: auto; }
.link-btn    { background: none; border: none; color: var(--text-faint); font-size: 13px; cursor: pointer; font-family: inherit; text-decoration: underline; width: auto; }

/* ── MRN lookup ───────────────────────────────────────────────────────────── */
.mrn-lookup { display: flex; gap: 8px; align-items: stretch; }
.mrn-lookup input { flex: 1; }
.mrn-lookup .btn { white-space: nowrap; }
.mrn-result { margin-top: 10px; font-size: 13px; line-height: 1.5; padding: 8px 10px; border-radius: 8px; }
.mrn-result.ok    { background: rgba(5,150,105,0.10); border: 1px solid rgba(5,150,105,0.35); color: #059669; }
.mrn-result.warn  { background: rgba(217,119,6,0.10);  border: 1px solid rgba(217,119,6,0.35);  color: #d97706; }
.mrn-result.err   { background: rgba(220,38,38,0.10);  border: 1px solid rgba(220,38,38,0.35);  color: #ef4444; }
.mrn-history { display: block; margin-top: 4px; font-size: 12px; opacity: 0.85; }
.ehr-link { display: inline-block; margin-top: 6px; font-weight: 600; text-decoration: underline; }

/* ── Finalise diagnosis ───────────────────────────────────────────────────── */
.finalise-block { background: rgba(99,102,241,0.08); border: 1px solid rgba(99,102,241,0.35);
  border-radius: 10px; padding: 14px 16px; margin: 14px 0; }
.finalise-block .result-block-title { margin-bottom: 6px; }
.finalise-hint { font-size: 12.5px; color: #64748b; margin-bottom: 12px; line-height: 1.5; }
.finalise-opts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.finalise-opt { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; cursor: pointer;
  padding: 8px 10px; border-radius: 8px; line-height: 1.4;
  border: 1px solid transparent; }
.finalise-opt > span { flex: 1; }
.finalise-opt:has(input:checked) { border-color: rgba(99,102,241,0.45); background: rgba(99,102,241,0.10); }
.finalise-opt:hover { background: rgba(255,255,255,0.04); }
.finalise-opt input[type="radio"] { accent-color: #818cf8; margin-top: 2px; flex-shrink: 0; }
.finalise-lik { color: #94a3b8; font-size: 12px; }
.finalise-other-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.finalise-other-row label { font-size: 12.5px; color: #94a3b8; }
.finalise-other { width: 100%; }
.finalise-banner { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  background: rgba(5,150,105,0.10); border: 1px solid rgba(5,150,105,0.40); border-radius: 10px;
  padding: 12px 16px; margin: 14px 0; font-size: 14px; }
.finalise-banner .finalise-check { color: #10b981; font-weight: 700; }
.finalise-banner .finalise-sub { font-size: 12px; color: #64748b; margin-top: 3px; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert { padding: 12px 14px; border-radius: 8px; font-size: 14px; line-height: 1.6; }
.alert-error   { background: #2d0f0f; border: 1px solid #7f1d1d; color: #f87171; }
.alert-success { background: #022c22; border: 1px solid #065f46; color: #34d399; }
.alert-info    { background: #13163d; border: 1px solid #2d3370; color: #a5b4fc; }

[data-theme="light"] .alert-error   { background: #fff1f2; border-color: #fecaca; color: #dc2626; }
[data-theme="light"] .alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #16a34a; }
[data-theme="light"] .alert-info    { background: #eef2ff; border-color: #c7d2fe; color: #4338ca; }

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; }

/* ── Theme toggle button ──────────────────────────────────────────────────── */
.theme-toggle {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--bg-surface); border: 1px solid var(--border);
  cursor: pointer; font-size: 16px; display: flex; align-items: center;
  justify-content: center; transition: background 0.15s; flex-shrink: 0;
}
.theme-toggle:hover { background: var(--bg-raised); }

/* ── Auth page ────────────────────────────────────────────────────────────── */
.auth-body   { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 2rem 1rem; }
.auth-wrap   { width: 100%; max-width: 440px; }
.auth-logo   { text-align: center; margin-bottom: 28px; }
.auth-logo h1 { font-size: 24px; font-weight: 700; color: var(--text-primary); margin-top: 12px; }
.auth-tagline { font-size: 13px; color: var(--text-ghost); margin-top: 4px; }
.auth-card   { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; }
.auth-card h2 { font-size: 20px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.auth-sub    { font-size: 14px; color: var(--text-faint); margin-bottom: 20px; }
.auth-switch { text-align: center; font-size: 14px; color: var(--text-faint); margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border-subtle); }
.auth-footer { text-align: center; font-size: 12px; color: var(--text-dim); margin-top: 14px; }
.auth-pane.hidden { display: none; }
.strength-wrap { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.strength-bar  { flex: 1; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.strength-bar > div { height: 100%; border-radius: 2px; transition: width 0.3s, background 0.3s; width: 0; }
#strength-label { font-size: 12px; font-weight: 600; min-width: 36px; }
#specialty-wrap { overflow: hidden; transition: max-height 0.3s ease, opacity 0.25s ease; }

/* ── Header ───────────────────────────────────────────────────────────────── */
#app-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-base);
  position: sticky; top: 0; z-index: 50;
  transition: background 0.2s, border-color 0.2s;
}
.header-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 24px;
  height: 60px; display: flex; align-items: center; justify-content: space-between;
}
.header-left  { display: flex; align-items: center; gap: 20px; }
.header-right { display: flex; align-items: center; gap: 12px; }
/* Accent tile holding the ClinIQ stethoscope mark — the same icon as the
   ClinIQ App card in the cliniqAI landing page Products dropdown. Strokes are
   currentColor, so the colour comes from here (white on accent), mirroring how
   ehr-cliniq renders its mark on a teal tile. */
.logo-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: #fff; }
.logo-mark svg { width: 18px; height: 18px; display: block; }
.logo-mark.sm { width: 28px; height: 28px; }
.logo-mark.sm svg { width: 16px; height: 16px; }
.logo-text { display: flex; flex-direction: column; }
.logo-name { font-size: 15px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.logo-sub  { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
#main-nav  { display: flex; gap: 2px; }
.nav-btn   { padding: 7px 14px; border-radius: 7px; border: none; font-size: 14px; font-weight: 500; font-family: inherit; cursor: pointer; background: transparent; color: var(--text-faint); display: flex; align-items: center; gap: 6px; transition: all 0.15s; }
.nav-btn.active { background: var(--bg-raised); color: var(--text-body); }
.nav-btn:hover:not(.active) { background: var(--bg-surface); color: var(--text-muted); }
.badge-red { background: #ef4444; color: #fff; border-radius: 10px; font-size: 11px; font-weight: 700; padding: 1px 6px; }
.ai-status { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-ghost); }
.dot-green { width: 8px; height: 8px; border-radius: 50%; background: #34d399; animation: pulse 1.5s ease-in-out infinite; }

/* Notification bell */
.notif-wrap { position: relative; }
.notif-btn  { position: relative; width: 36px; height: 36px; border-radius: 8px; background: var(--bg-surface); border: 1px solid var(--border); cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; }
.notif-btn .badge-red { position: absolute; top: -4px; right: -4px; border: 2px solid var(--notif-border); }
.notif-dropdown { position: absolute; right: 0; top: calc(100% + 8px); width: 340px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; z-index: 200; animation: fadeUp 0.2s ease-out; }
.notif-header { padding: 14px 16px; border-bottom: 1px solid var(--border-subtle); display: flex; justify-content: space-between; align-items: center; }
.notif-header > span { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.notif-header > button { background: none; border: none; color: var(--accent); font-size: 13px; cursor: pointer; font-family: inherit; }
.notif-item { padding: 14px 16px; border-bottom: 1px solid var(--border-faint); cursor: pointer; display: flex; gap: 12px; transition: background 0.15s; }
.notif-item:hover { background: var(--bg-raised); }
.notif-item.unread { background: var(--accent-subtle); }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; margin-top: 5px; }
.notif-empty { padding: 2rem; text-align: center; color: var(--text-ghost); font-size: 14px; }

/* User menu */
.user-menu-wrap { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; cursor: pointer; font-family: inherit; transition: background 0.15s; }
.user-btn:hover { background: var(--bg-raised); }
.avatar { width: 28px; height: 28px; border-radius: 7px; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0; }
.user-info { text-align: left; }
.user-info > span:first-child { display: block; font-size: 14px; font-weight: 600; color: var(--text-body); line-height: 1; }
.user-role { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.user-dropdown { position: absolute; right: 0; top: calc(100% + 8px); width: 220px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md); overflow: hidden; z-index: 100; animation: fadeUp 0.2s ease-out; }
.user-dropdown-info { padding: 14px 16px; border-bottom: 1px solid var(--border-subtle); }
.user-dropdown-info > p:first-child { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.user-dropdown-info .muted { font-size: 13px; margin-top: 2px; }
.dd-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.logout-btn { width: 100%; display: flex; align-items: center; gap: 8px; padding: 12px 16px; background: none; border: none; font-size: 14px; color: #ef4444; cursor: pointer; font-family: inherit; transition: background 0.15s; text-align: left; }
.logout-btn:hover { background: rgba(239,68,68,0.08); }

/* Doctor availability toggle */
.dd-availability { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border-subtle); }
.avail-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-body, var(--text-primary)); }
.avail-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); flex-shrink: 0; transition: background 0.15s; }
.avail-dot-on { background: #22c55e; }
.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider { position: absolute; inset: 0; cursor: pointer; background: var(--border); border-radius: 20px; transition: background 0.2s; }
.switch-slider::before { content: ""; position: absolute; height: 14px; width: 14px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform 0.2s; }
.switch input:checked + .switch-slider { background: #22c55e; }
.switch input:checked + .switch-slider::before { transform: translateX(16px); }
.switch input:focus-visible + .switch-slider { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.tab-inner { max-width: 1200px; margin: 0 auto; padding: 24px; }
.tab-title-row { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.tab-title-row h2 { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.tab-title-row .muted { font-size: 14px; margin-top: 4px; }

/* ── Assessment tab ──────────────────────────────────────────────────────────── */
.assessment-grid { display: grid; grid-template-columns: 2fr 3fr; gap: 20px; max-width: 1200px; margin: 0 auto; padding: 24px; }
.specialty-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.spec-btn { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border); font-size: 13px; font-weight: 500; font-family: inherit; cursor: pointer; background: var(--bg-surface); color: var(--text-faint); text-align: left; transition: all 0.15s; }
.spec-btn.active { background: var(--accent-subtle); border-color: var(--accent); color: var(--accent); }
.mode-toggle { display: flex; background: var(--bg-raised); border-radius: 8px; padding: 4px; gap: 4px; }
.mode-btn { flex: 1; padding: 8px 12px; border-radius: 6px; border: none; font-size: 13px; font-weight: 500; font-family: inherit; cursor: pointer; background: transparent; color: var(--text-faint); transition: all 0.15s; }
.mode-btn.active { background: var(--accent); color: #fff; }
.footer-note { text-align: center; font-size: 12px; color: var(--text-dim); margin-top: 8px; }

/* Result panel */
.empty-state { border: 2px dashed var(--border); border-radius: 12px; padding: 4rem 2rem; text-align: center; min-height: 400px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.empty-title  { font-size: 16px; font-weight: 600; color: var(--text-faint); }
.empty-sub    { font-size: 14px; color: var(--text-dim); margin-top: 8px; max-width: 300px; line-height: 1.6; }
.loading-state { border: 1px solid var(--border); background: var(--bg-surface); border-radius: 12px; padding: 4rem 2rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.loading-center { text-align: center; padding: 4rem 2rem; display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--text-faint); }
.spinner-wrap { position: relative; width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; }
.spinner      { width: 100%; height: 100%; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
.loading-title { font-size: 15px; font-weight: 600; color: var(--text-body); }
.result-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.result-title  { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.disclaimer-box { background: var(--bg-raised); border: 1px solid var(--border-subtle); border-radius: 8px; padding: 10px 14px; margin-top: 10px; font-size: 12px; color: var(--text-ghost); font-style: italic; line-height: 1.5; }

/* Clinical result blocks */
.result-summary { background: var(--accent-subtle); border: 1px solid rgba(99,102,241,0.25); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; font-size: 14px; color: var(--text-body); line-height: 1.7; }
.result-block { border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; }
.result-block-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }

.block-red    { background: rgba(220,38,38,0.07); border: 1px solid rgba(220,38,38,0.25); }
.block-red    .result-block-title { color: #f87171; }
.block-cyan   { background: rgba(6,182,212,0.06); border: 1px solid rgba(6,182,212,0.2); }
.block-cyan   .result-block-title { color: #22d3ee; }
.block-violet { background: rgba(99,102,241,0.06); border: 1px solid rgba(99,102,241,0.2); }
.block-violet .result-block-title { color: #a5b4fc; }
.block-green  { background: rgba(16,185,129,0.06); border: 1px solid rgba(16,185,129,0.2); }
.block-green  .result-block-title { color: #34d399; }
.block-amber  { background: rgba(245,158,11,0.07); border: 1px solid rgba(245,158,11,0.2); }
.block-amber  .result-block-title { color: #fbbf24; }
.block-default{ background: var(--bg-raised); border: 1px solid var(--border); }
.block-default .result-block-title { color: var(--text-muted); }
.block-teal   { background: rgba(6,182,212,0.05); border: 1px solid rgba(6,182,212,0.2); }
.block-teal   .result-block-title { color: #22d3ee; }

[data-theme="light"] .block-red    { background: #fff1f2; border-color: #fecaca; }
[data-theme="light"] .block-red    .result-block-title { color: #dc2626; }
[data-theme="light"] .block-cyan   { background: #ecfeff; border-color: #a5f3fc; }
[data-theme="light"] .block-cyan   .result-block-title { color: #0891b2; }
[data-theme="light"] .block-violet { background: #eef2ff; border-color: #c7d2fe; }
[data-theme="light"] .block-violet .result-block-title { color: #4338ca; }
[data-theme="light"] .block-green  { background: #f0fdf4; border-color: #bbf7d0; }
[data-theme="light"] .block-green  .result-block-title { color: #059669; }
[data-theme="light"] .block-amber  { background: #fffbeb; border-color: #fde68a; }
[data-theme="light"] .block-amber  .result-block-title { color: #d97706; }
[data-theme="light"] .block-teal   { background: #ecfeff; border-color: #a5f3fc; }
[data-theme="light"] .block-teal   .result-block-title { color: #0891b2; }
[data-theme="light"] .result-summary { background: #eef2ff; border-color: #c7d2fe; }

.dx-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 8px; }
.dx-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dx-name  { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.dx-cols  { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dx-col-label { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.dx-col-label.green { color: #34d399; }
.dx-col-label.red   { color: #f87171; }
[data-theme="light"] .dx-col-label.green { color: #059669; }
[data-theme="light"] .dx-col-label.red   { color: #dc2626; }
.dx-item  { font-size: 13px; color: var(--text-muted); margin-bottom: 3px; }

/* ── Diagnosis references ──────────────────────────────────────────────────── */
.dx-refs        { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border-faint); }
.dx-ref-label   { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
                  color: var(--text-ghost); margin-bottom: 6px; }
.dx-ref-item    { display: flex; align-items: baseline; gap: 8px; margin-bottom: 5px; flex-wrap: wrap; }
.dx-ref-source  { font-size: 11px; font-weight: 700; color: #818cf8; background: rgba(99,102,241,0.1);
                  border: 1px solid rgba(99,102,241,0.2); border-radius: 4px;
                  padding: 1px 6px; white-space: nowrap; flex-shrink: 0; }
.dx-ref-title   { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
a.dx-ref-title  { color: #93c5fd; text-decoration: none; }
a.dx-ref-title:hover { text-decoration: underline; color: #bfdbfe; }
[data-theme="light"] .dx-ref-source { color: #4338ca; background: #eef2ff; border-color: #c7d2fe; }
[data-theme="light"] a.dx-ref-title { color: #2563eb; }
[data-theme="light"] a.dx-ref-title:hover { color: #1d4ed8; }
.inv-category { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: #0891b2; margin-bottom: 6px; }
.inv-rationale { font-size: 13px; color: var(--text-faint); font-style: italic; margin-top: 4px; }
.action-row { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.action-text { font-size: 14px; color: var(--text-body); line-height: 1.6; }

/* Pill badges */
.pill { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 20px; white-space: nowrap; flex-shrink: 0; }
.pill-red    { background: rgba(220,38,38,0.12); color: #f87171; border: 1px solid rgba(220,38,38,0.3); }
.pill-amber  { background: rgba(217,119,6,0.12);  color: #fbbf24; border: 1px solid rgba(217,119,6,0.3); }
.pill-green  { background: rgba(5,150,105,0.12);  color: #34d399; border: 1px solid rgba(5,150,105,0.3); }
.pill-blue   { background: rgba(37,99,235,0.12);  color: #93c5fd; border: 1px solid rgba(37,99,235,0.3); }
.pill-violet { background: rgba(99,102,241,0.12); color: #a5b4fc; border: 1px solid rgba(99,102,241,0.3); }
.pill-cyan   { background: rgba(6,182,212,0.12);  color: #67e8f9; border: 1px solid rgba(6,182,212,0.3); }
.pill-slate  { background: var(--bg-raised); color: var(--text-muted); border: 1px solid var(--border); }
.pill-tags   { display: flex; flex-wrap: wrap; gap: 6px; }

[data-theme="light"] .pill-red    { background: #fff1f2; color: #dc2626; border-color: #fecaca; }
[data-theme="light"] .pill-amber  { background: #fffbeb; color: #d97706; border-color: #fde68a; }
[data-theme="light"] .pill-green  { background: #f0fdf4; color: #059669; border-color: #bbf7d0; }
[data-theme="light"] .pill-blue   { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }
[data-theme="light"] .pill-violet { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }
[data-theme="light"] .pill-cyan   { background: #ecfeff; color: #0891b2; border-color: #a5f3fc; }

/* ── Cases tab ────────────────────────────────────────────────────────────── */
.filter-row { display: flex; gap: 4px; background: var(--bg-raised); border-radius: 10px; padding: 4px; margin-bottom: 20px; flex-wrap: wrap; }
.filter-btn { padding: 8px 14px; border-radius: 7px; border: none; font-size: 13px; font-weight: 500; font-family: inherit; cursor: pointer; background: transparent; color: var(--text-faint); display: flex; align-items: center; gap: 6px; transition: all 0.15s; }
.filter-btn.active { background: var(--accent); color: #fff; }
.filter-count { font-size: 11px; padding: 1px 6px; border-radius: 10px; background: rgba(255,255,255,0.1); }
[data-theme="light"] .filter-count { background: rgba(0,0,0,0.08); }
.case-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px; cursor: pointer; transition: all 0.15s; display: flex; align-items: center; gap: 16px; margin-bottom: 8px; animation: fadeUp 0.2s ease-out; }
.case-card:hover { background: var(--bg-raised); border-color: var(--accent); }
.case-card.pending-card  { border-color: rgba(245,158,11,0.4); }
.case-card.admitted-card { border-color: rgba(16,185,129,0.4); }
.case-icon { width: 44px; height: 44px; border-radius: 10px; background: var(--bg-raised); display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.case-info { flex: 1; min-width: 0; }
.case-name-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.case-name { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.case-meta { display: flex; gap: 16px; flex-wrap: wrap; }
.case-meta span { font-size: 13px; color: var(--text-faint); }
.case-right { text-align: right; flex-shrink: 0; }
.case-right .muted { font-size: 12px; margin-top: 4px; }
.case-action { font-size: 12px; color: var(--accent); margin-top: 4px; }
.status-badge { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 20px; white-space: nowrap; }

/* ── Dashboard ────────────────────────────────────────────────────────────── */
.grain-toggle { display: flex; gap: 4px; background: var(--bg-raised); border-radius: 8px; padding: 4px; }
.grain-btn { padding: 7px 14px; border-radius: 6px; border: none; font-size: 13px; font-weight: 500; font-family: inherit; cursor: pointer; background: transparent; color: var(--text-faint); transition: all 0.15s; }
.grain-btn.active { background: var(--accent); color: #fff; }
.kpi-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 20px; }
.kpi-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; position: relative; overflow: hidden; }
.kpi-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--accent); }
.kpi-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-ghost); margin-bottom: 8px; }
.kpi-val   { font-size: 28px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.kpi-sub   { font-size: 13px; color: var(--text-faint); margin-top: 6px; }
.kpi-icon  { position: absolute; top: 16px; right: 16px; font-size: 22px; opacity: 0.6; }
.chart-row { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
.chart-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.chart-title { font-size: 14px; font-weight: 600; color: var(--text-body); margin-bottom: 16px; }
.pie-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; }
.pie-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-faint); }
.pie-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ── Modals ───────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 16px; }
[data-theme="light"] .modal-overlay { background: rgba(15,23,42,0.4); }
.modal-box { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; animation: fadeUp 0.25s ease-out; box-shadow: var(--shadow-lg); }
.modal-large { max-width: 760px; }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border-subtle); display: flex; align-items: flex-start; justify-content: space-between; }
.modal-header h3 { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.modal-header .muted { font-size: 13px; margin-top: 4px; }
.modal-close { background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: 24px; line-height: 1; margin-left: 16px; flex-shrink: 0; }
.modal-body { padding: 20px 24px; }
.sticky-header { position: sticky; top: 0; background: var(--bg-surface); z-index: 10; }
.detail-strip { display: flex; gap: 24px; background: var(--bg-raised); border: 1px solid var(--border-subtle); border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; flex-wrap: wrap; }
.detail-item label { font-size: 11px; font-weight: 600; color: var(--text-ghost); text-transform: uppercase; letter-spacing: 0.06em; display: block; margin-bottom: 2px; }
.detail-item span  { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.edit-action-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.edit-action-row input { flex: 1; padding: 8px 10px; font-size: 13px; }
/* Doctor's editable management plan rows in the review modal */
.rm-ap-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.rm-ap-row .draft-input { flex: 1; }
.modal-actions-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 8px; }
.modal-actions-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.reviewed-note { text-align: center; font-size: 13px; color: var(--text-ghost); margin-top: 12px; }

/* ── Follow-up questions ──────────────────────────────────────────────────── */
.followup-q {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border-faint);
}
.followup-q:last-child { border-bottom: none; }
.followup-num {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(6,182,212,0.12); border: 1px solid rgba(6,182,212,0.3);
  color: #22d3ee; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
[data-theme="light"] .followup-num { background: #ecfeff; border-color: #a5f3fc; color: #0891b2; }
.followup-text { font-size: 14px; color: var(--text-muted); line-height: 1.6; margin: 0; }

/* ── Review modal tabs ────────────────────────────────────────────────────── */
.rm-tab-bar {
  display: flex; border-bottom: 1px solid var(--border-faint);
  background: var(--bg-sunken); flex-shrink: 0;
}
.rm-tab {
  padding: 11px 20px; font-size: 13px; font-weight: 600;
  color: var(--text-ghost); background: none; border: none;
  border-bottom: 2px solid transparent; cursor: pointer;
  transition: color 0.15s; display: flex; align-items: center; gap: 6px;
}
.rm-tab:hover  { color: var(--text-muted); }
.rm-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.badge-indigo {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 10px; font-weight: 700;
}

/* ── Chat panel ───────────────────────────────────────────────────────────── */
.chat-panel {
  display: flex; flex-direction: column; min-height: 0; padding: 0 !important;
}
.chat-panel.hidden { display: none; }

.chat-reanalyse-bar {
  padding: 12px 20px; border-bottom: 1px solid var(--border-faint);
  background: var(--accent-faint); flex-shrink: 0;
}
.chat-apply-notice { margin-top: 8px; font-size: 12px; color: #34d399; font-weight: 600; }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px 20px;
  display: flex; flex-direction: column; gap: 4px;
  min-height: 200px; max-height: 380px;
}

.chat-pin {
  background: rgba(6,182,212,0.06); border: 1px solid rgba(6,182,212,0.18);
  border-radius: 10px; padding: 14px 16px; margin-bottom: 12px;
}
[data-theme="light"] .chat-pin { background: #ecfeff; border-color: #a5f3fc; }
.chat-pin-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: #22d3ee; margin-bottom: 10px; }
[data-theme="light"] .chat-pin-title { color: #0891b2; }
.chat-pin-q { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; border-bottom: 1px solid rgba(6,182,212,0.08); }
.chat-pin-q:last-child { border-bottom: none; }
.chat-pin-q p { font-size: 13px; color: var(--text-muted); margin: 0; line-height: 1.5; }

.chat-bubble-wrap { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 8px; }
.chat-bubble-wrap.me   { flex-direction: row-reverse; }
.chat-bubble-wrap.them { flex-direction: row; }
.chat-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg,#4f46e5,#0891b2);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #fff;
}
.chat-bubble { max-width: 75%; border-radius: 14px; padding: 10px 14px; }
.bubble-me   { background: var(--accent); border-bottom-right-radius: 4px; }
.bubble-them { background: var(--bg-raised); border: 1px solid var(--border-faint); border-bottom-left-radius: 4px; }
[data-theme="light"] .bubble-me { background: #4f46e5; }

.chat-sender { font-size: 11px; font-weight: 700; margin-bottom: 4px; }
.chat-text   { font-size: 14px; color: var(--text-body); margin: 0; line-height: 1.5; white-space: pre-wrap; }
.bubble-me .chat-text { color: #fff; }
.chat-time   { font-size: 11px; color: var(--text-dim); margin: 4px 0 0; text-align: right; }
.bubble-me .chat-time { color: rgba(255,255,255,0.6); }

.chat-system-msg {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  font-size: 12px; color: var(--text-ghost); padding: 8px 0; flex-wrap: wrap;
  border-top: 1px dashed var(--border-faint); border-bottom: 1px dashed var(--border-faint); margin: 8px 0;
}

.chat-input-bar {
  display: flex; align-items: flex-end; gap: 10px; padding: 14px 20px;
  border-top: 1px solid var(--border-faint); background: var(--bg-sunken); flex-shrink: 0;
}
.chat-input-bar textarea {
  flex: 1; resize: none; font-size: 14px;
  min-height: 52px; max-height: 120px;
  padding: 12px 14px; line-height: 1.5; border-radius: 10px;
}
.chat-send-btn {
  flex-shrink: 0; height: 40px; width: 40px; padding: 0; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  transition: background 0.15s; align-self: flex-end; margin-bottom: 6px;
}
.chat-send-btn:hover    { background: var(--accent-hover); }
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Draft editor ─────────────────────────────────────────────────────────── */
.chat-draft-banner {
  border-top: 2px solid rgba(99,102,241,0.35);
  background: var(--bg-overlay); flex-shrink: 0;
  max-height: 60vh; overflow-y: auto;
}
.chat-draft-banner.hidden { display: none; }

.chat-draft-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px 12px; flex-wrap: wrap; gap: 6px;
  border-bottom: 1px solid var(--border-faint); background: var(--accent-faint);
}
.chat-draft-header-left  { display: flex; flex-direction: column; gap: 2px; }
.chat-draft-header-left span:first-child { font-size: 13px; font-weight: 700; color: var(--accent); }
.chat-draft-sub { font-size: 12px; color: var(--text-ghost); }

.draft-sections { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }

.draft-section { background: var(--bg-surface); border: 1px solid var(--border-faint); border-radius: 10px; overflow: hidden; }
.draft-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: transparent;
  border-bottom: 1px solid transparent; cursor: pointer; user-select: none; transition: background 0.15s;
}
.draft-section-header:hover { background: var(--bg-raised); }
.draft-section.open .draft-section-header { border-bottom-color: var(--border-faint); }
.draft-section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-ghost); }
.draft-section-toggle { font-size: 11px; color: var(--text-dim); transition: transform 0.2s; }
.draft-section.open .draft-section-toggle { transform: rotate(180deg); }
.draft-section-content { display: none; }
.draft-section.open .draft-section-content { display: block; }

.draft-edit-area { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.draft-field-label { font-size: 11px; font-weight: 600; color: var(--text-ghost); text-transform: uppercase; letter-spacing: 0.05em; display: block; margin-bottom: 4px; }
.draft-textarea { width: 100%; resize: vertical; font-size: 13px; padding: 9px 11px; border-radius: 7px; line-height: 1.6; }
.draft-input { flex: 1; font-size: 13px; padding: 7px 10px; border-radius: 6px; min-width: 0; }
.draft-input-sm { max-width: 160px; flex: none; }
.draft-select { font-size: 12px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.draft-select-sm { width: 110px; flex-shrink: 0; }
.draft-list { display: flex; flex-direction: column; gap: 5px; margin-bottom: 6px; }
.draft-list-row { display: flex; align-items: center; gap: 7px; }
.draft-row-bullet { flex-shrink: 0; font-size: 13px; }
.draft-row-del {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 4px;
  background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.2);
  color: #ef4444; font-size: 11px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0; line-height: 1;
}
.draft-row-del:hover { background: rgba(239,68,68,0.16); }
.draft-inv-block { padding: 10px 12px; background: rgba(6,182,212,0.04); border: 1px solid rgba(6,182,212,0.12); border-radius: 8px; margin-bottom: 8px; }
[data-theme="light"] .draft-inv-block { background: #ecfeff; border-color: #a5f3fc; }
.draft-inv-header { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.draft-dx-block { padding: 10px 12px; background: var(--accent-subtle); border: 1px solid rgba(99,102,241,0.15); border-radius: 8px; margin-bottom: 8px; }
.draft-add-btn {
  font-size: 12px; color: var(--accent); background: var(--accent-subtle);
  border: 1px dashed rgba(99,102,241,0.3); border-radius: 6px;
  padding: 5px 10px; cursor: pointer; transition: background 0.15s;
}
.draft-add-btn:hover { background: rgba(99,102,241,0.14); }
.draft-add-btn-sm { font-size: 11px; padding: 3px 8px; margin-top: 4px; }

.chat-draft-actions {
  display: flex; gap: 8px; padding: 12px 16px;
  border-top: 1px solid var(--border-faint); background: var(--accent-faint);
  position: sticky; bottom: 0;
}

/* ══════════════════════════════════════════════════════════════
   TRANSFER WORKFLOW STYLES
   ══════════════════════════════════════════════════════════════ */

/* ── Transfer alert banner (shown when AI flags transfer needed) ── */
.transfer-alert {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; margin: 0 0 14px;
  background: rgba(249,115,22,0.08);
  border: 1px solid rgba(249,115,22,0.35);
  border-radius: 10px;
}
.transfer-alert-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.transfer-alert-body { flex: 1; }
.transfer-alert-title { font-size: 13px; font-weight: 700; color: #f97316; margin-bottom: 4px; }
.transfer-alert-text  { font-size: 13px; color: var(--text-body); line-height: 1.5; margin-bottom: 8px; }
.transfer-alert-btn {
  font-size: 12px; font-weight: 600; padding: 6px 14px;
  border-radius: 7px; border: none; cursor: pointer;
  background: #f97316; color: #fff; transition: background 0.15s;
}
.transfer-alert-btn:hover { background: #ea6c10; }

/* ── Transfer status pill in case cards ── */
.transfer-in-transit { animation: pulse-blue 2s infinite; }
@keyframes pulse-blue {
  0%,100% { box-shadow: 0 0 0 0 rgba(56,189,248,0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(56,189,248,0); }
}

/* ── Transfer modal ── */
.transfer-modal .modal-body { padding: 0; }

.transfer-steps {
  display: flex; border-bottom: 1px solid var(--border-faint);
  background: var(--bg-sunken); padding: 0 20px; gap: 0; overflow-x: auto;
}
.transfer-step-btn {
  flex-shrink: 0; padding: 12px 16px; font-size: 12px; font-weight: 600;
  color: var(--text-ghost); border: none; background: none; cursor: pointer;
  border-bottom: 2px solid transparent; transition: all 0.15s;
  display: flex; align-items: center; gap: 6px;
}
.transfer-step-btn.active { color: #f97316; border-bottom-color: #f97316; }
.transfer-step-btn.done   { color: var(--text-dim); }
.transfer-step-btn .step-num {
  width: 18px; height: 18px; border-radius: 50%; font-size: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--border-faint); color: var(--text-ghost);
}
.transfer-step-btn.active .step-num { background: #f97316; color: #fff; }
.transfer-step-btn.done .step-num   { background: #10b981; color: #fff; }

.transfer-step-panel { padding: 20px; display: none; }
.transfer-step-panel.active { display: block; }

/* ── Facility picker ── */
.facility-grid { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.facility-card {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px;
  border: 1.5px solid var(--border-faint); border-radius: 10px;
  background: var(--bg-surface); cursor: pointer; transition: all 0.15s;
}
.facility-card:hover   { border-color: #f97316; background: rgba(249,115,22,0.04); }
.facility-card.selected { border-color: #f97316; background: rgba(249,115,22,0.08); }
.facility-card-icon { font-size: 22px; flex-shrink: 0; margin-top: 1px; }
.facility-card-body { flex: 1; }
.facility-card-name { font-size: 14px; font-weight: 600; color: var(--text-heading); margin-bottom: 3px; }
.facility-card-addr { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.facility-caps { display: flex; flex-wrap: wrap; gap: 4px; }
.facility-cap-pill {
  font-size: 11px; padding: 2px 7px; border-radius: 20px;
  background: rgba(6,182,212,0.1); color: #22d3ee;
  border: 1px solid rgba(6,182,212,0.2);
}
.facility-cap-pill.match {
  background: rgba(16,185,129,0.1); color: #34d399;
  border-color: rgba(16,185,129,0.3); font-weight: 600;
}
.facility-card-right { text-align: right; flex-shrink: 0; }
.facility-dist { font-size: 12px; color: var(--text-ghost); margin-bottom: 4px; }
.facility-sel-check { font-size: 18px; color: #10b981; display: none; }
.facility-card.selected .facility-sel-check { display: block; }
.facility-icu-badge {
  font-size: 10px; padding: 2px 6px; border-radius: 4px;
  background: rgba(16,185,129,0.1); color: #10b981; border: 1px solid rgba(16,185,129,0.25);
}

/* ── Transport mode selector ── */
.transport-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; margin-bottom: 16px; }
.transport-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px; border: 1.5px solid var(--border-faint); border-radius: 10px;
  background: var(--bg-surface); cursor: pointer; transition: all 0.15s; text-align: center;
}
.transport-card:hover   { border-color: var(--accent); }
.transport-card.selected { border-color: var(--accent); background: var(--accent-subtle); }
.transport-card-icon { font-size: 24px; }
.transport-card-label { font-size: 13px; font-weight: 600; color: var(--text-heading); }
.transport-card-desc  { font-size: 11px; color: var(--text-ghost); line-height: 1.4; }
.transport-recommended { font-size: 10px; font-weight: 600; color: #10b981; margin-top: 2px; }

/* ── EMTALA checklist ── */
.emtala-checklist { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.emtala-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border-faint);
  background: var(--bg-surface); transition: background 0.15s;
}
.emtala-item.done   { background: rgba(16,185,129,0.06); border-color: rgba(16,185,129,0.25); }
.emtala-item.pending { background: rgba(249,115,22,0.05); border-color: rgba(249,115,22,0.2); }
.emtala-check { font-size: 16px; flex-shrink: 0; width: 20px; text-align: center; }
.emtala-text  { flex: 1; font-size: 13px; color: var(--text-body); }
.emtala-req   { font-size: 10px; font-weight: 600; color: var(--text-ghost); margin-left: 6px; }

/* ── SBAR document ── */
.sbar-doc { display: flex; flex-direction: column; gap: 12px; }
.sbar-section {
  padding: 14px 16px;
  border-radius: 8px; border-left: 3px solid;
}
.sbar-s { border-color: #ef4444; background: rgba(239,68,68,0.05); }
.sbar-b { border-color: #f59e0b; background: rgba(245,158,11,0.05); }
.sbar-a { border-color: #6366f1; background: rgba(99,102,241,0.05); }
.sbar-r { border-color: #10b981; background: rgba(16,185,129,0.05); }
.sbar-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-ghost); margin-bottom: 6px; }
.sbar-text  { font-size: 13px; color: var(--text-body); line-height: 1.7; }

/* ── Transfer timeline (in case review) ── */
.transfer-timeline { display: flex; flex-direction: column; gap: 0; margin-bottom: 16px; }
.tl-item {
  display: flex; gap: 14px; padding-bottom: 16px;
  position: relative;
}
.tl-item:last-child { padding-bottom: 0; }
.tl-item:not(:last-child)::before {
  content: ''; position: absolute;
  left: 15px; top: 32px; bottom: 0; width: 2px;
  background: var(--border-faint);
}
.tl-dot {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; z-index: 1;
  border: 2px solid var(--border-faint); background: var(--bg-surface);
}
.tl-dot.done    { background: rgba(16,185,129,0.15); border-color: #10b981; }
.tl-dot.active  { background: rgba(56,189,248,0.15); border-color: #38bdf8; }
.tl-dot.pending { background: var(--bg-surface); }
.tl-body { flex: 1; }
.tl-title { font-size: 13px; font-weight: 600; color: var(--text-heading); margin-bottom: 2px; }
.tl-meta  { font-size: 12px; color: var(--text-dim); }

/* ── Transfer summary card (in review modal analysis tab) ── */
.transfer-summary-card {
  border: 1px solid rgba(249,115,22,0.3);
  background: rgba(249,115,22,0.05);
  border-radius: 10px; padding: 14px 16px; margin-bottom: 14px;
}
.transfer-summary-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; flex-wrap: wrap; gap: 8px;
}
.transfer-summary-title { font-size: 13px; font-weight: 700; color: #f97316; }
.transfer-summary-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; }
.tsf-detail { display: flex; flex-direction: column; gap: 2px; }
.tsf-label  { font-size: 10px; font-weight: 600; color: var(--text-ghost); text-transform: uppercase; letter-spacing: 0.05em; }
.tsf-value  { font-size: 13px; color: var(--text-body); }

/* ── Status action buttons for transfer lifecycle ── */
.transfer-action-bar {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px; border-top: 1px solid var(--border-faint);
  background: var(--bg-sunken);
}
.btn-orange  { background: #f97316; color: #fff; border-color: #ea6c10; }
.btn-orange:hover { background: #ea6c10; }
.btn-sky     { background: #0ea5e9; color: #fff; border-color: #0284c7; }
.btn-sky:hover { background: #0284c7; }
.btn-teal    { background: #0d9488; color: #fff; border-color: #0f766e; }
.btn-teal:hover { background: #0f766e; }

/* ── Loading skeleton for facilities ── */
.facility-skeleton {
  height: 80px; border-radius: 10px; border: 1px solid var(--border-faint);
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-raised) 50%, var(--bg-surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Filter buttons for transfer statuses ── */
#fc-transfer_initiated, #fc-in_transit, #fc-transfer_accepted, #fc-arrived { display: none; }

/* ── Feedback / star rating ───────────────────────────────────────────────── */
.feedback-block { margin-top: 12px; }
.feedback-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.5;
}
.rating-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.rating-stars {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.rating-stars-lg { gap: 6px; margin-bottom: 14px; }

.rating-star {
  background: transparent;
  border: 0;
  padding: 4px;
  cursor: pointer;
  color: #475569;
  line-height: 0;
  border-radius: 6px;
  transition: color 0.15s, transform 0.1s;
}
.rating-star:hover,
.rating-star:focus-visible {
  color: #fbbf24;
  outline: none;
  transform: scale(1.08);
}
.rating-star.star-on { color: #f59e0b; }
.rating-star[aria-checked="true"] { color: #f59e0b; }
[data-theme="light"] .rating-star { color: #cbd5e1; }
[data-theme="light"] .rating-star.star-on,
[data-theme="light"] .rating-star[aria-checked="true"] { color: #f59e0b; }

.rating-status {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── SVG icon sizing ───────────────────────────────────────────────────────────
   Icons come from /static/js/icons.js and are sized in `em`, so they inherit the
   font-size of whatever they sit in. A few containers set type far smaller than
   an icon reads well at, so those get an explicit optical size here. */
.empty-icon              { font-size: 44px; line-height: 1; color: var(--text-dim); opacity: 0.5; margin-bottom: 1rem; }
.result-block-title .ico { font-size: 14px; }
.draft-section-toggle    { font-size: 13px; }
.transport-recommended   { font-size: 12px; }
.section-label .ico,
.mrn-result .ico,
.case-action .ico        { font-size: 13px; }
.spec-btn .ico           { font-size: 15px; }
.btn .ico                { font-size: 15px; }
.btn-sm .ico             { font-size: 14px; }
/* pills are inline-flex, so an icon child needs an explicit gap (no text node collapse) */
.pill                    { gap: 4px; }
.pill .ico               { font-size: 13px; }
