/* ============================================================
   FNAR Coches — Stylesheet
   Diseño Apple-inspired: minimalista, tipografía limpia,
   sombras suaves, sin librerías externas
   ============================================================ */

/* ── Variables ───────────────────────────────────────────────── */
:root {
    --white:          #ffffff;
    --gray-50:        #f5f5f7;
    --gray-100:       #e8e8ed;
    --gray-200:       #d2d2d7;
    --gray-400:       #86868b;
    --gray-500:       #6e6e73;
    --gray-700:       #424245;
    --gray-900:       #1d1d1f;

    --accent:         #1d3557;
    --accent-hover:   #2a4a7f;
    --accent-light:   #e8eef5;
    --accent-muted:   #4a6fa5;

    --danger:         #ff3b30;
    --danger-light:   #fff2f1;
    --success:        #34c759;
    --success-light:  #f0fdf4;
    --warning:        #ff9500;
    --warning-light:  #fff8f0;

    --radius-xs:      6px;
    --radius-sm:      8px;
    --radius-md:      12px;
    --radius-lg:      16px;
    --radius-xl:      20px;
    --radius-full:    9999px;

    --shadow-xs:      0 1px 2px rgba(0,0,0,.05);
    --shadow-sm:      0 1px 4px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:      0 4px 16px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.04);
    --shadow-lg:      0 8px 32px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.04);
    --shadow-focus:   0 0 0 3px rgba(29,53,87,.18);

    --sidebar-w:      260px;
    --topbar-h:       64px;
    --transition:     .18s ease;

    --font:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ── Reset & base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background:  var(--gray-50);
    color:       var(--gray-900);
    line-height: 1.5;
    min-height:  100vh;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ── Scrollbar webkit ────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: var(--radius-full); }

/* ============================================================
   AUTH LAYOUT
   ============================================================ */
.auth-body {
    background:     var(--gray-50);
    display:        flex;
    flex-direction: column;
    min-height:     100vh;
}

.auth-main {
    flex:            1;
    display:         flex;
    align-items:     center;
    justify-content: center;
    padding:         24px;
}

.auth-container { width: 100%; max-width: 420px; }

.auth-card {
    background:    var(--white);
    border-radius: var(--radius-xl);
    box-shadow:    var(--shadow-lg);
    padding:       48px 44px;
}

.auth-logo {
    width:           56px;
    height:          56px;
    background:      var(--accent);
    border-radius:   var(--radius-lg);
    display:         flex;
    align-items:     center;
    justify-content: center;
    margin:          0 auto 28px;
}

.auth-logo i {
    font-size: 24px;
    color:     var(--white);
}

.auth-title {
    font-size:   24px;
    font-weight: 700;
    text-align:  center;
    color:       var(--gray-900);
    margin-bottom: 4px;
    letter-spacing: -.3px;
}

.auth-subtitle {
    font-size:   14px;
    color:       var(--gray-400);
    text-align:  center;
    margin-bottom: 32px;
}

/* ── Formularios auth ────────────────────────────────────────── */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display:       block;
    font-size:     13px;
    font-weight:   500;
    color:         var(--gray-700);
    margin-bottom: 6px;
    letter-spacing: .1px;
}

.form-control {
    width:         100%;
    padding:       11px 14px;
    border:        1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size:     15px;
    color:         var(--gray-900);
    background:    var(--white);
    transition:    border-color var(--transition), box-shadow var(--transition);
    outline:       none;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow:   var(--shadow-focus);
}

.form-control::placeholder { color: var(--gray-400); }

.form-control[readonly] { background: var(--gray-50); cursor: default; }

textarea.form-control {
    resize:     vertical;
    min-height: 100px;
}

select.form-control { -webkit-appearance: none; appearance: none; cursor: pointer; }

.input-icon-wrap {
    position: relative;
}

.input-icon-wrap .form-control { padding-left: 42px; }

.input-icon-wrap .input-icon {
    position:  absolute;
    left:      14px;
    top:       50%;
    transform: translateY(-50%);
    color:     var(--gray-400);
    font-size: 15px;
    pointer-events: none;
}

/* ── Botones ─────────────────────────────────────────────────── */
.btn {
    display:         inline-flex;
    align-items:     center;
    justify-content: center;
    gap:             8px;
    padding:         10px 20px;
    border:          none;
    border-radius:   var(--radius-sm);
    font-size:       14px;
    font-weight:     600;
    letter-spacing:  .1px;
    cursor:          pointer;
    transition:      background var(--transition), transform var(--transition), box-shadow var(--transition);
    white-space:     nowrap;
    user-select:     none;
    text-decoration: none;
}

.btn:active { transform: scale(.98); }

.btn-primary {
    background: var(--accent);
    color:      var(--white);
    box-shadow: 0 2px 8px rgba(29,53,87,.25);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(29,53,87,.3);
}

.btn-secondary {
    background: var(--gray-100);
    color:      var(--gray-700);
}

.btn-secondary:hover { background: var(--gray-200); }

.btn-danger {
    background: var(--danger);
    color:      var(--white);
}

