:root {
  --bg: #0a0e14;
  --surface: #111620;
  --surface2: #171e2b;
  --surface3: #1d2636;
  --border: #232d40;
  --border2: #2d3a52;
  --accent: #3b82f6;
  --accent2: #60a5fa;
  --accent-glow: rgba(59,130,246,0.12);
  --green: #34d399;
  --green2: #6ee7b7;
  --amber: #fbbf24;
  --red: #f87171;
  --purple: #a78bfa;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --text3: #64748b;
  --serif: 'DM Serif Display', Georgia, serif;
  --sans: 'Instrument Sans', sans-serif;
  --mono: 'DM Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

/* ── HEADER ── */
.header {
  background: linear-gradient(180deg, #0d1420 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  flex-shrink: 0;
}
.logo { display: flex; align-items: center; gap: 11px; }
.logo-icon {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.logo-text { font-family: var(--serif); font-size: 19px; letter-spacing: 0.02em; }
.logo-sub { font-family: var(--mono); font-size: 9.5px; color: var(--text3); letter-spacing: 0.1em; text-transform: uppercase; margin-top: 1px; }
.header-note { font-family: var(--mono); font-size: 10.5px; color: var(--text3); }
.header-right { display: flex; align-items: center; gap: 16px; }
.header-badge {
  font-family: var(--mono); font-size: 10px; padding: 3px 9px;
  border: 1px solid var(--border2); border-radius: 12px; color: var(--text3);
}

/* ── LAYOUT ── */
.app { display: flex; height: calc(100vh - 58px); overflow: hidden; }

/* ── SIDEBAR ── */
.sidebar {
  width: 236px; min-width: 236px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 0 24px;
  flex-shrink: 0;
}
.sidebar-section { margin-bottom: 4px; }
.sidebar-label {
  font-family: var(--mono); font-size: 9.5px; color: var(--text3);
  letter-spacing: 0.12em; text-transform: uppercase;
  padding: 10px 14px 5px;
}
.sidebar-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 14px;
  cursor: pointer; transition: all 0.13s;
  border-left: 2px solid transparent;
  color: var(--text2); font-size: 12.5px;
  user-select: none;
}
.sidebar-item:hover { background: var(--surface2); color: var(--text); }
.sidebar-item.active {
  background: var(--accent-glow);
  border-left-color: var(--accent);
  color: var(--accent2);
}
.sidebar-item .si-icon { font-size: 13px; opacity: 0.85; width: 17px; text-align: center; flex-shrink: 0; }
.badge {
  margin-left: auto; font-family: var(--mono); font-size: 8.5px;
  padding: 1px 5px; border-radius: 8px;
  background: var(--surface3); color: var(--text3);
}
.badge.rad { background: rgba(59,130,246,0.14); color: var(--accent2); }
.badge.med { background: rgba(167,139,250,0.14); color: var(--purple); }
.badge.surg { background: rgba(52,211,153,0.14); color: var(--green); }

/* ── MAIN ── */
.main { flex: 1; overflow-y: auto; padding: 26px 28px; }

/* ── TOOL HEADER ── */
.tool-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; }
.tool-title { font-family: var(--serif); font-size: 24px; }
.tool-subtitle { color: var(--text3); font-size: 12.5px; margin-top: 2px; }
.tool-tags { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.tag {
  font-family: var(--mono); font-size: 9.5px;
  padding: 2px 7px; border-radius: 4px;
  border: 1px solid var(--border2); color: var(--text3);
}
.tag.blue  { border-color: rgba(59,130,246,0.4);  color: var(--accent2); }
.tag.purple{ border-color: rgba(167,139,250,0.4); color: var(--purple); }
.tag.green { border-color: rgba(52,211,153,0.4);  color: var(--green); }

/* ── CARD ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 14px;
}
.card-title {
  font-size: 11px; font-family: var(--mono);
  color: var(--text3); text-transform: uppercase;
  letter-spacing: 0.08em; margin-bottom: 13px;
}

/* ── GRID ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ── FORM ── */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 4px; font-weight: 500; }
.field select, .field input[type="number"] {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 6px; padding: 7px 9px;
  color: var(--text); font-family: var(--sans); font-size: 12.5px;
  outline: none; transition: border-color 0.13s;
  -webkit-appearance: none;
}
.field select:focus, .field input:focus { border-color: var(--accent); }
.field select option { background: var(--surface2); }

/* ── RADIO ── */
.radio-group { display: flex; gap: 6px; flex-wrap: wrap; }
.radio-btn {
  padding: 5px 11px; border: 1px solid var(--border2);
  border-radius: 6px; cursor: pointer; font-size: 12px;
  color: var(--text2); transition: all 0.13s;
  background: var(--surface2); user-select: none;
}
.radio-btn:hover { border-color: var(--accent); color: var(--text); }
.radio-btn.selected { background: var(--accent-glow); border-color: var(--accent); color: var(--accent2); }

/* ── CHECKBOX GROUP ── */
.check-group { display: flex; flex-direction: column; gap: 5px; }
.check-item {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 9px; border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; transition: all 0.13s;
  font-size: 12.5px; color: var(--text2);
  background: var(--surface2); user-select: none;
}
.check-item:hover { border-color: var(--border2); color: var(--text); }
.check-item.selected { border-color: var(--accent); background: var(--accent-glow); color: var(--text); }
.checkmark {
  width: 15px; height: 15px; border: 1px solid var(--border2);
  border-radius: 4px; display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: transparent; transition: all 0.13s; flex-shrink: 0;
}
.check-item.selected .checkmark { background: var(--accent); border-color: var(--accent); color: white; }

/* ── BUTTON ── */
.calc-btn {
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: white; border: none; border-radius: 7px;
  padding: 10px 22px; font-family: var(--sans);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: all 0.18s; margin-top: 4px; letter-spacing: 0.02em;
  width: 100%;
}
.calc-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 18px rgba(59,130,246,0.28); }
.calc-btn:active { transform: translateY(0); }
.calc-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── RESULT ── */
.result-box {
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 10px; padding: 18px; margin-top: 14px;
  animation: fadeUp 0.28s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.result-score { font-family: var(--serif); font-size: 48px; line-height: 1; margin-bottom: 3px; }
.result-label { color: var(--text2); font-size: 12.5px; margin-bottom: 13px; }
.result-interpretation {
  font-size: 12.5px; color: var(--text); line-height: 1.7;
  padding: 12px 14px; background: var(--surface3);
  border-radius: 7px; border-left: 3px solid var(--accent); margin-top: 12px;
}
.result-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 0; border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.result-row:last-child { border-bottom: none; }
.result-row .rl { color: var(--text2); }
.result-row .rv { font-family: var(--mono); font-weight: 500; }

/* ── SURVIVAL BAR ── */
.surv-bar-row { margin-bottom: 11px; }
.surv-bar-label { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text2); margin-bottom: 4px; }
.surv-bar-track { background: var(--surface3); border-radius: 4px; height: 7px; overflow: hidden; }
.surv-bar-fill { height: 100%; border-radius: 4px; transition: width 0.7s ease; }

