:root {
    --primary-color: #4338CA;
    --primary-hover: #3730A3;
    --accent-color: #0891B2;
    --gradient-main: linear-gradient(135deg, #4338CA 0%, #6D28D9 45%, #0891B2 100%);
    --gradient-soft: linear-gradient(135deg, #EEF2FF 0%, #F0FDFA 100%);
    --bg-color: #EEF2FF;
    --card-bg: #FFFFFF;
    --text-main: #1E293B;
    --text-muted: #64748B;
    --border-color: #E2E8F0;
    --instruction-bg: #F5F3FF;
    --sidebar-width: 250px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--gradient-soft);
    background-attachment: fixed;
    color: var(--text-main);
    margin: 0;
    min-height: 100vh;
}

/* ---------------- LOGIN SCREEN ---------------- */

#loginScreen {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-card {
    position: relative;
    background-color: var(--card-bg);
    padding: 36px 40px 32px;
    border-radius: 16px;
    box-shadow: 0 20px 45px rgba(67, 56, 202, 0.16), 0 4px 12px rgba(8, 145, 178, 0.08);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.login-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 7px;
    background: var(--gradient-main);
}

.login-logo {
    width: 64px; height: 64px;
    border-radius: 16px;
    margin: 0 auto 16px;
    display: block;
}

.brand-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--gradient-main);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.6px;
    padding: 5px 12px;
    border-radius: 999px;
    margin-bottom: 14px;
    text-transform: uppercase;
}

.login-card h2 {
    margin-top: 0;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 4px;
    letter-spacing: -0.5px;
    text-align: center;
}

.login-card p.subtitle {
    color: var(--text-muted);
    font-size: 13.5px;
    margin-bottom: 22px;
    font-weight: 500;
    text-align: center;
}

.login-center { text-align: center; }

.back-to-home {
    text-align: center;
    margin-top: 16px;
}
.back-to-home a {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s ease;
}
.back-to-home a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.mode-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}
.mode-tab {
    flex: 1;
    min-width: 180px;
    background: #F8FAFC;
    color: var(--text-muted);
    border: 1.5px solid var(--border-color);
    padding: 11px 16px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}
.mode-tab:hover { background: var(--instruction-bg); color: var(--primary-color); }
.mode-tab.active {
    background: var(--gradient-main);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 14px rgba(67, 56, 202, 0.25);
}

.bpr-logo-thumb {
    width: 36px; height: 36px; object-fit: cover;
    border-radius: 8px; border: 1px solid var(--border-color);
    display: block;
}

.bpr-profile-card {
    display: flex; align-items: center; gap: 16px;
    background: var(--instruction-bg);
    border: 1px solid #C7D2FE;
    border-radius: 12px;
    padding: 16px 18px;
    margin-bottom: 18px;
}
.bpr-profile-logo img, .bpr-profile-logo-placeholder {
    width: 64px; height: 64px; border-radius: 12px;
    object-fit: cover; flex-shrink: 0;
}
.bpr-profile-logo-placeholder {
    display: flex; align-items: center; justify-content: center;
    background: var(--gradient-main); color: #fff;
    font-weight: 800; font-size: 13px; letter-spacing: 0.5px;
}
.bpr-profile-info { flex: 1; min-width: 0; }
.bpr-profile-name { font-weight: 800; font-size: 15px; color: var(--text-main); margin-bottom: 4px; }

.sidebar-bpr-logo { margin-bottom: 10px; }
.sidebar-bpr-logo img {
    width: 40px; height: 40px; border-radius: 9px;
    object-fit: cover; border: 1px solid rgba(255,255,255,0.3);
}

.lock-tag {
    display: inline-block;
    background: #F1F5F9;
    color: #64748B;
    font-size: 12px;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid #E2E8F0;
}

/* ---------------- FORM ELEMENTS (shared) ---------------- */

.form-group { margin-bottom: 18px; }
.row-group { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }

