:root {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: #12202f;
  background: #f5f8fb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
}

header, footer {
  padding: 1rem;
  background: #0e2a47;
  color: white;
}

.warning {
  color: #ffd966;
  font-weight: 600;
}

main {
  display: grid;
  gap: 1rem;
  padding: 1rem;
  max-width: 1100px;
  margin: 0 auto;
}

.disclaimer {
  background: #fff4e5;
  border: 1px solid #fdb022;
  border-radius: 12px;
  color: #7a2e0e;
  padding: 0.85rem 1rem;
}

.disclaimer strong {
  font-weight: 700;
}

.card {
  background: white;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.1);
}

.grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.95rem;
}

label.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

input, select, button {
  padding: 0.55rem;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
}

button {
  cursor: pointer;
  border: none;
  background: #1e4f80;
  color: white;
  margin-top: 0.5rem;
}

button:hover { background: #173e66; }

.row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr 0.9fr 0.9fr auto;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: end;
}

.v-slice-mm {
  font-size: 0.8rem;
  color: #475467;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.results-actions {
  margin-bottom: 0.5rem;
}

pre {
  white-space: pre-wrap;
  background: #f8fafc;
  padding: 0.7rem;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.fenestration-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.fenestration-table th,
.fenestration-table td {
  border: 1px solid #d0d5dd;
  padding: 0.65rem 0.75rem;
  text-align: left;
}

.fenestration-table th {
  background: #eef4ff;
  color: #173e66;
}

.hint {
  color: #344054;
  margin-top: 0;
}

.diagnostics summary {
  cursor: pointer;
  font-weight: 600;
}

#templateDiagnosticsLog {
  max-height: 220px;
  overflow: auto;
  margin-top: 0.5rem;
  font-size: 0.8rem;
}

#viz {
  width: 100%;
  height: auto;
  background: #f8fafc;
  border: 1px solid #d0d5dd;
  border-radius: 10px;
  user-select: none;
  -webkit-user-select: none;
}

.viz-frame {
  fill: #ffffff;
  stroke: #98a2b3;
}

.viz-segment-buildable {
  fill: #e6f4ea;
}

.viz-segment-seal-stent {
  fill: #e6f4ea;
}

.viz-segment-nonbuildable {
  fill: #f2f4f7;
}

.viz-stent-wave {
  fill: none;
  stroke: #667085;
  stroke-width: 2;
  opacity: 0.6;
  pointer-events: none;
}

.viz-build-zone {
  fill: #b2ddff;
  opacity: 0.3;
}

.viz-posterior-constraint {
  fill: #f04438;
  opacity: 0.22;
  pointer-events: none;
}

.viz-graft-shape {
  fill: #ffffff;
  stroke: #98a2b3;
  stroke-width: 1;
}

.viz-grid-line {
  fill: none;
  stroke: #d0d5dd;
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.viz-diameter-line {
  fill: none;
  stroke: #6941c6;
  stroke-width: 1.;
}

.viz-axis-label {
  font-size: 10px;
  fill: #475467;
  pointer-events: none;
}

.viz-axis-tick {
  stroke: #667085;
}

.viz-taper-label {
  font-size: 11px;
  fill: #7a271a;
  font-weight: 600;
  pointer-events: none;
}

.viz-point {
  fill: #1d4ed8;
  cursor: grab;
}

.viz-point-reference {
  fill: #7a271a;
  cursor: grab;
}

.viz-label {
  font-size: 11px;
  fill: #101828;
  pointer-events: none;
}

.viz-segment-height-label {
  font-size: 14px;
  fill: #98a2b3;
  opacity: 0.75;
  pointer-events: none;
}

.viz-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: #475467;
}

.legend {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 0.25rem;
  vertical-align: middle;
}

.swatch-build { background: #e6f4ea; border: 1px solid #98a2b3; }
.swatch-nonbuild { background: #f2f4f7; border: 1px solid #98a2b3; }
.swatch-zone { background: #b2ddff; border: 1px solid #98a2b3; }
.swatch-stent { background: repeating-linear-gradient(45deg, #98a2b3, #98a2b3 2px, #e4e7ec 2px, #e4e7ec 4px); border: 1px solid #98a2b3; }
.swatch-reference { background: #7a271a; }
.swatch-vessel { background: #1d4ed8; }
.swatch-diameter { background: #6941c6; }
.swatch-posterior { background: #f04438; opacity: 0.7; }

.issue-error { color: #b42318; font-weight: 600; }
.issue-warning { color: #b54708; font-weight: 600; }
.issue-ok { color: #027a48; font-weight: 700; }

@media (max-width: 800px) {
  .grid.two { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr; }
}

@media print {
  header, footer, #summaryBtn, #validateBtn, #pdfBtn, #addVesselBtn, #addPlanBtn, #savePlanBtn, #loadPlanBtn, #templateDiagnosticsPanel {
    display: none !important;
  }
  body { background: white; }
  .card { box-shadow: none; border: 1px solid #cbd5e1; }
}
