/* =====================================================================
   FNTStudios Vehicle Manager - Main Stylesheet
   A modern, technological automotive management interface.
   ===================================================================== */

/* ---- CSS Variables / Theme ---- */
:root {
    /* Brand palette — deep teal-blue (automotive, engineering) */
    --primary:        #175e7a;
    --primary-light:  #1e7a9e;
    --primary-dark:   #0f4559;
    --primary-50:     #e8f1f5;
    --primary-100:    #c5dae6;

    --secondary:      #2a9d8f;
    --secondary-light:#3ab8a8;

    --accent:         #e9a23b;
    --accent-light:   #f0bd6a;

    --success:        #2d9e5f;
    --success-50:     #e6f4ec;
    --warning:        #d4881b;
    --warning-50:     #fdf3e3;
    --error:          #c84d4d;
    --error-50:       #fceaea;
    --info:           #3a7bd5;
    --info-50:        #e8f0fc;

    /* Neutral surfaces */
    --bg:             #f0f2f5;
    --bg-subtle:      #e8ebf0;
    --surface:        #ffffff;
    --surface-2:      #f7f8fa;
    --surface-3:      #eef0f4;
    --border:         #dde1e7;
    --border-light:   #eaedf2;

    /* Text */
    --text:           #1a2332;
    --text-secondary: #5a6678;
    --text-muted:     #8a94a6;
    --text-inverse:   #ffffff;

    /* Shadows */
    --shadow-sm:  0 1px 2px rgba(15, 30, 50, 0.06);
    --shadow:     0 2px 8px rgba(15, 30, 50, 0.08);
    --shadow-md:  0 4px 16px rgba(15, 30, 50, 0.1);
    --shadow-lg:  0 8px 32px rgba(15, 30, 50, 0.14);

    /* Radii */
    --radius-sm: 6px;
    --radius:    10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    /* Spacing (8px system) */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 24px;
    --sp-6: 32px;
    --sp-7: 48px;
    --sp-8: 64px;

    /* Transitions */
    --t-fast: 150ms ease;
    --t:      250ms ease;
    --t-slow: 400ms ease;

    /* Layout */
    --sidebar-w: 260px;
    --topbar-h:  64px;

    /* Typography */
    --font-sans: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', Consolas, monospace;
}

/* ---- Dark mode ---- */
[data-theme="dark"] {
    --primary:        #2b8db0;
    --primary-light:  #3da6cc;
    --primary-dark:   #175e7a;
    --primary-50:     #14283a;
    --primary-100:    #1a3550;

    --secondary:      #3ab8a8;
    --secondary-light:#4fd0bf;

    --accent:         #f0bd6a;
    --accent-light:   #f5d095;

    --bg:             #0d1117;
    --bg-subtle:      #161b22;
    --surface:        #161b22;
    --surface-2:      #1c232c;
    --surface-3:      #242c38;
    --border:         #2d3744;
    --border-light:   #1e252e;

    --text:           #e6edf3;
    --text-secondary: #9aa7b8;
    --text-muted:     #6b7585;
    --text-inverse:   #0d1117;

    --shadow-sm:  0 1px 2px rgba(0,0,0,0.2);
    --shadow:     0 2px 8px rgba(0,0,0,0.25);
    --shadow-md:  0 4px 16px rgba(0,0,0,0.3);
    --shadow-lg:  0 8px 32px rgba(0,0,0,0.4);

    --success-50:     #14281e;
    --warning-50:     #2a1f0d;
    --error-50:       #2a1414;
    --info-50:        #0f1d33;
}

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

html { font-size: 16px; }

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5 { line-height: 1.2; font-weight: 700; color: var(--text); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; }

a { color: var(--primary); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--primary-light); }

svg { display: inline-block; vertical-align: middle; }

