:root {
  color-scheme: light;
  --ink: #06163d;
  --muted: #546582;
  --quiet: #7b8aa3;
  --line: #d7e4f5;
  --line-strong: #b9cae4;
  --page: #eef4fb;
  --panel: #ffffff;
  --blue: #075cff;
  --blue-2: #0ca6ff;
  --blue-dark: #07327f;
  --green: #0b9f6a;
  --red: #cf2432;
  --amber: #d78b00;
  --shadow: 0 18px 42px rgba(18, 49, 100, 0.13);
  --shadow-soft: 0 10px 26px rgba(18, 49, 100, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% -12%, rgba(7, 92, 255, 0.12), transparent 30%),
    linear-gradient(180deg, #f8fbff 0%, #eef4fb 46%, #e8f0fa 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

img {
  max-width: 100%;
}

.app-header {
  height: 68px;
  display: grid;
  grid-template-columns: 286px minmax(280px, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 30px rgba(17, 43, 84, 0.08);
  backdrop-filter: blur(16px);
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.brand-mark img {
  width: 39px;
  height: 39px;
  object-fit: contain;
}

.brand strong,
.brand small {
  display: block;
  overflow: hidden;
  line-height: 1.18;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand strong {
  font-size: 17px;
  font-weight: 950;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.case-strip {
  min-height: 46px;
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) 146px;
  align-items: center;
  gap: 12px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #f7fbff);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.case-strip span,
.case-strip small,
.eyebrow,
.panel-head span,
.metric-card span,
.metric-grid span {
  color: var(--blue);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.case-strip strong {
  min-width: 0;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-strip small {
  justify-self: end;
  color: var(--quiet);
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.top-actions a,
.top-actions button,
.wide {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #c4d5ee;
  border-radius: 11px;
  padding: 0 14px;
  color: var(--blue-dark);
  background: #ffffff;
  font-size: 12px;
  font-weight: 950;
  box-shadow: 0 8px 18px rgba(7, 92, 255, 0.06);
}

.top-actions a:hover,
.top-actions button:hover,
.wide:hover {
  border-color: var(--blue);
  background: #f4f9ff;
}

.primary {
  border-color: var(--blue) !important;
  color: #ffffff !important;
  background: linear-gradient(135deg, var(--blue), var(--blue-2)) !important;
  box-shadow: 0 12px 28px rgba(7, 92, 255, 0.24) !important;
}

.app-shell {
  height: calc(100vh - 68px);
  padding: 12px;
}

.workspace {
  height: 100%;
  display: grid;
  grid-template-columns: 284px minmax(0, 1fr) 310px;
  gap: 12px;
  align-items: stretch;
}

.control-panel,
.result-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 11px;
  overflow: auto;
  padding: 2px;
}

.system-card,
.panel,
.viewer-panel,
.metric-card,
.metric-grid article {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.system-card,
.panel,
.metric-card,
.metric-grid article {
  padding: 15px;
}

.module-card {
  position: relative;
  overflow: hidden;
  color: #ffffff;
  background:
    radial-gradient(circle at 18% 10%, rgba(62, 190, 255, 0.42), transparent 31%),
    radial-gradient(circle at 96% 100%, rgba(4, 166, 255, 0.34), transparent 36%),
    linear-gradient(145deg, #071843 0%, #0a3279 58%, #075cff 100%);
}

.module-card::after {
  position: absolute;
  right: -50px;
  bottom: -56px;
  width: 170px;
  height: 170px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  content: "";
}

.module-card .eyebrow,
.module-card p {
  color: rgba(255, 255, 255, 0.78);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 230px;
  margin-top: 7px;
  font-size: 27px;
  line-height: 1.04;
  letter-spacing: 0;
}

h2 {
  font-size: 21px;
  line-height: 1.14;
  letter-spacing: 0;
}

p {
  color: var(--muted);
  line-height: 1.5;
}

.module-card p,
.compact-card p,
.prediction-card p {
  margin-top: 9px;
  font-size: 13px;
}

.workflow-list {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 7px;
  margin-top: 15px;
}

.workflow-list span {
  min-height: 30px;
  display: flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  padding: 0 10px;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
  font-weight: 900;
}

.workflow-list span.active,
.workflow-list span.done {
  color: #ffffff;
  background: rgba(18, 183, 255, 0.24);
}

.workflow-list span.done::after {
  margin-left: auto;
  content: "OK";
  color: rgba(255, 255, 255, 0.76);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-head strong {
  font-size: 15px;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 9px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
}

input,
textarea {
  width: 100%;
  border: 1px solid #c8d7eb;
  border-radius: 11px;
  padding: 9px 10px;
  color: var(--ink);
  background: #ffffff;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(7, 92, 255, 0.12);
}

textarea {
  min-height: 64px;
  resize: vertical;
}

.drop-zone {
  position: relative;
  min-height: 104px;
  display: grid;
  place-items: center;
  gap: 6px;
  border: 1.5px dashed #9ab7e3;
  border-radius: 14px;
  color: var(--blue-dark);
  background:
    radial-gradient(circle at 50% 0%, rgba(7, 92, 255, 0.1), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(235, 245, 255, 0.94));
  text-align: center;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--blue);
  background: #eff7ff;
}

.drop-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-zone strong {
  font-size: 15px;
}

.drop-zone span,
.file-name {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.file-name {
  display: block;
  margin-top: 9px;
}

.range-row {
  margin-bottom: 13px;
}

.range-row output {
  color: var(--blue-dark);
  font-size: 13px;
  font-weight: 950;
}

input[type="range"] {
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  accent-color: var(--blue);
  background: #d8e7fb;
}

.wide {
  width: 100%;
  margin-top: 8px;
}

.viewer-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) 42px;
  overflow: hidden;
}

.viewer-toolbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.mode-tabs button {
  min-height: 33px;
  border: 1px solid #c5d7ef;
  border-radius: 10px;
  padding: 0 11px;
  color: var(--blue-dark);
  background: #ffffff;
  font-size: 12px;
  font-weight: 950;
}

.mode-tabs button.active {
  border-color: var(--blue);
  color: #ffffff;
  background: var(--blue);
}

.image-stage {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(14, 76, 150, 0.08) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(0deg, rgba(14, 76, 150, 0.08) 1px, transparent 1px) 0 0 / 44px 44px,
    radial-gradient(circle at 50% 44%, rgba(7, 92, 255, 0.1), transparent 46%),
    #edf4fb;
}

.image-stage::before {
  position: absolute;
  inset: 20px;
  border: 1px solid rgba(7, 92, 255, 0.14);
  border-radius: 18px;
  content: "";
  pointer-events: none;
}

.image-stage::after {
  position: absolute;
  inset: auto 30px 22px 30px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(7, 92, 255, 0.28), transparent);
  content: "";
}

#mainImage {
  width: min(78%, 720px);
  max-height: calc(100vh - 206px);
  border-radius: 14px;
  object-fit: contain;
  background: #071120;
  box-shadow: 0 30px 70px rgba(7, 24, 67, 0.25);
}

.sample-mode #mainImage {
  width: min(74vh, 76%, 690px);
}

.custom-mode #mainImage {
  width: min(80%, 730px);
}

.custom-mode.enhanced-mode #mainImage {
  filter: grayscale(1) contrast(1.2) brightness(1.04);
}

.custom-mode.segmentation-mode #mainImage,
.custom-mode.mask-mode #mainImage {
  filter: grayscale(1) contrast(1.12) brightness(0.78);
}

.scan-glow,
.heatmap-overlay,
.measurement-overlay {
  pointer-events: none;
}

.scan-glow {
  position: absolute;
  inset: 12% 18%;
  border-radius: 22px;
  background: linear-gradient(90deg, transparent, rgba(32, 197, 255, 0.17), transparent);
  opacity: 0;
}

.analyzing .scan-glow {
  animation: scan 1s ease-in-out infinite;
  opacity: 1;
}

.heatmap-overlay {
  position: absolute;
  width: 165px;
  height: 198px;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 42, 42, 0.5), rgba(255, 222, 0, 0.32) 35%, rgba(0, 178, 255, 0.22) 62%, transparent 72%);
  mix-blend-mode: screen;
  opacity: 0;
  transform: translateY(40px);
}

.custom-mode.segmentation-mode .heatmap-overlay,
.custom-mode.mask-mode .heatmap-overlay {
  opacity: 0.82;
}

.measurement-overlay {
  position: absolute;
  inset: 11% 17%;
  display: none;
}

.custom-mode.measurement-mode .measurement-overlay {
  display: block;
}

.center-line,
.heart-line,
.thorax-line,
.heart-label,
.thorax-label {
  position: absolute;
}

.center-line {
  top: 8%;
  bottom: 8%;
  left: 50%;
  width: 3px;
  background: rgba(255, 224, 44, 0.92);
  box-shadow: 0 0 14px rgba(255, 224, 44, 0.5);
}

.heart-line {
  top: 56%;
  left: 50%;
  width: 23%;
  height: 4px;
  background: #e11d1d;
  transform: translateX(0);
}

.thorax-line {
  left: 13%;
  right: 13%;
  bottom: 14%;
  height: 4px;
  background: #1dc771;
}

.heart-label,
.thorax-label {
  border-radius: 999px;
  padding: 5px 9px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 950;
}

.heart-label {
  top: calc(56% - 30px);
  left: 54%;
  background: #b91c1c;
}

.thorax-label {
  bottom: calc(14% + 10px);
  left: 13%;
  background: #087f4f;
}

.viewer-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 16px;
  border-top: 1px solid var(--line);
  color: #53627d;
  background: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.viewer-status span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-card strong {
  display: block;
  font-size: 16px;
}

.metric-card,
.metric-grid article {
  padding: 16px;
}

.prediction-card strong {
  display: block;
  margin-top: 8px;
  color: var(--red);
  font-size: 29px;
  line-height: 1;
}

.prediction-card.normal strong {
  color: var(--green);
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
}

.metric-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

.report-panel {
  flex: 1;
  min-height: 230px;
  display: flex;
  flex-direction: column;
}

.report-panel p {
  flex: 1;
  min-height: 130px;
  font-size: 14px;
}

:fullscreen body,
:fullscreen .app-shell {
  background: #eef4fb;
}

body:fullscreen,
html:fullscreen {
  overflow: hidden;
}

@keyframes scan {
  0% {
    transform: translateX(-38%);
  }
  50% {
    transform: translateX(38%);
  }
  100% {
    transform: translateX(-38%);
  }
}

@media print {
  body {
    overflow: visible;
    background: #ffffff;
  }

  .app-header,
  .control-panel,
  .mode-tabs,
  .viewer-status {
    display: none !important;
  }

  .app-shell {
    height: auto;
    padding: 0;
  }

  .workspace {
    display: block;
    height: auto;
  }

  .viewer-panel,
  .result-panel .panel,
  .metric-card,
  .metric-grid article {
    box-shadow: none;
  }

  .image-stage {
    min-height: 520px;
  }
}

@media (max-width: 1180px) {
  body {
    overflow: auto;
  }

  .app-header {
    height: auto;
    grid-template-columns: 1fr;
  }

  .case-strip {
    grid-template-columns: 1fr;
  }

  .case-strip small {
    justify-self: start;
  }

  .app-shell {
    height: auto;
  }

  .workspace {
    height: auto;
    grid-template-columns: 290px minmax(0, 1fr);
  }

  .result-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 260px 300px 1fr;
  }

  .image-stage {
    min-height: 620px;
  }

  #mainImage,
  .custom-mode #mainImage {
    max-height: 560px;
  }
}

@media (max-width: 880px) {
  .workspace,
  .result-panel {
    grid-template-columns: 1fr;
  }

  .top-actions,
  .viewer-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .top-actions a,
  .top-actions button {
    width: 100%;
  }

  .image-stage {
    min-height: 520px;
  }

  #mainImage,
  .custom-mode #mainImage {
    width: min(90%, 560px);
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 10px;
  }

  .top-actions,
  .mode-tabs,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .mode-tabs,
  .mode-tabs button {
    width: 100%;
  }

  h1 {
    font-size: 25px;
  }
}
