:root {
    --primary: #c0392b;
    --primary-dark: #96281b;
    --primary-light: #e74c3c;
    --gradient: linear-gradient(135deg, #c0392b 0%, #e74c3c 50%, #96281b 100%);
    --gradient-soft: linear-gradient(135deg, #c0392b 0%, #e74c3c 100%);
    --white: #ffffff;
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-400: #bdbdbd;
    --gray-500: #9e9e9e;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;
    --gray-900: #212121;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-width: 260px;
    --topbar-height: 64px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    min-height: 100vh;
    display: flex;
    -webkit-font-smoothing: antialiased;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--gradient);
    color: var(--white);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
}

.brand-logos {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.brand-logo-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 6px;
    background: var(--white);
    padding: 3px;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.brand-sub {
    font-size: 0.75rem;
    opacity: 0.8;
    font-weight: 400;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: var(--white);
}

.nav-item.active {
    background: rgba(255,255,255,0.2);
    color: var(--white);
    font-weight: 600;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.15);
    font-size: 0.75rem;
    opacity: 0.6;
}

/* ==================== MAIN WRAPPER ==================== */
.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==================== TOPBAR ==================== */
.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-700);
    padding: 4px;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.current-date {
    font-size: 0.85rem;
    color: var(--gray-600);
    font-weight: 500;
}

/* ==================== CONTENT ==================== */
.content {
    flex: 1;
    padding: 32px;
}

.section {
    display: none;
}

.section.active {
    display: block;
}

/* ==================== STAT CARDS ==================== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    transition: all 0.2s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-card.highlight {
    background: var(--gradient-soft);
    border: none;
    color: var(--white);
}

.stat-card.highlight .stat-label {
    color: rgba(255,255,255,0.85);
}

.stat-card.highlight .stat-value {
    color: var(--white);
}

.stat-card.highlight .stat-icon {
    background: rgba(255,255,255,0.2);
    color: var(--white);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--gray-500);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(192, 57, 43, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

/* ==================== CHARTS ==================== */
.charts-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

.chart-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.chart-header {
    padding: 20px 24px 0;
}

.chart-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.chart-subtitle {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.chart-body {
    padding: 16px 24px 24px;
    height: 280px;
}

.chart-body-tall {
    height: 360px;
}

/* ==================== TABLE ==================== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
}

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

.filter-select {
    padding: 8px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--gray-700);
    background: var(--white);
    cursor: pointer;
    transition: border-color 0.2s;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

.table-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.table-wrapper {
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    white-space: nowrap;
}

th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    border-bottom: 2px solid var(--gray-200);
}

td {
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

tr:hover td {
    background: var(--gray-50);
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-aktif {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-selesai {
    background: var(--gray-100);
    color: var(--gray-600);
}

.badge-belum {
    background: #fff3e0;
    color: #e65100;
}

/* ==================== INPUT SECTION ==================== */
.input-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--gray-200);
}

.tab-btn {
    padding: 12px 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--gray-500);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--gray-700);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Upload */
.upload-card {
    max-width: 600px;
}

.upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 48px 32px;
    text-align: center;
    transition: all 0.3s ease;
    background: var(--white);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: #fef5f4;
}

.upload-icon {
    color: var(--gray-400);
    margin-bottom: 16px;
}

.upload-area h3 {
    font-size: 1.1rem;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.upload-area p {
    color: var(--gray-500);
    font-size: 0.9rem;
}

.upload-divider {
    display: block;
    color: var(--gray-400);
    margin: 16px 0;
    font-size: 0.85rem;
}

.upload-area input[type="file"] {
    display: none;
}

#uploadStatus {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    display: none;
}

#uploadStatus.success {
    display: block;
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

#uploadStatus.error {
    display: block;
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

/* Form */
.form-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.82rem;
    color: var(--gray-700);
    font-weight: 500;
}

.required {
    color: var(--primary);
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--gray-800);
    transition: all 0.2s;
    background: var(--white);
}

.form-group input::placeholder {
    color: var(--gray-400);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.08);
}

.form-actions {
    display: flex;
    gap: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient-soft);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(192, 57, 43, 0.25);
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(192, 57, 43, 0.35);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .charts-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

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

    .menu-toggle {
        display: block;
    }

    .content {
        padding: 20px 16px;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .topbar {
        padding: 0 16px;
    }

    .page-title {
        font-size: 1rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .stats-row {
        grid-template-columns: 1fr;
    }
}

/* ==================== DRILL DOWN PANEL ==================== */
.drill-down-panel {
    position: fixed;
    right: -420px;
    top: 0;
    bottom: 0;
    width: 400px;
    background: var(--white);
    box-shadow: -4px 0 24px rgba(0,0,0,0.12);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.drill-down-panel.active {
    right: 0;
}

.drill-down-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gradient-soft);
    color: var(--white);
}

.drill-down-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.drill-down-count {
    font-size: 0.8rem;
    opacity: 0.85;
}

.btn-close {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255,255,255,0.2);
    border-radius: 8px;
    color: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-close:hover {
    background: rgba(255,255,255,0.3);
}

.drill-down-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.drill-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    transition: background 0.15s;
    border: 1px solid var(--gray-100);
}

.drill-item:hover {
    background: var(--gray-50);
    border-color: var(--gray-200);
}

.drill-item-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(192, 57, 43, 0.08);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.drill-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.drill-item-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drill-item-detail {
    font-size: 0.75rem;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drill-item-date {
    font-size: 0.72rem;
    color: var(--gray-400);
}

/* Chart interaction hints */
.chart-subtitle em {
    color: var(--primary);
    font-style: normal;
    font-weight: 500;
}

/* Overlay when panel is open */
.drill-down-panel.active ~ .stats-row,
.drill-down-panel.active ~ .charts-row {
    opacity: 0.6;
    pointer-events: none;
    transition: opacity 0.3s;
}

@media (max-width: 768px) {
    .drill-down-panel {
        width: 100%;
        right: -100%;
    }
}
