/* ============================================
   Vehicle Recon Tracker — Stylesheet
   Industrial / Automotive Aesthetic
   ============================================ */

:root {
    --font-body: 'DM Sans', sans-serif;
    --font-mono: 'Space Mono', monospace;

    --color-bg:       #0f1117;
    --color-surface:  #181b24;
    --color-surface2: #1f2330;
    --color-border:   #2a2e3a;
    --color-border-h: #3a3f50;

    --color-text:     #e4e6ed;
    --color-text-dim: #8b90a0;
    --color-text-inv: #0f1117;

    --color-accent:   #f59e0b;
    --color-accent-h: #fbbf24;

    --color-success:  #22c55e;
    --color-danger:   #ef4444;
    --color-info:     #3b82f6;
    --color-warning:  #f59e0b;

    /* Status Colors */
    --status-unassigned: #64748b;
    --status-service:    #3b82f6;
    --status-parts:      #f59e0b;
    --status-waiting:    #a855f7;
    --status-detail:     #22c55e;
    --status-other:      #6b7280;
    --status-red:        #ef4444;
    --status-teal:       #14b8a6;
    --status-pink:       #ec4899;
    --status-indigo:     #6366f1;

    --radius:    8px;
    --radius-lg: 12px;
    --shadow:    0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
    --transition: 0.2s ease;
}

/* Light Theme */
[data-theme="light"] {
    --color-bg:       #f4f5f7;
    --color-surface:  #ffffff;
    --color-surface2: #eef0f4;
    --color-border:   #d1d5db;
    --color-border-h: #b0b5c0;

    --color-text:     #1a1a2e;
    --color-text-dim: #6b7280;
    --color-text-inv: #ffffff;

    --color-accent:   #d97706;
    --color-accent-h: #b45309;

    --shadow:    0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: var(--color-accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--color-accent-h); }
img { max-width: 100%; }

/* ---- Navigation ---- */
.main-nav {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-inner {
    max-width: 1360px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--color-text) !important;
    letter-spacing: -0.02em;
}
.brand-icon {
    color: var(--color-accent);
    font-size: 1.3rem;
}
.nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.nav-link {
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius);
    color: var(--color-text-dim) !important;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
}
.nav-link:hover, .nav-link.active {
    color: var(--color-text) !important;
    background: var(--color-surface2);
}
.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: 1rem;
    padding-left: 1rem;
    border-left: 1px solid var(--color-border);
}
.nav-user-name { font-weight: 600; font-size: 0.88rem; }
.nav-user-role {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-accent);
    font-family: var(--font-mono);
}
.nav-dropdown {
    position: relative;
}
.nav-dropdown-toggle {
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius);
    color: var(--color-text-dim) !important;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
    background: none;
    border: none;
    font-family: var(--font-body);
}
.nav-dropdown-toggle:hover, .nav-dropdown.open .nav-dropdown-toggle {
    color: var(--color-text) !important;
    background: var(--color-surface2);
}
.nav-dropdown-toggle::after {
    content: ' ▾';
    font-size: 0.7rem;
    opacity: 0.6;
}
.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.3rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    z-index: 150;
    padding: 0.35rem 0;
}
.nav-dropdown.open .nav-dropdown-menu {
    display: block;
}
.nav-dropdown-menu a {
    display: block;
    padding: 0.45rem 1rem;
    color: var(--color-text-dim) !important;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all var(--transition);
    text-decoration: none;
}
.nav-dropdown-menu a:hover, .nav-dropdown-menu a.active {
    color: var(--color-text) !important;
    background: var(--color-surface2);
}
.nav-toggle {
    display: none;
    background: none;
    border: 1px solid var(--color-border);
    color: var(--color-text);
    font-size: 1.3rem;
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius);
    cursor: pointer;
}

/* ---- Container ---- */
.container {
    max-width: 1360px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    flex: 1;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: var(--color-accent);
    color: var(--color-text-inv);
}
.btn-primary:hover { background: var(--color-accent-h); color: var(--color-text-inv); }

.btn-secondary {
    background: var(--color-surface2);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}
