:root {
    --sidebar-width: 320px;
    --brand-primary: #0f4c5c;
    --brand-accent: #e36414;
    --brand-surface: #f6f8fb;
    --topbar-height: 88px;
}

body {
    background: linear-gradient(180deg, #eef5f7 0%, #f9fbfc 100%);
    color: #1f2937;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    overflow-x: hidden;
}

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

.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    min-height: 100vh;
    background: linear-gradient(180deg, #12343b 0%, #0b1f24 100%) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.sidebar.offcanvas-lg,
.sidebar.offcanvas {
    --bs-offcanvas-width: min(88vw, 320px);
}

.sidebar .offcanvas-body {
    display: block;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    scrollbar-width: thin;
}

.sidebar-brand {
    display: block;
    width: 100%;
    padding: 0 0 1rem;
    margin-bottom: 1rem !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-brand h4 {
    line-height: 1.1;
}

.sidebar-brand small {
    display: inline-block;
    margin-top: 0.35rem;
}

.sidebar .nav.flex-column {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.sidebar .nav-item {
    width: 100%;
}

.sidebar .nav-link {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    border-radius: 0.65rem;
    transition: 0.2s ease;
    white-space: normal;
}

.sidebar-nav-icon {
    flex: 0 0 1rem;
    width: 1rem;
    margin-top: 0.15rem;
    text-align: center;
}

.sidebar-nav-label {
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.35;
}

.sidebar .nav-link.active,
.sidebar .nav-link:hover {
    background: rgba(255, 255, 255, 0.12);
}

.sidebar .collapse {
    margin-top: 0.35rem;
}

.sidebar .collapse .nav.flex-column {
    gap: 0.25rem !important;
}

.sidebar .collapse .nav-link {
    display: block;
    padding: 0.45rem 0.9rem;
    border-radius: 0.5rem;
    font-size: 0.95rem;
}

.sidebar .collapse .nav-link.active,
.sidebar .collapse .nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
}

.main-content {
    min-height: 100vh;
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: var(--topbar-height);
}

.topbar-alert-marquee {
    position: relative;
    overflow: hidden;
    border-radius: 0.9rem;
    border: 1px solid rgba(245, 158, 11, 0.2);
    background: linear-gradient(90deg, #fff7ed 0%, #fffbeb 100%);
    padding: 0.7rem 0;
}

.topbar-alert-track {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: max-content;
    animation: topbar-marquee 90s linear infinite;
}

.topbar-alert-marquee:hover .topbar-alert-track {
    animation-play-state: paused;
}

.topbar-alert-item {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.15rem 0.95rem;
    border-radius: 999px;
    font-size: 0.92rem;
    font-weight: 600;
    white-space: nowrap;
}

.topbar-alert-item-expired {
    background: rgba(220, 38, 38, 0.12);
    color: #b91c1c;
}

.topbar-alert-item-soon {
    background: rgba(245, 158, 11, 0.14);
    color: #b45309;
}

.topbar-alert-item-valid {
    background: rgba(22, 163, 74, 0.12);
    color: #166534;
}

@keyframes topbar-marquee {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(-50%);
    }
}

.topbar-toggle {
    flex: 0 0 auto;
}

.content-area,
.card-body,
.card-header {
    min-width: 0;
}

.content-area {
    padding: 1.5rem;
}

.dashboard-card {
    border: 0;
    border-radius: 1rem;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 10px 30px rgba(15, 76, 92, 0.08);
}

.dashboard-card .icon {
    width: 52px;
    height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: rgba(227, 100, 20, 0.12);
    color: var(--brand-accent);
    font-size: 1.25rem;
}

.card,
.table,
.dataTables_wrapper .row {
    border-radius: 1rem;
}

.card-header {
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.filter-card,
.table-card {
    box-shadow: 0 10px 30px rgba(15, 76, 92, 0.08);
    border: 0;
}

.table-card .card-body,
.filter-card .card-body {
    padding: 1.25rem;
}

.table thead th {
    background: #edf4f6;
    white-space: nowrap;
}

.table td,
.table th {
    vertical-align: middle;
}

.table-responsive {
    -webkit-overflow-scrolling: touch;
}

.datatable + .dataTables_wrapper,
.dataTables_wrapper {
    width: 100%;
}

.dataTables_wrapper .row {
    row-gap: 0.75rem;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    max-width: 100%;
}

.btn {
    white-space: nowrap;
}

.w-sm-auto {
    width: 100%;
}

.form-control,
.form-select {
    min-height: 44px;
}

.chart-card,
.filter-card canvas,
.table-card canvas {
    max-width: 100%;
}

.filter-card canvas,
.table-card canvas {
    min-height: 260px;
}

.login-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(227, 100, 20, 0.18), transparent 28%),
        linear-gradient(160deg, #0f4c5c 0%, #12343b 60%, #081417 100%);
}

.login-card {
    border: 0;
    border-radius: 1.25rem;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25);
}

.stat-chip {
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    background: rgba(15, 76, 92, 0.08);
}

.attendance-card {
    border-radius: 1.25rem;
}

.attendance-summary-card {
    background: linear-gradient(180deg, #f6f8ff 0%, #ffffff 100%);
    border: 1px solid #dce4f4;
    border-radius: 1rem;
    padding: 1rem;
    height: 100%;
}

.attendance-summary-label {
    font-size: 0.85rem;
    color: #6b7280;
}

.attendance-summary-value {
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.1;
    margin-top: 0.35rem;
}

.attendance-legend .attendance-tool {
    border-radius: 999px;
    border: 1px solid #cfd8ea;
    background: #fff;
    color: #344054;
}

.attendance-legend .attendance-tool.active {
    background: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
}

.attendance-status-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.45rem 0.8rem;
    font-size: 0.82rem;
    font-weight: 600;
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.attendance-grid-wrap {
    overflow-x: auto;
}

.attendance-grid-table {
    min-width: 1280px;
    border-collapse: separate;
    border-spacing: 0;
}

.attendance-grid-table th,
.attendance-grid-table td {
    border: 1px solid #e4e8f0;
    text-align: center;
    vertical-align: middle;
    padding: 0.35rem;
}

.attendance-grid-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f7f9fc;
}

.attendance-driver-col {
    min-width: 180px;
    text-align: left !important;
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff;
}

.attendance-day-head {
    min-width: 52px;
}

.attendance-day-number {
    font-weight: 700;
    line-height: 1.1;
}

.attendance-day-name {
    font-size: 0.8rem;
    color: #6b7280;
}

.attendance-weekend {
    background: #f8fafc !important;
}

.attendance-cell {
    width: 36px;
    height: 30px;
    border: 1px solid #d5dbe8;
    border-radius: 0.75rem;
    font-size: 0.72rem;
    font-weight: 700;
    background: #fff;
    transition: 0.2s ease;
}

.attendance-cell:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(15, 76, 92, 0.12);
}

.attendance-cell:disabled {
    opacity: 0.65;
}

.attendance-empty {
    background: #ffffff;
    color: #9ca3af;
}

.attendance-p {
    background: #dcfce7;
    border-color: #86efac;
    color: #166534;
}

.attendance-wo {
    background: #eef2ff;
    border-color: #c7d2fe;
    color: #3730a3;
}

.attendance-cl {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.attendance-sl {
    background: #fef3c7;
    border-color: #fcd34d;
    color: #92400e;
}

.attendance-el {
    background: #cffafe;
    border-color: #67e8f9;
    color: #155e75;
}

.attendance-lop,
.attendance-a {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #b91c1c;
}

.attendance-ph {
    background: #fef9c3;
    border-color: #fde047;
    color: #854d0e;
}

.attendance-co {
    background: #e5e7eb;
    border-color: #9ca3af;
    color: #111827;
}

.attendance-ml {
    background: #ede9fe;
    border-color: #c4b5fd;
    color: #6d28d9;
}

.attendance-ptl {
    background: #e0f2fe;
    border-color: #7dd3fc;
    color: #075985;
}

.attendance-footnote {
    color: #6b7280;
    font-size: 0.92rem;
}

.attendance-status-option {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 1rem;
    padding: 1rem;
    text-align: left;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.attendance-status-option:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(15, 76, 92, 0.12);
}

@media (min-width: 992px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
    }

    .main-content {
        margin-left: var(--sidebar-width);
    }
}

@media (max-width: 992px) {
    .sidebar {
        min-height: 100vh;
        height: 100vh;
    }

    .main-content {
        margin-left: 0;
    }

    .content-area {
        padding: 1rem;
    }

    .dashboard-card .card-body {
        align-items: flex-start !important;
    }

    .table-card .card-body,
    .filter-card .card-body {
        padding: 1rem;
    }

    .attendance-driver-col {
        position: static;
    }
}

@media (max-width: 767.98px) {
    :root {
        --topbar-height: auto;
    }

    .content-area {
        padding: 0.875rem;
    }

    .topbar {
        align-items: flex-start !important;
    }

    .topbar h5 {
        font-size: 1rem;
    }

    .topbar-alert-item {
        font-size: 0.84rem;
    }

    .card-header,
    .card-body {
        padding: 0.95rem !important;
    }

    .dashboard-card .icon {
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }

    .dashboard-card h4,
    .attendance-summary-value {
        font-size: 1.35rem;
    }

    .btn.w-sm-auto {
        width: 100% !important;
    }

    .table {
        font-size: 0.92rem;
    }

    .attendance-status-option {
        padding: 0.85rem;
    }

    .filter-card canvas,
    .table-card canvas {
        min-height: 220px;
    }
}

@media (max-width: 575.98px) {
    .sidebar .offcanvas-body {
        padding: 1rem;
    }

    .stat-chip {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length {
        text-align: left;
    }

    .dataTables_wrapper .dataTables_filter input {
        margin-left: 0;
        width: 100%;
    }
}

@media (min-width: 576px) {
    .w-sm-auto {
        width: auto !important;
    }
}

@media print {
    .sidebar,
    .topbar,
    .filter-card,
    .btn,
    .dataTables_filter,
    .dataTables_length,
    .dataTables_paginate,
    .dataTables_info {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
    }

    body {
        background: #fff;
    }
}
