/* ════════════════════════════════════════════════════════════════
   KLINAFY® CBCT v6 — Styles (larger text, proper aspect ratio)
   ════════════════════════════════════════════════════════════════ */
.cbct-pro { font-family: 'JetBrains Mono','SF Mono','Consolas',monospace; background:#000; color:#ccc; position:relative; height:100%; display:flex; flex-direction:column; overflow:hidden; user-select:none; font-size:12px; }

/* ── INIT ── */
.cbct-init { position:absolute; inset:0; z-index:150; background:#000; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:14px; }
.cbct-init[style*="display: none"] { display:none!important; }
.cbct-init__title { font-size:22px; font-weight:600; color:#4fc3f7; letter-spacing:3px; }
.cbct-init__sub { font-size:13px; color:#667; margin:0; }
.cbct-init__steps { display:flex; flex-direction:column; gap:8px; max-width:460px; margin:10px 0; }
.cbct-init__step { display:flex; align-items:flex-start; gap:10px; font-size:13px; color:#889; line-height:1.5; }
.cbct-init__num { flex-shrink:0; width:24px; height:24px; background:#1a237e; border:1px solid #3949ab; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:11px; font-weight:700; color:#90caf9; }
.cbct-init__btn { background:linear-gradient(135deg,#1a237e,#283593); border:1px solid #3949ab; color:#90caf9; padding:10px 28px; border-radius:6px; cursor:pointer; font-family:inherit; font-size:13px; letter-spacing:1px; transition:all 0.2s; }
.cbct-init__btn:hover { background:linear-gradient(135deg,#283593,#3949ab); transform:scale(1.02); }
.cbct-init__or { font-size:11px; color:#445; }
.cbct-init__drop { border:2px dashed #2a2a4a; border-radius:8px; padding:20px 40px; text-align:center; color:#667; font-size:13px; cursor:pointer; transition:all 0.2s; }
.cbct-init__drop:hover { border-color:#3949ab; color:#90caf9; }
.cbct-init__drop small { display:block; margin-top:6px; font-size:10px; }

/* ── TOPBAR ── */
.cbct-topbar { height:38px; background:#0d0d1a; border-bottom:1px solid #1a1a3a; display:flex; align-items:center; padding:0 12px; gap:12px; flex-shrink:0; }
.cbct-topbar__logo { font-size:12px; font-weight:700; color:#4fc3f7; letter-spacing:2px; }
.cbct-topbar__patient { font-size:12px; color:#90caf9; }
.cbct-topbar__tools { display:flex; gap:2px; margin-left:auto; }
.cbct-topbar__info { font-size:11px; color:#667; }

.cbct-tool { background:none; border:1px solid transparent; color:#ccc; padding:4px 8px; border-radius:3px; cursor:pointer; font-size:15px; transition:all 0.15s; }
.cbct-tool:hover { background:#1a1a3a; border-color:#2a2a4a; }
.cbct-tool.active { background:#1a237e; border-color:#3949ab; }

/* ── HU DISPLAY ── */
.cbct-hu-display { display:flex; align-items:center; gap:8px; margin-left:8px; padding:3px 12px; background:#0a0a1a; border:1px solid #2a2a4a; border-radius:4px; }
.cbct-hu-val { font-size:14px; font-weight:700; color:#4fc3f7; font-variant-numeric:tabular-nums; }
.cbct-hu-pos { font-size:10px; color:#667; }

/* ── BODY ── */
.cbct-body { flex:1; display:flex; overflow:hidden; }

/* ── SIDE PANEL ── */
.cbct-side { width:220px; min-width:190px; background:#0d0d1a; border-right:1px solid #1a1a3a; overflow-y:auto; padding:10px; flex-shrink:0; }
.sp-section { border-bottom:1px solid #1a1a3a; padding:10px 0; }
.sp-title { font-size:12px; font-weight:600; color:#90caf9; text-transform:uppercase; letter-spacing:1px; margin-bottom:8px; }
.sp-help { font-size:11px; color:#556; line-height:1.5; margin-bottom:8px; }
.sp-help b { color:#778; }
.sp-ctrl { margin-bottom:8px; }
.sp-ctrl label { display:flex; justify-content:space-between; font-size:11px; color:#99a; margin-bottom:3px; }
.sp-ctrl input[type=range] { width:100%; height:5px; appearance:none; background:#1a1a3a; border-radius:2px; outline:none; }
.sp-ctrl input[type=range]::-webkit-slider-thumb { appearance:none; width:14px; height:14px; border-radius:50%; background:#3b82f6; cursor:pointer; }
.sp-chips { display:flex; gap:4px; margin-top:6px; }
.sp-chip { font-size:11px; padding:4px 8px; background:#1a1a2e; border:1px solid #2a2a4a; border-radius:3px; cursor:pointer; color:#aab; }
.sp-chip:hover { border-color:#3b82f6; color:#fff; }
.sp-toggle { display:flex; justify-content:space-between; align-items:center; font-size:11px; color:#99a; padding:4px 0; }
.sp-toggle input { width:16px; height:16px; accent-color:#3b82f6; }
.sp-btn { width:100%; padding:9px; border:none; border-radius:4px; font-family:inherit; font-size:12px; cursor:pointer; margin-top:8px; }
.sp-btn--pri { background:linear-gradient(135deg,#1a237e,#283593); color:#90caf9; border:1px solid #3949ab; }
.sp-btn--pri:hover:not(:disabled) { background:linear-gradient(135deg,#283593,#3949ab); }
.sp-btn:disabled { opacity:0.4; cursor:default; }
.cbct-tool-btn {
  background: #1a1a2e;
  border: 1px solid #3a3a5a;
  color: #aaa;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 10px;
  transition: border-color .15s, color .15s;
}
.cbct-tool-btn:hover { border-color: #4fc3f7; color: #4fc3f7; }
.cbct-tool-btn.active {
  border-color: #f9ca24;
  color: #f9ca24;
  background: rgba(249,202,36,.08);
}
.cbct-meas-list { font-size: 10px; color: #778; }
.cbct-meas-item {
  display: flex;
  justify-content: space-between;
  padding: 2px 4px;
  border-bottom: 1px solid #1e1e38;
  line-height: 1.4;
}
.cbct-meas-item span { color: #f9ca24; font-weight: 600; }

/* ── 2×2 GRID ── */
.cbct-grid { flex:1; display:grid; grid-template-columns:1fr 1fr; grid-template-rows:1fr 1fr; gap:2px; padding:2px; background:#000; min-width:0; }

/* ── PANELS ── */
.cbct-panel { position:relative; background:#0a0a14; overflow:hidden; display:flex; flex-direction:column; align-items:center; justify-content:center; }
.cbct-panel canvas { display:block; max-width:100%; max-height:100%; object-fit:contain; }
.cbct-panel__label { position:absolute; top:4px; left:28px; font-size:11px; font-weight:600; color:#4fc3f7; letter-spacing:1px; z-index:5; text-shadow:0 1px 3px rgba(0,0,0,0.9); }
.cbct-panel__hint { font-weight:400; color:#556; font-size:9px; margin-left:4px; }
.cbct-panel__info { position:absolute; bottom:26px; left:28px; font-size:10px; color:#99a; z-index:5; text-shadow:0 1px 3px #000; }
.cbct-panel__infoR { position:absolute; bottom:26px; right:34px; font-size:10px; color:#667; z-index:5; text-shadow:0 1px 3px #000; }

/* ── RESULTS PANEL ── */
.cbct-panel--results { background:#0a0a14; align-items:stretch; justify-content:flex-start; }
.cbct-results-scroll { flex:1; overflow-y:auto; padding:8px 12px 12px; }
.cbct-results-scroll::-webkit-scrollbar { width:4px; }
.cbct-results-scroll::-webkit-scrollbar-thumb { background:#2a2a4a; border-radius:2px; }

/* ── METRIC CARDS ── */
.mc { background:#0d0d1a; border:1px solid #1a1a3a; border-radius:4px; padding:10px 12px; margin-bottom:8px; }
.mc--ok { border-left:3px solid #66bb6a; }
.mc--warn { border-left:3px solid #ffa726; }
.mc--danger { border-left:3px solid #ef5350; }
.mc-label { font-size:11px; color:#99a; text-transform:uppercase; letter-spacing:0.5px; display:flex; justify-content:space-between; align-items:center; }
.mc-val { font-size:20px; font-weight:700; margin:3px 0; font-variant-numeric:tabular-nums; }
.mc-val small { font-size:11px; font-weight:400; color:#778; }
.mc-sub { font-size:10px; color:#667; }
.mc-ref { font-size:9px; color:#445; margin-top:3px; }
.mc-badge { font-size:9px; font-weight:700; padding:2px 6px; border-radius:2px; }
.mc-badge--ok { background:#1b5e20; color:#a5d6a7; }
.mc-badge--warn { background:#e65100; color:#ffcc80; }
.mc-badge--danger { background:#b71c1c; color:#ef9a9a; }
.mc-row { display:flex; gap:8px; }
.mc--half { flex:1; }
.mc--half .mc-val { font-size:16px; }
.clinical-text { font-size:12px; color:#bbc; line-height:1.5; margin:4px 0; }

/* ── ORIENTATION MARKERS ── */
.cbct-or { position:absolute; font-size:12px; font-weight:700; color:#ffd54f; z-index:5; text-shadow:0 1px 4px #000; }
.cbct-or--t { top:4px; left:50%; transform:translateX(-50%); }
.cbct-or--b { bottom:26px; left:50%; transform:translateX(-50%); }
.cbct-or--l { left:28px; top:50%; transform:translateY(-50%); }
.cbct-or--r { right:32px; top:50%; transform:translateY(-50%); }

/* ── CROSSHAIRS ── */
.cbct-xh { position:absolute; z-index:4; pointer-events:none; }
.cbct-xh--h { left:0; right:0; height:1px; }
.cbct-xh--v { top:0; bottom:0; width:1px; }
.cbct-xh--cyan { background:rgba(0,255,255,0.35); }
.cbct-xh--yellow { background:rgba(255,255,0,0.35); }

/* ── SAGITAL SINGLE VIEW ── */
.cbct-cross-single { display:flex; align-items:center; justify-content:center; flex:1; width:100%; gap:8px; padding:0 8px; min-height:0; }
.cbct-cross-view { flex:1; display:flex; align-items:center; justify-content:center; min-width:0; min-height:0; height:100%; position:relative; }
.cbct-cross__s { width:100%; height:100%; display:flex; align-items:center; justify-content:center; }
.cbct-cross__s canvas { max-width:100%; max-height:100%; display:block; }
.cbct-cross--hidden { display:none!important; }
.cbct-cross-nav { background:none; border:1px solid #2a2a4a; color:#4fc3f7; width:32px; height:48px; border-radius:4px; cursor:pointer; font-size:16px; flex-shrink:0; transition:all 0.15s; }
.cbct-cross-nav:hover { background:#1a1a3a; border-color:#4fc3f7; }
.cbct-cross-dots { display:flex; gap:8px; justify-content:center; padding:4px 0 2px; }
.cbct-cross-dot { width:8px; height:8px; border-radius:50%; background:#2a2a4a; cursor:pointer; transition:all 0.15s; }
.cbct-cross-dot.active { background:#4fc3f7; box-shadow:0 0 6px rgba(79,195,247,0.5); }

/* ── SLIDERS ── */
.cbct-slider { position:absolute; right:2px; top:20px; bottom:4px; width:18px; display:flex; flex-direction:column; align-items:center; z-index:6; }
.cbct-slarr { background:none; border:none; color:#4fc3f7; font-size:10px; cursor:pointer; padding:2px; opacity:0.6; }
.cbct-slarr:hover { opacity:1; }
.cbct-sltrack { flex:1; width:6px; background:#1a1a3a; border-radius:3px; position:relative; cursor:pointer; margin:2px 0; }
.cbct-slthumb { position:absolute; width:14px; height:14px; background:#3b82f6; border-radius:50%; left:50%; transform:translate(-50%,-50%); cursor:grab; box-shadow:0 0 4px rgba(59,130,246,0.5); }
.cbct-slthumb:active { cursor:grabbing; }

/* ── BOTTOM BAR ── */
.cbct-bottombar { height:26px; background:#0d0d1a; border-top:1px solid #1a1a3a; display:flex; align-items:center; padding:0 12px; gap:14px; font-size:11px; color:#667; flex-shrink:0; }

/* ── RESPONSIVE ── */
@media (max-width:900px) { .cbct-side { display:none; } }
@media (max-width:700px) {
  .cbct-grid { grid-template-columns:1fr; grid-template-rows:repeat(4,1fr); }
}

/* ════════════════════════════════════════════════════════════════
   3D PANEL — Tab toggle within sagital slot
   ════════════════════════════════════════════════════════════════ */

/* Panel variant that hosts the tab bar */
.cbct-panel--tabbed {
  justify-content: flex-start;
  align-items: stretch;
}

/* Tab bar row */
.cbct-panel-tabs {
  height: 28px;
  background: #0d0d1a;
  border-bottom: 1px solid #1a1a3a;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 6px;
  flex-shrink: 0;
  position: relative;
  z-index: 6;
}

/* Individual tab buttons */
.cbct-panel-tab {
  background: none;
  border: 1px solid transparent;
  color: #556;
  padding: 2px 10px;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.5px;
  transition: all 0.15s;
  white-space: nowrap;
}
.cbct-panel-tab:hover { color: #99a; border-color: #2a2a4a; }
.cbct-panel-tab.active { background: #0e1e2e; border-color: #4fc3f7; color: #4fc3f7; }

/* Pushes TF selector to the right */
.cbct-panel-tab-spacer { flex: 1; }

/* Group wrapper for 3D controls in tab bar */
.cbct-3d-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Volumen / Superficie toggle buttons */
.cbct-3d-mode-btn {
  background: none;
  border: 1px solid #2a2a4a;
  border-radius: 3px;
  color: #556;
  padding: 2px 8px;
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.cbct-3d-mode-btn:hover  { color: #99a; border-color: #4a4a6a; }
.cbct-3d-mode-btn.active { background: #1a1a3a; border-color: #90caf9; color: #90caf9; }

/* Transfer-function dropdown (3D only) */
.cbct-3d-tf-select {
  background: #0d0d1a;
  border: 1px solid #2a2a4a;
  border-radius: 3px;
  color: #90caf9;
  font-size: 10px;
  padding: 1px 5px;
  font-family: inherit;
  cursor: pointer;
}
.cbct-3d-tf-select:hover { border-color: #4fc3f7; }

/* Reset camera button */
.cbct-3d-reset {
  background: none;
  border: 1px solid #2a2a4a;
  border-radius: 3px;
  color: #556;
  width: 22px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  flex-shrink: 0;
  transition: all 0.15s;
}
.cbct-3d-reset:hover { border-color: #4fc3f7; color: #4fc3f7; }

/* Panel body — fills remaining height below tab bar */
.cbct-panel-body {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
  width: 100%;
}
.cbct-panel-body--hidden { display: none !important; }

/* 3D renderer container — fills entire body */
.cbct-3d-container {
  position: absolute;
  inset: 0;
}

/* Status line inside 3D panel body */
.cbct-3d-info {
  position: absolute;
  bottom: 4px;
  left: 8px;
  font-size: 9px;
  color: #445;
  z-index: 5;
  pointer-events: none;
}

/* 3D renderer internal styles (r3d-* classes from Renderer3D) */
.r3d-root {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #08090f;
}
.r3d-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}
.r3d-viewport canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.r3d-badge {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 8px;
  color: #4fc3f7;
  letter-spacing: 1px;
  opacity: 0.45;
  pointer-events: none;
}
.r3d-hint {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  color: #334;
  white-space: nowrap;
  pointer-events: none;
}
