/* ===== SIGAP Design System ===== */
:root {
    --background: #FAFAFA;
    --surface: #FFFFFF;
    --sidebar: #FFFFFF;
    --primary: #E50914;
    --primary-hover: #C90812;
    --primary-soft: #FFF1F2;
    --text: #171717;
    --text-secondary: #737373;
    --border: #E5E5E5;
    --success: #16a34a;
    --success-soft: #f0fdf4;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --warning: #d97706;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    --radius: 12px;
    --sidebar-w: 260px;
}

[data-theme="dark"] {
    --background: #0D0D0D;
    --surface: #171717;
    --sidebar: #111111;
    --primary: #EF233C;
    --primary-hover: #ff3b52;
    --primary-soft: #2a1416;
    --text: #F5F5F5;
    --text-secondary: #A3A3A3;
    --border: #2A2A2A;
    --success: #22c55e;
    --success-soft: #14251a;
    --danger: #f87171;
    --danger-soft: #2a1414;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--background);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ===== Login ===== */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--background) 0%, var(--primary-soft) 100%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: var(--shadow);
}

/* Password field with show/hide toggle */
.pw-wrap {
    position: relative;
    display: block;
}

.pw-wrap input {
    width: 100%;
    padding-right: 44px;
}

.pw-toggle {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 42px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.pw-toggle svg {
    width: 18px;
    height: 18px;
    display: block;
}

.pw-toggle span {
    display: inline-flex;
    align-items: center;
}

.pw-toggle:hover {
    color: var(--primary);
}

.login-brand {
    text-align: center;
    margin-bottom: 24px;
}

.login-logo {
    width: 80px;
    height: 80px;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 22px;
    letter-spacing: 1px;
    margin-bottom: 12px;
    overflow: hidden;
}

.login-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.login-title {
    font-size: 22px;
    font-weight: 700;
}

.login-sub {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 4px;
}

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

.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.brand-logo {
    width: 38px;
    height: 38px;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    overflow: hidden;
    flex-shrink: 0;
}

.brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.brand-text b {
    font-size: 16px;
}

.brand-text span {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--background);
    color: var(--text);
}

.nav-item.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}

.nav-item.active .nav-icon {
    color: var(--primary);
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-group {
    margin-top: 14px;
}

.nav-group-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 4px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text-secondary);
}

.nav-group-label .nav-icon {
    width: 17px;
    height: 17px;
    opacity: 0.8;
}

.nav-item.nav-sub {
    margin-left: 12px;
    padding-left: 12px;
    font-size: 13px;
    border-left: 1px solid var(--border);
    border-radius: 0 10px 10px 0;
}

.nav-item.nav-sub.active {
    border-left-color: var(--primary);
}

.sidebar-user {
    border-top: 1px solid var(--border);
    padding: 14px 16px;
}

.user-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    text-transform: uppercase;
}

.user-name {
    font-weight: 600;
    font-size: 13px;
}

.user-role {
    font-size: 11px;
    color: var(--text-secondary);
}

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

.topbar {
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 40;
}

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

.page-title {
    font-size: 17px;
    font-weight: 700;
}

.content {
    padding: 24px;
    flex: 1;
}

.footer {
    padding: 16px 24px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
    border-top: 1px solid var(--border);
}

.hamburger,
.overlay {
    display: none;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

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

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    opacity: 0.9;
}

.btn-sm {
    padding: 6px 10px;
    font-size: 12px;
}

.btn-icon {
    padding: 6px 8px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
}

.btn-ghost:hover {
    background: var(--background);
}

/* ===== Cards ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-body {
    padding: 18px;
}

.card-header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
}

/* Stat cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary);
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    font-size: 24px;
    font-weight: 800;
    margin-top: 6px;
}

.stat-icon {
    position: absolute;
    right: 16px;
    top: 16px;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Tabs ===== */
.tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.tab-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tab-link:hover {
    color: var(--text);
}

.tab-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-link .nav-icon {
    width: 16px;
    height: 16px;
}

/* ===== Tables ===== */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    text-align: left;
    padding: 12px 14px;
    background: var(--background);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:hover {
    background: var(--background);
}

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

.text-right {
    text-align: right;
}

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

.nowrap {
    white-space: nowrap;
}

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success {
    background: var(--success-soft);
    color: var(--success);
}

.badge-danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.badge-primary {
    background: var(--primary-soft);
    color: var(--primary);
}

.badge-muted {
    background: var(--background);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 14px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}

label .req {
    color: var(--primary);
}

input,
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: border 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.form-hint {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Toolbar / filters */
.toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 16px;
}

.toolbar .grow {
    flex: 1;
    min-width: 180px;
}

.toolbar-right {
    margin-left: auto;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ===== Modal ===== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: flex-start;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    overflow-y: auto;
}

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

