:root {
    --primary: #006c49;
    --primary-dark: #003d2a;
    --primary-mid: #0d8f63;
    --primary-soft: #e7fff4;
    --primary-light: #79ffc4;
    --emerald: #0f9f6e;
    --paper: #f6fbf8;
    --white: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --soft-muted: #94a3b8;
    --line: rgba(15, 23, 42, .08);
    --line-strong: rgba(226, 232, 240, .82);
    --gold: #d4af37;
    --danger: #e11d48;
    --warning: #c2410c;
    --blue: #2563eb;
    --purple: #7c3aed;
    --shadow: 0 24px 70px rgba(0, 76, 52, .16);
    --shadow-soft: 0 14px 35px rgba(15, 23, 42, .08);
    --radius: 30px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--paper);
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--paper);
    overflow-x: hidden;
}

.app-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(circle at top left, rgba(0, 108, 73, .18), transparent 32rem),
        radial-gradient(circle at bottom right, rgba(15, 159, 110, .14), transparent 28rem),
        linear-gradient(135deg, #f9fffc 0%, #f2fbf7 52%, #ffffff 100%);
}

.app-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    opacity: .72;
    background-image: radial-gradient(rgba(0, 108, 73, .11) 1px, transparent 1px);
    background-size: 22px 22px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .75), rgba(0, 0, 0, .08));
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

img {
    max-width: 100%;
}

a {
    color: var(--primary);
    font-weight: 800;
}

.hidden {
    display: none !important;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(226, 232, 240, .55);
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 108, 73, .25);
    border-radius: 999px;
}

.login-screen {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(320px, 460px);
    gap: clamp(24px, 5vw, 72px);
    align-items: center;
    padding: clamp(22px, 5vw, 72px);
    position: relative;
}

.login-brand {
    max-width: 680px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.login-logo-full {
    width: min(310px, 74vw);
    display: block;
    border-radius: 28px;
    background: rgba(255, 255, 255, .94);
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, .72);
    box-shadow: var(--shadow);
}

.login-brand h1 {
    margin: 24px 0 8px;
    font-family: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
    font-size: clamp(3.1rem, 7vw, 6.2rem);
    font-weight: 900;
    line-height: .95;
    letter-spacing: -.055em;
    color: var(--text);
}

.login-brand p:not(.eyebrow) {
    max-width: 620px;
    margin: 0 0 18px;
    color: #334155;
    font-size: clamp(1.05rem, 2vw, 1.25rem);
    font-weight: 700;
    line-height: 1.55;
}

.login-brand strong {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    max-width: 620px;
    padding: 16px 18px;
    border: 1px solid rgba(0, 108, 73, .13);
    border-radius: 24px;
    color: var(--primary-dark);
    background: rgba(255, 255, 255, .82);
    box-shadow: var(--shadow-soft);
}

.login-brand strong::before {
    content: "";
    width: 10px;
    height: 40px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--primary-light), var(--primary));
}

.brand-logo-icon,
.topbar-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 15px;
    background: #fff;
    border: 1px solid rgba(255, 255, 255, .62);
    padding: 4px;
    box-shadow: 0 10px 25px rgba(0, 76, 52, .14);
}

.topbar-logo {
    flex: 0 0 auto;
}

.login-card,
.card,
.toolbar,
.scanner-panel,
.modal-box {
    position: relative;
    border: 1px solid rgba(226, 232, 240, .78);
    border-radius: 36px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 22px 60px rgba(15, 23, 42, .08);
}

.login-card {
    display: grid;
    gap: 20px;
    padding: clamp(26px, 4vw, 38px);
    overflow: hidden;
}

.login-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 128px;
    background:
        radial-gradient(circle at 20% 15%, rgba(121, 255, 196, .34), transparent 28%),
        linear-gradient(145deg, var(--primary), var(--primary-dark) 78%);
}

.login-card > * {
    position: relative;
    z-index: 1;
}

.login-card h2,
.section-title h2 {
    margin: 0;
    line-height: 1.12;
    color: var(--text);
    font-family: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
    font-weight: 900;
    letter-spacing: -.045em;
}

.login-card h2 {
    color: #fff;
    font-size: 1.72rem;
    max-width: 320px;
}

.login-card .eyebrow {
    color: rgba(255, 255, 255, .78);
}

.eyebrow {
    margin: 0 0 7px;
    color: var(--primary);
    font-size: .68rem;
    font-weight: 900;
    letter-spacing: .18em;
    text-transform: uppercase;
}

label {
    display: grid;
    gap: 8px;
    color: #334155;
    font-size: .76rem;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
}

