:root {
    --ink: #18202b;
    --muted: #667085;
    --line: #e5e7eb;
    --surface: #ffffff;
    --surface-soft: #eef3f8;
    --nav: #101820;
    --nav-2: #243447;
    --accent: #f5c542;
    --accent-2: #2f80ed;
    --success: #16835f;
    --danger: #d92d20;
    --warning: #b7791f;
}

* { letter-spacing: 0; }

body {
    font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--surface-soft);
    color: var(--ink);
    line-height: 1.45;
}

.app-topbar {
    background: linear-gradient(135deg, #101820 0%, #243447 100%);
    border-bottom: 1px solid rgba(255,255,255,.08);
    min-height: 76px;
    box-shadow: 0 12px 28px rgba(16, 24, 32, .16);
}

.btn-topbar-icon {
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255,255,255,.18);
    color: #fff;
    margin-right: 10px;
}

.btn-topbar-icon:hover,
.btn-topbar-icon:focus {
    color: var(--ink);
    background: var(--accent);
    border-color: var(--accent);
}

.navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #fff !important;
    font-weight: 800;
    font-size: 1.18rem;
}

.navbar-brand img {
    width: 56px;
    height: 56px;
    object-fit: contain;
}

.app-shell > .row { min-height: calc(100vh - 76px); }

.sidebar {
    background: linear-gradient(180deg, #101820 0%, #1a2734 48%, #243447 100%);
    min-height: calc(100vh - 76px);
    box-shadow: 8px 0 24px rgba(16,24,32,.08);
}

.sidebar .nav-link {
    color: rgba(255,255,255,.76);
    padding: 11px 14px;
    margin: 3px 10px;
    border-radius: 8px;
    font-weight: 650;
    font-size: .92rem;
    display: flex;
    align-items: center;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background: var(--accent);
    color: var(--ink);
    box-shadow: 0 8px 18px rgba(245, 197, 66, .22);
}

.sidebar .nav-link i {
    width: 22px;
    margin-right: 10px;
    text-align: center;
}

.sidebar-section-label {
    color: rgba(255,255,255,.48);
    font-size: .7rem;
    font-weight: 850;
    text-transform: uppercase;
    padding: 14px 22px 5px;
}

@media (min-width: 769px) {
    .sidebar,
    main.col-md-9 {
        transition: width .22s ease, flex-basis .22s ease, max-width .22s ease;
    }

    body.sidebar-collapsed #sidebar {
        flex: 0 0 76px !important;
        width: 76px !important;
        max-width: 76px !important;
    }

    body.sidebar-collapsed main.col-md-9,
    body.sidebar-collapsed main.col-lg-10 {
        flex: 0 0 calc(100% - 76px) !important;
        width: calc(100% - 76px) !important;
        max-width: calc(100% - 76px) !important;
        margin-left: 0 !important;
    }

    body.sidebar-collapsed .sidebar-section-label,
    body.sidebar-collapsed .nav-link-text {
        display: none;
    }

    body.sidebar-collapsed .sidebar .nav-link {
        justify-content: center;
        margin: 6px 10px;
        padding: 12px 0;
    }

    body.sidebar-collapsed .sidebar .nav-link i {
        margin-right: 0;
    }
}

main {
    padding-top: 26px;
    padding-bottom: 42px;
}

.page-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.page-title h1 {
    font-size: 1.45rem;
    font-weight: 800;
    margin: 0;
}

.page-title p {
    color: var(--muted);
    margin: 4px 0 0;
}

.card {
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 30px rgba(16,24,32,.06);
    margin-bottom: 18px;
    background: var(--surface);
}

.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    border-radius: 8px 8px 0 0 !important;
    padding: 15px 18px;
    font-weight: 800;
}

.card-body { padding: 18px; }

.metric {
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #ffffff 0%, #f9fbfd 100%);
    border-radius: 8px;
    padding: 16px;
    min-height: 118px;
}

.metric .label {
    color: var(--muted);
    font-size: .82rem;
    font-weight: 800;
    text-transform: uppercase;
}

.metric .number {
    font-size: 1.75rem;
    font-weight: 850;
    margin-top: 8px;
}

.metric i {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #fff7d6;
    color: #946200;
}

