:root {
    --maroon-deep: #120104;
    --maroon: #1e0308;
    --maroon-card: #320610;
    --maroon-border: #6b1222;
    --gold-light: #ffedb0;
    --gold: #f2c75c;
    --gold-dark: #c08a2b;
    --text-dark: #1d050a;
    --text-muted: #6c595e;
    --green: #1fa34a;
    --amber: #f5b82e;
    --red: #dc2626;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: radial-gradient(circle at top center, #380712 0%, #150205 60%, #0b0002 100%);
    color: #ffffff;
    min-height: 100vh;
    padding: 12px;
}

.admin-frame {
    max-width: 1460px;
    margin: 0 auto;
    border-radius: 14px;
    border: 2px solid #d4a338;
    background: linear-gradient(180deg, #32050d 0%, #1d0207 45%, #120104 100%);
    box-shadow: 0 0 36px rgba(242, 199, 92, 0.22), 0 20px 50px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    position: relative;
}

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 18px;
    border-bottom: 1px solid rgba(242, 199, 92, 0.35);
    background: linear-gradient(90deg, #2d040c 0%, #430814 45%, #2a040b 100%);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: rgba(242, 199, 92, 0.16);
    border: 1px solid rgba(242, 199, 92, 0.55);
    color: var(--gold-light);
    font-size: 20px;
    font-weight: 800;
    cursor: pointer;
    flex-shrink: 0;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.topbar-brand img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    flex-shrink: 0;
}

.topbar-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.4px;
    color: #ffffff;
}

.topbar-sub {
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 237, 176, 0.9);
    margin-left: 4px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.avatar-pill {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid var(--gold);
    object-fit: cover;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(242, 199, 92, 0.3);
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    font-size: 15px;
}

.icon-btn:hover { background: rgba(242, 199, 92, 0.2); }

/* Layout Shell */
.shell {
    display: grid;
    grid-template-columns: 218px 1fr;
    min-height: 680px;
}

.sidebar {
    padding: 12px 10px;
    border-right: 1px solid rgba(242, 199, 92, 0.25);
    background: linear-gradient(180deg, rgba(46, 6, 14, 0.96) 0%, rgba(20, 2, 6, 0.98) 100%);
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sidebar-mobile-head {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 4px 6px 12px;
    margin-bottom: 6px;
    border-bottom: 1px solid rgba(242, 199, 92, 0.25);
}

.sidebar-close {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(242, 199, 92, 0.35);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 40;
}

.sidebar-backdrop.open { display: block; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.88);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 600;
    transition: all 0.15s ease;
}

.nav-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--gold);
}

.nav-item:hover {
    background: rgba(242, 199, 92, 0.14);
    color: #fff;
}

.nav-item.active {
    background: linear-gradient(180deg, #ffedb0 0%, #f2c75c 52%, #c9922c 100%);
    color: #200308;
    font-weight: 800;
    box-shadow: 0 3px 12px rgba(242, 199, 92, 0.35);
}

.nav-item.active svg { color: #200308; }

.nav-badge {
    margin-left: auto;
    background: #dc2626;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
}

.main {
    padding: 14px 16px 20px;
    min-width: 0;
    overflow-x: hidden;
}

/* KPI Row */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.kpi-card {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: 10px;
    background: linear-gradient(135deg, #4b0917 0%, #2b040c 70%, #1d0207 100%);
    border: 1px solid rgba(242, 199, 92, 0.45);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    min-width: 0;
}

.kpi-card.has-flare::after {
    content: "";
    position: absolute;
    right: -10px;
    top: -10px;
    width: 110px;
    height: 110px;
    background: radial-gradient(circle, rgba(255, 237, 176, 0.55) 0%, rgba(242, 199, 92, 0.18) 38%, transparent 70%);
    pointer-events: none;
}

.kpi-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(242, 199, 92, 0.25) 0%, rgba(192, 138, 43, 0.1) 100%);
    border: 1px solid rgba(242, 199, 92, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold-light);
    flex-shrink: 0;
}

.kpi-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.82);
    margin-bottom: 2px;
}

.kpi-value-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.kpi-value {
    font-size: clamp(18px, 1.8vw, 24px);
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.kpi-delta {
    font-size: 12.5px;
    font-weight: 700;
    color: #34d399;
    white-space: nowrap;
}

/* Panels */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.15fr 0.9fr 1.25fr;
    gap: 12px;
    align-items: stretch;
}

