:root {
  --bg: #0f1419;
  --bg-elev: #171d25;
  --bg-card: #1c2430;
  --bg-soft: #232d3b;
  --line: #2d3a4d;
  --text: #e8eef6;
  --muted: #93a4b8;
  --faint: #6b7c90;
  --accent: #3d8bfd;
  --accent-2: #5eead4;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --font: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --max: 960px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.demo-banner {
  background: #3b2f14;
  color: #fde68a;
  text-align: center;
  font-size: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid #785f1d;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #2563eb, #0f766e);
  font-weight: 700; font-size: 13px; letter-spacing: 0.02em;
}
.brand-text { display: flex; flex-direction: column; }
.brand-text strong { font-size: 15px; }
.brand-text span { font-size: 12px; color: var(--muted); }

.top-controls { display: flex; gap: 10px; flex-wrap: wrap; }
.ctrl { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); }
.ctrl select {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 140px;
  font-size: 13px;
}

.subnav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(23, 29, 37, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 72px;
  z-index: 15;
}
.subnav button {
  flex: 0 0 auto;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  cursor: pointer;
}
.subnav button:hover { color: var(--text); background: var(--bg-soft); }
.subnav button.active {
  color: var(--text);
  background: var(--bg-soft);
  border-color: var(--line);
}

.screen {
  width: min(var(--max), 100%);
  margin: 0 auto;
  padding: 18px 16px 40px;
  flex: 1;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  background: var(--bg-elev);
}

h1 { font-size: 1.45rem; margin: 0 0 6px; letter-spacing: -0.02em; }
h2 { font-size: 1.1rem; margin: 0 0 8px; }
h3 { font-size: 0.98rem; margin: 0 0 6px; }
p { margin: 0 0 10px; color: var(--muted); }
.lead { font-size: 0.98rem; color: var(--text); }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row-between { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .subnav { top: 110px; }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.card.interactive { cursor: pointer; transition: border-color .15s, transform .15s; }
.card.interactive:hover { border-color: var(--accent); transform: translateY(-1px); }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.card.disabled { opacity: 0.55; pointer-events: none; }

.kpi {
  display: flex; flex-direction: column; gap: 4px;
}
.kpi .val { font-size: 1.4rem; font-weight: 700; color: var(--text); }
.kpi .lbl { font-size: 12px; color: var(--muted); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 3px 9px;
  font-size: 11px; font-weight: 600;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  white-space: nowrap;
}
.badge.ok { color: #a7f3d0; border-color: #065f46; background: #064e3b; }
.badge.warn { color: #fde68a; border-color: #92400e; background: #78350f; }
.badge.info { color: #bfdbfe; border-color: #1e3a8a; background: #1e3a5f; }
.badge.danger { color: #fecaca; border-color: #7f1d1d; background: #450a0a; }
.badge.teal { color: #99f6e4; border-color: #115e59; background: #134e4a; }

.btn {
  appearance: none; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--text);
  border-radius: 10px; padding: 10px 14px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled, .btn[disabled] {
  opacity: 0.45; cursor: not-allowed; filter: none;
}
.btn-primary {
  background: var(--accent); border-color: #1d4ed8; color: #fff;
}
.btn-success {
  background: #059669; border-color: #047857; color: #fff;
}
.btn-ghost {
  background: transparent;
}
.btn-danger {
  background: transparent; border-color: #7f1d1d; color: #fecaca;
}
.btn-block { width: 100%; }
.btn-sm { padding: 7px 10px; font-size: 12px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg-soft);
}
.list-item.selectable { cursor: pointer; }
.list-item.selectable:hover { border-color: var(--accent); }
.list-item.selected { border-color: var(--accent); background: #172554; }
.list-item .meta { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; margin-bottom: 2px; }
.list-item .sub { font-size: 13px; color: var(--muted); }
.list-item .right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }

.check {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg-soft);
}
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); }
.check label { flex: 1; cursor: pointer; font-size: 14px; }
.check.done { border-color: #065f46; background: #052e24; }
.check.done label { color: #a7f3d0; }

.pill-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.pill-tabs button {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; cursor: pointer;
}
.pill-tabs button.active { background: var(--bg-soft); color: var(--text); border-color: var(--accent); }

.split {
  display: grid; grid-template-columns: 1.2fr 1fr; gap: 12px;
}
@media (max-width: 720px) { .split { grid-template-columns: 1fr; } }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative; padding: 0 0 16px 22px;
  border-left: 2px solid var(--line); margin-left: 8px;
}
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -7px; top: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--faint); border: 2px solid var(--bg-card);
}
.timeline li.done::before { background: var(--ok); }
.timeline li.current::before { background: var(--accent); box-shadow: 0 0 0 4px rgba(61,139,253,.25); }
.timeline li.fail::before { background: var(--danger); }
.timeline .t-title { font-weight: 600; font-size: 14px; }
.timeline .t-sub { font-size: 12px; color: var(--muted); }

.notice {
  border-radius: 10px; padding: 12px 14px; font-size: 13px;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--muted);
}
.notice.info { border-color: #1e3a8a; background: #0f1c33; color: #bfdbfe; }
.notice.warn { border-color: #92400e; background: #2a1a08; color: #fde68a; }
.notice.ok { border-color: #065f46; background: #052e24; color: #a7f3d0; }
.notice.danger { border-color: #7f1d1d; background: #2a0b0b; color: #fecaca; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.strong { font-weight: 700; color: var(--text); }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.gap-8 { gap: 8px; }

.radio-card {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg-soft); cursor: pointer;
}
.radio-card.selected { border-color: var(--accent); background: #172554; }
.radio-card input { margin-top: 3px; accent-color: var(--accent); }
.radio-card .rec {
  margin-left: auto; font-size: 11px; color: #99f6e4;
  border: 1px solid #115e59; background: #134e4a;
  border-radius: 999px; padding: 2px 8px; white-space: nowrap;
}

.progress-bar {
  height: 8px; border-radius: 999px; background: var(--bg-soft); overflow: hidden;
  border: 1px solid var(--line);
}
.progress-bar > span {
  display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2));
  width: 0; transition: width .35s ease;
}

.drawer.hidden { display: none; }
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.drawer-panel {
  position: absolute; top: 0; right: 0; height: 100%;
  width: min(420px, 100%); background: var(--bg-elev);
  border-left: 1px solid var(--line); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.drawer-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.drawer-head h2 { margin: 0; font-size: 1rem; }
.drawer-body { padding: 16px; overflow: auto; flex: 1; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--text); font-size: 22px; cursor: pointer; line-height: 1;
}

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #111827; color: var(--text); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 999px; z-index: 80; font-size: 13px;
  box-shadow: var(--shadow); max-width: min(92vw, 480px); text-align: center;
}
.toast.hidden { display: none; }

.section-title {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin: 4px 0 10px;
}
.section-title h2 { margin: 0; }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }

.empty {
  text-align: center; padding: 28px 16px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius);
}

.steps-mini {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px;
}
.steps-mini span {
  font-size: 11px; padding: 4px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--faint);
}
.steps-mini span.on { color: var(--text); border-color: var(--accent); background: #172554; }
.steps-mini span.done { color: #a7f3d0; border-color: #065f46; }

hr.sep { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

.patient-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 999px;
  background: var(--bg-soft); border: 1px solid var(--line); font-size: 12px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
  background: #1e3a8a; color: #dbeafe;
}
