/*
 * Storia Absensi — design system bersama untuk semua halaman.
 * Token warna & ukuran di :root, lalu layout, komponen, dan utilitas kecil.
 */

:root {
    --font-sans: 'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --border: #e4e8ef;
    --border-strong: #cbd5e1;

    --text: #0f172a;
    --text-2: #334155;
    --muted: #64748b;
    --subtle: #94a3b8;

    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --primary-700: #1e40af;

    --success: #16a34a;
    --success-bg: #ecfdf5;
    --success-text: #166534;
    --success-border: #a7f3d0;

    --warning: #d97706;
    --warning-bg: #fffbeb;
    --warning-text: #92400e;
    --warning-border: #fde68a;

    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-bg: #fef2f2;
    --danger-text: #991b1b;
    --danger-border: #fecaca;

    --violet-bg: #f5f3ff;
    --violet-text: #5b21b6;

    --sidebar-bg: #0b1220;
    --sidebar-text: #cbd5e1;
    --sidebar-muted: #64748b;
    --sidebar-hover: rgba(148, 163, 184, 0.12);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 20px 40px -12px rgba(15, 23, 42, 0.25);
    --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.25);

    --sidebar-width: 264px;
    --topbar-height: 60px;
}

/* ---------- Reset & dasar ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--text); }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
svg { flex-shrink: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 6px; }

.skip-link {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 100;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--text);
    color: #fff;
    font-weight: 600;
}
.skip-link:focus { top: 12px; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- Layout aplikasi ---------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
    position: sticky;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 40;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 16px;
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.01em;
}
.sidebar-brand:hover { text-decoration: none; }

.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #fff;
    font-weight: 800;
    font-size: 1rem;
}

.brand-sub { display: block; font-size: 0.72rem; font-weight: 500; color: var(--sidebar-muted); letter-spacing: 0.02em; }

.nav { display: flex; flex-direction: column; gap: 2px; padding: 4px 12px 16px; }

.nav-section-title {
    margin: 14px 10px 6px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sidebar-muted);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 40px;
    padding: 8px 10px;
    border-radius: 10px;
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: 0.92rem;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.nav-link svg { width: 18px; height: 18px; opacity: 0.85; }
.nav-link:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-link.is-active { background: var(--primary); color: #fff; }
.nav-link.is-active svg { opacity: 1; }

.sidebar-footer {
    margin-top: auto;
    padding: 12px;
    border-top: 1px solid rgba(148, 163, 184, 0.14);
}

.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }

.avatar {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    background: #1e293b;
    color: #e2e8f0;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.user-chip-name { color: #fff; font-weight: 600; font-size: 0.9rem; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip-role { color: var(--sidebar-muted); font-size: 0.76rem; }
.user-chip > div { min-width: 0; }

.logout-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 40px;
    margin-top: 4px;
    padding: 8px 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #fca5a5;
    font-weight: 500;
    font-size: 0.92rem;
    cursor: pointer;
    text-align: left;
}
.logout-btn svg { width: 18px; height: 18px; }
.logout-btn:hover { background: rgba(239, 68, 68, 0.12); color: #fecaca; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: none;
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--topbar-height);
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 700; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.page { width: 100%; max-width: 1280px; margin: 0 auto; padding: 32px 32px 48px; }
.page.page-wide { max-width: 1600px; }
.page.page-narrow { max-width: 720px; }

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.page-title { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
.page-subtitle { margin-top: 4px; color: var(--muted); font-size: 0.95rem; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(15, 23, 42, 0.5);
}

/* Navigasi bawah untuk karyawan di layar kecil. */
.bottom-nav { display: none; }

@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.is-open { transform: translateX(0); }
    .topbar { display: flex; }
    .page { padding: 20px 16px 32px; }
    .page-title { font-size: 1.35rem; }
}

@media (min-width: 1025px) {
    .sidebar-backdrop { display: none !important; }
}

@media (max-width: 640px) {
    body.has-bottom-nav .page { padding-bottom: 96px; }
    .bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 30;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(8px);
        border-top: 1px solid var(--border);
    }
    .bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        min-height: 52px;
        padding: 6px 4px;
        border-radius: 10px;
        color: var(--muted);
        font-size: 0.72rem;
        font-weight: 600;
    }
    .bottom-nav a svg { width: 22px; height: 22px; }
    .bottom-nav a:hover { text-decoration: none; }
    .bottom-nav a.is-active { color: var(--primary); background: var(--primary-50); }
    .page-actions { width: 100%; }
    .page-actions > .btn { flex: 1; }
}