input,
select,
textarea {
    width: 100%;
    min-height: 50px;
    border: 1px solid #e2e8f0;
    border-radius: 22px;
    padding: 13px 16px;
    color: var(--text);
    background: #f8fafc;
    outline: none;
    font-weight: 800;
    transition: .2s ease;
}

select option {
    color: var(--text);
    background: #fff;
}

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

input::placeholder,
textarea::placeholder {
    color: #94a3b8;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(0, 108, 73, .55);
    box-shadow: 0 0 0 5px rgba(0, 108, 73, .09);
    background: #fff;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 292px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 0;
    color: #fff;
    background:
        radial-gradient(circle at 20% 15%, rgba(121, 255, 196, .34), transparent 28%),
        linear-gradient(145deg, var(--primary), var(--primary-dark) 78%);
    overflow-y: auto;
    box-shadow: 0 24px 70px rgba(0, 76, 52, .22);
}

.sidebar-head {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 28px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, .13);
}

.sidebar-head strong {
    display: block;
    color: #fff;
    font-size: 1.17rem;
    font-weight: 900;
    letter-spacing: -.035em;
}

.sidebar-head span {
    display: block;
    margin-top: 3px;
    color: rgba(255, 255, 255, .7);
    font-size: .78rem;
    font-weight: 800;
}

.nav-list {
    display: grid;
    gap: 8px;
    padding: 18px 14px;
}

.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 11px;
    border: 1px solid transparent;
    border-radius: 20px;
    padding: 13px 14px;
    color: rgba(255, 255, 255, .76);
    background: transparent;
    text-align: left;
    font-weight: 900;
    transition: .2s ease;
}

.nav-item svg,
.btn svg,
.icon-btn svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

.nav-item.active,
.nav-item:hover {
    color: #fff;
    background: rgba(255, 255, 255, .13);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .10);
}

.main {
    min-width: 0;
    display: grid;
    grid-template-rows: auto 1fr;
    height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 17px 22px;
    background: rgba(255, 255, 255, .78);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(226, 232, 240, .72);
}

.topbar > div:first-of-type {
    flex: 1;
}

