:root {
    --maroon: #7B1F1F;
    --maroon-dark: #5a1717;
    --maroon-light: #a83838;
    --hijau: #2D5F2D;
    --hijau-dark: #1f4520;
    --hijau-light: #4ade80;
    --emas: #D4A017;
    --emas-light: #fbbf24;
    --slate: #1e293b;
    --slate-light: #475569;
    --bg-body: #f5f5f4;
    --bg-card: #ffffff;
    --border-light: #e5e7eb;
    --text-muted: #6b7280;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08);
    --sidebar-width: 260px;
    --topbar-height: 60px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-body);
    color: var(--slate);
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

/* ===== AUTH LAYOUT ===== */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #7B1F1F 0%, #2D5F2D 100%);
    padding: 20px;
}
.auth-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.auth-logo {
    text-align: center;
    margin-bottom: 24px;
}
.auth-logo img { height: 80px; }
.auth-title {
    text-align: center;
    color: var(--maroon);
    font-weight: 700;
    margin-bottom: 4px;
}
.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 28px;
    font-size: 14px;
}

/* ===== APP LAYOUT ===== */
.app-wrapper { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--maroon) 0%, var(--maroon-dark) 100%);
    color: white;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
}
.sidebar-header {
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}
.sidebar-header img { height: 40px; background: white; padding: 4px; border-radius: 50%; }
.sidebar-brand {
    font-weight: 700;
    font-size: 14px;
    line-height: 1.2;
}
.sidebar-brand small { display: block; font-size: 11px; opacity: 0.7; font-weight: 400; margin-top: 2px; }

.sidebar-menu { padding: 12px 0; list-style: none; margin: 0; }
.sidebar-section-title {
    padding: 12px 20px 4px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.5;
    font-weight: 600;
}
.sidebar-item { padding: 0; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 14px;
    border-left: 3px solid transparent;
    transition: all 0.15s;
}
.sidebar-link:hover {
    background: rgba(255,255,255,0.05);
    color: white;
    border-left-color: var(--emas);
}
.sidebar-link.active {
    background: rgba(255,255,255,0.1);
    color: white;
    border-left-color: var(--emas);
    font-weight: 500;
}
.sidebar-link i { width: 18px; text-align: center; opacity: 0.9; }
.sidebar-link .badge { margin-left: auto; }

/* Main */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background: white;
    border-bottom: 1px solid var(--border-light);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--slate);
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
}
.topbar-search {
    position: relative;
}
.topbar-search input {
    border: 1px solid var(--border-light);
    background: var(--bg-body);
    border-radius: 8px;
    padding: 6px 12px 6px 36px;
    font-size: 14px;
    width: 280px;
    outline: none;
}
.topbar-search input:focus { border-color: var(--maroon); background: white; }
.topbar-search i { position: absolute; left: 12px; top: 9px; color: var(--text-muted); font-size: 14px; }

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

.notif-button {
    position: relative;
    background: none;
    border: none;
    color: var(--slate);
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
}
.notif-button:hover { background: var(--bg-body); }
.notif-badge {
    position: absolute;
    top: 4px; right: 4px;
    background: var(--emas);
    color: var(--maroon-dark);
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px 4px 4px;
    border-radius: 30px;
    cursor: pointer;
    border: 1px solid var(--border-light);
    background: white;
    transition: background 0.15s;
}
.user-menu:hover { background: var(--bg-body); }
.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--maroon);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
}
.user-menu-name { font-weight: 500; font-size: 13px; }
.user-menu-role { font-size: 11px; color: var(--text-muted); }

/* Content */
.content {
    flex: 1;
    padding: 24px;
    max-width: 100%;
    overflow-x: hidden;
}
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--slate);
    margin: 0;
}
.page-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}

/* Cards */
.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    margin-bottom: 12px;
}
.stat-icon.maroon { background: rgba(123, 31, 31, 0.1); color: var(--maroon); }
.stat-icon.hijau { background: rgba(45, 95, 45, 0.1); color: var(--hijau); }
.stat-icon.emas { background: rgba(212, 160, 23, 0.15); color: #b48010; }
.stat-icon.info { background: rgba(59, 130, 246, 0.1); color: #2563eb; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--slate); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.card-pp {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}
.card-pp-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-pp-header h3 { margin: 0; font-size: 15px; font-weight: 600; }
.card-pp-body { padding: 20px; }

/* Buttons override */
.btn-primary {
    background: var(--maroon) !important;
    border-color: var(--maroon) !important;
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--maroon-dark) !important;
    border-color: var(--maroon-dark) !important;
}
.btn-success {
    background: var(--hijau) !important;
    border-color: var(--hijau) !important;
}
.btn-success:hover { background: var(--hijau-dark) !important; border-color: var(--hijau-dark) !important; }

.text-maroon { color: var(--maroon) !important; }
.bg-maroon { background-color: var(--maroon) !important; }
.text-hijau { color: var(--hijau) !important; }
.bg-hijau { background-color: var(--hijau) !important; }
.text-emas { color: var(--emas) !important; }

/* Tables */
.table { background: white; }
.table thead th {
    background: var(--bg-body);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-light);
}
.table tbody td { font-size: 14px; vertical-align: middle; }