/* ---- App Layout ---- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform var(--t);
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-4);
    border-bottom: 1px solid var(--border);
    min-height: var(--topbar-h);
}

.brand-logo {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-logo img {
    display: block;
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 0.95rem; color: var(--text); }
.brand-text small { font-size: 0.72rem; color: var(--text-muted); }

.sidebar-search { padding: var(--sp-3) var(--sp-4); }
.search-form {
    display: flex; align-items: center; gap: var(--sp-2);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 6px 14px;
    transition: border-color var(--t-fast);
}
.search-form:focus-within { border-color: var(--primary); }
.search-form .icon { color: var(--text-muted); flex-shrink: 0; }
.search-form input {
    border: none; background: none; outline: none;
    font-size: 0.85rem; color: var(--text); width: 100%;
}

.sidebar-nav { padding: var(--sp-2) var(--sp-2); flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    margin-bottom: 2px;
    transition: all var(--t-fast);
}
.nav-item:hover {
    background: var(--surface-2);
    color: var(--text);
}
.nav-item.active {
    background: var(--primary-50);
    color: var(--primary);
    font-weight: 600;
}
[data-theme="dark"] .nav-item.active { background: var(--primary-100); }
.nav-item .icon { flex-shrink: 0; }
.nav-logout { color: var(--error); }
.nav-logout:hover { background: var(--error-50); color: var(--error); }
.nav-divider { height: 1px; background: var(--border); margin: var(--sp-3) var(--sp-4); }

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
}

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

/* ---- Topbar ---- */
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 var(--sp-5);
    gap: var(--sp-4);
    position: sticky; top: 0;
    z-index: 50;
}
.menu-toggle {
    display: none;
    background: none; border: none; cursor: pointer;
    color: var(--text-secondary); padding: var(--sp-2);
}
.page-title { font-size: 1.15rem; font-weight: 700; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: var(--sp-4); }

.theme-toggle {
    background: none; border: none; cursor: pointer;
    color: var(--text-secondary); padding: var(--sp-2);
    border-radius: var(--radius-sm);
    transition: all var(--t-fast);
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

.user-chip { display: flex; align-items: center; gap: var(--sp-2); }
.user-avatar {
    width: 34px; height: 34px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem;
}
.user-email { font-size: 0.82rem; color: var(--text-secondary); }

/* ---- Content ---- */
.content { flex: 1; padding: var(--sp-5); max-width: 1400px; width: 100%; }

.footer {
    padding: var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--border);
    display: flex; justify-content: space-between;
    font-size: 0.78rem; color: var(--text-muted);
}

/* ---- Flash messages ---- */
.flash {
    position: fixed; top: var(--sp-4); right: var(--sp-4);
    z-index: 1000;
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    display: flex; align-items: center; gap: var(--sp-4);
    animation: slideIn var(--t) ease;
    max-width: 420px;
    font-size: 0.88rem;
    font-weight: 500;
}
.flash-success { background: var(--success); color: #fff; }
.flash-error   { background: var(--error); color: #fff; }
.flash-warning { background: var(--warning); color: #fff; }
.flash-info    { background: var(--info); color: #fff; }
.flash-close {
    background: none; border: none; color: inherit;
    cursor: pointer; font-size: 1.2rem; opacity: 0.8;
}
.flash-close:hover { opacity: 1; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* ---- Cards ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--t), transform var(--t);
}
.card:hover { box-shadow: var(--shadow); }
.card-header {
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 1rem; font-weight: 700; }
.card-body { padding: var(--sp-5); }

/* ---- Grid layouts ---- */
.grid { display: grid; gap: var(--sp-5); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ---- Stat cards ---- */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--sp-5);
    box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column;
    gap: var(--sp-2);
    transition: all var(--t);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--primary);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card .stat-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius);
    background: var(--primary-50);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
}
[data-theme="dark"] .stat-card .stat-icon { background: var(--primary-100); }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 800; color: var(--text); }
.stat-card .stat-label { font-size: 0.82rem; color: var(--text-muted); }
.stat-card.accent::before { background: var(--accent); }
.stat-card.accent .stat-icon { background: var(--warning-50); color: var(--accent); }
.stat-card.success::before { background: var(--success); }
.stat-card.success .stat-icon { background: var(--success-50); color: var(--success); }
.stat-card.info::before { background: var(--info); }
.stat-card.info .stat-icon { background: var(--info-50); color: var(--info); }
.stat-card.error::before { background: var(--error); }
.stat-card.error .stat-icon { background: var(--error-50); color: var(--error); }

/* ---- Badges ---- */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.badge-primary { background: var(--primary-50); color: var(--primary); border-color: transparent; }
[data-theme="dark"] .badge-primary { background: var(--primary-100); }
.badge-accent  { background: var(--warning-50); color: var(--accent); border-color: transparent; }
.badge-success { background: var(--success-50); color: var(--success); border-color: transparent; }
.badge-error   { background: var(--error-50); color: var(--error); border-color: transparent; }
.badge-info    { background: var(--info-50); color: var(--info); border-color: transparent; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; gap: var(--sp-2);
    padding: 9px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--t-fast);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-light); color: #fff; border-color: var(--primary-light); }