.topbar h1 {
    margin: 0;
    color: var(--text);
    font-size: clamp(1.35rem, 2vw, 2rem);
    font-weight: 900;
    letter-spacing: -.05em;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-badge {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid rgba(0, 108, 73, .15);
    color: var(--primary);
    background: var(--primary-soft);
    font-size: .82rem;
    font-weight: 900;
    white-space: nowrap;
}

.page-content {
    min-width: 0;
    overflow-y: auto;
    padding: 24px;
}

.grid {
    display: grid;
    gap: 16px;
}

.grid.stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card {
    padding: 20px;
    overflow: hidden;
}

.card h3 {
    margin: 0 0 12px;
    color: var(--text);
    font-size: 1.12rem;
    font-weight: 900;
    letter-spacing: -.035em;
}

.stat-card {
    position: relative;
    overflow: hidden;
    min-height: 126px;
    display: grid;
    gap: 10px;
    align-content: start;
    padding: 22px;
    border-radius: 30px;
    background: rgba(255, 255, 255, .94);
    border: 1px solid rgba(226, 232, 240, .78);
    box-shadow: 0 14px 38px rgba(15, 23, 42, .07);
}

.stat-card::after {
    content: "";
    position: absolute;
    width: 115px;
    height: 115px;
    border-radius: 999px;
    right: -46px;
    top: -52px;
    background: rgba(0, 108, 73, .08);
}

.stat-card:nth-child(3n + 1) {
    background:
        radial-gradient(circle at 15% 15%, rgba(121, 255, 196, .48), transparent 35%),
        linear-gradient(145deg, #0c8b60, #00543a 72%);
    color: #fff;
    box-shadow: 0 22px 48px rgba(0, 108, 73, .24);
    border-color: rgba(255, 255, 255, .20);
}

.stat-card span {
    position: relative;
    z-index: 1;
    color: var(--soft-muted);
    font-size: .68rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.stat-card:nth-child(3n + 1) span {
    color: rgba(255, 255, 255, .72);
}

.stat-card strong {
    position: relative;
    z-index: 1;
    display: block;
    max-width: 100%;
    color: var(--text);
    font-size: clamp(1.45rem, 2vw, 1.9rem);
    font-weight: 900;
    line-height: 1.12;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.stat-card:nth-child(3n + 1) strong {
    color: #fff;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.section-title p {
    margin: 6px 0 0;
    color: var(--muted);
    font-weight: 700;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.toolbar label {
    min-width: 170px;
    flex: 1;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.btn,
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 18px;
    min-height: 42px;
    padding: 10px 15px;
    font-weight: 900;
    text-decoration: none;
    transition: .2s ease;
    box-shadow: 0 8px 22px rgba(15, 23, 42, .06);
}

.btn.primary {
    color: #fff;
    background: linear-gradient(145deg, var(--emerald), var(--primary));
    box-shadow: 0 12px 24px rgba(0, 108, 73, .22);
}

.btn.primary:hover {
    background: linear-gradient(145deg, var(--primary), var(--primary-dark));
    transform: translateY(-1px);
}

.btn.secondary {
    color: var(--primary);
    background: var(--primary-soft);
    border-color: rgba(0, 108, 73, .12);
}

.btn.warn {
    color: #fff;
    background: linear-gradient(145deg, #f59e0b, #c2410c);
}

.btn.danger {
    color: #fff;
    background: linear-gradient(145deg, #fb7185, #e11d48);
}

.btn.ghost,
.icon-btn {
    color: var(--primary-dark);
    background: #fff;
    border-color: rgba(226, 232, 240, .9);
}

.btn.ghost:hover,
.icon-btn:hover,
.btn.secondary:hover {
    color: #fff;
    background: var(--primary);
}

.btn.wide {
    width: 100%;
}

.icon-btn {
    width: 42px;
    padding: 0;
}

#menuToggle {
    display: none;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

th,
td {
    padding: 14px 12px;
    border-bottom: 1px solid #f1f5f9;
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--soft-muted);
    background: #f8fafc;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 900;
}

td {
    color: #334155;
    font-weight: 700;
}

td strong {
    color: var(--text);
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 27px;
    border-radius: 999px;
    padding: 5px 11px;
    font-size: .68rem;
    font-weight: 900;
    white-space: nowrap;
}

.badge.hadir,
.badge.hadir_tepat_waktu,
.badge.pulang,
.badge.aktif {
    color: var(--primary);
    background: var(--primary-soft);
}

.badge.terlambat,
.badge.pulang_lebih_awal,
.badge.belum_scan_pulang {
    color: #c2410c;
    background: #fff7ed;
}

.badge.izin {
    color: #2563eb;
    background: #eff6ff;
}

.badge.sakit {
    color: #7c3aed;
    background: #f5f3ff;
}

.badge.alfa,
.badge.nonaktif {
    color: #e11d48;
    background: #fff1f2;
}

.scanner-layout {
    display: grid;
    grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
    gap: 18px;
}

.scanner-panel {
    padding: 18px;
}

#qrReader {
    min-height: 320px;
    border-radius: 26px;
    overflow: hidden;
    background: #e7fff4;
    border: 1px solid rgba(0, 108, 73, .14);
}

.gate-display {
    min-height: 520px;
    display: grid;
    place-items: center;
    padding: clamp(20px, 4vw, 46px);
    border-radius: 36px;
    color: #fff;
    background:
        radial-gradient(circle at 15% 15%, rgba(121, 255, 196, .48), transparent 35%),
        linear-gradient(145deg, #0c8b60, #00543a 72%);
    box-shadow: 0 22px 48px rgba(0, 108, 73, .24);
}

.gate-card {
    width: min(100%, 780px);
    text-align: center;
}

.gate-card .welcome {
    margin: 0;
    color: rgba(255, 255, 255, .82);
    font-size: clamp(1.2rem, 4vw, 2.5rem);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.gate-card h2 {
    margin: 12px 0;
    font-size: clamp(2.35rem, 8vw, 5.4rem);
    line-height: 1;
    font-weight: 900;
    letter-spacing: -.06em;
    overflow-wrap: anywhere;
}

.gate-card .gate-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 18px;
}

.gate-meta span {
    min-width: 130px;
    border: 1px solid rgba(255, 255, 255, .20);
    border-radius: 22px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, .12);
    font-weight: 900;
}

.evidence {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 26px;
    border: 4px solid rgba(255, 255, 255, .35);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.form-grid .full {
    grid-column: 1 / -1;
}

.modal {
    width: min(780px, calc(100vw - 30px));
    border: 0;
    background: transparent;
    color: var(--text);
}

.modal::backdrop {
    background: rgba(0, 61, 42, .78);
    backdrop-filter: blur(8px);
}

.modal-box {
    position: relative;
    padding: 26px;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 80;
    max-width: 380px;
    padding: 14px 17px;
    border-radius: 22px;
    color: #fff;
    background: var(--primary);
    box-shadow: var(--shadow);
    transform: translateY(120%);
    opacity: 0;
    transition: .2s ease;
    font-weight: 800;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

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

.small {
    font-size: .82rem;
}

.print-letterhead {
    display: none;
}

.qr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 14px;
}

.student-card {
    min-height: 330px;
    display: grid;
    gap: 10px;
    justify-items: center;
    align-content: start;
    padding: 16px;
    border: 1px solid rgba(226, 232, 240, .78);
    border-radius: 30px;
    background: #fff;
    color: var(--text);
    box-shadow: 0 14px 36px rgba(15, 23, 42, .08);
}

.student-card .card-logo-full {
    width: 142px;
    height: 92px;
    object-fit: contain;
    border-radius: 20px;
    background: #fff;
}

.student-card .logo-ring {
    width: 50px;
    height: 50px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    color: #fff;
    background: var(--primary);
    font-weight: 900;
}

.student-card h3 {
    margin: 0;
    text-align: center;
    font-size: 1.05rem;
    font-weight: 900;
}

.student-card p {
    margin: 0;
    color: var(--muted);
    font-weight: 800;
}

.photo-thumb {
    width: 62px;
    height: 62px;
    border-radius: 18px;
    object-fit: cover;
    border: 1px solid var(--line-strong);
}

.bottom-nav {
    display: none;
}

canvas {
    max-width: 100%;
}

@media (max-width: 1080px) {
    .grid.stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .scanner-layout,
    .grid.two,
    .grid.three {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 860px) {
    .login-screen {
        grid-template-columns: 1fr;
        align-content: center;
        text-align: center;
    }

    .login-brand {
        align-items: center;
    }

    .app-shell {
        grid-template-columns: 1fr;
        padding-bottom: 100px;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 60;
        width: min(84vw, 310px);
        transform: translateX(-105%);
        transition: transform .28s cubic-bezier(.4, 0, .2, 1);
    }

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

    #menuToggle {
        display: inline-flex;
    }

    .topbar {
        align-items: flex-start;
        padding: 13px 14px;
    }

    .topbar-actions {
        align-items: flex-end;
        flex-direction: column;
    }

    .user-badge {
        max-width: 210px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .page-content {
        padding: 14px;
    }

    .bottom-nav {
        position: fixed;
        left: 14px;
        right: 14px;
        bottom: 12px;
        z-index: 55;
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        min-height: 78px;
        border: 1px solid rgba(255, 255, 255, .72);
        border-radius: 28px;
        background: rgba(255, 255, 255, .92);
        backdrop-filter: blur(18px);
        box-shadow: 0 18px 45px rgba(15, 23, 42, .18);
        overflow: hidden;
    }

    .bottom-nav .nav-item {
        min-height: 72px;
        justify-content: center;
        flex-direction: column;
        gap: 4px;
        border-radius: 22px;
        color: var(--muted);
        font-size: .68rem;
        padding: 6px;
    }

    .bottom-nav .nav-item.active {
        color: #fff;
        background: linear-gradient(145deg, var(--emerald), var(--primary));
        box-shadow: 0 12px 24px rgba(0, 108, 73, .22);
    }
}

@media (max-width: 640px) {
    .grid.stats,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .toolbar label {
        min-width: 100%;
    }

    .topbar h1 {
        font-size: 1.25rem;
    }

    .login-brand h1 {
        font-size: 3.1rem;
    }

    .login-card {
        padding: 24px;
    }

    .login-logo-full {
        width: min(260px, 82vw);
    }
}

@media print {
    body {
        background: #fff;
        color: #111;
    }

    .app-bg,
    .sidebar,
    .topbar,
    .toolbar,
    .bottom-nav,
    .btn,
    .icon-btn,
    .toast {
        display: none !important;
    }

    .app-shell,
    .main {
        display: block;
        height: auto;
    }

    .page-content {
        padding: 0;
        overflow: visible;
    }

    .card {
        border: 0;
        box-shadow: none;
        padding: 0;
        background: #fff;
        color: #111;
    }

    th,
    td {
        color: #111;
        border-bottom: 1px solid #ccc;
    }

    th {
        background: #f2f2f2;
    }

    .print-letterhead {
        display: block;
        text-align: center;
        margin-bottom: 18px;
        padding-bottom: 12px;
        border-bottom: 3px double #111;
        color: #111;
    }

    .student-card {
        break-inside: avoid;
        color: var(--text);
        border: 1px solid #ccc;
        box-shadow: none;
    }
}
