:root {
    --bg: #eaf0ee;
    --ink: #10302d;
    --ink-soft: #3d5a56;
    --paper: #ffffff;
    --line: #cfdad7;
    --accent: #f2b53d;
    --accent-ink: #3a2800;
    --ok: #1e7a4c;
    --warn: #8a5a00;
    --bad: #b3261e;
    --radius: 14px;
    --font-head: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
    --font-body: "Figtree", "Segoe UI", system-ui, sans-serif;
}

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

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.55;
}

h1, h2 { font-family: var(--font-head); line-height: 1.15; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 5vw, 2.7rem); font-weight: 800; }
h2 { font-size: 1.45rem; font-weight: 700; }

a { color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Hero ---------- */
.hero { max-width: 1100px; margin: 0 auto; padding: 2rem 1.25rem 1rem; }
.hero-sekolah { margin: 0 0 .35rem; font-weight: 600; color: var(--ink-soft); }
.hero-sub { margin: .5rem 0 0; max-width: 60ch; color: var(--ink-soft); }

/* ---------- Layout dua kartu ---------- */
.grid {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem 1.25rem 2rem;
    display: grid;
    gap: 1.25rem;
    grid-template-columns: 1fr;
}
@media (min-width: 900px) {
    .grid { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; }
    .card-login { position: sticky; top: 1.25rem; }
    .grid-dash { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); }
    .grid-dash .kartu-siswa { order: 0; }
}

.card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.5rem 1.25rem;
}
@media (min-width: 600px) { .card { padding: 1.75rem; } }

