:root {
    --bg: #080909;
    --panel: #111315;
    --panel2: #17191c;
    --border: #2c2a22;
    --gold: #d5a940;
    --gold2: #886a24;
    --text: #f5f1e7;
    --muted: #a7a7a7;
    --red: #ff3d3d;
    --green: #58d65a;
    --blue: #3f8cff;
    --yellow: #e7b63f;
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: radial-gradient(circle at top left, #202016 0, #090a0b 28%, #050505 100%);
    color: var(--text);
    font-family: Inter, Segoe UI, Arial, sans-serif;
    font-size: 14px;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
    width: 270px;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    background: linear-gradient(180deg, #111 0, #070808 100%);
    border-right: 1px solid #232323;
    padding: 22px 18px;
    overflow: auto;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 28px;
}

.brand-logo {
    width: 58px;
    height: 58px;
    border: 2px solid var(--gold);
    border-radius: 18px;
    display: grid;
    place-items: center;
    color: var(--red);
    font-size: 26px;
    background: #19130b;
    box-shadow: 0 0 24px rgba(213, 169, 64, .16);
}

.brand strong {
    display: block;
    color: var(--gold);
    font-size: 20px;
    letter-spacing: .5px;
}

.brand small {
    display: block;
    color: #cda650;
    font-size: 11px;
    letter-spacing: 4px;
}

.nav-menu a {
    display: flex;
    gap: 12px;
    align-items: center;
    color: #f1f1f1;
    text-decoration: none;
    padding: 14px 13px;
    border-radius: 12px;
    margin-bottom: 7px;
    font-weight: 600;
}

.nav-menu a i {
    width: 24px;
    color: #eee;
}

.nav-menu a:hover,
.nav-menu a.active {
    background: linear-gradient(90deg, rgba(213, 169, 64, .55), rgba(213, 169, 64, .13));
    box-shadow: inset 3px 0 0 var(--gold);
    color: #fff;
}

.emergency-card {
    margin-top: 36px;
    border: 1px solid rgba(255, 61, 61, .55);
    border-radius: 16px;
    padding: 18px;
    text-align: center;
    background: rgba(255, 61, 61, .04);
}

.emergency-card span {
    font-size: 12px;
    color: #aaa;
}

.emergency-card b {
    display: block;
    color: var(--red);
    font-size: 27px;
    margin: 7px 0;
}

.emergency-card p {
    border-top: 1px solid #333;
    padding-top: 12px;
    margin-bottom: 0;
    font-size: 16px;
}

/* MAIN */
.main-content {
    margin-left: 270px;
    width: calc(100% - 270px);
    padding: 26px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
    gap: 20px;
}

.topbar h1 {
    margin: 0;
    font-size: 30px;
}

.topbar p {
    margin: 6px 0 0;
    color: var(--muted);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.search-box {
    height: 52px;
    min-width: 300px;
    background: var(--panel);
    border: 1px solid #333;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
}

.search-box input {
    background: transparent;
    border: 0;
    outline: 0;
    color: #fff;
    width: 100%;
}

.icon-btn {
    position: relative;
    width: 52px;
    height: 52px;
    border: 1px solid #423723;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: #fff;
    text-decoration: none;
    background: var(--panel);
}

.icon-btn span {
    position: absolute;
    right: 8px;
    top: 5px;
    background: var(--red);
    border-radius: 999px;
    padding: 2px 6px;
    font-size: 11px;
}

.admin-chip {
    height: 52px;
    border: 1px solid #333;
    border-radius: 14px;
    background: var(--panel);
    display: flex;
    gap: 11px;
    align-items: center;
    padding: 0 15px;
}

.admin-chip i {
    font-size: 26px;
    color: var(--gold);
}

.admin-chip small {
    display: block;
    color: var(--gold);
    font-size: 11px;
}

.logout-btn {
    color: #ff4d4d !important;
    border-color: rgba(255, 77, 77, 0.35) !important;
}

.logout-btn:hover {
    background: rgba(255, 77, 77, 0.12) !important;
    box-shadow: 0 0 18px rgba(255, 77, 77, 0.25);
}

/* GRID & CARD */
.grid {
    display: grid;
    gap: 16px;
}

.cards {
    grid-template-columns: repeat(7, 1fr);
}

.card,
.panel {
    background: linear-gradient(180deg, rgba(25, 27, 29, .95), rgba(12, 13, 14, .98));
    border: 1px solid #2e2e2e;
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .26);
}

.card {
    padding: 18px;
}

.panel {
    padding: 18px;
}

.stat-card {
    padding: 18px;
    display: flex;
    gap: 14px;
    align-items: center;
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--gold);
    background: rgba(213, 169, 64, .13);
    border: 1px solid rgba(213, 169, 64, .35);
    font-size: 22px;
}

.stat-card label {
    color: #cacaca;
}

.stat-card b {
    display: block;
    font-size: 28px;
    margin-top: 4px;
}

.stat-card b::after {
    content: '';
    display: block;
    width: 32px;
    height: 3px;
    background: var(--red);
    border-radius: 9px;
    margin-top: 5px;
}

.panel-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    gap: 12px;
}