/* ---------- Kartu ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
}
.card + .card, .card + .grid, .grid + .card, .stats + .card, .stats + .grid, .alert + .card { margin-top: 20px; }

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.card-title { font-size: 1.05rem; font-weight: 700; }
.card-subtitle { margin-top: 2px; color: var(--muted); font-size: 0.88rem; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush > .card-header { padding: 20px 24px 0; }
.card-flush > .card-footer { padding: 0 24px 20px; }
.card-section + .card-section { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--border); }

@media (max-width: 640px) {
    .card { padding: 18px 16px; border-radius: 14px; }
    .card-flush { padding: 0; }
    .card-flush > .card-header { padding: 16px 16px 0; }
    .card-flush > .card-footer { padding: 0 16px 16px; }
}

/* ---------- Grid & utilitas ---------- */

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main-aside { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; }

@media (max-width: 960px) {
    .grid-2, .grid-3, .grid-main-aside { grid-template-columns: 1fr; }
}

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.text-muted { color: var(--muted); }
.text-subtle { color: var(--subtle); }
.text-sm { font-size: 0.86rem; }
.text-xs { font-size: 0.76rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.text-success { color: var(--success-text); }
.text-warning { color: var(--warning-text); }
.text-danger { color: var(--danger-text); }
.text-primary { color: var(--primary); }

/* ---------- Tombol ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    font-size: 0.92rem;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    text-decoration: none;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { background: var(--primary-hover); text-decoration: none; }
.btn:focus-visible { box-shadow: var(--focus-ring); }
.btn:disabled, .btn.is-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-secondary { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--subtle); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }

.btn-soft { background: var(--primary-50); color: var(--primary-700); }
.btn-soft:hover { background: var(--primary-100); }

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

.btn-danger-soft { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.btn-danger-soft:hover { background: #fee2e2; }

.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 0.84rem; border-radius: 8px; }
.btn-sm svg { width: 16px; height: 16px; }
.btn-lg { min-height: 48px; padding: 12px 20px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }

.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-top-color: #fff;
    border-radius: 999px;
    animation: spin 0.7s linear infinite;
}
.btn-secondary.is-loading::after { border-color: rgba(15, 23, 42, 0.2); border-top-color: var(--text); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Alert ---------- */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
    padding: 12px 14px;
    border: 1px solid;
    border-radius: var(--radius);
    font-size: 0.92rem;
}
.alert > svg { width: 20px; height: 20px; margin-top: 1px; }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: 700; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.alert-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.alert-error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
.alert-warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text); }
.alert-info { background: var(--primary-50); border-color: var(--primary-100); color: var(--primary-700); }

.alert-close {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    margin: -4px -4px -4px 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    opacity: 0.7;
    cursor: pointer;
}
.alert-close:hover { opacity: 1; background: rgba(15, 23, 42, 0.06); }
.alert-close svg { width: 16px; height: 16px; }

/* ---------- Badge ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
    background: var(--surface-3);
    color: var(--text-2);
}
.badge-dot::before { content: ''; width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.badge-success { background: #dcfce7; color: var(--success-text); }
.badge-warning { background: #fef3c7; color: var(--warning-text); }
.badge-danger { background: #fee2e2; color: var(--danger-text); }
.badge-info { background: var(--primary-100); color: var(--primary-700); }
.badge-violet { background: #ede9fe; color: var(--violet-text); }
.badge-lg { padding: 6px 14px; font-size: 0.88rem; }

/* ---------- Form ---------- */

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .field-full { grid-column: 1 / -1; }

@media (max-width: 960px) {
    .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .form-grid, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: 1fr; }
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field + .field { margin-top: 16px; }
.form-grid > .field + .field { margin-top: 0; }

.label { font-size: 0.86rem; font-weight: 600; color: var(--text-2); }
.label .optional { font-weight: 400; color: var(--muted); }
.label .required { color: var(--danger); }

.input {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--surface);
    font-size: 0.95rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input::placeholder { color: var(--subtle); }
