:root {
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --border-color: #e2e8f0;

    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #0ea5e9;
    --warning: #f59e0b;
    --danger: #ef4444;
    --purple: #8b5cf6;
    --teal: #14b8a6;

    --sidebar-width: 260px;
    --header-height: 64px;
    --radius-sm: 8px;
    --radius-md: 14px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.02), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    overflow-x: hidden;
    font-size: 13.5px;
    -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-main);
    margin-bottom: 0;
    letter-spacing: -0.02em;
}

.hidden {
    display: none !important;
}

.text-purple {
    color: var(--purple) !important;
}

/* LOGIN */
#login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0e7ff 100%);
}

.login-box {
    width: 100%;
    max-width: 400px;
    background: var(--bg-surface);
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.08);
}

.login-logo {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--success));
    color: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 20px;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-main);
}

/* APP LAYOUT */
#app-screen {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: var(--header-height) 1fr;
    grid-template-areas:
        "sidebar header"
        "sidebar main";
    height: 100vh;
}

.sidebar {
    grid-area: sidebar;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    z-index: 10;
}

.brand {
    padding: 0 28px 24px;
    font-weight: 700;
    font-size: 18px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.brand-icon {
    background: linear-gradient(135deg, var(--primary), var(--success));
    color: white;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 16px;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.2);
}

.nav-section-label {
    padding: 0 24px;
    margin-bottom: 12px;
    color: var(--text-light);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.nav-item {
    padding: 12px 24px;
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 14px;
    margin: 4px 16px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    text-decoration: none;
}

.nav-item:hover {
    background-color: #f1f5f9;
    color: var(--text-main);
}

.nav-item.active {
    background-color: var(--bg-body);
    color: var(--primary);
    font-weight: 600;
}

.menu-siswa-style .nav-item.active {
    background-color: #eff6ff;
    color: var(--primary);
}

.menu-admin-style .nav-item.active {
    background-color: #f5f3ff;
    color: var(--purple);
}

.menu-staff-style .nav-item.active {
    background-color: #f0fdfa;
    color: var(--teal);
}

.top-header {
    grid-area: header;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 36px;
    z-index: 5;
}

.main-content {
    grid-area: main;
    padding: 36px 48px;
    overflow-y: auto;
    position: relative;
}

/* COMPONENTS */
.card-flat {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card-flat.hoverable:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.accent-bar-primary {
    border-left: 5px solid var(--primary);
}

.accent-bar-success {
    border-left: 5px solid var(--success);
}

.accent-bar-purple {
    border-left: 5px solid var(--purple);
}

.accent-bar-warning {
    border-left: 5px solid var(--warning);
}

.form-control,
.form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    padding: 9px 14px;
    font-size: 13.5px;
    color: var(--text-main);
    background-color: var(--bg-surface);
    box-shadow: 0 1px 2px rgba(0,0,0,0.01) inset;
    transition: all 0.2s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
    outline: none;
}

.btn-minimal {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: var(--radius-sm);
    padding: 9px 16px;
    font-weight: 500;
    font-size: 13.5px;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.btn-minimal:hover {
    background-color: #f8fafc;
    border-color: #cbd5e1;
}

.btn-solid {
    background-color: var(--primary);
    border: 1px solid transparent;
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 9px 18px;
    font-weight: 600;
    font-size: 13.5px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
    text-decoration: none;
}

.btn-solid:hover {
    background-color: var(--primary-hover);
    color: #fff;
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.3);
    transform: translateY(-1px);
}

.table-wrapper {
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.table-minimal {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.table-minimal th {
    text-align: left;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-weight: 600;
    background-color: #f8fafc;
    white-space: nowrap;
}

.table-minimal td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}

.table-minimal tr:hover td {
    background-color: #fcfcfd;
}

.badge-status {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.bg-success-soft {
    background-color: #ecfdf5;
    color: #059669;
    border: 1px solid #a7f3d0;
}

.bg-warning-soft {
    background-color: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}

.bg-danger-soft {
    background-color: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.bg-info-soft {
    background-color: #f0f9ff;
    color: #0284c7;
    border: 1px solid #bae6fd;
}

.badge-lock {
    background-color: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 600;
}

.master-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
    overflow-x: auto;
}

.master-tab-btn {
    padding: 12px 24px;
    border: none;
    background: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 14px;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: -1px;
    white-space: nowrap;
    text-decoration: none;
}

.master-tab-btn:hover {
    color: var(--text-main);
}

.master-tab-btn.active {
    color: var(--purple);
    border-bottom-color: var(--purple);
    font-weight: 600;
}

/* ABSENSI BUTTON GROUP */
.btn-group-custom .btn {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
}

.btn-group-custom .btn-check:checked + .btn-outline-success {
    background-color: #10b981;
    color: white;
    border-color: #10b981;
}

.btn-group-custom .btn-check:checked + .btn-outline-warning {
    background-color: #f59e0b;
    color: white;
    border-color: #f59e0b;
}

.btn-group-custom .btn-check:checked + .btn-outline-info {
    background-color: #0ea5e9;
    color: white;
    border-color: #0ea5e9;
}

.btn-group-custom .btn-check:checked + .btn-outline-danger {
    background-color: #ef4444;
    color: white;
    border-color: #ef4444;
}

@media print {
    .sidebar,
    .top-header,
    .master-tabs,
    button,
    select,
    input[type="radio"],
    .btn-group-custom {
        display: none !important;
    }

    #app-screen {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        height: auto;
    }

    .main-content {
        padding: 0;
    }

    .card-flat,
    .table-wrapper {
        box-shadow: none;
        border: 1px solid #000;
    }
}

/* =========================
   ADMIN STABILIZER PATCH
========================= */

.page-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
}

.page-heading h3,
.page-heading h4 {
    font-weight: 700;
    font-size: 20px;
    margin-bottom: 6px;
}

.page-heading p {
    color: var(--text-muted);
    margin-bottom: 0;
    font-size: 13.5px;
}

.admin-filter-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.admin-table-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background-color: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-table-header h5 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 0;
}

.action-group {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.action-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.action-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.action-btn.edit {
    color: var(--primary);
}

.action-btn.delete {
    color: var(--danger);
}

.modal-content {
    border-radius: var(--radius-md) !important;
    border: 0 !important;
}

.modal-header {
    padding: 20px 24px 8px;
}

.modal-body {
    padding: 16px 24px;
}

.modal-footer {
    padding: 8px 24px 24px;
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}

.table-responsive-clean {
    width: 100%;
    overflow-x: auto;
}

.table-minimal td:last-child,
.table-minimal th:last-child {
    white-space: nowrap;
}

.alert {
    font-size: 13.5px;
}

.empty-state {
    padding: 32px;
    text-align: center;
    color: var(--text-muted);
}

@media (max-width: 992px) {
    #app-screen {
        grid-template-columns: 1fr;
        grid-template-rows: var(--header-height) 1fr;
        grid-template-areas:
            "header"
            "main";
    }

    .sidebar {
        display: none;
    }

    .main-content {
        padding: 24px;
    }

    .top-header {
        padding: 0 20px;
    }

    .page-heading {
        flex-direction: column;
    }
}

.action-group form {
    margin: 0;
}

.action-btn:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

.table-minimal .badge {
    font-size: 12px;
    font-weight: 600;
}