/* ── RISK PILL ── */
.risk-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px; font-size: 11.5px;
  font-weight: 600; letter-spacing: 0.03em;
}
.risk-low   { background: rgba(52,211,153,0.14);  color: var(--green); }
.risk-int   { background: rgba(251,191,36,0.14);  color: var(--amber); }
.risk-high  { background: rgba(248,113,113,0.14); color: var(--red); }
.risk-vhigh { background: rgba(248,113,113,0.22); color: #fc8181; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── INFO ROW ── */
.info-row {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 9px 11px; background: var(--surface3);
  border-radius: 6px; font-size: 11.5px; color: var(--text2);
  margin-top: 11px; line-height: 1.6;
}
.info-icon { color: var(--accent2); font-size: 13px; flex-shrink: 0; margin-top: 1px; }

/* ── HOME GRID ── */
.home-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px;
}
.stat-num { font-family: var(--serif); font-size: 34px; }
.stat-label { color: var(--text3); font-size: 11.5px; margin-top: 1px; }

.tool-card-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 11px; }
.tool-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 15px; cursor: pointer;
  transition: all 0.18s;
}
.tool-card:hover { border-color: var(--border2); transform: translateY(-2px); background: var(--surface2); }
.tool-card-icon { font-size: 20px; margin-bottom: 7px; }
.tool-card-name { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.tool-card-desc { font-size: 11.5px; color: var(--text3); line-height: 1.5; }
.tool-card-specialty { margin-top: 9px; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.06em; }
.spec-rad { color: var(--accent2); }
.spec-med { color: var(--purple); }
.spec-surg { color: var(--green); }
.spec-all { color: var(--amber); }

/* ── SECTION HEADER ── */
.section-h {
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text3); margin-bottom: 10px; margin-top: 18px;
}
.section-h:first-child { margin-top: 0; }

/* ── REF NOTE ── */
.ref-note {
  font-size: 10.5px; color: var(--text3); font-family: var(--mono);
  margin-top: 11px; padding-top: 11px;
  border-top: 1px solid var(--border); line-height: 1.7;
}

/* ── DIVIDER ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* ── LOADING ── */
.loading-overlay {
  display: flex; align-items: center; justify-content: center;
  padding: 20px; color: var(--text2); font-size: 13px;
  gap: 8px;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── ERROR ── */
.error-box {
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.3);
  border-radius: 7px; padding: 11px 14px;
  color: var(--red); font-size: 12.5px; margin-top: 10px;
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .sidebar { width: 50px; min-width: 50px; }
  .sidebar-item span:not(.si-icon), .badge, .sidebar-label { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .home-grid { grid-template-columns: 1fr 1fr; }
  .tool-card-grid { grid-template-columns: 1fr; }
}