.btn-danger { background: var(--error); color: #fff; border-color: var(--error); }
.btn-danger:hover { background: #b04545; color: #fff; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #268a52; color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 0.78rem; }
.btn-icon { padding: 7px; }
.btn-block { width: 100%; justify-content: center; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border); }
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}
.data-table th {
    text-align: left;
    padding: var(--sp-3) var(--sp-4);
    background: var(--surface-2);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
}
.data-table tbody tr { transition: background var(--t-fast); }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ---- Forms ---- */
.form-group { margin-bottom: var(--sp-4); }
.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--sp-2);
}
.form-group .hint { font-size: 0.76rem; color: var(--text-muted); margin-top: 4px; }
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
    outline: none;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-50);
}
[data-theme="dark"] .form-control:focus { box-shadow: 0 0 0 3px var(--primary-100); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--sp-4); }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.form-actions {
    display: flex; gap: var(--sp-3);
    padding-top: var(--sp-4);
    border-top: 1px solid var(--border-light);
    margin-top: var(--sp-4);
}

/* ---- Breadcrumbs ---- */
.breadcrumbs {
    display: flex; align-items: center; gap: var(--sp-2);
    font-size: 0.82rem; margin-bottom: var(--sp-4);
    color: var(--text-muted);
}
.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs a:hover { color: var(--primary); }
.crumb-sep { color: var(--text-muted); }
.crumb-current { color: var(--text); font-weight: 600; }

/* ---- Timeline ---- */
.timeline { position: relative; padding-left: var(--sp-6); }
.timeline::before {
    content: '';
    position: absolute; left: 11px; top: 0; bottom: 0;
    width: 2px;
    background: var(--border);
}
.timeline-year {
    position: relative;
    margin: var(--sp-5) 0 var(--sp-4);
    margin-left: calc(-1 * var(--sp-6));
    padding-left: var(--sp-6);
    font-size: 1.1rem; font-weight: 800;
    color: var(--primary);
}
.timeline-year::before {
    content: '';
    position: absolute; left: 7px; top: 50%;
    width: 10px; height: 10px;
    border-radius: var(--radius-full);
    background: var(--primary);
    transform: translateY(-50%);
}
.timeline-item {
    position: relative;
    margin-bottom: var(--sp-4);
}
.timeline-item::before {
    content: '';
    position: absolute; left: calc(-1 * var(--sp-6) + 8px); top: 12px;
    width: 9px; height: 9px;
    border-radius: var(--radius-full);
    background: var(--surface);
    border: 2px solid var(--primary);
}
.timeline-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--sp-4);
    box-shadow: var(--shadow-sm);
    transition: all var(--t-fast);
}
.timeline-card:hover { box-shadow: var(--shadow); border-color: var(--primary-100); }
.timeline-date {
    font-size: 0.78rem; font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.timeline-title { font-size: 1rem; font-weight: 600; margin-top: 2px; }
.timeline-meta {
    display: flex; flex-wrap: wrap; gap: var(--sp-3);
    margin-top: var(--sp-2);
    font-size: 0.8rem;
    color: var(--text-muted);
}
.timeline-meta span { display: flex; align-items: center; gap: 4px; }
.timeline-amount { font-weight: 700; color: var(--text); }

/* ---- Vehicle cards ---- */
.vehicle-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all var(--t);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}
.vehicle-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-3px); border-color: var(--primary-100); }
.vehicle-photo {
    width: 100%; height: 180px;
    object-fit: cover;
    background: var(--surface-2);
    display: block;
}
.vehicle-photo-placeholder {
    width: 100%; height: 180px;
    background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
}
.vehicle-info { padding: var(--sp-4); }
.vehicle-name { font-size: 1.1rem; font-weight: 700; }
.vehicle-sub { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }
.vehicle-plate {
    display: inline-block;
    margin-top: var(--sp-2);
    padding: 2px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}
.vehicle-stats {
    display: flex; justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    border-top: 1px solid var(--border-light);
    font-size: 0.78rem;
    color: var(--text-muted);
}
.vehicle-stats strong { color: var(--text); display: block; font-size: 0.88rem; }