.card-login {
    background: var(--ink);
    border-color: var(--ink);
    color: #eaf3f1;
}
.card-login .card-note, .card-login label { color: #bcd3cf; }
.card-note { margin: 0 0 1.25rem; color: var(--ink-soft); }

/* ---------- Form ---------- */
.field { margin-bottom: 1rem; min-width: 0; }
.row { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
@media (min-width: 520px) { .row { grid-template-columns: 1fr 1fr; } }

label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: .3rem; }

input, select, textarea {
    width: 100%;
    font: inherit;
    font-size: 1rem; /* cegah zoom otomatis di iOS */
    color: var(--ink);
    background: #fff;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    padding: .7rem .8rem;
    min-height: 46px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: 3px solid rgba(242, 181, 61, .55); outline-offset: 0; }
input[readonly] { background: #f0f4f3; color: var(--ink-soft); }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset[disabled] { opacity: .65; }

.hint { margin: -.25rem 0 1.1rem; font-size: .88rem; color: var(--ink-soft); }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    font: inherit; font-weight: 700;
    padding: .75rem 1.25rem; min-height: 46px;
    border-radius: 10px; border: 2px solid transparent;
    cursor: pointer; text-decoration: none;
}
form > .btn, fieldset > .btn { width: 100%; }
@media (min-width: 600px) { form > .btn-primary, fieldset > .btn-primary { width: auto; } }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #1a4742; }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { background: #ffc653; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-danger { background: #fff; color: var(--bad); border-color: #e3b5b1; }
.btn-danger:hover { background: var(--bad); color: #fff; }

.admin-link { margin: 1.25rem 0 0; font-size: .92rem; }
.admin-link a { color: var(--accent); }
.card:not(.card-login) .admin-link a { color: var(--ink); }

/* ---------- Alert & badge ---------- */
.alert { border-radius: 10px; padding: .85rem 1rem; margin-bottom: 1.1rem; font-size: .95rem; }
.alert ul { margin: .35rem 0 0; padding-left: 1.2rem; }
.alert-error { background: #fdeceb; color: #7a1812; border: 1px solid #f0c3bf; }
.alert-ok { background: #e4f4ea; color: #145536; border: 1px solid #b7dfc7; }
.alert-info { background: #fff4d9; color: #5d4100; border: 1px solid #f1d98f; }

.badge { display: inline-block; padding: .15rem .65rem; border-radius: 999px; font-size: .85rem; font-weight: 700; }
.st-wait { background: #ffe9b0; color: #6b4700; }
.st-ok { background: #cdeedb; color: #12512f; }
.st-no { background: #f7d0cc; color: #86160f; }

/* ---------- Kartu login siswa ---------- */
.sukses { max-width: 520px; margin: 0 auto; padding: 1.5rem 1.25rem 2.5rem; }
.kartu-sekolah { margin: 0 0 .25rem; font-size: .9rem; color: var(--accent); font-weight: 600; }
.kartu-data { margin: 1rem 0 1.25rem; display: grid; gap: .6rem; }
.kartu-data div { border-top: 1px solid rgba(255, 255, 255, .18); padding-top: .55rem; }
.kartu-data dt { font-size: .85rem; color: #bcd3cf; }
.kartu-data dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.kartu-data .nomor { font-family: var(--font-head); font-size: 1.6rem; letter-spacing: .04em; color: var(--accent); }

/* ---------- Topbar & footer ---------- */
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    max-width: 1100px; margin: 0 auto; padding: 1rem 1.25rem 0;
}
.topbar-brand { font-family: var(--font-head); font-weight: 700; font-size: 1.1rem; }
.foot { text-align: center; padding: 1rem 1.25rem 2rem; color: var(--ink-soft); font-size: .9rem; }

.solo { max-width: 440px; margin: 0 auto; padding: 2rem 1.25rem; }
body.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
body.center .solo { width: 100%; }

/* ---------- Admin ---------- */
.admin-wrap { max-width: 1100px; margin: 0 auto; padding: 1rem 1.25rem 3rem; }
.stat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: 1.25rem; }
@media (min-width: 700px) { .stat-row { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; display: flex; flex-direction: column; }
.stat-n { font-family: var(--font-head); font-size: 2rem; font-weight: 800; line-height: 1.1; }

.filter { display: grid; gap: .6rem; margin-bottom: 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 700px) { .filter { grid-template-columns: 1fr 200px auto; } }

.tabel { width: 100%; border-collapse: collapse; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tabel th { text-align: left; font-size: .9rem; padding: .75rem 1rem; background: #dfe9e6; }
.tabel td { padding: .7rem 1rem; vertical-align: top; }
.tabel .baris td { border-top: 1px solid var(--line); }
.tabel .detail td { padding: 0 1rem .8rem; }
.tabel summary { cursor: pointer; font-weight: 600; color: var(--ink-soft); padding: .3rem 0; }

.detail-grid { display: grid; gap: .6rem 1.5rem; grid-template-columns: 1fr; margin: .75rem 0 1rem; }
@media (min-width: 700px) { .detail-grid { grid-template-columns: repeat(3, 1fr); } }
.detail-grid dt { font-size: .82rem; color: var(--ink-soft); }
.detail-grid dd { margin: 0; overflow-wrap: anywhere; }

.aksi { display: flex; flex-wrap: wrap; gap: .6rem; }
.aksi form { margin: 0; }
.aksi-status { display: flex; gap: .5rem; flex-wrap: wrap; }
.aksi-status select { width: auto; }

/* Tabel jadi kartu bertumpuk di layar kecil */
@media (max-width: 760px) {
    .tabel, .tabel tbody, .tabel tr, .tabel td { display: block; width: 100%; }
    .tabel thead { display: none; }
    .tabel { border: 0; background: transparent; }
    .tabel .baris { background: var(--paper); border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; padding: .4rem 0; margin-top: .9rem; }
    .tabel .baris td { border: 0; display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 1rem; text-align: right; }
    .tabel .baris td::before { content: attr(data-label); font-weight: 600; color: var(--ink-soft); text-align: left; flex-shrink: 0; }
    .tabel .detail { background: var(--paper); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); }
    .tabel .detail td { padding: .2rem 1rem .9rem; }
    .aksi-status select, .aksi .btn { width: 100%; }
    .aksi form { width: 100%; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
