@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@500;700;800&family=Inter:wght@400;500;600&display=swap');

:root {
  --navy: #1F3A5F;
  --navy-dark: #142A45;
  --amber: #E8A33D;
  --amber-dark: #C97E1E;
  --paper: #F6F7FA;
  --card: #FFFFFF;
  --ink: #1B2430;
  --ink-soft: #5B6572;
  --line: #E3E7ED;
  --ok: #2E7D5B;
  --ok-bg: #E5F3EC;
  --warn: #C97E1E;
  --warn-bg: #FCF1DE;
  --danger: #C1443C;
  --danger-bg: #FBE9E7;
  --info: #2A5F8F;
  --info-bg: #E7F0F9;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(20, 42, 69, 0.06), 0 1px 2px rgba(20,42,69,0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: 'Manrope', 'Inter', sans-serif;
  font-weight: 800;
  color: var(--navy-dark);
  letter-spacing: -0.01em;
}

/* ---------- Topbar ---------- */
.topbar {
  background: var(--navy);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}
.topbar .stamp {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--amber);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Manrope', sans-serif; font-weight: 800; color: var(--navy-dark);
  flex-shrink: 0;
}
.topbar .title { font-size: 15px; font-weight: 700; line-height: 1.3; }
.topbar .subtitle { font-size: 12px; opacity: 0.75; }
.topbar .spacer { flex: 1; }
.topbar a.logout {
  color: #fff; opacity: 0.85; text-decoration: none; font-size: 13px;
  border: 1px solid rgba(255,255,255,0.3); padding: 6px 12px; border-radius: 8px;
}
.topbar a.logout:hover { opacity: 1; background: rgba(255,255,255,0.1); }

/* ---------- Layout ---------- */
.wrap { max-width: 640px; margin: 0 auto; padding: 20px 16px 60px; }
.wrap.wide { max-width: 1180px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 22px;
  margin-bottom: 16px;
}

/* ---------- Form elements ---------- */
label {
  display: block; font-size: 13px; font-weight: 600; color: var(--ink);
  margin-bottom: 6px; margin-top: 16px;
}
label .req { color: var(--danger); }
label:first-child { margin-top: 0; }

select, input[type=text], input[type=date], textarea {
  width: 100%; padding: 11px 13px; border-radius: 10px;
  border: 1.5px solid var(--line); font-size: 14.5px; font-family: inherit;
  background: #fff; color: var(--ink);
}
select:focus, input:focus, textarea:focus {
  outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(31,58,95,0.12);
}
textarea { resize: vertical; min-height: 70px; }

.radio-group { display: flex; flex-wrap: wrap; gap: 8px; }
.radio-pill {
  position: relative;
}
.radio-pill input { position: absolute; opacity: 0; }
.radio-pill label {
  margin: 0; padding: 9px 14px; border-radius: 999px; border: 1.5px solid var(--line);
  font-size: 13.5px; font-weight: 600; color: var(--ink-soft); cursor: pointer;
  transition: all .15s;
}
.radio-pill input:checked + label {
  background: var(--navy); border-color: var(--navy); color: #fff;
}

.hint { font-size: 12px; color: var(--ink-soft); margin-top: 5px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 10px; border: none; cursor: pointer;
  font-size: 14.5px; font-weight: 700; font-family: inherit; transition: all .15s;
}
.btn-primary { background: var(--navy); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--navy-dark); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-amber { background: var(--amber); color: var(--navy-dark); }
.btn-amber:hover { background: var(--amber-dark); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--line); color: var(--ink); }
.btn-outline:hover { border-color: var(--navy); }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-danger-text { background:none; border:none; color: var(--danger); font-size: 13px; cursor:pointer; font-weight: 600;}

/* ---------- Camera ---------- */
.camera-box {
  border-radius: 12px; overflow: hidden; background: var(--navy-dark);
  position: relative; aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center;
}
.camera-box video, .camera-box img { width: 100%; height: 100%; object-fit: cover; }
.camera-box .placeholder { color: rgba(255,255,255,0.5); font-size: 13px; text-align: center; padding: 20px;}

