/* ==========================================================================
   Guía de alivio del estreñimiento y Escala de Bristol - Fijate Tools
   Estilos corporativos conforme a las directrices canónicas de /tools/
   ========================================================================== */

:root {
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-heading: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Colores del sistema tema claro */
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-subtle: #f1f5f9;
    --bg-card-hover: #e2e8f0;
    --border-color: #e2e8f0;
    --border-subtle: #cbd5e1;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;

    /* Acentos médicos y fisiológicos */
    --accent-teal: #0d9488;
    --accent-teal-dark: #0f766e;
    --accent-teal-subtle: #ccfbf1;
    --accent-blue: #0284c7;
    --accent-amber: #d97706;
    --accent-rose: #e11d48;
    --accent-emerald: #10b981;

    /* Semáforos clínicos */
    --color-danger: #dc2626;
    --color-danger-bg: #fef2f2;
    --color-warning: #d97706;
    --color-warning-bg: #fffbeb;
    --color-success: #16a34a;
    --color-success-bg: #f0fdf4;
    --color-info: #0284c7;
    --color-info-bg: #f0f9ff;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.03);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Tema oscuro */
html[data-theme="dark"] {
    --bg-page: #0b0f17;
    --bg-card: #131b26;
    --bg-card-subtle: #1a2433;
    --bg-card-hover: #223044;
    --border-color: #243245;
    --border-subtle: #33435c;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    --accent-teal: #14b8a6;
    --accent-teal-dark: #0d9488;
    --accent-teal-subtle: #042f2e;
    --accent-blue: #38bdf8;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --accent-emerald: #34d399;

    --color-danger: #f87171;
    --color-danger-bg: #450a0a;
    --color-warning: #fbbf24;
    --color-warning-bg: #451a03;
    --color-success: #4ade80;
    --color-success-bg: #052e16;
    --color-info: #38bdf8;
    --color-info-bg: #082f49;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* Reset y estructura básica */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-main);
    color: var(--text-primary);
    background-color: var(--bg-page);
    line-height: 1.6;
    overflow-x: clip;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    margin-top: 0;
    font-weight: 700;
    line-height: 1.25;
}

/* Tipografía de cifras y fórmulas */
.text-mono {
    font-family: var(--font-mono);
}

/* Layout canónico /tools/ */
.main-wrapper.tool-layout {
    max-width: 1200px;
    margin: 1.5rem auto 3rem;
    padding: 0 1rem;
    box-sizing: border-box;
    flex: 1 0 auto;
    width: 100%;
}

.tool-with-sidebar {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    width: 100%;
}

.tool-main-content {
    flex: 1 1 0%;
    min-width: 0;
    width: 100%;
}

/* Barra de navegación de pestañas internas */
.tool-nav-tabs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.25rem 0.25rem 0.75rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    scrollbar-width: thin;
}

.nav-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.15rem;
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
    min-height: 42px;
}

.nav-tab-btn:hover {
    color: var(--accent-teal);
    border-color: var(--accent-teal);
    background: var(--bg-card-subtle);
}

.nav-tab-btn.active {
    color: #ffffff;
    background: var(--accent-teal);
    border-color: var(--accent-teal);
    box-shadow: 0 4px 10px rgba(13, 148, 136, 0.25);
}

.tab-pane {
    display: none;
    animation: fadeIn 0.25s ease-in-out;
}

.tab-pane.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Tarjeta contenedora de bloque */
.tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

.card-header-clean {
    margin-bottom: 1.25rem;
}

.card-title {
    font-size: 1.4rem;
    margin-bottom: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.card-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin: 0;
}

