:root {
    --ink: #17211d;
    --muted: #77827c;
    --line: #e8eeea;
    --canvas: #f3f5f4;
    --green: #16845b;
    --green-dark: #116c49;
    --green-pale: #e9f5ef;
    --green-mid: #d0ecdf;
    --sidebar-w: 260px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #f6f8f7;
    color: var(--ink);
    font-family: 'Manrope', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

:focus-visible {
    outline: 3px solid rgba(22, 132, 91, .3);
    outline-offset: 2px;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.sidebar {
    width: var(--sidebar-w);
    background: #fff;
    border-right: 1px solid var(--line);
    overflow-y: auto;
    overflow-x: hidden;
}

/* ── ENTRANCE ANIMATIONS ──── */
@keyframes adminFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes adminSlideIn {
    from { opacity: 0; transform: translateX(-16px); }
    to { opacity: 1; transform: translateX(0); }
}

.kpi-grid .panel {
    animation: adminFadeIn 0.5s ease both;
}

.kpi-grid .panel:nth-child(1) { animation-delay: 0.05s; }
.kpi-grid .panel:nth-child(2) { animation-delay: 0.1s; }
.kpi-grid .panel:nth-child(3) { animation-delay: 0.15s; }
.kpi-grid .panel:nth-child(4) { animation-delay: 0.2s; }
.kpi-grid .panel:nth-child(5) { animation-delay: 0.25s; }
.kpi-grid .panel:nth-child(6) { animation-delay: 0.3s; }

.content {
    min-width: 0;
    margin-left: var(--sidebar-w);
}

.nav-link {
    color: #697870;
    transition: all .2s cubic-bezier(.4,0,.2,1);
    border-left: 2.5px solid transparent;
    border-radius: 10px;
}

.nav-link:hover {
    background: var(--canvas);
    color: var(--green-dark);
    transform: translateX(2px);
}

.nav-link.active {
    background: linear-gradient(135deg, var(--green-pale), #ddf2e7);
    color: var(--green-dark);
    font-weight: 800;
    border-left-color: var(--green);
    box-shadow: 0 2px 8px rgba(22, 132, 91, .08);
}

.panel {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(22, 84, 60, .03), 0 4px 16px rgba(22, 84, 60, .03);
    transition: border-color .25s cubic-bezier(.4,0,.2,1), box-shadow .25s cubic-bezier(.4,0,.2,1), transform .25s cubic-bezier(.4,0,.2,1);
}

.panel:hover {
    border-color: #b8d4c5;
    box-shadow: 0 2px 6px rgba(22, 84, 60, .05), 0 12px 32px rgba(22, 84, 60, .08);
    transform: translateY(-1px);
}

.table-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    border-collapse: separate;
    border-spacing: 0;
    min-width: 700px;
    width: 100%;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: #556a60;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .07em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
    background: linear-gradient(180deg, #f4f7f5 0%, #eef2ef 100%);
    border-bottom: 2px solid #d8e3dc;
    padding: 11px 16px;
}

th:first-child { padding-left: 24px; }
th:last-child { padding-right: 24px; }

td {
    border-bottom: 1px solid #edf0ee;
    color: #3e4e48;
    font-size: 12px;
    white-space: nowrap;
    padding: 13px 16px;
    vertical-align: middle;
    transition: background-color .12s ease, border-color .12s ease;
}

td:first-child { padding-left: 24px; }
td:last-child { padding-right: 24px; }

tbody tr {
    transition: all .15s ease;
}

tbody tr:nth-child(even) td {
    background: #fafbfa;
}

tbody tr:hover td {
    background: #eef5f1 !important;
    border-bottom-color: #d5e5db;
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Action column button group */
td .flex.justify-end { gap: 4px; }
td .flex.justify-end button {
    border-radius: 8px;
    transition: all .15s ease;
}

.chart-box {
    position: relative;
    height: 235px;
}

.calendar-day,
.calendar-empty {
    position: relative;
    display: grid;
    width: 100%;
    aspect-ratio: 1;
    place-items: center;
}

.calendar-day {
    border-radius: 8px;
    color: #545c64;
    font-size: 10px;
    font-weight: 600;
    transition: background .15s ease, color .15s ease;
}

.calendar-day:hover { background: var(--green-pale); color: var(--green-dark); }

.calendar-day.selected {
    background: var(--green);
    color: #fff;
    font-weight: 800;
    box-shadow: 0 2px 8px rgba(22,132,91,.3);
}

.calendar-day.today:not(.selected) {
    box-shadow: inset 0 0 0 1.5px var(--green);
    color: var(--green);
    font-weight: 800;
}

.calendar-day.has-booking:not(.selected) {
    background: var(--green-pale);
    color: var(--green-dark);
    font-weight: 800;
}

.calendar-day.selected.has-booking { background: var(--green); color: #fff; }

.calendar-dot {
    position: absolute;
    bottom: 3px;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #ed7772;
}

.calendar-day.selected .calendar-dot { background: rgba(255,255,255,.7); }

/* ── SWAL2 PREMIUM FORMS ────── */
.swal2-container { backdrop-filter: blur(4px); }

.swal2-popup {
    border-radius: 20px !important;
    font-family: 'Manrope', sans-serif !important;
    box-shadow: 0 25px 80px rgba(15,40,30,.14), 0 4px 12px rgba(15,40,30,.06) !important;
    border: 1px solid rgba(22,132,91,.08) !important;
    width: min(640px, calc(100vw - 24px)) !important;
    max-height: calc(100dvh - 24px) !important;
    overflow-y: auto !important;
    padding: 28px !important;
}

.swal2-title {
    color: var(--ink) !important;
    font-size: 19px !important;
    font-weight: 800 !important;
    letter-spacing: -0.01em !important;
    padding: 0 0 4px !important;
}

.swal2-styled.swal2-confirm {
    border-radius: 10px !important;
    background: var(--green) !important;
    font-weight: 800 !important;
    font-size: 13px !important;
    padding: 10px 24px !important;
    transition: all .15s ease !important;
    box-shadow: 0 2px 8px rgba(22,132,91,.25) !important;
}
.swal2-styled.swal2-confirm:hover {
    background: var(--green-dark) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 14px rgba(22,132,91,.35) !important;
}

.swal2-styled.swal2-cancel {
    border-radius: 10px !important;
    font-weight: 700 !important;
    font-size: 13px !important;
    padding: 10px 20px !important;
    background: #f3f5f4 !important;
    color: #536159 !important;
    transition: all .15s ease !important;
}
.swal2-styled.swal2-cancel:hover {
    background: #e8eeea !important;
}

.swal2-html-container {
    max-width: 100% !important;
    overflow-x: hidden !important;
    overflow-wrap: anywhere;
    text-align: left !important;
    margin: 20px 0 0 !important;
    padding: 0 !important;
}

.swal2-input,
.swal2-select,
.swal2-textarea {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 6px 0 0 !important;
    height: 44px !important;
    padding: 0 14px !important;
    border: 1.5px solid #d5e0da !important;
    border-radius: 12px !important;
    background: #fafcfb !important;
    color: var(--ink) !important;
    font-family: 'Manrope', sans-serif !important;
    font-size: 13px !important;
    box-shadow: none !important;
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease !important;
}

.swal2-input::placeholder { color: #a3b0a8 !important; }

.swal2-input:focus, .swal2-select:focus, .swal2-textarea:focus {
    border-color: var(--green) !important;
    box-shadow: 0 0 0 4px rgba(22,132,91,.1) !important;
    background: #fff !important;
    outline: none !important;
}

.swal2-textarea {
    height: auto !important;
    min-height: 100px !important;
    padding: 12px 14px !important;
    resize: vertical !important;
    line-height: 1.6 !important;
}

.swal2-validation-message {
    border-radius: 10px !important;
    background: #fff5f4 !important;
    border: 1px solid #fdd9d7 !important;
    color: #c0392b !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    margin-top: 12px !important;
}

.swal2-html-container label {
    display: flex;
    width: 100%;
    min-width: 0;
    flex-direction: column;
    align-items: stretch;
    color: #3e5148;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.5;
    letter-spacing: -0.01em;
}

.swal2-html-container .grid {
    column-gap: 16px;
    row-gap: 14px;
}

.swal2-html-container input:not([type="file"]),
.swal2-html-container select,
.swal2-html-container textarea { display: block; min-width: 0; }

.swal2-html-container input[type="file"] {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 14px;
    border: 2px dashed #c5ddd0;
    border-radius: 12px;
    background: linear-gradient(135deg, #f4faf6 0%, #eef6f1 100%);
    color: #536159;
    font-size: 12px;
    transition: border-color .2s ease, background .2s ease;
    cursor: pointer;
}
.swal2-html-container input[type="file"]:hover {
    border-color: var(--green);
    background: linear-gradient(135deg, #eef6f1 0%, #e5f2ec 100%);
}

.swal2-html-container input[type="file"]::file-selector-button {
    margin-right: 12px;
    padding: 8px 14px;
    border: 0;
    border-radius: 8px;
    background: var(--green);
    color: #fff;
    font: inherit;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    transition: background .15s ease;
}
.swal2-html-container input[type="file"]::file-selector-button:hover {
    background: var(--green-dark);
}

/* ── SETTINGS ───────────────────── */
.settings-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(22,84,60,.04);
}

.settings-input {
    display: block;
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1px solid #dce7e2;
    border-radius: 10px;
    background: #fafcfb;
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    transition: border-color .15s, box-shadow .15s;
}

.settings-input:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(22,132,91,.12);
    background: #fff;
    outline: none;
}

.settings-label {
    display: block;
    margin-bottom: 5px;
    color: #45534a;
    font-size: 11px;
    font-weight: 700;
}

.settings-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    padding: 0 18px;
    border-radius: 10px;
    background: var(--green);
    color: #fff;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    border: none;
    cursor: pointer;
    transition: background .15s, transform .1s;
}

.settings-btn:hover { background: var(--green-dark); }
.settings-btn:active { transform: scale(.97); }
.settings-btn:disabled { opacity: .6; cursor: wait; }

#login-form input {
    transition: border-color .15s ease, box-shadow .15s ease;
}

#login-form input:focus-visible {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(22, 132, 91, .13);
    outline: none;
}

#login-submit:disabled {
    cursor: wait;
    opacity: .78;
}

@media(max-width:1023px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .24s cubic-bezier(.4,0,.2,1);
        z-index: 50;
    }
    .sidebar.open { transform: translateX(0); }
    .content { margin-left: 0; }
    .scrim.visible { display: block; }
}

@media(max-width:600px) {
    .page-pad {
        padding-left: 16px;
        padding-right: 16px;
    }

    .chart-box {
        height: 220px;
    }

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

    .kpi-grid .panel {
        min-width: 0;
        padding: 12px;
    }

    .kpi-grid .panel p:first-of-type {
        overflow-wrap: anywhere;
        font-size: 19px;
    }

    .content>header {
        gap: 8px;
        padding-right: 12px;
        padding-left: 12px;
    }

    #today-date {
        display: none;
    }

    #page-title {
        max-width: 112px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #notification-btn {
        flex: 0 0 34px;
        margin: 0;
    }

    #logout-btn {
        flex: 0 0 36px;
        justify-content: center;
        padding: 0;
    }

    .content>div.page-pad {
        padding-right: 16px;
        padding-left: 16px;
    }

    .swal2-title {
        font-size: 18px !important;
        overflow-wrap: anywhere;
    }

    .swal2-actions {
        flex-wrap: wrap;
    }
}

