* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f3f6fb;
    color: #122033;
}

a {
    color: inherit;
    text-decoration: none;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, .22), transparent 35%),
        linear-gradient(135deg, #0f172a, #1e3a8a 55%, #0f172a);
}

.auth-card {
    width: 100%;
    max-width: 430px;
    background: rgba(255,255,255,.96);
    border-radius: 28px;
    padding: 34px;
    box-shadow: 0 24px 70px rgba(0,0,0,.25);
}

.brand-mark {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #2563eb, #0f172a);
    color: #fff;
    font-weight: 900;
    font-size: 22px;
    margin-bottom: 18px;
}

.auth-card h1 {
    margin: 0;
    font-size: 28px;
}

.auth-card p {
    color: #64748b;
}

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 8px;
    color: #334155;
}

input, textarea, select {
    width: 100%;
    border: 1px solid #dbe3ef;
    border-radius: 14px;
    padding: 13px 14px;
    font-size: 15px;
    outline: none;
    background: #fff;
}

textarea {
    min-height: 90px;
    resize: vertical;
}

input:focus, textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}

.btn {
    border: 0;
    border-radius: 14px;
    padding: 12px 18px;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb, #1e40af);
    color: #fff;
}

.btn-muted {
    background: #e2e8f0;
    color: #0f172a;
}

.btn-danger {
    background: #fee2e2;
    color: #b91c1c;
}

.btn-full {
    width: 100%;
}

.alert {
    padding: 13px 15px;
    border-radius: 14px;
    margin-bottom: 16px;
    font-weight: 700;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 270px;
    background: #0f172a;
    color: #fff;
    padding: 24px;
    position: fixed;
    inset: 0 auto 0 0;
}

.sidebar-brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 34px;
}

.sidebar-logo {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    background: linear-gradient(135deg, #60a5fa, #2563eb);
    display: grid;
    place-items: center;
    font-weight: 900;
}

.sidebar-brand h2 {
    margin: 0;
    font-size: 18px;
}

.sidebar-brand span {
    font-size: 12px;
    color: #94a3b8;
}

.nav-link {
    display: block;
    padding: 13px 14px;
    border-radius: 14px;
    color: #cbd5e1;
    font-weight: 700;
    margin-bottom: 8px;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255,255,255,.1);
    color: #fff;
}

.sidebar-footer {
    position: absolute;
    bottom: 24px;
    left: 24px;
    right: 24px;
}

.logout-btn {
    width: 100%;
    background: rgba(255,255,255,.1);
    color: #fff;
}

.main {
    margin-left: 270px;
    width: calc(100% - 270px);
    padding: 28px;
}

.topbar {
    background: #fff;
    border-radius: 24px;
    padding: 22px 24px;
    box-shadow: 0 14px 40px rgba(15,23,42,.06);
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 24px;
}

.page-title {
    margin: 0;
    font-size: 28px;
}

.page-subtitle {
    margin: 6px 0 0;
    color: #64748b;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.card {
    background: #fff;
    border-radius: 24px;
    padding: 22px;
    box-shadow: 0 14px 40px rgba(15,23,42,.06);
}

