@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

@font-face {
    font-family: 'DrukWide';
    src: url('./font/DrukWide-SuperItalic-Trial.otf') format('opentype');
    font-weight: normal;
    font-style: italic;
    font-display: swap;
}

:root {
    /* Light Mode - Minimalist Black & White Palette */
    --bg-primary: #ffffff;
    --bg-secondary: #fafafa;
    --card-bg: #ffffff;
    --card-border: #e0e0e0;
    --text-primary: #000000;
    --text-secondary: #666666;
    --text-muted: #999999;
    --hover-bg: #f5f5f5;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.1);

    /* Profit Colors */
    --profit-positive: #00a86b;
    --profit-negative: #dc143c;
}

/* Dark Mode - Aplicar a html y body para evitar flash */
html.dark-mode,
body.dark-mode,
.dark-mode body {
    --bg-primary: #1a1a1a;
    --bg-secondary: #0f0f0f;
    --card-bg: #1a1a1a;
    --card-border: #333333;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --hover-bg: #252525;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.5);
}

body.dark-mode .cars-table thead,
.dark-mode .cars-table thead {
    border-bottom: 1px solid var(--card-border);
}

body.dark-mode .btn-primary,
.dark-mode .btn-primary {
    background: #ffffff;
    color: #000000;
}

body.dark-mode .btn-primary:hover,
.dark-mode .btn-primary:hover {
    background: #e0e0e0;
}

body.dark-mode .btn-secondary,
.dark-mode .btn-secondary {
    background: #1a1a1a;
    color: #ffffff;
}

body.dark-mode .form-group input:focus,
body.dark-mode .form-group select:focus,
body.dark-mode .form-group textarea:focus,
.dark-mode .form-group input:focus,
.dark-mode .form-group select:focus,
.dark-mode .form-group textarea:focus {
    border-color: #ffffff;
    box-shadow: 0 0 0 1px #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    background: var(--bg-secondary);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
    position: relative;
}

/* Sidebar Styles */
.sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    background: var(--card-bg);
    border-right: 1px solid var(--card-border);
    box-shadow: var(--shadow-md);
    transition: left 0.3s ease;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar.active {
    left: 0;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    flex: 1;
}

.sidebar-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 2px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-close svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-secondary);
}

.sidebar-close:hover {
    background: var(--hover-bg);
}

.sidebar-close:hover svg {
    stroke: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.sidebar-link.active {
    background: var(--hover-bg);
    color: var(--text-primary);
    border-left-color: #000000;
    font-weight: 600;
}

body.dark-mode .sidebar-link.active,
.dark-mode .sidebar-link.active {
    border-left-color: #ffffff;
}

.sidebar-link svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
    transition: transform 0.2s ease;
}

.sidebar-link:hover svg {
    transform: scale(1.1);
}

.sidebar-link .badge {
    margin-left: auto;
    background: #000000;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

body.dark-mode .sidebar-link .badge,
.dark-mode .sidebar-link .badge {
    background: #ffffff;
    color: #000000;
}

.sidebar-divider {
    height: 1px;
    background: var(--card-border);
    margin: 0.5rem 1.5rem;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--card-border);
    margin-top: auto;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem;
    background: var(--hover-bg);
    border-radius: 8px;
    transition: background-color 0.2s ease;
    cursor: pointer;
    margin-bottom: 0;
}

.sidebar-user:hover {
    background: var(--card-border);
}

.sidebar-user-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    /* background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%); */
    border-radius: 10px;
    position: relative;
}

.sidebar-user>.sidebar-user-icon svg {
    width: 20px;
    height: 20px;
    stroke: var(--bg-primary);
    stroke-width: 2.5;
}

.sidebar-user-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.sidebar-user .sidebar-chevron {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform 0.25s ease;
}

.sidebar-user-name {
    font-size: 0.813rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.4;
    letter-spacing: -0.01em;
}

.sidebar-user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
    font-weight: 400;
    letter-spacing: 0.01em;
}

/* User Dropdown */
.sidebar-user-dropdown {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.2s ease;
    padding: 0;
}

.sidebar-user-dropdown.active {
    max-height: 180px;
    opacity: 1;
    padding-top: 0.5rem;
}

.sidebar-user-dropdown a,
.sidebar-user-dropdown button {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary);
    text-decoration: none;
    background: transparent;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.sidebar-user-dropdown a svg,
.sidebar-user-dropdown button svg {
    width: 16px;
    height: 16px;
    stroke: var(--text-muted);
    transition: stroke 0.15s;
}

.sidebar-user-dropdown a:hover,
.sidebar-user-dropdown button:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.sidebar-user-dropdown a.active {
    background: var(--hover-bg);
    color: var(--text-primary);
    font-weight: 600;
}

.sidebar-user-dropdown a:hover svg,
.sidebar-user-dropdown button:hover svg,
.sidebar-user-dropdown a.active svg {
    stroke: var(--text-primary);
}

.sidebar-user-dropdown .sidebar-logout-item {
    color: #dc2626;
    margin-top: 0.25rem;
    border-top: 1px solid var(--card-border);
    border-radius: 0 0 7px 7px;
    padding-top: 0.6rem;
}

.sidebar-user-dropdown .sidebar-logout-item svg {
    stroke: #dc2626;
}

.sidebar-user-dropdown .sidebar-logout-item:hover {
    background: rgba(220, 38, 38, 0.08);
    color: #b91c1c;
}

.sidebar-user-dropdown .sidebar-logout-item:hover svg {
    stroke: #b91c1c;
}

/* Legacy logout button (keep for backward compat) */
.logout-btn {
    display: none;
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1050;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* Menu Toggle Button */
.menu-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    width: 48px;
    height: 48px;
    background: #000000;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
    z-index: 1000;
}

.menu-toggle:hover {
    background: #1a1a1a;
    transform: scale(1.05);
}

.menu-toggle svg {
    width: 24px;
    height: 24px;
    stroke: white;
    stroke-width: 2;
}

body.dark-mode .menu-toggle,
.dark-mode .menu-toggle {
    background: #ffffff;
}

body.dark-mode .menu-toggle:hover,
.dark-mode .menu-toggle:hover {
    background: #e0e0e0;
}

body.dark-mode .menu-toggle svg,
.dark-mode .menu-toggle svg {
    stroke: #000000;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    padding-left: 5rem;
    transition: padding-left 0.3s ease;
}

@media (max-width: 1200px) {
    .container {
        max-width: 100%;
    }
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 3rem;
    margin-top: 1rem;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-logo img {
    padding-top: 3px;
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: 10px;
}

.header h1 {
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.02em;
}

.header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 400;
    margin: 0;
}

/* Dark Mode Toggle */
.dark-mode-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 4px;
    padding: 0.75rem 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    box-shadow: var(--shadow-md);
}

.dark-mode-toggle svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-primary);
}

.dark-mode-toggle:hover {
    background: var(--hover-bg);
}

/* Card */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 4px;
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: var(--text-primary);
    font-weight: 600;
}

