/* AEGIS — Area Empati & Garda Inspirasi Siswa
   Palet dari logo: biru garda, koral empati, emas inspirasi. */
:root {
  --navy: #1F3A68;
  --navy-deep: #142847;
  --navy-soft: #E6ECF6;
  --coral: #E8776A;
  --coral-ink: #A9473B;
  --coral-soft: #FCEBE8;
  --gold: #E0A42E;
  --gold-ink: #7E5A10;
  --gold-soft: #FBF1DC;
  --green-ink: #1E6B4A;
  --green-soft: #E2F3EA;
  --red-ink: #A3302A;
  --red-soft: #FBE6E4;
  --blue-ink: #24518F;
  --blue-soft: #E3ECFA;
  --bg: #F3F5FA;
  --surface: #FFFFFF;
  --ink: #17223B;
  --muted: #56627C;
  --line: #D9E0EC;
  --radius: 10px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --shadow: 0 1px 2px rgba(23, 34, 59, .06), 0 4px 16px rgba(23, 34, 59, .05);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--ink); background: var(--bg); }
a { color: var(--navy); text-underline-offset: 2px; }
a:hover { color: var(--navy-deep); }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.25; margin: 0; text-wrap: balance; }
h1 { font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.pre { white-space: pre-wrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Kerangka ---------- */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; background: linear-gradient(to right, var(--navy-deep) 252px, var(--bg) 252px); }
.side { background: var(--navy-deep); color: #DCE3F0; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 16px; color: #fff; text-decoration: none; }
.brand svg { width: 34px; height: 41px; flex: none; }
.brand b { font-size: 19px; letter-spacing: .16em; display: block; }
.brand span { font-size: 11px; color: #AEBBD3; display: block; line-height: 1.3; }
.nav { padding: 6px 10px 24px; display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #8796B3; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: #DCE3F0; text-decoration: none; font-size: 14px; }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav a.on { background: rgba(224, 164, 46, .16); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav .count { margin-left: auto; background: var(--coral); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.side-foot { margin-top: auto; padding: 14px 18px 20px; font-size: 12px; color: #8796B3; border-top: 1px solid rgba(255, 255, 255, .08); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px max(20px, env(safe-area-inset-right)) 10px max(20px, env(safe-area-inset-left)); background: rgba(243, 245, 250, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar .spacer { flex: 1; }
.topbar .menu-btn { display: none; }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; text-align: right; }
.who b { display: block; font-size: 14px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.bell { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; color: var(--navy); }
.bell:hover { background: var(--navy-soft); }
.bell svg { width: 20px; height: 20px; }
.bell i { position: absolute; top: 5px; right: 5px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px; background: var(--coral); color: #fff; font-size: 10px; font-style: normal; font-weight: 700; display: grid; place-items: center; }
.content { padding: 24px max(20px, env(safe-area-inset-right)) 48px max(20px, env(safe-area-inset-left)); width: 100%; max-width: 1240px; display: flex; flex-direction: column; gap: 20px; }

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: var(--bg); }
  .side { position: fixed; inset: 0 auto 0 0; width: 272px; z-index: 50; transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(10, 20, 40, .45); }
  .topbar .menu-btn { display: inline-flex; }
  .who .who-text { display: none; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }

/* ---------- Kepala halaman ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; }
.page-head .eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--gold-ink); margin-bottom: 4px; }
.page-head p { color: var(--muted); max-width: 70ch; margin-top: 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.crumb { font-size: 13px; color: var(--muted); }
.crumb a { color: var(--muted); }

/* ---------- Kartu & grid ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card.flush { padding: 0; gap: 0; }
.card.flush > .card-head { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.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-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1080px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 420px) { .grid-4 { grid-template-columns: minmax(0, 1fr); } }

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.stat .v { font-size: 28px; font-weight: 800; color: var(--navy); font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .l { font-size: 13px; color: var(--muted); }
.stat.alert-stat { border-color: var(--coral); background: var(--coral-soft); }
.stat.alert-stat .v { color: var(--coral-ink); }

/* ---------- Daftar ---------- */
.list { display: flex; flex-direction: column; }
.list > * { padding: 12px 0; border-top: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.list > *:first-child { border-top: 0; padding-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list a.row-link { text-decoration: none; color: inherit; }
.list a.row-link:hover b { text-decoration: underline; }
.when { flex: none; width: 56px; text-align: center; border-radius: 8px; background: var(--navy-soft); color: var(--navy); padding: 6px 4px; line-height: 1.15; }
.when b { display: block; font-size: 18px; }
.when span { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Tabel ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: #F8F9FC; white-space: nowrap; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #FAFBFD; }
.tbl td.act { white-space: nowrap; text-align: right; }
.tbl .num { text-align: right; }

/* ---------- Badge ---------- */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: #EEF1F6; color: var(--muted); white-space: nowrap; }
.badge-wait { background: var(--gold-soft); color: var(--gold-ink); }
.badge-ok { background: var(--green-soft); color: var(--green-ink); }
.badge-bad { background: var(--red-soft); color: var(--red-ink); }
.badge-info { background: var(--blue-soft); color: var(--blue-ink); }
.badge-lock { background: var(--coral-soft); color: var(--coral-ink); }

/* ---------- Tombol ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #B9C4D8; background: #FAFBFD; color: var(--ink); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-deep); border-color: var(--navy-deep); color: #fff; }
.btn-accent { background: var(--coral); border-color: var(--coral); color: #2A0F0B; }
.btn-accent:hover { background: #DF6656; border-color: #DF6656; color: #2A0F0B; }
.btn-danger { color: var(--red-ink); }
.btn-danger:hover { background: var(--red-soft); border-color: #E9B8B3; color: var(--red-ink); }
.btn-sm { min-height: 32px; padding: 4px 11px; font-size: 13px; }
.btn-link { background: none; border: 0; padding: 0; min-height: 0; color: var(--navy); font-weight: 600; text-decoration: underline; }
.btn-link:hover { background: none; }
form.inline { display: inline; }

/* ---------- Form ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .wide { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field .req { color: var(--coral-ink); }
.help { font-size: 12px; color: var(--muted); }
.err { font-size: 12px; color: var(--red-ink); font-weight: 600; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=time], input[type=search], input[type=tel], input[type=url], select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid #C9D2E2; border-radius: 8px; background: #fff; color: var(--ink); font: inherit; font-size: 14px;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
textarea.tall { min-height: 260px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(31, 58, 104, .15); }
.is-invalid { border-color: var(--red-ink) !important; }
input[type=file] { font-size: 14px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--navy); }
.form-foot { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; padding-top: 4px; }
.filter { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filter .field { min-width: 160px; flex: 1 1 160px; max-width: 260px; }
.filter .field.search { flex: 2 1 220px; max-width: 340px; }

.picker { border: 1px solid #C9D2E2; border-radius: 8px; background: #fff; }
.picker input[type=search] { border: 0; border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0; }
.picker-list { max-height: 260px; overflow-y: auto; padding: 6px; }
.picker-list label { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; font-size: 14px; cursor: pointer; }
.picker-list label:hover { background: var(--bg); }
.picker-list input { width: 17px; height: 17px; accent-color: var(--navy); }
.picker-count { font-size: 12px; color: var(--muted); padding: 6px 12px; border-top: 1px solid var(--line); }

/* ---------- Pesan ---------- */
.alert { border-radius: 8px; padding: 12px 14px; font-size: 14px; border: 1px solid; display: block; }
.alert-ok { background: var(--green-soft); border-color: #B9DFCB; color: #14482F; }
.alert-error { background: var(--red-soft); border-color: #EBC1BC; color: #6E1E19; }
.alert-info { background: var(--navy-soft); border-color: #C6D3EA; color: var(--navy-deep); }
.alert-warn { background: var(--gold-soft); border-color: #EBD3A0; color: #5A400A; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.lock-note { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--coral-ink); background: var(--coral-soft); border-radius: 8px; padding: 10px 12px; }
.lock-note svg { width: 16px; height: 16px; flex: none; }

.empty { text-align: center; padding: 32px 16px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty b { color: var(--ink); font-size: 15px; }

/* ---------- Grafik batang sederhana ---------- */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 160px) minmax(0, 1fr) 48px; gap: 10px; align-items: center; font-size: 13px; }
.bar-track { height: 10px; background: #EBEFF6; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--navy); border-radius: 99px; }
.bar-fill.hot { background: var(--coral); }
.bar-row .n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.cols { display: flex; align-items: flex-end; gap: 12px; height: 160px; padding-top: 10px; border-bottom: 1px solid var(--line); }
.cols .c { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.cols .c i { display: block; width: 100%; max-width: 44px; background: var(--navy); border-radius: 6px 6px 0 0; min-height: 2px; }
.cols .c b { font-size: 12px; font-variant-numeric: tabular-nums; }
.cols-labels { display: flex; gap: 12px; }
.cols-labels span { flex: 1; text-align: center; font-size: 12px; color: var(--muted); }

/* ---------- Tab ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 10px 14px; font-size: 14px; font-weight: 600; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--navy); border-bottom-color: var(--gold); }

/* ---------- Detail ---------- */
.dl { display: grid; grid-template-columns: minmax(110px, 170px) minmax(0, 1fr); gap: 8px 16px; font-size: 14px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) { .dl { grid-template-columns: minmax(0, 1fr); gap: 2px; } .dl dd { margin-bottom: 8px; } }
.note-box { background: #FAFBFD; border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; white-space: pre-wrap; font-size: 14px; line-height: 1.65; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 13px; padding: 4px 10px; border-radius: 99px; background: var(--navy-soft); color: var(--navy); text-decoration: none; }

/* ---------- Angket ---------- */
.q { padding: 16px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 4px 12px; }
.q:first-of-type { border-top: 0; padding-top: 0; }
.q .no { font-weight: 800; color: var(--navy); font-variant-numeric: tabular-nums; }
.q .opts { grid-column: 2; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.q .opts label { display: flex; align-items: center; gap: 8px; border: 1px solid #C9D2E2; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-size: 14px; min-height: 44px; }
.q .opts input { accent-color: var(--navy); width: 17px; height: 17px; }
.q .opts label:has(input:checked) { border-color: var(--navy); background: var(--navy-soft); font-weight: 600; }
.progress { height: 8px; background: #EBEFF6; border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--gold); }

/* ---------- Halaman tamu ---------- */
.guest { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.guest-art { background: var(--navy-deep); color: #E7ECF6; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; position: relative; overflow: hidden; }
.guest-art::after { content: ""; position: absolute; right: -140px; bottom: -160px; width: 460px; height: 520px; background: url("../img/logo.svg") no-repeat center / contain; opacity: .07; }
.guest-art h1 { font-size: clamp(28px, 3.4vw, 40px); color: #fff; max-width: 15ch; }
.guest-art p { color: #B8C4DA; max-width: 44ch; font-size: 16px; }
.guest-art .acr { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); font-weight: 700; }
.guest-art ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; font-size: 14px; color: #C9D3E6; position: relative; z-index: 1; }
.guest-art li { display: flex; gap: 10px; }
.guest-art li::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--coral); margin-top: 7px; flex: none; }
.guest-form { padding: 48px max(24px, env(safe-area-inset-right)) 48px max(24px, env(safe-area-inset-left)); display: flex; align-items: center; justify-content: center; background: var(--surface); }
.guest-box { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 18px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.btn-block { width: 100%; min-height: 46px; }
.guest-links { display: flex; flex-direction: column; gap: 8px; font-size: 14px; border-top: 1px solid var(--line); padding-top: 16px; }
@media (max-width: 860px) {
  .guest { grid-template-columns: minmax(0, 1fr); }
  .guest-art { padding: 28px 20px; }
  .guest-art ul, .guest-art p.hide-sm { display: none; }
}
.public-wrap { max-width: 720px; margin: 0 auto; padding: 32px max(16px, env(safe-area-inset-right)) 56px max(16px, env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 20px; }
.public-top { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--navy); }
.public-top svg { width: 30px; height: 36px; }
.public-top b { letter-spacing: .14em; font-size: 18px; }
.ticket { font-size: 30px; font-weight: 800; letter-spacing: .12em; color: var(--navy); background: var(--gold-soft); border: 2px dashed var(--gold); border-radius: 10px; padding: 14px; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- Paginasi ---------- */
.pager { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: space-between; padding: 14px 20px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.pager .pages { display: flex; gap: 4px; flex-wrap: wrap; }
.pager a, .pager span.cur { min-width: 34px; height: 34px; padding: 0 8px; border-radius: 8px; display: grid; place-items: center; text-decoration: none; border: 1px solid var(--line); background: #fff; }
.pager span.cur { background: var(--navy); color: #fff; border-color: var(--navy); font-weight: 700; }
.pager span.dis { opacity: .45; }

@media print {
  .side, .topbar, .actions, .filter, .no-print { display: none !important; }
  .shell { display: block; }
  .card { break-inside: avoid; }
}