/* ---- Tabs ---- */
.tabs {
    display: flex; gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: var(--sp-5);
    overflow-x: auto;
}
.tab-link {
    padding: var(--sp-3) var(--sp-4);
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--t-fast);
    white-space: nowrap;
    font-family: inherit;
}
.tab-link:hover { color: var(--text); }
.tab-link.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn var(--t) ease; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---- Detail header ---- */
.detail-header {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--sp-5);
    margin-bottom: var(--sp-5);
    display: flex;
    gap: var(--sp-5);
    align-items: center;
    box-shadow: var(--shadow-sm);
}
.detail-photo {
    width: 180px; height: 180px;
    border-radius: var(--radius);
    object-fit: cover;
    flex-shrink: 0;
    background: var(--surface-2);
}
.detail-photo-placeholder {
    width: 180px; height: 180px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    flex-shrink: 0;
}
.detail-info { flex: 1; }
.detail-info h2 { font-size: 1.5rem; margin-bottom: var(--sp-1); }
.detail-info .sub { color: var(--text-muted); font-size: 0.9rem; margin-bottom: var(--sp-3); }
.detail-meta {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--sp-3);
}
.detail-meta-item { font-size: 0.8rem; }
.detail-meta-item .label { color: var(--text-muted); display: block; }
.detail-meta-item .value { font-weight: 600; color: var(--text); }

/* ---- Empty states ---- */
.empty-state {
    text-align: center;
    padding: var(--sp-7) var(--sp-5);
    color: var(--text-muted);
}
.empty-state .empty-icon {
    width: 64px; height: 64px;
    margin: 0 auto var(--sp-4);
    color: var(--border);
}
.empty-state h3 { color: var(--text-secondary); margin-bottom: var(--sp-2); }
.empty-state p { font-size: 0.88rem; max-width: 400px; margin: 0 auto var(--sp-4); }

/* ---- Login page ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, #0a2f3f 100%);
    padding: var(--sp-5);
    position: relative;
    overflow: hidden;
}
.login-page::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle at 30% 50%, rgba(46, 157, 143, 0.08) 0%, transparent 50%),
                radial-gradient(circle at 70% 80%, rgba(233, 162, 59, 0.06) 0%, transparent 50%);
    animation: bgShift 20s ease-in-out infinite alternate;
}
@keyframes bgShift {
    from { transform: translate(0, 0); }
    to   { transform: translate(50px, 30px); }
}
.login-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--sp-7);
    width: 100%; max-width: 420px;
    z-index: 1;
    animation: cardRise var(--t-slow) ease;
}
@keyframes cardRise {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}
.login-brand {
    text-align: center;
    margin-bottom: var(--sp-6);
}
.login-logo {
    display: block;
    width: min(100%, 240px);
    height: auto;
    margin: 0 auto var(--sp-4);
    object-fit: contain;
}

.login-brand h1 {
    font-size: 1.3rem;
    color: var(--text);
}

.login-brand p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.login-brand p { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }
.login-form .form-group:last-of-type { margin-bottom: var(--sp-5); }

/* ---- Document grid ---- */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--sp-4); }
.doc-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all var(--t-fast);
    display: flex; flex-direction: column;
}
.doc-card:hover { box-shadow: var(--shadow); border-color: var(--primary-100); }
.doc-thumb {
    height: 120px;
    background: var(--surface-2);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-thumb .doc-icon { width: 48px; height: 48px; color: var(--text-muted); }
.doc-info { padding: var(--sp-3); flex: 1; display: flex; flex-direction: column; gap: 4px; }
.doc-info .name { font-size: 0.82rem; font-weight: 600; word-break: break-word; }
.doc-info .meta { font-size: 0.72rem; color: var(--text-muted); }
.doc-actions { display: flex; gap: var(--sp-1); padding: var(--sp-2) var(--sp-3); border-top: 1px solid var(--border-light); }

/* ---- Photo gallery ---- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--sp-3); }
.gallery-item {
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--t-fast);
    position: relative;
}
.gallery-item:hover { transform: scale(1.03); box-shadow: var(--shadow-md); }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; }

/* ---- Progress / bar chart ---- */
.bar-chart { display: flex; flex-direction: column; gap: var(--sp-3); }
.bar-row { display: flex; align-items: center; gap: var(--sp-3); }
.bar-label { width: 120px; font-size: 0.82rem; color: var(--text-secondary); flex-shrink: 0; }
.bar-track { flex: 1; height: 24px; background: var(--surface-2); border-radius: var(--radius-sm); overflow: hidden; }
.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-sm);
    transition: width var(--t-slow) ease;
    display: flex; align-items: center; justify-content: flex-end;
    padding-right: var(--sp-2);
    font-size: 0.72rem; font-weight: 700; color: #fff;
}
.bar-fill.accent { background: linear-gradient(90deg, var(--accent), var(--accent-light)); }
.bar-fill.success { background: linear-gradient(90deg, var(--success), var(--secondary)); }
.bar-value { font-size: 0.82rem; font-weight: 600; width: 80px; text-align: right; }