.panel-title h2,
.panel-title h3 {
    margin: 0;
    font-size: 18px;
}

/* BUTTON */
.btn {
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(180deg, #c99b33, #6e511b);
    color: #fff;
    border: 1px solid #caa64c;
}

.btn-danger {
    background: #561818;
    color: #ffb7b7;
    border: 1px solid #8c2424;
}

.btn-dark {
    background: #222;
    color: #fff;
    border: 1px solid #3a3a3a;
}

.btn-info {
    background: #143052;
    color: #b7d7ff;
    border: 1px solid #245eab;
}

.btn-success {
    background: #143b20;
    color: #b9f5c5;
    border: 1px solid #23763a;
}

.btn-sm {
    padding: 7px 10px;
    font-size: 12px;
}

/* DASHBOARD */
.dashboard-main {
    grid-template-columns: 1.1fr .9fr;
    margin-top: 16px;
}

.bottom-grid {
    grid-template-columns: 1fr 1.1fr 1.2fr;
    margin-top: 16px;
}

.map {
    height: 382px;
    border-radius: 15px;
    overflow: hidden;
    background: #101010;
}

.map-small {
    height: 320px;
}

/* TABLE */
.table-wrap {
    overflow: auto;
    border-radius: 14px;
    border: 1px solid #282828;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(0, 0, 0, .15);
}

th,
td {
    padding: 13px 14px;
    border-bottom: 1px solid #282828;
    text-align: left;
    vertical-align: top;
}

th {
    color: #f4e7c1;
    background: #171717;
    font-size: 12px;
    text-transform: uppercase;
}

tr:hover td {
    background: rgba(213, 169, 64, .035);
}

/* BADGE */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    border: 1px solid #444;
    font-weight: 700;
}

.badge.success {
    color: #9dff9f;
    border-color: #2e7d32;
    background: #112416;
}

.badge.danger {
    color: #ff8e8e;
    border-color: #8c2424;
    background: #271010;
}

.badge.info {
    color: #9ecbff;
    border-color: #245eab;
    background: #101a2b;
}

.badge.warning {
    color: #ffd77e;
    border-color: #8f6a1c;
    background: #251d0a;
}

.badge.muted {
    color: #aaa;
    border-color: #555;
    background: #1a1a1a;
}

.badge.neutral {
    color: #eee;
}

/* FORM */
.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.form-control,
select,
textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"] {
    background: #0e0f10;
    border: 1px solid #363636;
    border-radius: 11px;
    color: #fff;
    padding: 11px 12px;
    outline: 0;
}

.form-control:focus,
input:focus,
select:focus,
textarea:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(213, 169, 64, .1);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 7px;
    color: #ddd;
    font-weight: 600;
}

