:root {
  --bg: #edf4ff;
  --panel: #ffffff;
  --panel-strong: #dbeafe;
  --text: #0f172a;
  --muted: #475569;
  --border: #cbd5e1;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --success-soft: #dcfce7;
  --shadow: 0 14px 40px rgba(37, 99, 235, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(180deg, #eff6ff 0%, #f8fafc 28%, #eef2ff 100%);
  color: var(--text);
}

button,
select,
input,
textarea {
  font: inherit;
}

button,
select,
input,
textarea {
  border: 1px solid var(--border);
  border-radius: 10px;
}

button {
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  padding: 0.65rem 0.95rem;
}

button:hover {
  border-color: var(--brand);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.25rem;
  background: rgba(37, 99, 235, 0.92);
  color: white;
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.2);
}


.brand-block {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.home-favicon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.15);
}

.home-favicon-link:hover {
  background: rgba(255, 255, 255, 0.28);
}

.home-favicon-link img {
  display: block;
  border-radius: 4px;
}
.topbar h1,
h2,
h3,
p {
  margin: 0;
}

.subtitle {
  margin-top: 0.25rem;
  color: rgba(255, 255, 255, 0.85);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.55rem;
  align-items: center;
}

.toolbar-field {
  font-size: 0.95rem;
}

.toolbar select {
  min-width: 13rem;
}

.container {
  display: grid;
  gap: 1.25rem;
  padding: 1.25rem;
}

.card {
  background: var(--panel);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.muted {
  color: var(--muted);
}

.status-banner {
  padding: 0.85rem 1rem;
  border-radius: 14px;
  border: 1px solid #86efac;
  background: var(--success-soft);
}

.hidden {
  display: none !important;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.75rem 0.65rem;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.92rem;
}

.action-cell {
  white-space: nowrap;
}

.action-btn {
  margin-right: 0.45rem;
  padding: 0.45rem 0.75rem;
}

.danger-btn {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #fecaca;
}

.ghost-btn {
  background: transparent;
}

.chart-panel {
  min-height: 340px;
}

.chart-shell {
  display: grid;
  gap: 0.75rem;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-swatch {
  width: 1rem;
  height: 0.2rem;
  border-radius: 999px;
  background: #94a3b8;
}

.chart-empty {
  color: var(--muted);
  padding: 1rem 0;
}

svg.chart-svg {
  width: 100%;
  height: auto;
  display: block;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border-radius: 14px;
  border: 1px solid #dbeafe;
}

.axis-label,
.tick-label {
  fill: #64748b;
  font-size: 12px;
}

.grid-line {
  stroke: #dbeafe;
  stroke-width: 1;
}

.axis-line {
  stroke: #94a3b8;
  stroke-width: 1.25;
}

.curve-line {
  fill: none;
  stroke-width: 1.4;
}

.curve-line.median {
  stroke-width: 2.2;
}

.patient-line {
  fill: none;
  stroke: var(--brand);
  stroke-width: 2.5;
}

.patient-point {
  fill: var(--brand);
  stroke: white;
  stroke-width: 1.5;
}

.point-label {
  fill: #1e293b;
  font-size: 11px;
}

.modal {
  border: none;
  padding: 0;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.22);
  width: min(30rem, calc(100vw - 2rem));
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.form-card {
  display: grid;
  gap: 0.85rem;
  padding: 1.1rem;
}

.form-card.narrow {
  width: min(24rem, calc(100vw - 2rem));
}

.form-card label {
  display: grid;
  gap: 0.35rem;
}

.form-card input,
.form-card select,
.form-card textarea {
  width: 100%;
  padding: 0.7rem 0.8rem;
  background: white;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
}

.form-actions.split {
  justify-content: space-between;
}

.form-error {
  min-height: 1.25rem;
  color: var(--danger);
}

.lock-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.58);
  z-index: 100;
}

@media (max-width: 900px) {
  .topbar {
    position: static;
  }

  .toolbar {
    justify-content: flex-start;
  }

  .toolbar select {
    min-width: 10rem;
  }

  .chart-panel {
    min-height: 280px;
  }
}

@media print {
  body {
    background: white;
  }

  .topbar,
  .status-banner,
  .action-cell,
  .modal,
  .lock-screen {
    display: none !important;
  }

  .container {
    padding: 0;
  }

  .card {
    box-shadow: none;
    border: 1px solid #cbd5e1;
    break-inside: avoid;
    margin-bottom: 1rem;
  }
}

.inline-info-btn {
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  line-height: 1;
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid #94a3b8;
  color: #0f172a;
  background: #e2e8f0;
  vertical-align: middle;
}

.percentile-cell {
  min-width: 15rem;
}

.percentile-block {
  display: grid;
  gap: 0.25rem;
}

.source-note {
  font-size: 0.74rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.percentile-line {
  font-size: 0.86rem;
  line-height: 1.25;
}

.metric-muted {
  color: #475569;
}

.clinical-caution {
  margin-top: 0.65rem;
  padding: 0.75rem;
  border: 1px solid #fed7aa;
  background: #fff7ed;
  border-radius: 10px;
}

.reference-list {
  margin: 0.5rem 0 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.35rem;
}

.reference-list a {
  color: #1d4ed8;
}