/* ---- DTC badge ---- */
.dtc-badge {
    display: inline-flex; align-items: center; gap: var(--sp-2);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 700;
    background: var(--error-50);
    color: var(--error);
    border: 1px solid var(--error);
}
.dtc-badge.historico { background: var(--success-50); color: var(--success); border-color: var(--success); }
.dtc-badge.activo { background: var(--error-50); color: var(--error); border-color: var(--error); }

/* ---- Page header actions ---- */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: var(--sp-5);
    flex-wrap: wrap; gap: var(--sp-3);
}
.page-header-actions { display: flex; gap: var(--sp-2); }

/* ---- Filters bar ---- */
.filters-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--sp-4);
    margin-bottom: var(--sp-5);
    display: flex; flex-wrap: wrap; gap: var(--sp-3);
    align-items: flex-end;
}
.filters-bar .form-group { margin-bottom: 0; min-width: 140px; flex: 1; }

/* ---- Inline list utilities ---- */
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.82rem; }
.text-xs { font-size: 0.75rem; }
.font-bold { font-weight: 700; }
.font-mono { font-family: var(--font-mono); }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ---- Invoice line items ---- */
.invoice-lines { margin-top: var(--sp-4); }
.line-item {
    display: grid;
    grid-template-columns: 2fr 1fr 100px 120px 120px 120px 40px;
    gap: var(--sp-2);
    align-items: center;
    padding: var(--sp-2) 0;
    border-bottom: 1px solid var(--border-light);
}
.line-item input, .line-item select {
    padding: 6px 10px; font-size: 0.82rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
}
.line-total { text-align: right; font-weight: 600; font-size: 0.85rem; }
.line-remove {
    background: none; border: none; color: var(--error);
    cursor: pointer; padding: 4px;
    border-radius: var(--radius-sm);
}
.line-remove:hover { background: var(--error-50); }
.invoice-totals {
    display: flex; justify-content: flex-end;
    margin-top: var(--sp-4);
}
.totals-table { min-width: 260px; }
.totals-table .total-row {
    display: flex; justify-content: space-between;
    padding: var(--sp-2) var(--sp-4);
    font-size: 0.88rem;
}
.totals-table .total-row.grand {
    border-top: 2px solid var(--border);
    margin-top: var(--sp-2);
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary);
}

/* ---- Odometer chart ---- */
.odometer-chart {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--sp-5);
    margin-bottom: var(--sp-5);
}
.chart-canvas {
    position: relative;
    height: 260px;
    margin-top: var(--sp-4);
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar.open + .sidebar-overlay { display: block; }
    .main-area { margin-left: 0; }
    .menu-toggle { display: flex; }
    .content { padding: var(--sp-4); }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .detail-header { flex-direction: column; text-align: center; }
    .detail-photo, .detail-photo-placeholder { width: 140px; height: 140px; }
    .topbar { padding: 0 var(--sp-3); }
    .user-email { display: none; }
    .page-title { font-size: 1rem; }
    .form-row { grid-template-columns: 1fr; }
    .form-row-2 { grid-template-columns: 1fr; }
    .line-item {
        grid-template-columns: 1fr;
        gap: var(--sp-1);
        padding: var(--sp-3);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        margin-bottom: var(--sp-2);
    }
    .line-item .line-remove { justify-self: flex-end; }
    .line-total { text-align: left; }
    .data-table thead { display: none; }
    .data-table, .data-table tbody, .data-table tr, .data-table td {
        display: block; width: 100%;
    }
    .data-table tr {
        margin-bottom: var(--sp-3);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        padding: var(--sp-2);
    }
    .data-table td {
        display: flex; justify-content: space-between;
        border: none; padding: 4px var(--sp-2);
        font-size: 0.85rem;
    }
    .data-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.78rem;
    }
    .filters-bar { flex-direction: column; }
    .filters-bar .form-group { width: 100%; }
}

@media (max-width: 480px) {
    .stat-card .stat-value { font-size: 1.3rem; }
    .login-card { padding: var(--sp-5); }
    .grid-auto { grid-template-columns: 1fr; }
}

/* ---- Utility ---- */
.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
