:root {
    --oc-ink: #14213d;
    --oc-ink-2: #1f2f57;
    --oc-amber: #fca311;
    --oc-bg: #f3f5f9;
}

body { background: var(--oc-bg); }
.bg-ink { background: var(--oc-ink) !important; }
.min-vw-0 { min-width: 0; }

.brand-mark {
    display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
    background: var(--oc-amber); color: var(--oc-ink); font-size: 1.25rem;
}
.brand-mark-lg { width: 64px; height: 64px; font-size: 2rem; border-radius: 16px; }
.brand-mark-sm { width: 28px; height: 28px; font-size: 1rem; border-radius: 7px; }
/* Logo yang diunggah (menu Pengaturan): latar putih agar logo gelap tetap terlihat di header gelap */
.brand-mark.has-logo { background: #fff; padding: 3px; overflow: hidden; flex-shrink: 0; }
.brand-mark.has-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.logo-preview { width: 96px; height: 96px; display: grid; place-items: center; border: 1px dashed #ced4da; border-radius: 12px; background: #fff; }
.logo-preview img { max-width: 88px; max-height: 88px; object-fit: contain; }

/* Footer copyright */
.app-footer { text-align: center; font-size: .75rem; color: #8a93a6; padding: 28px 0 4px; }
.login-footer { color: rgba(255, 255, 255, .55); padding: 16px 0 0; }

/* ---------------- Login ---------------- */
.login-page {
    min-height: 100vh; display: grid; place-items: center; grid-template-rows: 1fr auto; padding: 16px;
    background: radial-gradient(circle at 20% 10%, var(--oc-ink-2), var(--oc-ink) 60%);
}
.login-card { width: 100%; max-width: 380px; border-radius: 16px; }

/* ---------------- Admin ---------------- */
@media (min-width: 992px) {
    /* Lebar dikunci (Bootstrap offcanvas-lg memakai width:auto !important) supaya sidebar tidak
       terdorong menyempit oleh konten lebar seperti board kanban. */
    .sidebar.offcanvas-lg { flex: 0 0 250px; width: 250px !important; height: 100vh !important;
        position: sticky; top: 0; display: flex; flex-direction: column; }
}
/* Daftar menu bisa di-scroll sendiri, sehingga bagian "Login sebagai / Keluar" selalu terlihat */
.sidebar > .nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; flex-wrap: nowrap; }
.sidebar > div { flex-shrink: 0; }
.sidebar .nav-link { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar.offcanvas-lg { --bs-offcanvas-bg: var(--oc-ink); --bs-offcanvas-color: #fff; }
.sidebar .offcanvas-body, .sidebar { display: flex; flex-direction: column; }
.sidebar .nav-link { color: rgba(255,255,255,.75); border-radius: 8px; padding: .6rem .8rem; }
.sidebar .nav-link:hover { color: #fff; background: rgba(255,255,255,.07); }
.sidebar .nav-link.active { color: var(--oc-ink); background: var(--oc-amber); font-weight: 600; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.page-head h1 { font-size: 1.35rem; font-weight: 700; margin: 0; }
.page-head .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

.kpi { background: #fff; border-radius: 12px; padding: 1rem; border: 1px solid #e6e9f0; height: 100%; }
.kpi .label { color: #6c757d; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 1.7rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi .icon { float: right; font-size: 1.4rem; color: var(--oc-amber); }

.card { border-color: #e6e9f0; border-radius: 12px; }
.table td, .table th { vertical-align: middle; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: #6c757d; white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.map-box { height: 420px; border-radius: 12px; border: 1px solid #e6e9f0; z-index: 0; }
.dest-dot { display: block; width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.35); }

/* Live map */
.live-wrap { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 992px) { .live-wrap { grid-template-columns: 320px 1fr; } }
#liveMap { height: calc(100vh - 140px); min-height: 420px; }
.driver-list { max-height: calc(100vh - 140px); overflow: auto; }
.driver-list .list-group-item { cursor: pointer; }
.truck-pin {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
    color: #fff; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); font-size: 15px;
}
.truck-pin.trip { background: #fd7e14; }
.truck-pin.duty { background: #198754; }
.truck-pin.off  { background: #6c757d; }
.truck-pin.stale { opacity: .55; filter: grayscale(.6); }
.truck-label {
    background: var(--oc-ink); color: #fff; border: 0; border-radius: 6px; font-weight: 600; padding: 1px 6px; box-shadow: none;
}
.truck-label::before { display: none; }
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }

/* ---------------- Driver (mobile) ---------------- */
body.driver { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
.driver-top { position: sticky; top: 0; z-index: 1020; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; }
.install-bar { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: var(--oc-ink-2); }
.install-bar .btn { margin-left: auto; }
.driver-main { max-width: 560px; margin: 0 auto; padding: 16px; }
.card-d { border: 0; border-radius: 16px; box-shadow: 0 1px 3px rgba(20,33,61,.08); }
.stat-box { background: var(--oc-bg); border-radius: 12px; padding: 10px; }
.stat-box.ok { background: #e8f6ee; color: #146c43; }
.active-trip { background: #fff7e6; border: 1px solid #ffe0a3; border-radius: 12px; padding: 12px; }
.dest-list { max-height: 300px; overflow: auto; }
.dest-list .list-group-item { padding: .7rem .8rem; }
.dest-list .list-group-item:has(input:checked) { background: #eef4ff; border-color: #9ec5fe; }
.trip-timeline li { position: relative; padding: 0 0 12px 20px; border-left: 2px solid #dee2e6; margin-left: 6px; }
.trip-timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.trip-timeline li::before { content: ''; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: #198754; }
.trip-timeline li.is-active::before { background: var(--oc-amber); box-shadow: 0 0 0 4px rgba(252,163,17,.25); }

.driver-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; display: flex; background: #fff;
    border-top: 1px solid #e6e9f0; padding-bottom: env(safe-area-inset-bottom);
}
.driver-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 8px 0; color: #6c757d; text-decoration: none; font-size: .75rem; }
.driver-nav a i { font-size: 1.35rem; }
.driver-nav a.active { color: var(--oc-ink); font-weight: 600; }

/* ---------------- Kanban rencana pengiriman ---------------- */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.kcol { flex: 0 0 280px; background: #e9edf4; border-radius: 12px; display: flex; flex-direction: column; max-height: calc(100vh - 230px); }
.kcol-head { padding: 10px 12px; border-radius: 12px 12px 0 0; background: var(--oc-ink); color: #fff; }
.kcol.unassigned .kcol-head { background: #6c757d; }
.kest { opacity: .85; }
.klist { padding: 8px; overflow-y: auto; min-height: 120px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.kcard { background: #fff; border-radius: 10px; padding: 8px 10px; border: 1px solid #dde2ea; border-left: 4px solid #adb5bd; cursor: grab; }
.kcard:active { cursor: grabbing; }
.kcard.status-onsite { border-left-color: #fd7e14; background: #fff7e6; }
.kcard.status-done { border-left-color: #198754; background: #f0f8f3; }
.kcard.locked { cursor: default; }
.kcard.no-driver { border-color: #f1aeb5; border-left-color: #dc3545; }
.kcard .kno { display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 50%; background: var(--oc-ink); color: #fff; font-size: .75rem; font-weight: 700; }
.kcol.unassigned .kcard .kno { background: #adb5bd; }
.kcard .knote { color: #495057; cursor: pointer; }
.kcard .knote.empty { color: #adb5bd; }
.kghost { opacity: .4; background: #cfe2ff; }
.add-list { max-height: 45vh; overflow: auto; }
.plan-no { display: inline-grid; place-items: center; min-width: 24px; height: 24px; border-radius: 50%; background: var(--oc-ink); color: #fff; font-size: .8rem; font-weight: 700; }

/* ---------------- Driver: tujuan berikutnya & aktivitas lain ---------------- */
.next-card { border: 2px solid #0d6efd !important; }
.plan-list .plan-truck { border-top: 0 !important; }
.plan-list .plan-next { background: #eef4ff; border-radius: 8px; padding-left: 6px; padding-right: 6px; }
.stop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.stop-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; font-size: .8rem; line-height: 1.2; }
.stop-btn i { font-size: 1.4rem; color: var(--oc-ink); }
.trip-timeline li.is-stop::before { background: #0dcaf0; }
details > summary { cursor: pointer; list-style: revert; }
.truck-pin.stop { background: #0dcaf0; }

/* ---------------- Tugas, kontak & foto bukti ---------------- */
.contact-box { background: #f0f7f3; border: 1px solid #cfe8da; border-radius: 12px; padding: 10px; }
.instructions-box { background: #fff8e1; border: 1px solid #ffe08a; border-radius: 12px; padding: 10px; }
.task-done { padding: 8px 10px; border: 1px solid #dee2e6; border-radius: 10px; margin-bottom: 6px; background: #fff; }
.task-done:has(input:checked) { background: #e8f6ee; border-color: #a3cfbb; }
.photo-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid #dee2e6; }
.ktasks .badge { font-size: .7rem; }
.proof-photo { width: 160px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid #dee2e6; }

/* ---------------- Pembaruan otomatis & notifikasi ---------------- */
.live-toast {
    position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 1060;
    max-width: 536px; margin: 0 auto; background: var(--oc-ink); color: #fff; border-radius: 12px;
    padding: 12px 14px; box-shadow: 0 6px 24px rgba(0,0,0,.25); font-size: .9rem; animation: toastIn .25s ease-out;
}
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.live-flash > section { animation: liveFlash 2.4s ease-out; }
@keyframes liveFlash { 0%, 30% { box-shadow: 0 0 0 3px #fca311; } 100% { box-shadow: 0 1px 3px rgba(20,33,61,.08); } }

/* ---------------- Sidebar: grup menu ---------------- */
.sidebar .nav-group {
    margin: .9rem .8rem .3rem; font-size: .7rem; font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; color: rgba(255,255,255,.45);
}
.sidebar .nav-item + .nav-item { margin-top: 2px; }
.sidebar .nav-link { padding: .5rem .8rem; }

/* ---------------- Pengaturan ---------------- */
.settings-save { position: sticky; bottom: 0; z-index: 5; background: var(--oc-bg); padding: 12px 0; border-top: 1px solid #e6e9f0; }
