/* ============================================================
   Vehicle Log — design system
   ============================================================ */

:root {
    --brand:        #0f766e;
    --brand-dark:   #115e59;
    --brand-soft:   #ccfbf1;
    --bg:           #f4f5f7;
    --card:         #ffffff;
    --ink:          #1a202c;
    --ink-2:        #5b6472;
    --ink-3:        #98a1b0;
    --line:         #e7e9ee;
    --green:        #16a34a;
    --green-ink:    #04703c;
    --green-bg:     #e9f9ef;
    --amber:        #d97706;
    --amber-ink:    #92510a;
    --amber-bg:     #fdf3e0;
    --red:          #dc2626;
    --red-ink:      #b91c1c;
    --red-bg:       #fdecec;
    --radius:       16px;
    --shadow:       0 1px 3px rgba(16, 24, 40, .07), 0 6px 18px rgba(16, 24, 40, .05);
    --shadow-lift:  0 4px 10px rgba(16, 24, 40, .10), 0 12px 32px rgba(16, 24, 40, .10);
}

* { -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
}

h1, h2, h3, h4 { font-weight: 700; letter-spacing: -.02em; }

/* ---------- Top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; gap: 12px;
    background: var(--brand);
    color: #fff;
    padding: 14px 18px;
    padding-top: calc(14px + env(safe-area-inset-top));
}
.driver-topbar { justify-content: space-between; }
.topbar-brand { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }
.topbar-brand .bi { margin-right: 6px; }

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px;
    border: 0; border-radius: 12px;
    background: rgba(255, 255, 255, .14);
    color: #fff; font-size: 1.35rem;
    text-decoration: none;
}
.icon-btn:active { background: rgba(255, 255, 255, .28); color: #fff; }
.icon-btn:hover  { color: #fff; }

/* ---------- Admin sidebar ---------- */
.has-sidebar .content {
    padding: 24px 18px 48px;
    max-width: 1060px;
    margin: 0 auto;
}
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
    width: 250px;
    background: #fff;
    border-right: 1px solid var(--line);
    padding: 18px 14px;
    transform: translateX(-100%);
    transition: transform .22s ease;
    display: flex; flex-direction: column;
}
.sidebar-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-lift); }
.sidebar-overlay {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(15, 23, 42, .45);
    opacity: 0; pointer-events: none;
    transition: opacity .22s ease;
}
.sidebar-open .sidebar-overlay { opacity: 1; pointer-events: auto; }

.sidebar-brand {
    font-size: 1.2rem; font-weight: 800; color: var(--brand);
    padding: 8px 12px 20px;
}
.sidebar-brand .bi { margin-right: 8px; }
.sidebar-link {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; margin-bottom: 2px;
    border-radius: 12px;
    color: var(--ink-2); font-weight: 500;
    text-decoration: none;
    font-size: 1rem;
}
.sidebar-link .bi { font-size: 1.15rem; }
.sidebar-link:hover  { background: var(--bg); color: var(--ink); }
.sidebar-link.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.sidebar-logout { margin-top: auto; color: var(--ink-3); }

@media (min-width: 992px) {
    .sidebar { transform: none; }
    .sidebar-toggle, .sidebar-overlay { display: none; }
    .has-sidebar .topbar { display: none; }
    .has-sidebar .content { margin-left: 250px; padding: 36px 36px 64px; max-width: none; }
}

/* ---------- Alerts / flash banners ---------- */
.app-alert {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px; margin-bottom: 18px;
    border-radius: 14px;
    font-weight: 600; font-size: 1rem;
    transition: opacity .6s ease;
}
.app-alert.fade-out { opacity: 0; }
.app-alert-success { background: var(--green-bg); color: var(--green-ink); }
.app-alert-danger  { background: var(--red-bg);   color: var(--red-ink); }
.app-alert .bi { font-size: 1.2rem; }

/* ---------- Login ---------- */
.login-page {
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    background: linear-gradient(160deg, #0f766e 0%, #115e59 55%, #134e4a 100%);
}
.login-card {
    background: var(--card);
    border-radius: 22px;
    box-shadow: var(--shadow-lift);
    padding: 34px 28px;
    width: 100%; max-width: 400px;
    text-align: center;
}
.login-logo {
    width: 68px; height: 68px; margin: 0 auto 14px;
    display: flex; align-items: center; justify-content: center;
    background: var(--brand-soft); color: var(--brand);
    border-radius: 20px; font-size: 2rem;
}
.login-card h1 { font-size: 1.5rem; margin-bottom: 2px; }
.login-sub { color: var(--ink-2); margin-bottom: 22px; }
.login-card form { text-align: left; }
.login-card .form-label { font-weight: 600; font-size: .92rem; }
.login-card .form-control {
    border-radius: 12px; border-color: var(--line);
    padding: 12px 14px; font-size: 1.05rem;
}
.login-card .form-control:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 .2rem rgba(15, 118, 110, .15);
}
.remember-row {
    display: flex; align-items: center; gap: 10px;
    margin: 18px 0 20px;
    color: var(--ink-2); font-size: .95rem;
    cursor: pointer;
}
.remember-row input { width: 20px; height: 20px; accent-color: var(--brand); }