.btn-danger:hover { background: #e02d23; }

.btn-ghost {
    background: transparent;
    color:      var(--accent);
    padding:    8px 12px;
}

.btn-ghost:hover { background: var(--accent-light); }

.btn-sm  { padding: 7px 14px; font-size: 13px; }
.btn-lg  { padding: 13px 28px; font-size: 16px; }
.btn-full { width: 100%; }

.btn-icon {
    width:   36px;
    height:  36px;
    padding: 0;
    border-radius: var(--radius-sm);
}

/* ── Alertas flash ───────────────────────────────────────────── */
.flash {
    display:     flex;
    align-items: center;
    gap:         12px;
    padding:     14px 20px;
    margin:      0 28px;
    border-radius: var(--radius-md);
    font-size:   14px;
    font-weight: 500;
    position:    relative;
}

.flash-success { background: var(--success-light); color: #1a6a34; border: 1px solid #bbf7d0; }
.flash-error   { background: var(--danger-light);  color: #9f1010; border: 1px solid #fecaca; }
.flash-warning { background: var(--warning-light); color: #7c4a00; border: 1px solid #fed7aa; }

.flash i:first-child { font-size: 16px; flex-shrink: 0; }

.flash-close {
    margin-left:  auto;
    background:   transparent;
    border:       none;
    color:        inherit;
    opacity:      .6;
    padding:      2px 4px;
    border-radius: var(--radius-xs);
    transition:   opacity var(--transition);
}

.flash-close:hover { opacity: 1; }

/* ── Error list en formularios ───────────────────────────────── */
.error-list {
    background:    var(--danger-light);
    border:        1px solid #fecaca;
    border-radius: var(--radius-md);
    padding:       14px 16px;
    margin-bottom: 20px;
}

.error-list p {
    font-size:   13px;
    color:       #9f1010;
    display:     flex;
    align-items: center;
    gap:         8px;
    margin-bottom: 4px;
}

.error-list p:last-child { margin-bottom: 0; }

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app-wrapper {
    display:    flex;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
    width:      var(--sidebar-w);
    min-height: 100vh;
    background: var(--white);
    border-right: 1px solid var(--gray-100);
    display:    flex;
    flex-direction: column;
    position:   fixed;
    top:        0;
    left:       0;
    bottom:     0;
    z-index:    100;
    transition: transform .25s cubic-bezier(.4,0,.2,1);
}

.sidebar-header {
    display:     flex;
    align-items: center;
    gap:         12px;
    padding:     22px 20px 20px;
    border-bottom: 1px solid var(--gray-100);
}

.sidebar-logo {
    width:           38px;
    height:          38px;
    background:      var(--accent);
    border-radius:   var(--radius-sm);
    display:         flex;
    align-items:     center;
    justify-content: center;
    flex-shrink:     0;
}

.sidebar-logo i { font-size: 16px; color: var(--white); }

.sidebar-brand {
    font-size:   15px;
    font-weight: 700;
    color:       var(--gray-900);
    letter-spacing: -.2px;
}

.sidebar-nav {
    flex:    1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap:     4px;
    overflow-y: auto;
}

.nav-item {
    display:       flex;
    align-items:   center;
    gap:           12px;
    padding:       11px 14px;
    border-radius: var(--radius-sm);
    font-size:     14px;
    font-weight:   500;
    color:         var(--gray-500);
    transition:    background var(--transition), color var(--transition);
}

.nav-item i {
    width:     18px;
    font-size: 15px;
    text-align: center;
    flex-shrink: 0;
}

.nav-item:hover {
    background: var(--gray-50);
    color:      var(--gray-900);
}

.nav-item.active {
    background: var(--accent-light);
    color:      var(--accent);
    font-weight: 600;
}

.sidebar-footer {
    display:     flex;
    align-items: center;
    gap:         10px;
    padding:     16px 16px;
    border-top:  1px solid var(--gray-100);
}

.sidebar-user {
    display:     flex;
    align-items: center;
    gap:         10px;
    flex:        1;
    min-width:   0;
}

.user-avatar {
    width:           34px;
    height:          34px;
    background:      var(--accent);
    color:           var(--white);
    border-radius:   var(--radius-full);
    display:         flex;
    align-items:     center;
    justify-content: center;
    font-size:       13px;
    font-weight:     700;
    flex-shrink:     0;
}

.user-info {
    display:        flex;
    flex-direction: column;
    min-width:      0;
}

.user-name {
    font-size:   13px;
    font-weight: 600;
    color:       var(--gray-900);
    white-space: nowrap;
    overflow:    hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 11px;
    color:     var(--gray-400);
}

.logout-btn {
    width:           32px;
    height:          32px;
    border-radius:   var(--radius-sm);
    display:         flex;
    align-items:     center;
    justify-content: center;
    color:           var(--gray-400);
    transition:      color var(--transition), background var(--transition);
    flex-shrink:     0;
}

.logout-btn:hover { color: var(--danger); background: var(--danger-light); }

/* ── Main area ───────────────────────────────────────────────── */
.main-area {
    margin-left: var(--sidebar-w);
    flex:        1;
    display:     flex;
    flex-direction: column;
    min-height:  100vh;
    min-width:   0;
}

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
    height:        var(--topbar-h);
    background:    var(--white);
    border-bottom: 1px solid var(--gray-100);
    display:       flex;
    align-items:   center;
    gap:           16px;
    padding:       0 28px;
    position:      sticky;
    top:           0;
    z-index:       50;
}

.hamburger {
    display:        none;
    flex-direction: column;
    gap:            5px;
    background:     none;
    border:         none;
    padding:        6px;
    border-radius:  var(--radius-xs);
    flex-shrink:    0;
}

.hamburger span {
    display:       block;
    width:         20px;
    height:        2px;
    background:    var(--gray-700);
    border-radius: var(--radius-full);
    transition:    var(--transition);
}

.page-title {
    font-size:   18px;
    font-weight: 600;
    color:       var(--gray-900);
    letter-spacing: -.2px;
    flex:        1;
}

.topbar-right { margin-left: auto; }

.topbar-logout {
    display:     flex;
    align-items: center;
    gap:         7px;
    font-size:   13px;
    font-weight: 500;
    color:       var(--gray-500);
    padding:     7px 12px;
    border-radius: var(--radius-sm);
    transition:  background var(--transition), color var(--transition);
}

.topbar-logout:hover { background: var(--danger-light); color: var(--danger); }

/* ── Page content ────────────────────────────────────────────── */
.page-content {
    flex:    1;
    padding: 28px 28px 40px;
}

/* ── Overlay móvil ───────────────────────────────────────────── */
.sidebar-overlay {
    display:    none;
    position:   fixed;
    inset:      0;
    background: rgba(0,0,0,.35);
    z-index:    90;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active { display: block; }

/* ============================================================
   COMPONENTES COMPARTIDOS
   ============================================================ */

/* ── Card ────────────────────────────────────────────────────── */
.card {
    background:    var(--white);
    border-radius: var(--radius-lg);
    box-shadow:    var(--shadow-sm);
    border:        1px solid var(--gray-100);
}

.card-header {
    display:     flex;
    align-items: center;
    justify-content: space-between;
    padding:     20px 24px 16px;
    border-bottom: 1px solid var(--gray-100);
}

.card-title {
    font-size:   16px;
    font-weight: 600;
    color:       var(--gray-900);
    letter-spacing: -.15px;
}

.card-body { padding: 24px; }

/* ── Sección cabecera de página ──────────────────────────────── */
.section-header {
    display:     flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap:         16px;
    flex-wrap:   wrap;
}

.section-title {
    font-size:   22px;
    font-weight: 700;
    color:       var(--gray-900);
    letter-spacing: -.3px;
}

.section-subtitle {
    font-size:  13px;
    color:      var(--gray-400);
    margin-top: 2px;
}

/* ── Tabla ───────────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border:     1px solid var(--gray-100);
}

table {
    width:           100%;
    border-collapse: collapse;
    background:      var(--white);
    font-size:       14px;
}

thead th {
    padding:    12px 16px;
    text-align: left;
    font-size:  11px;
    font-weight: 600;
    color:      var(--gray-500);
    letter-spacing: .6px;
    text-transform: uppercase;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-100);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--gray-100);
    transition:    background var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

tbody td {
    padding:        12px 16px;
    vertical-align: middle;
    color:          var(--gray-900);
}

.td-photo {
    width: 64px;
    padding: 10px 10px 10px 16px;
}

.thumb {
    width:         48px;
    height:        48px;
    border-radius: var(--radius-sm);
    object-fit:    cover;
    background:    var(--gray-100);
    display:       flex;
    align-items:   center;
    justify-content: center;
    flex-shrink:   0;
    overflow:      hidden;
}

.thumb img {
    width:      100%;
    height:     100%;
    object-fit: cover;
}

.thumb-placeholder {
    color:     var(--gray-300);
    font-size: 20px;
}

.td-actions {
    white-space: nowrap;
    text-align:  right;
}

.actions-cell {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
    display:       inline-flex;
    align-items:   center;
    gap:           5px;
    padding:       3px 10px;
    border-radius: var(--radius-full);
    font-size:     11px;
    font-weight:   600;
    letter-spacing: .3px;
}

.badge-accent  { background: var(--accent-light);  color: var(--accent); }
.badge-success { background: var(--success-light); color: #15803d; }
.badge-warning { background: var(--warning-light); color: #9a3412; }
.badge-gray    { background: var(--gray-100);      color: var(--gray-500); }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
    text-align:  center;
    padding:     64px 24px;
    color:       var(--gray-400);
}

.empty-state-icon {
    font-size:     52px;
    margin-bottom: 16px;
    opacity:       .35;
}

.empty-state h3 {
    font-size:   18px;
    font-weight: 600;
    color:       var(--gray-700);
    margin-bottom: 8px;
}

.empty-state p {
    font-size:     14px;
    max-width:     320px;
    margin:        0 auto 24px;
    line-height:   1.6;
}

/* ============================================================
   MÓDULO: BUSCADOR
   ============================================================ */
.filter-card {
    background:    var(--white);
    border-radius: var(--radius-lg);
    box-shadow:    var(--shadow-sm);
    border:        1px solid var(--gray-100);
    padding:       24px;
    margin-bottom: 28px;
}

.filter-grid {
    display:               grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap:                   16px;
    align-items:           end;
}

.filter-actions {
    display:     flex;
    gap:         10px;
    align-items: center;
    flex-wrap:   wrap;
    margin-top:  4px;
}

.geo-btn {
    display:     inline-flex;
    align-items: center;
    gap:         7px;
    padding:     10px 16px;
    background:  var(--gray-50);
    border:      1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size:   13px;
    font-weight: 500;
    color:       var(--gray-700);
    cursor:      pointer;
    transition:  all var(--transition);
}

.geo-btn:hover {
    border-color: var(--accent);
    color:        var(--accent);
    background:   var(--accent-light);
}

.geo-btn i { color: var(--accent); }

/* ── Cuadrícula de coches (buscador) ─────────────────────────── */
.cars-grid {
    display:               grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap:                   20px;
}

.car-card {
    background:    var(--white);
    border-radius: var(--radius-lg);
    box-shadow:    var(--shadow-md);
    border:        1px solid var(--gray-100);
    overflow:      hidden;
    transition:    transform .2s ease, box-shadow .2s ease;
    display:       flex;
    flex-direction: column;
}

.car-card:hover {
    transform:  translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.car-card-photo {
    aspect-ratio: 16/10;
    overflow:     hidden;
    background:   var(--gray-100);
    position:     relative;
}

.car-card-photo img {
    width:      100%;
    height:     100%;
    object-fit: cover;
    transition: transform .3s ease;
}

.car-card:hover .car-card-photo img { transform: scale(1.04); }

.car-card-photo-placeholder {
    width:           100%;
    height:          100%;
    display:         flex;
    align-items:     center;
    justify-content: center;
    font-size:       44px;
    color:           var(--gray-300);
}

.car-card-body {
    padding: 18px 20px 20px;
    flex:    1;
    display: flex;
    flex-direction: column;
}

.car-card-header {
    display:         flex;
    align-items:     flex-start;
    justify-content: space-between;
    margin-bottom:   6px;
}

.car-card-name {
    font-size:   16px;
    font-weight: 700;
    color:       var(--gray-900);
    letter-spacing: -.2px;
}

.car-card-year {
    font-size:   12px;
    font-weight: 600;
    color:       var(--gray-400);
    background:  var(--gray-100);
    padding:     2px 8px;
    border-radius: var(--radius-full);
}

.car-card-price {
    font-size:   22px;
    font-weight: 700;
    color:       var(--accent);
    margin-bottom: 12px;
    letter-spacing: -.5px;
}

.car-card-meta {
    display:   flex;
    flex-wrap: wrap;
    gap:       8px;
    margin-bottom: 12px;
}

.car-meta-item {
    display:     flex;
    align-items: center;
    gap:         5px;
    font-size:   12px;
    color:       var(--gray-500);
}

.car-meta-item i { color: var(--gray-400); font-size: 11px; }

.car-card-commercial {
    display:     flex;
    align-items: center;
    gap:         8px;
    margin-top:  auto;
    padding-top: 12px;
    border-top:  1px solid var(--gray-100);
}

.car-commercial-avatar {
    width:           28px;
    height:          28px;
    background:      var(--accent);
    color:           var(--white);
    border-radius:   var(--radius-full);
    display:         flex;
    align-items:     center;
    justify-content: center;
    font-size:       11px;
    font-weight:     700;
    flex-shrink:     0;
    overflow:        hidden;
}

.car-commercial-avatar img {
    width:      100%;
    height:     100%;
    object-fit: cover;
}

.car-commercial-name {
    font-size:  12px;
    color:      var(--gray-500);
    font-weight: 500;
}

/* ── Resultados meta ─────────────────────────────────────────── */
.results-meta {
    display:     flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap:   wrap;
    gap:         8px;
}

.results-count {
    font-size:  14px;
    color:      var(--gray-500);
}

.results-count strong { color: var(--gray-900); font-weight: 600; }

/* ============================================================
   MÓDULO: GESTIÓN (tablas)
   ============================================================ */

/* ── Foto en tabla ───────────────────────────────────────────── */
.table-photo {
    width:         48px;
    height:        48px;
    border-radius: var(--radius-sm);
    object-fit:    cover;
    background:    var(--gray-100);
}

/* ── Comercial avatar en tabla ───────────────────────────────── */
.commercial-row {
    display:     flex;
    align-items: center;
    gap:         10px;
}

.commercial-avatar-lg {
    width:           56px;
    height:          56px;
    border-radius:   var(--radius-full);
    background:      var(--accent);
    color:           var(--white);
    display:         flex;
    align-items:     center;
    justify-content: center;
    font-size:       18px;
    font-weight:     700;
    overflow:        hidden;
    flex-shrink:     0;
}

.commercial-avatar-lg img {
    width:      100%;
    height:     100%;
    object-fit: cover;
}

.commercial-info-name {
    font-weight: 600;
    font-size:   14px;
    color:       var(--gray-900);
}

.commercial-info-sub {
    font-size: 12px;
    color:     var(--gray-500);
}

/* ============================================================
   FORMULARIOS (páginas crear/editar)
   ============================================================ */
.form-card {
    background:    var(--white);
    border-radius: var(--radius-lg);
    box-shadow:    var(--shadow-sm);
    border:        1px solid var(--gray-100);
    max-width:     760px;
}

.form-card .card-body { padding: 28px 32px; }

.form-grid-2 {
    display:               grid;
    grid-template-columns: 1fr 1fr;
    gap:                   18px;
}

.form-grid-3 {
    display:               grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap:                   18px;
}

.form-grid-full { grid-column: 1 / -1; }

.form-row {
    display:     flex;
    gap:         18px;
    align-items: flex-start;
}

.form-row .form-group { flex: 1; }

/* ── Hint / helper text ──────────────────────────────────────── */
.form-hint {
    font-size:  12px;
    color:      var(--gray-400);
    margin-top: 5px;
}

/* ── Select wrapper con ícono ────────────────────────────────── */
.select-wrap { position: relative; }

.select-wrap::after {
    content:        '\f107';
    font-family:    'Font Awesome 6 Free';
    font-weight:    900;
    position:       absolute;
    right:          13px;
    top:            50%;
    transform:      translateY(-50%);
    color:          var(--gray-400);
    pointer-events: none;
    font-size:      13px;
}

.select-wrap select { padding-right: 36px; }

/* ── Subida de fotos ─────────────────────────────────────────── */
.upload-zone {
    border:        2px dashed var(--gray-200);
    border-radius: var(--radius-md);
    padding:       28px;
    text-align:    center;
    cursor:        pointer;
    transition:    border-color var(--transition), background var(--transition);
    position:      relative;
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--accent);
    background:   var(--accent-light);
}

.upload-zone input[type="file"] {
    position: absolute;
    inset:    0;
    opacity:  0;
    cursor:   pointer;
    width:    100%;
    height:   100%;
}

.upload-zone-icon {
    font-size:     30px;
    color:         var(--gray-300);
    margin-bottom: 10px;
    transition:    color var(--transition);
}

.upload-zone:hover .upload-zone-icon { color: var(--accent-muted); }

.upload-zone-text {
    font-size:  14px;
    color:      var(--gray-500);
}

.upload-zone-text strong { color: var(--accent); }

.upload-zone-hint {
    font-size:  12px;
    color:      var(--gray-400);
    margin-top: 5px;
}

/* ── Preview de fotos ────────────────────────────────────────── */
.photo-preview-grid {
    display:               grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap:                   10px;
    margin-top:            14px;
}

.photo-preview-item {
    position:      relative;
    aspect-ratio:  1;
    border-radius: var(--radius-sm);
    overflow:      hidden;
    background:    var(--gray-100);
    border:        2px solid var(--gray-200);
}

.photo-preview-item.is-main { border-color: var(--accent); }

.photo-preview-item img {
    width:      100%;
    height:     100%;
    object-fit: cover;
}

.photo-preview-remove {
    position:    absolute;
    top:         4px;
    right:       4px;
    width:       24px;
    height:      24px;
    background:  rgba(0,0,0,.6);
    color:       var(--white);
    border:      none;
    border-radius: var(--radius-full);
    display:     flex;
    align-items: center;
    justify-content: center;
    font-size:   11px;
    cursor:      pointer;
    transition:  background var(--transition);
    text-decoration: none;
}

.photo-preview-remove:hover { background: var(--danger); }

.photo-main-badge {
    position:  absolute;
    bottom:    4px;
    left:      4px;
    background: var(--accent);
    color:     var(--white);
    font-size: 9px;
    font-weight: 700;
    padding:   2px 6px;
    border-radius: var(--radius-full);
    letter-spacing: .5px;
    text-transform: uppercase;
}

/* ── Foto de perfil de comercial ─────────────────────────────── */
.profile-photo-wrap {
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    gap:             12px;
}

.profile-photo-preview {
    width:         100px;
    height:        100px;
    border-radius: var(--radius-full);
    background:    var(--gray-100);
    display:       flex;
    align-items:   center;
    justify-content: center;
    font-size:     36px;
    color:         var(--gray-300);
    overflow:      hidden;
    border:        3px solid var(--gray-200);
    transition:    border-color var(--transition);
}

.profile-photo-preview img {
    width:      100%;
    height:     100%;
    object-fit: cover;
}

/* ── Form footer ─────────────────────────────────────────────── */
.form-footer {
    display:     flex;
    gap:         12px;
    align-items: center;
    padding:     20px 32px;
    border-top:  1px solid var(--gray-100);
    background:  var(--gray-50);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ============================================================
   UTILIDADES
   ============================================================ */
.text-sm      { font-size: 13px; }
.text-xs      { font-size: 11px; }
.text-muted   { color: var(--gray-400); }
.text-accent  { color: var(--accent); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }

.fw-medium { font-weight: 500; }
.fw-semi   { font-weight: 600; }
.fw-bold   { font-weight: 700; }

.d-flex         { display: flex; }
.align-center   { align-items: center; }
.justify-between{ justify-content: space-between; }
.gap-2          { gap: 8px; }
.gap-3          { gap: 12px; }
.mt-2           { margin-top: 8px; }
.mt-4           { margin-top: 16px; }
.mb-4           { margin-bottom: 16px; }

.price-tag {
    font-weight: 700;
    color:       var(--accent);
    font-size:   15px;
}

/* ── Separador ───────────────────────────────────────────────── */
.divider {
    border:        none;
    border-top:    1px solid var(--gray-100);
    margin:        24px 0;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* ── Tablet grande ────────────────────────────────────────── */
@media (max-width: 1024px) {
    .form-grid-3 { grid-template-columns: 1fr 1fr; }
    .car-detail-body { grid-template-columns: 1fr 340px; }
}

/* ── Tablet y móvil grande (768px-) ──────────────────────── */
@media (max-width: 768px) {
    /* ── Sidebar ─── */
    .sidebar {
        transform: translateX(-100%);
        width:     var(--sidebar-w);
    }
    .sidebar.open { transform: translateX(0); }
    .main-area    { margin-left: 0; }
    .hamburger    { display: flex; }

    /* ── Topbar ─── */
    .topbar            { padding: 0 18px; }
    .topbar-logout span{ display: none; }

    /* ── Layout ─── */
    .page-content { padding: 20px 16px 40px; }
    .flash        { margin: 0 16px; }

    /* ── Formularios ─── */
    .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
    .form-row          { flex-direction: column; }
    .form-card .card-body { padding: 20px 18px; }
    .form-footer       { padding: 16px 18px; flex-wrap: wrap; }

    /* ── Buscador ─── */
    .filter-grid  { grid-template-columns: 1fr 1fr; }
    .cars-grid    { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
    .section-header { flex-direction: column; align-items: flex-start; }

    /* ── Auth ─── */
    .auth-card    { padding: 36px 28px; }

    /* ── Detalle coche ─── */
    .car-detail-body { grid-template-columns: 1fr; }
    .car-detail-title{ font-size: 22px; }
    .car-detail-price{ font-size: 26px; }

    /* ── TABLA → TARJETAS en móvil ─── */
    /* El wrapper pierde el borde/sombra (las filas las tienen) */
    .table-wrap {
        background:    transparent;
        border:        none;
        box-shadow:    none;
        border-radius: 0;
        overflow:      visible;
    }

    /* Convierte tabla y celdas en bloques */
    .table-wrap table { display: block; }
    .table-wrap thead { display: none; }    /* Oculta cabecera */
    .table-wrap tbody { display: block; }

    /* Cada fila = tarjeta */
    .table-wrap tbody tr {
        display:       block;
        background:    var(--white);
        border-radius: var(--radius-lg);
        box-shadow:    var(--shadow-md);
        border:        1px solid var(--gray-100);
        margin-bottom: 16px;
        padding:       4px 16px 12px;
    }

    .table-wrap tbody tr.row-suspended {
        border-color: #fed7aa;
        background:   #fffbf5;
    }

    /* Cada celda = fila flex con etiqueta a la izquierda */
    .table-wrap tbody td {
        display:         flex;
        justify-content: space-between;
        align-items:     center;
        padding:         10px 0;
        border-bottom:   1px solid var(--gray-100);
        font-size:       14px;
        gap:             12px;
        min-height:      44px; /* touch-friendly */
    }

    .table-wrap tbody td:last-child { border-bottom: none; }

    /* Etiqueta auto desde data-label */
    .table-wrap tbody td[data-label]:not([data-label=""])::before {
        content:       attr(data-label);
        font-size:     11px;
        font-weight:   600;
        color:         var(--gray-400);
        text-transform: uppercase;
        letter-spacing: .5px;
        flex-shrink:   0;
        min-width:     72px;
    }

    /* Celda de foto: centrada, sin etiqueta */
    .table-wrap tbody td.td-photo {
        justify-content: center;
        padding:         12px 0 8px;
    }

    /* Celda de acciones: alineada a la derecha */
    .table-wrap tbody td.td-actions {
        justify-content: flex-end;
        flex-wrap:       wrap;
        gap:             8px;
        padding-top:     12px;
    }

    /* Botones touch-friendly (mínimo 44px) */
    .btn-icon { min-width: 44px; min-height: 44px; border-radius: var(--radius-sm); }
    .actions-cell { gap: 8px; flex-wrap: wrap; }
}

/* ── Móvil pequeño (480px-) ──────────────────────────────── */
@media (max-width: 480px) {
    .filter-grid  { grid-template-columns: 1fr; }
    .cars-grid    { grid-template-columns: 1fr; }
    .carousel-thumb { width: 52px; height: 40px; }
    .filter-actions { flex-direction: column; align-items: stretch; }
    .filter-actions .btn,
    .filter-actions .geo-btn { width: 100%; justify-content: center; }
    .section-header .btn { width: 100%; justify-content: center; }

    /* Texto en botón reactivar visible en móvil */
    .btn-reactivate { min-height: 44px; }
}

/* ============================================================
   TARJETAS COMO ENLACES (buscador)
   ============================================================ */
.car-card-link {
    display:         block;
    text-decoration: none;
    color:           inherit;
    border-radius:   var(--radius-lg);
}

.car-card-link:focus-visible {
    outline:        3px solid var(--accent);
    outline-offset: 2px;
}

/* Badge "Visto" sobre la foto de la tarjeta */
.car-card-seen-badge {
    position:      absolute;
    top:           10px;
    left:          10px;
    background:    #16a34a;
    color:         #fff;
    font-size:     11px;
    font-weight:   700;
    padding:       4px 10px;
    border-radius: var(--radius-full);
    display:       flex;
    align-items:   center;
    gap:           5px;
    letter-spacing: .3px;
    box-shadow:    0 2px 6px rgba(0,0,0,.18);
}

/* Tarjeta con estado "visto": borde verde sutil */
.car-card.is-seen {
    border-color: #bbf7d0;
}

/* ============================================================
   MÓDULO: DETALLE DEL COCHE
   ============================================================ */
.car-detail-layout {
    max-width: 1100px;
}

/* Cabecera */
.btn-back {
    display:       inline-flex;
    align-items:   center;
    gap:           8px;
    font-size:     13px;
    font-weight:   500;
    color:         var(--gray-500);
    padding:       6px 0;
    margin-bottom: 16px;
    transition:    color var(--transition);
}

.btn-back:hover { color: var(--accent); }

.car-detail-header { margin-bottom: 24px; }

.car-detail-title-row {
    display:     flex;
    align-items: flex-start;
    gap:         16px;
    flex-wrap:   wrap;
}

.car-detail-title {
    font-size:      28px;
    font-weight:    800;
    color:          var(--gray-900);
    letter-spacing: -.5px;
    line-height:    1.15;
}

.car-detail-subtitle {
    font-size:   14px;
    color:       var(--gray-400);
    font-weight: 500;
    margin-top:  4px;
    display:     block;
}

.car-detail-seen-badge {
    font-size:   13px;
    padding:     6px 14px;
    flex-shrink: 0;
    margin-top:  4px;
}

/* Cuerpo: 2 columnas */
.car-detail-body {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap:     28px;
    align-items: start;
}

/* ── Galería / carrusel ──────────────────────────────────────── */
.car-detail-gallery {
    min-width: 0;
}

.carousel {
    position:      relative;
    border-radius: var(--radius-lg);
    overflow:      hidden;
    background:    var(--gray-100);
    aspect-ratio:  16/10;
}

.carousel-slide {
    display:    none;
    width:      100%;
    height:     100%;
}

.carousel-slide.active {
    display: block;
}

.carousel-slide img {
    width:      100%;
    height:     100%;
    object-fit: cover;
}

.carousel-btn {
    position:        absolute;
    top:             50%;
    transform:       translateY(-50%);
    width:           40px;
    height:          40px;
    background:      rgba(255,255,255,.88);
    border:          none;
    border-radius:   var(--radius-full);
    display:         flex;
    align-items:     center;
    justify-content: center;
    font-size:       14px;
    color:           var(--gray-900);
    cursor:          pointer;
    transition:      background var(--transition), transform var(--transition);
    box-shadow:      var(--shadow-sm);
    z-index:         2;
    backdrop-filter: blur(4px);
}

.carousel-btn:hover {
    background: var(--white);
    transform:  translateY(-50%) scale(1.08);
}

.carousel-prev { left: 12px; }
.carousel-next { right: 12px; }

.carousel-counter {
    position:        absolute;
    bottom:          12px;
    right:           14px;
    background:      rgba(0,0,0,.48);
    color:           #fff;
    font-size:       12px;
    font-weight:     600;
    padding:         3px 10px;
    border-radius:   var(--radius-full);
    backdrop-filter: blur(4px);
}

/* Miniaturas */
.carousel-thumbs {
    display:    flex;
    gap:        8px;
    margin-top: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
}

.carousel-thumb {
    flex-shrink:   0;
    width:         68px;
    height:        50px;
    border-radius: var(--radius-sm);
    overflow:      hidden;
    border:        2px solid var(--gray-200);
    padding:       0;
    background:    var(--gray-100);
    cursor:        pointer;
    transition:    border-color var(--transition), transform var(--transition);
}

.carousel-thumb:hover { border-color: var(--accent-muted); }

.carousel-thumb.active {
    border-color: var(--accent);
    transform:    scale(1.06);
}

.carousel-thumb img {
    width:      100%;
    height:     100%;
    object-fit: cover;
}

/* Sin fotos */
.car-detail-no-photo {
    aspect-ratio:    16/10;
    border-radius:   var(--radius-lg);
    background:      var(--gray-100);
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    justify-content: center;
    color:           var(--gray-300);
    gap:             10px;
    font-size:       48px;
}

.car-detail-no-photo p {
    font-size:  14px;
    color:      var(--gray-400);
    font-weight: 500;
}

/* ── Panel de información ─────────────────────────────────────── */
.car-detail-info {
    background:    var(--white);
    border-radius: var(--radius-lg);
    box-shadow:    var(--shadow-sm);
    border:        1px solid var(--gray-100);
    padding:       24px;
    display:       flex;
    flex-direction: column;
    gap:           20px;
}

.car-detail-price {
    font-size:      32px;
    font-weight:    800;
    color:          var(--accent);
    letter-spacing: -1px;
    line-height:    1;
}

/* Ficha técnica */
.car-detail-specs {
    display:       flex;
    flex-direction: column;
    gap:           0;
    border-radius: var(--radius-md);
    border:        1px solid var(--gray-100);
    overflow:      hidden;
}

.car-spec-item {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    padding:         10px 14px;
    border-bottom:   1px solid var(--gray-100);
    gap:             12px;
}

.car-spec-item:last-child { border-bottom: none; }

.car-spec-label {
    font-size:  13px;
    color:      var(--gray-500);
    display:    flex;
    align-items: center;
    gap:        6px;
    flex-shrink: 0;
}

.car-spec-label i { color: var(--gray-300); font-size: 12px; }

.car-spec-value {
    font-size:   13px;
    font-weight: 600;
    color:       var(--gray-900);
    text-align:  right;
}

/* Descripción */
.car-detail-section-title {
    font-size:     12px;
    font-weight:   700;
    text-transform: uppercase;
    letter-spacing: .7px;
    color:         var(--gray-400);
    margin-bottom: 8px;
}

.car-detail-description p {
    font-size:   14px;
    color:       var(--gray-700);
    line-height: 1.6;
}

/* Comercial */
.car-detail-commercial-card {
    display:     flex;
    align-items: center;
    gap:         14px;
    background:  var(--gray-50);
    border-radius: var(--radius-md);
    padding:     14px;
    border:      1px solid var(--gray-100);
}

.car-detail-commercial-info {
    display:        flex;
    flex-direction: column;
    gap:            4px;
}

.commercial-info-phone {
    font-size:   13px;
    color:       var(--accent);
    font-weight: 500;
    display:     flex;
    align-items: center;
    gap:         5px;
    text-decoration: none;
    transition:  color var(--transition);
}

.commercial-info-phone:hover { color: var(--accent-hover); }

/* ── Favoritos ──────────────────────────────────────────────── */
.fav-btn {
    position:        absolute;
    top:             10px;
    right:           10px;
    width:           36px;
    height:          36px;
    border-radius:   50%;
    border:          none;
    background:      rgba(255,255,255,0.92);
    color:           var(--gray-400);
    font-size:       16px;
    display:         flex;
    align-items:     center;
    justify-content: center;
    cursor:          pointer;
    transition:      all var(--transition);
    box-shadow:      0 1px 4px rgba(0,0,0,.15);
    z-index:         2;
}

.fav-btn:hover      { color: #e53e3e; background: #fff; transform: scale(1.1); }
.fav-btn.is-fav     { color: #e53e3e; }
.fav-btn.is-fav:hover { color: #c53030; }

/* Variante grande para la página de detalle */
.fav-btn-lg {
    position:        static;
    width:           auto;
    height:          auto;
    border-radius:   var(--radius-md);
    background:      var(--gray-100);
    color:           var(--text-secondary);
    font-size:       14px;
    font-weight:     600;
    padding:         10px 16px;
    gap:             6px;
    flex-direction:  row;
    box-shadow:      none;
    border:          1.5px solid var(--gray-200);
}

.fav-btn-lg.is-fav       { color: #e53e3e; background: #fff5f5; border-color: #fecaca; }
.fav-btn-lg:hover        { background: #fff5f5; border-color: #fecaca; color: #e53e3e; transform: none; }

/* Separador visual en sidebar */
.nav-divider {
    height:     1px;
    background: var(--gray-200);
    margin:     8px 16px;
}

/* ============================================================
   FOOTER GLOBAL
   ============================================================ */
.site-footer {
    background:  #1a6b7a;
    color:       #fff;
    text-align:  center;
    font-size:   12px;
    padding:     10px 16px;
    line-height: 1.4;
    letter-spacing: .2px;
    flex-shrink: 0;
}

/* ============================================================
   SIDEBAR — LOGO FNAR
   ============================================================ */
.sidebar-header {
    padding:         16px 20px;
    border-bottom:   1px solid var(--gray-100);
    display:         flex;
    align-items:     center;
    justify-content: center;
    min-height:      72px;
}

.sidebar-fnar-logo {
    max-height:  48px;
    width:       auto;
    display:     block;
    object-fit:  contain;
}

/* ============================================================
   MÓDULO: MI EMPRESA
   ============================================================ */

/* Logo de empresa en formulario */
.empresa-logo-wrap {
    display:        flex;
    flex-direction: column;
    gap:            12px;
}

.empresa-logo-current {
    display:     flex;
    align-items: center;
    gap:         12px;
}

.empresa-logo-preview {
    max-height:    80px;
    max-width:     200px;
    border-radius: var(--radius-sm);
    border:        1px solid var(--gray-200);
    object-fit:    contain;
    background:    var(--gray-50);
    padding:       4px;
}

.upload-zone-sm {
    padding: 16px;
    max-width: 320px;
}

/* ============================================================
   SISTEMA DE CADUCIDAD — ESTILOS
   ============================================================ */

/* Badge de peligro (rojo) */
.badge-danger {
    background: var(--danger-light);
    color:      var(--danger);
}

/* Colores de texto para vigencia */
.text-success       { color: #15803d; }
.text-warning-strong{ color: #92400e; }

/* Fila de coche suspendido en tabla */
.row-suspended {
    border-color: #fed7aa !important;
    background:   #fffbf5 !important;
}

/* Botón reactivar */
.btn-reactivate {
    display:         inline-flex;
    align-items:     center;
    justify-content: center;
    gap:             6px;
    padding:         7px 14px;
    background:      var(--warning-light);
    color:           #92400e;
    border:          1.5px solid #fcd34d;
    border-radius:   var(--radius-sm);
    font-size:       13px;
    font-weight:     600;
    cursor:          pointer;
    transition:      all var(--transition);
    white-space:     nowrap;
    text-decoration: none;
}

.btn-reactivate:hover {
    background:   #fef3c7;
    border-color: #f59e0b;
    transform:    translateY(-1px);
}

/* En escritorio el label del botón reactivar se oculta para no romper la tabla */
@media (min-width: 769px) {
    .btn-label-responsive { display: none; }
}