.input:hover { border-color: var(--subtle); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }
.input:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
.input[readonly] { background: var(--surface-2); }
.input.is-invalid, .input[aria-invalid="true"] { border-color: var(--danger); }
.input.is-invalid:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2); }
textarea.input { min-height: 96px; resize: vertical; }
select.input {
    appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
input[type="file"].input { padding: 7px 8px; }
input[type="file"].input::file-selector-button {
    margin-right: 12px;
    padding: 6px 12px;
    border: 0;
    border-radius: 8px;
    background: var(--primary-50);
    color: var(--primary-700);
    font-weight: 600;
    cursor: pointer;
}

.help { font-size: 0.82rem; color: var(--muted); }
.field-error { font-size: 0.82rem; color: var(--danger-text); font-weight: 500; }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 24px; }

@media (max-width: 640px) {
    .form-actions > .btn { flex: 1; }
}

.input-group { display: flex; gap: 8px; }
.input-group > .input { flex: 1; }

/* Kotak informasi read-only (mis. jadwal hari ini). */
.info-box {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
}

/* Pilihan segmented (radio sebagai tombol). */
.segmented { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.segmented label {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 10px 14px;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}
.segmented label svg { width: 18px; height: 18px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { border-color: var(--primary); background: var(--primary-50); color: var(--primary-700); }
.segmented label:has(input:focus-visible) { box-shadow: var(--focus-ring); }
.segmented label:has(input:disabled) { opacity: 0.45; cursor: not-allowed; background: var(--surface-3); }

/* ---------- Filter / toolbar ---------- */

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    align-items: end;
    margin-bottom: 20px;
}
.filters .field + .field { margin-top: 0; }
.filters-actions { display: flex; gap: 8px; }
.filters-actions .btn { flex: 1; }

.searchbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.searchbar .input { flex: 1 1 220px; width: auto; }
.searchbar .input-date { flex: 0 1 180px; }
.searchbar select.input { flex: 0 1 180px; }

@media (max-width: 640px) {
    .searchbar > * { flex: 1 1 100% !important; }
}

/* ---------- Tabel ---------- */

.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.card-flush > .table-wrap { border-top: 1px solid var(--border); margin-top: 16px; }

.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th, .table td { padding: 12px 16px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table thead th {
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbfd; }
.table td.actions { white-space: nowrap; text-align: right; }
.table td.actions .row { justify-content: flex-end; flex-wrap: nowrap; }
.table .cell-sub { display: block; margin-top: 2px; color: var(--muted); font-size: 0.8rem; }
.table tr.is-muted td { color: var(--muted); }

/* Tabel bergaya kartu di layar kecil: tiap baris jadi kartu dengan label kolom. */
@media (max-width: 720px) {
    .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
    .table-stack tbody tr:last-child { border-bottom: 0; }
    .table-stack td { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 6px 0; border: 0; text-align: right; }
    .table-stack td::before { content: attr(data-label); flex-shrink: 0; color: var(--muted); font-size: 0.78rem; font-weight: 600; text-align: left; padding-top: 1px; }
    .table-stack td[data-label=""]::before, .table-stack td:not([data-label])::before { content: none; }
    .table-stack td.cell-primary { justify-content: flex-start; text-align: left; font-size: 0.98rem; padding-bottom: 8px; }
    .table-stack td.cell-primary::before { content: none; }
    .table-stack td.actions { justify-content: flex-end; padding-top: 10px; }
    .table-stack td.actions::before { content: none; }
    .table-stack td.empty-cell { justify-content: center; text-align: center; }
    .table-stack td.empty-cell::before { content: none; }
    .table-stack tbody tr:hover td { background: transparent; }
}

/* Tabel matriks laporan bulanan (kolom per tanggal). */
.table-matrix { font-size: 0.84rem; }
.table-matrix th, .table-matrix td { padding: 8px 6px; text-align: center; border-right: 1px solid var(--border); }
.table-matrix th:last-child, .table-matrix td:last-child { border-right: 0; }
.table-matrix thead th { padding: 10px 6px; }
.table-matrix .col-name {
    position: sticky;
    left: 0;
    z-index: 2;
    min-width: 180px;
    max-width: 220px;
    padding: 8px 16px;
    text-align: left;
    background: var(--surface);
    box-shadow: 1px 0 0 var(--border);
}
.table-matrix thead .col-name { z-index: 3; background: var(--surface-2); }
.table-matrix tbody tr:hover .col-name { background: #fafbfd; }
.table-matrix .is-weekend { background: #fafafa; }
.table-matrix thead th.is-today { background: var(--primary-100); color: var(--primary-700); }
.table-matrix .col-total { min-width: 110px; font-weight: 700; }

.day-badge {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 700;
    background: transparent;
    color: var(--subtle);
}
.day-badge.code-H { background: #dcfce7; color: var(--success-text); }
.day-badge.code-I, .day-badge.code-E { background: #fef3c7; color: var(--warning-text); }
.day-badge.code-A { background: #fee2e2; color: var(--danger-text); }
.day-badge.code-C { background: #ede9fe; color: var(--violet-text); }
.day-badge.code-O { background: var(--surface-3); color: var(--text-2); }

.legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 18px;
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    font-size: 0.84rem;
    color: var(--muted);
}
.legend strong { color: var(--text); }
.legend-item { display: inline-flex; align-items: center; gap: 8px; }
.legend .day-badge { width: 24px; height: 24px; }

/* ---------- Statistik ---------- */

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stats.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .stats, .stats.cols-3 { grid-template-columns: 1fr 1fr; gap: 12px; } }

.stat {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.stat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat-label { color: var(--muted); font-size: 0.84rem; font-weight: 600; }
.stat-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--primary-50); color: var(--primary); }
.stat-icon svg { width: 18px; height: 18px; }
.stat-icon.is-success { background: var(--success-bg); color: var(--success); }
.stat-icon.is-warning { background: var(--warning-bg); color: var(--warning); }
.stat-icon.is-danger { background: var(--danger-bg); color: var(--danger); }
.stat-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-meta { color: var(--muted); font-size: 0.8rem; }

@media (max-width: 480px) {
    .stat { padding: 14px; }
    .stat-value { font-size: 1.4rem; }
    .stat-icon { display: none; }
}

.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.progress.is-success > span { background: var(--success); }
.progress.is-warning > span { background: var(--warning); }
.progress.is-danger > span { background: var(--danger); }

/* ---------- Status hari ini (halaman presensi) ---------- */

.hero-status {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.hero-status-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; flex-shrink: 0; }
.hero-status-icon svg { width: 24px; height: 24px; }
.hero-status.is-success .hero-status-icon { background: var(--success-bg); color: var(--success); }
.hero-status.is-warning .hero-status-icon { background: var(--warning-bg); color: var(--warning); }
.hero-status.is-danger .hero-status-icon { background: var(--danger-bg); color: var(--danger); }
.hero-status-title { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hero-status-text { margin-top: 4px; color: var(--muted); font-size: 0.9rem; }

@media (max-width: 640px) {
    .hero-status { align-items: flex-start; padding: 16px; }
    .hero-status-icon { width: 40px; height: 40px; }
}

.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 4px; }
.step { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.step svg { width: 16px; height: 16px; }
.step.is-done { background: var(--success-bg); color: var(--success-text); }

.timer { font-size: 2.25rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--primary); }
.timer.is-over { color: var(--danger); }

.location-status { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius); border: 1px dashed var(--border-strong); background: var(--surface-2); font-size: 0.9rem; }
.location-status svg { width: 20px; height: 20px; color: var(--muted); }
.location-status.is-ready { border-style: solid; border-color: var(--success-border); background: var(--success-bg); color: var(--success-text); }
.location-status.is-ready svg { color: var(--success); }
.location-status.is-error { border-style: solid; border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger-text); }
.location-status.is-error svg { color: var(--danger); }
.location-status .coords { display: block; font-size: 0.78rem; opacity: 0.85; font-variant-numeric: tabular-nums; }

.photo-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 150px;
    padding: 20px;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--muted);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}
.photo-drop:hover { border-color: var(--primary); background: var(--primary-50); }
.photo-drop svg { width: 28px; height: 28px; color: var(--primary); }
.photo-drop strong { color: var(--text); }
.photo-drop:has(input:focus-visible) { box-shadow: var(--focus-ring); }
.photo-drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.photo-preview { width: 100%; max-height: 260px; object-fit: cover; border-radius: 10px; }

/* ---------- Daftar ringkas ---------- */

.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; padding-bottom: 0; }
.list-item:first-child { padding-top: 0; }
.list-title { font-weight: 600; }
.list-meta { color: var(--muted); font-size: 0.82rem; }