.btn-secondary:hover { border-color: var(--color-border-h); background: var(--color-border); }

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}
.btn-danger:hover { background: #dc2626; color: #fff; }

.btn-outline {
    background: transparent;
    color: var(--color-text-dim);
    border: 1px solid var(--color-border);
}
.btn-outline:hover { color: var(--color-text); border-color: var(--color-border-h); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---- Forms ---- */
.form-group {
    margin-bottom: 1.25rem;
}
.form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-dim);
    font-family: var(--font-mono);
}
.form-control {
    width: 100%;
    padding: 0.65rem 0.9rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}
.form-control::placeholder { color: var(--color-text-dim); opacity: 0.6; }

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b90a0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.25rem;
}
textarea.form-control { resize: vertical; min-height: 80px; }

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

/* ---- Cards ---- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h2, .card-header h3 {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.card-body { padding: 1.5rem; }

/* ---- Alerts ---- */
.alert {
    padding: 0.85rem 1.2rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    border: 1px solid;
}
.alert-success { background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.25); color: var(--color-success); }
.alert-danger  { background: rgba(239,68,68,0.1);  border-color: rgba(239,68,68,0.25);  color: var(--color-danger); }
.alert-info    { background: rgba(59,130,246,0.1);  border-color: rgba(59,130,246,0.25); color: var(--color-info); }
.alert-warning { background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.25); color: var(--color-warning); }

/* ---- Status Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.7rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.badge-unassigned, .badge-slate  { background: rgba(100,116,139,0.15); color: var(--status-unassigned); }
.badge-service, .badge-blue      { background: rgba(59,130,246,0.15);   color: var(--status-service); }
.badge-parts, .badge-amber       { background: rgba(245,158,11,0.15);   color: var(--status-parts); }
.badge-waiting, .badge-purple    { background: rgba(168,85,247,0.15);   color: var(--status-waiting); }
.badge-detail, .badge-green      { background: rgba(34,197,94,0.15);    color: var(--status-detail); }
.badge-other, .badge-gray        { background: rgba(107,114,128,0.15);  color: var(--status-other); }
.badge-red    { background: rgba(239,68,68,0.15);  color: var(--status-red); }
.badge-teal   { background: rgba(20,184,166,0.15); color: var(--status-teal); }
.badge-pink   { background: rgba(236,72,153,0.15); color: var(--status-pink); }
.badge-indigo { background: rgba(99,102,241,0.15); color: var(--status-indigo); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
}
th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-dim);
    font-family: var(--font-mono);
    font-weight: 700;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface2);
}
td {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}
tr:hover td { background: rgba(245,158,11,0.03); }

.stock-num {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--color-accent);
}
.age-days {
    font-family: var(--font-mono);
    font-weight: 700;
}
.age-warn { color: var(--color-warning); }
.age-crit { color: var(--color-danger); }

/* Overdue target front-line date — distinct purple/magenta pulse */
tr.overdue-target {
    background: rgba(168,85,247,0.06) !important;
    border-left: 3px solid #a855f7;
}
tr.overdue-target td:first-child {
    border-left: 3px solid #a855f7;
}
.overdue-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.68rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: #a855f7;
    background: rgba(168,85,247,0.12);
    padding: 0.1rem 0.45rem;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    animation: overduePulse 2s ease-in-out infinite;
}
@keyframes overduePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.actions-cell { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* ---- Status Group Headers ---- */
.status-group {
    margin-bottom: 2rem;
}
.status-group-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    margin-bottom: 0.5rem;
}
.status-group-header h3 {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 700;
}
.status-group-count {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--color-text-dim);
    background: var(--color-surface2);
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
}

