/* ===== VARIABLES CSS ===== */
:root {
    /* Colores primarios */
    --color-primary: #0f4c81;
    --color-primary-light: #1e5a96;
    --color-primary-dark: #0a3861;

    /* Colores secundarios */
    --color-success: #0e9f6e;
    --color-success-light: #16b77e;
    --color-danger: #dc2626;
    --color-warning: #f59e0b;
    --color-info: #0ea5e9;

    /* Grises */
    --color-gray-50: #f8fafc;
    --color-gray-100: #f1f5f9;
    --color-gray-200: #e2e8f0;
    --color-gray-300: #cbd5e1;
    --color-gray-400: #94a3b8;
    --color-gray-500: #64748b;
    --color-gray-600: #475569;
    --color-gray-700: #334155;
    --color-gray-800: #1e293b;
    --color-gray-900: #0f172a;

    /* Backgrounds */
    --bg-page: #f4f7fb;
    --bg-card: #ffffff;
    --bg-hover: #eff6ff;
    --bg-active: #eef6ff;

    /* Borders */
    --border-color: #e2e8f0;
    --border-color-light: #f1f5f9;
    --border-color-dark: #cbd5e1;

    /* Espaciados */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;

    /* Bordes redondeados */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.25rem;

    /* Sombras */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 25px rgba(15, 23, 42, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

    /* Transiciones */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;

    /* Tipografía */
    --font-sans: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
}

/* ===== ESTILOS GLOBALES ===== */
html, body {
    font-family: var(--font-sans);
    background: var(--bg-page);
    color: var(--color-gray-800);
    line-height: 1.6;
}

* {
    box-sizing: border-box;
}

a, .btn-link {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover, .btn-link:hover {
    color: var(--color-primary-light);
}

h1, h2, h3, h4, h5, h6 {
    color: var(--color-gray-900);
    font-weight: var(--font-weight-semibold);
    line-height: 1.2;
    margin-bottom: var(--space-md);
}

h1 { font-size: clamp(1.75rem, 4vw, 2.25rem); }
h2 { font-size: clamp(1.5rem, 3.5vw, 1.875rem); }
h3 { font-size: clamp(1.25rem, 3vw, 1.5rem); }
h4 { font-size: clamp(1.125rem, 2.5vw, 1.25rem); }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

/* ===== BOTONES ===== */

/* ===== BOTONES ===== */
.btn {
    border-radius: var(--radius-md);
    font-weight: var(--font-weight-medium);
    transition: all var(--transition-fast);
    padding: 0.5rem 1rem;
    border-width: 1px;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    color: #fff;
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

.btn-primary:hover {
    background-color: var(--color-primary-light);
    border-color: var(--color-primary-light);
}

.btn-outline-secondary {
    border-color: var(--color-gray-400);
    color: var(--color-gray-700);
}

.btn-outline-secondary:hover {
    background-color: var(--color-gray-100);
    border-color: var(--color-gray-500);
}

.btn-success {
    background-color: var(--color-success);
    border-color: var(--color-success);
}

.btn-success:hover {
    background-color: var(--color-success-light);
    border-color: var(--color-success-light);
}

.btn:focus, 
.btn:active:focus, 
.btn-link.nav-link:focus, 
.form-control:focus, 
.form-check-input:focus, 
.form-select:focus {
    box-shadow: 0 0 0 0.2rem rgba(15, 76, 129, 0.2);
    border-color: var(--color-primary);
    outline: none;
}

/* ===== LAYOUT ===== */
.content {
    padding-top: var(--space-lg);
    padding-bottom: var(--space-xl);
}

article.content {
    max-width: 1280px;
    margin: 0 auto;
}

/* Secciones destacadas (tarjetas grandes tipo "Información para el Excel Técnico" y "Control de
   costos"): tinte suave derivado de las variables del tema en vez de las clases crudas de Bootstrap
   (bg-info-subtle/bg-success-subtle), que traen un azul/verde de fábrica sin relación con la paleta. */
.section-tint-info {
    background-color: rgba(14, 165, 233, 0.07);
    border-color: rgba(14, 165, 233, 0.3) !important;
}

.section-tint-success {
    background-color: rgba(14, 159, 110, 0.07);
    border-color: rgba(14, 159, 110, 0.3) !important;
}

.page-header {
    padding: var(--space-sm) 0 var(--space-md);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: var(--space-lg);
}

.page-header h1 {
    margin-bottom: var(--space-xs);
}

.page-header .text-muted {
    font-size: 0.95rem;
}

/* ===== CARDS Y SECCIONES ===== */
.card-soft {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    transition: box-shadow var(--transition-base);
}

.card-soft:hover {
    box-shadow: var(--shadow-xl);
}

.section-card {
    padding-top: var(--space-lg) !important;
    padding-bottom: var(--space-lg) !important;
}

.section-title {
    margin-bottom: var(--space-md);
    letter-spacing: 0.01em;
    font-weight: var(--font-weight-semibold);
}

.section-subtitle {
    margin-top: var(--space-md);
    margin-bottom: var(--space-md);
    color: var(--color-gray-800);
    font-weight: var(--font-weight-medium);
}

/* ===== TOGGLE DE SECCIONES ===== */
.section-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    border: 0;
    background: transparent;
    padding: 0;
    text-align: left;
    color: inherit;
    cursor: pointer;
    transition: opacity var(--transition-fast);
}

.section-toggle:hover {
    opacity: 0.8;
}

.section-toggle-icon {
    display: inline-block;
    width: 0.72rem;
    height: 0.72rem;
    border-right: 2px solid var(--color-gray-800);
    border-bottom: 2px solid var(--color-gray-800);
    transform: rotate(-45deg);
    transition: transform var(--transition-base) ease;
    margin-right: var(--space-xs);
    flex-shrink: 0;
}

.section-toggle.expanded .section-toggle-icon {
    transform: rotate(45deg);
}

/* ===== FORMULARIOS ===== */
.form-control,
.form-select {
    border-radius: var(--radius-md);
    border-color: var(--border-color);
    padding: 0.5rem 0.75rem;
    transition: all var(--transition-fast);
}

.form-control:hover,
.form-select:hover {
    border-color: var(--color-gray-400);
}

.form-label {
    font-weight: var(--font-weight-medium);
    color: var(--color-gray-700);
    margin-bottom: var(--space-sm);
}

.input-group .btn {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.input-group .form-control {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

/* ===== UTILIDADES ===== */
.helper-text {
    display: inline-block;
    margin-top: var(--space-sm);
    font-size: 0.875rem;
    color: var(--color-gray-600);
}

.action-toolbar {
    padding: var(--space-md);
    border: 1px dashed var(--border-color-dark);
    border-radius: var(--radius-lg);
    background: var(--color-gray-50);
}

.preview-panel {
    background: var(--color-gray-50) !important;
    border-color: var(--border-color) !important;
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
}

.status-banner {
    border-radius: var(--radius-md);
    border-color: #bfdbfe;
    background: #eff6ff;
    color: #1e3a8a;
    padding: var(--space-md);
}

/* ===== TABLAS ===== */
.table-clean-wrap {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    overflow-y: hidden;
    background: var(--bg-card);
}

.table-clean {
    margin-bottom: 0;
}

.table-clean thead th {
    color: var(--color-gray-700);
    font-weight: var(--font-weight-semibold);
    border-bottom: 1px solid var(--border-color);
    background: var(--color-gray-50);
    padding: var(--space-md);
}

.table-clean td,
.table-clean th {
    padding-top: var(--space-md);
    padding-bottom: var(--space-md);
    vertical-align: middle;
}

.table-clean tbody tr {
    transition: background-color var(--transition-fast);
}

.table-clean tbody tr:hover {
    background-color: var(--bg-hover);
}

/* Tabla de "Calculo por partida": padding mas ajustado para que quepan todas las
   columnas (incluida "Orden") sin necesidad de scroll horizontal en el ancho normal. */
.calc-items-table thead th {
    padding: 0.5rem 0.4rem;
}

.calc-items-table td,
.calc-items-table tfoot th {
    padding-left: 0.4rem;
    padding-right: 0.4rem;
}

.calc-items-table .btn-group-sm > .btn {
    padding-left: 0.4rem;
    padding-right: 0.4rem;
}

/* ===== LISTAS ===== */
.list-group-soft .list-group-item {
    border-left: 0;
    border-right: 0;
    padding-top: var(--space-md);
    padding-bottom: var(--space-md);
    transition: background-color var(--transition-fast);
}

.list-group-item {
    border-radius: var(--radius-md);
}

/* ===== BADGES ===== */
.badge {
    font-weight: var(--font-weight-medium);
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
}

/* ===== BÚSQUEDA Y SUGERENCIAS ===== */
.repair-search-input {
    border-width: 1.5px;
    font-size: 1rem;
}

.repair-suggestions {
    display: grid;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

.repair-suggestion-item {
    width: 100%;
    text-align: left;
    border: 1px solid var(--border-color);
    background: var(--color-gray-50);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    transition: all var(--transition-base);
    cursor: pointer;
}

.repair-suggestion-item:hover {
    border-color: #93c5fd;
    background: var(--bg-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.name-suggestions {
    position: absolute;
    z-index: 20;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 2px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    max-height: 220px;
    overflow-y: auto;
}

.name-suggestion-item {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    border-bottom: 1px solid var(--border-color);
    background: #fff;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
}

.name-suggestion-item:last-child {
    border-bottom: 0;
}

.name-suggestion-item:hover {
    background: var(--bg-hover);
}

/* ===== PANELS Y SIDEBARS ===== */
.side-panel {
    position: sticky;
    top: 5rem;
}

@media (max-width: 1199px) {
    .side-panel {
        position: static;
        margin-top: var(--space-lg);
    }
}

.workflow-hint {
    border-radius: var(--radius-lg);
    border-color: #bfdbfe;
    background: #eff6ff;
    color: #1e3a8a;
    margin-bottom: var(--space-md);
    padding: var(--space-md);
}

.recent-repairs-panel {
    min-height: 70vh;
}

.recent-table-wrap {
    max-height: 66vh;
    overflow-y: auto;
    overflow-x: auto;
}

/* Con 50+ reparaciones la lista ya no cabe sin hacer scroll dentro de su caja; se fija
   el encabezado para no perder de vista qué columna es cuál al bajar. */
.recent-table-wrap thead th {
    position: sticky;
    top: 0;
    z-index: 1;
}

@media (max-width: 768px) {
    .recent-table-wrap {
        max-height: 50vh;
    }
}

.recent-folio-btn {
    border: 0;
    background: #eef2ff;
    color: #3730a3;
    font-weight: var(--font-weight-bold);
    border-radius: 999px;
    padding: 0.25rem 0.75rem;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.recent-folio-btn:hover {
    background: #4338ca;
    color: #fff;
    transform: scale(1.05);
}

.recent-row-active td {
    background: var(--bg-active);
}

.stat-card {
    min-height: 128px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-top: 3px solid transparent;
}

/* Barra de acento por tarjeta (una por metrica) para que cada dato se distinga a simple vista y el
   numero grande no compita en peso visual con el resto de la pagina. */
.stat-card-primary { border-top-color: var(--color-primary); }
.stat-card-info { border-top-color: var(--color-info); }
.stat-card-success { border-top-color: var(--color-success); }
.stat-card-warning { border-top-color: var(--color-warning); }

.stat-card-primary .stat-value { color: var(--color-primary); }
.stat-card-info .stat-value { color: var(--color-info); }
.stat-card-success .stat-value { color: var(--color-success); }
.stat-card-warning .stat-value { color: var(--color-warning); }

/* Ícono de la etiqueta con el mismo acento del valor grande, para que el color de cada
   tarjeta se refuerce también arriba y no solo en el número. */
.stat-card-primary .stat-label i { color: var(--color-primary); }
.stat-card-info .stat-label i { color: var(--color-info); }
.stat-card-success .stat-label i { color: var(--color-success); }
.stat-card-warning .stat-label i { color: var(--color-warning); }

.stat-label {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 0.4rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    color: #0f172a;
}

.stat-value.small-value {
    font-size: 1.1rem;
    font-weight: 650;
}

.quick-action {
    display: block;
    text-decoration: none;
    color: inherit;
    border: 1px solid #dbe3ef;
    border-radius: 12px;
    background: #f8fafc;
    padding: 1rem;
    transition: all 0.18s ease;
    height: 100%;
}

.quick-action:hover {
    border-color: #93c5fd;
    background: #eff6ff;
    transform: translateY(-1px);
}

.quick-action-title {
    font-weight: 650;
    margin-bottom: 0.35rem;
    color: #0f172a;
}

.quick-action-text {
    color: #475569;
    font-size: 0.94rem;
    line-height: 1.45;
}

.table thead th {
    color: #334155;
    font-weight: 600;
    border-bottom: 2px solid #e2e8f0;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #16a34a;
}

.invalid {
    outline: 1px solid #dc2626;
}

.validation-message {
    color: #dc2626;
}

.blazor-error-boundary {
    background: #b42318;
    padding: 0.9rem 1.2rem;
    color: white;
    border-radius: 8px;
}

    .blazor-error-boundary::after {
        content: "Ocurrió un error inesperado."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

@media (max-width: 1024px) {
    article.content {
        max-width: 100%;
    }

    .page-header {
        padding-top: 0.25rem;
        padding-bottom: 0.75rem;
    }

    .section-card {
        padding-top: 1.1rem !important;
        padding-bottom: 1.1rem !important;
    }

    .side-panel {
        position: static;
        top: auto;
    }

    .recent-repairs-panel {
        min-height: auto;
    }

    /* Antes esto quitaba el límite de alto (max-height: none) cuando el panel de
       "Reparaciones recientes" pasa a apilarse debajo del formulario (<=1024px). Como
       esa regla queda después de la de <=768px en el CSS, también le ganaba a esa en
       móvil, y la lista completa (50+ filas) se renderizaba sin límite ni scroll propio,
       alargando muchísimo la página. Se deja con el mismo límite que móvil para que
       siempre se pueda hacer scroll dentro de su propia caja. */
    .recent-table-wrap {
        max-height: 50vh;
    }

    .stat-value {
        font-size: 1.55rem;
    }

    .table-clean th,
    .table-clean td {
        font-size: 0.9rem;
    }
}

.upload-workspace {
    border: 1px solid #dbe3ef;
    border-radius: 12px;
    background: #f8fafc;
    padding: 1rem;
}

.upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.selected-files-panel {
    border: 1px dashed #c7d2fe;
    border-radius: 10px;
    background: #eef2ff;
    padding: 0.75rem;
}

.selected-files-title {
    font-size: 0.84rem;
    font-weight: 650;
    color: #1e3a8a;
    margin-bottom: 0.45rem;
}

.selected-files-list {
    margin: 0;
    padding-left: 1rem;
    max-height: 180px;
    overflow-y: auto;
}

.selected-files-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.88rem;
    color: #334155;
    padding: 0.2rem 0;
}

.file-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    color: #475569;
    font-variant-numeric: tabular-nums;
    font-size: 0.8rem;
}

.files-visualization-header {
    margin-bottom: 0.35rem;
}

.attachment-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.6rem;
}

.attachment-item {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    padding: 0.75rem 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.attachment-main {
    min-width: 0;
}

.attachment-name {
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.attachment-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    font-size: 0.78rem;
    color: #475569;
}

.empty-files-state {
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    padding: 1rem;
    background: #f8fafc;
}

/* ═══════════════════════════════════════════════
   MÓDULO DE ARCHIVOS POR TIPO
═══════════════════════════════════════════════ */

/* Fila de botones pill por tipo */
.file-type-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.file-type-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.38rem 1rem;
    border-radius: 999px;
    border: 2px solid transparent;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
    letter-spacing: 0.01em;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.file-type-btn[data-type="DiagnosticPhoto"] {
    background: #f0f9ff;
    border-color: #7dd3fc;
    color: #0369a1;
}
.file-type-btn[data-type="DiagnosticPhoto"]:hover,
.file-type-btn[data-type="DiagnosticPhoto"].active {
    background: #0284c7;
    border-color: #0284c7;
    color: #fff;
    box-shadow: 0 3px 10px rgba(2,132,199,0.35);
}

/* Colores por tipo de botón */
.file-type-btn[data-type="InputPhoto"] {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}
.file-type-btn[data-type="InputPhoto"]:hover,
.file-type-btn[data-type="InputPhoto"].active {
    background: #1d4ed8;
    border-color: #1d4ed8;
    color: #fff;
    box-shadow: 0 3px 10px rgba(29,78,216,0.35);
}

.file-type-btn[data-type="Quotation"] {
    background: #fefce8;
    border-color: #fcd34d;
    color: #92400e;
}
.file-type-btn[data-type="Quotation"]:hover,
.file-type-btn[data-type="Quotation"].active {
    background: #d97706;
    border-color: #d97706;
    color: #fff;
    box-shadow: 0 3px 10px rgba(217,119,6,0.35);
}

.file-type-btn[data-type="Blueprint"] {
    background: #f0fdf4;
    border-color: #6ee7b7;
    color: #065f46;
}
.file-type-btn[data-type="Blueprint"]:hover,
.file-type-btn[data-type="Blueprint"].active {
    background: #059669;
    border-color: #059669;
    color: #fff;
    box-shadow: 0 3px 10px rgba(5,150,105,0.35);
}

.file-type-btn[data-type="ProcessEvidence"] {
    background: #fff7ed;
    border-color: #fdba74;
    color: #9a3412;
}
.file-type-btn[data-type="ProcessEvidence"]:hover,
.file-type-btn[data-type="ProcessEvidence"].active {
    background: #ea580c;
    border-color: #ea580c;
    color: #fff;
    box-shadow: 0 3px 10px rgba(234,88,12,0.35);
}

.file-type-btn[data-type="FinalEvidence"] {
    background: #fdf4ff;
    border-color: #d8b4fe;
    color: #6b21a8;
}
.file-type-btn[data-type="FinalEvidence"]:hover,
.file-type-btn[data-type="FinalEvidence"].active {
    background: #7c3aed;
    border-color: #7c3aed;
    color: #fff;
    box-shadow: 0 3px 10px rgba(124,58,237,0.35);
}

.file-type-btn[data-type="ServiceInvoice"] {
    background: #fff1f2;
    border-color: #fda4af;
    color: #9f1239;
}
.file-type-btn[data-type="ServiceInvoice"]:hover,
.file-type-btn[data-type="ServiceInvoice"].active {
    background: #e11d48;
    border-color: #e11d48;
    color: #fff;
    box-shadow: 0 3px 10px rgba(225,29,72,0.35);
}

.file-type-btn[data-type="ReportPdf"] {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #334155;
}
.file-type-btn[data-type="ReportPdf"]:hover,
.file-type-btn[data-type="ReportPdf"].active {
    background: #0f172a;
    border-color: #0f172a;
    color: #fff;
    box-shadow: 0 3px 10px rgba(15,23,42,0.3);
}

/* Fallback para tipos sin data-type */
.file-type-btn:not([data-type]):not(.active) {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #334155;
}
.file-type-btn:not([data-type]).active {
    background: #4f46e5;
    border-color: #4f46e5;
    color: #fff;
}

.file-type-btn-badge {
    background: rgba(0,0,0,0.12);
    border-radius: 999px;
    padding: 0 0.45rem;
    font-size: 0.7rem;
    font-weight: 800;
    min-width: 18px;
    text-align: center;
    line-height: 1.5;
}

.file-type-btn.active .file-type-btn-badge {
    background: rgba(255,255,255,0.25);
}

/* Panel expandible */
.file-panel-expanded {
    border: 2px solid #e0e7ff;
    border-radius: 16px;
    background: linear-gradient(135deg, #fafbff 0%, #f0f4ff 100%);
    padding: 1.25rem;
    animation: panelFadeIn 0.18s ease;
}

@keyframes panelFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.file-panel-header {
    font-weight: 700;
    font-size: 1rem;
    color: #1e1b4b;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.file-panel-title {
    font-size: 1rem;
}

/* Zona de subida */
.file-upload-inline {
    background: #fff;
    border: 2px dashed #a5b4fc;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    transition: border-color 0.15s;
}

.file-upload-inline:hover {
    border-color: #6366f1;
}

.file-upload-title {
    font-weight: 700;
    font-size: 0.85rem;
    color: #4f46e5;
    margin-bottom: 0.1rem;
}

/* Galería */
.file-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
}

.file-gallery-item {
    width: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 0.65rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    transition: box-shadow 0.15s, transform 0.15s;
}

.file-gallery-item:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
    transform: translateY(-2px);
}

.file-thumb-link {
    display: block;
    width: 180px;
    height: 160px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #f1f5f9;
    transition: box-shadow 0.15s;
}

.file-thumb-link:hover {
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.file-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 180px;
    height: 160px;
    border-radius: 8px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    text-decoration: none;
    transition: box-shadow 0.15s;
}

.file-icon-wrap:hover {
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}

.file-icon {
    font-size: 4rem;
    line-height: 1;
}

.file-pdf-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 180px;
}

.file-pdf-embed {
    width: 180px;
    height: 240px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #f1f5f9;
}

.file-pdf-open {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    margin-top: 0.3rem;
}

.file-gallery-name {
    font-size: 0.75rem;
    color: #475569;
    margin-top: 0.4rem;
    width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-xs {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
}

/* Estilos heredados (compatibility) */
.file-type-panel {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    padding: 0.85rem 1rem;
}

.file-type-header { min-height: 36px; }
.file-type-label { font-weight: 650; font-size: 0.95rem; color: #0f172a; }

/* Presupuesto con cantidad > 1: mismo amarillo usado en la hoja de control de costos impresa para
   marcar que el TOTAL ya viene multiplicado por la cantidad de piezas repetidas. */
.budget-quantity-highlight {
    background-color: #fff59d;
    border-color: #f2c94c !important;
}

/* Cálculo por partidas y presupuestos: antes, la caja EDITABLE ("Configuración del
   presupuesto activo") y la caja de RESULTADOS (presupuesto ya calculado, solo lectura)
   compartían exactamente el mismo estilo (border rounded bg-light-subtle), por lo que a
   simple vista no se distinguía cuál se podía editar y cuál era un cálculo de solo
   consulta. Ahora cada una tiene un acento de color distinto (azul = editar, verde =
   resultado) que además reutiliza la paleta del tema en vez de un gris genérico. */
.calc-config-panel {
    background-color: rgba(15, 76, 129, 0.05);
    border: 1px solid rgba(15, 76, 129, 0.18);
    border-left: 3px solid var(--color-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-md) var(--space-lg);
}

/* Fila de "agregar pieza": antes flotaba sin caja entre dos secciones que sí la tenían;
   se le da un contenedor punteado (mismo lenguaje visual que .action-toolbar) para que
   se lea como un paso intermedio y no como un elemento suelto. */
.calc-add-item-panel {
    background: var(--color-gray-50);
    border: 1px dashed var(--border-color-dark);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
}

.budget-result-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--color-success);
    border-radius: var(--radius-lg);
    padding: var(--space-md) var(--space-lg);
}

/* Resumen COSTO/FACTOR/TOTAL/CANTIDAD/TOTAL FINAL: antes eran dos cajas blancas apiladas
   (una con 3-4 líneas de texto, otra solo con cantidad y total) dentro de la caja de
   resultados; se unifican en una sola cuadrícula compacta tipo "mini stat cards" para
   que se lea de un vistazo en vez de tener que leer renglón por renglón. */
.budget-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: var(--space-md);
    padding-top: var(--space-sm);
    margin-top: var(--space-sm);
    border-top: 1px solid var(--border-color-light);
}

.budget-summary-grid .summary-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-gray-500);
    font-weight: var(--font-weight-semibold);
    margin-bottom: 0.15rem;
}

.budget-summary-grid .summary-value {
    font-weight: var(--font-weight-semibold);
    color: var(--color-gray-900);
}

.budget-summary-grid .summary-final .summary-value {
    font-size: 1.2rem;
    color: var(--color-success);
}

.budget-summary-grid.budget-quantity-highlight {
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    margin-top: var(--space-sm);
    border-top: none;
}

.budget-summary-grid .budget-note {
    grid-column: 1 / -1;
    font-size: 0.85rem;
    color: var(--color-gray-700);
    border-top: 1px dashed var(--border-color);
    padding-top: var(--space-sm);
}

/* Cálculo por partidas: acciones de "crear" separadas de las de "navegar" con su propio recuadro,
   para que no se vean como un solo bloque de botones apretados. */
.calc-toolbar-groups {
    display: flex;
    align-items: stretch;
    gap: var(--space-md);
}

.calc-toolbar-group {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
}

.calc-toolbar-group-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-gray-500);
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-xs);
}

