:root {
  --bg: #020912;
  --panel: #061321;
  --panel-2: #091b2f;
  --line: #24415e;
  --text: #eff7ff;
  --muted: #9fb5cb;
  --blue: #1767e8;
  --green: #35e46b;
  --yellow: #ffd23f;
  --red: #ff3d4d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

.dashboard {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) 260px;
  gap: 6px;
  padding: 6px;
}

.sidebar, .viewer-card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sidebar {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.logo {
  width: 100%;
  max-height: 64px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.patient-card {
  display: grid;
  gap: 3px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  font-size: 12px;
}

.patient-card span, .control-title {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
}

nav {
  display: grid;
  gap: 6px;
}

button {
  border: 1px solid var(--line);
  background: #07182a;
  color: var(--text);
  border-radius: 6px;
  padding: 9px 10px;
  font-weight: 700;
  cursor: pointer;
}

button.active {
  background: var(--blue);
  border-color: var(--blue);
}

.upload-card {
  border: 1px dashed #4b759e;
  border-radius: 7px;
  padding: 12px;
  display: grid;
  gap: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.upload-card strong { color: #2ff4ff; }
.upload-card span { color: #b6c7da; font-size: 12px; }
.upload-card input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.controls .control-title {
  grid-column: 1 / -1;
}

.viewer-card {
  display: grid;
  grid-template-rows: 34px minmax(0, 1fr) 28px auto;
  min-height: calc(100vh - 16px);
  overflow: hidden;
}

.viewer-card header, .viewer-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.viewer-card footer {
  justify-content: center;
  gap: 16px;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  color: #dff4ff;
  font-size: 12px;
}

.image-stage {
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 8px;
  position: relative;
  overflow: hidden;
}

#mainImage {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: calc(100vh - 82px);
  object-fit: contain;
  object-position: center center;
}

#mainImage:not([src]) { display: none; }

#emptyState {
  color: var(--muted);
  font-size: 20px;
  text-align: center;
}

.results {
  display: grid;
  grid-template-rows: auto auto auto minmax(120px, 1fr);
  gap: 8px;
  min-height: calc(100vh - 16px);
}

.panel {
  padding: 12px;
  overflow: hidden;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  color: #ddecff;
  margin-bottom: 8px;
}

#findingsList {
  margin: 0;
  padding-left: 24px;
}

#findingsList li {
  margin: 7px 0;
  font-size: 16px;
  font-weight: 700;
}

.risk-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.gauge {
  width: 92px;
  height: 48px;
  border-radius: 92px 92px 0 0;
  background: conic-gradient(from 270deg, var(--green) 0 35%, var(--yellow) 35% 62%, var(--red) 62% 100%);
  position: relative;
  overflow: hidden;
}

.gauge::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 0;
  height: 30px;
  background: var(--panel);
  border-radius: 60px 60px 0 0;
}

#needle {
  position: absolute;
  width: 3px;
  height: 46px;
  background: #fff;
  bottom: -4px;
  left: 45px;
  transform-origin: bottom center;
  transform: rotate(-70deg);
  z-index: 2;
}

#riskPercent {
  font-size: 38px;
  color: var(--red);
  font-weight: 900;
  line-height: 1;
}

#riskLevel {
  font-size: 17px;
  font-weight: 800;
}

.risk-bar {
  margin-top: 10px;
  height: 7px;
  border-radius: 999px;
  background: #17304a;
  overflow: hidden;
}

.risk-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--green), var(--yellow), var(--red));
}

.output h2 {
  color: var(--green);
  font-size: 24px;
  line-height: 1;
  margin: 14px 0 8px;
}

.output h2.positive { color: var(--red); }
.output h2.review { color: var(--yellow); }

.output p, .model-card p, .viewer-explain li {
  color: #d8e8f8;
  font-size: 13px;
  line-height: 1.35;
}

.viewer-explain {
  max-height: 170px;
  padding: 10px 14px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
  background: rgba(9, 27, 47, 0.66);
}

.viewer-explain strong {
  display: block;
  margin-bottom: 6px;
  color: #ddecff;
}

.viewer-explain ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

@media (max-width: 920px) {
  .dashboard {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
  }
  .viewer-card {
    min-height: 58vh;
  }
  .results {
    min-height: auto;
  }
  #mainImage {
    max-height: 54vh;
  }
}
