/* =====================================================================
   RTO Vehicle & Compliance Management System
   Theme: clean white background with red / maroon accents.
   ===================================================================== */
:root {
    --red: #8b1a1a;          /* maroon accent (from brand card) */
    --red-600: #a51f1f;
    --red-500: #c62828;
    --red-050: #fbeaea;
    --ink: #1f2328;
    --muted: #6b7280;
    --line: #e6e6e9;
    --bg: #f6f7f9;
    --white: #ffffff;
    --green: #1b7f4c;
    --amber: #b45309;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
    font-size: 14px;
    line-height: 1.5;
}
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px; background: var(--white); border-right: 1px solid var(--line);
    display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0;
    z-index: 30;
}
.sidebar .brand {
    padding: 18px 20px; border-bottom: 3px solid var(--red);
    display: flex; align-items: center; gap: 10px;
}
.sidebar .brand .logo {
    width: 34px; height: 34px; border-radius: 8px; background: var(--red);
    color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.sidebar .brand .title { font-weight: 700; font-size: 14px; line-height: 1.2; }
.sidebar .brand .title small { display: block; color: var(--muted); font-weight: 500; font-size: 11px; }
.nav { padding: 10px 8px; overflow-y: auto; flex: 1; }
.nav a {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
    color: var(--ink); font-weight: 500; margin-bottom: 2px;
}
.nav a:hover { background: var(--red-050); text-decoration: none; }
.nav a.active { background: var(--red); color: #fff; }
.nav a .ic { width: 18px; text-align: center; opacity: .85; }
.nav .group-label { padding: 12px 14px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.main { flex: 1; margin-left: 240px; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    height: 58px; background: var(--white); border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between; padding: 0 22px;
    position: sticky; top: 0; z-index: 20;
}
.topbar .page-title { font-weight: 600; font-size: 16px; }
.topbar .user { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.topbar .user .who { text-align: right; line-height: 1.2; }
.topbar .user .who strong { color: var(--ink); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--red-050); color: var(--red); display: grid; place-items: center; font-weight: 700; }
.content { padding: 22px; }

/* ---------- Cards ---------- */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 700; }
.card-body { padding: 18px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--red); font-weight: 700; margin: 0 0 12px; }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.kpi { background: var(--white); border: 1px solid var(--line); border-left: 4px solid var(--red); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.kpi .value.danger { color: var(--red-500); }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--white); color: var(--ink); font-weight: 600; cursor: pointer; font-size: 13px; }
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-600); }
.btn-danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-050); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: #374151; }
.field label .req { color: var(--red); }
.field input, .field select, .field textarea {
    padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
    background: #fff; color: var(--ink); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--red-050); }
.field .hint { font-size: 11px; color: var(--muted); }
.inline-add { display: flex; gap: 6px; }
.inline-add select { flex: 1; }

/* ---------- Creatable searchable combobox ---------- */
.combo { position: relative; }
.combo .combo-input { width: 100%; padding-right: 28px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.combo-list {
    position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 50;
    margin: 0; padding: 6px 0; list-style: none;
    background: #fff; border: 1px solid var(--line); border-radius: 8px;
    box-shadow: 0 8px 24px rgba(16,24,40,.12); max-height: 240px; overflow-y: auto;
}
.combo-option, .combo-create, .combo-empty {
    padding: 8px 12px; cursor: pointer; font-size: 13px;
}
.combo-option:hover, .combo-option.is-active,
.combo-create:hover, .combo-create.is-active { background: var(--red-050); }
.combo-create { color: var(--red); font-weight: 600; }
.combo-empty { color: var(--muted); cursor: default; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.checkbox input { width: auto; }

.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 18px; border-top: 1px solid var(--line); background: #fafafa; border-radius: 0 0 var(--radius) var(--radius); position: sticky; bottom: 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { background: #faf7f7; color: #374151; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; }
table.data tbody tr:hover, table.data tr:hover { background: #fcfcfd; }
table.data td.actions { text-align: right; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-success { background: #e7f4 ; background: #e6f4ec; color: var(--green); }
.badge-warning { background: #fef3e2; color: var(--amber); }
.badge-danger { background: var(--red-050); color: var(--red-500); }
.badge-muted { background: #eef0f2; color: var(--muted); }

/* ---------- Alerts / flash ---------- */
.flash { padding: 11px 16px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; border: 1px solid transparent; }
.flash-success { background: #e6f4ec; color: var(--green); border-color: #bfe3cd; }
.flash-error { background: var(--red-050); color: var(--red-500); border-color: #f0c9c9; }

/* ---------- Filters bar ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters .field { min-width: 160px; }
.filters .field input[type="date"] { min-width: 160px; }

/* ---------- Pills / tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 8px 8px 0 0; font-weight: 600; color: var(--muted); cursor: pointer; }
.tab.active { color: var(--red); border-bottom: 2px solid var(--red); }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #fff 0%, var(--red-050) 100%); padding: 20px; }
.auth-card { background: #fff; width: 100%; max-width: 400px; border-radius: 14px; box-shadow: 0 10px 40px rgba(139,26,26,.12); overflow: hidden; }
.auth-head { background: var(--red); color: #fff; padding: 26px 28px; }
.auth-head h1 { margin: 0; font-size: 19px; }
.auth-head p { margin: 6px 0 0; opacity: .9; font-size: 13px; }
.auth-body { padding: 26px 28px; }
.auth-body .field { margin-bottom: 16px; }

/* ---------- Misc ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.page-head h2 { margin: 0; font-size: 20px; }
.page-head-stack { flex-direction: column; align-items: flex-start; gap: 10px; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.page-actions form { margin: 0; }
.muted { color: var(--muted); }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .big { font-size: 42px; margin-bottom: 8px; }
.row-flex { display: flex; gap: 16px; flex-wrap: wrap; }
.row-flex > * { flex: 1; min-width: 260px; }
.summary-list { list-style: none; margin: 0; padding: 0; }
.summary-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.summary-list li:last-child { border-bottom: 0; }
.summary-list .k { color: var(--muted); }
.pagination { display: flex; gap: 6px; margin-top: 16px; justify-content: center; }
.pagination a, .pagination span { padding: 6px 11px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.pagination .current { background: var(--red); color: #fff; border-color: var(--red); }
.notice { background: #fff8e6; border: 1px solid #f2e2b3; color: #7a5b00; padding: 12px 14px; border-radius: 8px; font-size: 13px; }

@media (max-width: 860px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .menu-toggle { display: inline-flex !important; }
}
.menu-toggle { display: none; }
