:root {
  --green: #2e7d32;
  --green-dark: #1b5e20;
  --green-light: #e8f5e9;
  --gold: #f9a825;
  --bg: #f4f6f4;
  --card: #ffffff;
  --text: #263238;
  --muted: #78909c;
}

* { box-sizing: border-box; }

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

.topbar {
  background: var(--green-dark);
  color: #fff;
  padding: 12px 16px;
}
.brand { font-weight: 700; font-size: 1.15rem; margin-bottom: 8px; }
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav a {
  color: #c8e6c9;
  text-decoration: none;
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
}
.nav a.active { background: var(--green); color: #fff; }
.nav a.logout { color: #ffcdd2; margin-left: auto; }

.container { max-width: 720px; margin: 16px auto; padding: 0 12px; }

.hero { text-align: center; margin: 12px 0 20px; }
.btn-scan {
  display: inline-block;
  background: var(--green);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  padding: 20px 32px;
  border-radius: 16px;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(46, 125, 50, 0.35);
}

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.stat {
  background: var(--card);
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.stat-num { font-size: 2rem; font-weight: 800; color: var(--green); }
.stat-label { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }

.card {
  background: var(--card);
  border-radius: 14px;
  padding: 18px;
  margin: 16px 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.card h2 { margin: 0 0 12px; font-size: 1.1rem; }
.hint { color: var(--muted); font-size: 0.85rem; }
.empty { color: var(--muted); font-size: 0.9rem; }

.list { list-style: none; padding: 0; margin: 0; }
.list li {
  display: flex; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid #eceff1;
}
.list li:last-child { border-bottom: none; }
.nama { font-weight: 600; }
.meta { color: var(--muted); font-size: 0.85rem; }

#reader { width: 100%; max-width: 340px; margin: 12px auto; border-radius: 12px; overflow: hidden; }
.last-scan { text-align: center; font-size: 0.9rem; color: var(--muted); margin: 4px 0 10px; min-height: 20px; }
.last-scan b { color: var(--text); }
.result { min-height: 26px; margin: 12px 0; padding: 10px 14px; border-radius: 10px; font-size: 0.95rem; }
.result.ok { background: var(--green-light); color: var(--green-dark); }
.result.warn { background: #fff8e1; color: #b26a00; }
.result.err { background: #ffebee; color: #b71c1c; }

.btn-primary {
  background: var(--green); color: #fff; border: none;
  padding: 12px 18px; border-radius: 10px; font-weight: 600; cursor: pointer;
}
.btn-secondary {
  background: #eceff1; color: var(--text); border: none;
  padding: 12px 18px; border-radius: 10px; font-weight: 600; cursor: pointer;
  text-decoration: none; display: inline-block;
}
.btn-del { background: #ffebee; border: none; border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.btn-edit { background: #e3f2fd; border: none; border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.row-actions { white-space: nowrap; }

.form { display: grid; gap: 10px; margin: 14px 0; }
.form input, .form-inline input {
  padding: 12px; border: 1px solid #cfd8dc; border-radius: 10px; font-size: 1rem;
}
.form-inline { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }

.table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 0.9rem; }
.table th, .table td { text-align: left; padding: 9px 6px; border-bottom: 1px solid #eceff1; }
.table th { color: var(--muted); font-weight: 600; }
.table code { background: var(--green-light); padding: 2px 6px; border-radius: 6px; font-size: 0.78rem; }

.bar { background: #eceff1; border-radius: 8px; height: 10px; overflow: hidden; min-width: 70px; margin-bottom: 2px; }
.bar-fill { background: var(--green); height: 100%; border-radius: 8px; }
.pct-text { font-size: 0.8rem; color: var(--muted); }

.hidden { display: none; }
.manual { margin-top: 10px; display: grid; gap: 8px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal.hidden { display: none; }
.modal-box { background: #fff; border-radius: 14px; padding: 20px; width: 100%; max-width: 420px; display: grid; gap: 10px; }
.modal-box h3 { margin: 0 0 4px; }
.modal-box input { padding: 12px; border: 1px solid #cfd8dc; border-radius: 10px; font-size: 1rem; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-top: 16px; }
.id-card {
  border: 2px solid var(--green); border-radius: 14px;
  text-align: center; padding: 14px;
}
.id-head { font-weight: 700; color: var(--green-dark); margin-bottom: 8px; }
.id-qr svg { width: 130px; height: 130px; }
.id-name { font-weight: 700; font-size: 1.05rem; margin-top: 6px; }
.id-kelas { color: var(--muted); font-size: 0.85rem; }
.id-code { font-family: monospace; font-size: 0.72rem; color: var(--muted); margin-top: 4px; }

@media print {
  .topbar, .hero, .btn-primary, .btn-secondary, .nav { display: none !important; }
  body { background: #fff; }
  .cards-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .id-card { break-inside: avoid; }
}
