:root {
    --ink: #17241d;
    --muted: #68776e;
    --bg: #f3f6f3;
    --card: #ffffff;
    --green-950: #123c2c;
    --green: #196c45;
    --green-light: #e6f3eb;
    --lime: #dff46a;
    --line: #dde6df;
    --red: #b52f36;
    --amber: #976400;
    --shadow: 0 12px 34px rgba(22, 53, 36, .075);
    --header-height: 72px;
    --radius: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: 'DM Sans', sans-serif; -webkit-font-smoothing: antialiased; }
body { overflow-x: hidden; }
button, input, select, textarea { font-family: inherit; }
a { color: var(--green); }

.app-header { height: var(--header-height); background: var(--green-950); color: #fff; position: sticky; top: 0; z-index: 50; }
.header-inner { height: 100%; max-width: 1168px; margin: auto; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font: 800 20px Manrope; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--lime); color: var(--green-950); box-shadow: inset 0 0 0 1px rgba(0,0,0,.04); }
.brand-copy { display: flex; flex-direction: column; line-height: 1.05; }
.brand-copy small { margin-top: 4px; color: #afc6ba; font: 700 9px 'DM Sans'; letter-spacing: .16em; text-transform: uppercase; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.header-actions form { margin: 0; }
.icon-button, .header-logout { min-width: 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid rgba(255,255,255,.22); border-radius: 12px; background: rgba(255,255,255,.07); color: #fff; }
.icon-button svg, .header-logout svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.header-logout { gap: 8px; padding: 0 14px; font-weight: 700; cursor: pointer; }
.notification-bell { position: relative; text-decoration: none; }
.notification-bell span { position: absolute; top: -5px; right: -7px; min-width: 20px; padding: 2px 5px; border: 2px solid var(--green-950); border-radius: 99px; background: #dc3f47; color: #fff; font-size: 10px; font-weight: 800; text-align: center; }

.desktop-nav { background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); position: sticky; top: var(--header-height); z-index: 40; backdrop-filter: blur(12px); }
.desktop-nav-inner { max-width: 1168px; margin: auto; padding: 0 24px; display: flex; gap: 30px; }
.desktop-nav a { position: relative; padding: 17px 0; color: var(--muted); text-decoration: none; font-weight: 700; font-size: 14px; white-space: nowrap; }
.desktop-nav a:hover, .desktop-nav a.active { color: var(--green); }
.desktop-nav a.active:after { content: ''; position: absolute; height: 3px; border-radius: 3px 3px 0 0; background: var(--green); left: 0; right: 0; bottom: 0; }

.container { max-width: 1168px; margin: 0 auto; padding: 34px 24px 80px; }
.hero { position: relative; overflow: hidden; margin-bottom: 24px; padding: 34px 36px; border-radius: 26px; background: var(--green-950); color: #fff; box-shadow: var(--shadow); }
.hero:after { content: ''; position: absolute; width: 230px; height: 230px; border-radius: 50%; background: var(--lime); right: -88px; top: -120px; opacity: .95; }
.hero > * { position: relative; z-index: 1; }
.eyebrow { color: #7b8b82; text-transform: uppercase; letter-spacing: .13em; font-size: 11px; font-weight: 800; }
.hero .eyebrow { color: #b9cec2; }
h1, h2, h3 { font-family: Manrope, sans-serif; margin: 0 0 10px; letter-spacing: -.025em; }
h1 { font-size: clamp(28px, 4.5vw, 42px); line-height: 1.12; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
p { margin: 4px 0 20px; color: var(--muted); line-height: 1.55; }
.hero p { max-width: 620px; color: #cfddd5; }

.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)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.stat { position: relative; overflow: hidden; }
.stat strong { display: block; margin-top: 8px; font: 800 32px Manrope; letter-spacing: -.04em; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

.btn, button { min-height: 44px; border: 0; border-radius: 12px; background: var(--green); color: #fff; padding: 12px 18px; font: 700 14px 'DM Sans'; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; transition: transform .15s, filter .15s; }
.btn:hover, button:hover { filter: brightness(.96); }
.btn:active, button:active { transform: translateY(1px); }
.btn.lime { background: var(--lime); color: var(--green-950); }
.btn.small, button.small { min-height: 36px; padding: 8px 12px; font-size: 12px; }
.danger { background: #fff0f0 !important; color: var(--red) !important; }
button:disabled, input:disabled, select:disabled, textarea:disabled { opacity: .58; cursor: not-allowed; }

label { display: block; margin-bottom: 7px; font-weight: 700; font-size: 13px; }
input, textarea, select { width: 100%; min-height: 48px; border: 1px solid #cbd7cf; background: #fff; border-radius: 12px; padding: 12px 14px; color: var(--ink); font-size: 16px; outline: none; transition: border .15s, box-shadow .15s; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(25,108,69,.12); }
input[type=file] { padding: 9px; }
textarea { min-height: 100px; resize: vertical; }
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.hint { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.registration-input { text-transform: uppercase; }
.divider { height: 1px; margin: 22px 0; background: var(--line); }

.badge { display: inline-flex; align-items: center; min-height: 27px; border-radius: 99px; padding: 5px 10px; background: var(--green-light); color: #176342; font-size: 11px; font-weight: 800; }
.badge.unpaid { background: #fff2cf; color: var(--amber); }
.badge.open { background: #e9efff; color: #315ba3; }
.alert { margin-bottom: 20px; padding: 15px 18px; border-radius: 14px; font-weight: 600; }
.alert.success { background: #dff4e7; color: #176342; }
.alert.error { background: #fff0f0; color: #8f2429; }
.alert.error ul { margin: 8px 0 0; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
td { overflow-wrap: anywhere; }
th { color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-size: 11px; }
tbody tr:last-child td { border-bottom: 0; }
.thumb { flex: 0 0 auto; width: 50px; height: 50px; border-radius: 14px; object-fit: cover; background: #e7ede9; }
.empty { padding: 42px 16px; color: var(--muted); text-align: center; }
.mobile-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.page-heading { margin-bottom: 20px; }
.record-list { display: flex; flex-direction: column; }
.record-item { min-height: 68px; padding: 16px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.record-item:last-child { border-bottom: 0; }
.photo-large { width: 100%; max-height: 320px; object-fit: cover; border-radius: 16px; background: #e7ede9; }
.odometer { font: 800 28px Manrope; }

.login-shell { min-height: calc(100dvh - var(--header-height) - 70px); display: grid; place-items: center; padding: 30px 0; }
.login-card { width: min(440px,100%); }
.login-card h1 { margin-top: 6px; }
.login-card form > button { width: 100%; }
.bottom-nav { display: none; }

@media (max-width: 760px) {
    :root { --header-height: 62px; --radius: 17px; }
    body.app-authenticated { padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
    .app-header { box-shadow: 0 3px 16px rgba(5,33,20,.16); }
    .header-inner { padding: 0 16px; }
    .brand-mark { width: 36px; height: 36px; border-radius: 11px; }
    .brand { font-size: 18px; }
    .brand-copy small { font-size: 8px; }
    .logout-label { display: none; }
    .header-logout { width: 42px; padding: 0; }
    .desktop-nav { display: none; }
    .container { padding: 20px 14px 30px; }
    .container > .row:first-child, .report-heading { align-items: flex-start; }
    .container > .row:first-child { flex-wrap: wrap; }
    .page-heading { flex-wrap: wrap; }
    .page-heading > div:first-child { flex: 1 1 100%; }
    .container > .row:first-child > .btn { flex: 0 0 auto; }
    .hero { margin: 0 0 16px; padding: 25px 21px; border-radius: 20px; }
    .hero:after { width: 160px; height: 160px; right: -72px; top: -88px; }
    .hero h1 { max-width: 80%; }
    h1 { font-size: 29px; }
    h2 { font-size: 20px; }
    p { margin-bottom: 16px; }
    .grid-3, .grid-2 { grid-template-columns: 1fr; gap: 14px; }
    .card { padding: 18px; box-shadow: 0 5px 18px rgba(22,53,36,.045); }
    .btn.small, button.small { min-height: 40px; }
    .stat { min-height: 112px; }
    .stat strong { font-size: 29px; }
    .row { gap: 10px; }
    .row > h1, .row > div { min-width: 0; }
    .mobile-actions { width: 100%; }
    .mobile-actions > .btn, .mobile-actions > button { flex: 1 1 0; }
    .report-heading { display: block; }
    .report-heading .mobile-actions { margin: 14px 0 18px; }

    table, tbody, tr, td { display: block; width: 100%; }
    table thead { display: none; }
    tbody tr { margin: 0; padding: 14px 0; border-bottom: 1px solid var(--line); }
    tbody tr:last-child { border-bottom: 0; }
    td { display: grid; grid-template-columns: minmax(82px, 35%) minmax(0, 1fr); align-items: center; gap: 8px; border: 0; padding: 6px 0; text-align: right; }
    td:before { content: attr(data-label); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-size: 10px; font-weight: 800; text-align: left; }
    td > * { justify-self: end; }
    td .row { justify-content: flex-end !important; }
    td.empty { display: block; padding: 30px 10px; text-align: center; }
    td.empty:before, td:not([data-label]):before { display: none; }
    td:not([data-label]) { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding-top: 10px; }
    td:not([data-label]) .btn, td:not([data-label]) button { flex: 1 1 110px; width: auto; }
    .hide-mobile { display: none !important; }

    .bottom-nav { position: fixed; z-index: 100; left: 0; right: 0; bottom: 0; min-height: calc(64px + env(safe-area-inset-bottom)); padding: 6px 8px env(safe-area-inset-bottom); display: flex; align-items: stretch; justify-content: space-around; gap: 2px; border-top: 1px solid var(--line); background: rgba(255,255,255,.97); box-shadow: 0 -8px 25px rgba(25,48,35,.08); backdrop-filter: blur(16px); }
    .bottom-nav a { position: relative; min-width: 54px; flex: 1; padding: 5px 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border-radius: 12px; color: #748078; text-decoration: none; font-size: 9px; font-weight: 800; }
    .bottom-nav a svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
    .bottom-nav a:first-child svg { fill: currentColor; stroke: none; }
    .bottom-nav a.active { color: var(--green); background: #edf6f0; }
    .role-driver .bottom-nav a { max-width: 180px; }
    .login-shell { min-height: calc(100dvh - var(--header-height) - 40px); padding: 12px 0; align-items: center; }
    .login-card { padding: 24px 20px; }
}

@media (max-width: 390px) {
    .brand-copy { font-size: 16px; }
    .container { padding-left: 11px; padding-right: 11px; }
    .card { padding: 16px; }
    .container > .row:first-child { flex-wrap: wrap; }
    .container > .row:first-child > .btn { width: 100%; }
    .mobile-actions > .btn, .mobile-actions > button { flex-basis: 100%; }
}

@media print {
    .app-header, .desktop-nav, .bottom-nav, .report-filters, .report-heading .mobile-actions { display: none !important; }
    body { background: #fff; padding: 0 !important; }
    .container { max-width: none; padding: 0; }
    .card { box-shadow: none; break-inside: avoid; }
    a { color: inherit; text-decoration: none; }
}