.white-panel {
    background: #ffffff;
    color: var(--text-dark);
    border-radius: 10px;
    padding: 14px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.maroon-panel {
    background: linear-gradient(180deg, #320610 0%, #200309 100%);
    border: 1px solid rgba(242, 199, 92, 0.35);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 14px;
}

.panel-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.panel-title-light {
    font-size: 16px;
    font-weight: 800;
    color: var(--gold-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

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

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    min-width: 520px;
}

.data-table.compact { min-width: 0; }

.data-table thead th {
    background: #5b0916;
    color: #ffffff;
    font-weight: 700;
    text-align: left;
    padding: 8px 10px;
    white-space: nowrap;
}

.data-table thead th:first-child { border-radius: 6px 0 0 6px; }
.data-table thead th:last-child { border-radius: 0 6px 6px 0; text-align: center; }

.data-table tbody td {
    padding: 9px 10px;
    border-bottom: 1px solid #f0e8ea;
    color: #24070d;
    font-weight: 500;
    vertical-align: middle;
}

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

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    border: none;
}

.badge-green { background: #1fa34a; }
.badge-amber { background: #f5b82e; color: #200308; }
.badge-red { background: #dc2626; }
.badge-blue { background: #2563eb; }

/* Buttons & Forms */
.btn-gold {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: linear-gradient(180deg, #ffedb0 0%, #f2c75c 50%, #d49b35 100%);
    color: #200308;
    border: 1px solid #ffedb0;
    border-radius: 7px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.btn-sm { padding: 4px 10px; font-size: 11.5px; border-radius: 5px; }
.btn-green { background: #1fa34a; color: #fff; border: none; cursor: pointer; font-weight: 700; }
.btn-red { background: #dc2626; color: #fff; border: none; cursor: pointer; font-weight: 700; }
.btn-blue { background: #2563eb; color: #fff; border: none; cursor: pointer; font-weight: 700; }
.btn-outline { background: transparent; color: #fff; border: 1px solid rgba(242, 199, 92, 0.5); border-radius: 7px; padding: 7px 14px; font-size: 13px; font-weight: 700; cursor: pointer; text-decoration: none; }

.action-group {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
}

.input, .select, .textarea {
    width: 100%;
    padding: 8px 10px;
    border-radius: 7px;
    border: 1px solid #d9c8cc;
    font-size: 13px;
    color: var(--text-dark);
    background: #fff;
    font-family: inherit;
}

.input-dark {
    background: #28050d;
    color: #fff;
    border: 1px solid #6b1222;
}

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

.field { margin-bottom: 11px; }
.field label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #ffedb0;
    margin-bottom: 4px;
}

.alert-success {
    background: rgba(31, 163, 74, 0.2);
    border: 1px solid #1fa34a;
    color: #bbf7d0;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 600;
}

.alert-error {
    background: rgba(220, 38, 38, 0.2);
    border: 1px solid #dc2626;
    color: #fecaca;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 600;
}

/* Modal Popups */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(8, 1, 3, 0.78);
    backdrop-filter: blur(3px);
    z-index: 80;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-backdrop.open { display: flex; }

.modal-box {
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    background: linear-gradient(180deg, #32050d 0%, #1a0206 100%);
    border: 2px solid #d4a338;
    border-radius: 14px;
    padding: 18px 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
    color: #fff;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 10px;
    margin-bottom: 14px;
    border-bottom: 1px solid rgba(242, 199, 92, 0.3);
}

.modal-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--gold-light);
}

.modal-close {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(242, 199, 92, 0.35);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
}

/* Donut Legend */
.donut-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex: 1;
    flex-wrap: wrap;
}

.legend-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 140px;
}

.legend-row {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    font-weight: 600;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-pct { margin-left: auto; font-weight: 700; color: #3d2228; }

.chart-tooltip-pill {
    background: #200308;
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.25;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}

/* Responsive Mobile Drawer & Layout */
@media (max-width: 1120px) {
    body { padding: 6px; }
    .shell { grid-template-columns: 1fr; }
    .menu-toggle { display: inline-flex; }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 270px;
        max-width: 82vw;
        z-index: 60;
        transform: translateX(-105%);
        transition: transform 0.22s ease;
        overflow-y: auto;
        border-right: 2px solid #d4a338;
        box-shadow: 8px 0 30px rgba(0, 0, 0, 0.8);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-mobile-head { display: flex; }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .topbar { padding: 10px 12px; }
    .topbar-title { font-size: 14.5px; }
    .topbar-sub { display: none; }
    .avatar-pill { display: none; }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpi-card { padding: 11px 10px; gap: 8px; }
    .kpi-icon { width: 34px; height: 34px; }
    .kpi-value { font-size: 16px; }
    .main { padding: 10px; }
}