.card-title svg {
    width: 24px;
    height: 24px;
    stroke: var(--text-primary);
}

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

.card-header .card-title {
    margin-bottom: 0;
}

/* Collapsible Card Header */
.card-header-collapsible {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    margin-bottom: 0;
    padding: 0.5rem;
    margin: -0.5rem;
    border-radius: 4px;
}

.card-header-collapsible:hover {
    background: var(--hover-bg);
}

.card-header-collapsible .card-title {
    margin-bottom: 0;
    flex: 1;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
}

.collapse-hint {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: normal;
}

.collapse-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.3s ease;
    color: var(--text-secondary);
}

.collapse-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.collapse-btn svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    transition: transform 0.3s ease;
}

.collapse-btn.expanded svg {
    transform: rotate(180deg);
}

/* Collapsible Content */
.collapsible-content {
    max-height: 10000px;
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.4s ease,
        margin-top 0.4s ease;
    opacity: 1;
    margin-top: 1.5rem;
}

.collapsible-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    pointer-events: none;
}

/* Button Styles */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 2px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

.btn-primary {
    background: #000000;
    color: white;
}

.btn-primary:hover {
    background: #1a1a1a;
}

.btn-secondary {
    background: #ffffff;
    color: var(--text-primary);
    border: 1px solid var(--card-border);
}

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

