/* =====================================================================
   AutoDealer ERP — Design System (custom CSS only, no framework)
   Palette per brief: sidebar #111827, primary #1E3A8A, secondary #2563EB,
   accent #F59E0B, success #22C55E, danger #EF4444, bg #F8FAFC.
   ===================================================================== */

:root {
    --sidebar: #111827;
    --sidebar-2: #0b111e;
    --primary: #1E3A8A;
    --secondary: #2563EB;
    --accent: #F59E0B;
    --success: #22C55E;
    --danger: #EF4444;
    --violet: #8B5CF6;
    --bg: #F8FAFC;
    --card: #FFFFFF;
    --ink: #0f172a;
    --ink-2: #475569;
    --muted: #94a3b8;
    --line: #e6eaf0;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
    --shadow: 0 10px 30px -12px rgba(15, 23, 42, 0.18);
    --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, 0.28);
    --grad-primary: linear-gradient(135deg, #1E3A8A 0%, #2563EB 100%);
    --grad-accent: linear-gradient(135deg, #F59E0B 0%, #f97316 100%);
    --sans: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

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

html, body { height: 100%; }

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

/* ---------------------------------------------------------------- Shell */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 264px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 22px 22px;
    color: #fff; font-size: 18px; letter-spacing: .2px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-mark {
    width: 38px; height: 38px; border-radius: 11px;
    display: grid; place-items: center;
    background: var(--grad-accent);
    color: #1a1206; font-size: 17px;
    box-shadow: 0 6px 16px -6px rgba(245,158,11,.7);
}
.brand-text { font-weight: 500; }
.brand-text strong { font-weight: 800; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 12px 20px; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 6px; }

.nav-group-label {
    text-transform: uppercase; font-size: 10.5px; letter-spacing: .12em;
    color: #64748b; padding: 16px 12px 8px; font-weight: 700;
}
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 11px;
    color: #cbd5e1; font-weight: 500; font-size: 13.5px;
    position: relative; transition: background .15s, color .15s;
}
.nav-link i { width: 18px; text-align: center; font-size: 15px; opacity: .9; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.is-active {
    background: var(--grad-primary); color: #fff;
    box-shadow: 0 8px 20px -10px rgba(37,99,235,.9);
}
.nav-link.is-soon { opacity: .55; cursor: default; }
.nav-link.is-soon:hover { background: transparent; color: #cbd5e1; }
.soon-tag {
    margin-left: auto; font-style: normal; font-size: 9.5px;
    background: rgba(255,255,255,.08); color: #94a3b8;
    padding: 2px 7px; border-radius: 20px; letter-spacing: .04em;
}

.sidebar-footer { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.06); }
.env-badge {
    font-size: 11px; color: #64748b;
    background: rgba(255,255,255,.04); padding: 6px 10px; border-radius: 8px;
    display: inline-block;
}

.main { flex: 1; margin-left: 264px; display: flex; flex-direction: column; min-width: 0; }

/* -------------------------------------------------------------- Topbar */
.topbar {
    height: 66px; background: rgba(255,255,255,.8);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 16px;
    padding: 0 26px; position: sticky; top: 0; z-index: 30;
}
.topbar-title { font-weight: 700; font-size: 16px; color: var(--ink); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.icon-btn {
    position: relative; width: 40px; height: 40px; border-radius: 11px;
    border: 1px solid var(--line); background: #fff; color: var(--ink-2);
    cursor: pointer; display: grid; place-items: center; font-size: 15px;
    transition: background .15s, box-shadow .15s;
}
.icon-btn:hover { background: var(--bg); box-shadow: var(--shadow-sm); }
.badge-dot {
    position: absolute; top: -4px; right: -4px;
    background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
    min-width: 18px; height: 18px; border-radius: 10px; padding: 0 5px;
    display: grid; place-items: center; border: 2px solid #fff;
}
.menu-toggle { display: none; }

.user-chip {
    display: flex; align-items: center; gap: 10px;
    background: #fff; border: 1px solid var(--line); border-radius: 12px;
    padding: 6px 12px 6px 6px; cursor: pointer; color: var(--ink);
    transition: box-shadow .15s;
}
.user-chip:hover { box-shadow: var(--shadow-sm); }
.avatar {
    width: 30px; height: 30px; border-radius: 9px; background: var(--grad-primary);
    color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 13px;
}
.user-name { font-weight: 600; font-size: 13px; }
.user-chip i { color: var(--muted); font-size: 11px; }

/* Dropdowns */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; top: calc(100% + 10px); min-width: 240px;
    background: #fff; border: 1px solid var(--line); border-radius: 14px;
    box-shadow: var(--shadow-lg); padding: 8px; z-index: 50;
    opacity: 0; visibility: hidden; transform: translateY(-6px);
    transition: opacity .15s, transform .15s, visibility .15s;
}
.dropdown-menu-right { right: 0; }
.dropdown.open .dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-head { font-weight: 700; font-size: 12px; color: var(--ink-2); padding: 8px 10px; }
.dropdown-empty { padding: 16px 10px; color: var(--muted); font-size: 13px; }
.dropdown-link {
    width: 100%; text-align: left; background: none; border: none; cursor: pointer;
    display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 9px;
    color: var(--ink); font-size: 13px; font-family: inherit;
}
.dropdown-link:hover { background: var(--bg); }
.dropdown-foot-form { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.link-btn { background: none; border: none; color: var(--secondary); cursor: pointer; font-size: 12.5px; font-weight: 600; font-family: inherit; padding: 6px 10px; }
.notif-item { padding: 9px 10px; border-radius: 9px; }
.notif-item:hover { background: var(--bg); }
.notif-item strong { display: block; font-size: 13px; }
.notif-item span { color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------- Content */
.content { padding: 26px; max-width: 1400px; width: 100%; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 800; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; }
.page-sub { color: var(--ink-2); margin-top: 3px; font-size: 13.5px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 22px; }
.stat-card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 20px; display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow-sm);
    transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 20px; color: #fff; flex-shrink: 0; }
.icon-blue { background: var(--grad-primary); }
.icon-green { background: linear-gradient(135deg, #16a34a, #22C55E); }
.icon-amber { background: var(--grad-accent); }
.icon-violet { background: linear-gradient(135deg, #7c3aed, #8B5CF6); }
.stat-label { color: var(--ink-2); font-size: 12.5px; font-weight: 600; display: block; }
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -.02em; display: block; margin-top: 2px; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 15px; font-weight: 700; }
.card-body { padding: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 4px; }

/* Activity feed */
.activity-feed { list-style: none; }
.activity-feed li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.activity-feed li:last-child { border-bottom: none; }
.feed-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--secondary); margin-top: 6px; flex-shrink: 0; }
.activity-feed strong { font-size: 13px; }
.feed-action { display: block; color: var(--ink-2); font-size: 12.5px; }
.activity-feed em { color: var(--muted); font-size: 11.5px; font-style: normal; }

/* -------------------------------------------------------------- Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--ink-2); font-weight: 700; padding: 12px 14px; border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table td { padding: 13px 14px; border-bottom: 1px solid var(--line); font-size: 13.5px; vertical-align: middle; }
.table tbody tr:hover { background: #fafbff; }
.table tbody tr:last-child td { border-bottom: none; }
.cell-sub { display: block; color: var(--muted); font-size: 12px; }
.ta-right { text-align: right; } .ta-center { text-align: center; }
.mono { font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
.empty-row { text-align: center; color: var(--muted); padding: 40px 14px; }

/* Pills */
.pill { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; letter-spacing: .01em; }
.pill-available { background: #dcfce7; color: #15803d; }
.pill-reserved { background: #fef3c7; color: #b45309; }
.pill-sold { background: #dbeafe; color: #1d4ed8; }
.pill-in_service { background: #ede9fe; color: #6d28d9; }
.pill-archived { background: #f1f5f9; color: #64748b; }

/* Row actions */
.row-actions { display: inline-flex; gap: 6px; align-items: center; justify-content: flex-end; }
.inline-form { display: inline; }
.icon-action {
    width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
    background: #fff; color: var(--ink-2); display: inline-grid; place-items: center;
    cursor: pointer; font-size: 12.5px; transition: background .15s, color .15s, border-color .15s;
}
.icon-action:hover { background: var(--bg); color: var(--secondary); border-color: #c7d2fe; }
.icon-action.danger:hover { color: var(--danger); border-color: #fecaca; background: #fef2f2; }

/* Pagination */
.pagination { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.page-link {
    min-width: 34px; height: 34px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--line);
    display: grid; place-items: center; font-size: 13px; font-weight: 600; color: var(--ink-2); background: #fff;
}
.page-link:hover { background: var(--bg); }
.page-link.is-active { background: var(--grad-primary); color: #fff; border-color: transparent; }

/* -------------------------------------------------------------- Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 8px; justify-content: center;
    padding: 10px 16px; border-radius: 11px; font-size: 13.5px; font-weight: 600;
    cursor: pointer; border: 1px solid transparent; font-family: inherit;
    transition: transform .12s, box-shadow .15s, background .15s, border-color .15s;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--grad-primary); color: #fff; box-shadow: 0 10px 22px -12px rgba(37,99,235,.9); }
.btn-primary:hover { box-shadow: 0 14px 26px -12px rgba(37,99,235,1); }
.btn-secondary { background: #eef2ff; color: var(--primary); border-color: #dbe3ff; }
.btn-secondary:hover { background: #e2e8ff; }
.btn-ghost { background: #fff; color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-accent { background: var(--grad-accent); color: #1a1206; }

/* -------------------------------------------------------------- Forms */
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea, .filters input, .filters select {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
    font-size: 13.5px; font-family: inherit; color: var(--ink); background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus,
.filters input:focus, .filters select:focus {
    outline: none; border-color: var(--secondary); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.field textarea { resize: vertical; }
.form-footer { display: flex; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }

.filters { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.filters .input-icon { flex: 1; min-width: 220px; }
.filters select { width: auto; min-width: 150px; }

.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; }
.input-icon input { padding-left: 38px; }
.toggle-pw { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--muted); cursor: pointer; }

/* Detail grid */
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px 24px; }
.detail-grid > div { display: flex; flex-direction: column; gap: 3px; }
.dl { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.dv { font-size: 14.5px; font-weight: 600; }
.detail-notes { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.detail-notes p { margin-top: 6px; color: var(--ink-2); }

/* Permission matrix */
.matrix-toolbar { display: flex; gap: 8px; margin-bottom: 14px; }
.table.matrix th, .table.matrix td { padding: 8px 6px; text-align: center; }
.matrix .matrix-mod { text-align: left; white-space: nowrap; font-weight: 600; font-size: 13px; position: sticky; left: 0; background: #fff; }
.matrix .matrix-mod i { color: var(--secondary); margin-right: 6px; }
.matrix-act { font-size: 10px !important; }
.perm-box { width: 17px; height: 17px; accent-color: var(--secondary); cursor: pointer; }
.na { color: #cbd5e1; }

/* Alerts */
.alert { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; font-size: 13.5px; font-weight: 500; margin-bottom: 18px; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-danger { background: #fee2e2; color: #991b1b; }
.alert-info { background: #dbeafe; color: #1e40af; }

.muted { color: var(--muted); }

/* Error pages */
.error-page { text-align: center; padding: 80px 20px; }
.error-code { font-size: 92px; font-weight: 900; letter-spacing: -.04em; background: var(--grad-primary); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1; }
.error-page h1 { margin: 8px 0 6px; font-size: 24px; }
.error-page .btn { margin-top: 20px; }

/* ------------------------------------------------------- Auth / Login */
.auth-body { background:
    radial-gradient(1200px 600px at 10% -10%, rgba(37,99,235,.15), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(245,158,11,.12), transparent 55%),
    var(--bg);
    min-height: 100vh; }
.auth-wrap { display: grid; grid-template-columns: 1.05fr .95fr; min-height: 100vh; }
.auth-hero {
    background: linear-gradient(150deg, #0b1120 0%, #111827 45%, #1E3A8A 130%);
    color: #e2e8f0; display: flex; align-items: center; padding: 60px; position: relative; overflow: hidden;
}
.auth-hero::after {
    content: ''; position: absolute; width: 480px; height: 480px; border-radius: 50%;
    background: radial-gradient(circle, rgba(245,158,11,.22), transparent 70%);
    top: -140px; right: -120px;
}
.auth-hero-inner { position: relative; z-index: 2; max-width: 460px; }
.auth-brand { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 500; margin-bottom: 42px; }
.auth-brand strong { font-weight: 800; }
.auth-hero h1 { font-size: 38px; line-height: 1.15; font-weight: 800; letter-spacing: -.02em; }
.auth-hero p { color: #94a3b8; margin-top: 16px; font-size: 15px; max-width: 400px; }
.auth-illustration { width: 100%; margin-top: 40px; }

.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth-card {
    width: 100%; max-width: 400px; background: rgba(255,255,255,.75);
    backdrop-filter: blur(16px) saturate(160%);
    border: 1px solid rgba(255,255,255,.6); border-radius: 22px;
    padding: 38px 34px; box-shadow: var(--shadow-lg);
}
.auth-card h2 { font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
.auth-card .muted { margin: 4px 0 22px; }
.auth-card .field { margin-bottom: 16px; }
.auth-card .btn-block { margin-top: 8px; padding: 12px; }
.auth-demo {
    margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--line);
    display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted);
}
.auth-demo code { background: #0f172a; color: #e2e8f0; padding: 8px 10px; border-radius: 8px; font-size: 12.5px; }

/* -------------------------------------------------------- Responsive */
.backdrop { display: none; }
@media (max-width: 1100px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } .form-grid, .detail-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .main { margin-left: 0; }
    .menu-toggle { display: grid; }
    .grid-2 { grid-template-columns: 1fr; }
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
    .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 35; }
}
@media (max-width: 560px) {
    .stat-grid, .form-grid, .detail-grid { grid-template-columns: 1fr; }
    .content { padding: 18px; }
    .user-name { display: none; }
}

/* Accessibility */
:focus-visible { outline: 2px solid var(--secondary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
