:root {
    --bg: #1a1a1a;
    --bg2: #242424;
    --bg3: #2e2e2e;
    --card: #2a2a2a;
    --border: #3a3a3a;
    --text: #e8e8e8;
    --text2: #a0a0a0;
    --accent: #4ade80;
    --accent2: #22c55e;
    --urgent: #ef4444;
    --penting: #f59e0b;
    --normal: #6b7280;
    --owner: #b45309;
    --pm: #1d4ed8;
    --pengawas: #0d9488;
    --blue: #3b82f6;
    --purple: #8b5cf6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-logo {
    padding: 0 20px 20px;
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}

.sidebar-logo span { color: var(--text2); font-size: 11px; display: block; font-weight: 400; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text2);
    transition: all 0.2s;
    border-left: 3px solid transparent;
    font-size: 13px;
}

.sidebar-nav a:hover, .sidebar-nav a.active {
    color: var(--text);
    background: var(--bg3);
    border-left-color: var(--accent);
}

.sidebar-nav a .icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-bottom {
    margin-top: auto;
    padding: 15px 20px;
    border-top: 1px solid var(--border);
}

.user-info { display: flex; align-items: center; gap: 10px; }
.user-info .name { font-size: 13px; font-weight: 600; }
.user-info .role-tag { font-size: 11px; color: var(--text2); }

.main-content {
    margin-left: 220px;
    flex: 1;
    padding: 24px;
    max-width: calc(100vw - 220px);
}

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.topbar h1 { font-size: 20px; font-weight: 700; }
.topbar .date { color: var(--text2); font-size: 13px; }

.notif-btn {
    position: relative;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
}

.notif-badge {
    position: absolute;
    top: -4px; right: -4px;
    background: var(--urgent);
    color: #fff;
    font-size: 10px;
    width: 18px; height: 18px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}

/* Cards */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.card-title { font-size: 13px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; }

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--bg3);
    border-radius: 10px;
    padding: 14px;
}

