:root {
    --primary: #1e5b94;
    --primary-dark: #143f68;
    --bg: #f2f5f8;
    --card: #ffffff;
    --text: #21324a;
    --muted: #6b7a90;
    --danger: #c0392b;
    --success: #1e8449;
    --border: #dfe6ee;
    --radius: 10px;

    /* ---- Token tambahan untuk tampilan "app" (dashboard) ---- */
    --app-grad-1: #4338ca;
    --app-grad-2: #3b82f6;
    --app-navy: #101a34;
    --app-radius-lg: 22px;
    --app-radius-md: 16px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(20, 63, 104, 0.12);
    width: 100%;
    max-width: 440px;
    padding: 32px 28px;
}

.login-header { text-align: center; margin-bottom: 20px; }
.login-header h1 { font-size: 20px; margin: 8px 0 2px; color: var(--primary-dark); }
.login-header p { color: var(--muted); font-size: 13px; margin: 0; }

.tab-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

.tab-btn {
    border: none;
    background: transparent;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
}

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

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.form-group { margin-bottom: 14px; }
label { display: block; font-size: 13px; margin-bottom: 5px; color: var(--text); font-weight: 600; }

input[type="text"], input[type="password"], input[type="date"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
}

input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }

.captcha-row { display: flex; align-items: center; gap: 10px; }
.captcha-box {
    background: #eef3f8;
    border: 1px dashed var(--border);
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--primary-dark);
}

.btn-submit {
    width: 100%;
    padding: 11px;
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 6px;
}

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

