/* ============================================================
   NEXA AKADEMIK — gaya cerah ceria khas madrasah
   ============================================================ */
:root {
  --green: #16A34A;
  --green-2: #22C55E;
  --green-dark: #15803D;
  --green-soft: #E8F7EE;
  --yellow: #F59E0B;
  --yellow-2: #FBBF24;
  --yellow-soft: #FEF3C7;
  --sky: #0EA5E9;
  --sky-soft: #E0F2FE;
  --violet: #8B5CF6;
  --violet-soft: #EDE9FE;
  --red: #EF4444;
  --red-soft: #FEE2E2;
  --teal: #14B8A6;
  --teal-soft: #CCFBF1;
  --ink: #1F2937;
  --muted: #6B7280;
  --card: #FFFFFF;
  --line: #E5EFE7;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(22, 101, 52, 0.08);
  --shadow-lg: 0 12px 36px rgba(22, 101, 52, 0.14);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(251,191,36,.22), transparent 60%),
    radial-gradient(800px 500px at -10% 20%, rgba(34,197,94,.16), transparent 60%),
    radial-gradient(700px 500px at 60% 110%, rgba(14,165,233,.14), transparent 60%),
    linear-gradient(160deg, #F7FCF4 0%, #FDFBF1 55%, #F3FBFD 100%);
  background-attachment: fixed;
  min-height: 100vh;
}
a { color: var(--green-dark); text-decoration: none; }
img { max-width: 100%; }
button { font-family: inherit; }

/* ---------- Login ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.login-wrap { width: 100%; max-width: 430px; }
.login-card {
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 24px;
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; align-items: center; gap: 14px; justify-content: center; margin-bottom: 22px; }
.login-logo { width: 62px; height: 62px; border-radius: 18px; object-fit: cover; }
.login-logo-fallback {
  width: 62px; height: 62px; border-radius: 18px;
  background: linear-gradient(135deg, var(--green), var(--green-2));
  color: #fff; font-weight: 800; font-size: 28px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(22,163,74,.35);
}
.login-title { text-align: center; margin: 0 0 4px; font-size: 22px; font-weight: 800; color: var(--green-dark); }
.login-sub { text-align: center; color: var(--muted); font-size: 13.5px; margin: 0 0 24px; }
.login-hint { background: var(--green-soft); border-radius: 12px; padding: 10px 14px; font-size: 12.5px; color: var(--green-dark); margin-top: 18px; line-height: 1.5; }

/* ---------- App layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 264px; flex-shrink: 0;
  background: rgba(255,255,255,.94);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 14px; border-bottom: 1px solid var(--line); }
.brand-logo-img { width: 46px; height: 46px; border-radius: 14px; object-fit: cover; }
.brand-logo {
  width: 46px; height: 46px; border-radius: 14px;
  background: linear-gradient(135deg, var(--green), var(--yellow));
  color: #fff; font-weight: 800; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(22,163,74,.3);
}
.brand-txt b { display: block; font-size: 15px; color: var(--ink); line-height: 1.25; }
.brand-txt span { font-size: 11.5px; color: var(--muted); display: block; margin-top: 2px; }
.nav { padding: 10px 12px 20px; flex: 1; }
.nav-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #9CA3AF; margin: 16px 10px 6px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin: 2px 0;
  border-radius: 12px; color: #374151; font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--green-soft); color: var(--green-dark); }
.nav-link.active { background: linear-gradient(135deg, var(--green), var(--green-2)); color: #fff; box-shadow: 0 4px 12px rgba(22,163,74,.3); }
.nav-ico { font-size: 16px; width: 22px; text-align: center; }
.sidebar-foot { padding: 14px 18px; font-size: 11px; color: #9CA3AF; border-top: 1px solid var(--line); line-height: 1.6; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 24px;
  background: rgba(255,255,255,.8);
  backdrop-filter: blur(14px) saturate(180%);
  border-bottom: 1px solid var(--line);
}
.menu-btn {
  display: none;
  width: 42px; height: 42px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--green-soft); color: var(--green-dark); font-size: 20px;
}
.page-title { font-size: 17px; font-weight: 700; margin: 0; flex: 1; color: var(--ink); }
.page-title small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip .avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--yellow), var(--yellow-2));
  color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.user-chip .uc-name { font-size: 13.5px; font-weight: 600; line-height: 1.2; }
.user-chip .uc-role { font-size: 11.5px; color: var(--muted); }
.role-pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: var(--green-soft); color: var(--green-dark);
  font-size: 11px; font-weight: 600;
}
.content { padding: 24px; max-width: 1280px; width: 100%; margin: 0 auto; flex: 1; }

/* ---------- Flash ---------- */
.flash { border-radius: 14px; padding: 13px 16px; margin-bottom: 18px; font-size: 14px; font-weight: 500; }
/* display:block (bukan flex): pada flash yang isinya teks + <b>/<a>/tombol, flex membuat
   tiap elemen inline jadi item terpisah sehingga teks panjang tidak membungkus rapi dan
   melebar keluar layar di HP (terbukti overflow 36px di 390px). */