.dl { display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; margin: 0; }
.dl dt { font-weight: 600; color: var(--text-2); }
.dl dd { margin: 0; }

/* ---------- Empty state ---------- */

.empty-state { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty-state svg { width: 40px; height: 40px; margin: 0 auto 12px; color: var(--subtle); }
.empty-state-title { color: var(--text); font-weight: 600; margin-bottom: 4px; }

/* ---------- Pagination ---------- */

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding-top: 16px;
    margin-top: 4px;
    border-top: 1px solid var(--border);
}
.card-flush > .pagination { margin: 0; padding: 14px 24px; }
.pagination-info { color: var(--muted); font-size: 0.86rem; }
.pagination-links { display: flex; gap: 8px; }

@media (max-width: 640px) {
    .card-flush > .pagination { padding: 12px 16px; }
    .pagination { justify-content: center; }
    .pagination-info { width: 100%; text-align: center; }
}

/* ---------- Modal (dialog) ---------- */

.modal {
    width: min(640px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    padding: 0;
    border: 0;
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
}
.modal::backdrop { background: rgba(15, 23, 42, 0.55); }
.modal-sm { width: min(440px, calc(100vw - 32px)); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 24px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 1.05rem; font-weight: 700; }
.modal-body { padding: 20px 24px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface-2); }