.btn-brand {
    background: var(--brand); border: 0; color: #fff;
    border-radius: 14px; font-weight: 700;
    padding: 13px;
}
.btn-brand:hover, .btn-brand:focus, .btn-brand:active { background: var(--brand-dark); color: #fff; }

/* ---------- Driver log screen ---------- */
.driver-shell { font-size: 18px; }
.driver-content {
    padding: 20px 16px 48px;
    max-width: 520px; margin: 0 auto;
}
.log-title { font-size: 1.5rem; margin-bottom: 2px; }
.log-hint { color: var(--ink-2); margin-bottom: 18px; font-size: 1rem; }

.vehicle-list { display: flex; flex-direction: column; gap: 14px; }

.vehicle-card {
    display: block; width: 100%; text-align: left;
    background: var(--card);
    border: 0; border-left: 6px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 18px 16px;
    transition: transform .08s ease, box-shadow .08s ease;
}
.vehicle-card:active { transform: scale(.985); box-shadow: var(--shadow-lift); }
.vehicle-card.parked { border-left-color: var(--green); }
.vehicle-card.out    { border-left-color: var(--amber); }

.vc-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.vc-name { font-size: 1.35rem; font-weight: 700; letter-spacing: -.01em; }
.vc-sub { color: var(--ink-2); font-size: 1rem; margin-top: 4px; }
.vc-sub strong { color: var(--ink); }
.vc-action {
    margin-top: 12px; padding-top: 12px;
    border-top: 1px solid var(--line);
    color: var(--brand); font-weight: 600; font-size: 1rem;
    display: flex; align-items: center; justify-content: space-between;
}
.vehicle-card.out .vc-action { color: var(--amber-ink); }

.status-pill {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: .82rem; font-weight: 700;
    white-space: nowrap;
}
.pill-parked { background: var(--green-bg); color: var(--green-ink); }
.pill-out    { background: var(--amber-bg); color: var(--amber-ink); }
.pill-stale  { background: var(--red-bg);   color: var(--red-ink); }

/* ---------- Guided flow overlay ---------- */
.flow-open { overflow: hidden; }
.flow-overlay {
    position: fixed; inset: 0; z-index: 100;
    background: var(--bg);
    display: flex; flex-direction: column;
}
.flow-header {
    display: flex; align-items: center; gap: 12px;
    background: var(--brand); color: #fff;
    padding: 14px 18px;
    padding-top: calc(14px + env(safe-area-inset-top));
}
.flow-vehicle { font-size: 1.1rem; font-weight: 700; }
.flow-body {
    flex: 1; overflow-y: auto;
    padding: 28px 20px 48px;
    max-width: 520px; margin: 0 auto; width: 100%;
}
.flow-step h2 { font-size: 1.45rem; margin-bottom: 6px; }
.flow-hint { color: var(--ink-2); font-size: 1.05rem; margin-bottom: 20px; }

.driver-grid { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.driver-btn {
    display: flex; align-items: center; gap: 12px;
    width: 100%;
    background: var(--card);
    border: 2px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    font-size: 1.2rem; font-weight: 600; color: var(--ink);
    text-align: left;
}
.driver-btn .bi { color: var(--brand); font-size: 1.3rem; }
.driver-btn:active { border-color: var(--brand); background: var(--brand-soft); }

.odo-input {
    width: 100%;
    background: var(--card);
    border: 2px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    font-size: 2rem; font-weight: 700; letter-spacing: .02em;
    text-align: center;
    color: var(--ink);
}
.odo-input:focus {
    outline: none; border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, .15);
}

.flow-error {
    margin: 14px 0 0;
    padding: 12px 14px;
    background: var(--red-bg); color: var(--red-ink);
    border-radius: 12px;
    font-weight: 600; font-size: 1rem;
}

.btn-big {
    display: block; width: 100%;
    margin-top: 20px;
    border: 0; border-radius: var(--radius);
    padding: 18px;
    font-size: 1.25rem; font-weight: 700; color: #fff;
    box-shadow: var(--shadow);
}
.btn-big:disabled { opacity: .7; }
.btn-big-green { background: var(--green); }
.btn-big-green:active { background: #12813b; }
.btn-big-amber { background: var(--amber); }
.btn-big-amber:active { background: #b45309; }

/* ---------- Admin: cards, stat tiles, tables ---------- */
.page-title { font-size: 1.45rem; margin-bottom: 4px; }
.page-sub { color: var(--ink-2); margin-bottom: 22px; }

.panel {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 20px;
}
.panel h2 { font-size: 1.1rem; margin-bottom: 16px; }

.stat-row {
    display: grid; gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    margin-bottom: 20px;
}
.stat-tile {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
}
.stat-label {
    color: var(--ink-2); font-size: .85rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em;
    margin-bottom: 6px;
}
.stat-value { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; }
.stat-value small { font-size: 1rem; font-weight: 600; color: var(--ink-2); }

.status-grid {
    display: grid; gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    margin-bottom: 20px;
}

.table-wrap { overflow-x: auto; }
.app-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.app-table th {
    text-align: left; color: var(--ink-2); font-weight: 600;
    font-size: .82rem; text-transform: uppercase; letter-spacing: .04em;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.app-table td {
    padding: 12px; border-bottom: 1px solid var(--line);
    vertical-align: middle; white-space: nowrap;
}
.app-table tr:last-child td { border-bottom: 0; }
.app-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.app-table th.num { text-align: right; }
.app-table tfoot td { font-weight: 700; border-top: 2px solid var(--line); }

/* ---------- Admin forms ---------- */
.filter-bar {
    display: flex; flex-wrap: wrap; gap: 10px;
    align-items: flex-end;
    margin-bottom: 18px;
}
.filter-bar .form-label { font-size: .82rem; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.filter-bar .form-select, .filter-bar .form-control {
    border-radius: 10px; border-color: var(--line); min-width: 140px;
}
.form-select:focus, .form-control:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 .2rem rgba(15, 118, 110, .12);
}

.btn-outline-brand {
    border: 1.5px solid var(--brand); color: var(--brand);
    border-radius: 10px; font-weight: 600;
    background: transparent;
}
.btn-outline-brand:hover { background: var(--brand); color: #fff; }

.badge-soft { padding: 4px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.badge-open   { background: var(--amber-bg); color: var(--amber-ink); }
.badge-closed { background: var(--green-bg); color: var(--green-ink); }
.badge-off    { background: var(--bg); color: var(--ink-3); }

/* ---------- Maintenance form ---------- */
.field-grid {
    display: grid; gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-bottom: 14px;
}
.field-grid .form-label { font-size: .82rem; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.field-grid .form-select, .field-grid .form-control { border-radius: 10px; border-color: var(--line); }

.next-due-box {
    border: 1px dashed var(--line);
    border-radius: 14px;
    padding: 16px 16px 8px;
    margin-top: 6px;
}
.next-due-box legend {
    float: none; width: auto;
    font-size: .95rem; font-weight: 700;
    padding: 0 6px; margin-bottom: 10px;
}
.muted-note { color: var(--ink-3); font-weight: 500; font-size: .85rem; }

.quick-suggest {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    margin: 4px 0 12px;
}
.quick-suggest .btn { border-radius: 999px; }

/* ---------- Due dates ---------- */
.due-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.due-heading-overdue { color: var(--red-ink); }
.due-heading-soon    { color: var(--amber-ink); }

.due-list { display: flex; flex-direction: column; gap: 10px; }
.due-item {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px;
    background: var(--bg);
    border-left: 5px solid var(--line);
    border-radius: 14px;
}
.due-item.due-overdue { background: var(--red-bg);   border-left-color: var(--red); }
.due-item.due-soon    { background: var(--amber-bg); border-left-color: var(--amber); }
.due-item.due-ok      { border-left-color: var(--green); }

.due-icon {
    display: flex; align-items: center; justify-content: center;
    flex: 0 0 auto;
    width: 40px; height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .75);
    color: var(--ink-2); font-size: 1.15rem;
}
.due-main { flex: 1 1 auto; min-width: 0; }
.due-what { font-weight: 700; letter-spacing: -.01em; }
.due-meta { color: var(--ink-2); font-size: .9rem; margin-top: 2px; }
.due-right {
    display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
    justify-content: flex-end;
    flex: 0 0 auto;
}
.due-link {
    color: var(--brand); font-weight: 600; font-size: .9rem;
    text-decoration: none; white-space: nowrap;
    display: inline-block; margin-top: 4px;
}
.due-link:hover { color: var(--brand-dark); text-decoration: underline; }

.stat-tile-link { display: block; color: inherit; text-decoration: none; }
.stat-tile-link:hover { color: inherit; box-shadow: var(--shadow-lift); }
.tile-overdue { background: var(--red-bg); }
.tile-overdue .stat-label, .tile-overdue .stat-value { color: var(--red-ink); }
.tile-soon { background: var(--amber-bg); }
.tile-soon .stat-label, .tile-soon .stat-value { color: var(--amber-ink); }

@media (max-width: 576px) {
    .panel { padding: 16px; }
    .has-sidebar .content { padding: 18px 12px 48px; }
    .due-item { flex-wrap: wrap; }
    .due-right { width: 100%; justify-content: flex-start; padding-left: 54px; }
}
