:root {
  --font-small: 11px;
  --font-body: 13px;
  --font-section: 16px;
  --font-title: 22px;
  color-scheme: dark;
  --navy: #071529;
  --navy-2: #0b1f3a;
  --panel: #0d2038;
  --panel-2: #112a49;
  --line: rgba(166, 191, 225, 0.18);
  --text: #eef5ff;
  --muted: #91a4be;
  --blue: #3d7cff;
  --blue-2: #1762f4;
  --green: #43d69e;
  --danger: #ff6b7a;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  min-width: 900px;
  overflow: hidden;
  background: #050c16;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-size: var(--font-body);
}

button, input, textarea, select { font: inherit; }
button { -webkit-user-select: none; user-select: none; }

.mode-chooser {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 36px;
  background: radial-gradient(circle at 50% 30%, rgba(26, 80, 151, .42), transparent 42%), linear-gradient(145deg, #020913, #071529 58%, #0a2342);
}
.mode-card { width: min(820px, calc(100vw - 72px)); border: 1px solid rgba(164, 194, 235, .2); border-radius: 24px; background: rgba(7, 21, 41, .9); padding: 30px; box-shadow: 0 30px 80px rgba(0,0,0,.45); text-align: center; backdrop-filter: blur(18px); }
.mode-card > img { display: block; width: 220px; height: 220px; object-fit: contain; margin: 0 auto 6px; }
.mode-card h2 { margin: 8px 0 7px; font-size: var(--font-title); }
.mode-card > p { margin: 0 auto 24px; max-width: 520px; color: var(--muted); line-height: 1.5; }
.mode-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.mode-option { min-height: 132px; display: flex; flex-direction: column; justify-content: center; gap: 9px; border: 1px solid rgba(137, 172, 219, .24); border-radius: 16px; background: linear-gradient(145deg, rgba(28, 67, 113, .62), rgba(10, 30, 54, .88)); color: var(--text); padding: 20px 16px; cursor: pointer; transition: transform .16s ease, border-color .16s ease, background .16s ease; }
.mode-option:hover { transform: translateY(-2px); border-color: rgba(61,124,255,.8); background: linear-gradient(145deg, rgba(40, 92, 159, .78), rgba(12, 39, 71, .94)); }
.mode-option strong { font-size: var(--font-section); }
.mode-option span { color: #a9bad0; font-size: var(--font-small); line-height: 1.4; }
.mode-library-button { width: 100%; min-height: 52px; margin-top: 12px; border: 1px solid rgba(137, 172, 219, .35); border-radius: 15px; background: rgba(16, 45, 79, .82); color: var(--text); font-weight: 750; cursor: pointer; transition: border-color .16s ease, background .16s ease, transform .16s ease; }
.mode-library-button:hover { transform: translateY(-1px); border-color: rgba(61,124,255,.8); background: rgba(27, 69, 119, .9); }

.app-shell { height: 100%; display: flex; flex-direction: column; }

.topbar {
  height: 50px;
  flex: 0 0 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: rgba(246, 246, 246, .96);
  border-bottom: 1px solid #c8c8c8;
  color: var(--navy);
  backdrop-filter: blur(18px);
}

.top-actions { display: flex; gap: 6px; }
.task-tray { flex: 1; min-width: 0; display: flex; justify-content: center; gap: 7px; overflow-x: auto; padding: 3px 12px; scrollbar-width: none; }
.task-tray::-webkit-scrollbar { display: none; }
.task-pill { flex: 0 0 min(270px, 26vw); min-width: 180px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 7px; align-items: center; border: 1px solid rgba(36,91,163,.28); border-radius: 10px; background: rgba(232,240,252,.95); color: #173253; padding: 5px 7px 5px 9px; box-shadow: 0 2px 8px rgba(24,58,105,.09); }
.task-pill strong, .task-pill span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-pill strong { font-size: var(--font-small); }
.task-pill span { color: #58708e; font-size: var(--font-small); }
.task-pill button { grid-column: 2; grid-row: 1 / 3; width: 20px; height: 20px; border: 0; border-radius: 50%; background: transparent; color: #6c7f96; padding: 0; font-size: var(--font-section); line-height: 1; cursor: pointer; }
.task-pill button:hover { background: rgba(255,85,103,.12); color: #c93048; }
.task-pill .task-progress { grid-column: 1; height: 2px; overflow: hidden; border-radius: 999px; background: rgba(23,50,83,.12); }
.task-pill .task-progress > i { display: block; width: 35%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--green)); animation: task-progress 1.35s ease-in-out infinite; }
@keyframes task-progress { 0% { transform: translateX(-120%); } 100% { transform: translateX(390%); } }
.topbar > .button, .top-actions .button { border-radius: 7px; padding: 6px 10px; font-size: var(--font-body); }
.top-actions .button.primary { box-shadow: 0 2px 7px rgba(23, 98, 244, .2); }
.mode-button { border-color: #91a9c9; background: #edf4ff; }

.button {
  appearance: none;
  border: 1px solid #c4d0e2;
  border-radius: 9px;
  background: #fff;
  color: #173253;
  padding: 9px 13px;
  font-weight: 650;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.button:hover { border-color: #7ca0d5; background: #f6f9ff; }
.button:active { transform: translateY(1px); }
.button.primary { border-color: var(--blue-2); color: white; background: linear-gradient(135deg, #3d7cff, #1557e5); box-shadow: 0 6px 18px rgba(23, 98, 244, .24); }
.button.full { width: 100%; }
select.mode-button { appearance: auto; min-width: 126px; padding-right: 24px; }

.workspace {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  gap: 1px;
  background: #14263d;
}

.panel { min-width: 0; background: var(--navy); }
.study-panel { padding: 12px; overflow: auto; }
.report-panel { padding: 22px; overflow: auto; }
.report-panel { display: flex; flex-direction: column; }
.viewer-panel { display: flex; min-width: 0; flex-direction: column; overflow: hidden; background: #02060c; }
.volume-open:not(.measurement-open) > .stack-controls { display: none; }
.reconstruction-select { background: #121c29; border-color: #354258; flex: 0 0 auto; }
body:not([data-exam-mode="ct"]) .reconstruction-select { display: none; }
.reconstruction-open #cineBtn { display: none; }
.volume-reconstruction-only .volume-toolbar { display: none; }
body:not([data-exam-mode="ct"]) .volume-entry { display: none; }
.volume-panel { position: absolute; inset: 0; z-index: 8; display: flex; flex-direction: column; background: #04090f; cursor: default; }
.volume-toolbar { display: flex; flex-wrap: wrap; gap: 5px; padding: 7px; border-bottom: 1px solid #273444; }
.volume-toolbar label { display: flex; align-items: center; gap: 3px; font-size: 11px; }
.volume-toolbar input { width: 58px; }
.volume-panel input, .volume-panel select { background: #121c29; color: #e5eaf0; border: 1px solid #354258; border-radius: 5px; padding: 5px; min-width: 0; }
.volume-workspace { display: flex; flex: 1; min-height: 0; }
.volume-view { flex: 1; min-width: 0; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.volume-view img { max-width: none; max-height: none; object-fit: contain; user-select: none; -webkit-user-drag: none; transform-origin: center; }
#volumeDrawing, #volume3D { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.volume-orientation { position: absolute; left: 7px; bottom: 7px; pointer-events: none; white-space: pre-line; font-size: 10px; color: #a6c6d6; }
.volume-measures { width: 222px; flex: 0 0 222px; padding: 10px; border-left: 1px solid #273444; display: flex; flex-direction: column; gap: 7px; overflow-y: auto; color: #cdd6df; font-size: 11px; }
.volume-measures p { margin: 0; line-height: 1.5; color: #97a6b6; }
.volume-segmentation-controls, #volume3DControls { display: flex; flex-direction: column; gap: 7px; }
.volume-color-bands { display: flex; flex-direction: column; gap: 8px; }
.volume-color-band { min-width: 0; margin: 0; padding: 7px; border: 1px solid #304359; border-radius: 6px; }
.volume-color-heading { display: flex; align-items: center; justify-content: space-between; gap: 5px; margin-bottom: 5px; }
.volume-color-heading label { display: flex; align-items: center; gap: 4px; }
.volume-color-heading input[type="color"] { width: 35px; height: 25px; padding: 1px; cursor: pointer; }
.volume-color-band .volume-color-bound { display: grid; grid-template-columns: 1fr 70px; align-items: center; gap: 4px; }
.volume-color-band input[type="range"], #volume3DControls > label > input[type="range"] { display: block; width: 100%; min-width: 0; margin: 4px 0 7px; }
.volume-color-band input[type="number"] { width: 70px; }
.volume-color-band label:last-child input { margin-bottom: 0; }
.volume-mode-3d .volume-measures { width: 258px; flex-basis: 258px; }
.volume-color-bands.disabled { opacity: .5; }
.volume-color-notice { color: #ffab9c !important; }
.volume-color-band input[aria-invalid="true"] { outline: 1px solid #ffab9c; }
.volume-measures .tool { white-space: normal; }
.volume-mode-3d .volume-toolbar label, .volume-mode-3d #volumeBone, .volume-mode-3d #volumeNative { display: none; }
.volume-measures label { display: block; line-height: 1.5; }
.volume-measures input[type="number"] { width: 65px; }
.volume-hu, .volume-edit-tools { display: flex; gap: 4px; }
.volume-edit-tools .tool { flex: 1; padding: 5px; }
#volumeResult { padding: 8px; border: 1px solid #304359; border-radius: 6px; white-space: pre-line; line-height: 1.5; color: #9de0e4; }
.volume-navigation { display: flex; align-items: center; gap: 8px; padding: 5px 10px; font-size: 11px; }
.volume-navigation input { flex: 1; }
.measurement-open .volume-navigation { display: none; }
.volume-range-labels { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.volume-range-labels output { display: block; color: #e4eef8; }
.volume-hu-range { position: relative; height: 32px; --low: 25.45%; --high: 100%; }
.volume-hu-range::before { content: ''; position: absolute; left: 8px; right: 8px; top: 13px; height: 6px; border-radius: 4px; background: linear-gradient(to right,#334155 0 var(--low),#3d7cff var(--low) var(--high),#334155 var(--high) 100%); }
.volume-panel .volume-hu-range input { appearance: none; -webkit-appearance: none; position: absolute; inset: 0; width: 100%; height: 32px; margin: 0; padding: 0; border: 0; background: transparent; pointer-events: none; }
.volume-hu-range input::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 16px; height: 22px; border-radius: 7px; background: white; border: 1px solid #99aac0; box-shadow: 0 1px 4px #0008; pointer-events: auto; cursor: ew-resize; }
.volume-hu-range input::-moz-range-thumb { width: 16px; height: 22px; border-radius: 7px; background: white; border: 1px solid #99aac0; pointer-events: auto; cursor: ew-resize; }
.volume-notice { margin: 0; padding: 6px 10px; font-size: 11px; color: #aab7c6; line-height: 1.4; }
.volume-notice.error { color: #ffab9c; }
.volume-mode-3d .volume-navigation { display: none; }
.volume-reconstruction-only:not(.volume-mode-3d) .volume-measures { display: none; }
.volume-reconstruction-only #volumeDrawing { pointer-events: none; }
.volume-review-prompt { padding: 10px; border: 1px solid #459ea5; border-radius: 8px; font-size: 12px; }
.volume-review-prompt p { margin: 0 0 8px; }
.volume-review-prompt .tool { white-space: normal; }
body:not([data-exam-mode="ct"]) .automatic-volume-option { display: none; }
@media (max-width: 1200px) { .volume-measures { width: 190px; flex-basis: 190px; } }

.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel-heading h2 { margin: 4px 0 0; font-size: var(--font-section); }
.eyebrow { color: #73a5ff; font-size: var(--font-small); font-weight: 800; letter-spacing: .13em; }
.badge, .ai-chip { border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: rgba(255,255,255,.04); font-size: var(--font-small); font-weight: 750; padding: 5px 8px; white-space: nowrap; }
.ai-chip { color: #b9d2ff; border-color: rgba(61,124,255,.4); background: rgba(61,124,255,.12); }

.patient-card { border: 1px dashed rgba(145,164,190,.28); border-radius: 13px; padding: 24px 16px; text-align: center; color: var(--muted); }
.patient-card h2 { margin: 12px 0 6px; color: var(--text); font-size: var(--font-section); }
.patient-card p { margin: 0; line-height: 1.45; font-size: var(--font-body); }
.empty-illustration { width: 58px; height: 58px; margin: 0 auto; display: grid; place-items: center; border-radius: 14px; background: linear-gradient(145deg, rgba(61,124,255,.25), rgba(67,214,158,.12)); border: 1px solid rgba(109,156,255,.3); color: #bcd1ff; font-size: var(--font-small); font-weight: 850; letter-spacing: .08em; }

.patient-data { border: 1px solid var(--line); border-radius: 13px; padding: 14px; background: linear-gradient(145deg, rgba(42,79,126,.26), rgba(13,32,56,.1)); }
.patient-data h2 { margin: 0 0 12px; font-size: var(--font-section); overflow-wrap: anywhere; }
.patient-data dl { margin: 0; display: grid; gap: 9px; }
.patient-data dl div { display: grid; gap: 2px; }
.patient-data dt { color: var(--muted); font-size: var(--font-small); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.patient-data dd { margin: 0; font-size: var(--font-body); line-height: 1.35; }
.series-title { margin: 18px 0 8px; color: var(--muted); font-size: var(--font-small); font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.series-list { display: grid; gap: 7px; }
.series-item { width: 100%; display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 10px; background: rgba(255,255,255,.035); color: var(--text); padding: 4px 6px; }
.series-item:hover { background: rgba(255,255,255,.07); }
.series-item.active { border-color: rgba(61,124,255,.7); background: rgba(61,124,255,.16); }
.series-analysis-checkbox { width: 15px; height: 15px; margin: 0; accent-color: var(--blue); cursor: pointer; }
.series-view-button { min-width: 0; border: 0; border-radius: 7px; background: transparent; color: inherit; text-align: left; padding: 6px 4px; cursor: pointer; }
.series-view-button:focus-visible { outline: 2px solid rgba(61,124,255,.8); outline-offset: 1px; }
.series-view-button strong { display: block; font-size: var(--font-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.series-view-button span { display: block; margin-top: 4px; color: var(--muted); font-size: var(--font-small); }

.operation-card { margin-top: 14px; border: 1px solid var(--line); border-radius: 11px; padding: 11px; background: rgba(61,124,255,.08); }
.operation-row, .report-progress-head { display: flex; justify-content: space-between; gap: 10px; font-size: var(--font-small); }
.progress { height: 5px; margin-top: 9px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.1); }
.progress > div { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--green)); transition: width .25s ease; }
.progress > div.indeterminate { width: 38% !important; animation: report-indeterminate 1.35s ease-in-out infinite; transition: none; }
@keyframes report-indeterminate {
  0% { transform: translateX(-130%); }
  100% { transform: translateX(365%); }
}

.viewer-toolbar { min-height: 50px; display: flex; align-items: center; gap: 7px; padding: 7px 12px; background: #0a1728; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tool-group { display: flex; gap: 3px; padding: 3px; border-radius: 9px; background: rgba(255,255,255,.04); }
.tool, .icon-button { border: 1px solid transparent; border-radius: 7px; background: transparent; color: #9fb0c8; padding: 7px 9px; font-size: var(--font-small); font-weight: 700; cursor: pointer; white-space: nowrap; }
.tool:hover, .icon-button:hover { color: white; background: rgba(255,255,255,.07); }
.tool.active, .icon-button.active, .preset.active { color: white; border-color: rgba(61,124,255,.45); background: rgba(61,124,255,.18); }
.window-preset-select { appearance: auto; min-width: 112px; border-color: rgba(255,255,255,.09); background: #0a1728; }
.window-preset-select.active { color: white; border-color: rgba(61,124,255,.45); background: rgba(61,124,255,.18); }
.tool-divider { width: 1px; height: 26px; background: var(--line); margin: 0 2px; }
.toolbar-spacer { flex: 1; }
.window-values { display: flex; gap: 5px; }
.window-values label { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: var(--font-small); font-weight: 800; }
.window-values input { width: 58px; border: 1px solid var(--line); border-radius: 6px; background: #071221; color: white; padding: 5px; font-size: var(--font-small); }

.viewport { position: relative; flex: 1; min-height: 0; overflow: hidden; background: radial-gradient(circle at center, #111720 0, #03070c 58%, #010306 100%); cursor: crosshair; }
.viewer-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; color: #6d7d92; text-align: center; padding: 24px; }
.viewer-empty h2 { margin: 18px 0 6px; color: #abb9cb; font-size: var(--font-section); }
.viewer-empty p { margin: 0; max-width: 410px; font-size: var(--font-body); line-height: 1.5; }
.viewer-watermark { position: absolute; right: 24px; bottom: 24px; width: min(24vw, 260px); max-height: 44%; object-fit: contain; opacity: .16; pointer-events: none; user-select: none; }
.viewer-symbol { width: 120px; height: 120px; display: grid; place-items: center; }
.modality-symbol { display: none; width: 118px; height: 118px; overflow: visible; fill: none; stroke: rgba(61,124,255,.56); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.symbol-ct { display: block; }
.symbol-ecg { width: 180px; height: 80px; stroke-width: 2; }
body[data-exam-mode="rx"] .symbol-ct, body[data-exam-mode="ecg"] .symbol-ct { display: none; }
body[data-exam-mode="rx"] .symbol-rx, body[data-exam-mode="ecg"] .symbol-ecg { display: block; }
.image-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.image-stage img { max-width: none; max-height: none; width: 96%; height: 96%; object-fit: contain; image-rendering: auto; transform-origin: center; filter: drop-shadow(0 4px 20px rgba(0,0,0,.65)); -webkit-user-drag: none; user-select: none; }
.overlay { position: absolute; z-index: 3; color: #f3f7ff; font: 11px/1.45 ui-monospace, "SFMono-Regular", Menlo, monospace; text-shadow: 0 1px 4px #000; pointer-events: none; white-space: pre-line; }
.top-left { top: 13px; left: 14px; }.top-right { top: 13px; right: 14px; text-align: right; }.bottom-left { bottom: 13px; left: 14px; }.bottom-right { bottom: 13px; right: 14px; text-align: right; }
.stack-controls { min-height: 45px; display: flex; align-items: center; gap: 10px; padding: 7px 12px; background: #091525; border-top: 1px solid var(--line); }
.stack-controls input { flex: 1; accent-color: var(--blue); }
.stack-controls span { min-width: 64px; color: var(--muted); font: 10px ui-monospace, monospace; text-align: right; }
.slice-button { width: 31px; height: 31px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.04); color: white; font-size: 21px; cursor: pointer; }

.patient-fields { display: grid; grid-template-columns: minmax(0, 2fr) minmax(82px, 1fr); gap: 8px; margin-bottom: 13px; }
.patient-fields label { display: grid; gap: 6px; color: #cbd8e8; font-size: var(--font-small); font-weight: 750; }
.patient-name-field { position: relative; }
.patient-fields input { width: 100%; min-width: 0; height: 36px; border: 1px solid var(--line); border-radius: 9px; outline: none; background: rgba(0,0,0,.2); color: var(--text); padding: 0 10px; }
.patient-suggestions { position: absolute; z-index: 30; top: calc(100% + 2px); left: 0; right: 0; display: grid; overflow: hidden; border: 1px solid rgba(116,151,199,.55); border-radius: 10px; background: #101f33; box-shadow: 0 12px 28px rgba(0,0,0,.42); }
.patient-suggestion { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; border: 0; border-bottom: 1px solid rgba(145,164,190,.14); background: transparent; padding: 9px 10px; color: #edf4ff; text-align: left; cursor: pointer; }
.patient-suggestion:last-child { border-bottom: 0; }
.patient-suggestion:hover, .patient-suggestion:focus-visible { outline: none; background: rgba(61,124,255,.16); }
.patient-suggestion strong { overflow: hidden; font-size: var(--font-small); text-overflow: ellipsis; white-space: nowrap; }
.patient-suggestion small { flex: none; color: #91a4be; font-size: var(--font-small); font-weight: 650; }
.anatomy-region { width: 100%; height: 36px; margin: 0 0 5px; border: 1px solid var(--line); border-radius: 9px; outline: none; background: rgba(0,0,0,.2); color: var(--text); padding: 0 10px; font-size: var(--font-small); }
.anatomy-region:focus { border-color: rgba(61,124,255,.7); box-shadow: 0 0 0 3px rgba(61,124,255,.1); }
.anatomy-region:disabled { opacity: .6; }
.coverage-note { margin: 0 0 12px; color: var(--muted); font-size: var(--font-small); line-height: 1.4; }
.report-panel textarea { width: 100%; height: 142px; resize: vertical; border: 1px solid var(--line); border-radius: 12px; outline: none; background: rgba(0,0,0,.2); color: var(--text); padding: 12px; line-height: 1.5; }
.patient-fields input:focus, .report-panel textarea:focus { border-color: rgba(61,124,255,.7); box-shadow: 0 0 0 3px rgba(61,124,255,.1); }
.field-label { display: block; margin-bottom: 7px; color: #cbd8e8; font-size: var(--font-small); font-weight: 750; }
.text-counter { margin-top: 5px; color: var(--muted); font-size: var(--font-small); text-align: right; }
.privacy-note { position: relative; display: grid; place-items: center; margin: 14px 0; border-radius: 10px; background: rgba(67,214,158,.08); padding: 11px 36px; color: #a8cabb; text-align: center; }
.privacy-note p { margin: 0; width: 100%; font-size: var(--font-small); line-height: 1.45; text-align: center; }
.privacy-icon { position: absolute; left: 10px; top: 50%; width: 20px; height: 20px; display: grid; place-items: center; transform: translateY(-50%); border-radius: 50%; background: rgba(67,214,158,.18); color: var(--green); font-size: var(--font-small); font-weight: 900; }
.comparative-option { display: flex; align-items: center; gap: 10px; margin: -2px 0 13px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.025); padding: 9px 10px; color: #d8e4f3; cursor: pointer; }
.comparative-option input { width: 15px; height: 15px; margin: 0; accent-color: var(--blue); }
.comparative-option strong { font-size: var(--font-small); }
.report-button { width: 100%; border: 0; border-radius: 12px; background: linear-gradient(135deg, #3d7cff, #1558e8 62%, #154cc6); color: white; padding: 13px; font-weight: 800; cursor: pointer; box-shadow: 0 10px 24px rgba(21,88,232,.28); }
.report-button span { display: block; }
.report-button:disabled { opacity: .38; cursor: not-allowed; box-shadow: none; }
.report-progress { margin-top: 14px; border: 1px solid rgba(61,124,255,.25); border-radius: 12px; background: rgba(61,124,255,.08); padding: 12px; }
.report-progress p { margin: 8px 0 0; color: var(--muted); font-size: var(--font-small); }
.report-progress.error { border-color: rgba(255,85,103,.48); background: rgba(255,85,103,.1); }
.report-progress.error .progress > div { background: #ff5567; }
.report-ready { margin-top: 14px; display: grid; grid-template-columns: 44px 1fr; gap: 10px; border: 1px solid rgba(67,214,158,.25); border-radius: 12px; background: rgba(67,214,158,.08); padding: 12px; }
.report-ready h3 { margin: 2px 0 3px; font-size: var(--font-body); }.report-ready p { margin: 0; color: var(--muted); font-size: var(--font-small); overflow-wrap: anywhere; }
.ready-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 9px; background: rgba(67,214,158,.16); color: var(--green); font-size: var(--font-small); font-weight: 900; }
.report-ready .full { grid-column: 1 / -1; }
.report-ready .cloud-publish { border-color: rgba(67,214,158,.4); background: rgba(67,214,158,.14); color: #8df0c8; }
.report-ready .cloud-publish:disabled { opacity: .45; cursor: not-allowed; }
.clinical-safety { margin-top: 16px; color: #7f91a9; font-size: var(--font-small); line-height: 1.45; text-align: center; }
.developer-credit { margin-top: auto; padding-top: 20px; color: #667a95; font-size: var(--font-small); line-height: 1.4; text-align: center; }

.library-page { position: fixed; z-index: 40; inset: 50px 0 0; overflow: auto; background: linear-gradient(145deg, #071529, #0b1f3a 62%, #08182d); color: var(--text); padding: 28px 34px 42px; }
.library-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; max-width: 1320px; margin: 0 auto 24px; }
.library-header h2 { margin: 5px 0 5px; font-size: var(--font-title); }
.library-header p { margin: 0; color: var(--muted); font-size: var(--font-body); }
.library-header-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.cloud-auth-notice { max-width: 1320px; margin: 0 auto 16px; color: var(--muted); font-size: var(--font-body); }
.cloud-auth-notice:empty { display: none; }
.library-filters { display: grid; grid-template-columns: minmax(220px, 1.5fr) repeat(3, minmax(140px, .65fr)) auto; align-items: end; gap: 12px; max-width: 1320px; margin: 0 auto 22px; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.035); }
.library-filters label { display: grid; gap: 6px; color: var(--muted); font-size: var(--font-small); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.library-filters input, .library-filters select { width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 9px; outline: none; background: #071526; color: var(--text); padding: 0 11px; font-size: var(--font-small); text-transform: none; letter-spacing: normal; }
.library-filters input:focus, .library-filters select:focus { border-color: rgba(61,124,255,.75); box-shadow: 0 0 0 3px rgba(61,124,255,.1); }
.library-count { align-self: center; min-width: 90px; color: #b9d2ff; font-size: var(--font-small); font-weight: 750; text-align: right; }
.library-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); gap: 14px; max-width: 1320px; margin: 0 auto; }
.library-card { display: flex; min-height: 230px; flex-direction: column; border: 1px solid var(--line); border-radius: 15px; background: linear-gradient(145deg, rgba(27,57,94,.76), rgba(8,24,44,.92)); padding: 17px; box-shadow: 0 14px 34px rgba(0,0,0,.18); }
.library-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.library-head-meta { display: flex; align-items: center; gap: 7px; }
.library-card h3 { margin: 0 0 6px; font-size: var(--font-section); overflow-wrap: anywhere; }
.library-card .exam-description { margin: 0; color: #c0cee0; font-size: var(--font-small); line-height: 1.4; }
.exam-modality { display: inline-block; margin-top: 8px; border-radius: 999px; background: rgba(61,124,255,.16); color: #aecdff; padding: 4px 7px; font-size: var(--font-small); font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.library-cloud-badge { display: inline-block; margin: 8px 0 0 6px; border-radius: 999px; background: rgba(67,214,158,.13); color: #7ee7bd; padding: 4px 7px; font-size: var(--font-small); font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.library-date { display: inline-flex; flex: 0 0 auto; align-items: center; align-self: flex-start; border: 1px solid rgba(61,124,255,.35); border-radius: 999px; background: rgba(61,124,255,.12); color: #b9d2ff; padding: 5px 8px; font-size: var(--font-small); font-weight: 750; line-height: 1; white-space: nowrap; }
.library-card-actions { display: flex; gap: 8px; margin: 15px 0 13px; }
.library-card-actions .button { padding: 7px 10px; font-size: var(--font-small); }
.library-card-actions .button:disabled { opacity: .4; cursor: not-allowed; }
.reports-block { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
.reports-title { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; color: var(--muted); font-size: var(--font-small); font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.report-link { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: 8px; padding: 8px 9px; border-radius: 9px; background: rgba(67,214,158,.07); }
.report-link + .report-link { margin-top: 6px; }
.report-link span { min-width: 0; color: #b8c9dd; font-size: var(--font-small); white-space: normal; overflow-wrap: anywhere; line-height: 1.5; }
.report-link button { border: 0; background: transparent; color: var(--green); font-size: var(--font-small); font-weight: 800; cursor: pointer; }
.library-icon-button { display: inline-grid; flex: 0 0 auto; width: 28px; height: 28px; place-items: center; border: 0; border-radius: 7px; background: transparent; padding: 0; cursor: pointer; transition: color .15s ease, background .15s ease, opacity .15s ease; }
.trash-button { color: #7f93ac; }
.trash-button:hover { background: rgba(255,92,112,.12); color: #ff7185; }
.edit-patient-button { color: #8fa8c3; }
.edit-patient-button:hover { background: rgba(61,124,255,.13); color: #aecdff; }
.publish-button { color: #67d9aa; }
.publish-button:hover { background: rgba(67,214,158,.12); color: #8aefc5; }
.report-link .unpublish-button { color: #ff6176; }
.report-link .unpublish-button:hover { background: rgba(255,92,112,.14); color: #ff8a9a; }
.publish-button:disabled, .unpublish-button:disabled { opacity: .5; cursor: wait; }
.library-icon-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.report-link .trash-button { color: #7790a8; }
.no-reports { color: #71849d; font-size: var(--font-small); }
.library-empty { display: grid; place-items: center; gap: 7px; max-width: 1320px; min-height: 260px; margin: 0 auto; border: 1px dashed rgba(145,164,190,.28); border-radius: 15px; color: var(--muted); text-align: center; }
.library-empty strong { color: var(--text); font-size: var(--font-section); }
.library-empty span { font-size: var(--font-small); }

dialog { width: min(520px, calc(100vw - 40px)); border: 1px solid #d2dce9; border-radius: 16px; background: #fff; color: #142944; padding: 0; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(2,8,16,.72); backdrop-filter: blur(5px); }
dialog form { padding: 22px; }
.dialog-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }.dialog-header h2 { margin: 4px 0 0; font-size: var(--font-section); }.dialog-close { border: 0; background: transparent; color: #6a7b91; font-size: var(--font-title); cursor: pointer; }
dialog input { width: 100%; border: 1px solid #bfccde; border-radius: 9px; outline: none; padding: 11px; color: #122743; background: white; }
dialog input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(61,124,255,.1); }
.edit-patient-fields { display: grid; grid-template-columns: minmax(0, 2fr) minmax(110px, .75fr); gap: 12px; }
.edit-patient-fields label { display: grid; gap: 7px; color: #40536d; font-size: var(--font-small); font-weight: 750; }
.dialog-help { color: #65758b; font-size: var(--font-small); line-height: 1.45; }.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.button.danger { border-color: #d63c52; background: #d63c52; color: #fff; }
.button.danger:hover { border-color: #ea4a61; background: #ea4a61; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: min(580px, calc(100vw - 40px)); border: 1px solid rgba(255,255,255,.16); border-radius: 11px; background: rgba(18,35,57,.96); color: white; padding: 11px 14px; box-shadow: var(--shadow); font-size: var(--font-body); }
.toast.error { border-color: rgba(255,107,122,.45); background: rgba(78,23,35,.97); }

.hidden { display: none !important; }

body[data-exam-mode="rx"] .window-control,
body[data-exam-mode="rx"] .tool[data-tool="window"],
body[data-exam-mode="ecg"] .window-control,
body[data-exam-mode="ecg"] .tool[data-tool="window"],
body[data-exam-mode="ecg"] .cine-control,
body[data-exam-mode="ecg"] .key-images-option { display: none; }

body[data-exam-mode="rx"] .image-stage img,
body[data-exam-mode="ecg"] .image-stage img { width: auto; height: auto; max-width: 96%; max-height: 96%; }

@media (max-width: 1280px) {
  .workspace { grid-template-columns: 196px minmax(0, 1fr); }
  .study-panel { padding: 10px; }
}

@media (max-width: 900px) {
  .mode-options { grid-template-columns: 1fr; }
}

/* Uma hierarquia única para controles, conteúdo e títulos. */
button, input, select, textarea { font-family: inherit; }
.topbar .button, .tool, .icon-button, .anatomy-region,
.patient-fields input, .field-label, .patient-fields label,
.comparative-option strong, .library-filters input, .library-filters select,
.library-card-actions .button, .report-link button { font-size: var(--font-body); }
.study-panel { display: flex; flex-direction: column; overflow-y: auto; }
.study-reports { margin-top: auto; padding-top: 20px; }
.study-reports h3 { font-size: var(--font-body); margin: 0 0 8px; }
#studyReportsList { display: grid; gap: 7px; font-size: var(--font-small); color: var(--muted); }
.study-report-button { width: 100%; text-align: left; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.04); color: var(--text); font-size: var(--font-small); line-height: 1.5; overflow-wrap: anywhere; cursor: pointer; }
.study-report-button:hover { border-color: var(--green); }
.report-notice { font-size: var(--font-small); line-height: 1.5; color: #d9b97e; }
.report-notice.error { color: #ff8e9a; }
.report-notice:empty { display: none; }


.top-navigation { display: flex; flex: 0 0 auto; gap: 7px; align-items: center; }
.top-navigation .button { border-radius: 7px; padding: 6px 10px; }
#interpretationBtn.attention { border-color: var(--blue); background: #e6efff; }
.interpretation-dialog { width: min(590px, calc(100vw - 40px)); max-height: calc(100vh - 46px); padding: 0; border: 1px solid #30455f; background: var(--navy); color: var(--text); overflow-y: auto; }
.interpretation-dialog .report-panel { border-radius: inherit; min-height: 0; }
.interpretation-dialog::backdrop { background: rgba(2,8,16,.64); backdrop-filter: none; }
.interpretation-header-actions { display: flex; align-items: center; gap: 8px; }
.interpretation-dialog input { background: rgba(0,0,0,.2); color: var(--text); border-color: var(--line); }
.interpretation-dialog .developer-credit { margin-top: 20px; }
.mpr-only { display: none; }
.mpr-cache-status { margin-left: 10px; font-size: var(--font-small); color: var(--muted); }
.mpr-open .mpr-only { display: inline-block; }
.mpr-open #rotateBtn, .mpr-open #cineBtn { display: none; }
.volume-mode-mpr .volume-workspace, .volume-mode-mpr > .volume-navigation { display: none; }
.mpr-workspace { min-height: 0; flex: 1; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 1px; background: #26384b; }
.mpr-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; background: #02060c; outline: none; }
.mpr-pane.active { box-shadow: inset 0 0 0 1px var(--plane-color); }
.mpr-pane:focus-visible { outline: 2px solid var(--plane-color); outline-offset: -2px; }
.mpr-pane-header { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 7px 9px; border-top: 2px solid var(--plane-color); background: #0a1728; }
.mpr-pane-header strong { color: #eef5ff; font-size: var(--font-body); }
.mpr-pane-header .tool { padding: 4px 6px; font-size: var(--font-small); }
.mpr-pane-body { position: relative; flex: 1; min-height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; touch-action: none; }
.mpr-image-frame { position: relative; flex: 0 0 auto; transform-origin: center; }
.mpr-image-frame img { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
.mpr-reference { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.mpr-orientation { position: absolute; z-index: 1; color: #a6c6d6; font-size: 11px; text-shadow: 0 1px 3px #000; pointer-events: none; }
.mpr-orientation.top { top: 5px; left: 50%; }
.mpr-orientation.bottom { bottom: 5px; left: 50%; }
.mpr-orientation.left { left: 5px; top: 50%; }
.mpr-orientation.right { right: 5px; top: 50%; }
.mpr-navigation { display: flex; align-items: center; gap: 7px; padding: 6px 8px; color: #aab7c6; font-size: var(--font-small); }
.mpr-navigation input { min-width: 0; flex: 1; width: 100%; }
.mpr-navigation output { flex: 0 0 auto; min-width: 52px; text-align: right; }
.mpr-workspace.expanded { grid-template-columns: minmax(0,1fr); }
.mpr-workspace.expanded .mpr-pane:not(.expanded-pane) { display: none; }

.volume-clips { margin: 8px 0; border-top: 1px solid #304359; border-bottom: 1px solid #304359; padding: 7px 0; }
.volume-clips summary { cursor: pointer; font-weight: 600; }
.volume-clip-plane { min-width: 0; margin: 8px 0; padding: 6px 8px; border: 1px solid #304359; border-radius: 6px; }
.volume-clip-plane legend { padding: 0 4px; font-weight: 600; }
.volume-clip-plane select, .volume-clip-plane input[type="range"] { display: block; width: 100%; min-width: 0; margin: 4px 0; }
.volume-clip-plane label { margin-top: 6px; }
.volume-clip-ends { display: flex; justify-content: space-between; color: #aab7c6; text-transform: capitalize; }

.volume-clip-range { position: relative; height: 28px; margin: 5px 8px; background: linear-gradient(to right, #304359 var(--low,0%), #70bde0 var(--low,0%), #70bde0 var(--high,100%), #304359 var(--high,100%)) center / 100% 4px no-repeat; }
.volume-clip-plane .volume-clip-range input[type="range"] { position: absolute; inset: 0; width: 100%; height: 28px; margin: 0; padding: 0; appearance: none; -webkit-appearance: none; background: transparent; pointer-events: none; }
.volume-clip-range input::-webkit-slider-runnable-track { background: transparent; border: 0; }
.volume-clip-range input::-webkit-slider-thumb { pointer-events: auto; appearance: none; -webkit-appearance: none; width: 16px; height: 20px; border: 2px solid #bce7ff; border-radius: 5px; background: #287bab; cursor: ew-resize; }
.volume-clip-range input::-moz-range-track { background: transparent; border: 0; }
.volume-clip-range input::-moz-range-thumb { pointer-events: auto; width: 12px; height: 16px; border: 2px solid #bce7ff; border-radius: 5px; background: #287bab; cursor: ew-resize; }
.volume-clip-range input:focus-visible::-webkit-slider-thumb { outline: 2px solid white; outline-offset: 2px; }

#volumeLightingPanel > label { display: block; margin-top: 8px; }
#volumeLightingPanel input[type="range"] { display: block; width: 100%; margin: 4px 0 7px; }

.volume-preset-label select { display:block; width:100%; margin-top:6px; padding:6px; }
#volumeAdvancedColors > label { display:block; margin:8px 0; }
#volumeAdvancedColors > label.hidden, #volumeAdvancedColors > label[hidden] { display:none; }
.volume-color-notice:empty { display:none; }

.clinical-details { margin: 12px 0; }
.clinical-details summary { cursor: pointer; }
.clinical-details input, .clinical-details select { width:100%; box-sizing:border-box; }
.ecg-measurements-dialog { width:min(1200px,95vw); max-height:90vh; overflow:auto; padding:20px; box-sizing:border-box; }
.ecg-measurements-dialog img { width:100%; height:auto; }
.ecg-measurements-dialog pre { white-space:pre-wrap; overflow-wrap:anywhere; font:inherit; font-size:13px; }