/* ---- Dashboard Stats ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}
.stat-card.stat-total::before    { background: var(--color-accent); }
.stat-card.stat-unassigned::before, .stat-card.stat-slate::before { background: var(--status-unassigned); }
.stat-card.stat-service::before, .stat-card.stat-blue::before   { background: var(--status-service); }
.stat-card.stat-parts::before, .stat-card.stat-amber::before    { background: var(--status-parts); }
.stat-card.stat-waiting::before, .stat-card.stat-purple::before  { background: var(--status-waiting); }
.stat-card.stat-detail::before, .stat-card.stat-green::before   { background: var(--status-detail); }
.stat-card.stat-other::before, .stat-card.stat-gray::before     { background: var(--status-other); }
.stat-card.stat-red::before    { background: var(--status-red); }
.stat-card.stat-teal::before   { background: var(--status-teal); }
.stat-card.stat-pink::before   { background: var(--status-pink); }
.stat-card.stat-indigo::before { background: var(--status-indigo); }

.stat-value {
    font-family: var(--font-mono);
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.35rem;
}
.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-dim);
    font-family: var(--font-mono);
}

/* ---- Toolbar ---- */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.toolbar-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.toolbar-filters { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.toolbar-filters .form-control {
    width: auto;
    min-width: 180px;
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
}

/* ---- Auth Pages ---- */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(245,158,11,0.06) 0%, transparent 50%),
        var(--color-bg);
}
.auth-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 440px;
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}
.auth-brand {
    text-align: center;
    margin-bottom: 2rem;
}
.auth-brand .brand-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
}
.auth-brand h1 {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.auth-brand p {
    font-size: 0.85rem;
    color: var(--color-text-dim);
    margin-top: 0.25rem;
}
.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--color-text-dim);
}

/* ---- Modal ---- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 {
    font-family: var(--font-mono);
    font-weight: 700;
}
.modal-close {
    background: none;
    border: none;
    color: var(--color-text-dim);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 0.25rem;
}
.modal-close:hover { color: var(--color-text); }
.modal-body { padding: 1.5rem; }
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* ---- Notes Section ---- */
.notes-list { margin-top: 1rem; }
.note-item {
    padding: 0.75rem 1rem;
    border-left: 3px solid var(--color-accent);
    background: var(--color-surface2);
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-bottom: 0.75rem;
}
.note-meta {
    font-size: 0.75rem;
    color: var(--color-text-dim);
    font-family: var(--font-mono);
    margin-bottom: 0.3rem;
}
.note-text { font-size: 0.9rem; line-height: 1.5; }

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-text-dim);
}
.empty-state .empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.4;
}
.empty-state p { font-size: 0.95rem; }

/* ---- Toggle switch ---- */
.toggle-wrap {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}
.toggle-wrap > div:last-child {
    flex: 1;
    min-width: 0;
}
.toggle {
    position: relative;
    width: 44px;
    min-width: 44px;
    height: 24px;
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 2px;
}
.toggle input { display: none; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--color-border);
    border-radius: 100px;
    transition: var(--transition);
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--color-text);
    border-radius: 50%;
    transition: var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--color-accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); background: var(--color-text-inv); }

/* ---- Page Header ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.page-header h1 {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.page-header p {
    color: var(--color-text-dim);
    font-size: 0.88rem;
}

/* ---- Footer ---- */
.site-footer {
    border-top: 1px solid var(--color-border);
    padding: 1.25rem 0;
    text-align: center;
    font-size: 0.78rem;
    color: var(--color-text-dim);
    font-family: var(--font-mono);
}
.footer-inner {
    max-width: 1360px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .nav-links { display: none; flex-direction: column; position: absolute; top: 60px; left: 0; right: 0; background: var(--color-surface); border-bottom: 1px solid var(--color-border); padding: 1rem; gap: 0.5rem; }
    .nav-links.open { display: flex; }
    .nav-toggle { display: block; }
    .nav-dropdown { position: static; }
    .nav-dropdown-menu { position: static; margin-top: 0; box-shadow: none; border: none; padding: 0 0 0 1rem; min-width: auto; display: none; }
    .nav-dropdown.open .nav-dropdown-menu { display: block; }
    .nav-dropdown-toggle::after { content: ' ▾'; }
    .nav-user { margin-left: 0; padding-left: 0; border-left: none; flex-direction: column; align-items: flex-start; gap: 0.4rem; padding-top: 0.75rem; border-top: 1px solid var(--color-border); }
    .form-row { grid-template-columns: 1fr; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-actions, .toolbar-filters { flex-direction: column; }
    .toolbar-filters .form-control { min-width: 100%; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .page-header { flex-direction: column; align-items: flex-start; }
    .actions-cell { flex-direction: column; }
}