.modal {
    background: var(--surface);
    border-radius: 14px;
    width: 100%;
    max-width: 520px;
    margin: 40px auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: modalIn 0.18s ease;
}

.modal.modal-lg {
    max-width: 640px;
}

@keyframes modalIn {
    from {
        transform: translateY(-12px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
}

.modal-body {
    padding: 20px;
    max-height: 65vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
}

/* Detail list */
.detail-list {
    display: grid;
    gap: 12px;
}

.detail-item {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 12px;
}

.detail-item dt {
    color: var(--text-secondary);
    font-size: 13px;
}

.detail-item dd {
    font-weight: 500;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 200;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--success);
    border-radius: 10px;
    padding: 12px 16px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    font-size: 13px;
    font-weight: 500;
    max-width: 340px;
    animation: toastIn 0.25s ease;
}

.toast.error {
    border-left-color: var(--danger);
}

@keyframes toastIn {
    from {
        transform: translateX(20px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Empty state */
.empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}

.empty-icon {
    width: 44px;
    height: 44px;
    margin: 0 auto 12px;
    opacity: 0.5;
}

/* Theme toggle */
.theme-toggle {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
}

.theme-toggle:hover {
    background: var(--background);
}

.action-group {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
}

.mono {
    font-variant-numeric: tabular-nums;
}

.muted {
    color: var(--text-secondary);
}

.mt-3 {
    margin-top: 16px;
}

.help-cred {
    font-size: 11px;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 14px;
}

/* ===== Responsive ===== */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .main {
        margin-left: 0;
    }

    .hamburger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        border-radius: 10px;
        border: 1px solid var(--border);
        background: var(--surface);
        cursor: pointer;
        color: var(--text);
    }

    .overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 45;
    }

    .overlay.open {
        display: block;
    }

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

    .detail-item {
        grid-template-columns: 1fr;
        gap: 2px;
    }
}

@media (max-width: 480px) {
    .content {
        padding: 16px;
    }

    .stat-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stat-value {
        font-size: 20px;
    }
}

/* Login: full white background & edge-to-edge card on mobile */
@media (max-width: 640px) {
    .login-wrap {
        background: var(--surface);
        padding: 0;
        align-items: stretch;
    }

    .login-card {
        max-width: none;
        min-height: 100vh;
        border: none;
        border-radius: 0;
        box-shadow: none;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 28px 24px;
    }

    .login-brand {
        margin-bottom: 28px;
    }

    .login-logo {
        width: 72px;
        height: 72px;
        border-radius: 18px;
        font-size: 28px;
        margin-bottom: 16px;
    }

    .login-title {
        font-size: 24px;
    }
}

/* ===== Anggota: foto, dynamic list, detail ===== */
.anggota-thumb {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    text-transform: uppercase;
    vertical-align: middle;
}

.repeat-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.repeat-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.repeat-row input {
    flex: 1;
}

.file-current {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.detail-photo {
    text-align: center;
    margin-bottom: 12px;
}

.detail-photo img {
    width: 120px;
    height: 120px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid var(--border);
}

/* ===== Status badges (Program Kerja SDM) ===== */
.badge.status-belum {
    background: var(--danger-soft);
    color: var(--danger);
}

.badge.status-proses {
    background: #eff6ff;
    color: #2563eb;
}

.badge.status-tinjauan {
    background: #fff7ed;
    color: #d97706;
}

.badge.status-selesai {
    background: var(--success-soft);
    color: var(--success);
}

[data-theme="dark"] .badge.status-proses {
    background: #14203a;
    color: #60a5fa;
}

[data-theme="dark"] .badge.status-tinjauan {
    background: #2a1e0f;
    color: #fbbf24;
}

/* ===== Clamp long table cell text so the table fits the screen ===== */
.cell-clamp {
    max-width: 320px;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* ===== Inline status dropdown (Daftar Program Kerja SDM) ===== */
.status-select {
    padding: 4px 26px 4px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background-color: var(--background);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.status-select.status-belum {
    background-color: var(--danger-soft);
    color: var(--danger);
    border-color: transparent;
}

.status-select.status-proses {
    background-color: #eff6ff;
    color: #2563eb;
    border-color: transparent;
}

.status-select.status-tinjauan {
    background-color: #fff7ed;
    color: #d97706;
    border-color: transparent;
}

.status-select.status-selesai {
    background-color: var(--success-soft);
    color: var(--success);
    border-color: transparent;
}

[data-theme="dark"] .status-select.status-proses {
    background-color: #14203a;
    color: #60a5fa;
}

[data-theme="dark"] .status-select.status-tinjauan {
    background-color: #2a1e0f;
    color: #fbbf24;
}