.calc-toolbar-divider {
    width: 1px;
    background: var(--border-color);
    flex-shrink: 0;
}

@media (max-width: 1024px) {
    .calc-toolbar-groups {
        flex-direction: column;
    }

    .calc-toolbar-group .btn,
    .calc-toolbar-group .badge,
    .calc-toolbar-group .form-label {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    .calc-toolbar-select {
        width: 100%;
        max-width: 100%;
    }

    .authorization-actions {
        display: grid !important;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .authorization-actions .btn {
        width: 100%;
    }

    .table-clean-wrap {
        border-radius: 10px;
    }
}

@media (max-width: 768px) {
    .content {
        padding-top: 0.75rem;
    }

    .page-header {
        padding-top: 0.15rem;
        padding-bottom: 0.65rem;
        margin-bottom: 1rem !important;
    }

    h1 {
        font-size: 1.45rem;
    }

    .section-title {
        font-size: 1.05rem;
    }

    .section-subtitle {
        font-size: 0.95rem;
    }

    .stat-card {
        min-height: 100px;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    .stat-value.small-value {
        font-size: 1rem;
    }

    .quick-action {
        padding: 0.9rem;
    }

    .quick-action-text {
        font-size: 0.88rem;
    }

    .action-toolbar {
        display: grid !important;
        grid-template-columns: 1fr;
        gap: 0.5rem !important;
        padding: 0.65rem;
    }

    .action-toolbar .btn,
    .action-toolbar a.btn {
        width: 100%;
    }

    .table-clean th,
    .table-clean td {
        font-size: 0.86rem;
        padding-top: 0.55rem;
        padding-bottom: 0.55rem;
    }

    .table-clean thead th {
        white-space: nowrap;
    }

    .upload-workspace {
        padding: 0.75rem;
    }

    .upload-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .attachment-item {
        flex-direction: column;
        align-items: stretch;
    }

    .attachment-item .btn {
        width: 100%;
    }

    .attachment-name {
        white-space: normal;
    }

    .file-type-buttons {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.45rem;
    }

    .file-type-btn {
        width: 100%;
        justify-content: center;
        white-space: normal;
        text-align: center;
        padding: 0.5rem 0.85rem;
    }

    .file-panel-expanded {
        padding: 0.85rem;
    }

    .file-upload-inline .d-flex {
        display: grid !important;
        grid-template-columns: 1fr;
        gap: 0.5rem !important;
    }

    .file-upload-inline .form-control,
    .file-upload-inline .btn {
        width: 100% !important;
        max-width: 100% !important;
    }

    .file-gallery {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }

    .file-gallery-item,
    .file-thumb-link,
    .file-icon-wrap,
    .file-pdf-preview,
    .file-pdf-embed,
    .file-gallery-name {
        width: 100%;
        max-width: 100%;
    }

    .file-thumb-link,
    .file-icon-wrap {
        height: 170px;
    }

    .authorization-panel {
        padding: 0.85rem !important;
    }
}

/* ===== RESPONSIVE ENHANCEMENTS ===== */

/* Touch-friendly en móvil */
@media (hover: none) and (pointer: coarse) {
    .btn, .repair-suggestion-item, .quick-action, .recent-folio-btn {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Tablets y pantallas medianas */
@media (max-width: 991px) {
    .stat-value {
        font-size: 1.75rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }
}

/* Móviles pequeños */
@media (max-width: 480px) {
    .page-header h1 {
        font-size: 1.5rem;
    }

    .section-card {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    .section-toggle {
        gap: var(--space-sm);
    }

    .section-title {
        font-size: 1rem;
    }

    .calc-toolbar-group .btn,
    .authorization-actions .btn,
    .action-toolbar .btn {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
    }

    .table-clean th,
    .table-clean td {
        font-size: 0.8rem;
        padding: var(--space-sm);
    }

    .file-panel-expanded,
    .file-upload-inline,
    .upload-workspace {
        padding: var(--space-md);
    }

    .badge {
        white-space: normal;
        line-height: 1.3;
        font-size: 0.75rem;
    }

    .stat-card {
        min-height: 100px;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .btn {
        padding: 0.6rem 1rem;
    }
}

/* Landscape móvil */
@media (max-height: 600px) and (orientation: landscape) {
    .recent-table-wrap {
        max-height: 40vh;
    }

    .side-panel {
        position: static;
    }
}

/* Utilidades responsive */
.text-truncate-mobile {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (min-width: 768px) {
    .text-truncate-mobile {
        overflow: visible;
        text-overflow: clip;
        white-space: normal;
    }
}

.repair-suggestion-item {
    display: block;
    width: 100%;
    text-align: left;
    border: 1px solid var(--border-color);
    background: #fff;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
    margin-bottom: 0.55rem;
}

.repair-suggestion-item:hover {
    border-color: var(--color-primary-light);
    background: var(--bg-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.repair-suggestion-item-body {
    display: block;
    width: 100%;
    border: 0;
    background: transparent;
    padding: 0;
    text-align: left;
    color: inherit;
}

/* ===== MODAL DE SELECCION DE FOTOS (Excel Tecnico) ===== */
.modal-backdrop-custom {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    padding: var(--space-lg);
}

.modal-panel-custom {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: min(900px, 100%);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-color);
}

.modal-panel-body {
    padding: var(--space-lg);
    overflow-y: auto;
}

.modal-panel-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-color);
}

.photo-select-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: var(--space-sm);
}

.photo-select-item {
    position: relative;
    display: block;
    aspect-ratio: 1;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.photo-select-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.photo-select-item input[type="checkbox"] {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 20px;
    height: 20px;
    z-index: 2;
    cursor: pointer;
}

.photo-select-item.selected {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(15, 76, 129, 0.3);
}

@media (max-width: 640px) {
    .modal-panel-body {
        padding: var(--space-md);
    }

    .photo-select-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    }
}
