/* ==========================================================================
   Advanced Automotive Mechanics — workshop admin
   ========================================================================== */

:root {
    --ink: #12161c;
    --ink-2: #1a2028;
    --steel: #2a323d;
    --muted: #667085;
    --line: #e4e7ec;
    --bg: #f3f4f6;
    --white: #fff;
    --red: #d62028;
    --red-2: #f0383f;
    --red-dark: #a8141b;
    --green: #16a34a;
    --amber: #d97706;
    --blue: #2563eb;
    --purple: #7c3aed;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
    --font-head: 'Barlow Condensed', 'Arial Narrow', Arial, sans-serif;
    --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    --sidebar: 250px;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: var(--font-body); font-size: 14px; line-height: 1.55; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; margin: 0 0 .5rem; line-height: 1.1; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 .8rem; }
.icon { flex-shrink: 0; vertical-align: middle; }
.muted { color: var(--muted); }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }

/* Layout ----------------------------------------------------------------- */
.admin { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 40;
    background: var(--ink); color: #aab2bd;
    display: flex; flex-direction: column;
    transition: transform .25s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 18px; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.sidebar-brand img { width: 38px; height: 38px; }
.sidebar-brand strong { display: block; font-family: var(--font-head); color: var(--white); font-size: 1.3rem; letter-spacing: 1px; line-height: 1; }
.sidebar-brand small { font-family: var(--font-head); color: var(--red-2); font-size: .66rem; letter-spacing: 2px; font-weight: 700; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.nav-label { font-size: .68rem; text-transform: uppercase; letter-spacing: 1.5px; color: #6b7480; padding: 14px 10px 6px; font-weight: 600; }
.nav-link {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; border-radius: 8px; margin-bottom: 2px;
    font-weight: 500; color: #c3cad3; transition: background .15s ease, color .15s ease;
}
.nav-link:hover { background: rgba(255, 255, 255, .05); color: var(--white); }
.nav-link.active { background: var(--red); color: var(--white); }
.nav-link .count { margin-left: auto; background: var(--red-2); color: var(--white); font-size: .7rem; font-weight: 700; border-radius: 999px; padding: 1px 8px; }
.nav-link.active .count { background: rgba(255, 255, 255, .25); }
.sidebar-foot { padding: 14px 12px; border-top: 1px solid rgba(255, 255, 255, .06); }

.main { flex: 1; margin-left: var(--sidebar); min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 16px;
    height: 64px; padding: 0 28px;
    background: var(--white); border-bottom: 1px solid var(--line);
}
.topbar-search { flex: 1; max-width: 420px; position: relative; }
.topbar-search input { width: 100%; padding: 9px 14px 9px 38px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font: inherit; }
.topbar-search input:focus { outline: none; border-color: var(--red); background: var(--white); }
.topbar-search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px; border-radius: 999px; }
.user-chip:hover { background: var(--bg); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: var(--white); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.menu-btn { display: none; background: none; border: 0; cursor: pointer; padding: 6px; color: var(--ink); }

.content { padding: 28px; flex: 1; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 0; color: var(--muted); }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.crumbs { font-size: .8rem; color: var(--muted); margin-bottom: 6px; }
.crumbs a:hover { color: var(--red); }

/* Components ------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
    font: inherit; font-weight: 600; font-size: .88rem; cursor: pointer; white-space: nowrap;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.btn-primary { background: var(--red); color: var(--white); }
.btn-primary:hover { background: var(--red-dark); }
.btn-dark { background: var(--ink); color: var(--white); }
.btn-dark:hover { background: var(--steel); }
.btn-light { background: var(--white); border-color: var(--line); color: var(--ink); }
.btn-light:hover { border-color: #cfd4dc; background: #fafafa; }
.btn-success { background: var(--green); color: var(--white); }
.btn-success:hover { background: #12833c; }
.btn-danger-ghost { background: transparent; color: var(--red); border-color: #f5c2c4; }
.btn-danger-ghost:hover { background: #fdecec; }
.btn-sm { padding: 6px 11px; font-size: .8rem; }
.btn-icon { padding: 7px; }
.btn-block { width: 100%; }

.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 20px; }
.card + .card { margin-top: 20px; }
.grid > .card + .card { margin-top: 0; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }

.stat { display: flex; gap: 14px; align-items: center; padding: 20px; }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.stat-icon.red { background: #fdecec; color: var(--red); }
.stat-icon.blue { background: #e8f0fe; color: var(--blue); }
.stat-icon.amber { background: #fef3e2; color: var(--amber); }
.stat-icon.green { background: #e7f6ec; color: var(--green); }
.stat-icon.purple { background: #f1ebfe; color: var(--purple); }
.stat small { display: block; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .8px; font-weight: 600; }
.stat strong { font-family: var(--font-head); font-size: 1.9rem; line-height: 1.1; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 600; padding: 11px 16px; background: #f9fafb; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfc; }
.table .title { font-weight: 600; }
.table .sub { display: block; font-size: .8rem; color: var(--muted); }
.table a.title:hover { color: var(--red); }
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .icon { color: #c4cad3; margin-bottom: 8px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-family: var(--font-body); font-size: .74rem; font-weight: 600; letter-spacing: 0; text-transform: none; white-space: nowrap; vertical-align: middle; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-gray { background: #f2f4f7; color: #475467; }
.badge-red { background: #fdecec; color: #b42318; }
.badge-blue { background: #e8f0fe; color: #1d4ed8; }
.badge-amber { background: #fef3e2; color: #b54708; }
.badge-green { background: #e7f6ec; color: #067647; }
.badge-purple { background: #f1ebfe; color: #6d28d9; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.filters .form-control { width: auto; min-width: 160px; padding: 8px 12px; }
.filters .search { flex: 1; min-width: 200px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { padding: 7px 12px; border-radius: 7px; font-weight: 600; font-size: .82rem; color: var(--muted); }
.tabs a:hover { background: var(--bg); color: var(--ink); }
.tabs a.active { background: var(--ink); color: var(--white); }

/* Forms ------------------------------------------------------------------ */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: .8rem; font-weight: 600; color: var(--steel); }
.form-group label .req { color: var(--red); }
.form-control {
    width: 100%; padding: 9px 12px; font: inherit; font-size: .9rem; color: var(--ink);
    background: var(--white); border: 1px solid #d0d5dd; border-radius: 8px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(214, 32, 40, .12); }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-control.is-invalid { border-color: var(--red); }
.invalid-feedback { color: var(--red); font-size: .78rem; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 20px; border-top: 1px solid var(--line); background: #fafbfc; border-radius: 0 0 var(--radius) var(--radius); }
.section-title { font-family: var(--font-head); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; font-size: 1rem; color: var(--steel); margin: 6px 0 2px; grid-column: 1 / -1; padding-bottom: 6px; border-bottom: 1px dashed var(--line); }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }

.alert { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-weight: 500; }
.alert-success { background: #e7f6ec; color: #067647; border: 1px solid #b7e4c7; }
.alert-error { background: #fdecec; color: #b42318; border: 1px solid #f5c2c4; }

/* Line items ------------------------------------------------------------- */
.items-table td { padding: 8px; vertical-align: top; }
.items-table th { padding: 10px 8px; }
.items-table .form-control { padding: 8px 10px; }
.items-table .col-type { width: 120px; }
.items-table .col-qty { width: 90px; }
.items-table .col-price { width: 130px; }
.items-table .col-total { width: 130px; text-align: right; font-weight: 600; padding-top: 16px; }
.items-table .col-del { width: 44px; }
.totals { margin-left: auto; width: 100%; max-width: 340px; }
.totals div { display: flex; justify-content: space-between; padding: 7px 0; }
.totals .grand { border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 12px; font-family: var(--font-head); font-size: 1.4rem; font-weight: 700; }

/* Detail lists ----------------------------------------------------------- */
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; margin: 0; }
.dl dt { color: var(--muted); font-size: .82rem; font-weight: 500; }
.dl dd { margin: 0; font-weight: 500; word-break: break-word; }
.text-block { white-space: pre-wrap; background: #f9fafb; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 0 0 14px; min-height: 44px; }
.label-sm { font-size: .72rem; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 600; margin-bottom: 6px; display: block; }

/* Chat ------------------------------------------------------------------- */
.chat-list a { display: flex; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); align-items: center; }
.chat-list a:hover { background: #fafbfc; }
.chat-list .preview { color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-window { display: flex; flex-direction: column; height: calc(100vh - 220px); min-height: 420px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; background: #f6f7f9; display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 70%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.bubble time { display: block; font-size: .7rem; opacity: .6; margin-top: 4px; }
.bubble-visitor { align-self: flex-start; background: var(--white); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble-staff { align-self: flex-end; background: var(--ink); color: var(--white); border-bottom-right-radius: 4px; }
.chat-reply { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--line); }
.chat-reply textarea { flex: 1; min-height: 46px; height: 46px; resize: none; }

/* Pagination ------------------------------------------------------------- */
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 16px; border-top: 1px solid var(--line); }
.pagination-info { color: var(--muted); font-size: .82rem; }
.pagination-links { display: flex; gap: 4px; }
.pagination-links a, .pagination-links span { min-width: 34px; height: 34px; display: grid; place-items: center; padding: 0 8px; border-radius: 7px; border: 1px solid var(--line); background: var(--white); font-weight: 600; font-size: .85rem; }
.pagination-links a:hover { border-color: var(--red); color: var(--red); }
.pagination-links .active { background: var(--ink); color: var(--white); border-color: var(--ink); }
.pagination-links .disabled { color: #c4cad3; }

/* Auth ------------------------------------------------------------------- */
.auth-wrap {
    min-height: 100vh; display: grid; place-items: center; padding: 20px;
    background: radial-gradient(800px 400px at 80% 0%, rgba(214, 32, 40, .25), transparent 60%), linear-gradient(140deg, #0d1015, #1d232c);
}
.auth-card { width: 100%; max-width: 420px; background: var(--white); border-radius: 16px; padding: 38px 34px; box-shadow: 0 30px 60px rgba(0, 0, 0, .35); }
.auth-card .logo { display: block; width: 240px; margin: 0 auto 26px; }
.auth-card h1 { text-align: center; font-size: 1.6rem; }
.auth-card p.muted { text-align: center; margin-bottom: 24px; }

/* Integration cards ------------------------------------------------------ */
.integration { display: flex; gap: 16px; align-items: flex-start; }
.integration .stat-icon { width: 52px; height: 52px; }

/* Printable documents ---------------------------------------------------- */
.doc { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 44px; box-shadow: var(--shadow); max-width: 900px; }
.doc-head { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 24px; border-bottom: 3px solid var(--ink); margin-bottom: 26px; }
.doc-head img { width: 260px; }
.doc-biz { text-align: right; font-size: .85rem; color: var(--muted); line-height: 1.6; }
.doc-title { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 26px; flex-wrap: wrap; }
.doc-title h1 { font-size: 2.4rem; color: var(--red); margin: 0; }
.doc-meta { display: grid; grid-template-columns: auto auto; gap: 4px 18px; font-size: .88rem; }
.doc-meta span:nth-child(odd) { color: var(--muted); }
.doc-meta span:nth-child(even) { font-weight: 600; text-align: right; }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 26px; }
.doc-parties > div { background: #f9fafb; border-radius: 8px; padding: 14px 16px; font-size: .9rem; }
.doc .table th { background: var(--ink); color: var(--white); }
.doc-foot { margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted); display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.sign-line { margin-top: 40px; border-top: 1px solid var(--ink); padding-top: 6px; font-size: .8rem; color: var(--muted); }

@media print {
    body { background: #fff; }
    .sidebar, .topbar, .no-print, .page-head .page-actions, .alert { display: none !important; }
    .main { margin: 0; }
    .content { padding: 0; }
    .doc { border: 0; box-shadow: none; padding: 0; max-width: none; }
    .grid-main-side { display: block; }
    .doc .table th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    a { color: inherit; }
}

/* Responsive ------------------------------------------------------------- */
@media (max-width: 1200px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-main-side { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
    .main { margin-left: 0; }
    .menu-btn { display: block; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .content { padding: 18px; }
    .topbar { padding: 0 16px; }
    .doc { padding: 24px; }
    .doc-head, .doc-parties, .doc-foot { grid-template-columns: 1fr; flex-direction: column; }
    .doc-biz { text-align: left; }
}
@media (max-width: 600px) {
    .grid-4, .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
    .topbar-search { display: none; }
    .dl { grid-template-columns: 1fr; gap: 2px; }
    .dl dd { margin-bottom: 10px; }
}