@media(max-width:1023px) {
    .table-wrap {
        overflow: visible;
    }

    .table-wrap table {
        display: block !important;
        min-width: 0;
        width: 100%;
    }

    .table-wrap thead {
        display: none;
    }

    .table-wrap tbody {
        display: grid !important;
        gap: 8px;
        padding: 8px 12px;
    }

    .table-wrap tbody tr {
        display: grid !important;
        min-width: 0;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px 12px;
        padding: 12px;
        border: 1px solid #eaede9;
        border-radius: 12px;
        background: #fff;
        box-shadow: 0 1px 6px rgba(20,50,35,.04);
    }

    .table-wrap tbody td {
        display: block !important;
        min-width: 0;
        padding: 0 !important;
        border: 0;
        overflow-wrap: anywhere;
        white-space: normal;
        font-size: 11px;
        line-height: 1.5;
    }

    .table-wrap tbody td::before {
        display: block !important;
        margin-bottom: 3px;
        color: #8b9490;
        font-size: 9px;
        font-weight: 800;
        letter-spacing: .06em;
        text-transform: uppercase;
    }

    .table-wrap tbody td:last-child {
        grid-column: 1 / -1;
        padding-top: 8px !important;
        border-top: 1px solid #f0eff2;
    }

    .table-wrap tbody td:last-child::before {
        content: 'Aksi';
    }

    #latest-rentals-body td:nth-child(1)::before { content: 'Kode'; }
    #latest-rentals-body td:nth-child(2)::before { content: 'Pelanggan'; }
    #latest-rentals-body td:nth-child(3)::before { content: 'Kendaraan'; }
    #latest-rentals-body td:nth-child(4)::before { content: 'Periode'; }
    #latest-rentals-body td:nth-child(5)::before { content: 'Total'; }
    #latest-rentals-body td:nth-child(6)::before { content: 'Status'; }

    #rentals-body td:nth-child(1)::before { content: 'Kode'; }
    #rentals-body td:nth-child(2)::before { content: 'Pelanggan'; }
    #rentals-body td:nth-child(3)::before { content: 'Kendaraan'; }
    #rentals-body td:nth-child(4)::before { content: 'Tanggal'; }
    #rentals-body td:nth-child(5)::before { content: 'Total'; }
    #rentals-body td:nth-child(6)::before { content: 'Status'; }

    #vehicles-body td:nth-child(1)::before { content: 'Kendaraan'; }
    #vehicles-body td:nth-child(2)::before { content: 'Merek / kategori'; }
    #vehicles-body td:nth-child(3)::before { content: 'Plat nomor'; }
    #vehicles-body td:nth-child(4)::before { content: 'Harga per hari'; }
    #vehicles-body td:nth-child(5)::before { content: 'Status'; }

    #brands-body td:nth-child(1)::before { content: 'Merek'; }
    #brands-body td:nth-child(2)::before { content: 'Logo'; }

    #categories-body td:nth-child(1)::before { content: 'Kategori'; }
    #categories-body td:nth-child(2)::before { content: 'Deskripsi'; }
    #categories-body td:nth-child(3)::before { content: 'Gambar'; }

    #users-body td:nth-child(1)::before { content: 'Nama'; }
    #users-body td:nth-child(2)::before { content: 'Email'; }
    #users-body td:nth-child(3)::before { content: 'Telepon'; }
    #users-body td:nth-child(4)::before { content: 'Alamat'; }
    #users-body td:nth-child(5)::before { content: 'Role'; }

    #pickup-body td:nth-child(1)::before { content: 'Kode pesanan'; }
    #pickup-body td:nth-child(2)::before { content: 'Pelanggan'; }
    #pickup-body td:nth-child(3)::before { content: 'Kendaraan'; }
    #pickup-body td:nth-child(4)::before { content: 'Jadwal pengambilan'; }

    #returns-body td:nth-child(1)::before { content: 'Kode'; }
    #returns-body td:nth-child(2)::before { content: 'Pelanggan'; }
    #returns-body td:nth-child(3)::before { content: 'Kendaraan'; }
    #returns-body td:nth-child(4)::before { content: 'Jatuh tempo'; }
    #returns-body td:nth-child(5)::before { content: 'Pengembalian'; }
    #returns-body td:nth-child(6)::before { content: 'Denda'; }
}

@media(min-width:701px) and (max-width:1023px) {
    .table-wrap tbody tr {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media(max-width:380px) {
    .content>header {
        padding-right: 8px;
        padding-left: 8px;
    }

    #page-title {
        max-width: 92px;
    }

    #notification-btn {
        margin-right: 0;
    }

    .kpi-grid .panel p:first-of-type {
        font-size: 17px;
    }
}

@media(prefers-reduced-motion:reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* ── SCROLLBAR ────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d0d8d4; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #b5c4be; }