.stat-label {
    color: #64748b;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

.stat-value {
    font-size: 30px;
    font-weight: 900;
    margin-top: 8px;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    font-size: 12px;
    color: #64748b;
    text-transform: uppercase;
    padding: 14px;
    border-bottom: 1px solid #e2e8f0;
}

td {
    padding: 14px;
    border-bottom: 1px solid #eef2f7;
    vertical-align: top;
}

.badge {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 800;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.form-grid .full {
    grid-column: 1 / -1;
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pagination {
    margin-top: 18px;
}


.btn-sm {
    padding: 6px 10px;
    font-size: 13px;
    border-radius: 6px;
}


.btn-secondary {
    background: #475569;
    color: #fff;
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
}

.btn-success {
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: #fff;
}

.btn-info {
    background: linear-gradient(135deg, #0ea5e9, #0369a1);
    color: #fff;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(15, 23, 42, .16);
}

.driver-action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.driver-action-buttons .btn {
    min-width: 110px;
    white-space: nowrap;
}

@media (max-width: 900px) {
    .sidebar {
        position: static;
        width: 100%;
    }

    .app-shell {
        display: block;
    }

    .main {
        margin-left: 0;
        width: 100%;
        padding: 16px;
    }

    .stats-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        display: block;
    }
}

.module-hero {
    background: #fff;
    border-radius: 28px;
    padding: 28px 32px;
    margin-bottom: 28px;
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.18);
}

.hero-buying {
    border-left: 7px solid #2563eb;
    background: linear-gradient(135deg, #ffffff 0%, #eff6ff 100%);
}

.hero-selling {
    border-left: 7px solid #16a34a;
    background: linear-gradient(135deg, #ffffff 0%, #ecfdf5 100%);
}

.module-badge {
    display: inline-flex;
    padding: 7px 13px;
    border-radius: 999px;
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 800;
    font-size: 12px;
    margin-bottom: 10px;
}

.module-badge.green {
    background: #dcfce7;
    color: #15803d;
}

.topbar-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.stat-card {
    background: #fff;
    padding: 22px;
    border-radius: 22px;
    box-shadow: 0 15px 35px rgba(15, 23, 42, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.18);
}

.stat-card span {
    display: block;
    font-size: 13px;
    color: #64748b;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 10px;
}

.stat-card strong {
    font-size: 28px;
    color: #0f172a;
}

.stat-card.blue {
    border-left: 6px solid #2563eb;
}

.stat-card.green {
    border-left: 6px solid #16a34a;
}

.stat-card.danger {
    border-left: 6px solid #dc2626;
}

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.section-subtitle {
    margin: 4px 0 0;
    color: #64748b;
}

.btn-success {
    background: #16a34a;
    color: #fff;
}

.btn-light {
    background: #f8fafc;
    color: #0f172a;
    border: 1px solid #cbd5e1;
}

.stat-card.green { background: #e6f9f0; color: #0f9d58; }
.stat-card.red { background: #fdecea; color: #d93025; }
.stat-card.blue { background: #e8f0fe; color: #1a73e8; }
.stat-card.orange { background: #fff4e5; color: #f57c00; }
.stat-card.dark { background: #eef2f7; color: #111827; }

.filter-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-row input,
.filter-row select {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
}

.empty-state {
    text-align: center;
    padding: 30px;
    color: #6b7280;
}

.empty-state .btn {
    margin-top: 10px;
}

.text-green {
    color: #0f9d58;
    font-weight: 700;
}

.text-red {
    color: #d93025;
    font-weight: 700;
}

.data-table th {
    background: #f9fafb;
}

.data-table td {
    vertical-align: middle;
}


/* OWNER FINANCE PREMIUM UI */
.owner-finance-page .stats-grid {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(160px, 1fr));
    gap: 18px;
    margin: 24px 0;
}

.owner-finance-page .stat-card {
    border-radius: 22px;
    padding: 22px;
    min-height: 120px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
    border: 1px solid rgba(255,255,255,0.7);
}

.owner-finance-page .stat-card span {
    display: block;
    font-size: 13px;
    font-weight: 800;
    opacity: 0.85;
    margin-bottom: 14px;
    text-transform: uppercase;
}

.owner-finance-page .stat-card strong {
    display: block;
    font-size: 25px;
    font-weight: 900;
}

.owner-finance-page .stat-card.green {
    background: linear-gradient(135deg, #dcfce7, #bbf7d0) !important;
    color: #166534 !important;
}

.owner-finance-page .stat-card.red {
    background: linear-gradient(135deg, #fee2e2, #fecaca) !important;
    color: #991b1b !important;
}

.owner-finance-page .stat-card.blue {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe) !important;
    color: #1e40af !important;
}

.owner-finance-page .stat-card.orange {
    background: linear-gradient(135deg, #ffedd5, #fed7aa) !important;
    color: #9a3412 !important;
}

.owner-finance-page .stat-card.dark {
    background: linear-gradient(135deg, #1e293b, #475569) !important;
    color: #ffffff !important;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.25);
}

.owner-finance-page .stat-card.dark span {
    color: rgba(255,255,255,0.7);
}

.owner-finance-page .stat-card.dark strong {
    color: #ffffff;
}

.owner-finance-page .finance-filter-card {
    padding: 22px;
}

.owner-finance-page .filter-row {
    display: grid !important;
    grid-template-columns: 1.5fr 1fr 1fr auto auto;
    gap: 14px;
    align-items: end;
}

.owner-finance-page .filter-row select,
.owner-finance-page .filter-row input {
    height: 48px;
    border-radius: 14px;
    border: 1px solid #dbe3ef;
    padding: 0 16px;
    font-weight: 700;
    background: #fff;
}

.owner-finance-page .empty-state {
    text-align: center;
    padding: 50px 20px;
    border-radius: 18px;
    background: linear-gradient(135deg, #f8fafc, #eef2ff);
    border: 1px dashed #c7d2fe;
}

.owner-finance-page .empty-state p {
    font-size: 18px;
    font-weight: 800;
    color: #475569;
    margin-bottom: 18px;
}

.owner-finance-page .text-green {
    color: #16a34a !important;
    font-weight: 900;
}

.owner-finance-page .text-red {
    color: #dc2626 !important;
    font-weight: 900;
}

.owner-finance-page .data-table th {
    background: #f8fafc !important;
    color: #475569;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

@media (max-width: 1200px) {
    .owner-finance-page .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .owner-finance-page .filter-row {
        grid-template-columns: 1fr;
    }
}

.primary-btn {
    background: linear-gradient(135deg, #2563eb, #1e40af) !important;
    color: #fff !important;
}

.danger-btn {
    background: #fee2e2 !important;
    color: #b91c1c !important;
}

.small-btn {
    padding: 7px 11px !important;
    font-size: 13px !important;
    border-radius: 10px !important;
}

.income-btn {
    background: linear-gradient(135deg, #16a34a, #15803d) !important;
    color: #fff !important;
}

.expense-btn {
    background: linear-gradient(135deg, #dc2626, #991b1b) !important;
    color: #fff !important;
}


.scroll-x {
    overflow-x: auto;
    width: 100%;
    padding-bottom: 8px;
}

.data-table {
    min-width: 1200px;
}

.scroll-x::-webkit-scrollbar {
    height: 8px;
}

.scroll-x::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.scroll-x::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.data-table th:first-child,
.data-table td:first-child {
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 2;
}


/* ANDROID APP MODE - FORCE LEFT SIDEBAR */
body.app-mode {
    min-width: 1000px;
}

body.app-mode .app-shell {
    display: flex !important;
}

body.app-mode .sidebar {
    position: fixed !important;
    width: 270px !important;
    inset: 0 auto 0 0 !important;
}

body.app-mode .main {
    margin-left: 270px !important;
    width: calc(100% - 270px) !important;
    padding: 22px !important;
}

body.app-mode .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

body.app-mode .topbar {
    display: flex !important;
}

@media (max-width: 900px) {
    .module-hero {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar-actions {
        justify-content: flex-start;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}
