:root {
    color-scheme: light;
    --bg: #f3f5f7;
    --ink: #14202b;
    --muted: #6c7886;
    --line: #dce2e8;
    --panel: #fff;
    --nav: #172d27;
    --nav-soft: #24443a;
    --green: #1f8a5b;
    --blue: #236b8e;
    --red: #c64d4d;
    --amber: #b67715;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 Inter, Arial, Helvetica, sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
svg { width: 18px; height: 18px; stroke-width: 1.8; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: 27px; line-height: 1.2; letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 17px; letter-spacing: 0; }
h3 { margin: 0; font-size: 13px; }

input, select, textarea {
    width: 100%; min-height: 42px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px;
    outline: none; background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: #5894ad; box-shadow: 0 0 0 3px rgba(35, 107, 142, .1); }
textarea { resize: vertical; }

.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; width: 248px; flex-direction: column;
    background: var(--nav); color: #fff; border-right: 1px solid rgba(255,255,255,.05);
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.sidebar > .sidebar-brand { height: 78px; padding: 0 22px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-brand > span:last-child { display: grid; min-width: 0; }
.sidebar-brand strong { font-size: 15px; letter-spacing: 0; }
.sidebar-brand small { color: #94aaa2; font-size: 11px; }
.brand-mark {
    display: inline-grid; width: 38px; height: 38px; flex: 0 0 38px; place-items: center; border-radius: 7px;
    background: #2b9a69; color: #fff; font-size: 13px; font-weight: 800;
}
.brand-mark.large { width: 52px; height: 52px; font-size: 16px; }
.sidebar-nav { flex: 1; padding: 18px 12px; }
.sidebar-nav p { margin: 16px 11px 7px; color: #789087; font-size: 10px; font-weight: 700; }
.sidebar-nav a {
    display: flex; height: 44px; align-items: center; gap: 12px; margin-bottom: 3px; padding: 0 12px;
    border-radius: 6px; color: #c6d2ce; text-decoration: none; transition: background .15s, color .15s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.055); color: #fff; }
.sidebar-nav a.active { background: var(--nav-soft); color: #fff; font-weight: 700; box-shadow: inset 3px 0 #37a876; }
.sidebar-nav a b { margin-left: auto; padding: 2px 7px; border-radius: 10px; background: rgba(255,255,255,.1); font-size: 10px; }
.sidebar-nav a.nav-sub { height: 34px; margin-left: 28px; padding-left: 10px; color: #93aaa2; font-size: 12px; }
.sidebar-nav a.nav-sub svg { width: 14px; height: 14px; }
.sidebar-nav a.nav-sub.active { background: transparent; color: #6bd09d; box-shadow: none; }
.sidebar-user { display: grid; grid-template-columns: 34px minmax(0,1fr) 34px; align-items: center; gap: 9px; padding: 15px 14px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-user > span:nth-child(2) { display: grid; min-width: 0; }
.sidebar-user strong, .sidebar-user small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user strong { font-size: 12px; }
.sidebar-user small { color: #90a69e; font-size: 10px; }
.avatar { display: inline-grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border-radius: 50%; background: #dcebe5; color: #24664e; font-weight: 800; }
.sidebar-user .avatar { background: #315148; color: #fff; }

.workspace { min-height: 100vh; margin-left: 248px; }
.content { width: min(1560px, 100%); margin: 0 auto; padding: 28px 30px 40px; }
.mobile-header { display: none; }
.page-header { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-header > div:first-child { margin-right: auto; }
.page-header > div > p:last-child { margin: 0; color: var(--muted); }
.page-actions { display: flex; align-items: center; gap: 8px; }
.page-actions a { text-decoration: none; }
.eyebrow { margin-bottom: 5px; color: var(--green); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.filters { display: flex; align-items: end; gap: 8px; }
.filters label { display: grid; gap: 4px; min-width: 145px; }
.filters label span, .field-label > span:first-child { color: #4e5d6b; font-size: 11px; font-weight: 700; }
.filters .search-field { width: 250px; }
.lead-filters { flex: 1 0 100%; justify-content: flex-end; padding-top: 12px; border-top: 1px solid var(--line); }
.lead-filters .clear-filter { align-self: end; border-color: var(--line); background: #fff; text-decoration: none; }
.filter-button { display: flex; min-height: 42px; align-items: center; gap: 7px; padding: 0 14px; border: 0; border-radius: 6px; background: var(--blue); color: #fff; }

.notice { display: flex; align-items: center; gap: 9px; margin-bottom: 16px; padding: 11px 13px; border: 1px solid #aedac4; border-radius: 6px; background: #eaf7f0; color: #17633f; }
.notice.error { border-color: #e7baba; background: #fff0f0; color: #912f2f; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 13px; margin-bottom: 16px; }
.metric { display: flex; min-height: 116px; align-items: center; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); }
.metric > div { display: grid; min-width: 0; }
.metric small, .metric em { color: var(--muted); font-size: 11px; font-style: normal; }
.metric strong { margin: 2px 0; font-size: 23px; letter-spacing: 0; }
.metric strong.negative { color: var(--red); }
.money-values { display: grid; gap: 0; margin: 2px 0; }
.money-values strong { font-size: 20px; line-height: 1.25; letter-spacing: 0; }
.money-values strong small { color: inherit; font-size: 10px; font-weight: 800; }
.money-values .negative { color: var(--red); }
.money-values .positive { color: var(--green); }
.finance-totals .money-values { margin-top: 4px; }
.finance-totals .money-values strong { font-size: 16px; }
.metric-icon, .quick-icon, .transaction-icon, .vehicle-icon { display: inline-grid; flex: 0 0 auto; place-items: center; }
.metric-icon { width: 42px; height: 42px; border-radius: 7px; }
.metric-icon.blue, .quick-icon.blue { background: #e6f2f8; color: var(--blue); }
.metric-icon.green, .quick-icon.green { background: #e4f4ec; color: var(--green); }
.metric-icon.red, .quick-icon.red { background: #faeaea; color: var(--red); }
.metric-icon.amber, .quick-icon.amber { background: #fbf0da; color: var(--amber); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0,2fr) minmax(280px,1fr); gap: 16px; margin-bottom: 16px; }
.panel { min-width: 0; margin-bottom: 16px; padding: 18px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); }
.dashboard-grid .panel { margin-bottom: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 15px; }
.panel-head > div:first-child { display: grid; gap: 3px; }
.panel-head span { color: var(--muted); font-size: 11px; }
.text-link { color: var(--blue); font-size: 12px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.quick-panel > a { display: grid; grid-template-columns: 38px 1fr 18px; align-items: center; gap: 11px; padding: 13px 0; border-top: 1px solid #edf0f2; color: var(--ink); text-decoration: none; }
.quick-panel > a:first-of-type { border-top: 0; }
.quick-panel > a > span:nth-child(2) { display: grid; }
.quick-panel > a small { color: var(--muted); font-size: 11px; }
.quick-panel > a > svg { color: #9ba6af; }
.quick-icon { width: 36px; height: 36px; border-radius: 6px; }
.finance-totals { display: grid; grid-template-columns: repeat(5,1fr); }
.finance-totals > div { display: grid; gap: 4px; padding: 5px 20px; border-left: 1px solid var(--line); }
.finance-totals > div:first-child { padding-left: 0; border-left: 0; }
.finance-totals small { color: var(--muted); font-size: 11px; }
.finance-totals strong { font-size: 18px; }
.amber-text { color: var(--amber); }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; min-width: 1050px; border-collapse: collapse; background: #fff; }
.compact-table table { min-width: 700px; }
.leads-table-wrap { border: 0; border-top: 1px solid var(--line); border-radius: 0; }
.leads-table { min-width: 1120px; }
.leads-table th { padding: 9px 10px; background: #fff; color: #7a8590; font-size: 9px; }
.leads-table td { padding: 12px 10px; }
.leads-table tbody tr:hover { background: #f7faf9; }
th { padding: 10px 12px; background: #f6f8f9; color: #52606d; text-align: left; font-size: 10px; text-transform: uppercase; }
td { padding: 11px 12px; border-top: 1px solid #e8ecef; vertical-align: middle; }
tbody tr:hover { background: #fafcfc; }
td small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.route { min-width: 180px; }
.row-id { color: var(--muted); font-size: 11px; }
.badge { display: inline-block; padding: 5px 8px; border-radius: 12px; background: #edf1f3; font-size: 10px; font-weight: 700; white-space: nowrap; }
.badge.confirmed, .badge.completed { background: #e4f4ea; color: #237348; }
.badge.cancelled { background: #fbe8e8; color: #a33838; }
.badge.in_progress { background: #fff3d9; color: #8b5e13; }
.empty { padding: 25px; color: var(--muted); text-align: center; }
.mini-form select { min-width: 132px; min-height: 34px; padding: 6px 8px; font-size: 11px; }
.leads-table .mini-form select { border: 0; box-shadow: none; font-weight: 700; }
.status.confirmed, .status.completed, .pay.paid { border-color: #abd8bd; background: #edf9f1; color: #216b46; }
.status.cancelled, .pay.unpaid { border-color: #edbcbc; background: #fff4f4; color: #963434; }
.status.in_progress, .pay.partial { border-color: #e4cc92; background: #fff9eb; color: #815a15; }
.actions { display: flex; gap: 5px; }
.actions form { margin: 0; }

.lead-form { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; }
.lead-form textarea { grid-column: span 2; }
.form-actions { display: flex; grid-column: 1 / -1; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.primary, .secondary { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border-radius: 6px; }
.primary { border: 1px solid var(--blue); background: var(--blue); color: #fff; }
.primary:hover { background: #195a79; }
.secondary { border: 1px solid var(--line); background: #fff; color: var(--ink); }
.icon-button, .collapse-button { display: inline-grid; width: 34px; height: 34px; padding: 0; place-items: center; border: 1px solid transparent; border-radius: 6px; background: transparent; color: inherit; }
.icon-button:hover, .collapse-button:hover { background: rgba(0,0,0,.05); }
.icon-button.danger { color: var(--red); }
.form-grid, .fleet-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.stack { display: grid; gap: 10px; }
.split { display: grid; grid-template-columns: 1fr 100px; gap: 9px; }
.split.equal { grid-template-columns: 1fr 1fr; }
.activity { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 28px; }
.activity h3 { margin-bottom: 8px; color: var(--muted); text-transform: uppercase; }
.activity p { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; margin: 0; padding: 11px 0; border-top: 1px solid #edf0f2; }
.activity p > span:nth-child(2) { display: grid; }
.activity small { color: var(--muted); font-size: 10px; }
.activity b { font-size: 12px; }
.transaction-icon { width: 30px; height: 30px; border-radius: 50%; }
.transaction-icon.income { background: #e5f4eb; color: var(--green); }
.transaction-icon.outcome { background: #faeaea; color: var(--red); }
.resource-list article { display: grid; grid-template-columns: 38px minmax(0,1fr) auto 74px; align-items: center; gap: 11px; padding: 12px 0; border-top: 1px solid #edf0f2; }
.resource-list article > span:nth-child(2), .resource-meta { display: grid; }
.resource-list small { color: var(--muted); font-size: 10px; }
.resource-meta { text-align: right; }
.resource-meta strong { font-size: 12px; }
.vehicle-icon { width: 36px; height: 36px; border-radius: 7px; background: #eaf1f4; color: var(--blue); }

.record-form { max-width: 1080px; }
.single-form { max-width: 760px; }
.form-section { padding: 22px; }
.section-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid #edf0f2; }
.section-heading > div { display: grid; gap: 3px; }
.section-heading h2, .section-heading p { margin: 0; }
.section-heading p { color: var(--muted); font-size: 11px; }
.section-number { display: inline-grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; border-radius: 50%; background: #e4f3ec; color: var(--green); font-size: 13px; font-weight: 800; }
.field-grid { display: grid; gap: 14px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
.field-grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.field-grid .full { grid-column: 1 / -1; }
.field { display: grid; align-content: start; gap: 6px; }
.field > span:first-child { color: #42515e; font-size: 11px; font-weight: 700; }
.input-pair { display: grid; grid-template-columns: minmax(0,1fr) 92px; }
.input-pair input { border-radius: 6px 0 0 6px; }
.input-pair select { border-left: 0; border-radius: 0 6px 6px 0; }
.sticky-form-actions { position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: flex-end; gap: 9px; margin-top: -1px; padding: 13px 18px; border: 1px solid var(--line); border-radius: 7px; background: rgba(255,255,255,.96); box-shadow: 0 -6px 18px rgba(30,48,42,.05); }
.sticky-form-actions a { text-decoration: none; }
.expense-types { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 9px; margin-bottom: 20px; }
.expense-types input { position: absolute; opacity: 0; pointer-events: none; }
.expense-types label > span { display: flex; min-height: 82px; flex-direction: column; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); border-radius: 6px; color: #52606d; cursor: pointer; transition: .15s; }
.expense-types label > span b { font-size: 11px; }
.expense-types input:checked + span { border-color: var(--green); background: #edf8f2; color: #176a45; box-shadow: 0 0 0 2px rgba(31,138,91,.08); }
.expense-types input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }
.data-list article { display: grid; grid-template-columns: 40px minmax(0,1fr) auto 74px; align-items: center; gap: 12px; padding: 13px 4px; border-top: 1px solid #edf0f2; }
.data-list article:first-child { border-top: 0; }
.data-list article > span:nth-child(2), .data-list article > span:nth-child(3) { display: grid; gap: 2px; }
.data-list article > span:nth-child(3) { text-align: right; }
.data-list small { color: var(--muted); font-size: 10px; }
.income-text { color: var(--green); }
.outcome-text { color: var(--red); }
.fee-note { color: var(--green); font-weight: 700; }
.auto-badge { display: inline-block; margin-left: 5px; padding: 2px 6px; border-radius: 9px; background: #e4f4ec; color: var(--green); font-size: 9px; font-style: normal; vertical-align: middle; }
.empty-state { display: grid; justify-items: center; gap: 6px; padding: 50px 20px; color: var(--muted); text-align: center; }
.empty-state > svg { width: 30px; height: 30px; }
.empty-state h3, .empty-state p { margin: 0; }
.empty-state p { font-size: 11px; }
.resource-layout { display: grid; grid-template-columns: minmax(280px, .7fr) minmax(420px, 1.3fr); gap: 16px; }
.resource-layout > .panel { align-self: start; }
.row-actions { display: flex; justify-content: flex-end; gap: 4px; }
.row-actions form { margin: 0; }
.row-actions .icon-button { border-color: var(--line); background: #fff; }
.row-actions .icon-button:hover { background: #f2f5f6; }
.small-modal { width: min(560px, calc(100% - 24px)); }

.modal { width: min(920px, calc(100% - 24px)); max-height: calc(100vh - 30px); padding: 0; border: 0; border-radius: 8px; box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.modal::backdrop { background: rgba(12,23,20,.58); }
.modal-body { padding: 22px; }
.modal .form-heading { grid-column: 1 / -1; }
.modal .form-heading span { color: var(--green); font-weight: 800; }

.login-page { min-height: 100vh; background: #fff; }
.login-shell { display: grid; min-height: 100vh; grid-template-columns: minmax(360px,.9fr) minmax(480px,1.1fr); }
.login-brand { display: flex; flex-direction: column; justify-content: space-between; padding: 52px; background: var(--nav); color: #fff; }
.login-brand > div:nth-child(2) { max-width: 520px; }
.login-brand h1 { margin-bottom: 18px; font-size: 44px; line-height: 1.15; }
.login-brand p:not(.eyebrow) { max-width: 430px; color: #a9bbb5; font-size: 16px; }
.login-brand .eyebrow { color: #5fc28f; }
.login-footer { color: #758d85; font-size: 11px; }
.login-panel { display: grid; place-items: center; padding: 38px; }
.login-form { width: min(400px,100%); }
.login-heading { margin-bottom: 28px; }
.login-heading > span { color: var(--green); font-size: 10px; font-weight: 800; }
.login-heading h2 { margin: 7px 0 5px; font-size: 28px; }
.login-heading p { color: var(--muted); }
.field-label { display: grid; gap: 6px; margin-bottom: 15px; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 70px; }
.password-toggle { position: absolute; top: 4px; right: 4px; width: auto; padding: 0 8px; color: var(--blue); font-size: 11px; font-weight: 700; }
.check-label { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 20px; color: #4f5d69; font-size: 12px; }
.check-label input { width: 15px; min-height: 15px; accent-color: var(--green); }
.login-button { width: 100%; min-height: 46px; justify-content: space-between; }
.mobile-brand { display: none; }

[hidden] { display: none !important; }
.sidebar-backdrop { display: none; }

@media (max-width: 1100px) {
    .content { padding: 24px 20px 36px; }
    .metrics { grid-template-columns: repeat(2,1fr); }
    .lead-form { grid-template-columns: repeat(2,1fr); }
    .finance-totals { grid-template-columns: repeat(3,1fr); gap: 16px 0; }
    .finance-totals > div:nth-child(4) { padding-left: 0; border-left: 0; }
}

@media (max-width: 820px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { position: fixed; inset: 0; z-index: 19; display: block; background: rgba(10,25,20,.48); }
    .workspace { margin-left: 0; }
    .mobile-header { display: flex; height: 62px; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--line); background: #fff; }
    .mobile-header .sidebar-brand { gap: 8px; }
    .mobile-header .brand-mark { width: 32px; height: 32px; flex-basis: 32px; }
    .page-header { align-items: stretch; flex-direction: column; }
    .dashboard-grid, .form-grid, .fleet-grid, .resource-layout { grid-template-columns: 1fr; }
    .activity { grid-template-columns: 1fr; }
    .login-shell { grid-template-columns: 1fr; }
    .login-brand { display: none; }
    .mobile-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 50px; }
}

@media (max-width: 600px) {
    .content { padding: 20px 12px 30px; }
    h1 { font-size: 24px; }
    .filters { display: grid; grid-template-columns: 1fr 1fr; }
    .filters label, .filters .search-field { width: auto; min-width: 0; }
    .filters .search-field { grid-column: 1 / -1; }
    .lead-filters { grid-template-columns: 1fr 1fr; justify-content: stretch; }
    .filter-button { justify-content: center; }
    .metrics { grid-template-columns: 1fr 1fr; gap: 8px; }
    .metric { min-height: 100px; padding: 12px; }
    .metric-icon { width: 34px; height: 34px; }
    .metric strong { font-size: 19px; }
    .lead-form { grid-template-columns: 1fr; }
    .lead-form textarea { grid-column: auto; }
    .finance-totals { grid-template-columns: 1fr 1fr; }
    .finance-totals > div, .finance-totals > div:nth-child(4) { padding: 8px 10px; border-left: 0; }
    .panel { padding: 14px; }
    .split, .split.equal { grid-template-columns: 1fr; }
    .field-grid.two, .field-grid.three { grid-template-columns: 1fr; }
    .expense-types { grid-template-columns: repeat(2,1fr); }
    .expense-types label:last-child { grid-column: 1 / -1; }
    .data-list article { grid-template-columns: 34px minmax(0,1fr) 74px; }
    .data-list article > span:nth-child(3) { grid-column: 2; text-align: left; }
    .data-list article > .row-actions { grid-column: 3; grid-row: 1 / span 2; }
    .resource-list article { grid-template-columns: 36px minmax(0,1fr) 70px; }
    .resource-list .resource-meta { grid-column: 2; text-align: left; }
    .resource-list .row-actions { grid-column: 3; grid-row: 1 / span 2; }
    .login-panel { padding: 24px; }
    .login-heading h2 { font-size: 25px; }
}