.alert {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-error { background: #fdecea; color: var(--danger); border: 1px solid #f5c6c0; }
.alert-success { background: #e9f7ef; color: var(--success); border: 1px solid #b7e4c7; }

.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---- Dashboard sederhana (dipakai halaman non-app / fallback) ---- */
.topbar {
    background: var(--primary);
    color: #fff;
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.topbar a { color: #fff; text-decoration: none; font-size: 13px; background: rgba(255,255,255,.15); padding: 6px 12px; border-radius: 6px; }
.main-content { padding: 28px; max-width: 960px; margin: 0 auto; }
.role-badge {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    margin-bottom: 12px;
}
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; text-align: left; }
th { background: #eef3f8; }
.btn-small { font-size: 12px; padding: 5px 10px; border-radius: 6px; border: none; cursor: pointer; }
.btn-unlock { background: var(--success); color: #fff; }
.btn-toggle { background: #eef3f8; color: var(--text); }

/* =========================================================
   APP SHELL - tampilan ala aplikasi mobile / PWA
   ========================================================= */
.app-body {
    background: var(--bg);
    padding-bottom: calc(78px + var(--safe-bottom));
    min-height: 100vh;
}

.app-topbar {
    background: var(--app-navy);
    color: #fff;
    padding: calc(14px + var(--safe-top)) 18px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.app-topbar-left { display: flex; align-items: center; gap: 12px; }
.app-topbar-avatar {
    width: 40px; height: 40px; border-radius: 12px;
    background: linear-gradient(135deg, var(--app-grad-1), var(--app-grad-2));
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px; color: #fff; flex-shrink: 0;
}
.app-topbar-title { font-size: 15px; font-weight: 700; line-height: 1.2; }
.app-topbar-sub { font-size: 12px; color: #aab3ca; }
.app-topbar-actions { display: flex; align-items: center; gap: 10px; }
.app-icon-btn {
    width: 38px; height: 38px; border-radius: 10px;
    background: rgba(255,255,255,.08);
    display: flex; align-items: center; justify-content: center;
    color: #fff; text-decoration: none; font-size: 16px; position: relative; border: none; cursor: pointer;
}
.app-icon-btn .badge-count {
    position: absolute; top: -5px; right: -5px;
    background: #e03e5c; color: #fff; font-size: 10px; font-weight: 700;
    min-width: 17px; height: 17px; border-radius: 999px;
    display: flex; align-items: center; justify-content: center; padding: 0 3px;
}

.app-wrap { max-width: 480px; margin: 0 auto; padding: 16px; }

/* ---- Hero / kartu profil ---- */
.hero-card {
    background: linear-gradient(135deg, var(--app-grad-1), var(--app-grad-2));
    border-radius: var(--app-radius-lg);
    padding: 20px;
    color: #fff;
    box-shadow: 0 14px 30px rgba(67, 56, 202, .28);
}
.hero-top { display: flex; align-items: center; gap: 14px; }
.hero-avatar {
    width: 58px; height: 58px; border-radius: 16px;
    background: #fff; color: var(--app-grad-1);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 20px; flex-shrink: 0;
}
.hero-greet { font-size: 12px; color: rgba(255,255,255,.8); margin: 0; }
.hero-name { font-size: 19px; font-weight: 800; margin: 2px 0 8px; }
.hero-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.hero-chip {
    background: rgba(255,255,255,.18);
    font-size: 11.5px; font-weight: 600; padding: 4px 10px;
    border-radius: 999px; display: inline-flex; align-items: center; gap: 4px;
}
.hero-qr {
    margin-left: auto; text-align: center; flex-shrink: 0;
    background: rgba(255,255,255,.15); border-radius: 14px; padding: 8px 10px;
    text-decoration: none; color: #fff; font-size: 10px; font-weight: 600;
}
.hero-qr .qr-emoji { font-size: 20px; display: block; margin-bottom: 2px; }
.hero-divider { border: none; border-top: 1px solid rgba(255,255,255,.18); margin: 16px 0; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-chip {
    background: rgba(255,255,255,.14);
    border-radius: 12px; padding: 10px 6px; text-align: center;
}
.stat-chip .stat-label { font-size: 10px; letter-spacing: .04em; color: rgba(255,255,255,.75); text-transform: uppercase; }
.stat-chip .stat-value { font-size: 15px; font-weight: 800; margin-top: 3px; }

/* ---- Kartu putih (menu / ringkasan) ---- */
.app-card {
    background: var(--card);
    border-radius: var(--app-radius-md);
    padding: 16px;
    margin-top: 16px;
    box-shadow: 0 4px 18px rgba(20, 40, 80, .06);
}
.app-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.app-card-title { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 800; color: var(--text); letter-spacing: .01em; }
.app-card-title .dot-icon { color: var(--app-grad-1); font-size: 15px; }
.app-card-link { font-size: 12px; font-weight: 700; color: var(--app-grad-1); text-decoration: none; }

.menu-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 6px; }
.menu-item {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    text-decoration: none; color: var(--text); text-align: center;
    position: relative;
}
.menu-icon {
    width: 52px; height: 52px; border-radius: 15px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; position: relative;
}
.menu-item span { font-size: 11px; font-weight: 600; line-height: 1.2; }
.menu-badge {
    position: absolute; top: -4px; right: 6px;
    background: #f0a53b; color: #fff; font-size: 9.5px; font-weight: 700;
    min-width: 16px; height: 16px; border-radius: 999px;
    display: flex; align-items: center; justify-content: center; padding: 0 3px;
}
.menu-item.is-soon { opacity: .55; }
.menu-item.is-soon .menu-icon { filter: grayscale(35%); }
.menu-soon-tag {
    position: absolute; bottom: -12px; left: 50%; transform: translateX(-50%);
    background: #eef1f6; color: var(--muted); font-size: 8px; font-weight: 700;
    padding: 1px 5px; border-radius: 6px; white-space: nowrap;
}

.icon-indigo { background: #e6e6fd; color: #4338ca; }
.icon-teal   { background: #d9f6ee; color: #0f9b7e; }
.icon-green  { background: #e2f6e5; color: #1e8449; }
.icon-pink   { background: #fbe4f0; color: #c02b7a; }
.icon-purple { background: #efe4fb; color: #7c3aed; }
.icon-red    { background: #fbe3e3; color: #c0392b; }
.icon-amber  { background: #fdf0d8; color: #b6790a; }
.icon-blue   { background: #dcebfd; color: #1e5b94; }

.summary-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.summary-card {
    background: var(--card); border-radius: var(--app-radius-md);
    padding: 14px; box-shadow: 0 4px 18px rgba(20, 40, 80, .06);
}
.summary-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.summary-icon { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.summary-pill { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.summary-pill.good { background: #e2f6e5; color: #1e8449; }
.summary-pill.warn { background: #fdf0d8; color: #b6790a; }
.summary-label { font-size: 11.5px; color: var(--muted); margin: 0; }
.summary-value { font-size: 17px; font-weight: 800; margin: 2px 0 0; }

/* ---- Menu admin/staff (non-siswa) ---- */
.staff-menu-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.staff-menu-item {
    background: var(--card); border-radius: var(--app-radius-md);
    padding: 14px; text-decoration: none; color: var(--text);
    box-shadow: 0 4px 18px rgba(20, 40, 80, .06);
    display: flex; flex-direction: column; gap: 10px; min-height: 88px;
}
.staff-menu-item .menu-icon { width: 40px; height: 40px; border-radius: 12px; font-size: 18px; }
.staff-menu-item strong { font-size: 13px; }
.staff-menu-item small { font-size: 11px; color: var(--muted); }

/* ---- Bottom navigation ---- */
.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: #fff; border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-around;
    padding: 8px 6px calc(8px + var(--safe-bottom));
    box-shadow: 0 -6px 18px rgba(20,40,80,.06);
}
.bottom-nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    text-decoration: none; color: var(--muted); font-size: 10.5px; font-weight: 600;
    padding: 4px 8px;
}
.bottom-nav-item .nav-icon { font-size: 19px; line-height: 1; }
.bottom-nav-item.active { color: var(--app-grad-1); }

@media (min-width: 600px) {
    .app-wrap { padding: 24px; }
}
