:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eff6ff;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --bg: #f5f8fc;
    --white: #ffffff;
    --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }
.d-none { display: none !important; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 250px;
    background: var(--white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 20;
    transition: width .25s ease, transform .25s ease;
}
.sidebar.collapsed { width: 72px; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .btn-text,
.sidebar.collapsed .sidebar-bottom { display: none; }
.sidebar.collapsed .brand { justify-content: center; padding: 22px 12px; }
.sidebar.collapsed .brand-icon { margin: 0; }
.sidebar.collapsed .nav-link { justify-content: center; padding: 11px 12px; }
.sidebar.collapsed .nav-icon { margin: 0; font-size: 18px; }
.sidebar.collapsed .sidebar-toggle { transform: rotate(180deg); }
.sidebar.collapsed .sidebar-bottom { padding: 12px; }
.sidebar.collapsed .sidebar-bottom .btn { justify-content: center; padding: 11px 12px; }
.sidebar-header { padding: 22px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-icon {
    width: 42px; height: 42px; border-radius: 11px; background: var(--primary); color: var(--white);
    display: grid; place-items: center; font-weight: 800; letter-spacing: .5px; flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.brand strong { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand span { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-toggle {
    display: none;
    width: 32px; height: 32px; border: 0; background: transparent; border-radius: 8px;
    color: var(--muted); cursor: pointer; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s, color .15s, transform .25s;
}
.sidebar-toggle:hover { background: var(--primary-soft); color: var(--primary); }
.sidebar-menu { padding: 15px 10px; flex: 1; overflow-y: auto; }
.nav-link {
    display: flex; align-items: center; gap: 10px; padding: 11px 13px; margin: 3px 0;
    border-radius: 9px; color: #4b5563; font-weight: 600; text-decoration: none;
    white-space: nowrap; transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.nav-link.active { background: #dbeafe; color: var(--primary-dark); }
.nav-icon { font-size: 18px; flex-shrink: 0; }
.nav-text { overflow: hidden; text-overflow: ellipsis; }
.sidebar-bottom { padding: 12px 10px 16px; border-top: 1px solid var(--border); }
.main-area { margin-left: 250px; min-height: 100vh; transition: margin-left .25s ease; }
.sidebar.collapsed + .main-area { margin-left: 72px; }
.topbar {
    height: 70px; padding: 0 25px; background: var(--white); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar h1 { margin: 0; font-size: 19px; }
.menu-toggle { display: none; border: 0; background: transparent; font-size: 21px; color: var(--text); }
.user-info { display: flex; align-items: center; gap: 10px; position: relative; }
.user-avatar {
    width: 38px; height: 38px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
    display: grid; place-items: center; font-weight: 800; cursor: pointer;
}
.user-info strong, .user-info small { display: block; }
.user-info small { color: var(--muted); margin-top: 2px; }
.user-dropdown {
    position: absolute; top: 100%; right: 0; margin-top: 8px;
    background: var(--white); border: 1px solid var(--border); border-radius: 10px;
    box-shadow: var(--shadow); min-width: 220px; opacity: 0; visibility: hidden;
    transform: translateY(-8px); transition: all .15s ease; z-index: 100;
}
.user-info:hover .user-dropdown,
.user-info:focus-within .user-dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-item {
    display: block; padding: 10px 15px; color: var(--text); text-decoration: none; font-size: 13px; font-weight: 500;
}
.dropdown-item:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.dropdown-item:first-child { border-radius: 10px 10px 0 0; }
.dropdown-item:last-child { border-radius: 0 0 10px 10px; }
.content { padding: 25px; max-width: 1500px; margin: 0 auto; }

.card { background: var(--white); border: 1px solid var(--border); border-radius: 14px; margin-bottom: 20px; box-shadow: var(--shadow); }
.card-header { min-height: 59px; padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-title { margin: 0; font-size: 16px; font-weight: 800; }
.card-body { padding: 20px; }
.card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.welcome {
    background: linear-gradient(135deg, var(--primary), #3b82f6); color: var(--white); border-radius: 15px;
    padding: 25px; margin-bottom: 22px; box-shadow: var(--shadow);
}
.welcome h2 { margin: 0 0 7px; font-size: 22px; }
.welcome p { margin: 0; opacity: .9; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 20px; }
.stat-card { background: var(--white); border: 1px solid var(--border); border-radius: 13px; padding: 18px; box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.stat-value { font-size: 25px; font-weight: 800; }
.stat-accent { border-left: 4px solid var(--primary); }

.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-group { margin-bottom: 17px; }
.form-label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 7px; }
.form-control, .form-select, .form-textarea {
    width: 100%; border: 1px solid #d1d5db; border-radius: 9px; padding: 10px 12px; background: var(--white); color: var(--text); outline: none;
}
.form-control:focus, .form-select:focus, .form-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.form-textarea { min-height: 260px; resize: vertical; line-height: 1.6; }
.form-help { color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: 6px; }
.form-actions { display: flex; align-items: end; gap: 8px; flex-wrap: wrap; }

.btn { border: 0; border-radius: 9px; padding: 10px 15px; font-size: 13px; font-weight: 700; transition: .15s; }
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-warning { background: var(--warning); color: var(--white); }
.btn-secondary { background: #e5e7eb; color: #374151; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 10px; font-size: 12px; }

.alert { display: none; padding: 12px 15px; border-radius: 9px; margin-bottom: 18px; font-size: 13px; }
.alert.show { display: block; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }

.table-wrapper { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 650px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { background: #f8fafc; color: #374151; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
td { font-size: 13px; }
tbody tr:hover td { background: #f9fafb; }
.empty-state { text-align: center; color: var(--muted); padding: 30px !important; }

.badge { display: inline-block; padding: 4px 8px; border-radius: 20px; font-size: 11px; font-weight: 800; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-primary { background: #dbeafe; color: #1d4ed8; }
.badge-warning { background: #fef3c7; color: #92400e; }

.filter-card { margin-bottom: 18px; }
.filter-actions { display: flex; align-items: end; gap: 8px; flex-wrap: wrap; }
.student-counter { display: inline-block; padding: 8px 12px; border-radius: 8px; background: #f1f5f9; font-weight: 800; }
.student-counter.ready { background: #dcfce7; color: #166534; }
.student-counter.warning { background: #fef3c7; color: #92400e; }
.student-counter.error { background: #fee2e2; color: #991b1b; }
.preview-list { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-top: 15px; }
.preview-list-header { padding: 10px 13px; background: #f8fafc; font-weight: 800; font-size: 12px; }
.preview-row { display: grid; grid-template-columns: 70px 1fr; gap: 10px; padding: 9px 13px; border-bottom: 1px solid #f1f5f9; }
.preview-row:last-child { border-bottom: 0; }
.preview-no { color: var(--muted); font-weight: 700; }

.attendance-table select { min-width: 130px; }
.status-cards { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.status-card-input { position: absolute; opacity: 0; pointer-events: none; }
.status-card-label {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 70px; padding: 8px 14px; border-radius: 10px; border: 2px solid transparent;
    background: var(--white); font-weight: 700; font-size: 12px; cursor: pointer;
    transition: all .15s ease; user-select: none; box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.status-card-label:hover { transform: translateY(-1px); box-shadow: 0 4px 8px rgba(0,0,0,.08); }
.status-card-input:checked + .status-card-label { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.12); }

/* Hadir - Hijau */
.status-card-input:checked + .status-card-label.status-hadir,
.status-card-label.status-hadir { border-color: #86efac; color: #166534; }
.status-card-input:checked + .status-card-label.status-hadir { background: #dcfce7; box-shadow: 0 4px 12px rgba(22, 163, 74, .25); }
.status-card-label.status-hadir:hover { background: #dcfce7; }

/* Sakit - Biru */
.status-card-input:checked + .status-card-label.status-sakit,
.status-card-label.status-sakit { border-color: #93c5fd; color: #1e40af; }
.status-card-input:checked + .status-card-label.status-sakit { background: #dbeafe; box-shadow: 0 4px 12px rgba(37, 99, 235, .25); }
.status-card-label.status-sakit:hover { background: #dbeafe; }

/* Ijin - Kuning */
.status-card-input:checked + .status-card-label.status-ijin,
.status-card-label.status-ijin { border-color: #fcd34d; color: #92400e; }
.status-card-input:checked + .status-card-label.status-ijin { background: #fef3c7; box-shadow: 0 4px 12px rgba(217, 119, 6, .25); }
.status-card-label.status-ijin:hover { background: #fef3c7; }

/* Alpha - Merah */
.status-card-input:checked + .status-card-label.status-alpha,
.status-card-label.status-alpha { border-color: #fca5a5; color: #991b1b; }
.status-card-input:checked + .status-card-label.status-alpha { background: #fee2e2; box-shadow: 0 4px 12px rgba(220, 38, 38, .25); }
.status-card-label.status-alpha:hover { background: #fee2e2; }

.report-meta { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 0 0 16px; color: #4b5563; }
.report-meta strong { color: var(--text); }
.report-table { min-width: 900px; }
.report-table th, .report-table td { white-space: nowrap; }
.report-table td:not(:nth-child(1)):not(:nth-child(2)):not(:nth-last-child(-n+4)) { text-align: center; }
.report-table td:not(:nth-last-child(-n+4)) { font-weight: 600; }
.report-table tfoot td { background: #f8fafc; font-weight: 800; }
.print-meta { display: none; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, #eff6ff, #dbeafe); }
.login-card { width: 100%; max-width: 420px; background: var(--white); border-radius: 20px; padding: 35px; box-shadow: 0 15px 40px rgba(30, 64, 175, .12); }
.login-logo { width: 70px; height: 70px; border-radius: 18px; background: var(--primary); color: var(--white); display: grid; place-items: center; margin: 0 auto 20px; font-size: 26px; font-weight: 800; }
.login-title { text-align: center; font-size: 24px; font-weight: 800; margin-bottom: 6px; }
.login-subtitle { text-align: center; color: var(--muted); margin-bottom: 28px; }

@media (max-width: 1100px) {
    .stats-grid, .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: .25s; }
    .sidebar.open { transform: translateX(0); box-shadow: 0 0 30px rgba(15, 23, 42, .15); }
    .main-area { margin-left: 0; }
    .menu-toggle { display: block; }
}
@media (max-width: 600px) {
    .content { padding: 15px; }
    .topbar { height: 62px; padding: 0 15px; }
    .topbar h1 { font-size: 16px; }
    .user-info small, .user-info strong { display: none; }
    .stats-grid, .form-grid, .form-grid.three, .form-grid.two { grid-template-columns: 1fr; }
    .welcome { padding: 20px; }
    .card-body { padding: 15px; }
    .login-card { padding: 25px 20px; }
}

.jurnal-print {
    white-space: normal;
    word-break: break-word;
}

.no-print {
    display: none !important;
}

.print-only {
    display: block;
}

@media print {
    @page {
        size: A4 landscape;
        margin: 10mm;
    }
    body { background: #fff; }
    .no-print, .sidebar, .topbar, .filter-card, .card:first-child, .alert, .filter-actions, .card-header, .form-help { display: none !important; }
    .content { padding: 0; max-width: none; }
    .card { box-shadow: none; border: 0; }
    .print-meta { display: block; margin-bottom: 18px; }
    .print-meta h2 { text-align: center; margin: 0 0 12px; font-size: 17px; }
    .print-meta p { margin: 4px 0; }
    .table-wrapper { overflow: visible; }
    table { min-width: 0; font-size: 9px; }
    th, td { padding: 5px 6px; }
}