@media (max-width: 640px) {
    .modal-header, .modal-body, .modal-footer { padding-left: 16px; padding-right: 16px; }
    .modal-footer > .btn { flex: 1; }
}

.modal-photo { width: min(860px, calc(100vw - 32px)); background: #0b1220; color: #fff; }
.modal-photo .modal-header { border-color: rgba(255, 255, 255, 0.1); }
.modal-photo .modal-title { color: #fff; font-size: 0.95rem; font-weight: 600; }
.modal-photo .btn-ghost { color: #e2e8f0; }
.modal-photo .btn-ghost:hover { background: rgba(255, 255, 255, 0.1); }
.modal-photo img { width: 100%; max-height: calc(100vh - 140px); object-fit: contain; background: #000; }

/* ---------- Combobox (pencarian pilihan) ---------- */

.combobox { position: relative; }
.combobox-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 20;
    max-height: 240px;
    margin: 0;
    padding: 4px;
    list-style: none;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
}
.combobox-option { padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 0.92rem; }
.combobox-option:hover, .combobox-option.is-active { background: var(--primary-50); color: var(--primary-700); }
.combobox-empty { padding: 8px 10px; color: var(--muted); font-size: 0.88rem; }

/* ---------- Baris entri jadwal ---------- */

.entry-list { display: flex; flex-direction: column; gap: 12px; }
.entry {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.8fr) minmax(0, 1fr) minmax(0, 0.9fr) minmax(0, 1.3fr) auto;
    gap: 12px;
    align-items: end;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
}
.entry .field + .field { margin-top: 0; }
.entry-index { display: none; }

@media (max-width: 1200px) {
    .entry { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .entry-remove { grid-column: 1 / -1; justify-self: end; }
}
@media (max-width: 640px) {
    .entry { grid-template-columns: 1fr; }
    .entry-index { display: block; font-weight: 700; font-size: 0.85rem; color: var(--muted); }
    .entry-remove { justify-self: stretch; }
    .entry-remove .btn { width: 100%; }
}

/* ---------- Peta ---------- */

.map { height: 340px; border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; z-index: 0; }
@media (max-width: 640px) { .map { height: 280px; } }

/* ---------- Foto ---------- */

.thumb {
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface-3);
    cursor: zoom-in;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Halaman tamu (login) ---------- */

.auth {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.auth-aside {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 48px;
    background: radial-gradient(120% 120% at 0% 0%, #1e3a8a 0%, #0b1220 60%);
    color: #e2e8f0;
    overflow: hidden;
}
.auth-aside h2 { color: #fff; font-size: 2rem; letter-spacing: -0.02em; max-width: 420px; }
.auth-aside p { margin-top: 12px; color: #94a3b8; max-width: 420px; }
.auth-features { display: grid; gap: 14px; margin-top: 32px; }
.auth-feature { display: flex; align-items: center; gap: 12px; color: #cbd5e1; }
.auth-feature svg { width: 20px; height: 20px; color: #60a5fa; }
.auth-main { display: grid; place-items: center; padding: 32px 20px; background: var(--surface); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .page-title { font-size: 1.6rem; }

.password-field { position: relative; }
.password-field .input { padding-right: 46px; }
.password-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.password-toggle:hover { color: var(--text); background: var(--surface-3); }
.password-toggle svg { width: 18px; height: 18px; }

.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--text-2); cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--primary); }

@media (max-width: 900px) {
    .auth { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
}