label { display: block; margin-bottom: 8px; font-weight: 600; font-size: 14px; color: #334155; }
label .req { color: #DC2626; }

input[type="text"], input[type="number"], input[type="password"],
input[type="date"], input[type="file"], select, textarea {
    width: 100%;
    padding: 12px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background-color: #fff;
    transition: all 0.2s ease;
    color: var(--text-main);
}

textarea { resize: vertical; }

select { cursor: pointer; font-weight: 600; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 56, 202, 0.15);
}

input[type="file"] { padding: 9px; background-color: #F8FAFC; cursor: pointer; }
input:disabled { background: #F1F5F9; color: var(--text-muted); }

.field-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

.btn-generate {
    background: var(--gradient-main);
    color: white;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.2px;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 8px 18px rgba(67, 56, 202, 0.28);
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-generate:hover { transform: translateY(-1px); box-shadow: 0 12px 22px rgba(67, 56, 202, 0.35); }
.btn-generate:active { transform: translateY(0); }
.btn-generate.btn-inline { width: auto; padding: 11px 20px; font-size: 14px; }

.btn-outline {
    background: #fff;
    color: var(--primary-color);
    border: 1.5px solid var(--primary-color);
    padding: 11px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-outline:hover { background: var(--instruction-bg); }

.btn-reset {
    background-color: #fff;
    color: #DC2626;
    border: 1.5px solid #FCA5A5;
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}
.btn-reset:hover { background-color: #FEF2F2; border-color: #EF4444; }

.btn-small {
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    margin-right: 6px;
    margin-bottom: 4px;
}
.btn-primary-small { background: var(--primary-color); color: #fff; }
.btn-primary-small:hover { background: var(--primary-hover); }
.btn-danger-small { background: #FEF2F2; color: #B91C1C; border: 1px solid #FCA5A5; }
.btn-danger-small:hover { background: #FEE2E2; }
.btn-outline-small { background: #fff; color: var(--accent-color); border: 1px solid #A5F3FC; }
.btn-outline-small:hover { background: #ECFEFF; }

.preview-ref {
    font-family: 'Consolas', monospace;
    background: #F1F5F9;
    border: 1px dashed #CBD5E1;
    padding: 9px 10px;
    border-radius: 6px;
    font-size: 13px;
    margin-top: 8px;
    color: var(--primary-color);
    font-weight: 700;
}

.status {
    margin-top: 15px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    min-height: 20px;
    padding: 12px;
    border-radius: 8px;
    display: none;
}
.status.success { display: block; background-color: #ECFDF5; color: #065F46; border: 1px solid #6EE7B7; }
.status.error { display: block; background-color: #FEF2F2; color: #991B1B; border: 1px solid #FCA5A5; }

.invalid-preview {
    display: none; margin-top: 15px; background-color: #FFF7ED;
    border: 1px solid #FDBA74; border-left: 4px solid #F97316;
    color: #7C2D12; padding: 12px 14px; border-radius: 8px; font-size: 13px;
}
.duplicate-info {
    display: none; margin-top: 15px; background-color: #EFF6FF;
    border: 1px solid #93C5FD; border-left: 4px solid #2563EB;
    color: #1E3A8A; padding: 12px 14px; border-radius: 8px; font-size: 13px;
}
.invalid-preview h4, .duplicate-info h4 { margin: 0 0 8px 0; font-size: 14px; }
.invalid-preview h4 { color: #9A3412; }
.duplicate-info h4 { color: #1D4ED8; }
.invalid-preview p, .duplicate-info p { margin: 0 0 8px 0; line-height: 1.4; }
.invalid-list {
    max-height: 160px; overflow-y: auto; background: #FFFFFF;
    border: 1px solid #FED7AA; border-radius: 6px; padding: 8px;
    font-family: monospace; font-size: 12.5px;
}
.duplicate-info .invalid-list { border: 1px solid #BFDBFE; }
.invalid-list div { padding: 4px 0; border-bottom: 1px dashed #FED7AA; }
.duplicate-info .invalid-list div { border-bottom: 1px dashed #BFDBFE; }
.invalid-list div:last-child { border-bottom: none; }

.instructions {
    background-color: var(--instruction-bg);
    border-left: 4px solid var(--primary-color);
    padding: 15px 20px;
    border-radius: 0 10px 10px 0;
    margin-bottom: 25px;
    font-size: 13.5px;
    color: var(--text-main);
}
.instructions h3 { margin: 0 0 8px 0; font-size: 14px; color: var(--primary-color); }
.instructions ul { margin: 0; padding-left: 20px; }
.instructions li { margin-bottom: 6px; line-height: 1.4; }

/* ---------------- APP SHELL ---------------- */

#appShell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--gradient-main);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 22px 0;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    overflow-y: auto;
    z-index: 40;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.18);
    margin-bottom: 16px;
}
.sidebar-brand img { width: 38px; height: 38px; border-radius: 9px; flex-shrink: 0; }
.sidebar-brand-text { line-height: 1.25; }
.sidebar-brand-text strong { display: block; font-size: 14.5px; font-weight: 800; }
.sidebar-brand-text span { font-size: 11px; opacity: 0.85; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    opacity: 0.85;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.10); opacity: 1; }
.nav-item.active { background: rgba(255,255,255,0.16); opacity: 1; border-left-color: #fff; }
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
    margin-top: auto;
    padding: 16px 20px 4px;
    border-top: 1px solid rgba(255,255,255,0.18);
}
.sidebar-user-name { font-weight: 700; font-size: 14px; }
.sidebar-user-bpr { font-size: 12px; opacity: 0.85; margin: 4px 0 10px; }
.btn-logout {
    display: flex; align-items: center; gap: 8px;
    width: 100%; background: rgba(255,255,255,0.14); color: #fff;
    border: none; padding: 10px 12px; border-radius: 8px;
    font-size: 13px; font-weight: 700; cursor: pointer;
}
.btn-logout:hover { background: rgba(255,255,255,0.24); }

.role-badge {
    display: inline-block; font-size: 11px; font-weight: 700;
    padding: 3px 9px; border-radius: 999px; letter-spacing: 0.3px;
}
.badge-admin { background: #FEF3C7; color: #92400E; }
.badge-supervisor { background: #DBEAFE; color: #1E40AF; }
.badge-checker { background: #DCFCE7; color: #166534; }
.sidebar .role-badge.badge-admin { background: #FDE68A; color: #78350F; }
.sidebar .role-badge.badge-supervisor { background: #BFDBFE; color: #1E3A8A; }
.sidebar .role-badge.badge-checker { background: #BBF7D0; color: #14532D; }

.main-area {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: #fff;
    padding: 16px 28px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar h1 { font-size: 19px; margin: 0; font-weight: 800; color: var(--text-main); }
.hamburger {
    display: none; background: none; border: none; cursor: pointer;
    padding: 6px; color: var(--text-main);
}

.content-area { padding: 26px 28px 60px; flex: 1; }

.footer-note { text-align: center; padding: 18px; font-size: 12.5px; color: var(--text-muted); font-weight: 500; }

/* ---------------- CARDS / PANELS ---------------- */

.card {
    position: relative;
    background-color: var(--card-bg);
    padding: 30px 32px;
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(67, 56, 202, 0.10), 0 4px 12px rgba(8, 145, 178, 0.06);
    overflow: hidden;
}
.card::before {
    content: ""; position: absolute; top: 0; left: 0; right: 0; height: 6px;
    background: var(--gradient-main);
}
.wide-card { max-width: 720px; }

.panel {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 26px 28px;
    box-shadow: 0 12px 30px rgba(67, 56, 202, 0.08), 0 4px 12px rgba(8, 145, 178, 0.05);
    margin-bottom: 22px;
}
.panel h3 { margin-top: 0; font-size: 17px; font-weight: 800; color: var(--text-main); }
.panel-header-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }

.welcome-card {
    background: var(--gradient-main);
    color: #fff;
    padding: 26px 30px;
    border-radius: 16px;
    margin-bottom: 22px;
}
.welcome-card h2 { margin: 0 0 6px; font-size: 21px; }
.welcome-card p { margin: 0; opacity: 0.92; font-size: 13.5px; }
.welcome-card .role-badge { background: rgba(255,255,255,0.22); color: #fff; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card {
    background: #fff; border-radius: 14px; padding: 20px;
    box-shadow: 0 8px 20px rgba(67,56,202,0.08);
    border-top: 4px solid var(--primary-color);
}
.stat-value { font-size: 28px; font-weight: 800; color: var(--text-main); }
.stat-label { font-size: 13px; font-weight: 700; color: var(--text-main); margin-top: 4px; }
.stat-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

.quick-actions { display: flex; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.quick-actions .btn-inline { width: auto; }

.filter-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 6px; }
.filter-row .form-group { min-width: 170px; margin-bottom: 14px; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
    background: var(--instruction-bg); color: var(--primary-color);
    text-align: left; padding: 10px 12px; font-weight: 700;
    white-space: nowrap; border-bottom: 2px solid var(--border-color);
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.data-table tr:hover td { background: #FAFAFF; }
.data-table code { background: #F1F5F9; padding: 2px 6px; border-radius: 4px; font-size: 12.5px; }
.action-cell { white-space: nowrap; }

.empty-state { color: var(--text-muted); font-size: 13.5px; text-align: center; padding: 24px 0; }

.status-pill { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status-aktif { background: #DCFCE7; color: #166534; }
.status-nonaktif { background: #FEE2E2; color: #991B1B; }

.you-tag {
    background: var(--gradient-main); color: #fff; font-size: 10px; font-weight: 700;
    padding: 2px 7px; border-radius: 999px; margin-left: 6px; letter-spacing: 0.3px;
}

.inline-form {
    background: var(--instruction-bg);
    border: 1px dashed #C7D2FE;
    border-radius: 12px;
    padding: 18px 20px;
    margin-bottom: 18px;
}
.inline-form h4 { margin: 0 0 14px; font-size: 15px; color: var(--primary-color); }

.quota-info {
    font-size: 12.5px; font-weight: 700; color: var(--accent-color);
    background: #ECFEFF; border: 1px solid #A5F3FC; display: inline-block;
    padding: 6px 12px; border-radius: 999px; margin-bottom: 14px;
}

/* ---------------- RESPONSIVE ---------------- */

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 4px 0 20px rgba(0,0,0,0.2);
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .main-area { margin-left: 0; }
    .hamburger { display: inline-flex; align-items: center; }
}

@media (max-width: 480px) {
    .content-area { padding: 18px 16px 50px; }
    .card, .panel { padding: 20px 18px; }
    .row-group { flex-direction: column; align-items: stretch; }
    .btn-reset { width: 100%; }
    .filter-row .form-group { min-width: 100%; }
}