.flash.success { background: var(--green-soft); color: var(--green-dark); border: 1px solid #BBE9CD; }
.flash.error { background: var(--red-soft); color: #B91C1C; border: 1px solid #FECACA; }
.flash.info { background: var(--sky-soft); color: #0369A1; border: 1px solid #BAE6FD; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card + .card, .section + .section { margin-top: 0; }
.card-title { margin: 0 0 4px; font-size: 16px; font-weight: 700; color: var(--ink); }
.card-sub { margin: 0 0 16px; font-size: 12.5px; color: var(--muted); }
.section-title { margin: 28px 0 14px; font-size: 15px; font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.section-title .badge { margin-left: auto; }

/* Stat cards */
.grid-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.grid-stats.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-stats.grid-3 { grid-template-columns: repeat(3, 1fr); }
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
  position: relative; overflow: hidden;
}
.stat-card .st-ico {
  width: 46px; height: 46px; border-radius: 14px; font-size: 22px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 12px;
}
.stat-card .st-val { font-size: 30px; font-weight: 800; line-height: 1.1; color: var(--ink); }
.stat-card .st-lbl { font-size: 13px; color: var(--muted); font-weight: 500; margin-top: 4px; }
.stat-card .st-sub { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.c-green { background: var(--green-soft); color: var(--green-dark); }
.c-yellow { background: var(--yellow-soft); color: #B45309; }
.c-sky { background: var(--sky-soft); color: #0369A1; }
.c-violet { background: var(--violet-soft); color: #6D28D9; }
.c-red { background: var(--red-soft); color: #B91C1C; }
.c-teal { background: var(--teal-soft); color: #0F766E; }
.c-orange { background: #FFEDD5; color: #C2410C; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 12px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer;
  background: var(--green-soft); color: var(--green-dark);
  transition: transform .1s, box-shadow .15s, background .15s;
}
.btn:hover { filter: brightness(.98); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, var(--green), var(--green-2)); color: #fff; box-shadow: 0 6px 16px rgba(22,163,74,.3); }
.btn-primary:hover { box-shadow: 0 8px 20px rgba(22,163,74,.4); }
.btn-yellow { background: linear-gradient(135deg, #F59E0B, #FBBF24); color: #fff; box-shadow: 0 6px 16px rgba(245,158,11,.35); }
.btn-sky { background: linear-gradient(135deg, #0284C7, #38BDF8); color: #fff; box-shadow: 0 6px 16px rgba(2,132,199,.3); }
.btn-danger { background: var(--red-soft); color: #B91C1C; }
.btn-danger-solid { background: linear-gradient(135deg, #DC2626, #EF4444); color: #fff; }
.btn-outline { background: #fff; border-color: var(--line); color: #374151; }
.btn-outline:hover { border-color: var(--green-2); color: var(--green-dark); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 10px; }
.btn-lg { padding: 13px 26px; font-size: 15px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #374151; }
.field label .req { color: var(--red); }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.form-control, select.form-control, textarea.form-control, input.form-control {
  width: 100%; padding: 10px 13px;
  border: 1.5px solid #D8E5DB; border-radius: 12px;
  font-size: 14px; font-family: inherit; color: var(--ink);
  background: #FBFEFC; outline: none; transition: border .15s, box-shadow .15s;
}
.form-control:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(34,197,94,.15); background: #fff; }
textarea.form-control { min-height: 90px; resize: vertical; }
input[type="checkbox"].form-check { width: 18px; height: 18px; accent-color: var(--green); }
input[type="date"].form-control, input[type="time"].form-control { min-height: 42px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid var(--line); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; background: #fff; }
.tbl th {
  background: #F3FAF5; color: var(--green-dark); text-align: left;
  padding: 11px 13px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1.5px solid var(--line); white-space: nowrap;
}
.tbl td { padding: 10px 13px; border-bottom: 1px solid #EFF6F1; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #FAFDFB; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .actions { white-space: nowrap; }
.tbl .actions a, .tbl .actions button { margin-right: 6px; }

/* ---------- Badges & status ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.bg-green { background: var(--green-soft); color: var(--green-dark); }
.bg-yellow { background: var(--yellow-soft); color: #B45309; }
.bg-sky { background: var(--sky-soft); color: #0369A1; }
.bg-red { background: var(--red-soft); color: #B91C1C; }
.bg-gray { background: #F3F4F6; color: #4B5563; }
.bg-violet { background: var(--violet-soft); color: #6D28D9; }
.badge-status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.st-h { background: var(--green-soft); color: var(--green-dark); }
.st-t { background: #FFEDD5; color: #C2410C; }
.st-s { background: var(--sky-soft); color: #0369A1; }
.st-i { background: var(--violet-soft); color: #6D28D9; }
.st-a { background: var(--red-soft); color: #B91C1C; }
.st-d { background: var(--teal-soft); color: #0F766E; }
.st-dl { background: #DBEAFE; color: #1D4ED8; }
.st-p { background: #EEF2FF; color: #4338CA; }

/* ---------- Progress bar ---------- */
.progress { height: 10px; background: #E8F3EC; border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--green), var(--green-2)); }
.progress.warn > i { background: linear-gradient(90deg, #F59E0B, #FBBF24); }
.progress.danger > i { background: linear-gradient(90deg, #DC2626, #EF4444); }
.pct-label { font-size: 12px; font-weight: 700; color: var(--green-dark); }

/* ---------- CSS Bar chart ---------- */
.chart { display: flex; align-items: flex-end; gap: 14px; height: 190px; padding: 10px 4px 0; }
.chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart .bar { width: 100%; max-width: 46px; border-radius: 8px 8px 4px 4px; background: linear-gradient(180deg, var(--green-2), var(--green)); min-height: 3px; position: relative; transition: height .3s; }
.chart .bar.yellow { background: linear-gradient(180deg, #FBBF24, #F59E0B); }
.chart .bar.sky { background: linear-gradient(180deg, #38BDF8, #0284C7); }
.chart .bar.red { background: linear-gradient(180deg, #F87171, #DC2626); }
.chart .bar.violet { background: linear-gradient(180deg, #A78BFA, #7C3AED); }
.chart .bar-label { font-size: 11px; color: var(--muted); font-weight: 600; }
.chart .bar-val { font-size: 11px; color: var(--ink); font-weight: 700; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 18px; }
.tab-pill {
  padding: 8px 16px; border-radius: 999px; background: rgba(255,255,255,.8);
  border: 1px solid var(--line); color: #4B5563; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.tab-pill:hover { border-color: var(--green-2); color: var(--green-dark); }
.tab-pill.active { background: linear-gradient(135deg, var(--green), var(--green-2)); color: #fff; border-color: transparent; box-shadow: 0 4px 12px rgba(22,163,74,.3); }

/* ---------- Timeline / list ---------- */
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 11px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.list-plain li:last-child { border-bottom: 0; }

/* ---------- QR ---------- */
.qr-box { text-align: center; padding: 18px; }
.qr-box canvas, .qr-box img { border-radius: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.08); background: #fff; }
.qr-student { margin-top: 12px; font-weight: 700; font-size: 15px; }
.qr-sub { color: var(--muted); font-size: 12.5px; }

/* QR scan area */
.scan-stage { position: relative; background: #0F172A; border-radius: 20px; overflow: hidden; min-height: 320px; display: flex; align-items: center; justify-content: center; }
.scan-stage video { width: 100%; max-height: 480px; object-fit: cover; }
.scan-frame { position: absolute; top: 50%; left: 50%; width: 220px; height: 220px; transform: translate(-50%, -50%); border: 3px solid rgba(255,255,255,.9); border-radius: 18px; box-shadow: 0 0 0 2000px rgba(15,23,42,.55); pointer-events: none; }
.scan-hint { color: #94A3B8; font-size: 14px; text-align: center; padding: 20px; }
.scan-result {
  position: absolute; left: 12px; right: 12px; bottom: 12px;
  background: rgba(255,255,255,.96); border-radius: 16px; padding: 14px 16px;
  box-shadow: var(--shadow-lg); animation: pop .25s ease;
}
@keyframes pop { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.scan-result .sr-name { font-weight: 800; font-size: 16px; color: var(--ink); }
.scan-result .sr-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.scan-result .sr-status { font-weight: 800; margin-top: 8px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.scan-busy { position: absolute; inset: 0; background: rgba(15,23,42,.7); display: none; align-items: center; justify-content: center; color: #fff; font-weight: 600; z-index: 5; }
.scan-busy.show { display: flex; }

/* ---------- Kartu QR (print) ---------- */
.qr-card {
  width: 85.6mm; height: 54mm;
  background: #fff; border: 1.5px solid #CBD5E1; border-radius: 10px;
  padding: 5mm; display: flex; gap: 4mm; align-items: center;
  break-inside: avoid; page-break-inside: avoid;
}
.qr-card .qc-qr { width: 40mm; height: 40mm; display: flex; align-items: center; justify-content: center; }
.qr-card .qc-info { flex: 1; font-size: 3mm; }
.qr-card .qc-info b { font-size: 3.4mm; display: block; }
.qr-card .qc-info .qc-school { font-size: 2.6mm; color: #475569; margin-bottom: 1.5mm; font-weight: 700; }
.qr-card .qc-info div { margin: 0.8mm 0; color: #334155; }
.qr-card .qc-id { font-size: 2.6mm; color: var(--green-dark); font-weight: 700; letter-spacing: .03em; margin-top: 1mm !important; }
.qr-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5mm; }

/* ---------- Mobile ---------- */
@media (max-width: 992px) {
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
  .grid-stats.grid-3 { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .qr-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { position: fixed; left: -280px; transition: left .25s ease; box-shadow: none; }
  body.sidebar-open .sidebar { left: 0; box-shadow: var(--shadow-lg); }
  .menu-btn { display: inline-flex; }
  .main { width: 100%; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
}
@media (max-width: 560px) {
  .grid-stats { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .grid-stats.grid-3 { grid-template-columns: repeat(2, 1fr); }
  .stat-card { padding: 14px; }
  .stat-card .st-val { font-size: 24px; }
  .user-chip .uc-name, .user-chip .uc-role { display: none; }
  .card { padding: 16px; }
  .qr-grid { grid-template-columns: 1fr; }
  .btn-lg { padding: 12px 20px; }
  .form-actions .btn { flex: 1; }
  .scan-frame { width: 180px; height: 180px; }
}

/* ---------- Print ---------- */
@media print {
  body { background: #fff !important; }
  .sidebar, .topbar, .no-print, .flash, .tabs, .filter-bar { display: none !important; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  .table-wrap { overflow: visible !important; border: 0; }
  table.tbl { font-size: 10px; width: 100% !important; }
  .tbl th, .tbl td { white-space: normal !important; padding: 4px 5px; }
  .print-title { text-align: center; margin-bottom: 14px; }
  .print-title b { font-size: 15px; display: block; }
  .print-title span { font-size: 12px; color: #555; }
}

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.bold { font-weight: 700; }
.flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 14px; }
.empty .big { font-size: 40px; display: block; margin-bottom: 10px; }
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.page-btn { padding: 7px 13px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: 13px; color: #374151; }
.page-btn.active { background: var(--green); color: #fff; border-color: var(--green); }
.filter-bar { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 18px; display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filter-bar .field { min-width: 160px; flex: 1; }
.filter-bar .field.small-f { flex: 0 1 auto; min-width: 120px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.kop-sekolah { text-align: center; padding-bottom: 10px; margin-bottom: 14px; border-bottom: 2.5px solid var(--ink); }
.kop-sekolah b { font-size: 16px; display: block; }
.kop-sekolah span { font-size: 12px; color: #333; display: block; line-height: 1.5; }
