:root {
  /* Tema biru putih, mengikuti warna logo LPK Aulia Persada */
  --bg: #f3f7fd;
  --card: #ffffff;
  --text: #16233a;
  --muted: #64718a;
  --line: #dfe7f3;
  --primary: #1677e8;
  --primary-2: #0f5fc2;
  --primary-soft: #e5f0fd;
  --accent: #f08a0c;
  --ok: #1d8049; --ok-soft: #e3f4ea;
  --warn: #a96b10; --warn-soft: #fcf1dc;
  --bad: #be3a2c; --bad-soft: #fbe8e5;
  --info: #2a62a8; --info-soft: #e5eefa;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 8px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5;
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

/* ---------- Topbar ---------- */
.topbar {
  background: var(--primary); color: #fff;
  display: flex; align-items: center; gap: 12px; padding: 12px 20px;
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .2px; }
.brand-logo {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%; background: #fff;
  overflow: hidden; box-shadow: 0 0 0 2px rgba(255,255,255,.35);
}
/* Gambar logo punya ruang kosong di tepi; diperbesar agar lingkarannya pas */
.brand-logo img { display: block; width: 136%; height: 136%; margin: -18%; object-fit: contain; }
.brand small { display: block; font-weight: 400; opacity: .8; font-size: .75rem; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: .9rem; opacity: .9; text-align: right; }
.topbar .btn-ghost { color: #fff; border-color: rgba(255,255,255,.4); }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.12); }

/* ---------- Layout ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
@media (max-width: 760px) {
  .grid-2 { grid-template-columns: 1fr; }
  .container { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .topbar .who span.role { display: none; }
}

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.stack > * + * { margin-top: 16px; }

.stat { padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: .82rem; }
.stat .value { font-size: 1.7rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat.ok .value { color: var(--ok); }
.stat.warn .value { color: var(--warn); }
.stat.bad .value { color: var(--bad); }
.stat.info .value { color: var(--info); }
.stat.primary .value { color: var(--primary); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 18px; scrollbar-width: none; }
.tab {
  background: none; border: 0; padding: 10px 14px; cursor: pointer; font: inherit; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Forms ---------- */
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1 1 160px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: #fff;
  border: 1px solid #cdd3de; border-radius: 8px; padding: 9px 11px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea { resize: vertical; min-height: 70px; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline input, .inline select { width: auto; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; border-radius: 8px; padding: 9px 16px; cursor: pointer;
  border: 1px solid transparent; background: var(--primary); color: #fff; text-decoration: none;
  transition: background .15s;
}
.btn:hover { background: var(--primary-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: #f0f2f6; }
.btn-ok { background: var(--ok); } .btn-ok:hover { background: #166a3c; }
.btn-warn { background: var(--accent); } .btn-warn:hover { background: #d27605; }
.btn-danger { background: var(--bad); } .btn-danger:hover { background: #9e2f23; }
.btn-sm { padding: 5px 10px; font-size: .85rem; }
.btn-lg { padding: 14px 20px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; padding: 0; font-weight: 600; }
.link-btn.danger { color: var(--bad); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-bad { background: var(--bad-soft); color: var(--bad); }
.b-info { background: var(--info-soft); color: var(--info); }
.b-muted { background: #eef0f4; color: var(--muted); }
.b-primary { background: var(--primary-soft); color: var(--primary); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f7f8fb; font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .3px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { white-space: nowrap; text-align: right; }
td.actions > * + * { margin-left: 10px; }
.empty { text-align: center; color: var(--muted); padding: 24px; }

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-2) 45%, #fff 45%);
}
.login-card { width: 100%; max-width: 380px; padding: 28px; }
.login-card .brand { color: var(--text); justify-content: center; flex-direction: column; text-align: center; margin-bottom: 22px; gap: 6px; }
.login-logo { width: 130px; height: 130px; object-fit: contain; margin: -10px 0 -6px; }
.login-card .brand h1 { font-size: 1.3rem; color: var(--primary-2); }
.alert { padding: 10px 12px; border-radius: 8px; font-size: .9rem; margin-bottom: 12px; }
.alert-bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- Absen card ---------- */
.clock { font-size: 2.6rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 1px; color: var(--primary); }
.today-date { color: var(--muted); }
.status-box { background: #f7f8fb; border: 1px dashed var(--line); border-radius: 10px; padding: 12px 14px; margin: 14px 0; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-row .full { grid-column: 1 / -1; }

/* ---------- Activity list ---------- */
.act-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.act-item:last-child { border-bottom: 0; }
.act-icon { flex: 0 0 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 1.1rem; }
.act-icon.kursus { background: var(--info-soft); }
.act-icon.luar { background: var(--warn-soft); }
.act-body { flex: 1; min-width: 0; }
.act-title { font-weight: 600; }

/* ---------- Dialog ---------- */
dialog {
  border: 0; border-radius: 14px; padding: 0; width: min(480px, calc(100vw - 32px));
  box-shadow: 0 20px 50px rgba(0,0,0,.25); color: var(--text);
}
dialog::backdrop { background: rgba(15, 23, 42, .45); }
dialog form { padding: 20px; }
dialog h3 { margin-bottom: 14px; font-size: 1.1rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #1b2333; color: #fff; padding: 11px 18px; border-radius: 10px; font-size: .92rem;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--bad); }