.form-actions {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Form Styles */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-group input,
.form-group select,
.form-group textarea {
    background: var(--bg-primary);
    border: 1px solid var(--card-border);
    border-radius: 2px;
    padding: 0.75rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #000000;
    box-shadow: 0 0 0 1px #000000;
}

.form-group input::placeholder {
    color: var(--text-muted);
}

/* Recambios Input Group */
.recambios-input-group {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.recambio-nombre {
    flex: 2;
    min-width: 0;
}

.recambio-precio {
    flex: 1;
    min-width: 0;
}

.recambio-btn {
    padding: 0.5rem 1rem;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Table Styles */
/* ==========================================
   Inventory Card Header
   ========================================== */
.inv-card {
    border-radius: 12px;
}

.inv-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.inv-card-title-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.inv-card-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.inv-card-icon svg {
    width: 16px;
    height: 16px;
}

html:not(.dark-mode) .inv-card-icon svg {
    stroke: #374151;
}

html.dark-mode .inv-card-icon svg {
    stroke: #d1d5db;
}

.inv-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.inv-card-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* ==========================================
   Inventory Table
   ========================================== */
.table-container {
    overflow-x: auto;
    margin-top: 0.5rem;
}

.cars-table {
    width: 100%;
    border-collapse: collapse;
}

.cars-table thead {
    border-bottom: 1px solid var(--card-border);
}

.cars-table th {
    padding: 0.6rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    white-space: nowrap;
}

.th-money {
    text-align: right;
    width: 90px;
}

.cars-table th:last-child,
.cars-table td:last-child {
    width: 40px;
    padding-right: 0.5rem;
}

.th-right {
    text-align: right;
}

.th-center {
    text-align: center;
}

.cars-table tbody tr {
    border-bottom: 1px solid var(--card-border);
    transition: background 0.12s ease;
    cursor: pointer;
}

.cars-table tbody tr:last-child {
    border-bottom: none;
}

.cars-table tbody tr:hover {
    background: var(--hover-bg);
}

.cars-table td {
    padding: 0.6rem 0.75rem;
    color: var(--text-primary);
    font-size: 0.8rem;
    vertical-align: middle;
}

.td-right {
    text-align: right;
}

.td-center {
    text-align: center;
}

/* Vehicle cell with thumb */
.inv-vehicle-cell {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.inv-row-thumb {
    width: 36px;
    height: 36px;
    border-radius: 7px;
    object-fit: cover;
    flex-shrink: 0;
}

.inv-row-thumb-logo {
    object-fit: contain;
    background: var(--bg-secondary);
    padding: 4px;
}

.inv-row-thumb-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 7px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.inv-row-thumb-placeholder svg {
    width: 14px;
    height: 14px;
}

html:not(.dark-mode) .inv-row-thumb-placeholder svg {
    stroke: #d1d5db;
}

html.dark-mode .inv-row-thumb-placeholder svg {
    stroke: #4b5563;
}

.inv-vehicle-info {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
    min-width: 0;
}

.inv-vehicle-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.inv-vehicle-sub {
    font-size: 0.68rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.inv-matricula {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* Price display */
.inv-price {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--text-primary);
}

/* Profit cell */
.inv-profit-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.05rem;
}

.inv-profit-pct {
    font-size: 0.65rem;
    font-weight: 600;
}

.profit-positive {
    color: var(--profit-positive) !important;
    font-weight: 600;
}

.profit-estimated {
    color: #3b82f6 !important;
    font-weight: 600;
}

.inv-profit-est {
    font-size: 0.6rem;
    font-weight: 600;
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    padding: 0.05rem 0.35rem;
    border-radius: 4px;
    letter-spacing: 0.02em;
}

.profit-negative {
    color: var(--profit-negative) !important;
    font-weight: 600;
}

/* Date cells */
.inv-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Stock pill */
.inv-stock-pill {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-radius: 5px;
    font-variant-numeric: tabular-nums;
}

/* Etiqueta ambiental */
.inv-etiqueta-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.inv-etiqueta-empty {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Row More Button & Dropdown */
.inv-more-wrap {
    position: relative;
    display: flex;
    justify-content: flex-end;
}

.inv-more-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.inv-more-btn svg {
    width: 15px;
    height: 15px;
}

html:not(.dark-mode) .inv-more-btn svg {
    stroke: #9ca3af;
}

html.dark-mode .inv-more-btn svg {
    stroke: #6b7280;
}

.inv-more-btn:hover,
.cars-table tbody tr:hover .inv-more-btn {
    border-color: var(--card-border);
    background: var(--bg-secondary);
}

html:not(.dark-mode) .inv-more-btn:hover svg {
    stroke: #374151;
}

html.dark-mode .inv-more-btn:hover svg {
    stroke: #d1d5db;
}

.inv-row-menu {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    z-index: 100;
    background: var(--bg-primary);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 0.3rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    min-width: 130px;
    opacity: 0;
    transform: translateY(-4px) scale(0.97);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.inv-row-menu.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Menú con position:fixed - no crea scroll ni se recorta */
.inv-row-menu.inv-row-menu-fixed {
    position: fixed;
    right: auto;
    top: auto;
    bottom: auto;
    left: auto;
    margin: 0;
    transform: translateY(-4px) scale(0.97);
}

.inv-row-menu.inv-row-menu-fixed.visible {
    transform: translateY(0) scale(1);
}

.dark-mode .inv-row-menu {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.inv-row-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.45rem 0.65rem;
    background: transparent;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: background 0.12s ease;
    text-align: left;
}

.inv-row-menu-item:hover {
    background: var(--hover-bg);
}

.inv-row-menu-item svg {
    width: 13px;
    height: 13px;
}

html:not(.dark-mode) .inv-row-menu-item svg {
    stroke: #6b7280;
}

html.dark-mode .inv-row-menu-item svg {
    stroke: #9ca3af;
}

.inv-row-menu-danger {
    color: #ef4444;
}

.inv-row-menu-danger svg {
    stroke: #ef4444 !important;
}

.inv-row-menu-danger:hover {
    background: rgba(239, 68, 68, 0.06);
}

/* Empty state */
.inv-empty-td {
    padding: 2.5rem 1rem !important;
}

.inv-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-muted);
}

.inv-empty svg {
    width: 24px;
    height: 24px;
    opacity: 0.3;
}

html:not(.dark-mode) .inv-empty svg {
    stroke: #9ca3af;
}

html.dark-mode .inv-empty svg {
    stroke: #6b7280;
}

.inv-empty span {
    font-size: 0.78rem;
}



/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-primary);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1.75rem;
    max-width: 780px;
    width: 92%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
}

.modal-content.vehicle-modal-content {
    max-width: 560px;
}

.dark-mode .modal-content {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

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

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    font-weight: 600;
}

.close-btn {
    /* background: var(--hover-bg);
    border: 1px solid var(--card-border);
    width: 36px;
    height: 36px;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center; */
    background: white !important;
    color: #0a0a0a !important;
    border: 1px solid #141515 !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.close-btn:hover {
    background: rgba(220, 38, 38, 0.1) !important;
    color: #dc2626 !important;
    border-color: #dc2626 !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.close-btn:hover svg {
    stroke: #f61414;
}

.dark-mode .close-btn {
    background: #2d3748 !important;
    color: #ffffff !important;
    border-color: #ffffff !important;
}

body.dark-mode .close-btn:hover,
.dark-mode .close-btn:hover {
    background: rgba(220, 38, 38, 0.1) !important;
    color: #f87171 !important;
    border-color: #dc2626 !important;
}

/* body.dark-mode .close-btn:hover svg,
.dark-mode .close-btn:hover svg {
    stroke: #000000;
} */

/* Profile Details */
.profile-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.detail-item {
    background: var(--bg-secondary);
    padding: 1.25rem;
    border-radius: 2px;
    border: 1px solid var(--card-border);
}

.detail-label {
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.detail-value {
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 600;
}

/* Color del precio de venta según el modo */
html:not(.dark-mode) .detail-value.highlight {
    color: #000000;
}

html.dark-mode .detail-value.highlight {
    color: #ffffff;
}

/* Summary Card (compact vehicle modal) */
.summary-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.summary-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.summary-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.summary-cell {
    text-align: center;
    padding: 0.7rem;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.summary-cell-bordered {
    background: transparent;
    border: 1px solid var(--card-border);
}

.summary-cell-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
    font-weight: 500;
}

.summary-cell-value {
    font-weight: 700;
    font-size: 0.95rem;
}

.summary-profit {
    padding: 0.8rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.summary-grid-dates {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.summary-date-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.summary-date-item strong {
    color: var(--text-primary);
    font-weight: 600;
}

.summary-client-card {
    padding: 1rem;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.summary-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--text-primary);
    color: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    overflow: hidden;
    flex-shrink: 0;
}

.summary-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.summary-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.action-row-top {
    display: flex;
    gap: 0.5rem;
}

.action-row-top .action-btn {
    flex: 1;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 0.85rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s ease;
    border: 1.5px solid var(--card-border);
    font-family: inherit;
    white-space: nowrap;
}

.action-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.action-btn-outline {
    background: transparent;
    color: var(--text-primary);
}

.action-btn-outline:hover {
    background: var(--hover-bg);
    border-color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.action-btn-solid {
    background: var(--text-primary);
    color: var(--bg-primary);
    border-color: var(--text-primary);
}

.action-btn-solid:hover {
    opacity: 0.88;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.action-btn-full {
    width: 100%;
}

/* Stats Tabs */
.stats-tabs-container {
    margin-bottom: 2rem;
}

.stats-tabs {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-secondary);
    padding: 0.5rem;
    border-radius: 12px;
    border: 1px solid var(--card-border);
}

.stats-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.stats-tab svg {
    width: 18px;
    height: 18px;
    transition: transform 0.2s ease;
}

.stats-tab:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.stats-tab.active {
    background: var(--card-bg);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.stats-tab.active svg {
    transform: scale(1.1);
}

.stats-tab-content {
    animation: fadeIn 0.3s ease;
}

.stats-tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Charts Row for Client Stats */
.charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.chart-card {
    padding: 2rem;
    position: relative;
    min-height: 350px;
}

.chart-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    color: var(--text-primary);
    font-weight: 600;
}

.chart-title svg {
    width: 24px;
    height: 24px;
    stroke: var(--text-primary);
}

.chart-card canvas {
    max-height: 300px !important;
    width: 100% !important;
    display: block !important;
}

@media (max-width: 768px) {
    .charts-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .chart-card {
        padding: 1.5rem;
        min-height: 300px;
    }

    .chart-card canvas {
        max-height: 250px;
    }
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 2rem;
}

/* Top Car Indicator Compact */
.top-car-indicator-compact {
    margin-bottom: 2rem;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, var(--card-bg) 0%, var(--bg-secondary) 100%);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: all 0.25s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.top-car-indicator-compact::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--profit-positive), transparent);
    opacity: 0.5;
}

.top-car-indicator-compact:hover {
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 168, 107, 0.3);
}

.dark-mode .top-car-indicator-compact {
    background: linear-gradient(135deg, var(--card-bg) 0%, #1f1f1f 100%);
}

.dark-mode .top-car-indicator-compact:hover {
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
    border-color: rgba(0, 168, 107, 0.25);
}

.top-car-indicator-thumb {
    width: 86px;
    height: 66px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--card-border);
}

.top-car-indicator-thumb-placeholder {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.top-car-indicator-thumb-placeholder svg {
    width: 22px;
    height: 22px;
}

.top-car-indicator-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(0, 168, 107, 0.08);
    border-radius: 8px;
    flex-shrink: 0;
    color: var(--profit-positive);
}

.dark-mode .top-car-indicator-icon {
    background: rgba(0, 168, 107, 0.12);
}

.top-car-indicator-icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.top-car-indicator-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.top-car-indicator-label {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.top-car-indicator-title {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--profit-positive);
}

.top-car-indicator-vehicle {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.top-car-indicator-matricula {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
}

.top-car-indicator-stats {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-left: auto;
}

.top-car-indicator-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    padding: 0.45rem 0.7rem;
    background: var(--bg-secondary);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    min-width: 68px;
}

.dark-mode .top-car-indicator-stat {
    background: rgba(255, 255, 255, 0.04);
}

.top-car-indicator-stat-label {
    font-size: 0.58rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.top-car-indicator-stat-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.top-car-indicator-stat-value.profit {
    color: var(--profit-positive);
}

.top-car-indicator-stat-value.days {
    color: var(--text-secondary);
}

.top-car-indicator-badge {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.65rem;
    background: rgba(0, 168, 107, 0.08);
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--profit-positive);
}

.dark-mode .top-car-indicator-badge {
    background: rgba(0, 168, 107, 0.12);
}

.top-car-indicator-badge svg {
    width: 12px;
    height: 12px;
}

.top-car-indicator-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.top-car-indicator-link {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.4rem 0.7rem;
    border-radius: 8px;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.top-car-indicator-link:hover {
    color: var(--profit-positive);
    background: rgba(0, 168, 107, 0.06);
}

.top-car-indicator-link svg {
    width: 14px;
    height: 14px;
}

@media (max-width: 1400px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .stats-tabs {
        flex-direction: column;
        gap: 0.25rem;
    }

    .stats-tab {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    .stats-tab span {
        font-size: 0.875rem;
    }
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--text-muted);
}

.stat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.stat-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--hover-bg);
    border-radius: 8px;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.stat-icon svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-primary);
    stroke-width: 2;
}