/* Aviso médico de emergencia / Red flags */
.red-flag-banner {
    background: var(--color-danger-bg);
    border: 1px solid var(--color-danger);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.red-flag-icon {
    flex-shrink: 0;
    color: var(--color-danger);
    margin-top: 0.2rem;
}

.red-flag-content h3 {
    font-size: 1.05rem;
    color: var(--color-danger);
    margin-bottom: 0.25rem;
}

.red-flag-content p {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin: 0;
}

/* ==========================================================================
   Sección 1: Escala de Bristol interactiva
   ========================================================================== */
.bristol-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.bristol-card {
    background: var(--bg-card-subtle);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    display: flex;
    flex-direction: column;
}

.bristol-card:hover {
    border-color: var(--accent-teal);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.bristol-card.selected {
    border-color: var(--accent-teal);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.2);
}

.bristol-card-badge {
    display: inline-block;
    align-self: flex-start;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    text-transform: none;
}

.bristol-svg-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.5rem;
    margin-bottom: 0.75rem;
    height: 80px;
    border: 1px solid var(--border-color);
}

.bristol-svg {
    max-width: 100%;
    max-height: 100%;
}

.bristol-card-title {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.bristol-card-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    flex-grow: 1;
}

.bristol-meta-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-muted);
    border-top: 1px dashed var(--border-color);
    padding-top: 0.5rem;
}

/* Panel de detalle clínico de Bristol */
.bristol-detail-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 5px solid var(--accent-teal);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-top: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.detail-header-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.detail-badge-status {
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 700;
}

.detail-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
    background: var(--bg-card-subtle);
    padding: 0.85rem;
    border-radius: var(--radius-md);
}

.metric-item {
    font-size: 0.85rem;
}

.metric-label {
    color: var(--text-muted);
    display: block;
    margin-bottom: 0.15rem;
}

.metric-val {
    font-weight: 600;
    color: var(--text-primary);
}

.recom-list {
    margin: 0.5rem 0 0;
    padding-left: 1.25rem;
    font-size: 0.92rem;
    color: var(--text-secondary);
}

.recom-list li {
    margin-bottom: 0.5rem;
}

/* ==========================================================================
   Sección 2: Evaluador clínico de Criterios de Roma IV
   ========================================================================== */
.roma-intro-box {
    background: var(--color-info-bg);
    border: 1px solid var(--color-info);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.92rem;
}

.roma-questions-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.roma-item-card {
    background: var(--bg-card-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transition: var(--transition);
}

.roma-item-card:hover {
    border-color: var(--accent-teal);
    background: var(--bg-card);
}

.roma-item-text {
    font-size: 0.95rem;
    color: var(--text-primary);
    flex: 1;
}

.roma-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.roma-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.roma-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-round {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--border-subtle);
    transition: .3s;
    border-radius: 34px;
}

.slider-round:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

.roma-switch input:checked + .slider-round {
    background-color: var(--accent-teal);
}

.roma-switch input:checked + .slider-round:before {
    transform: translateX(22px);
}

/* Caja de banderas rojas seleccionables */
.red-flags-card {
    background: var(--bg-card);
    border: 2px solid var(--color-danger);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-top: 1.5rem;
}

.red-flags-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.red-flag-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--color-danger-bg);
    border: 1px solid rgba(220, 38, 38, 0.2);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.red-flag-checkbox-label:hover {
    border-color: var(--color-danger);
}

.red-flag-checkbox-label input[type="checkbox"] {
    margin-top: 0.25rem;
    width: 18px;
    height: 18px;
    accent-color: var(--color-danger);
    flex-shrink: 0;
}

.red-flag-label-text h4 {
    font-size: 0.92rem;
    margin-bottom: 0.15rem;
    color: var(--color-danger);
}

.red-flag-label-text p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Resultado del evaluador Roma IV */
.roma-result-box {
    margin-top: 1.5rem;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-card-subtle);
}

/* ==========================================================================
   Sección 3: Calculadora y semáforo de fibra dietética
   ========================================================================== */
.fiber-summary-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--bg-card-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
}

.kpi-card-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.kpi-card-val {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-teal);
    line-height: 1.1;
    margin-bottom: 0.25rem;
}

