:root {
    --fondo: #f4f7fb;
    --superficie: #ffffff;
    --superficie-suave: #f8fafc;
    --borde: #dbe4ef;
    --texto: #172033;
    --secundario: #64748b;
    --azul: #2563eb;
    --azul-suave: #e8f0ff;
    --verde: #059669;
    --verde-suave: #dcfce7;
    --naranja: #d97706;
    --naranja-suave: #fff3d6;
    --rojo: #dc2626;
    --rojo-suave: #fee2e2;
    --violeta: #7c3aed;
    --sombra: 0 12px 34px rgba(45, 65, 95, .08);
}

* { box-sizing: border-box; }
html, body { max-width: 100%; }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--texto);
    background:
        radial-gradient(circle at 8% 0%, rgba(37, 99, 235, .08), transparent 28rem),
        radial-gradient(circle at 96% 12%, rgba(5, 150, 105, .06), transparent 24rem),
        var(--fondo);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.barra-superior {
    background: rgba(255, 255, 255, .88);
    border-bottom: 1px solid var(--borde);
    backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 20;
}
.marca { display: inline-flex; align-items: center; gap: .7rem; color: var(--texto); font-weight: 800; text-decoration: none; }
.marca-icono { width: 2.55rem; height: 2.55rem; display: grid; place-items: center; color: white; background: linear-gradient(135deg, #2563eb, #10b981); border-radius: .85rem; box-shadow: 0 8px 18px rgba(37, 99, 235, .2); }
.volver { color: var(--azul); text-decoration: none; font-size: .9rem; }

.hero { padding: 3.8rem 0 2rem; }
.hero h1 { max-width: 850px; margin: 0 0 1.25rem; font-size: clamp(2.35rem, 5vw, 4.8rem); line-height: .98; letter-spacing: -.05em; font-weight: 850; }
.hero p { max-width: 780px; margin: 0; color: var(--secundario); font-size: 1.08rem; line-height: 1.65; }
.etiqueta { color: var(--azul); font-size: .74rem; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }
.btn-actualizar { width: 100%; max-width: 230px; padding: .8rem 1.2rem; color: white; background: linear-gradient(135deg, #2563eb, #1d4ed8); border: 0; border-radius: .8rem; font-weight: 750; box-shadow: 0 10px 24px rgba(37, 99, 235, .2); }
.btn-actualizar:hover, .btn-actualizar:focus { color: white; background: linear-gradient(135deg, #1d4ed8, #1e40af); }
.btn-actualizar:disabled {
    color: #fff;
    background: linear-gradient(135deg, #4f7fe9, #4169d8);
    opacity: .82;
}

.panel-progreso, .panel-controles, .tabla-contenedor, .panel-diagnostico, .metrica {
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: 1rem;
    box-shadow: var(--sombra);
}
.panel-progreso { padding: 1.25rem; }
.texto-secundario { color: var(--secundario); }
.detalle-progreso { min-height: 1.25rem; color: var(--azul); font-size: .82rem; margin-top: .25rem; }
.estado-icono { flex: 0 0 auto; width: 2.7rem; height: 2.7rem; display: grid; place-items: center; border-radius: .8rem; color: var(--verde); background: var(--verde-suave); font-size: 1.25rem; }
.estado-icono.activo { color: var(--azul); background: var(--azul-suave); }
.estado-icono.aviso { color: var(--naranja); background: var(--naranja-suave); }
.estado-icono.error { color: var(--rojo); background: var(--rojo-suave); }
.progress { height: .55rem; background: #e9eff7; border-radius: 999px; }
.progress-bar { background: linear-gradient(90deg, #2563eb, #10b981); transition: width .35s ease; }
.form-check-input:checked { background-color: var(--azul); border-color: var(--azul); }
.fuentes-progreso { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .55rem; }
.fuente-estado { display: flex; align-items: center; gap: .55rem; min-width: 0; padding: .6rem .7rem; color: var(--secundario); background: var(--superficie-suave); border: 1px solid var(--borde); border-radius: .7rem; font-size: .78rem; }
.fuente-estado span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fuente-estado i { flex: 0 0 auto; }
.fuente-estado.activa { color: var(--azul); border-color: #a9c5ff; background: var(--azul-suave); }
.fuente-estado.correcta { color: var(--verde); border-color: #a7e5ca; background: #f0fdf8; }
.fuente-estado.aviso { color: var(--naranja); border-color: #f2d39a; background: #fffbeb; }

.metrica { min-height: 100%; padding: 1rem 1.1rem; }
.metrica-icono { width: 2.15rem; height: 2.15rem; display: grid; place-items: center; margin-bottom: .65rem; border-radius: .65rem; }
.metrica-icono.azul { color: var(--azul); background: var(--azul-suave); }
.metrica-icono.verde { color: var(--verde); background: var(--verde-suave); }
.metrica-icono.violeta { color: var(--violeta); background: #f0e8ff; }
.metrica-icono.naranja { color: var(--naranja); background: var(--naranja-suave); }
.metrica strong { display: block; font-size: 1.6rem; letter-spacing: -.03em; }
.metrica small { color: var(--secundario); }

.panel-controles { padding: 1rem; box-shadow: none; }
.form-control, .form-select, .input-group-text { border-color: var(--borde); }
.form-control, .form-select { color: var(--texto); background: var(--superficie); }
.form-control:focus, .form-select:focus { border-color: #7da5f8; box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .12); }
.input-group-text { color: var(--secundario); background: var(--superficie-suave); }
.contador { color: var(--secundario); font-size: .88rem; }

.tabla-contenedor { width: 100%; max-width: 100%; overflow: hidden; contain: inline-size; min-height: 220px; }
.table-responsive { width: 100%; max-width: 100%; max-height: 68vh; overflow: auto; }
#tablaCoches { min-width: 980px; margin: 0; --bs-table-bg: transparent; --bs-table-border-color: #e7edf5; --bs-table-color: var(--texto); }
#tablaCoches thead { position: sticky; top: 0; z-index: 3; background: #f8fafc; }
#tablaCoches th { padding: .9rem .75rem; white-space: nowrap; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; }
#tablaCoches td { padding: .85rem .75rem; }
#tablaCoches tbody tr:hover { background: #f8fbff; }
.ordenar { all: unset; display: inline-flex; align-items: center; gap: .3rem; cursor: pointer; color: #52627a; }
.ordenar:hover, .ordenar[aria-sort] { color: var(--azul); }
.modelo { min-width: 250px; max-width: 400px; font-weight: 750; line-height: 1.28; }
.fuente-tabla { color: var(--secundario); font-size: .78rem; }
.puntuacion { display: inline-grid; place-items: center; min-width: 3rem; padding: .36rem .55rem; border-radius: 999px; font-weight: 850; }
.puntuacion.alta { color: #047857; background: #dff7ec; }
.puntuacion.media { color: #a16207; background: #fff3d6; }
.puntuacion.baja { color: #b91c1c; background: #fee8e8; }
.abrir { width: 2.3rem; height: 2.3rem; display: inline-grid; place-items: center; color: var(--azul); border: 1px solid #c9d7ec; border-radius: .65rem; text-decoration: none; }
.abrir:hover { color: #1d4ed8; background: var(--azul-suave); }
.estado-vacio { display: grid; place-items: center; text-align: center; padding: 3.5rem 1rem; color: var(--secundario); }
.estado-vacio span { width: 3rem; height: 3rem; display: grid; place-items: center; margin-bottom: .8rem; color: var(--azul); background: var(--azul-suave); border-radius: 50%; font-size: 1.35rem; }
.estado-vacio p { margin: 0; }

.panel-diagnostico { padding: 1.3rem; }
.btn-trazas { color: var(--texto); background: var(--superficie-suave); border: 1px solid var(--borde); }
.btn-trazas:hover { color: var(--azul); border-color: #9cb9ec; }
.trazas { overflow: hidden; border: 1px solid #cbd5e1; border-radius: .8rem; background: #172033; color: #dbeafe; }
.trazas-cabecera { display: flex; justify-content: space-between; padding: .65rem .85rem; color: #94a3b8; border-bottom: 1px solid #334155; font-size: .75rem; }
.trazas pre { max-height: 420px; margin: 0; padding: 1rem; overflow: auto; color: #dbeafe; font: .76rem/1.6 Consolas, "Courier New", monospace; white-space: pre-wrap; word-break: break-word; }

@media (max-width: 991.98px) {
    .fuentes-progreso { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767.98px) {
    .hero { padding: 2.2rem 0 1.5rem; }
    .hero h1 { font-size: 2.45rem; }
    .btn-actualizar { max-width: none; }
    .fuentes-progreso { grid-template-columns: 1fr; }
    .table-responsive { max-height: 72vh; }
    #tablaCoches { display: block; width: 100%; min-width: 0; }
    #tablaCoches thead { display: none; }
    #tablaCoches tbody { display: block; width: 100%; }
    #tablaCoches tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .15rem .75rem; padding: .8rem; border-bottom: 1px solid #e2e8f0; }
    #tablaCoches tbody tr[hidden] { display: none; }
    #tablaCoches tbody td { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; padding: .35rem 0; border: 0; }
    #tablaCoches tbody td:first-child { grid-column: 1 / -1; }
    #tablaCoches tbody td::before { color: var(--secundario); font-size: .64rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; margin-bottom: .2rem; }
    #tablaCoches tbody td:nth-child(1)::before { content: 'Modelo'; }
    #tablaCoches tbody td:nth-child(2)::before { content: 'Lugar'; }
    #tablaCoches tbody td:nth-child(3)::before { content: 'Precio al contado'; }
    #tablaCoches tbody td:nth-child(4)::before { content: 'Kilómetros'; }
    #tablaCoches tbody td:nth-child(5)::before { content: 'Plazas'; }
    #tablaCoches tbody td:nth-child(6)::before { content: 'Puntuación'; }
    #tablaCoches tbody td:nth-child(7)::before { content: 'Fuente'; }
    #tablaCoches tbody td:nth-child(8)::before { content: 'Anuncio'; }
    .modelo { min-width: 0; max-width: 100%; }
}