.stat-card .num { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-card .num.urgent { color: var(--urgent); }
.stat-card .num.accent { color: var(--accent); }
.stat-card .label { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* Avatar */
.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
    flex-shrink: 0;
}

.avatar-pm { background: var(--pm); }
.avatar-pengawas { background: var(--pengawas); }
.avatar-owner { background: var(--owner); }
.avatar-vendor { background: var(--purple); }

/* Dashboard header card */
.dash-header {
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dash-header.pm { background: linear-gradient(135deg, #1e3a5f, #1d4ed8); }
.dash-header.pengawas { background: linear-gradient(135deg, #0f3d38, #0d9488); }
.dash-header.owner { background: linear-gradient(135deg, #3d2000, #b45309); }

.dash-header h2 { font-size: 18px; font-weight: 700; }
.dash-header .sub { font-size: 12px; opacity: 0.8; margin-top: 2px; }

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-urgent { background: rgba(239,68,68,0.2); color: #ef4444; border: 1px solid rgba(239,68,68,0.3); }
.badge-penting { background: rgba(245,158,11,0.2); color: #f59e0b; border: 1px solid rgba(245,158,11,0.3); }
.badge-normal { background: rgba(107,114,128,0.2); color: #9ca3af; border: 1px solid rgba(107,114,128,0.3); }
.badge-low { background: rgba(59,130,246,0.2); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.badge-done { background: rgba(74,222,128,0.2); color: #4ade80; border: 1px solid rgba(74,222,128,0.3); }
.badge-progress { background: rgba(59,130,246,0.2); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.badge-pending { background: rgba(107,114,128,0.2); color: #9ca3af; border: 1px solid rgba(107,114,128,0.3); }

/* Task list */
.task-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.task-item:last-child { border-bottom: none; }

.task-check {
    width: 20px; height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border);
    flex-shrink: 0;
    cursor: pointer;
    margin-top: 2px;
    transition: all 0.2s;
}

.task-check.done { background: var(--accent); border-color: var(--accent); }
.task-check.done::after { content: '✓'; color: #000; font-size: 11px; display: flex; align-items: center; justify-content: center; height: 100%; }

.task-title { font-size: 13px; font-weight: 500; }
.task-title.done-text { text-decoration: line-through; color: var(--text2); }
.task-meta { font-size: 11px; color: var(--text2); margin-top: 3px; }

/* Progress bar */
.progress-bar {
    background: var(--bg3);
    border-radius: 4px;
    height: 6px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--accent);
    transition: width 0.3s;
}

.progress-fill.urgent { background: var(--urgent); }
.progress-fill.penting { background: var(--penting); }

/* Project item */
.project-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.project-item:last-child { border-bottom: none; }
.project-name { font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }

/* Decision cards */
.decision-card {
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.decision-card:hover { opacity: 0.85; }
.decision-card.red { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); }
.decision-card.yellow { background: rgba(245,158,11,0.15); border: 1px solid rgba(245,158,11,0.3); }
.decision-card.orange { background: rgba(249,115,22,0.15); border: 1px solid rgba(249,115,22,0.3); }

.decision-card .dtitle { font-size: 13px; font-weight: 600; }
.decision-card .dsub { font-size: 12px; color: var(--text2); margin-top: 3px; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 6px; font-weight: 500; }

.form-control {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    transition: border-color 0.2s;
}

.form-control:focus { outline: none; border-color: var(--accent); }
textarea.form-control { resize: vertical; min-height: 80px; }

select.form-control option { background: var(--bg3); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: var(--accent2); }
.btn-danger { background: var(--urgent); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--penting); color: #000; }
.btn-warning:hover { background: #d97706; }
.btn-ghost { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-pengawas { background: var(--pengawas); color: #fff; }
.btn-pengawas:hover { background: #0f766e; }

/* Table */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text2);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:hover td { background: var(--bg3); }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text2); font-size: 20px; cursor: pointer; }

/* Notif dropdown */
.notif-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 300px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    z-index: 200;
    overflow: hidden;
}

.notif-dropdown.active { display: block; }
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 12px; }
.notif-item:last-child { border-bottom: none; }
.notif-item .ntype { font-size: 10px; color: var(--text2); margin-top: 3px; }

/* Report photo preview */
.photo-preview {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.photo-preview img {
    width: 80px; height: 80px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* AI result box */
.ai-result {
    background: rgba(74,222,128,0.08);
    border: 1px solid rgba(74,222,128,0.2);
    border-radius: 10px;
    padding: 14px;
    font-size: 13px;
    line-height: 1.6;
    margin-top: 12px;
    white-space: pre-wrap;
}

.ai-result.error {
    background: rgba(239,68,68,0.08);
    border-color: rgba(239,68,68,0.2);
    color: #ef4444;
}

/* Section label */
.section-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 16px 0 8px;
}

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; }

.tab-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text2);
    transition: all 0.2s;
}

.tab-btn.active { background: var(--accent); color: #000; border-color: var(--accent); }

/* Alert */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-success { background: rgba(74,222,128,0.1); border: 1px solid rgba(74,222,128,0.3); color: var(--accent); }
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #ef4444; }
.alert-info { background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.3); color: #60a5fa; }

/* Owner read-only banner */
.readonly-banner {
    background: rgba(245,158,11,0.15);
    border: 1px solid rgba(245,158,11,0.3);
    color: var(--penting);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 12px;
    text-align: center;
    margin-bottom: 16px;
}

/* Login page */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 380px;
}

.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo h1 { font-size: 22px; font-weight: 800; color: var(--accent); }
.login-logo p { color: var(--text2); font-size: 13px; margin-top: 4px; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; max-width: 100vw; padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .mobile-menu-btn { display: flex; }
}

.mobile-menu-btn {
    display: none;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* Grid helpers */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.text-muted { color: var(--text2); }
.text-sm { font-size: 12px; }
.fw-600 { font-weight: 600; }
/* Light Theme */
body.light-theme {
    --bg: #ffffff;
    --bg2: #f8f9fa;
    --bg3: #e9ecef;
    --card: #ffffff;
    --border: #dee2e6;
    --text: #212529;
    --text2: #6c757d;
    --accent: #198754;
    --accent2: #20c997;
    --urgent: #dc3545;
    --penting: #fd7e14;
    --normal: #6c757d;
    --owner: #d63384;
    --pm: #0d6efd;
    --pengawas: #20c997;
    --blue: #0d6efd;
    --purple: #6f42c1;
}

/* Mobile Navigation */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card);
    border-top: 1px solid var(--border);
    padding: 8px 0;
    z-index: 1000;
    flex-direction: row;
    justify-content: space-around;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    text-decoration: none;
    color: var(--text2);
    border-radius: 8px;
    transition: all 0.2s;
    min-width: 0;
    flex: 1;
    max-width: 80px;
    border: none;
    background: none;
    cursor: pointer;
}

.mobile-nav-item:hover,
.mobile-nav-item.active {
    color: var(--accent);
    background: rgba(74,222,128,0.1);
}

.mobile-nav-icon {
    font-size: 18px;
    margin-bottom: 2px;
}

.mobile-nav-label {
    font-size: 10px;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar { 
        transform: translateX(-100%); 
        transition: transform 0.3s; 
    }
    .sidebar.open { 
        transform: translateX(0); 
    }
    .main-content { 
        margin-left: 0; 
        max-width: 100vw; 
        padding: 16px; 
        padding-bottom: 80px; /* Space for mobile nav */
    }
    .mobile-nav { 
        display: flex; 
    }
    .mobile-menu-btn { 
        display: flex; 
    }
    .stats-grid { 
        grid-template-columns: repeat(2, 1fr); 
    }
    .grid-2 { 
        grid-template-columns: 1fr; 
    }
    .grid-3 { 
        grid-template-columns: repeat(2, 1fr); 
    }
    .flex-between {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .topbar h1 {
        font-size: 18px;
    }
    .card {
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 12px;
    }
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .mobile-nav-label {
        font-size: 9px;
    }
    .mobile-nav-icon {
        font-size: 16px;
    }
}

/* Light theme scrollbar */
body.light-theme ::-webkit-scrollbar-track { 
    background: #f1f3f4; 
}
body.light-theme ::-webkit-scrollbar-thumb { 
    background: #dadce0; 
}
body.light-theme ::-webkit-scrollbar-thumb:hover { 
    background: #bdc1c6; 
}