.balance-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.balance-metric {
    min-height: 126px;
    height: 100%;
    overflow: hidden;
}

.balance-metric .number {
    font-size: 1.25rem;
    overflow-wrap: anywhere;
}

.balance-metric .label {
    font-size: .74rem;
}

.balance-metric,
.balance-metric .label,
.balance-metric .number {
    color: #fff;
}

.balance-metric i {
    background: rgba(255,255,255,.18);
    color: #fff;
}

.metric-receivable {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.metric-payable {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.metric-receivable .label,
.metric-payable .label {
    color: rgba(255,255,255,.86);
}

.metric-receivable i,
.metric-payable i {
    background: rgba(255,255,255,.18);
    color: #fff;
}

.balance-metric-white,
.balance-metric-white .label,
.balance-metric-white .number {
    color: #fff;
}

.balance-metric-white i {
    background: rgba(255,255,255,.18);
    color: #fff;
}

.dashboard-metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
}

.dashboard-metric {
    min-height: 138px;
    height: 100%;
    border-radius: 8px;
    padding: 16px;
    color: #fff;
    overflow: hidden;
    box-shadow: 0 16px 34px rgba(16,24,32,.12);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.dashboard-metric i {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255,255,255,.18);
    color: #fff;
}

.dashboard-metric .number {
    font-size: 1.35rem;
    font-weight: 850;
    overflow-wrap: anywhere;
    line-height: 1.15;
}

.dashboard-metric .label {
    font-size: .76rem;
    font-weight: 850;
    text-transform: uppercase;
    color: rgba(255,255,255,.86);
}

.metric-blue { background: linear-gradient(135deg, #1f6feb 0%, #0f3d91 100%); }
.metric-indigo { background: linear-gradient(135deg, #635bff 0%, #34258f 100%); }
.metric-slate { background: linear-gradient(135deg, #243447 0%, #101820 100%); }
.metric-amber { background: linear-gradient(135deg, #f59e0b 0%, #92400e 100%); }
.metric-teal { background: linear-gradient(135deg, #0f766e 0%, #064e3b 100%); }
.metric-emerald { background: linear-gradient(135deg, #10b981 0%, #047857 100%); }
.metric-gold { background: linear-gradient(135deg, #f5c542 0%, #946200 100%); color: #18202b; }
.metric-gold i { background: rgba(24,32,43,.16); color: #18202b; }
.metric-gold .label { color: rgba(24,32,43,.78); }
.metric-cyan { background: linear-gradient(135deg, #0891b2 0%, #155e75 100%); }
.metric-purple { background: linear-gradient(135deg, #7c3aed 0%, #4c1d95 100%); }
.metric-red { background: linear-gradient(135deg, #dc3545 0%, #8f1d2a 100%); }
.metric-green { background: linear-gradient(135deg, #198754 0%, #0f5132 100%); }
.metric-rose { background: linear-gradient(135deg, #e11d48 0%, #881337 100%); }

.btn {
    border-radius: 8px;
    font-weight: 750;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--ink);
}

.btn-primary:hover,
.btn-primary:focus {
    background: #e7b72d;
    border-color: #e7b72d;
    color: var(--ink);
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.form-label,
label {
    font-weight: 750;
    color: #344054;
    font-size: .9rem;
}

.form-control,
.form-select {
    border-radius: 8px;
    border-color: #d0d5dd;
}

.table-responsive {
    border: 1px solid var(--line);
    border-radius: 8px;
}

.table { margin: 0; }

.table thead th {
    background: #f0f3f7;
    color: #344054;
    border-bottom: 1px solid var(--line);
    font-size: .76rem;
    text-transform: uppercase;
    font-weight: 850;
    white-space: nowrap;
}

.table tbody td {
    vertical-align: middle;
    color: #293241;
    border-color: #edf0f3;
    font-size: .9rem;
}

.table-hover tbody tr:hover { background: #fffaf0; }

.badge {
    border-radius: 999px;
    font-weight: 750;
}

.status-cancelled { color: var(--danger); font-weight: 800; }
.status-live { color: var(--success); font-weight: 800; }
.wide-table { min-width: 1500px; }
.driver-directory-table { min-width: 2100px; }
.driver-table-scroll { max-height: 560px; }
.balance-table { min-width: 1780px; }

.balance-export-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.balance-export-btn {
    min-width: 154px;
    justify-content: center;
}

.balance-table .status-col {
    min-width: 104px;
}

.balance-table .bank-col {
    min-width: 132px;
    white-space: nowrap;
}

.balance-table .balance-status-col {
    min-width: 142px;
    white-space: nowrap;
}

.balance-table .narrow-balance-col {
    width: 96px;
    min-width: 96px;
    max-width: 104px;
    white-space: normal;
    line-height: 1.15;
}

.balance-table td.narrow-balance-col {
    white-space: nowrap;
}

.balance-table .opening-balance-col {
    min-width: 132px;
}

.data-table-scroll {
    max-height: 430px;
    overflow: auto;
}

.data-table-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 3;
}

.driver-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    align-items: end;
}

.driver-export-actions {
    display: flex;
    gap: 8px;
    align-items: end;
}

.driver-th-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.column-note-btn {
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 50%;
    background: #243447;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .68rem;
    padding: 0;
}

.column-note-btn:hover,
.column-note-btn:focus {
    background: var(--accent);
    color: var(--ink);
}

.driver-note-cell {
    min-width: 180px;
    white-space: normal;
}

.driver-name-cell {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 220px;
    position: relative;
}

.driver-name-cell form {
    margin: 0;
}

.driver-name-hover {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: help;
}

.driver-name-hover .fa-circle-info {
    color: var(--accent-2);
    font-size: .84rem;
}

.driver-hover-card {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 20;
    width: 280px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    box-shadow: 0 18px 38px rgba(16,24,32,.18);
    font-size: .78rem;
    font-weight: 500;
    line-height: 1.35;
    white-space: normal;
}

.driver-hover-card span {
    display: block;
    margin-bottom: 3px;
}

.driver-hover-card span:last-child {
    margin-bottom: 0;
}

.driver-name-hover:hover .driver-hover-card,
.driver-name-hover:focus .driver-hover-card,
.driver-name-hover:focus-within .driver-hover-card {
    display: block;
}

.driver-reg-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 92px;
    padding: 5px 10px;
    border: 2px solid #18202b;
    border-radius: 6px;
    background: #f5c542;
    color: #101820;
    font-weight: 900;
    font-size: .92rem;
    letter-spacing: .04em;
    white-space: nowrap;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.4);
}

.driver-vehicles-cell {
    min-width: 280px;
    white-space: normal;
}

.driver-vehicle-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 6px 0;
    border-bottom: 1px solid var(--line);
}

.driver-vehicle-summary:last-child {
    border-bottom: 0;
}

.driver-vehicle-summary small {
    flex-basis: 100%;
    color: var(--muted);
}

.driver-actions-cell {
    min-width: 132px;
    white-space: nowrap;
}

.driver-actions-cell form {
    display: inline-block;
    margin: 0 0 0 6px;
}

.status-form { margin: 0; }

.status-select {
    width: 104px;
    border: 0;
    color: #fff;
    font-weight: 850;
}

.status-active,
.status-active:focus {
    background-color: var(--success);
    color: #fff;
}

.status-inactive,
.status-inactive:focus {
    background-color: var(--danger);
    color: #fff;
}

.invoice-box {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 26px;
}

.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #101820 0%, #243447 52%, #f5c542 52%, #f5c542 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 430px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 26px 70px rgba(0,0,0,.22);
    padding: 30px;
}

.login-card img {
    width: 58px;
    height: 58px;
    object-fit: contain;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 76px;
        left: -100%;
        width: 280px;
        z-index: 1050;
        transition: left .25s ease;
    }

    .sidebar.show { left: 0; }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        top: 76px;
        left: 0;
        width: 100%;
        height: calc(100% - 76px);
        background: rgba(16,24,32,.55);
        z-index: 1040;
    }

    .sidebar-backdrop.show { display: block; }
    main { padding: 20px 14px !important; }
    .page-title { align-items: flex-start; flex-direction: column; }
    .login-page { background: #101820; }
}

@media print {
    .no-print,
    .sidebar,
    .navbar,
    footer,
    .btn { display: none !important; }
    body { background: white; }
    main { width: 100% !important; margin: 0 !important; padding: 0 !important; }
    .card,
    .invoice-box { box-shadow: none; border: none; }
}