.kpi-card-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Barra de progreso de fibra */
.fiber-progress-container {
    background: var(--bg-card-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.progress-header-flex {
    display: flex;
    justify-content: space-between;
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.fiber-bar-track {
    height: 16px;
    background: var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
}

.fiber-bar-soluble {
    background: var(--accent-teal);
    height: 100%;
    transition: width 0.3s ease;
}

.fiber-bar-insoluble {
    background: var(--accent-amber);
    height: 100%;
    transition: width 0.3s ease;
}

.fiber-legend {
    display: flex;
    gap: 1.5rem;
    font-size: 0.82rem;
    margin-top: 0.5rem;
    color: var(--text-secondary);
}

.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.35rem;
}

/* Filtros y catálogo de alimentos */
.food-filters-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.food-filter-btn {
    padding: 0.4rem 0.85rem;
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.food-filter-btn.active, .food-filter-btn:hover {
    background: var(--accent-teal-subtle);
    color: var(--accent-teal-dark);
    border-color: var(--accent-teal);
}

.food-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.food-item-card {
    background: var(--bg-card-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: var(--transition);
}

.food-item-card:hover {
    border-color: var(--accent-teal);
}

.food-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.35rem;
}

.food-name {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.food-portion {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.food-fiber-pills {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.65rem;
    font-size: 0.75rem;
}

.pill-soluble {
    background: var(--accent-teal-subtle);
    color: var(--accent-teal-dark);
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.pill-insoluble {
    background: #fef3c7;
    color: #92400e;
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.food-btn-add {
    width: 100%;
    min-height: 38px;
    background: var(--bg-card);
    border: 1px solid var(--accent-teal);
    color: var(--accent-teal);
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.food-btn-add:hover {
    background: var(--accent-teal);
    color: #ffffff;
}

/* ==========================================================================
   Sección 4: Biomecánica postural y reflejos
   ========================================================================== */
.biomechanics-comparison {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.posture-card {
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    border: 1.5px solid var(--border-color);
    background: var(--bg-card-subtle);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.posture-card.posture-bad {
    border-color: var(--color-danger);
    background: var(--color-danger-bg);
}

.posture-card.posture-good {
    border-color: var(--color-success);
    background: var(--color-success-bg);
}

html[data-theme="dark"] .posture-card.posture-bad {
    background: rgba(127, 29, 29, 0.28);
    border-color: rgba(248, 113, 113, 0.55);
}

html[data-theme="dark"] .posture-card.posture-good {
    background: rgba(20, 83, 45, 0.28);
    border-color: rgba(74, 222, 128, 0.55);
}

.posture-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
}

.posture-badge {
    display: inline-block;
    padding: 0.3rem 0.65rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 700;
}

.posture-badge-bad {
    background: #fee2e2;
    color: #991b1b;
}

.posture-badge-good {
    background: #dcfce7;
    color: #166534;
}

html[data-theme="dark"] .posture-badge-bad {
    background: rgba(248, 113, 113, 0.18);
    color: #fecaca;
    border: 1px solid rgba(248, 113, 113, 0.35);
}

html[data-theme="dark"] .posture-badge-good {
    background: rgba(74, 222, 128, 0.18);
    color: #bbf7d0;
    border: 1px solid rgba(74, 222, 128, 0.35);
}

.posture-angle-chip {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.22rem 0.55rem;
    border-radius: 999px;
}

.posture-angle-bad {
    background: rgba(220, 38, 38, 0.12);
    color: var(--color-danger);
}

.posture-angle-good {
    background: rgba(22, 163, 74, 0.12);
    color: var(--color-success);
}

.posture-visual-frame {
    margin: 0 0 1rem;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #080d14;
    border: 1px solid rgba(148, 163, 184, 0.22);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
    position: relative;
}

.posture-bad .posture-visual-frame {
    border-color: rgba(239, 68, 68, 0.4);
}

.posture-good .posture-visual-frame {
    border-color: rgba(16, 185, 129, 0.4);
}

.posture-visual-img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 960 / 536;
    object-fit: cover;
    transition: transform 0.35s ease;
}

.posture-card:hover .posture-visual-img {
    transform: scale(1.02);
}

.posture-visual-caption {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.85rem;
    background: rgba(11, 15, 23, 0.92);
    border-top: 1px solid rgba(148, 163, 184, 0.15);
    color: #e2e8f0;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.35;
}

.posture-caption-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.posture-caption-dot.dot-danger {
    background: #ef4444;
    box-shadow: 0 0 8px #ef4444;
}

.posture-caption-dot.dot-success {
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
}

.posture-card-heading {
    font-size: 1.05rem;
    margin: 0 0 0.4rem;
}

.posture-card-heading.heading-bad {
    color: var(--color-danger);
}

.posture-card-heading.heading-good {
    color: var(--color-success);
}

.posture-card-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.55;
}

/* ==========================================================================
   Sección 5: Fármacos astringentes
   ========================================================================== */
.drugs-table-wrap {
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

.drugs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    text-align: left;
}

.drugs-table th {
    background: var(--bg-card-subtle);
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    color: var(--text-primary);
}

.drugs-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

/* ==========================================================================
   Sección 6: Generador de informe clínico imprimible
   ========================================================================== */
.report-actions-bar {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.btn-primary-action {
    background: var(--accent-teal);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-md);
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.btn-primary-action:hover {
    background: var(--accent-teal-dark);
}

.btn-secondary-action {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.btn-secondary-action:hover {
    background: var(--bg-card-subtle);
    border-color: var(--accent-teal);
}

.report-preview-sheet {
    background: #ffffff;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-md);
    padding: 2rem;
    box-shadow: var(--shadow-md);
}

html[data-theme="dark"] .report-preview-sheet {
    background: #ffffff;
    color: #0f172a;
}

.report-header-sheet {
    border-bottom: 2px solid #0f172a;
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

/* ==========================================================================
   Modales corporativos (reemplazo estricto de window.alert)
   ========================================================================== */
.app-modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.2s ease-out;
}

.app-modal-backdrop.active {
    display: flex;
}

.app-modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    position: relative;
    animation: modalScale 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScale {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.app-modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-modal-title {
    font-size: 1.15rem;
    margin: 0;
}

.app-modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-modal-close-btn:hover {
    color: var(--text-primary);
    background: var(--bg-card-subtle);
}

.app-modal-body {
    padding: 1.5rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.app-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* ==========================================================================
   Acordeón SEO de preguntas frecuentes (FAQ)
   ========================================================================== */
.seo-faq-section {
    margin-top: 2.5rem;
    border-top: 1px solid var(--border-color);
    padding-top: 2rem;
}

.faq-accordion {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.faq-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.faq-question {
    width: 100%;
    text-align: left;
    padding: 1rem 1.25rem;
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    min-height: 44px;
}

.faq-question svg {
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.faq-item.open .faq-question svg {
    transform: rotate(180deg);
}

.faq-answer {
    padding: 0 1.25rem 1.25rem;
    font-size: 0.92rem;
    color: var(--text-secondary);
    display: none;
    line-height: 1.6;
}

.faq-item.open .faq-answer {
    display: block;
}

/* ==========================================================================
   Estilos de impresión médica (@media print)
   ========================================================================== */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }

    .app-header,
    .tools-ad-banner-section,
    .tool-ad-sidebar,
    .tool-nav-tabs,
    .report-actions-bar,
    .fijate-footer,
    .app-affiliate-section,
    .seo-faq-section {
        display: none !important;
    }

    .main-wrapper.tool-layout {
        margin: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
    }

    .report-preview-sheet {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
    }
}

/* ==========================================================================
   Responsive: Móviles y tablets
   ========================================================================== */
@media (max-width: 768px) {
    .main-wrapper.tool-layout {
        padding: 0 0.75rem;
        margin: 1rem auto 2rem;
    }

    .tool-card {
        padding: 1rem;
    }

    .card-title {
        font-size: 1.2rem;
    }

    .bristol-grid {
        grid-template-columns: 1fr;
    }

    .fiber-summary-dashboard {
        grid-template-columns: 1fr;
    }

    .roma-item-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .roma-toggle-wrap {
        align-self: flex-end;
    }

    .report-header-sheet {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}