/* ---------- Alerts ---------- */
.alert { padding: 12px 14px; border-radius: 10px; font-size: 13.5px; margin-top: 14px; display:flex; gap:8px; align-items:flex-start;}
.alert-danger { background: var(--danger-bg); color: var(--danger); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-info { background: var(--info-bg); color: var(--info); }

/* ---------- Badges (status stempel) ---------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
}
.badge-hadir { background: var(--ok-bg); color: var(--ok); }
.badge-terlambat { background: var(--warn-bg); color: var(--warn); }
.badge-sakit { background: var(--info-bg); color: var(--info); }
.badge-izin { background: #EEE7F9; color: #6B3FA0; }
.badge-alpa { background: var(--danger-bg); color: var(--danger); }

/* ---------- Dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat-card .num { font-family:'Manrope',sans-serif; font-size: 28px; font-weight: 800; color: var(--navy-dark); }
.stat-card .lbl { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; margin-top: 2px;}

.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filter-field { flex: 1; min-width: 140px; }
.filter-field label { margin-top: 0; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; padding: 10px 12px; background: var(--paper); color: var(--ink-soft);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700;
  border-bottom: 1.5px solid var(--line); white-space: nowrap;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #FAFBFD; }
.table-scroll { overflow-x: auto; border-radius: 10px; }
.thumb { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; border:1px solid var(--line); }
.link-map { color: var(--navy); font-size: 12.5px; text-decoration: none; font-weight: 600;}
.link-map:hover { text-decoration: underline; }

.tabs { display:flex; gap: 6px; margin-bottom: 18px; border-bottom: 1.5px solid var(--line); }
.tab { padding: 10px 4px; margin-right: 18px; font-size: 14px; font-weight: 700; color: var(--ink-soft); cursor:pointer; border-bottom: 2.5px solid transparent; }
.tab.active { color: var(--navy); border-color: var(--amber); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-soft); }

@media (max-width: 640px) {
  .wrap.wide { padding: 14px 10px 60px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Toast Notification ---------- */
.toast-container {
  position: fixed; top: 18px; right: 18px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px; max-width: 340px;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--card); border-left: 4px solid var(--navy);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(20,42,69,0.16);
  padding: 12px 14px; font-size: 13.5px; font-weight: 500; color: var(--ink);
  opacity: 0; transform: translateX(20px); transition: all .25s ease;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-ok { border-left-color: var(--ok); }
.toast-ok .toast-icon { color: var(--ok); }
.toast-danger { border-left-color: var(--danger); }
.toast-danger .toast-icon { color: var(--danger); }
.toast-info { border-left-color: var(--info); }
.toast-info .toast-icon { color: var(--info); }
.toast-icon { font-weight: 800; font-size: 15px; flex-shrink: 0; }
.toast-msg { flex: 1; line-height: 1.4; }
.toast-close { cursor: pointer; opacity: 0.5; font-size: 16px; line-height: 1; flex-shrink: 0; }
.toast-close:hover { opacity: 1; }
@media (max-width: 640px) {
  .toast-container { top: auto; bottom: 18px; right: 12px; left: 12px; max-width: none; }
}

/* ---------- Search input (siswa) ---------- */
.search-wrap { position: relative; }
.search-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  background: var(--card); border: 1.5px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); max-height: 240px; overflow-y: auto; z-index: 50;
  display: none;
}
.search-results.show { display: block; }
.search-item { padding: 10px 13px; cursor: pointer; font-size: 14px; border-bottom: 1px solid var(--line); }
.search-item:last-child { border-bottom: none; }
.search-item:hover, .search-item.active { background: var(--paper); }
.search-item .si-nama { font-weight: 600; color: var(--ink); }
.search-item .si-meta { font-size: 12px; color: var(--ink-soft); margin-top: 1px; }
.search-empty { padding: 12px 13px; font-size: 13px; color: var(--ink-soft); text-align: center; }

.manual-toggle {
  display: flex; align-items: center; gap: 8px; margin-top: 14px;
  font-size: 13px; font-weight: 600; color: var(--ink-soft); cursor: pointer; user-select: none;
}
.manual-toggle input { width: 16px; height: 16px; accent-color: var(--navy); cursor: pointer; }

.selected-chip {
  display: none; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--ok-bg); color: var(--ok); border-radius: 10px; padding: 10px 13px;
  font-size: 13.5px; font-weight: 600; margin-top: 8px;
}
.selected-chip.show { display: flex; }
.selected-chip .chip-clear { cursor: pointer; opacity: 0.7; font-weight: 800; }
.selected-chip .chip-clear:hover { opacity: 1; }

/* ---------- Inline edit table ---------- */
.row-edit-input {
  width: 100%; padding: 6px 8px; border-radius: 6px; border: 1.5px solid var(--navy);
  font-size: 13px; font-family: inherit;
}
.table-actions { display: flex; gap: 10px; white-space: nowrap; }
.btn-edit-text { background:none; border:none; color: var(--navy); font-size: 13px; cursor:pointer; font-weight: 600;}
.btn-save-text { background:none; border:none; color: var(--ok); font-size: 13px; cursor:pointer; font-weight: 600;}