/* MODAL FINAL */
.modal {
    display: none;
    position: fixed !important;
    inset: 0 !important;
    z-index: 999999 !important;
    background: rgba(0, 0, 0, 0.82) !important;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
}

.modal.show,
.modal.active {
    display: flex !important;
}

.modal-box {
    position: relative !important;
    z-index: 1000000 !important;
    width: min(920px, 96vw);
    max-height: 90vh;
    overflow-y: auto;
    background: linear-gradient(180deg, #151719, #0d0e0f);
    border: 1px solid rgba(213, 169, 64, 0.35);
    border-radius: 18px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.85);
    padding: 20px;
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    gap: 12px;
}

.modal-head h3 {
    margin: 0;
}

.close {
    background: #222;
    color: #fff;
    border: 1px solid #555;
    border-radius: 10px;
    width: 36px;
    height: 36px;
    cursor: pointer;
}

.modal input,
.modal select,
.modal textarea {
    width: 100%;
}

.modal textarea {
    min-height: 80px;
    resize: vertical;
}

/* FIX LEAFLET MAP MENIMPA MODAL */
body.modal-open .leaflet-container {
    visibility: hidden !important;
}

body.modal-open .modal .leaflet-container {
    visibility: visible !important;
}

.leaflet-container,
.leaflet-pane,
.leaflet-map-pane,
.leaflet-tile-pane,
.leaflet-overlay-pane,
.leaflet-shadow-pane,
.leaflet-marker-pane,
.leaflet-tooltip-pane,
.leaflet-popup-pane,
.leaflet-control-container,
.leaflet-top,
.leaflet-bottom,
.leaflet-control {
    z-index: 0 !important;
}

/* OTHER */
.flash {
    padding: 13px 16px;
    border-radius: 13px;
    margin-bottom: 16px;
    border: 1px solid #333;
}

.flash.success {
    background: #102216;
    color: #b7f8c2;
    border-color: #245f34;
}

.flash.error {
    background: #2c1010;
    color: #ffb1b1;
    border-color: #6d2020;
}

.row-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.tab {
    padding: 9px 12px;
    border: 1px solid #333;
    border-radius: 999px;
    color: #eee;
    text-decoration: none;
}

.tab.active {
    background: rgba(213, 169, 64, .2);
    border-color: var(--gold);
    color: #ffd76d;
}

.mini-list {
    display: grid;
    gap: 10px;
}

.mini-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #282828;
    padding: 10px 0;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    background: #333;
}

.summary-number {
    font-size: 26px;
    font-weight: 800;
}

.text-muted {
    color: var(--muted);
}

.mt-16 {
    margin-top: 16px;
}

.w-100 {
    width: 100%;
}

/* RESPONSIVE */
/* RESPONSIVE */
@media (max-width: 1180px) {
    .cards {
        grid-template-columns: repeat(3, 1fr);
    }

    .dashboard-main,
    .bottom-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-actions {
        flex-wrap: wrap;
    }

    .search-box {
        min-width: 220px;
    }
}

@media (max-width: 780px) {
    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
    }

    .app-shell {
        display: block;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 16px;
    }

    .cards {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .topbar-actions {
        width: 100%;
    }

    .search-box {
        width: 100%;
    }

    .modal {
        align-items: flex-start;
        padding: 16px;
    }

    .modal-box {
        width: 96vw;
        max-height: none;
        padding: 16px;
    }
}
/* FORCE HIDE MAP SAAT MODAL TERBUKA */
body.modal-open #orderMap,
body.modal-open #dashboardMap,
body.modal-open .map,
body.modal-open .map-small,
body.modal-open .leaflet-container {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

body.modal-open .modal {
    z-index: 9999999 !important;
}

body.modal-open .modal-box {
    z-index: 10000000 !important;
}

body.modal-open .modal,
body.modal-open .modal * {
    visibility: visible !important;
    opacity: 1 !important;
}