/* === 1. ESTILOS BASE Y CONTENEDORES === */
    :root { --cybercef-app-visual-scale: 0.87; }
    * { box-sizing: border-box; margin: 0; padding: 0; }
    /* Utilidad crítica de visibilidad. Se mantiene con !important para que los paneles y modales ocultos no sean reactivados por reglas posteriores. */
    [hidden], .hidden { display: none !important; }
    body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; display: flex; flex-direction: column; align-items: center; padding: 20px; background: #f0f2f5; color: #333; min-height: calc(100vh / var(--cybercef-app-visual-scale)); overflow-x: hidden; transform: scale(var(--cybercef-app-visual-scale)); transform-origin: top center; width: calc(100% / var(--cybercef-app-visual-scale)); }
    /* Escalado visual global con transform estándar: evita desfases de puntero asociados a CSS zoom en Mac/Safari/Retina. */
    .container { width: 100%; max-width: 1450px; display: flex; flex-direction: column; align-items: center; gap: 20px; background: #ffffff; border-radius: 15px; padding: 25px; box-shadow: 0 8px 25px rgba(0,0,0,0.1); border: 1px solid #dee2e6; }
    .header { text-align: center; width: 100%; padding: 10px; background: #f8f9fa; border-radius: 10px; margin-bottom: 15px; border-bottom: 2px solid #007bff; position: relative; }
    #app-title { font-size: 2.3rem; color: #FF2C2C; text-shadow: none; letter-spacing: 1px; margin-bottom: 5px; }
    .subtitle { font-size: 1.0rem; color: #6c757d; font-style: italic; }
    
    /* Modificación de Layout Principal */
    .main-content { display: flex; width: 100%; gap: 30px; align-items: flex-start; }
    .left-workspace { display: flex; flex-direction: column; flex: 1; max-width: 850px; }
    .canvas-area-wrapper { display: flex; gap: 20px; width: 100%; align-items: flex-start; }
    
    /* === 2. CONTROLES Y SELECTORES === */
    .analysis-selector, .language-selector { display: flex; align-items: center; gap: 8px; position: absolute; top: 15px; }
    .analysis-selector { left: 20px; }
    .language-selector { right: 20px; }
    .analysis-selector label, .language-selector label { font-size: 0.8rem; color: #495057; }
    .analysis-selector select, .language-selector select { background: #e9ecef; border: 1px solid #ced4da; border-radius: 4px; color: #495057; padding: 5px 10px; cursor: pointer; font-size: 0.8rem; }
    .buttons { display: flex; flex-direction: row; gap: 12px; justify-content: center; margin-bottom: 15px; }
    .action-btn { width: 45px; height: 45px; border: 1px solid #ced4da; border-radius: 8px; background: linear-gradient(to bottom, #f8f9fa, #e9ecef); color: #343a40; font-weight: bold; font-size: 1rem; cursor: pointer; transition: all 0.3s; box-shadow: 0 4px 8px rgba(0,0,0,0.1); display: flex; align-items: center; justify-content: center; gap: 8px; }
    .action-btn:hover { background: linear-gradient(to bottom, #ffffff, #f1f3f5); transform: translateY(-3px); box-shadow: 0 6px 12px rgba(0,0,0,0.15); }
    .action-btn:active { transform: translateY(1px); box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
    .action-btn.active { background: linear-gradient(to bottom, #007bff, #0056b3); color: white; border-color: #0056b3; }

    .action-btn.green { background: linear-gradient(to bottom, #28a745, #218838); color: white; border-color: #1e7e34;}
    .action-btn.green:hover { background: linear-gradient(to bottom, #2db94d, #24953f); }

    .action-btn.save-image-btn { background: linear-gradient(to bottom, #5bd9ff, #40cfff); color: #073947; border-color: #23b8ea; }
    .action-btn.save-image-btn:hover { background: linear-gradient(to bottom, #7ee2ff, #40cfff); border-color: #18a9dc; }
.action-btn.orange-solid {
    background: linear-gradient(to bottom, #f59e0b, #d97706);
    color: white;
    border-color: #b45309;
}
.action-btn.orange-solid:hover {
    background: linear-gradient(to bottom, #f7b733, #ea860b);
}

.action-btn.orange-active.active {
    background: linear-gradient(to bottom, #f59e0b, #d97706);
    color: white;
    border-color: #b45309;
}
.action-btn.orange-active.active:hover {
    background: linear-gradient(to bottom, #f7b733, #ea860b);
}
    .measurements-panel-title { justify-content: flex-start; gap: 12px; flex-wrap: wrap; }
    .pdf-action-group { display: inline-flex; align-items: center; justify-content: flex-start; gap: 8px; margin-left: 0; }
    .action-btn.pdf { width: 36px; height: 36px; background: linear-gradient(to bottom, #28a745, #218838); color: white; padding: 0; margin-left: 0; border-color: #1e7e34; }
    .reset-btn { background: linear-gradient(to bottom, #dc3545, #c82333); color: white; border-color: #b21f2d;}
    .reset-btn:hover { background: linear-gradient(to bottom, #e44d5a, #d62c3c); }
    
    /* === 3. CANVAS Y HERRAMIENTAS LATERALES === */
    .canvas-section { flex: 1; max-width: 750px; position: relative; }
    .controls-section { flex: 1; max-width: 580px; display: flex; flex-direction: column; gap: 20px; position: relative; z-index: 100; }
    .canvas-wrapper { position: relative; width: 750px; height: 810px; border: 1px solid #ced4da; border-radius: 8px; overflow: auto !important; box-shadow: 0 4px 12px rgba(0,0,0,0.1); background-color: #fff; }
    canvas { width: 100%; height: 100%; cursor: crosshair; display: block !important; }
    #canvas { width: 1750px; height: 1810px; }
    #coords-display { position: absolute; top: 10px; left: 60px; background: rgba(0,0,0,0.7); color: white; padding: 8px 15px; border-radius: 5px; font-family: 'Courier New', monospace; font-size: 15px; z-index: 10; pointer-events: none; box-shadow: 0 2px 8px rgba(0,0,0,0.4); display: none; }
    .left-toolbar { display: flex; flex-direction: column; gap: 12px; background: #f8f9fa; padding: 15px 10px; border-radius: 12px; box-shadow: 0 5px 15px rgba(0,0,0,0.05); border: 1px solid #dee2e6; width: max-content; align-items: center; height: fit-content; }
    
    /* === 4. COMPONENTES DEL PANEL DERECHO (PANELES, SLIDERS, TABS) === */
    .panel { background: #f8f9fa; padding: 20px; border-radius: 12px; box-shadow: 0 5px 15px rgba(0,0,0,0.05); border: 1px solid #dee2e6; }
    .panel-title { font-size: 1.4rem; color: #0056b3; margin-bottom: 15px; padding-bottom: 8px; border-bottom: 1px solid #dee2e6; display: flex; justify-content: space-between; align-items: center; }
    .patient-data {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.patient-data.compact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-items: center;
}

.patient-data input {
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: 4px;
    color: #495057;
    padding: 8px;
    font-size: 0.9rem;
    width: 100%;
    min-width: 0;
}

.patient-data input::placeholder { color: #6c757d; }

.visually-hidden-field {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.age-auto-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.age-auto-field label {
    font-size: 0.72rem;
    line-height: 1;
    font-weight: 700;
    color: #0056b3;
}
.age-auto-field input[type="date"] {
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: 4px;
    color: #495057;
    padding: 7px 8px;
    font-size: 0.88rem;
    width: 100%;
    min-width: 0;
}
.age-calculated {
    font-size: 0.74rem;
    line-height: 1.15;
    color: #495057;
    background: rgba(0, 86, 179, 0.07);
    border: 1px solid rgba(0, 86, 179, 0.12);
    border-radius: 4px;
    padding: 3px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
body.dark-mode .age-auto-field label { color: #66b2ff; }
body.dark-mode .age-calculated {
    color: #e9ecef;
    background: rgba(102, 178, 255, 0.12);
    border-color: rgba(102, 178, 255, 0.22);
}
body.dark-mode .age-auto-field input[type="date"] {
    background: #333;
    color: #fff;
    border-color: #555;
}

@media (max-width: 768px) {
    .patient-data.compact-grid {
        grid-template-columns: 1fr;
    }
}
    .control-group { display: flex; flex-direction: column; gap: 15px; margin-bottom: 20px; }
    .control-group > label { display: grid; grid-template-columns: 180px 1fr 60px; align-items: center; column-gap: 12px; color: #495057; }
    .slider-wrapper { display: block; padding-right: 0; }
    .slider-container { position: relative; width: 100%; display: flex; align-items: center; padding: 0 4px; gap: 10px; }
    .slider-container input[type="range"] { width: 100%; height: 6px; background: #dee2e6; border-radius: 3px; outline: none; -webkit-appearance: none; appearance: none; }
    .slider-container input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 8px; height: 8px; background: #007bff; border-radius: 50%; cursor: pointer; box-shadow: 0 0 5px rgba(0,123,255,0.5); }
    .value-display { width: 60px; text-align: right; font-family: monospace; color: #0056b3; }
    .slider-control-btn { background: #007bff; border: none; width: 4px; height: 4px; border-radius: 50%; cursor: pointer; position: absolute; top: 50%; transform: translateY(-50%); box-shadow: 0 0 5px rgba(0,123,255,0.5); }
    .slider-control-btn.left { left: 0; } .slider-control-btn.right { right: 0; }
    .tabs { width: 100%; }
    .tab-buttons { 
        display: flex; 
        gap: 0px; /* Sin gap para permitir el traslape */
        margin-bottom: 2px; 
        background: #e9ecef; 
        padding: 5px; 
        border-radius: 8px; 
        flex-wrap: nowrap; /* OBLIGATORIO: Fuerza una sola línea */
        align-items: center; 
        border: 1px solid #ced4da; 
        overflow-x: auto; /* Permite scroll oculto si la pantalla es enana */
        scrollbar-width: none; 
    }
    .tab-buttons::-webkit-scrollbar { display: none; }

    .tab-button { 
        display: flex; 
        align-items: center; 
        justify-content: center; 
        gap: 6px; 
        font-weight: 600; 
        font-size: 0.6rem; /* <-- Reducido aprox un 35% (inactivas) */
        padding: 8px 12px; 
        background: transparent; 
        color: #6c757d; 
        border: 1px solid transparent; 
        border-radius: 6px; 
        cursor: pointer; 
        transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); 
        white-space: nowrap; 
        overflow: hidden; 
        flex: 1 1 40px; 
        margin-left: -8px; 
        position: relative;
    }
    
    /* <-- NUEVO: Fuerza a los íconos a escalar con el texto --> */
    .tab-button i, .tab-button svg {
        width: 1.3em !important;
        height: 1.3em !important;
        font-size: 1.3em;
        transition: all 0.3s ease;
    }

    .tab-button:first-child { margin-left: 0; } 
    
    .tab-button:hover { 
        background: #dee2e6; 
        color: #343a40; 
        z-index: 1; 
    }
    
    .tab-button.active { 
        background: #ffffff; 
        color: #007bff; 
        box-shadow: 0 2px 10px rgba(0,0,0,0.15); 
        border: 1px solid #ced4da;
        flex: 0 0 auto; 
        padding: 8px 16px;
        z-index: 2; 
        margin-left: -2px; 
        margin-right: 4px;
        font-size: 0.85rem; /* <-- Recupera su tamaño original 100% al estar activa */
    }
    
    .tab-button[data-tab="vto"].active { color: #e84393; }
    .tab-button[data-tab="superimposition"].active { color: #000080; }
    .tab-content { display: none; }
    .tab-content.active { display: block; }
    .measurement-panel { background: #f8f9fa; padding: 20px; border-radius: 12px; box-shadow: 0 5px 15px rgba(0,0,0,0.05); border: 1px solid #dee2e6; width: 100%; }
    .measurements-list { display: flex; flex-direction: column; gap: 1px; width: 100%; }
    .measurement-item { background: #ffffff; border-radius: 8px; padding: 3px; border-left: 4px solid #007bff; display: flex; justify-content: space-between; align-items: center; transition: all 0.3s; }
    .measurement-item:hover { background: #f1f3f5; transform: translateX(5px); }
    .measurement-header { display: flex; flex-direction: column; gap: 1px; }
    .measurement-title { font-size: 0.9rem; color: #495057; }
    .measurement-description { font-size: 0.75rem; color: #6c757d; font-style: italic; }
    .measurement-values { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
    .measurement-value { font-size: 1rem; font-weight: bold; color: #0056b3; font-family: 'Courier New', monospace; }
    .measurement-unit { font-size: 0.75rem; color: #6c757d; margin-left: 3px; }
    .normal-range { font-size: 0.75rem; color: #28a745; }



/* === AJUSTE QUIRÚRGICO: ESPACIADO DE FILAS EN PESTAÑA CONTROLES ===
   Reduce solo los espacios verticales entre:
   1) carga de radiografía/perfil y fila Transformar Polígono: 35px -> 21px (60%).
   2) fila Transformar Polígono y fila Exportar/Cargar: 15px -> 10px (~65%).
   No altera tamaños de botones, handlers, canvas, cálculos ni coordenadas clínicas. */
#controls .controls-upload-group {
  gap: 0;
  margin-bottom: 21px;
}
#controls .controls-upload-group .image-upload-controls {
  margin-bottom: 0;
}
#controls .controls-transform-row {
  margin-bottom: 10px;
}
    .calibration-group { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
    .calibration-group input { flex: 1; padding: 8px; border: 1px solid #ced4da; border-radius: 4px; }
    .calibrate-btn { background: linear-gradient(to bottom, #17a2b8, #138496); color: white; border: none; border-radius: 8px; padding: 8px 12px; cursor: pointer; transition: all 0.3s; display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: bold; }
    .calibrate-btn:hover { background: linear-gradient(to bottom, #19b4cc, #1595a8); }
    .calibrate-btn.active { background: linear-gradient(to bottom, #ffc107, #e0a800); color: #212529; }
/* === 6. ELEMENTOS FLOTANTES === */
    #floating-table-container { position: fixed; top: 100px; left: 20px; width: 550px; max-width: 90vw; background-color: #ffffff; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15); z-index: 1001; border: 1px solid #dee2e6; overflow: hidden; }
    .floating-table-header { padding: 10px 15px; background-color: #007bff; color: white; font-weight: bold; cursor: move; user-select: none; display:flex; align-items:center; justify-content:space-between; gap:10px; }
    .floating-table-close { width:24px; height:24px; border:0; border-radius:999px; background:rgba(255,255,255,0.18); color:#fff; font-size:18px; line-height:20px; font-weight:800; cursor:pointer; display:inline-flex; align-items:center; justify-content:center; }
    .floating-table-close:hover { background:rgba(255,255,255,0.30); }
    #floating-table-content { padding: 15px; max-height: 70vh; overflow: auto; }
    #floating-analysis-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; }
    #floating-analysis-table th, #floating-analysis-table td { border: 1px solid #e0e0e0; padding: 6px 8px; text-align: center; min-width: 50px; }
    #floating-analysis-table th { background-color: #f8f9fa; font-weight: 600; color: #343a40; }
    #floating-analysis-table td:first-child, #floating-analysis-table th:first-child { background-color: #f8f9fa; font-weight: bold; }
    #canvas-tooltip { position: fixed; background-color: rgba(0, 0, 0, 0.85); color: white; padding: 6px 12px; border-radius: 5px; font-size: 12px; pointer-events: none; z-index: 2000; transition: opacity 0.2s; }

    /* === 8. RESPONSIVE DESIGN === */
    @media (max-width: 1250px) {
      .main-content { flex-direction: column; align-items: center; }
      .left-workspace { max-width: 100%; align-items: center; }
      .canvas-area-wrapper { flex-direction: column; align-items: center; }
      .left-toolbar { flex-direction: row; width: 100%; justify-content: center; }
      .controls-section { max-width: 600px; width: 100%; }
      .slider-wrapper { justify-content: center; }
    }
    @media (max-width: 768px) {
      .container { padding: 15px; max-width: 95%; }
      h1 { font-size: 1.1rem; }
      .subtitle { font-size: 0.475rem; }
      .canvas-wrapper { width: 100%; height: auto; aspect-ratio: 750/810; }
      .panel { padding: 15px; }
      .analysis-selector, .language-selector { position: static; margin-top: 10px; justify-content: center; }
      #floating-table-container { width: 95vw; top: 10px; left: 2.5vw; }
      #floating-analysis-table { font-size: 0.65rem; }
      #floating-analysis-table th, #floating-analysis-table td { padding: 4px; min-width: 35px; }
    }
    @media (max-width: 480px) {
      .patient-data { margin-top: 10px; }
      label { flex-direction: column; align-items: flex-start; gap: 8px; }
      .buttons { flex-wrap: wrap; }
      .action-btn { flex-basis: calc(25% - 10px); }
      .measurement-item { flex-direction: column; align-items: flex-start; gap: 10px; }
      .measurement-values { align-items: flex-start; width: 100%; border-top: 1px solid #dee2e6; padding-top: 8px; }
    }

    /* === 9. MODO OSCURO (Unificado y limpio) === */
    body.dark-mode { background: #121212; color: #e0e0e0; }
    body.dark-mode .container { background: #1e1e1e; border-color: #333; box-shadow: 0 8px 25px rgba(0,0,0,0.5); }
    body.dark-mode .header { background: #2c2c2c; border-bottom: 2px solid #0056b3; }
    body.dark-mode .panel, body.dark-mode .left-toolbar { background: #2c2c2c; border-color: #444; }
    body.dark-mode .canvas-wrapper { background-color: #ffffff; border-color: #444; }
    body.dark-mode .measurement-item { background: #222; border-left-color: #0056b3; }
    body.dark-mode .measurement-item:hover { background: #333; }
    body.dark-mode .measurement-title, body.dark-mode h1 { color: #fff; }
    body.dark-mode .measurement-description, body.dark-mode .subtitle, body.dark-mode .divider-text { color: #aaa; }
    body.dark-mode input[type="text"], body.dark-mode input[type="number"], body.dark-mode select { background: #333; color: #fff; border-color: #555; }
    body.dark-mode input::placeholder { color: #888; }
    body.dark-mode .action-btn { background: linear-gradient(to bottom, #444, #333); color: #e0e0e0; border-color: #555; }
    body.dark-mode .action-btn:hover { background: linear-gradient(to bottom, #555, #444); }
    body.dark-mode .action-btn.active { background: linear-gradient(to bottom, #007bff, #0056b3); color: white; border-color: #0056b3; }

    body.dark-mode .action-btn.green, body.dark-mode .action-btn.pdf { background: linear-gradient(to bottom, #1e7e34, #155724); border-color: #155724; }
    body.dark-mode .action-btn.green:hover { background: linear-gradient(to bottom, #218838, #1e7e34); }

    body.dark-mode .action-btn.save-image-btn { background: linear-gradient(to bottom, #5bd9ff, #40cfff); color: #062f3b; border-color: #23b8ea; }
    body.dark-mode .action-btn.save-image-btn:hover { background: linear-gradient(to bottom, #7ee2ff, #40cfff); border-color: #18a9dc; }
    body.dark-mode .tab-button { background: #333; color: #ccc; border-color: #555; }
    body.dark-mode .tab-button.active { background: #007bff; color: #fff; border-color: #0056b3; }
    body.dark-mode .measurement-heading-text, body.dark-mode .value-display, body.dark-mode .panel-title { color: #66b2ff; border-bottom-color: #444; }
    body.dark-mode .divider { border-top-color: #444; }
    body.dark-mode #floating-table-container { background-color: #2c2c2c; border-color: #444; }
    body.dark-mode .floating-table-header { background-color: #004494; border-bottom: 1px solid #444; }
    body.dark-mode #floating-analysis-table th { background-color: #333; color: #fff; border-color: #555; }
    body.dark-mode #floating-analysis-table td { border-color: #555; color: #e0e0e0; }
    body.dark-mode #floating-analysis-table td:first-child, body.dark-mode #floating-analysis-table th:first-child { background-color: #333; }
body.dark-mode #analysis-label, body.dark-mode #language-label, body.dark-mode .control-group > label { color: #e0e0e0; }
    body.dark-mode #canvas-tooltip { background-color: rgba(220, 220, 220, 0.95); color: #121212; border: 1px solid #444; }
  
/* === CONTENEDOR DE MEDIDAS CON SCROLL === */
    #measurements-list {
        max-height: 77vh; /* Ocupará máximo el 55% de la altura de la ventana (ajústalo a gusto) */
        overflow-y: auto;
        padding-right: 8px; /* Espacio para que el scroll no tape el texto */
        padding-top: 5px;
    }

    /* === ENCABEZADOS FIJOS (Sticky Headers) === */
    /* Atrapa automáticamente los títulos de categorías y los textos antiguos */
    #measurements-list > div[style*="background-color"], 
    #measurements-list > .measurement-heading-text {
        position: sticky;
        top: 0;
        z-index: 10;
        box-shadow: 0 4px 6px -2px rgba(0,0,0,0.1);
    }
    
    /* Le damos fondo a los encabezados antiguos para que no sean transparentes al scrollear */
    #measurements-list > .measurement-heading-text {
        background-color: #f8f9fa; 
        padding: 8px 0;
        border-radius: 4px;
        margin-top: 0;
    }

    /* Soporte nativo para tu Modo Oscuro */
    body.dark-mode #measurements-list > .measurement-heading-text {
        background-color: #2c2c2c;
    }

    /* === DISEÑO DE LA BARRA DE SCROLL === */
    #measurements-list::-webkit-scrollbar {
        width: 8px;
    }
    #measurements-list::-webkit-scrollbar-track {
        background: transparent; 
    }
    #measurements-list::-webkit-scrollbar-thumb {
        background: #ced4da; 
        border-radius: 8px;
    }
    #measurements-list::-webkit-scrollbar-thumb:hover {
        background: #adb5bd; 
    }
body.pre-i18n {
    visibility: hidden;
}
/* UX clínica esencial. */
.clinical-ux-strip {
    display: grid;
    grid-template-columns: minmax(92px, 1fr);
    gap: 6px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    flex: 0 1 150px;
    max-width: 150px;
}
.clinical-ux-strip.clinical-ux-strip-inline { flex: 0 0 92px; max-width: 92px; min-width: 84px; }
.clinical-ux-chip {
    min-width: 0;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 4px 6px;
    background: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    min-height: 40px;
}
.clinical-ux-chip .chip-label { font-size: .50rem; color: #64748b; text-transform: uppercase; letter-spacing: .02em; font-weight: 700; }
.clinical-ux-chip strong { font-size: .68rem; color: #1e293b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clinical-ux-chip.ok { border-color: #bbf7d0; background: #f0fdf4; }
.clinical-ux-chip.warn { border-color: #fde68a; background: #fffbeb; }
.clinical-ux-chip.danger { border-color: #fecaca; background: #fff1f2; }
.action-btn:focus-visible,
.image-upload-btn:focus-visible,
.calibrate-btn:focus-visible,
.tab-button:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible { outline: 3px solid rgba(0,123,255,.35); outline-offset: 2px; }
.action-btn:disabled,
.image-upload-btn:disabled,
.calibrate-btn:disabled,
button:disabled { opacity: .52; cursor: not-allowed !important; transform: none !important; box-shadow: none !important; filter: grayscale(.15); }
.buttons { background: rgba(248,249,250,.82); border: 1px solid #e9ecef; border-radius: 12px; padding: 8px; }
.left-toolbar .divider { opacity: .8; }
.measurement-item { min-height: 42px; padding: 6px 8px; }
.measurement-title { font-weight: 650; }
.measurement-description { line-height: 1.25; }
.panel-title { gap: 10px; }
body.dark-mode .clinical-ux-strip { background: transparent; border-color: transparent; box-shadow: none; }
body.dark-mode .clinical-ux-chip { background: #2d2d2d; border-color: #444; }
body.dark-mode .clinical-ux-chip .chip-label { color: #94a3b8; }
body.dark-mode .clinical-ux-chip strong { color: #f8fafc; }
body.dark-mode .clinical-ux-chip.ok { background: #12261b; border-color: #166534; }
body.dark-mode .clinical-ux-chip.warn { background: #2d2512; border-color: #a16207; }
body.dark-mode .clinical-ux-chip.danger { background: #2d1719; border-color: #991b1b; }
body.dark-mode .buttons { background: rgba(44,44,44,.75); border-color: #444; }
@media (max-width: 768px) { .clinical-ux-strip { max-width: none; grid-template-columns: 1fr; } }
@media (max-width: 460px) { .clinical-ux-strip.clinical-ux-strip-inline { flex: 1 1 100%; max-width: none; } }
@media print { .clinical-ux-strip { box-shadow: none !important; break-inside: avoid; } }

/* Estado visual de landmarks. */
.point-status-legend {
    position: absolute;
    left: 515px;
    top: 675px;
    bottom: auto;
    z-index: 65;
    min-width: 148px;
    padding: 9px 10px;
    border-radius: 10px;
    background: rgba(255,255,255,0.88);
    border: 1px solid rgba(10, 25, 47, 0.12);
    border-left: 4px solid #ffc107;
    box-shadow: 0 6px 16px rgba(0,0,0,0.16);
    backdrop-filter: blur(4px);
    color: #1f2933;
    font-size: 11px;
    line-height: 1.25;
    pointer-events: none;
}
.point-status-title {
    font-size: 11.5px;
    font-weight: 800;
    color: #0056b3;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.point-status-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 2px 0;
    white-space: nowrap;
}
.point-dot {
    width: 9px;
    height: 9px;
    display: inline-block;
    border-radius: 999px;
    border: 1px solid rgba(0,0,0,0.25);
    box-sizing: border-box;
}
.dot-gray { background: #b8c2cc; }
.dot-red { background: #ff0000; }
.dot-yellow { background: #ffc107; }
.dot-halo {
    box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.95), 0 0 8px rgba(255, 193, 7, 0.65);
}
.point-critical-counter {
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px solid rgba(0,0,0,0.08);
    font-weight: 700;
    color: #6c5100;
}
body.dark-mode .point-status-legend {
    background: rgba(16, 24, 39, 0.88);
    color: #e5e7eb;
    border-color: rgba(255,255,255,0.10);
}
body.dark-mode .point-status-title { color: #7dd3fc; }
body.dark-mode .point-critical-counter { color: #fde68a; border-top-color: rgba(255,255,255,0.12); }

.rocabado-penning-qc {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(0,0,0,0.08);
}
.rp-qc-title {
    font-weight: 800;
    color: #4a148c;
    margin-bottom: 3px;
    white-space: nowrap;
}
.rp-qc-message {
    font-weight: 700;
    line-height: 1.28;
    max-width: 175px;
    white-space: normal;
}
.rp-qc-ok { color: #087f23; }
.rp-qc-warn { color: #856404; }
.rp-qc-danger { color: #b00020; }
body.dark-mode .rocabado-penning-qc { border-top-color: rgba(255,255,255,0.12); }
body.dark-mode .rp-qc-title { color: #c4b5fd; }
body.dark-mode .rp-qc-ok { color: #86efac; }
body.dark-mode .rp-qc-warn { color: #fde68a; }
body.dark-mode .rp-qc-danger { color: #fca5a5; }

/* Paneles flotantes colapsables y móviles. */
.floating-canvas-panel {
    position: absolute;
    user-select: none;
    pointer-events: auto;
    touch-action: none;
}
.floating-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: move;
}
.floating-panel-toggle {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 1px solid rgba(0,0,0,0.18);
    border-radius: 6px;
    background: rgba(255,255,255,0.72);
    color: #334155;
    font-size: 12px;
    font-weight: 900;
    line-height: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}
.floating-panel-toggle:hover {
    background: rgba(255,255,255,0.95);
    transform: translateY(-1px);
}
.floating-canvas-panel.is-collapsed .floating-panel-content {
    display: none;
}
.floating-canvas-panel.is-collapsed {
    min-width: 0;
}
.floating-canvas-panel.is-dragging {
    opacity: 0.92;
    box-shadow: 0 10px 24px rgba(0,0,0,0.24);
}
.point-status-legend {
    pointer-events: auto;
}
.point-status-title {
    margin-bottom: 6px;
}
.point-status-title span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.dot-yellow {
    background: #CCFF00;
}
.cad-layers-panel {
    top: 515px;
    left: 515px;
    z-index: 50;
    min-width: 160px;
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid #17a2b8;
    background: rgba(255,255,255,0.85);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    backdrop-filter: blur(4px);
    color: #333;
    font-size: 0.8rem;
}
.cad-layers-header {
    margin-bottom: 10px;
}
.cad-layers-header strong {
    color: #17a2b8;
    font-size: 0.9rem;
    font-weight: 800;
}
.cad-layers-panel label {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    cursor: pointer;
    color: #333;
}
.cad-layers-panel label:last-child {
    margin-bottom: 0;
}
.cad-layers-panel input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}
.canvas-age-calculated {
    margin-top: 7px;
    padding-top: 7px;
    border-top: 1px solid rgba(0,0,0,0.10);
    color: #0056b3;
    font-size: 0.76rem;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 185px;
}
body.dark-mode .floating-panel-toggle {
    background: rgba(31, 41, 55, 0.86);
    color: #e5e7eb;
    border-color: rgba(255,255,255,0.18);
}
body.dark-mode .cad-layers-panel {
    background: rgba(16, 24, 39, 0.88);
    color: #e5e7eb;
    border-color: rgba(255,255,255,0.10);
    border-left-color: #38bdf8;
}
body.dark-mode .cad-layers-header strong {
    color: #7dd3fc;
}
body.dark-mode .cad-layers-panel label {
    color: #e5e7eb;
}
body.dark-mode .canvas-age-calculated {
    color: #7dd3fc;
    border-top-color: rgba(255,255,255,0.14);
}


.measurement-description.has-tooltip {
    cursor: help;
    text-decoration: underline dotted rgba(108, 117, 125, 0.7);
    text-underline-offset: 2px;
}


/* Filas largas de control y auditoría. */
.measurement-item[data-measure="projUSP"] {
    align-items: flex-start;
    min-height: 62px;
}
.measurement-item[data-measure="projUSP"] .measurement-values {
    max-width: 56%;
}
.measurement-item[data-measure="projUSP"] .measurement-value-text {
    white-space: normal;
    line-height: 1.25;
    text-align: right;
}


/* ======================================================================
   CCF-9.9.0A — Layout Workstation / Pantalla completa
   Objetivo: aprovechar mejor ventanas maximizadas sin tocar lógica clínica,
   fórmulas, mediciones, normas ni seguridad.
   ====================================================================== */
:root {
    --cybercef-app-visual-scale: 1;
    --ccf-app-padding: 12px;
    --ccf-shell-gap: 14px;
    --ccf-panel-min: 390px;
    --ccf-panel-max: 560px;
    --ccf-canvas-min: 760px;
}

html {
    width: 100%;
    height: 100%;
}

body {
    width: 100% !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    padding: var(--ccf-app-padding) !important;
    overflow: hidden !important;
    align-items: stretch !important;
    transform: none !important;
    transform-origin: initial !important;
}

.container {
    width: 100% !important;
    max-width: none !important;
    height: calc(100dvh - (var(--ccf-app-padding) * 2)) !important;
    min-height: 0 !important;
    align-items: stretch !important;
    gap: var(--ccf-shell-gap) !important;
    padding: 14px !important;
    overflow: hidden !important;
}

.main-content {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
    width: 100% !important;
    display: grid !important;
    grid-template-columns: minmax(var(--ccf-canvas-min), 1fr) minmax(var(--ccf-panel-min), var(--ccf-panel-max));
    gap: 16px !important;
    align-items: stretch !important;
    overflow: hidden !important;
}

.left-workspace {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    min-height: 0 !important;
    height: 100% !important;
}

.header {
    flex: 0 0 auto !important;
    margin-bottom: 10px !important;
    padding: 8px 10px !important;
}

#app-title {
    font-size: clamp(1.45rem, 2vw, 2.15rem) !important;
    margin-bottom: 2px !important;
}

.subtitle {
    font-size: clamp(0.72rem, 0.9vw, 0.95rem) !important;
}

.analysis-selector,
.language-selector {
    top: 10px !important;
}

.canvas-area-wrapper {
    display: flex !important;
    flex: 1 1 auto !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    gap: 12px !important;
    align-items: stretch !important;
    overflow: hidden !important;
}

.left-toolbar {
    flex: 0 0 auto !important;
    position: sticky !important;
    top: 0 !important;
    max-height: 100% !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    gap: 9px !important;
    padding: 10px 8px !important;
    scrollbar-width: thin;
}

.left-toolbar .action-btn {
    flex: 0 0 auto;
}

.canvas-section {
    flex: 1 1 auto !important;
    max-width: none !important;
    min-width: 0 !important;
    height: 100% !important;
    display: flex !important;
}

.canvas-wrapper {
    width: 100% !important;
    height: 100% !important;
    min-height: 520px !important;
    max-height: 100% !important;
    overscroll-behavior: contain;
}

.controls-section {
    flex: 1 1 auto !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    min-height: 0 !important;
    height: 100% !important;
    overflow: hidden !important;
    gap: 10px !important;
}

.tabs {
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
    height: 100% !important;
    overflow: hidden !important;
}

.tab-buttons {
    flex: 0 0 auto !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    flex-wrap: nowrap !important;
    padding-bottom: 4px !important;
    scrollbar-width: thin;
}

.tab-button {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
}

.tab-content {
    min-height: 0 !important;
    overflow: hidden !important;
}

.tab-content.active {
    display: block !important;
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding-right: 6px !important;
    scrollbar-width: thin;
}

.panel,
.measurement-panel {
    margin-bottom: 10px !important;
}

#all-findings-container {
    max-height: none !important;
}

#clinical-synthesis-container {
    max-height: calc(100dvh - 300px) !important;
    overflow-y: auto !important;
}


/* Pantallas medianas/estrechas: se vuelve a permitir scroll de página y apilado seguro. */
@media (max-width: 1250px) {
    body {
        height: auto !important;
        min-height: 100dvh !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    .container {
        height: auto !important;
        min-height: calc(100dvh - (var(--ccf-app-padding) * 2)) !important;
        overflow: visible !important;
    }

    .main-content {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        overflow: visible !important;
    }

    .left-workspace,
    .controls-section,
    .tabs {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .canvas-area-wrapper {
        height: calc(100dvh - 190px) !important;
        min-height: 600px !important;
        overflow: hidden !important;
    }

    .controls-section {
        width: 100% !important;
    }

    .tab-content.active {
        max-height: 72vh !important;
        overflow-y: auto !important;
    }
}

@media (max-width: 768px) {
    body {
        padding: 8px !important;
    }

    .container {
        width: 100% !important;
        max-width: none !important;
        padding: 10px !important;
    }

    .canvas-area-wrapper {
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    .canvas-section {
        width: 100% !important;
    }

    .canvas-wrapper {
        width: 100% !important;
        height: min(70vh, 760px) !important;
        min-height: 420px !important;
        aspect-ratio: auto !important;
    }

    .left-toolbar {
        max-width: 100% !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
    }
}

@media (max-height: 780px) and (min-width: 1251px) {
    .container {
        padding: 10px !important;
        gap: 10px !important;
    }

    .header {
        padding: 6px 10px !important;
        margin-bottom: 8px !important;
    }

    .canvas-wrapper {
        min-height: 460px !important;
    }

    .left-toolbar {
        gap: 7px !important;
        padding: 8px 7px !important;
    }

    .action-btn {
        width: 40px;
        height: 40px;
    }
}


/* ======================================================================
   CCF-9.9.0A-scale087-fullviewport — Layout workstation compacto
   Mantiene el aprovechamiento de ancho de CCF-9.9.0A, pero escala la
   superficie interna de trabajo a 0.87 sin transformar el body completo.
   Esto evita que la app pierda ancho útil al maximizar la ventana.
   ====================================================================== */
:root {
    --cybercef-app-visual-scale: 1;
    --cybercef-workstation-content-scale: 0.87;
}

body {
    transform: none !important;
    width: 100% !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    overflow: hidden !important;
    align-items: stretch !important;
}

@media (min-width: 1251px) {
    .container {
        transform: scale(var(--cybercef-workstation-content-scale)) !important;
        transform-origin: top left !important;
        width: calc(100% / var(--cybercef-workstation-content-scale)) !important;
        height: calc((100dvh - (var(--ccf-app-padding) * 2)) / var(--cybercef-workstation-content-scale)) !important;
        max-width: none !important;
    }
}

@media (max-width: 1250px) {
    .container {
        transform: none !important;
        width: 100% !important;
        height: auto !important;
    }
}


/* ======================================================================
   CCF-9.9.0A-scale087-fullviewport — Ajuste alto completo
   Mantiene layout workstation compacto al 87%, pero ocupa ancho y alto
   completos de la ventana. No escala el body; escala el contenedor interno
   con dimensiones compensadas a 100vw/100dvh.
   ====================================================================== */
:root {
    --cybercef-app-visual-scale: 1;
    --cybercef-workstation-content-scale: 0.87;
    --ccf-app-padding: 0px;
}

html,
body {
    width: 100% !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}

body {
    display: block !important;
    transform: none !important;
    transform-origin: initial !important;
}

@media (min-width: 1251px) {
    .container {
        transform: scale(var(--cybercef-workstation-content-scale)) !important;
        transform-origin: top left !important;
        width: calc(100vw / var(--cybercef-workstation-content-scale)) !important;
        height: calc(100dvh / var(--cybercef-workstation-content-scale)) !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
        border-radius: 0 !important;
        overflow: hidden !important;
    }

    .main-content {
        height: auto !important;
        flex: 1 1 auto !important;
    }

    .canvas-area-wrapper,
    .controls-section,
    .tabs,
    .left-workspace {
        height: 100% !important;
        min-height: 0 !important;
    }

    .canvas-wrapper {
        height: 100% !important;
        min-height: 520px !important;
        max-height: none !important;
    }
}

@media (max-width: 1250px) {
    body {
        display: flex !important;
        padding: 8px !important;
        height: auto !important;
        min-height: 100dvh !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    .container {
        transform: none !important;
        width: 100% !important;
        height: auto !important;
        min-height: calc(100dvh - 16px) !important;
        border-radius: 12px !important;
    }
}

/* ======================================================================
   CCF-9.9.0B — Panel derecho colapsable / Canvas amplio
   Conserva el layout workstation de 9.9.0A, permite ocultar el panel
   derecho desde el rail izquierdo y maximiza el área visible del canvas.
   No modifica lógica clínica, mediciones ni normas.
   ====================================================================== */
.panel-toggle-btn {
    background: linear-gradient(to bottom, #eef6ff, #d7ebff);
    color: #0d4f8b;
    border-color: #a9d3ff;
}
.panel-toggle-btn:hover {
    background: linear-gradient(to bottom, #ffffff, #e5f2ff);
    border-color: #7dbdff;
}
.panel-toggle-btn.active,
body.ccf-right-panel-collapsed .panel-toggle-btn {
    background: linear-gradient(to bottom, #0d6efd, #084db5);
    color: #ffffff;
    border-color: #063b8d;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.18), 0 6px 14px rgba(13, 77, 181, 0.22);
}
body.dark-mode .panel-toggle-btn {
    background: linear-gradient(to bottom, #2c3e50, #1f2d3a);
    color: #dceeff;
    border-color: #41627d;
}
body.dark-mode .panel-toggle-btn.active,
body.dark-mode.ccf-right-panel-collapsed .panel-toggle-btn {
    background: linear-gradient(to bottom, #1f6feb, #0d4fb3);
    color: #ffffff;
    border-color: #0b4aa6;
}

@media (min-width: 1251px) {
    body.ccf-right-panel-collapsed .main-content {
        grid-template-columns: minmax(var(--ccf-canvas-min), 1fr) !important;
    }

    body.ccf-right-panel-collapsed .controls-section {
        display: none !important;
    }

    body.ccf-right-panel-collapsed .canvas-section,
    body.ccf-right-panel-collapsed .canvas-wrapper {
        width: 100% !important;
        max-width: none !important;
    }

    body.ccf-right-panel-collapsed .left-workspace {
        width: 100% !important;
        max-width: none !important;
    }

    body.ccf-right-panel-collapsed .canvas-area-wrapper {
        width: 100% !important;
    }
}

@media (max-width: 1250px) {
    body.ccf-right-panel-collapsed .controls-section {
        display: none !important;
    }
}

body.ccf-right-panel-collapsed::after {
    content: "Panel derecho oculto — botón azul del rail para restaurar";
    position: fixed;
    right: 16px;
    bottom: 12px;
    z-index: 5000;
    background: rgba(13, 110, 253, 0.92);
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    padding: 7px 11px;
    border-radius: 999px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.22);
    pointer-events: none;
}

@media (max-width: 768px) {
    body.ccf-right-panel-collapsed::after {
        left: 12px;
        right: 12px;
        text-align: center;
    }
}

/* ======================================================================
   CCF-9.9.0C — Limpieza de overlays flotantes del canvas
   Normaliza alertas, selector de alineación, badge QA y paneles flotantes.
   No modifica lógica clínica, mediciones ni normas.
   ====================================================================== */
:root {
    --ccf-overlay-gap: 14px;
    --ccf-overlay-radius: 12px;
    --ccf-overlay-shadow: 0 10px 26px rgba(0,0,0,0.22);
    --ccf-overlay-backdrop: rgba(255,255,255,0.94);
    --ccf-overlay-border: rgba(15, 23, 42, 0.14);
}

.canvas-wrapper {
    isolation: isolate;
}

.ccf-canvas-overlay {
    position: absolute;
    z-index: 1100;
    border-radius: var(--ccf-overlay-radius);
    box-shadow: var(--ccf-overlay-shadow);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.ccf-align-banner {
    top: var(--ccf-overlay-gap);
    left: 50%;
    transform: translateX(-50%);
    max-width: min(720px, calc(100% - 40px));
    padding: 10px 18px;
    border: 2px solid #e0a800;
    background: rgba(255, 193, 7, 0.96);
    color: #111827;
    font-weight: 800;
    text-align: center;
    line-height: 1.25;
    pointer-events: none;
}

.ccf-align-mode-picker {
    top: 58px;
    left: 50%;
    transform: translateX(-50%);
    min-width: 300px;
    max-width: min(420px, calc(100% - 40px));
    padding: 16px;
    border: 1px solid #ced4da;
    background: rgba(255,255,255,0.97);
    text-align: center;
    z-index: 1110;
}

.ccf-align-mode-title {
    font-weight: 800;
    color: #0056b3;
    margin-bottom: 12px;
}

.ccf-align-mode-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.ccf-inline-action-btn {
    width: auto !important;
    min-width: 120px;
    padding: 0 14px !important;
}

.ccf-align-mode-cancel {
    margin: 0 auto !important;
}


.ccf-reliability-badge {
    right: var(--ccf-overlay-gap);
    bottom: var(--ccf-overlay-gap);
    display: none;
    max-width: min(330px, calc(100% - 40px));
    padding: 10px 14px;
    border-left: 4px solid #28a745;
    background: rgba(255,255,255,0.95);
    color: #1f2933;
    font-size: 0.75rem;
    line-height: 1.35;
    pointer-events: none;
    z-index: 1104;
}

.floating-canvas-panel {
    max-width: min(260px, calc(100% - 28px));
    overflow: hidden;
}

.point-status-legend,
.cad-layers-panel {
    border-radius: 12px;
    box-shadow: 0 8px 22px rgba(0,0,0,0.18);
}

.point-status-legend {
    left: clamp(18px, 34%, 515px);
    top: clamp(18px, 58%, 675px);
}

.cad-layers-panel {
    left: clamp(18px, 34%, 515px);
    top: clamp(18px, 44%, 515px);
}

body.dark-mode {
    --ccf-overlay-backdrop: rgba(16, 24, 39, 0.92);
    --ccf-overlay-border: rgba(255,255,255,0.12);
}

body.dark-mode .ccf-align-mode-picker,
body.dark-mode .ccf-reliability-badge {
    background: rgba(16, 24, 39, 0.94);
    color: #e5e7eb;
    border-color: rgba(255,255,255,0.12);
}

body.dark-mode .ccf-align-mode-title {
    color: #7dd3fc;
}

body.dark-mode .ccf-align-banner {
    color: #111827;
}

@media (max-width: 768px) {
    .ccf-align-banner,
    .ccf-align-mode-picker {
        top: 10px;
        left: 10px;
        right: 10px;
        transform: none;
        max-width: none;
    }

    .ccf-align-mode-picker {
        top: 54px;
        min-width: 0;
    }


    .ccf-reliability-badge {
        bottom: 92px;
    }

    .point-status-legend,
    .cad-layers-panel {
        left: 12px;
        max-width: calc(100% - 24px);
    }
}

/* Panel de Medidas a altura completa. */
#measurements.tab-content.active {
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
    height: 100% !important;
    overflow: hidden !important;
}
#measurements > .measurement-panel {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
    max-height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    margin-bottom: 0 !important;
    box-sizing: border-box !important;
}
#measurements .measurements-panel-title { flex: 0 0 auto !important; }
#measurements #measurements-list {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
}
body.dark-mode #measurements > .measurement-panel { border-color: #444 !important; }
@media (max-width: 1250px) {
    #measurements.tab-content.active { height: auto !important; max-height: 72vh !important; overflow-y: auto !important; }
    #measurements > .measurement-panel { height: auto !important; min-height: 0 !important; max-height: none !important; overflow: visible !important; }
    #measurements #measurements-list { max-height: 68vh !important; overflow-y: auto !important; }
}

/* ======================================================================
   CCF-9.9.0C5 — Canvas sin barras visibles + Superposición full-height
   - Oculta scrollbars del viewport del canvas sin desactivar desplazamiento programático.
   - El pan del canvas se realiza por arrastre del fondo/radiografía cuando mover imagen está OFF.
   - La rueda del mouse hace zoom solo sobre el canvas; las tablas mantienen su scroll normal.
   - La tabla Intervalo T0 vs T1/T2 usa alto completo como VTO y Superposición.
   ====================================================================== */
.canvas-wrapper {
    overflow: hidden !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    touch-action: none;
}
.canvas-wrapper::-webkit-scrollbar {
    width: 0 !important;
    height: 0 !important;
    display: none !important;
}
.canvas-wrapper.ccf-viewport-panning,
.canvas-wrapper.ccf-viewport-panning #canvas {
    cursor: grabbing !important;
}
#canvas {
    user-select: none;
}
#superimposition.tab-content.active {
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
    height: 100% !important;
    overflow: hidden !important;
}
#superimposition > .panel {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
    max-height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    margin-bottom: 0 !important;
    padding-bottom: 16px !important;
    box-sizing: border-box !important;
}
#superimposition > .panel > .panel-title,
#superimposition > .panel > .control-group,
#superimposition > .panel > .patient-data,
#superimposition > .panel > .buttons {
    flex: 0 0 auto !important;
}
#superimposition #comparison-results {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    margin-bottom: 0 !important;
    box-sizing: border-box !important;
}
#superimposition #comparison-results::-webkit-scrollbar {
    width: 8px;
}
#superimposition #comparison-results::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 128, 0.38);
    border-radius: 999px;
}
body.dark-mode #superimposition > .panel {
    border-color: #444 !important;
}
@media (max-width: 1250px) {
    #superimposition.tab-content.active {
        height: auto !important;
        max-height: 72vh !important;
        overflow-y: auto !important;
    }
    #superimposition > .panel {
        height: auto !important;
        min-height: 0 !important;
        max-height: 68vh !important;
        overflow-y: auto !important;
    }
    #superimposition #comparison-results {
        max-height: 68vh !important;
    }
}


/* ======================================================================
   CCF-9.9.0C6 — Overlays anclados al viewport visible del canvas
   - Badges y guías se posicionan respecto al área visible del canvas, no
     respecto al canvas lógico completo. Así no dependen de zoom ni pan.
   ====================================================================== */
.ccf-canvas-overlay,
.floating-canvas-panel {
    will-change: left, top;
}
.ccf-align-banner {
    top: var(--ccf-overlay-gap);
    left: 50%;
    transform: translateX(-50%);
    width: auto;
}
.ccf-align-mode-picker {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(420px, calc(100% - 40px));
}
.ccf-reliability-badge {
    right: auto !important;
    bottom: auto !important;
}
.cad-layers-panel {
    left: 15px;
    top: 15px;
}
.point-status-legend {
    left: 15px;
    top: 175px;
}
@media (max-width: 768px) {
    .ccf-align-mode-picker {
        transform: translateX(-50%);
    }
}

/* ======================================================================
   Modal interno de atajos clínicos
   ====================================================================== */
.ccf-shortcuts-modal.hidden {
    display: none !important;
}
.ccf-shortcuts-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
}
.ccf-shortcuts-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(4px);
}
.ccf-shortcuts-dialog {
    position: relative;
    width: min(980px, calc(100vw - 42px));
    max-height: min(86vh, 860px);
    display: flex;
    flex-direction: column;
    background: rgba(255,255,255,0.98);
    color: #1f2937;
    border: 1px solid rgba(15, 23, 42, 0.16);
    border-radius: 18px;
    box-shadow: 0 24px 70px rgba(0,0,0,0.32);
    overflow: hidden;
}
.ccf-shortcuts-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 22px 14px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.12);
    background: linear-gradient(135deg, #f8fbff 0%, #edf7ff 100%);
}
.ccf-shortcuts-title {
    font-size: 1.14rem;
    font-weight: 800;
    color: #0b3f66;
    letter-spacing: -0.01em;
}
.ccf-shortcuts-subtitle {
    margin-top: 4px;
    font-size: 0.82rem;
    color: #667085;
}
.ccf-shortcuts-close {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(15, 23, 42, 0.16);
    border-radius: 10px;
    background: #ffffff;
    color: #334155;
    cursor: pointer;
    font-weight: 800;
}
.ccf-shortcuts-close:hover,
.ccf-shortcuts-close:focus-visible {
    background: #eef6ff;
    color: #0f4c81;
}
.ccf-shortcuts-body {
    padding: 18px 22px 22px;
    overflow-y: auto;
    min-height: 0;
}
.ccf-shortcuts-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.ccf-shortcut-card {
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
    overflow: hidden;
}
.ccf-shortcut-card h3 {
    margin: 0;
    padding: 12px 14px;
    font-size: 0.92rem;
    color: #0b3f66;
    background: #f4f9ff;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}
.ccf-shortcut-card table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}
.ccf-shortcut-card td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.07);
    vertical-align: top;
    line-height: 1.32;
}
.ccf-shortcut-card tr:last-child td {
    border-bottom: 0;
}
.ccf-shortcut-card kbd {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #0f172a;
    font-weight: 800;
    font-size: 0.72rem;
    white-space: nowrap;
    box-shadow: inset 0 -1px 0 rgba(15, 23, 42, 0.12);
}
.ccf-shortcut-note {
    margin: 0 0 14px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(14, 165, 233, 0.25);
    background: #eef9ff;
    color: #28556d;
    font-size: 0.82rem;
    line-height: 1.4;
}
.ccf-shortcut-statusline {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}
.ccf-shortcut-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 999px;
    padding: 6px 10px;
    background: #ffffff;
    color: #475569;
    font-size: 0.76rem;
    font-weight: 700;
}
.ccf-shortcut-pill.is-on {
    background: #ecfdf3;
    color: #087443;
    border-color: rgba(8, 116, 67, 0.24);
}
.ccf-shortcut-pill.is-off {
    background: #f8fafc;
}
body.dark-mode .ccf-shortcuts-dialog {
    background: rgba(17, 24, 39, 0.98);
    color: #e5e7eb;
    border-color: rgba(255,255,255,0.12);
}
body.dark-mode .ccf-shortcuts-header {
    background: linear-gradient(135deg, #111827 0%, #0f2742 100%);
    border-bottom-color: rgba(255,255,255,0.10);
}
body.dark-mode .ccf-shortcuts-title { color: #d9f1ff; }
body.dark-mode .ccf-shortcuts-subtitle { color: #9ca3af; }
body.dark-mode .ccf-shortcuts-close {
    background: #1f2937;
    color: #e5e7eb;
    border-color: rgba(255,255,255,0.16);
}
body.dark-mode .ccf-shortcut-card {
    background: #111827;
    border-color: rgba(255,255,255,0.12);
}
body.dark-mode .ccf-shortcut-card h3 {
    background: #0f2742;
    color: #d9f1ff;
    border-bottom-color: rgba(255,255,255,0.10);
}
body.dark-mode .ccf-shortcut-card td {
    border-bottom-color: rgba(255,255,255,0.08);
}
body.dark-mode .ccf-shortcut-card kbd {
    background: #0f172a;
    border-color: #334155;
    color: #f8fafc;
}
body.dark-mode .ccf-shortcut-note {
    background: rgba(14, 165, 233, 0.10);
    border-color: rgba(125, 211, 252, 0.25);
    color: #bae6fd;
}
body.dark-mode .ccf-shortcut-pill {
    background: #0f172a;
    color: #cbd5e1;
    border-color: rgba(255,255,255,0.12);
}
body.dark-mode .ccf-shortcut-pill.is-on {
    background: rgba(16, 185, 129, 0.12);
    color: #86efac;
}
@media (max-width: 760px) {
    .ccf-shortcuts-modal { padding: 14px; }
    .ccf-shortcuts-grid { grid-template-columns: 1fr; }
    .ccf-shortcuts-dialog { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); }
    .ccf-shortcuts-header { padding: 14px 16px 12px; }
    .ccf-shortcuts-body { padding: 14px 16px 18px; }
}


.measurement-status-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
    margin: 0 0 10px 0;
    min-width: 0;
}
.measurement-status-row .measurement-qa-summary {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    cursor: help;
}
.measurement-status-row .clinical-ux-strip.clinical-ux-strip-inline {
    flex: 0 0 92px;
    max-width: 92px;
    min-width: 84px;
}
@media (max-width: 620px) {
    .measurement-status-row { flex-wrap: wrap; }
    .measurement-status-row .measurement-qa-summary { flex: 1 1 100%; }
    .measurement-status-row .clinical-ux-strip.clinical-ux-strip-inline {
        flex: 0 0 100%;
        max-width: none;
    }
    .measurement-status-row .clinical-ux-chip { flex-direction: row; align-items: center; justify-content: space-between; }
}

/* ===================================================================
   CCF-9.9.4/9.9.5 — QA Core por medida + Catálogo
   =================================================================== */
.measurement-qa-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 11px;
    margin: 0 0 10px 0;
    border-radius: 10px;
    border: 1px solid rgba(15, 23, 42, 0.10);
    background: #f8fafc;
    color: #334155;
    font-size: 0.78rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
.measurement-qa-summary-main {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}
.measurement-qa-summary-main strong {
    display: block;
    font-size: 0.82rem;
    color: #0f172a;
}
.measurement-qa-summary-main span:last-child {
    display: block;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.measurement-qa-summary-badge {
    font-size: 1rem;
    line-height: 1;
}
.measurement-qa-summary-counts {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
    font-weight: 700;
    color: #475569;
}
.measurement-qa-summary-counts span {
    display: inline-flex;
    border-radius: 999px;
    background: rgba(255,255,255,0.72);
    padding: 3px 7px;
    border: 1px solid rgba(15,23,42,0.08);
}
.measurement-qa-summary-ok { background: #ecfdf3; border-color: rgba(22, 163, 74, 0.18); }
.measurement-qa-summary-warn { background: #fffbeb; border-color: rgba(217, 119, 6, 0.22); }
.measurement-qa-summary-prelim { background: #fff7ed; border-color: rgba(234, 88, 12, 0.22); }
.measurement-qa-summary-danger { background: #fef2f2; border-color: rgba(220, 38, 38, 0.22); }
.measurement-qa-summary-info { background: #eff6ff; border-color: rgba(37, 99, 235, 0.18); }

.measurement-item {
    position: relative;
}
.measurement-item.measurement-qa-ok { border-left-color: #22c55e; }
.measurement-item.measurement-qa-warn { border-left-color: #f59e0b; }
.measurement-item.measurement-qa-prelim { border-left-color: #f97316; }
.measurement-item.measurement-qa-danger { border-left-color: #ef4444; }
.measurement-item.measurement-qa-info { border-left-color: #3b82f6; }
.measurement-qa-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    width: fit-content;
    max-width: 140px;
    border-radius: 999px;
    padding: 2px 7px;
    margin-top: 4px;
    font-size: 0.66rem;
    font-weight: 800;
    line-height: 1.25;
    white-space: nowrap;
    border: 1px solid transparent;
}
.measurement-qa-badge-ok { background: #dcfce7; color: #166534; border-color: rgba(22, 101, 52, 0.14); }
.measurement-qa-badge-warn { background: #fef3c7; color: #92400e; border-color: rgba(146, 64, 14, 0.16); }
.measurement-qa-badge-prelim { background: #ffedd5; color: #9a3412; border-color: rgba(154, 52, 18, 0.16); }
.measurement-qa-badge-danger { background: #fee2e2; color: #991b1b; border-color: rgba(153, 27, 27, 0.16); }
.measurement-qa-badge-info { background: #dbeafe; color: #1e40af; border-color: rgba(30, 64, 175, 0.14); }

body.dark-mode .measurement-qa-summary {
    background: #111827;
    color: #d1d5db;
    border-color: rgba(255,255,255,0.10);
}
body.dark-mode .measurement-qa-summary-main strong { color: #f9fafb; }
body.dark-mode .measurement-qa-summary-main span:last-child { color: #cbd5e1; }
body.dark-mode .measurement-qa-summary-counts span {
    background: rgba(15, 23, 42, 0.88);
    border-color: rgba(255,255,255,0.08);
}
body.dark-mode .measurement-qa-summary-ok { background: rgba(22, 101, 52, 0.22); }
body.dark-mode .measurement-qa-summary-warn { background: rgba(146, 64, 14, 0.24); }
body.dark-mode .measurement-qa-summary-prelim { background: rgba(154, 52, 18, 0.24); }
body.dark-mode .measurement-qa-summary-danger { background: rgba(153, 27, 27, 0.24); }
body.dark-mode .measurement-qa-summary-info { background: rgba(30, 64, 175, 0.24); }

body.dark-mode .measurement-qa-badge-ok { background: rgba(22, 101, 52, 0.28); color: #bbf7d0; }
body.dark-mode .measurement-qa-badge-warn { background: rgba(146, 64, 14, 0.30); color: #fde68a; }
body.dark-mode .measurement-qa-badge-prelim { background: rgba(154, 52, 18, 0.30); color: #fed7aa; }
body.dark-mode .measurement-qa-badge-danger { background: rgba(153, 27, 27, 0.30); color: #fecaca; }
body.dark-mode .measurement-qa-badge-info { background: rgba(30, 64, 175, 0.30); color: #bfdbfe; }

@media (max-width: 760px) {
    .measurement-qa-summary { flex-direction: column; align-items: flex-start; }
    .measurement-qa-summary-counts { justify-content: flex-start; }
}


/* ======================================================================
   CCF-9.9.5A — Ajustes QA visual, Dev Help y badge QC móvil
   ====================================================================== */
.measurement-header.measurement-header-has-qa {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 6px;
    row-gap: 1px;
    align-items: start;
}
.measurement-header.measurement-header-has-qa .measurement-qa-badge {
    grid-column: 1;
    grid-row: 1;
}
.measurement-header.measurement-header-has-qa .measurement-title {
    grid-column: 2;
    grid-row: 1;
}
.measurement-header.measurement-header-has-qa .measurement-description,
.measurement-header.measurement-header-has-qa .measurement-description-long,
.measurement-header.measurement-header-has-qa .measurement-description-compact {
    grid-column: 2;
    grid-row: 2;
}
.measurement-qa-badge {
    width: 20px;
    height: 20px;
    min-width: 20px;
    padding: 0;
    justify-content: center;
    align-items: center;
    font-size: 0.86rem;
    line-height: 1;
    border-radius: 999px;
    white-space: nowrap;
    overflow: hidden;
}
.ccf-reliability-badge {
    pointer-events: auto;
    cursor: move;
    user-select: none;
    width: 300px;
    max-width: min(300px, calc(100% - 40px));
}
.ccf-reliability-badge.is-dragging {
    opacity: 0.92;
    box-shadow: 0 14px 30px rgba(0,0,0,0.22);
}
.ccf-reliability-badge::after {
    content: '↔';
    float: right;
    opacity: 0.45;
    font-size: 0.72rem;
    margin-left: 8px;
}

/* ======================================================================
   CCF-9.9.6A — Clasificación normativa
   ====================================================================== */
.normal-range {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}
.measurement-norm-type-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 0.58rem;
    line-height: 1.25;
    font-weight: 800;
    letter-spacing: 0.01em;
    border: 1px solid rgba(15, 23, 42, 0.10);
    background: #f8fafc;
    color: #334155;
    white-space: nowrap;
}
.measurement-norm-type-formal-norm { background: #ecfdf3; color: #166534; border-color: rgba(22, 101, 52, 0.14); }
.measurement-norm-type-dynamic-norm { background: #eff6ff; color: #1d4ed8; border-color: rgba(29, 78, 216, 0.14); }
.measurement-norm-type-orientative-reference { background: #fefce8; color: #854d0e; border-color: rgba(133, 77, 14, 0.16); }
.measurement-norm-type-proxy-cybercef { background: #fff7ed; color: #9a3412; border-color: rgba(154, 52, 18, 0.16); }
.measurement-norm-type-technical-control { background: #f1f5f9; color: #334155; border-color: rgba(51, 65, 85, 0.14); }
.measurement-norm-type-text-clinical { background: #f5f3ff; color: #6d28d9; border-color: rgba(109, 40, 217, 0.14); }
.measurement-norm-type-experimental { background: #fef2f2; color: #991b1b; border-color: rgba(153, 27, 27, 0.16); }
.measurement-norm-type-no-norm-verify { background: #fee2e2; color: #7f1d1d; border-color: rgba(127, 29, 29, 0.18); }
.measurement-norm-type-unclassified { background: #f3f4f6; color: #4b5563; border-color: rgba(75, 85, 99, 0.14); }

body.dark-mode .measurement-norm-type-badge {
    background: rgba(15, 23, 42, 0.78);
    color: #e5e7eb;
    border-color: rgba(255,255,255,0.10);
}
body.dark-mode .measurement-norm-type-formal-norm { background: rgba(22, 101, 52, 0.28); color: #bbf7d0; }
body.dark-mode .measurement-norm-type-dynamic-norm { background: rgba(30, 64, 175, 0.28); color: #bfdbfe; }
body.dark-mode .measurement-norm-type-orientative-reference { background: rgba(133, 77, 14, 0.28); color: #fef08a; }
body.dark-mode .measurement-norm-type-proxy-cybercef { background: rgba(154, 52, 18, 0.28); color: #fed7aa; }
body.dark-mode .measurement-norm-type-technical-control { background: rgba(51, 65, 85, 0.52); color: #cbd5e1; }
body.dark-mode .measurement-norm-type-text-clinical { background: rgba(109, 40, 217, 0.28); color: #ddd6fe; }
body.dark-mode .measurement-norm-type-experimental,
body.dark-mode .measurement-norm-type-no-norm-verify { background: rgba(153, 27, 27, 0.30); color: #fecaca; }


/* ======================================================================
   CCF-9.9.6A — Performance patch QA visual
   Mantiene el semáforo antes del nombre sin usar grid en cada medida.
   ====================================================================== */
.measurement-header.measurement-header-has-qa {
    position: relative;
    display: block;
    padding-left: 26px;
    min-height: 20px;
}
.measurement-header.measurement-header-has-qa .measurement-qa-badge {
    position: absolute;
    left: 0;
    top: 1px;
    grid-column: auto;
    grid-row: auto;
}
.measurement-header.measurement-header-has-qa .measurement-title,
.measurement-header.measurement-header-has-qa .measurement-description,
.measurement-header.measurement-header-has-qa .measurement-description-long,
.measurement-header.measurement-header-has-qa .measurement-description-compact {
    grid-column: auto;
    grid-row: auto;
}


/* CCF-9.9.11 — Observer QA / confiabilidad de trazado */



/* CCF-9.9.23 — Entrada avanzada de imágenes */
.ccf-advanced-drag-hint {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  z-index: 12000;
  min-width: 300px;
  max-width: min(440px, calc(100vw - 36px));
  padding: 20px 22px;
  border-radius: 18px;
  border: 1px solid rgba(34, 96, 150, 0.35);
  background: rgba(11, 31, 52, 0.92);
  color: #fff;
  text-align: center;
  box-shadow: 0 22px 60px rgba(0,0,0,0.28);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.16s ease, transform 0.16s ease;
  backdrop-filter: blur(8px);
}
.ccf-advanced-drag-hint.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.ccf-advanced-drag-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 10px;
  border-radius: 50%;
  border: 2px dashed rgba(255,255,255,0.46);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: #9bd5ff;
}
body.ccf-advanced-drag-active .canvas-wrapper,
body.ccf-advanced-drag-active #canvas {
  outline: 2px dashed rgba(66, 159, 216, 0.75);
  outline-offset: -8px;
}
.ccf-upload-drop-active {
  box-shadow: 0 0 0 3px rgba(66, 159, 216, 0.35) !important;
  transform: translateY(-1px);
}
.ccf-image-entry-modal {
  position: fixed;
  inset: 0;
  z-index: 13000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 18, 33, 0.56);
  opacity: 0;
  transition: opacity 0.18s ease;
  backdrop-filter: blur(3px);
}
.ccf-image-entry-modal-ready { opacity: 1; }
.ccf-image-entry-modal-closing { opacity: 0; }
.ccf-image-entry-dialog {
  width: min(560px, calc(100vw - 28px));
  background: #ffffff;
  color: #1f2937;
  border-radius: 16px;
  padding: 22px 24px 20px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.32);
  border-top: 5px solid #19496F;
  transform: translateY(8px);
  transition: transform 0.18s ease;
}
.ccf-image-entry-modal-ready .ccf-image-entry-dialog { transform: translateY(0); }
.ccf-image-entry-kicker {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #429FD8;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.ccf-image-entry-dialog h3 {
  margin: 0 0 8px;
  color: #19496F;
  font-size: 1.18rem;
}
.ccf-image-entry-dialog p {
  margin: 8px 0;
  font-size: 0.92rem;
  line-height: 1.45;
}
.ccf-image-entry-note {
  color: #586575;
}
.ccf-image-entry-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}
.ccf-image-entry-status span {
  font-size: 0.76rem;
  padding: 5px 9px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #dbe4ef;
}
.ccf-image-entry-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
}
.ccf-image-entry-actions button {
  border: 1px solid #d0dde8;
  border-radius: 10px;
  padding: 10px 12px;
  background: #f8fafc;
  color: #1f2937;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
  text-align: left;
}
.ccf-image-entry-actions button:hover {
  transform: translateY(-1px);
  border-color: #429FD8;
  background: #eef7ff;
}
.ccf-image-entry-actions button.primary {
  background: #19496F;
  color: #fff;
  border-color: #19496F;
}
.ccf-image-entry-actions button.ghost {
  text-align: center;
  background: #ffffff;
  color: #64748b;
}
.ccf-advanced-entry-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 14000;
  max-width: min(620px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(25,73,111,0.96);
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  box-shadow: 0 14px 34px rgba(0,0,0,0.22);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.ccf-advanced-entry-toast-out {
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
}


/* CCF-9.9.23 — Reubicación guiada sobre nueva radiografía */
body.ccf-guided-relocation-active #canvas {
    cursor: crosshair !important;
}
.ccf-reloc-panel {
    position: absolute;
    right: 18px;
    top: 18px;
    width: min(420px, calc(100% - 36px));
    z-index: 48;
    display: none;
    background: rgba(15, 23, 42, 0.94);
    color: #f8fafc;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.32);
    backdrop-filter: blur(8px);
    overflow: hidden;
    font-size: 12px;
}
.ccf-reloc-panel.show { display: block; }
.ccf-reloc-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px 9px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.22);
}
.ccf-reloc-head strong {
    display: block;
    font-size: 13px;
    letter-spacing: 0.02em;
}
.ccf-reloc-head span {
    display: block;
    margin-top: 3px;
    color: #cbd5e1;
    font-size: 11px;
}
.ccf-reloc-head button {
    border: 0;
    background: rgba(255,255,255,0.10);
    color: #fff;
    border-radius: 999px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 16px;
    line-height: 22px;
}
.ccf-reloc-progress {
    height: 5px;
    background: rgba(148, 163, 184, 0.24);
}
.ccf-reloc-progress > div {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #38bdf8, #22c55e);
    transition: width 0.2s ease;
}
.ccf-reloc-current {
    padding: 12px 14px;
    display: grid;
    grid-template-columns: auto auto 1fr;
    gap: 7px 9px;
    align-items: center;
}
.ccf-reloc-current span {
    font-family: monospace;
    color: #94a3b8;
    font-size: 11px;
}
.ccf-reloc-current b {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.16);
    color: #f8fafc;
    font-family: monospace;
    font-size: 12px;
}
.ccf-reloc-current strong { font-size: 13px; }
.ccf-reloc-current p,
.ccf-reloc-current em {
    grid-column: 1 / -1;
    margin: 0;
    color: #cbd5e1;
    line-height: 1.45;
    font-style: normal;
}
.ccf-reloc-current.warn em { color: #fbbf24; }
.ccf-reloc-current.large em { color: #fca5a5; }
.ccf-reloc-actions-row {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    padding: 0 14px 12px;
}
.ccf-reloc-actions-row button {
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(255,255,255,0.08);
    color: #e2e8f0;
    border-radius: 9px;
    padding: 7px 6px;
    font-size: 11px;
    cursor: pointer;
}
.ccf-reloc-actions-row button:hover { background: rgba(255,255,255,0.14); }
.ccf-reloc-actions-row button.primary {
    background: #2563eb;
    border-color: #60a5fa;
    color: #fff;
}
.ccf-reloc-foot {
    padding: 9px 14px 12px;
    border-top: 1px solid rgba(148, 163, 184, 0.18);
    color: #94a3b8;
    line-height: 1.4;
}
.ccf-image-entry-actions button[data-action^="guided"] {
    border-color: rgba(37, 99, 235, 0.45);
    color: #1d4ed8;
    background: #eff6ff;
}
.ccf-image-entry-actions button[data-action^="guided"]:hover {
    background: #dbeafe;
}
@media (max-width: 900px) {
    .ccf-reloc-panel { left: 10px; right: auto; top: 10px; width: calc(100% - 20px); }
    .ccf-reloc-actions-row { grid-template-columns: repeat(2, 1fr); }
}

/* CCF-9.9.24 — Calibración segura CAL_A/CAL_B */
.ccf-safe-calibration-chip{
  display:inline-flex;align-items:center;gap:6px;margin-left:6px;padding:5px 8px;border-radius:999px;
  border:1px solid rgba(0,123,255,.35);background:#f4f9ff;color:#07599b;font-size:11px;font-weight:700;line-height:1;cursor:pointer;
  box-shadow:0 1px 3px rgba(0,0,0,.08);user-select:none;white-space:nowrap;
}
.ccf-safe-calibration-chip[data-status="confirmed"]{background:#eafaf0;border-color:#38a169;color:#146c2e;}
.ccf-safe-calibration-chip[data-status="pending"]{background:#fff7e6;border-color:#f59f00;color:#9a5a00;}
.ccf-safe-calibration-dot{width:7px;height:7px;border-radius:50%;background:#f59f00;box-shadow:0 0 0 2px rgba(245,159,0,.18);}
.ccf-safe-calibration-chip[data-status="confirmed"] .ccf-safe-calibration-dot{background:#2f9e44;box-shadow:0 0 0 2px rgba(47,158,68,.18);}
.ccf-safe-calibration-panel{
  position:fixed;right:20px;bottom:22px;width:min(360px,calc(100vw - 32px));z-index:99999;background:#fff;border:1px solid #d0dde8;border-radius:14px;
  box-shadow:0 18px 40px rgba(20,38,60,.22);padding:12px;color:#1a2a38;font-size:12px;
}
.ccf-safe-calibration-panel-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px;color:#19496F;}
.ccf-safe-calibration-panel-head button{border:0;background:#eef4fa;border-radius:50%;width:24px;height:24px;cursor:pointer;color:#19496F;font-weight:800;}
.ccf-safe-calibration-panel-note{background:#f8fafc;border-left:3px solid #f59f00;border-radius:6px;padding:8px;margin-bottom:8px;line-height:1.35;color:#41576d;}
.ccf-safe-calibration-panel table{width:100%;border-collapse:collapse;}
.ccf-safe-calibration-panel th,.ccf-safe-calibration-panel td{padding:5px 4px;border-bottom:1px solid #edf2f7;text-align:left;vertical-align:top;}
.ccf-safe-calibration-panel th{width:42%;color:#64748b;font-weight:700;}
body.dark-mode .ccf-safe-calibration-panel{background:#15202b;color:#e6edf3;border-color:#2b4158;}
body.dark-mode .ccf-safe-calibration-panel-note{background:#0f1720;color:#cbd5e1;}
body.dark-mode .ccf-safe-calibration-panel th,body.dark-mode .ccf-safe-calibration-panel td{border-color:#26394c;}



/* CCF-9.9.25S — Auditoría de puntos al cambiar análisis */
.ccf-analysis-point-audit-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: min(420px, calc(100vw - 36px));
  background: rgba(255,255,255,0.97);
  color: #1f2937;
  border: 1px solid #d0dde8;
  border-left: 5px solid #19496F;
  border-radius: 14px;
  box-shadow: 0 16px 32px rgba(0,0,0,0.18);
  z-index: 10040;
  padding: 12px 14px;
  font-size: 0.78rem;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.ccf-analysis-point-audit-toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.ccf-analysis-point-audit-toast.warn { border-left-color: #d97706; }
.ccf-analysis-point-audit-toast.fail { border-left-color: #dc2626; }
.ccf-analysis-point-audit-toast.ok { border-left-color: #16a34a; }
.ccf-analysis-point-audit-toast h4 {
  margin: 0 0 6px 0;
  color: #19496F;
  font-size: 0.86rem;
}
.ccf-analysis-point-audit-toast p {
  margin: 0 0 8px 0;
  line-height: 1.45;
  color: #4b5563;
}
.ccf-analysis-point-audit-toast code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.7rem;
  background: #f3f4f6;
  border-radius: 4px;
  padding: 1px 4px;
}
.ccf-analysis-point-audit-toast button {
  border: 1px solid #d0dde8;
  background: #fff;
  color: #19496F;
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 0.72rem;
  cursor: pointer;
}
.ccf-analysis-point-audit-toast button:hover { border-color: #429FD8; }

/* CCF-9.9.25S — Modal de cierre Catmull-Rom mandibular/perfil */
.ccf-cat-modal {
  position: fixed;
  inset: 0;
  z-index: 9997;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity 0.16s ease;
}
.ccf-cat-modal.ready { opacity: 1; }
.ccf-cat-dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: min(82vh, 720px);
  overflow: auto;
  background: #fff;
  border: 1px solid rgba(25, 73, 111, 0.18);
  border-radius: 18px;
  box-shadow: 0 22px 70px rgba(15, 23, 42, 0.34);
  padding: 20px;
  transform: translateY(8px);
  transition: transform 0.16s ease;
}
.ccf-cat-modal.ready .ccf-cat-dialog { transform: translateY(0); }
.ccf-cat-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fdf2f8;
  border: 1px solid #fbcfe8;
  color: #9d174d;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.ccf-cat-dialog h3 {
  margin: 0 0 8px;
  color: #19496F;
  font-size: 1.05rem;
}
.ccf-cat-dialog p {
  margin: 0 0 10px;
  color: #475569;
  line-height: 1.45;
  font-size: 0.88rem;
}
.ccf-cat-summary {
  margin: 10px 0;
  padding: 10px 12px 10px 26px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  color: #334155;
  font-size: 0.8rem;
  line-height: 1.55;
}
.ccf-cat-note {
  padding: 9px 11px;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412 !important;
  font-weight: 650;
}
.ccf-cat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}
.ccf-cat-actions button {
  border: 1px solid #d0dde8;
  background: #fff;
  color: #19496F;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 800;
  cursor: pointer;
  font-size: 0.78rem;
}
.ccf-cat-actions button:hover:not(:disabled) {
  border-color: #429FD8;
  box-shadow: 0 0 0 3px rgba(66, 159, 216, 0.12);
}
.ccf-cat-actions button.primary {
  background: linear-gradient(135deg, #19496F, #256f9c);
  color: #fff;
  border-color: #19496F;
}
.ccf-cat-actions button.ghost {
  color: #64748b;
}
.ccf-cat-actions button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

/* Panel de reubicación guiada anclado al viewport. */
.ccf-viewport-anchored-panel {
  position: fixed !important;
  overflow: auto;
  box-sizing: border-box;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
}
.ccf-reloc-panel.ccf-viewport-anchored-panel { transform: none !important; }
@media (max-width: 760px) {
  .ccf-reloc-panel.ccf-viewport-anchored-panel { width: calc(100vw - 20px) !important; left: 10px !important; top: 10px !important; }
}
.ccf-reloc-panel.ccf-panel-user-moved { box-shadow: 0 18px 42px rgba(15,23,42,.28); }
.ccf-reloc-head { cursor: move; user-select: none; }
.ccf-reloc-head button { cursor: pointer; }



/* Tablet responsive support: landscape workstation and portrait stacked workflow. */
@media (pointer: coarse) {
    button,
    select,
    input,
    .action-btn,
    .tab-button,
    .image-upload-btn,
    .calibrate-btn {
        min-height: 44px;
    }

    .action-btn {
        width: 48px;
        height: 48px;
    }

    input[type="range"] {
        min-height: 34px;
    }

    input[type="range"]::-webkit-slider-thumb {
        width: 24px !important;
        height: 24px !important;
    }

    input[type="range"]::-moz-range-thumb {
        width: 24px !important;
        height: 24px !important;
    }

    #canvas {
        touch-action: none;
    }

    .floating-panel-toggle,
    .floating-table-close,
    .ccf-shortcuts-close {
        min-width: 38px;
        min-height: 38px;
    }
}

@media (min-width: 980px) and (max-width: 1250px) and (orientation: landscape) {
    html,
    body {
        width: 100% !important;
        height: 100dvh !important;
        min-height: 100dvh !important;
        overflow: hidden !important;
    }

    body {
        display: block !important;
        padding: 0 !important;
    }

    .container {
        width: 100% !important;
        height: 100dvh !important;
        min-height: 0 !important;
        padding: 8px !important;
        gap: 8px !important;
        border-radius: 0 !important;
        overflow: hidden !important;
    }

    .main-content {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) minmax(310px, 36vw) !important;
        gap: 10px !important;
        height: 100% !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    .left-workspace,
    .controls-section,
    .tabs {
        height: 100% !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: hidden !important;
    }

    .header {
        margin-bottom: 6px !important;
        padding: 6px 8px !important;
        min-height: 72px;
    }

    #app-title {
        font-size: clamp(1.25rem, 2.3vw, 1.75rem) !important;
    }

    .subtitle {
        font-size: 0.72rem !important;
    }

    .analysis-selector,
    .language-selector {
        top: 7px !important;
    }

    .analysis-selector { left: 8px !important; }
    .language-selector { right: 8px !important; }

    .analysis-selector label,
    .language-selector label {
        display: none;
    }

    .canvas-area-wrapper {
        height: calc(100% - 78px) !important;
        min-height: 0 !important;
        gap: 8px !important;
        overflow: hidden !important;
    }

    .left-toolbar {
        position: static !important;
        max-height: 100% !important;
        gap: 7px !important;
        padding: 7px 5px !important;
        overflow-y: auto !important;
    }

    .canvas-section,
    .canvas-wrapper {
        height: 100% !important;
        min-height: 0 !important;
        max-height: none !important;
    }

    .controls-section {
        width: 100% !important;
    }

    .tab-buttons {
        position: sticky;
        top: 0;
        z-index: 8;
        background: #e9ecef;
    }

    .tab-content.active {
        max-height: none !important;
        height: 100% !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .panel,
    .measurement-panel {
        padding: 12px !important;
    }

    .panel-title {
        font-size: 1.05rem !important;
        margin-bottom: 10px !important;
    }

    .control-group > label {
        grid-template-columns: minmax(120px, 1fr) minmax(110px, 1.4fr) 54px !important;
        column-gap: 8px !important;
    }
}

@media (max-width: 979px), (max-width: 1250px) and (orientation: portrait) {
    html,
    body {
        width: 100% !important;
        height: auto !important;
        min-height: 100dvh !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }

    body {
        display: block !important;
        padding: 0 !important;
    }

    .container {
        width: 100% !important;
        min-height: 100dvh !important;
        height: auto !important;
        padding: 8px !important;
        gap: 8px !important;
        border-radius: 0 !important;
        overflow: visible !important;
    }

    .main-content {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        min-height: 0 !important;
        gap: 10px !important;
        overflow: visible !important;
    }

    .header {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas:
            "title title"
            "subtitle subtitle"
            "analysis language";
        gap: 6px 10px;
        margin-bottom: 6px !important;
        padding: 8px !important;
    }

    #app-title { grid-area: title; font-size: clamp(1.35rem, 4vw, 1.9rem) !important; }
    .subtitle { grid-area: subtitle; font-size: 0.78rem !important; }
    .analysis-selector { grid-area: analysis; }
    .language-selector { grid-area: language; }

    .analysis-selector,
    .language-selector {
        position: static !important;
        width: 100%;
        justify-content: center;
    }

    .analysis-selector select,
    .language-selector select {
        min-width: 0;
        max-width: 100%;
        flex: 1 1 auto;
    }

    .canvas-area-wrapper {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        min-height: 0 !important;
        gap: 6px !important;
        overflow: visible !important;
    }

    .left-toolbar {
        position: sticky !important;
        top: 0 !important;
        z-index: 900 !important;
        display: flex !important;
        flex-direction: row !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        padding: 6px !important;
        gap: 7px !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        overscroll-behavior-inline: contain;
        -webkit-overflow-scrolling: touch;
    }

    .left-toolbar .divider {
        width: 1px;
        min-width: 1px;
        height: 32px;
        margin: 0 2px !important;
    }

    .canvas-section {
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
    }

    .canvas-wrapper {
        width: 100% !important;
        height: clamp(500px, 68dvh, 820px) !important;
        min-height: 500px !important;
        max-height: none !important;
        overflow: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .controls-section,
    .tabs {
        width: 100% !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .tab-buttons {
        position: sticky !important;
        top: 60px !important;
        z-index: 850 !important;
        width: 100%;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .tab-button {
        min-width: max-content;
        padding-inline: 14px !important;
    }

    .tab-content.active {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        padding-right: 0 !important;
    }

    .panel,
    .measurement-panel {
        padding: 14px !important;
    }

    .control-group > label {
        grid-template-columns: minmax(120px, 1fr) minmax(120px, 1.5fr) 58px !important;
    }

    #floating-table-container {
        width: calc(100vw - 20px) !important;
        max-width: none !important;
        left: 10px !important;
        top: 10px !important;
        max-height: calc(100dvh - 20px);
        overflow: auto;
    }
}

@media (max-width: 620px) {
    .header {
        grid-template-columns: 1fr;
        grid-template-areas:
            "title"
            "subtitle"
            "analysis"
            "language";
    }

    .analysis-selector label,
    .language-selector label {
        min-width: 72px;
        text-align: right;
    }

    .canvas-wrapper {
        height: 62dvh !important;
        min-height: 430px !important;
    }

    .patient-data.compact-grid {
        grid-template-columns: 1fr !important;
    }

    .control-group > label {
        grid-template-columns: 1fr !important;
        row-gap: 6px;
    }

    .value-display {
        width: auto;
        text-align: left;
    }
}


/* ======================================================================
   CyberCef Lite — auditoría de Controles y seguridad configurable
   Corrige estilos perdidos de carga y evita recortes de botones en tablets.
   ====================================================================== */
#controls .image-upload-controls {
    display: grid;
    grid-template-columns: 45px minmax(0, 1fr) minmax(0, 1fr) 45px;
    grid-template-areas: "deleteRx loadRx loadProfile deleteProfile";
    gap: 10px;
    width: 100%;
    align-items: stretch;
}
#deleteRadiograph { grid-area: deleteRx; }
#triggerImageUpload_radiograph { grid-area: loadRx; }
#triggerImageUpload_profile { grid-area: loadProfile; }
#deleteProfile { grid-area: deleteProfile; }

#controls .image-upload-btn {
    min-width: 0;
    min-height: 45px;
    padding: 8px 10px;
    border: 1px solid #9db7d0;
    border-radius: 8px;
    background: linear-gradient(to bottom, #f8fbff, #e6eef7);
    color: #17324d;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font: inherit;
    font-size: .82rem;
    font-weight: 700;
    line-height: 1.15;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 3px 7px rgba(15, 43, 68, .10);
    transition: background .2s ease, border-color .2s ease, transform .15s ease, box-shadow .2s ease;
    white-space: normal;
}
#controls .image-upload-btn:hover {
    background: linear-gradient(to bottom, #ffffff, #edf5fc);
    border-color: #5d91bf;
    box-shadow: 0 5px 10px rgba(15, 43, 68, .15);
    transform: translateY(-1px);
}
#controls .image-upload-btn.active {
    background: linear-gradient(to bottom, #1976d2, #0d5cab);
    border-color: #0d5cab;
    color: #fff;
}
#controls .image-upload-btn svg,
#controls .action-btn svg {
    flex: 0 0 auto;
    max-width: 24px;
    max-height: 24px;
}
body.dark-mode #controls .image-upload-btn {
    background: linear-gradient(to bottom, #3d4b58, #2c3741);
    border-color: #596b7a;
    color: #f2f6f9;
}
body.dark-mode #controls .image-upload-btn.active {
    background: linear-gradient(to bottom, #1976d2, #0d5cab);
    border-color: #4da3ff;
    color: #fff;
}

#controls .controls-transform-row,
#controls .controls-file-row {
    width: 100%;
    min-width: 0;
}

@media (max-width: 1250px) {
    #controls .patient-gender-row,
    #controls .stage-selector-row {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px 10px !important;
        align-items: center !important;
    }
    #controls .patient-gender-row > span,
    #controls .stage-selector-row > strong {
        grid-column: 1 / -1;
    }
    #controls .patient-gender-row label,
    #controls .stage-selector-row label {
        min-width: 0;
        line-height: 1.2;
    }
    #controls .report-type-row {
        flex-wrap: wrap;
    }
    #controls .report-type-row > strong {
        flex: 1 0 100%;
    }
    #controls .report-type-row > select {
        width: 100%;
        min-width: 0;
    }

    #controls .controls-transform-row,
    #controls .controls-file-row {
        display: grid !important;
        justify-content: stretch !important;
        align-items: stretch !important;
        gap: 8px !important;
        overflow: visible !important;
    }
    #controls .controls-transform-row {
        grid-template-columns: repeat(4, minmax(44px, 1fr));
    }
    #controls .controls-file-row {
        grid-template-columns: repeat(3, minmax(44px, 1fr));
    }
    #controls .controls-transform-row .action-btn,
    #controls .controls-file-row .action-btn {
        width: 100% !important;
        min-width: 44px !important;
        max-width: none !important;
        margin: 0 !important;
        flex-basis: auto !important;
    }
    #btnApplyCOCR,
    #btnClearCPI {
        max-width: 100%;
        white-space: normal;
        line-height: 1.15;
    }
}

@media (min-width: 980px) and (max-width: 1250px) and (orientation: landscape) {
    #controls .panel {
        overflow-x: hidden;
    }
    #controls .image-upload-controls {
        grid-template-columns: 44px minmax(0, 1fr) minmax(0, 1fr) 44px;
        gap: 7px;
    }
    #controls .image-upload-btn {
        padding-inline: 6px;
        font-size: .74rem;
    }
    #controls .controls-transform-row {
        grid-template-columns: repeat(4, minmax(42px, 1fr));
    }
    #controls .controls-file-row {
        grid-template-columns: repeat(3, minmax(42px, 1fr));
    }
}

@media (max-width: 620px) {
    #controls .image-upload-controls {
        grid-template-columns: 44px minmax(0, 1fr);
        grid-template-areas:
            "deleteRx loadRx"
            "deleteProfile loadProfile";
        gap: 8px;
    }
    #controls .controls-transform-row {
        grid-template-columns: repeat(3, minmax(44px, 1fr));
    }
    #controls .controls-file-row {
        grid-template-columns: repeat(3, minmax(44px, 1fr));
    }
    #controls .patient-gender-row,
    #controls .stage-selector-row {
        grid-template-columns: 1fr;
    }
}