.stat-icon.profit-positive {
    background: rgba(0, 168, 107, 0.1);
}

.stat-icon.profit-positive svg {
    stroke: var(--profit-positive);
}

.stat-icon.profit-negative {
    background: rgba(220, 20, 60, 0.1);
}

.stat-icon.profit-negative svg {
    stroke: var(--profit-negative);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    line-height: 1.2;
}

.stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.stat-breakdown {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.stat-detail {
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.4;
    opacity: 0.9;
}

.stat-footer {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--card-border);
}

.stat-detail {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.stat-detail.text-muted {
    color: var(--text-muted);
}

.stat-detail.profit-positive {
    color: var(--profit-positive);
    font-weight: 500;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty-state-icon {
    margin-bottom: 1rem;
    opacity: 0.4;
    display: flex;
    justify-content: center;
}

.empty-state-icon svg {
    width: 60px;
    height: 60px;
    stroke: var(--text-muted);
}

.empty-state-text {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--card-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Sidebar Scrollbar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--card-border);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Filter Section */
/* Filters Section */
.filters-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.filters-search-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.search-group {
    position: relative;
    flex: 1;
}

.search-group .search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    stroke: var(--text-muted);
    pointer-events: none;
}

.search-group input {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    background: var(--bg-primary);
    border: 1.5px solid var(--card-border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-group input::placeholder {
    color: var(--text-muted, #aaa);
    font-weight: 400;
}

.search-group input:hover {
    border-color: var(--text-muted, #999);
}

.search-group input:focus {
    outline: none;
    border-color: #000000;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.dark-mode .search-group input:focus {
    border-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.btn-filter-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    background: var(--bg-primary);
    border: 1.5px solid var(--card-border);
    border-radius: 10px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-filter-clear:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
    background: var(--hover-bg);
}

.btn-filter-clear svg {
    width: 15px;
    height: 15px;
}

.filters-selects-row {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-pill {
    flex: 1 1 0;
    min-width: 110px;
}

.filter-pill select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding: 0.45rem 2rem 0.45rem 0.7rem;
    background: var(--bg-primary);
    border: 1.5px solid var(--card-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.filter-pill select:hover {
    border-color: var(--text-muted, #999);
}

.filter-pill select:focus {
    outline: none;
    border-color: #000000;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.06);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23000000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

.dark-mode .filter-pill select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

.dark-mode .filter-pill select:focus {
    border-color: #ffffff;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

.filters-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.results-count {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 1024px) {
    .container {
        padding: 1.5rem;
        padding-left: 5rem;
    }

    .menu-toggle {
        top: 0.75rem;
        left: 0.75rem;
    }

    .dark-mode-toggle {
        top: 0.75rem;
        right: 0.75rem;
    }

    .card {
        padding: 1.5rem;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .card-header .btn-primary {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
        padding-left: 1rem;
        padding-top: 4rem;
    }

    .header {
        margin-bottom: 2rem;
    }

    .menu-toggle {
        top: 0.5rem;
        left: 0.5rem;
        width: 44px;
        height: 44px;
    }

    .menu-toggle svg {
        width: 22px;
        height: 22px;
    }

    .dark-mode-toggle {
        top: 0.5rem;
        right: 0.5rem;
        padding: 0.65rem 0.8rem;
    }

    .sidebar {
        width: 260px;
        left: -260px;
    }

    .header-logo {
        flex-direction: column;
        gap: 0.5rem;
    }

    .header-logo img {
        width: 40px;
        height: 40px;
    }

    .header h1 {
        font-size: 1.75rem;
    }

    .header p {
        font-size: 0.85rem;
        padding: 0 1rem;
    }


    .card {
        padding: 1.25rem;
    }

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

    .card-title svg {
        width: 20px;
        height: 20px;
    }

    .collapse-btn svg {
        width: 20px;
        height: 20px;
    }

    .collapse-hint {
        font-size: 0.7rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .top-car-indicator-compact {
        padding: 1rem;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .top-car-indicator-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        width: 100%;
    }

    .top-car-indicator-stats {
        gap: 0.4rem;
        margin-left: 0;
        width: 100%;
    }

    .top-car-indicator-stat {
        flex: 1;
        min-width: 0;
    }

    .top-car-indicator-thumb,
    .top-car-indicator-thumb-placeholder {
        width: 44px;
        height: 44px;
        border-radius: 8px;
    }

    .top-car-indicator-icon {
        width: 32px;
        height: 32px;
    }

    .top-car-indicator-icon svg {
        width: 16px;
        height: 16px;
    }

    .top-car-indicator-vehicle {
        font-size: 0.95rem;
    }

    .top-car-indicator-link {
        width: 100%;
        justify-content: center;
    }

    .form-group {
        width: 100%;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .btn {
        padding: 0.65rem 1.25rem;
        font-size: 0.8rem;
    }

    /* Recambios section responsive */
    .recambios-input-group {
        flex-direction: column;
        gap: 0.75rem;
    }

    .recambio-nombre,
    .recambio-precio {
        flex: none;
        width: 100%;
    }

    .recambio-btn {
        width: 100%;
        justify-content: center;
    }

    #recambiosContainer {
        max-width: 100%;
        overflow-x: hidden;
    }

    #recambiosContainer>div {
        flex-direction: column;
        gap: 0.5rem;
    }

    #recambiosContainer button {
        width: 100%;
    }

    .btn-text {
        display: inline;
    }

    .modal-content {
        padding: 1.25rem;
        width: 95%;
    }

    .modal-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .modal-header h2 {
        font-size: 1.1rem;
        flex: 1;
        min-width: calc(100% - 50px);
    }

    .modal-header h2 svg {
        width: 20px;
        height: 20px;
    }

    .profile-details {
        grid-template-columns: 1fr;
    }

    .summary-grid-3 {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.4rem;
    }

    .summary-grid-dates {
        flex-direction: column;
        gap: 0.4rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .stat-card {
        padding: 1.25rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
    }

    .stat-icon svg {
        width: 18px;
        height: 18px;
    }

    .filters-selects-row {
        flex-direction: column;
    }

    .filter-pill {
        width: 100%;
    }

    .table-container {
        margin-top: 0.5rem;
    }

    .cars-table th,
    .cars-table td {
        padding: 0.5rem;
    }

    .modal-content .btn {
        flex: 1;
        min-width: 140px;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0.75rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .header p {
        font-size: 0.8rem;
    }

    .card {
        padding: 1rem;
        border-radius: 2px;
    }

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

    .form-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .form-group {
        width: 100%;
    }

    .form-group label {
        font-size: 0.7rem;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 0.65rem;
        font-size: 0.8rem;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.75rem;
        gap: 0.4rem;
        width: 100%;
        justify-content: center;
    }

    .btn svg {
        width: 16px;
        height: 16px;
    }

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

    .stat-card {
        padding: 1rem;
    }

    .stat-label {
        font-size: 0.7rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .stat-icon {
        width: 32px;
        height: 32px;
    }

    .stat-icon svg {
        width: 16px;
        height: 16px;
    }

    .stat-detail {
        font-size: 0.75rem;
    }

    .modal-content {
        padding: 1rem;
        width: 98%;
    }

    .modal-header h2 {
        font-size: 1rem;
    }

    .detail-item {
        padding: 1rem;
    }

    .detail-value {
        font-size: 1rem;
    }

    .cars-table {
        min-width: 700px;
    }

    .cars-table th,
    .cars-table td {
        padding: 0.45rem 0.4rem;
    }

    .inv-row-thumb,
    .inv-row-thumb-placeholder {
        width: 28px;
        height: 28px;
    }

    .empty-state {
        padding: 2rem 1rem;
    }

    .empty-state-icon svg {
        width: 45px;
        height: 45px;
    }

    .detail-label {
        font-size: 0.65rem;
    }

    /* Recambios responsive */
    .recambios-input-group {
        flex-direction: column;
        gap: 0.75rem;
    }

    .recambio-nombre,
    .recambio-precio {
        flex: none;
        width: 100%;
    }

    .recambio-btn {
        width: 100%;
        justify-content: center;
    }

    #recambiosContainer {
        max-width: 100%;
        overflow-x: hidden;
    }

    #recambiosContainer>div {
        flex-direction: column;
    }

    #recambiosContainer button {
        width: 100%;
    }

    .filters-selects-row {
        flex-direction: column;
    }

    .filter-pill {
        width: 100%;
    }
}

/* ===============================================
   ALERTS SYSTEM
   =============================================== */

.alerts-section {
    margin-bottom: 2rem;
}

.alert-card {
    border: 1px solid var(--card-border);
    border-radius: 12px;
}

.alert-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.alert-card-title-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.alert-card-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.alert-card-icon svg {
    width: 16px;
    height: 16px;
}

html:not(.dark-mode) .alert-card-icon svg {
    stroke: #374151;
}

html.dark-mode .alert-card-icon svg {
    stroke: #d1d5db;
}

.alert-card-title-text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

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

.alert-card-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
}

.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: 0.75rem;
}

.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--card-border);
    transition: background 0.15s ease;
    position: relative;
}

.alert-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.alert-item:first-child {
    padding-top: 0;
}

.alert-icon {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    flex-shrink: 0;
    background: var(--bg-secondary);
}

.alert-icon svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

html:not(.dark-mode) .alert-icon svg {
    stroke: #6b7280;
}

html.dark-mode .alert-icon svg {
    stroke: #9ca3af;
}

html:not(.dark-mode) .alert-item.alert-info .alert-icon svg {
    stroke: #2196f3;
}

html:not(.dark-mode) .alert-item.alert-warning .alert-icon svg {
    stroke: #f59e0b;
}

html:not(.dark-mode) .alert-item.alert-error .alert-icon svg {
    stroke: #ef4444;
}

html:not(.dark-mode) .alert-item.alert-success .alert-icon svg {
    stroke: #10b981;
}

html.dark-mode .alert-item.alert-info .alert-icon svg {
    stroke: #60a5fa;
}

html.dark-mode .alert-item.alert-warning .alert-icon svg {
    stroke: #fbbf24;
}

html.dark-mode .alert-item.alert-error .alert-icon svg {
    stroke: #f87171;
}

html.dark-mode .alert-item.alert-success .alert-icon svg {
    stroke: #34d399;
}

.alert-vehicle-thumb {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.alert-vehicle-thumb-placeholder svg {
    width: 16px;
    height: 16px;
}

html:not(.dark-mode) .alert-vehicle-thumb-placeholder svg {
    stroke: #6b7280;
}

html.dark-mode .alert-vehicle-thumb-placeholder svg {
    stroke: #9ca3af;
}

.alert-client-thumb {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.alert-client-thumb-initial {
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
}

.alert-meta-item.alert-client-tag {
    background: rgba(37, 99, 235, 0.08);
    padding: 0.2rem 0.45rem;
    border-radius: 6px;
    font-weight: 500;
    color: #2563eb;
}

.alert-meta-item.alert-client-tag svg {
    stroke: #2563eb !important;
}

.dark-mode .alert-meta-item.alert-client-tag {
    background: rgba(96, 165, 250, 0.1);
    color: #60a5fa;
}

.dark-mode .alert-meta-item.alert-client-tag svg {
    stroke: #60a5fa !important;
}

.alert-meta-item.alert-vehicle-tag {
    background: var(--bg-secondary);
    padding: 0.2rem 0.45rem;
    border-radius: 6px;
    font-weight: 500;
}

.alert-item .alert-btn.btn-delete:hover svg {
    stroke: #ef4444 !important;
}

.alert-content {
    flex: 1;
    min-width: 0;
}

.alert-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.alert-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.alert-priority {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.alert-priority.priority-high {
    background: rgba(239, 68, 68, 0.08);
    color: #ef4444;
}

.alert-priority.priority-medium {
    background: rgba(245, 158, 11, 0.08);
    color: #f59e0b;
}

.alert-priority.priority-low {
    background: var(--bg-secondary);
    color: var(--text-muted);
}

.alert-message {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0.5rem;
    white-space: pre-wrap;
}

.alert-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.alert-meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.alert-meta-item svg {
    width: 12px;
    height: 12px;
}

html:not(.dark-mode) .alert-meta-item svg {
    stroke: #374151;
}

html.dark-mode .alert-meta-item svg {
    stroke: #d1d5db;
}

.alert-meta-item.alert-scheduled {
    background: rgba(59, 130, 246, 0.08);
    padding: 0.2rem 0.45rem;
    border-radius: 6px;
    font-weight: 500;
    color: #3b82f6;
}

.alert-meta-item.alert-scheduled svg {
    stroke: #3b82f6 !important;
}

.alert-meta-item.alert-pending {
    background: rgba(245, 158, 11, 0.08);
    padding: 0.2rem 0.45rem;
    border-radius: 6px;
    font-weight: 500;
    color: #f59e0b;
}

.alert-meta-item.alert-pending svg {
    stroke: #f59e0b !important;
}

.alert-meta-item.alert-sent {
    background: rgba(16, 185, 129, 0.08);
    padding: 0.2rem 0.45rem;
    border-radius: 6px;
    font-weight: 500;
    color: #10b981;
}

.alert-meta-item.alert-sent svg {
    stroke: #10b981 !important;
}

.alert-meta-item.alert-comercial {
    background: var(--bg-secondary);
    padding: 0.2rem 0.45rem;
    border-radius: 6px;
    font-weight: 500;
}

.alert-actions {
    display: flex;
    gap: 0.3rem;
    flex-shrink: 0;
}

.alert-btn {
    padding: 0.35rem;
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.alert-btn svg {
    width: 14px;
    height: 14px;
}

html:not(.dark-mode) .alert-btn svg {
    stroke: #374151;
}

html.dark-mode .alert-btn svg {
    stroke: #d1d5db;
}

html:not(.dark-mode) .alert-btn:hover {
    border-color: #111827;
    background: var(--hover-bg);
}

html:not(.dark-mode) .alert-btn:hover svg {
    stroke: #111827;
}

html.dark-mode .alert-btn:hover {
    border-color: #f3f4f6;
    background: var(--hover-bg);
}

html.dark-mode .alert-btn:hover svg {
    stroke: #f3f4f6;
}

.alert-btn.btn-delete:hover {
    border-color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.06);
}

.alert-btn.btn-delete:hover svg {
    stroke: #ef4444 !important;
}

.alert-btn.btn-calendar:hover {
    border-color: #10b981 !important;
}

.alert-btn.btn-calendar:hover svg {
    stroke: #10b981 !important;
}

/* Calendar Modal */
.cal-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.cal-modal-overlay.visible {
    opacity: 1;
}

.cal-modal {
    background: var(--bg-primary);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    width: 92%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    transform: translateY(12px) scale(0.98);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.cal-modal-overlay.visible .cal-modal {
    transform: translateY(0) scale(1);
}

.dark-mode .cal-modal {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

.cal-modal-title-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.cal-modal-icon {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.cal-modal-icon svg {
    width: 15px;
    height: 15px;
}

html:not(.dark-mode) .cal-modal-icon svg {
    stroke: #374151;
}

html.dark-mode .cal-modal-icon svg {
    stroke: #d1d5db;
}

.cal-modal-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.cal-modal-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin: 0.1rem 0 0;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-modal-close {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.cal-modal-close svg {
    width: 13px;
    height: 13px;
}

html:not(.dark-mode) .cal-modal-close svg {
    stroke: #6b7280;
}

html.dark-mode .cal-modal-close svg {
    stroke: #9ca3af;
}

.cal-modal-close:hover {
    background: rgba(239, 68, 68, 0.08);
    border-color: #ef4444;
}

.cal-modal-close:hover svg {
    stroke: #ef4444 !important;
}

.cal-modal-body {
    padding: 0.5rem;
}

.cal-option {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    padding: 0.7rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease;
    font-family: inherit;
    text-align: left;
}

.cal-option:hover {
    background: var(--hover-bg);
}

.cal-option-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    flex-shrink: 0;
}

.cal-option-icon svg {
    width: 18px;
    height: 18px;
}

.cal-icon-apple {
    background: rgba(0, 0, 0, 0.06);
    color: #1d1d1f;
}

.dark-mode .cal-icon-apple {
    background: rgba(255, 255, 255, 0.08);
    color: #e5e7eb;
}

.cal-icon-google {
    background: rgba(66, 133, 244, 0.08);
}

.cal-icon-office {
    background: rgba(0, 120, 212, 0.06);
}

.cal-icon-yahoo {
    background: rgba(96, 1, 210, 0.06);
}

.cal-option-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
}

.cal-option-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}

.cal-option-desc {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.cal-option-arrow {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
    transform: translateX(-4px);
}

html:not(.dark-mode) .cal-option-arrow {
    stroke: #9ca3af;
}

html.dark-mode .cal-option-arrow {
    stroke: #6b7280;
}

.cal-option:hover .cal-option-arrow {
    opacity: 1;
    transform: translateX(0);
}

/* Sidebar Alert Badge */
.sidebar-alert-badge {
    position: absolute;
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 0.35rem;
    background: #f44336;
    color: white;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
}

.sidebar-link {
    position: relative;
}

/* Sidebar Alerts Dropdown Toggle */
.sidebar-alerts-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
}

.sidebar-alerts-toggle .sidebar-alert-badge {
    position: static;
    transform: none;
    margin-left: auto;
    margin-right: 0.25rem;
}

.sidebar-alerts-toggle .sidebar-chevron {
    position: absolute;
    right: 1rem;
    width: 14px;
    height: 14px;
    transition: transform 0.3s ease;
    flex-shrink: 0;
    opacity: 0.5;
}

.sidebar-alerts-toggle:hover .sidebar-chevron {
    opacity: 1;
}

.sidebar-alerts-toggle.active .sidebar-chevron {
    transform: rotate(180deg);
    opacity: 1;
}

/* Sidebar Alerts Dropdown */
.sidebar-alerts-dropdown {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.25s ease,
        padding 0.25s ease;
    opacity: 0;
    padding: 0;
    margin: 0;
}

.sidebar-alerts-dropdown.active {
    max-height: 500px;
    opacity: 1;
    padding: 0.5rem 0;
    margin: 0.25rem 0 0.5rem 0;
}

.sidebar-alerts-dropdown-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Alert notification in menu */
.sidebar-alerts-section {
    margin: 1rem 0;
    padding: 0 1rem;
}

.sidebar-alert-item {
    padding: 0.625rem 0.75rem;
    background: transparent;
    border-left: 2px solid;
    border-radius: 6px;
    margin: 0.125rem 0.5rem;
    font-size: 0.75rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.sidebar-alerts-dropdown .sidebar-alert-item {
    margin: 0.125rem 0.5rem;
}

.sidebar-alert-item:hover {
    background: var(--hover-bg);
    padding-left: 1rem;
}

.sidebar-alert-item.alert-info {
    border-left-color: #2196f3;
}

.sidebar-alert-item.alert-warning {
    border-left-color: #ff9800;
}

.sidebar-alert-item.alert-error {
    border-left-color: #f44336;
}

.sidebar-alert-item.alert-success {
    border-left-color: #4caf50;
}

.sidebar-alert-title {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.813rem;
}

.sidebar-alert-title svg {
    width: 13px;
    height: 13px;
    stroke-width: 2;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-alert-item.alert-info .sidebar-alert-title svg {
    stroke: #2196f3;
}

.sidebar-alert-item.alert-warning .sidebar-alert-title svg {
    stroke: #ff9800;
}

.sidebar-alert-item.alert-error .sidebar-alert-title svg {
    stroke: #f44336;
}

.sidebar-alert-item.alert-success .sidebar-alert-title svg {
    stroke: #4caf50;
}

.sidebar-alert-message {
    color: var(--text-secondary);
    font-size: 0.688rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    opacity: 0.85;
}

/* Empty State */
.alerts-empty {
    text-align: center;
    padding: 1.5rem 1rem;
    color: var(--text-muted);
}

.alerts-empty-icon {
    margin-bottom: 0.5rem;
    opacity: 0.3;
}

.alerts-empty-icon svg {
    width: 28px;
    height: 28px;
    stroke: var(--text-muted);
}

.alerts-empty-text {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================
   Alert Form Modal
   ========================================== */

.alert-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.alert-modal-overlay.visible {
    opacity: 1;
}

.alert-modal {
    background: var(--bg-primary);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    width: 92%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    transform: translateY(12px) scale(0.98);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.alert-modal-overlay.visible .alert-modal {
    transform: translateY(0) scale(1);
}

.dark-mode .alert-modal {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

.alert-modal-title-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.alert-modal-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.alert-modal-icon svg {
    width: 16px;
    height: 16px;
}

html:not(.dark-mode) .alert-modal-icon svg {
    stroke: #374151;
}

html.dark-mode .alert-modal-icon svg {
    stroke: #d1d5db;
}

.alert-modal-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.alert-modal-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin: 0.1rem 0 0;
}

.alert-modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.alert-modal-close svg {
    width: 14px;
    height: 14px;
}

html:not(.dark-mode) .alert-modal-close svg {
    stroke: #6b7280;
}

html.dark-mode .alert-modal-close svg {
    stroke: #9ca3af;
}

.alert-modal-close:hover {
    background: rgba(239, 68, 68, 0.08);
    border-color: #ef4444;
}

.alert-modal-close:hover svg {
    stroke: #ef4444 !important;
}

.alert-modal-body {
    padding: 1.25rem 1.5rem;
}

.alert-form-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.alert-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.alert-form-half {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 180px;
}

.alert-form-full {
    flex: 1 1 100%;
}

.alert-form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.alert-form-group input,
.alert-form-group select,
.alert-form-group textarea {
    border-radius: 8px;
    border: 1.5px solid var(--card-border);
    padding: 0.6rem 0.75rem;
    font-size: 0.85rem;
    font-family: inherit;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.alert-form-group input:focus,
.alert-form-group select:focus,
.alert-form-group textarea:focus {
    outline: none;
    border-color: #000000;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.dark-mode .alert-form-group input:focus,
.dark-mode .alert-form-group select:focus,
.dark-mode .alert-form-group textarea:focus {
    border-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.alert-form-group input::placeholder,
.alert-form-group textarea::placeholder {
    color: var(--text-muted);
}

.alert-form-group textarea {
    resize: vertical;
    min-height: 70px;
}

.alert-form-group small {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.alert-form-divider {
    width: 100%;
    height: 1px;
    background: var(--card-border);
    margin: 0.35rem 0;
}

.alert-form-section-label {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.alert-form-section-label svg {
    width: 13px;
    height: 13px;
}

html:not(.dark-mode) .alert-form-section-label svg {
    stroke: #6b7280;
}

html.dark-mode .alert-form-section-label svg {
    stroke: #9ca3af;
}

/* Alert DateTime Picker */
.alert-datetime-wrapper {
    gap: 0.45rem !important;
}

.alert-datetime-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.alert-quick-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.68rem;
    font-weight: 600;
    font-family: inherit;
    border: 1.5px solid var(--card-border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.alert-quick-btn:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
    background: var(--hover-bg);
}

.alert-quick-btn.active {
    border-color: var(--text-primary);
    background: var(--text-primary);
    color: var(--bg-primary);
}

.alert-datetime-inputs {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.alert-datetime-field {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex: 1;
    border: 1.5px solid var(--card-border);
    border-radius: 8px;
    padding: 0 0.6rem;
    background: var(--bg-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.alert-datetime-field:focus-within {
    border-color: #000;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.dark-mode .alert-datetime-field:focus-within {
    border-color: #fff;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.alert-datetime-field svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

html:not(.dark-mode) .alert-datetime-field svg {
    stroke: #9ca3af;
}

html.dark-mode .alert-datetime-field svg {
    stroke: #6b7280;
}

.alert-datetime-field input {
    border: none !important;
    padding: 0.5rem 0 !important;
    background: transparent !important;
    font-size: 0.82rem;
    color: var(--text-primary);
    width: 100%;
    box-shadow: none !important;
    outline: none;
}

.alert-datetime-field input:focus {
    box-shadow: none !important;
    border: none !important;
}

.alert-datetime-clear {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.alert-datetime-clear svg {
    width: 12px;
    height: 12px;
}

html:not(.dark-mode) .alert-datetime-clear svg {
    stroke: #9ca3af;
}

html.dark-mode .alert-datetime-clear svg {
    stroke: #6b7280;
}

.alert-datetime-clear:hover {
    background: rgba(239, 68, 68, 0.08);
    border-color: #ef4444;
}

.alert-datetime-clear:hover svg {
    stroke: #ef4444 !important;
}

.alert-datetime-hint {
    font-size: 0.68rem;
    color: var(--text-muted);
    transition: color 0.15s ease;
}

.alert-datetime-hint.has-date {
    color: #10b981;
    font-weight: 500;
}

@media (max-width: 520px) {
    .alert-datetime-inputs {
        flex-direction: column;
    }

    .alert-datetime-field {
        width: 100%;
    }
}

.alert-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--card-border);
}

.alert-modal-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1.5px solid transparent;
}

.alert-modal-btn-cancel {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--card-border);
}

.alert-modal-btn-cancel:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.alert-modal-btn-save {
    background: var(--text-primary);
    color: var(--bg-primary);
    border-color: var(--text-primary);
}

.alert-modal-btn-save:hover {
    opacity: 0.85;
}

.alert-modal-btn-save svg {
    width: 14px;
    height: 14px;
    stroke: var(--bg-primary);
}

@media (max-width: 520px) {
    .alert-modal {
        width: 96%;
        max-height: 95vh;
    }

    .alert-modal-header,
    .alert-modal-body,
    .alert-modal-footer {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .alert-form-half {
        flex: 1 1 100%;
        min-width: 0;
    }
}

/* Responsive Alerts */
@media (max-width: 768px) {
    .alert-item {
        flex-direction: column;
        gap: 0.6rem;
    }

    .alert-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* ===============================================
   VEHICLE-SPECIFIC ALERTS
   =============================================== */

.vehicle-alerts-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid var(--card-border);
}

.vehicle-alerts-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.vehicle-alert-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--card-border);
    border-left: 4px solid;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.vehicle-alert-item:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-sm);
}

.vehicle-alert-item.alert-info {
    border-left-color: #2196f3;
}

.vehicle-alert-item.alert-warning {
    border-left-color: #ff9800;
}

.vehicle-alert-item.alert-error {
    border-left-color: #f44336;
}

.vehicle-alert-item.alert-success {
    border-left-color: #4caf50;
}

.vehicle-alert-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

.vehicle-alert-item.alert-info .vehicle-alert-icon {
    background: rgba(33, 150, 243, 0.15);
}

.vehicle-alert-item.alert-info .vehicle-alert-icon svg {
    stroke: #2196f3;
}

.vehicle-alert-item.alert-warning .vehicle-alert-icon {
    background: rgba(255, 152, 0, 0.15);
}

.vehicle-alert-item.alert-warning .vehicle-alert-icon svg {
    stroke: #ff9800;
}

.vehicle-alert-item.alert-error .vehicle-alert-icon {
    background: rgba(244, 67, 54, 0.15);
}

.vehicle-alert-item.alert-error .vehicle-alert-icon svg {
    stroke: #f44336;
}

.vehicle-alert-item.alert-success .vehicle-alert-icon {
    background: rgba(76, 175, 80, 0.15);
}

.vehicle-alert-item.alert-success .vehicle-alert-icon svg {
    stroke: #4caf50;
}

.vehicle-alert-icon svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.5;
}

.vehicle-alert-content {
    flex: 1;
    min-width: 0;
}

.vehicle-alert-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.vehicle-alert-header strong {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.vehicle-alert-content p {
    font-size: 0.813rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.vehicle-alert-delete {
    padding: 0.35rem;
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.vehicle-alert-delete:hover {
    background: rgba(244, 67, 54, 0.1);
    border-color: #f44336;
}

/* Color del icono de eliminar según el modo */
html:not(.dark-mode) .vehicle-alert-delete svg {
    width: 16px;
    height: 16px;
    stroke: #000000;
}

html.dark-mode .vehicle-alert-delete svg {
    width: 16px;
    height: 16px;
    stroke: #ffffff;
}

.vehicle-alert-delete:hover svg {
    stroke: #f44336;
}

@media (max-width: 768px) {
    .vehicle-alert-item {
        flex-direction: column;
        gap: 0.75rem;
    }

    .vehicle-alert-delete {
        align-self: flex-end;
    }
}

/* Vehicle Alert Badge (in table) */
.vehicle-alert-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 0.4rem;
    background: #ff9800;
    color: white;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* Page Header Styles (for añadir-coche.html) */
.page-header {
    text-align: center;
    margin-bottom: 2rem;
    animation: slideDown 0.3s ease;
}

.page-header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1rem;
}

.page-header-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    border-radius: 12px;
}

.page-header-icon svg {
    width: 28px;
    height: 28px;
    stroke: var(--bg-primary);
    stroke-width: 2;
}

.page-header h1 {
    margin-top: 0.5rem;
    font-size: 2rem;
    color: var(--text-primary);
}

.page-header .page-subtitle {
    max-width: 600px;
    margin: 0 auto;
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Alert Container Styles */
.alert-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 400px;
}

.alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-left: 4px solid;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease-out;
}

.alert-success {
    border-left-color: var(--success);
}

.alert-error {
    border-left-color: var(--danger);
}

.alert-warning {
    border-left-color: #ff9800;
}

.alert-info {
    border-left-color: var(--primary);
}

.alert svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.alert-success svg {
    stroke: var(--success);
}

.alert-error svg {
    stroke: var(--danger);
}

.alert-warning svg {
    stroke: #ff9800;
}

.alert-info svg {
    stroke: var(--primary);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

@media (max-width: 768px) {
    .page-header-icon {
        width: 48px;
        height: 48px;
    }

    .page-header-icon svg {
        width: 24px;
        height: 24px;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }

    .alert-container {
        left: 1rem;
        right: 1rem;
        max-width: none;
    }
}

/* ===============================================
   CLIENTES SIDEBAR SECTION
   =============================================== */

.sidebar-clientes-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
}

.sidebar-clientes-toggle .sidebar-chevron {
    position: absolute;
    right: 1rem;
    width: 14px;
    height: 14px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    opacity: 0.5;
}

.sidebar-clientes-toggle:hover .sidebar-chevron {
    opacity: 1;
}

.sidebar-clientes-toggle.active .sidebar-chevron {
    transform: rotate(180deg);
    opacity: 1;
}

.sidebar-clientes-dropdown {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.25s ease,
        padding 0.25s ease;
    opacity: 0;
    padding: 0;
    margin: 0;
}

.sidebar-clientes-dropdown[style*="display: block"],
.sidebar-clientes-dropdown.active {
    max-height: 300px;
    opacity: 1;
    padding: 0.5rem 0;
    margin: 0.25rem 0 0.5rem 0;
}

.dark-mode .sidebar-clientes-dropdown {
    border-left: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-clientes-dropdown:not([style*="display: none"]) {
    border-left: 1px solid rgba(0, 0, 0, 0.05);
}

.sidebar-docs-dropdown,
.sidebar-servicios-dropdown {
    padding: 0.5rem 0;
    margin: 0.25rem 0 0.5rem 0;
    border-left: 1px solid rgba(0, 0, 0, 0.05);
    margin-left: 1.25rem;
}

.dark-mode .sidebar-docs-dropdown,
.dark-mode .sidebar-servicios-dropdown {
    border-left: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-sublink {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem 0.625rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 6px;
    margin: 0.125rem 0.5rem;
    position: relative;
    font-size: 0.875rem;
}

.sidebar-sublink::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 60%;
    background: var(--text-primary);
    border-radius: 0 2px 2px 0;
    transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-sublink:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
    padding-left: 1.75rem;
}

.sidebar-sublink:hover::before {
    width: 3px;
}

.sidebar-sublink.active {
    background-color: var(--hover-bg);
    color: var(--text-primary);
    font-weight: 500;
    padding-left: 1.75rem;
}

.sidebar-sublink.active::before {
    width: 3px;
}

.sidebar-sublink svg {
    width: 16px;
    height: 16px;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.sidebar-sublink:hover svg,
.sidebar-sublink.active svg {
    opacity: 1;
}

.sidebar-count {
    margin-left: auto;
    background: var(--text-muted);
    color: var(--bg-primary);
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
    transition: all 0.2s ease;
}

.sidebar-sublink:hover .sidebar-count,
.sidebar-sublink.active .sidebar-count {
    background: var(--text-primary);
    transform: scale(1.05);
}

.dark-mode .sidebar-count {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

.dark-mode .sidebar-sublink:hover .sidebar-count,
.dark-mode .sidebar-sublink.active .sidebar-count {
    background: rgba(255, 255, 255, 0.3);
}

/* Alert Badge Styles */
.sidebar-alert-badge {
    background: #ff4444 !important;
    color: white !important;
    animation: pulse-badge 2s infinite;
}

.sidebar-alert-badge:empty,
.sidebar-alert-badge[data-count="0"] {
    display: none;
}

@keyframes pulse-badge {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.7);
    }

    50% {
        box-shadow: 0 0 0 4px rgba(255, 68, 68, 0);
    }
}

.sidebar-link:hover .sidebar-alert-badge {
    background: #ff2222 !important;
    transform: scale(1.1);
}

.dark-mode .sidebar-alert-badge {
    background: #ff4444 !important;
    color: white !important;
}