/* ==========================================================================
   GABS DealerDash — original stylesheet (clean admin look)
   Palette: primary #1E5AAE · accent #7C6FF2 · background #F4F6FA
   ========================================================================== */
:root {
    --primary: #1E5AAE;
    --primary-dk: #17468A;
    --primary-lt: #E8F0FB;
    --accent: #7C6FF2;
    --accent-lt: #EFEDFE;
    --bg: #F4F6FA;
    --surface: #FFFFFF;
    --border: #D8E0EA;
    --text: #26334D;
    --muted: #6B7A95;
    --ok: #2E9E5B;      --ok-lt: #E6F5EC;
    --bad: #D64545;     --bad-lt: #FBEAEA;
    --warn: #C98A0B;    --warn-lt: #FBF2DF;
    --info: #2B8CC9;    --info-lt: #E5F2FA;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(38, 51, 77, .07), 0 4px 14px rgba(38, 51, 77, .06);
    --shadow-lg: 0 10px 40px rgba(38, 51, 77, .18);
    --sidebar-w: 250px;
    --topbar-h: 60px;
    --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body {
    margin: 0; font-family: var(--font); color: var(--text);
    background: var(--bg); -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dk); }
h1, h2, h3, h4 { margin: 0; font-weight: 650; }
.ico { width: 20px; height: 20px; flex: 0 0 auto; }
code { background: var(--primary-lt); border-radius: 4px; padding: 1px 6px; font-size: .85em; }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w); background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0;
    z-index: 60; transition: transform .25s ease;
}
.app-main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.brand { display: flex; align-items: center; gap: 10px; padding: 16px 20px; }
.brand-mark {
    width: 36px; height: 36px; border-radius: 9px; background: var(--primary);
    color: #fff; display: inline-flex; align-items: center; justify-content: center;
}
.brand-mark .ico { width: 22px; height: 22px; }
.brand-text { font-weight: 800; font-size: 1.05rem; letter-spacing: .2px; color: var(--text); }
.brand-text em { font-style: normal; color: var(--accent); font-weight: 600; margin-left: 5px; }
.brand.light .brand-text { color: #fff; }

.menu { flex: 1; padding: 8px 12px; overflow-y: auto; }
.menu-item {
    display: flex; align-items: center; gap: 11px; padding: 9px 12px; margin: 2px 0;
    border-radius: 8px; color: var(--muted); font-weight: 550; font-size: .93rem;
}
.menu-item:hover { background: var(--bg); color: var(--text); }
.menu-item.active { background: var(--primary); color: #fff; box-shadow: 0 3px 10px rgba(30, 90, 174, .35); }
.sidebar-foot { padding: 14px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--accent-lt); color: var(--accent);
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-meta strong { font-size: .88rem; }
.user-meta small { color: var(--muted); font-size: .75rem; overflow: hidden; text-overflow: ellipsis; }

.topbar {
    height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px; padding: 0 20px; position: sticky; top: 0; z-index: 40;
}
.topbar-title { font-size: 1.1rem; flex: 1; }
.topbar-right { display: flex; gap: 10px; align-items: center; }
.chip { background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-size: .8rem; color: var(--muted); }

.content { padding: 22px; flex: 1; padding-bottom: 90px; }

/* ---------- Cards / KPI ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: .98rem; }
.card-body { padding: 16px 18px; }
.card-body.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); }
.grid-2 { grid-template-columns: 1fr 1fr; }
.kpi { display: flex; gap: 14px; align-items: center; padding: 18px; }
.kpi-ico { width: 44px; height: 44px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; }
.kpi-ico .ico { width: 22px; height: 22px; }
.kpi-ico.c1 { background: var(--primary-lt); color: var(--primary); }
.kpi-ico.c2 { background: var(--accent-lt); color: var(--accent); }
.kpi-ico.c3 { background: var(--warn-lt); color: var(--warn); }
.kpi-ico.c4 { background: var(--ok-lt); color: var(--ok); }
.kpi-ico.c5 { background: var(--info-lt); color: var(--info); }
.kpi-label { color: var(--muted); font-size: .8rem; font-weight: 550; }
.kpi-value { font-size: 1.45rem; font-weight: 750; line-height: 1.2; }
.kpi-sub { color: var(--muted); font-size: .78rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th {
    text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .4px;
    color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--border); background: #FAFBFD; white-space: nowrap;
}
.tbl td { padding: 11px 14px; border-bottom: 1px solid #EDF1F7; vertical-align: middle; }
.tbl tbody tr:hover { background: #F8FAFD; }
.tbl .actions { display: flex; gap: 6px; justify-content: flex-end; }
.sub { color: var(--muted); font-size: .78rem; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 650; white-space: nowrap; }
.b-ok     { background: var(--ok-lt);     color: var(--ok); }
.b-bad    { background: var(--bad-lt);    color: var(--bad); }
.b-warn   { background: var(--warn-lt);   color: var(--warn); }
.b-info   { background: var(--info-lt);   color: var(--info); }
.b-accent { background: var(--accent-lt); color: var(--accent); }
.b-muted  { background: #EAEDF3;          color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); border-radius: 8px; padding: 8px 14px;
    font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn .ico { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dk); border-color: var(--primary-dk); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(.95); }
.btn-danger { background: var(--bad-lt); border-color: transparent; color: var(--bad); }
.btn-danger:hover { background: #F6DCDC; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 5px 9px; font-size: .8rem; border-radius: 7px; }
.btn-lg { padding: 12px 18px; font-size: .95rem; }
.btn-block { width: 100%; justify-content: center; }
.icon-btn {
    border: none; background: transparent; cursor: pointer; color: var(--muted);
    width: 36px; height: 36px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: .8rem; font-weight: 650; color: var(--muted); margin-bottom: 5px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
    width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
    font: inherit; color: var(--text); background: var(--surface); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30, 90, 174, .13); }
textarea { resize: vertical; min-height: 90px; }
.form-grid { display: grid; gap: 0 16px; grid-template-columns: 1fr 1fr; }
.check-row { display: flex; gap: 8px; align-items: center; margin: 10px 0 16px; font-size: .88rem; color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.filters .field { margin: 0; min-width: 130px; flex: 0 1 170px; }
.filters .field.grow { flex: 1 1 220px; }
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; font-size: .88rem; }
.alert-bad { background: var(--bad-lt); color: var(--bad); }
.alert-ok { background: var(--ok-lt); color: var(--ok); }

/* ---------- Page toolbar ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 1.15rem; }
.page-head .hint { color: var(--muted); font-size: .85rem; }

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(24, 33, 54, .5); z-index: 90;
    display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal-backdrop[hidden] { display: none; }
.modal {
    background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg);
    width: 100%; max-width: 560px; animation: pop .18s ease;
}
.modal.wide { max-width: 780px; }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 1rem; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* ---------- Offcanvas (master data) ---------- */
.offcanvas {
    position: fixed; top: 0; right: 0; bottom: 0; width: 420px; max-width: 92vw; z-index: 95;
    background: var(--surface); box-shadow: var(--shadow-lg); transform: translateX(105%); transition: transform .25s ease;
    display: flex; flex-direction: column;
}
.offcanvas.open { transform: translateX(0); }
.offcanvas[hidden] { display: none; }
.offcanvas-backdrop { position: fixed; inset: 0; background: rgba(24, 33, 54, .4); z-index: 94; }
.offcanvas-backdrop[hidden] { display: none; }
.offcanvas-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.offcanvas-body { padding: 18px 20px; overflow-y: auto; flex: 1; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab {
    padding: 8px 15px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
    color: var(--muted); font-size: .86rem; font-weight: 600; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Toasts ---------- */
.toast-stack { position: fixed; top: 18px; right: 18px; z-index: 120; display: flex; flex-direction: column; gap: 10px; }
.toast {
    background: var(--surface); border-left: 4px solid var(--ok); border-radius: 8px; box-shadow: var(--shadow-lg);
    padding: 12px 16px; font-size: .88rem; font-weight: 550; min-width: 240px; animation: slidein .2s ease;
}
.toast.t-bad { border-left-color: var(--bad); }
.toast.t-info { border-left-color: var(--info); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }

/* ---------- Confirm dialog (sweetalert-style) ---------- */
.confirm-box { max-width: 400px; text-align: center; padding: 26px 24px; }
.confirm-ico { width: 58px; height: 58px; border-radius: 50%; background: var(--warn-lt); color: var(--warn); display: inline-flex; align-items: center; justify-content: center; font-size: 1.6rem; margin-bottom: 12px; }
.confirm-ico.bad { background: var(--bad-lt); color: var(--bad); }
.confirm-box h3 { margin-bottom: 8px; }
.confirm-box p { color: var(--muted); font-size: .9rem; margin: 0 0 18px; }
.confirm-btns { display: flex; gap: 10px; justify-content: center; }

/* ---------- Chat widget ---------- */
.chat-fab {
    position: fixed; right: 20px; bottom: 20px; z-index: 80; width: 52px; height: 52px; border-radius: 50%;
    background: var(--accent); color: #fff; border: none; cursor: pointer; box-shadow: var(--shadow-lg);
    display: flex; align-items: center; justify-content: center; transition: transform .15s ease;
}
.chat-fab:hover { transform: scale(1.07); }
.chat-fab .ico { width: 24px; height: 24px; }
.chat-panel {
    position: fixed; right: 20px; bottom: 84px; z-index: 85; width: 340px; max-width: calc(100vw - 32px);
    height: 440px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--border);
}
.chat-panel[hidden] { display: none; }
.chat-fab[hidden] { display: none; }
.chat-head { background: var(--accent); color: #fff; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; }
.chat-title { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: .9rem; }
.chat-head .icon-btn { color: #fff; }
.chat-head .icon-btn:hover { background: rgba(255,255,255,.15); color: #fff; }
.chat-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.chat-msg { max-width: 82%; padding: 9px 12px; border-radius: 12px; font-size: .85rem; line-height: 1.45; white-space: pre-wrap; }
.chat-msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.chat-form input { flex: 1; }

/* ---------- Login ---------- */
.login-body { display: flex; align-items: stretch; min-height: 100vh; }
.login-wrap { display: grid; grid-template-columns: 1.1fr 1fr; width: 100%; min-height: 100vh; }
.login-hero { position: relative; overflow: hidden; background: #101B33; color: #fff; display: flex; align-items: center; }
.hero-inner { position: relative; z-index: 2; padding: 48px; max-width: 520px; }
.hero-inner h2 { font-size: 2rem; margin: 26px 0 12px; }
.hero-inner p { color: #B9C4D8; line-height: 1.6; }
.hero-points { list-style: none; padding: 0; margin: 26px 0 0; display: flex; flex-direction: column; gap: 12px; }
.hero-points li { display: flex; gap: 10px; align-items: center; color: #D8E1F0; font-size: .93rem; }
.hero-points .ico { color: #6FDCA0; }
.blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; }
.blob-a { width: 420px; height: 420px; background: var(--accent); top: -80px; right: -80px; }
.blob-b { width: 380px; height: 380px; background: #1FA9A0; bottom: -120px; left: -60px; }
.login-card { background: var(--surface); display: flex; flex-direction: column; justify-content: center; padding: 48px; }
.login-card > .brand { padding: 0 0 26px; }
.login-title { font-size: 1.5rem; margin-bottom: 6px; }
.login-sub { color: var(--muted); margin: 0 0 22px; }
.login-hint { color: var(--muted); font-size: .8rem; margin-top: 18px; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty-state .ico { width: 42px; height: 42px; opacity: .4; margin-bottom: 10px; }
.empty-state p { margin: 0; font-size: .92rem; }

/* ---------- Download queue pulse ---------- */
.pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--info); margin-right: 6px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* ---------- Print (invoice PDF-ready view) ---------- */
@media print {
    .sidebar, .topbar, .bottom-nav, .chat-fab, .chat-panel, .toast-stack, .no-print { display: none !important; }
    .app-main { margin: 0; }
    body { background: #fff; }
    .print-doc { box-shadow: none; border: none; }
}

/* ---------- Responsive / mobile ---------- */
#menuToggle { display: none; }
@media (max-width: 900px) {
    .sidebar { transform: translateX(-105%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    #menuToggle { display: inline-flex; }
    .grid-2 { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .content { padding: 14px; padding-bottom: 96px; }
    .login-wrap { grid-template-columns: 1fr; }
    .login-hero { display: none; }
    .login-card { padding: 30px 22px; }
    .bottom-nav {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; background: var(--surface);
        border-top: 1px solid var(--border); display: flex; justify-content: space-around; padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
    }
    .bn-item { display: inline-flex; flex-direction: column; align-items: center; color: var(--muted); padding: 7px 16px; border-radius: 10px; border: none; background: none; cursor: pointer; }
    .bn-item.active { color: var(--primary); background: var(--primary-lt); }
    .bn-chat { color: var(--accent); }
}
@media (min-width: 901px) { .bottom-nav { display: none; } }

/* ---------- Vehicle photo thumbnails ---------- */
.veh-thumb {
    width: 52px; height: 38px; object-fit: cover; border-radius: 8px;
    border: 1px solid var(--border); background: var(--bg); display: inline-flex;
    align-items: center; justify-content: center; color: var(--muted); overflow: hidden;
}
.veh-thumb svg { width: 20px; height: 20px; }
.veh-thumb--lg { width: 120px; height: 84px; border-radius: 10px; }
.veh-thumb--lg svg { width: 34px; height: 34px; }
.photo-edit { display: flex; gap: 16px; align-items: flex-start; }
.doc-file-row { display: grid; grid-template-columns: 160px 1fr; gap: 8px; align-items: center; margin-bottom: 8px; }
