:root {
    --ink: #102a43;
    --muted: #627d98;
    --line: #d9e2ec;
    --surface: #fff;
    --canvas: #edf2f7;
    --blue: #1565c0;
    --blue-dark: #0d47a1;
    --yellow: #f6c945;
    --green: #16865b;
    --red: #c43d4b;
    --shadow: 0 12px 32px rgba(16, 42, 67, .08);
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; color: var(--ink); background: var(--canvas); }
body { overflow-x: hidden; line-height: 1.45; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .35rem; font-size: clamp(1.9rem, 3vw, 2.6rem); line-height: 1.1; letter-spacing: -.035em; }
h2 { margin-bottom: .45rem; }
.muted { color: var(--muted); }
.eyebrow { margin-bottom: .45rem; color: var(--blue); font-size: .72rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }

.topbar { position: sticky; z-index: 1000; top: 0; min-height: 76px; padding: 0 clamp(1rem, 4vw, 3rem); display: flex; align-items: center; gap: 2rem; background: rgba(255,255,255,.96); border-bottom: 1px solid rgba(188,204,220,.72); box-shadow: 0 4px 22px rgba(16,42,67,.06); backdrop-filter: blur(16px); }
.brand { display: inline-flex; align-items: center; gap: .75rem; margin-right: auto; }
.brand-mark, .login-logo { display: grid; place-items: center; color: var(--ink); background: var(--yellow); font-weight: 900; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px 11px 11px 3px; }
.brand span:last-child { display: flex; flex-direction: column; line-height: 1.1; }
.brand small { margin-top: .2rem; color: var(--muted); font-size: .68rem; }
.topbar nav { display: flex; gap: .35rem; }
.topbar nav a { padding: .65rem .9rem; border-radius: 9px; color: var(--muted); font-size: .9rem; font-weight: 700; }
.topbar nav a:hover { color: var(--blue); background: #edf5ff; }
.topbar form { margin: 0; }

.page-shell { width: min(1540px, 100%); margin: 0 auto; padding: clamp(1.25rem, 3vw, 2.4rem); }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.4rem; }
.page-heading p:last-child { margin-bottom: 0; }
.dashboard-hero { position: relative; min-height: 190px; margin-bottom: 1.2rem; padding: clamp(1.5rem, 4vw, 2.7rem); display: flex; align-items: center; justify-content: space-between; gap: 2rem; overflow: hidden; color: #fff; background: linear-gradient(118deg, #102a43 0%, #153f73 52%, #1565c0 100%); border-radius: 24px; box-shadow: 0 22px 48px rgba(16,42,67,.2); }
.dashboard-hero::before, .dashboard-hero::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.dashboard-hero::before { width: 340px; height: 340px; right: 9%; top: -210px; border: 65px solid rgba(246,201,69,.13); }
.dashboard-hero::after { width: 190px; height: 190px; right: -75px; bottom: -105px; background: rgba(255,255,255,.07); }
.dashboard-hero > * { position: relative; z-index: 1; }
.dashboard-hero .eyebrow { color: var(--yellow); }
.dashboard-hero h1 { margin-bottom: .65rem; font-size: clamp(2.1rem, 4vw, 3.5rem); }
.dashboard-hero p:last-child { margin: 0; color: #d9e8f7; font-size: 1rem; }
.live-connection { display: flex; align-items: flex-end; flex-direction: column; gap: .55rem; }
.live-connection small { color: #bcccdc; }
.live-connection .status-pill { padding: .55rem .9rem; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22); }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.stats-grid article { display: flex; align-items: center; justify-content: flex-start; gap: 1rem; padding: 1.15rem 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 17px; box-shadow: var(--shadow); }
.stats-grid span { color: var(--muted); font-size: .86rem; font-weight: 650; }
.stats-grid strong { display: block; margin: .1rem 0; font-size: 1.8rem; line-height: 1; }
.stats-grid small { color: #829ab1; font-size: .7rem; }
.stat-icon { display: grid; place-items: center; flex: 0 0 48px; height: 48px; border-radius: 14px; font-size: .7rem !important; font-weight: 900 !important; letter-spacing: .02em; }
.stat-blue .stat-icon { color: #0d47a1; background: #e6f1ff; }
.stat-yellow .stat-icon { color: #755400; background: #fff2c2; }
.stat-purple .stat-icon { color: #6842a0; background: #f0e8ff; }
.stat-green .stat-icon { color: #096b48; background: #dff7ed; }

.tracking-grid { display: grid; grid-template-columns: minmax(0, 2.15fr) minmax(320px, .72fr); min-height: 650px; gap: 1rem; }
.map-card, .driver-feed, .table-card, .form-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
#map { width: 100%; min-height: 590px; }
.map-toolbar { min-height: 60px; padding: .75rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); }
.map-toolbar strong, .map-toolbar span { display: block; }
.map-toolbar strong { font-size: .86rem; }
.map-toolbar div > span { margin-top: .15rem; color: var(--muted); font-size: .72rem; }
.map-legend { display: flex !important; align-items: center; gap: .45rem; color: var(--muted); font-size: .72rem; font-weight: 750; }
.map-legend i { width: 9px; height: 9px; border-radius: 50%; background: #1eb980; box-shadow: 0 0 0 4px #e1f7ef; }
.driver-feed { max-height: 650px; overflow-y: auto; }
.card-heading { position: sticky; z-index: 2; top: 0; min-height: 76px; padding: 1rem 1.2rem; display: flex; align-items: center; justify-content: space-between; background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); }
.card-heading .eyebrow { margin-bottom: .15rem; font-size: .62rem; }
.card-heading h2 { margin: 0; font-size: 1.05rem; }
.card-heading span { display: grid; place-items: center; min-width: 25px; height: 25px; padding: 0 .35rem; border-radius: 999px; color: var(--blue); background: #edf5ff; font-weight: 800; font-size: .75rem; }
.driver-row { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: .8rem; padding: 1rem 1.2rem; border-bottom: 1px solid #edf2f6; cursor: pointer; transition: .18s ease; }
.driver-row:hover, .driver-row.selected { background: #f2f7fd; }
.driver-row.reporting { box-shadow: inset 3px 0 #1eb980; }
.driver-row.on-trip { background-image: linear-gradient(90deg, rgba(111, 66, 193, .06), transparent 55%); }
.driver-row strong, td strong { display: block; font-size: .86rem; }
.driver-row div > span { display: block; margin-top: .08rem; color: #334e68; font-size: .78rem; }
.driver-row small, td small { display: block; margin-top: .2rem; color: var(--muted); font-size: .75rem; }
.driver-row time { color: var(--muted); font-size: .72rem; }
.driver-report { display: flex; align-items: flex-end; flex-direction: column; gap: .2rem; }
.driver-report b { color: #486581; font-size: .68rem; }
.driver-dot { width: 9px; height: 9px; border-radius: 50%; background: #bcccdc; box-shadow: 0 0 0 4px #eef2f5; }
.driver-dot.online { background: #1eb980; box-shadow: 0 0 0 4px #e1f7ef; }
.driver-dot.waiting { background: #f0b429; box-shadow: 0 0 0 4px #fff3ca; }
.taxi-marker { display: grid; place-items: center; width: 46px; height: 30px; border: 3px solid #fff; border-radius: 9px 9px 9px 2px; color: var(--ink); background: var(--yellow); box-shadow: 0 6px 18px rgba(16,42,67,.3); font-size: 9px; font-weight: 950; }
.taxi-marker.online { background: #35d099; }

.button { min-height: 38px; padding: .55rem .9rem; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: #fff; cursor: pointer; font-weight: 750; font-size: .85rem; }
.button:hover { border-color: #9fb3c8; }
.button-primary { color: #fff; border-color: var(--blue); background: var(--blue); }
.button-primary:hover { background: var(--blue-dark); }
.button-danger { color: var(--red); border-color: #f0bec4; background: #fff6f7; }
.button-success { color: var(--green); border-color: #a9ddca; background: #effaf6; }
.button-ghost { background: transparent; }
.button-large { min-height: 48px; }
.button-small { min-height: 32px; padding: .38rem .6rem; font-size: .75rem; }
.status-pill { display: inline-flex; align-items: center; width: max-content; padding: .35rem .7rem; border-radius: 999px; font-size: .72rem; font-weight: 800; }
.status-online { color: #096b48; background: #dff7ed; }
.status-idle, .status-waiting { color: #8b6508; background: #fff3ca; }
.status-trip { color: #6842a0; background: #f0e8ff; }
.status-off { color: #8d3340; background: #ffe8eb; }

.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.08fr .92fr; }
.login-visual { position: relative; padding: clamp(2rem, 7vw, 7rem); display: flex; flex-direction: column; justify-content: center; color: #fff; overflow: hidden; background: linear-gradient(145deg, #102a43 0%, #0d47a1 100%); }
.login-visual::after { content: ""; position: absolute; width: 420px; height: 420px; right: -110px; bottom: -130px; border: 80px solid rgba(246,201,69,.13); border-radius: 50%; }
.login-visual .eyebrow { color: var(--yellow); }
.login-visual h1 { font-size: clamp(3.2rem, 7vw, 6.5rem); max-width: 800px; margin-bottom: 1.2rem; }
.login-visual > p:last-child { max-width: 520px; color: #bcccdc; font-size: 1.1rem; }
.login-logo { width: 58px; height: 58px; margin-bottom: 3rem; border-radius: 18px 18px 18px 5px; font-size: 1.6rem; }
.login-card { width: min(480px, 88%); margin: auto; padding: 2rem; display: grid; gap: 2rem; }
.login-card h2 { margin: 0; font-size: 2rem; }
.form-stack { display: grid; }
label { margin-bottom: .4rem; color: #334e68; font-size: .82rem; font-weight: 750; }
input { width: 100%; min-height: 44px; margin-bottom: .9rem; padding: .65rem .78rem; border: 1px solid #bcccdc; border-radius: 9px; color: var(--ink); background: #fff; outline: none; }
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(21,101,192,.12); }
.checkbox { display: flex; align-items: center; gap: .5rem; margin-bottom: 1.1rem; }
.checkbox input { width: 17px; min-height: 17px; margin: 0; }
.validation { color: var(--red); font-size: .77rem; }
div.validation:empty, span.validation:empty { display: none; }
.validation ul { margin: 0 0 1rem; padding-left: 1.2rem; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: .9rem 1rem; color: var(--muted); background: #f8fafc; border-bottom: 1px solid var(--line); text-align: left; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; }
td { padding: 1rem; border-bottom: 1px solid #edf2f6; font-size: .86rem; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.actions { display: flex; justify-content: flex-end; gap: .45rem; }
.actions form { margin: 0; }
.empty-table, .empty-compact, .empty-state { color: var(--muted); text-align: center; }
.empty-table { padding: 3rem; }
.empty-compact { padding: 2rem 1rem; }
.empty-state { width: min(620px, 90%); margin: 15vh auto; padding: 3rem; background: #fff; border-radius: 16px; }

.form-card { padding: clamp(1.2rem, 3vw, 2rem); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 1.2rem; }
.field { display: flex; flex-direction: column; }
.field-wide { grid-column: 1 / -1; }
.form-actions { margin-top: 1rem; padding-top: 1.2rem; display: flex; justify-content: flex-end; gap: .6rem; border-top: 1px solid var(--line); }
.danger-zone { margin-top: 1rem; display: flex; align-items: end; justify-content: space-between; gap: 2rem; }
.danger-zone h2 { font-size: 1.1rem; }
.danger-zone p { margin: 0; }
.inline-form { display: flex; align-items: center; gap: .6rem; }
.inline-form input { min-width: 280px; margin: 0; }
.alert { margin-bottom: 1rem; padding: .85rem 1rem; border-radius: 9px; font-size: .86rem; font-weight: 700; }
.alert-success { color: #096b48; background: #dff7ed; border: 1px solid #a9ddca; }
.alert-error { color: #8d3340; background: #ffe8eb; border: 1px solid #f0bec4; }
.settings-grid { display: grid; grid-template-columns: minmax(0, 720px); }
.settings-grid .form-card h2 { margin-bottom: .55rem; }
.setting-control { margin-top: 1.5rem; display: flex; align-items: flex-end; gap: .75rem; }
.setting-control .field { width: 190px; }
.setting-control input { margin-bottom: 0; font-size: 1.25rem; font-weight: 800; }
.setting-unit { padding-bottom: .8rem; color: var(--muted); font-weight: 750; }
.setting-example { margin-top: 1.5rem; padding: 1rem; display: grid; gap: .25rem; color: #334e68; background: #edf5ff; border-radius: 12px; }
.setting-example span { color: var(--muted); font-size: .84rem; }

@media (max-width: 900px) {
    .topbar { flex-wrap: wrap; gap: .5rem; padding-block: .7rem; }
    .topbar nav { order: 3; width: 100%; overflow-x: auto; }
    .tracking-grid { grid-template-columns: 1fr; }
    #map { min-height: 480px; }
    .driver-feed { max-height: 380px; }
    .login-page { grid-template-columns: 1fr; }
    .login-visual { min-height: 38vh; padding: 2rem; }
    .login-visual h1 { font-size: 3rem; }
    .login-logo { margin-bottom: 1rem; }
    .login-card { padding-block: 3rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
    .dashboard-hero { min-height: 230px; align-items: flex-start; flex-direction: column; }
    .live-connection { align-items: flex-start; }
    .login-visual h1 { font-size: 2.6rem; overflow-wrap: anywhere; }
    .login-card { width: 100%; padding: 2.5rem 1.5rem; }
    .page-heading, .danger-zone { align-items: stretch; flex-direction: column; }
    .stats-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .field-wide { grid-column: auto; }
    .inline-form { align-items: stretch; flex-direction: column; }
    .inline-form input { min-width: 0; }
}