/* Forms */
.form-control:focus, .form-select:focus {
    border-color: var(--maroon);
    box-shadow: 0 0 0 0.2rem rgba(123, 31, 31, 0.15);
}

/* Alerts */
.alert { border: none; border-left: 4px solid; }
.alert-success { background: rgba(45, 95, 45, 0.08); color: var(--hijau-dark); border-left-color: var(--hijau); }
.alert-danger { background: rgba(220, 38, 38, 0.08); color: #991b1b; border-left-color: #dc2626; }
.alert-warning { background: rgba(245, 158, 11, 0.1); color: #92400e; border-left-color: #f59e0b; }
.alert-info { background: rgba(59, 130, 246, 0.08); color: #1e40af; border-left-color: #3b82f6; }

/* Badges */
.badge { font-weight: 500; padding: 4px 10px; border-radius: 6px; }

/* Dropdown */
.dropdown-menu { border: 1px solid var(--border-light); box-shadow: 0 8px 24px rgba(0,0,0,0.1); border-radius: 10px; padding: 8px; }
.dropdown-item { border-radius: 6px; padding: 8px 12px; font-size: 14px; }
.dropdown-item:hover { background: var(--bg-body); }

/* Notif dropdown */
.notif-dropdown { width: 360px; padding: 0; }
.notif-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex; justify-content: space-between; align-items: center;
}
.notif-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex; gap: 12px;
    cursor: pointer;
    transition: background 0.15s;
}
.notif-item:hover { background: var(--bg-body); }
.notif-item.unread { background: rgba(123, 31, 31, 0.04); }
.notif-icon-circle {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(123, 31, 31, 0.1);
    color: var(--maroon);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.notif-content { flex: 1; min-width: 0; }
.notif-title { font-size: 13px; font-weight: 600; margin: 0 0 2px; }
.notif-message { font-size: 12px; color: var(--text-muted); margin: 0; line-height: 1.4; }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Document viewer */
.doc-viewer-modal .modal-dialog { max-width: 90%; height: 90vh; }
.doc-viewer-modal .modal-content { height: 90vh; }
.doc-viewer-modal .modal-body { padding: 0; height: calc(90vh - 60px); }
.doc-viewer-modal iframe { width: 100%; height: 100%; border: 0; }

/* Mobile */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main { margin-left: 0; }
    .topbar-toggle { display: block; }
    .topbar-search input { width: 160px; }
    .content { padding: 16px; }
}

/* Calendar overrides */
.fc-toolbar-title { font-size: 18px !important; }
.fc-button-primary { background: var(--maroon) !important; border-color: var(--maroon) !important; }
.fc-button-primary:hover { background: var(--maroon-dark) !important; border-color: var(--maroon-dark) !important; }
.fc-event { border-radius: 6px; padding: 2px 6px; font-size: 12px; }

/* Empty states */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state i { font-size: 48px; opacity: 0.4; margin-bottom: 16px; }
.empty-state h4 { color: var(--slate); font-weight: 500; }

/* Document viewer card */
.doc-card {
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    gap: 12px;
    align-items: center;
    background: var(--bg-body);
    transition: background 0.15s;
}
.doc-card:hover { background: white; box-shadow: var(--shadow-sm); }
.doc-card-icon {
    width: 48px; height: 48px;
    background: var(--maroon);
    color: white;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
}
.doc-card-info { flex: 1; min-width: 0; }
.doc-card-name { font-weight: 500; font-size: 14px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-card-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Kanban */
.kanban {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
.kanban-column { background: var(--bg-body); border-radius: 10px; padding: 12px; min-height: 400px; }
.kanban-column h5 { font-size: 13px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 12px; }
.kanban-card {
    background: white;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
    border-left: 3px solid var(--maroon);
}
@media (max-width: 992px) {
    .kanban { grid-template-columns: 1fr; }
}
