:root {
  /* Palet diambil dari logo SMAN 5 Sumatera Barat */
  --brand-950: #082740;
  --brand-900: #0e3356;
  --brand-800: #123f69;
  --brand-700: #164878;
  --brand-600: #1c5b91;
  --brand-500: #2b6fa6;
  --brand-100: #dceaf5;
  --brand-50: #f2f7fb;

  --accent-red: #a42438;
  --accent-red-soft: #fbeaec;
  --accent-gold: #d8c635;
  --accent-gold-soft: #fbf8df;
  --accent-green: #78c68b;
  --accent-green-deep: #3d8657;
  --accent-green-soft: #eaf7ed;

  --canvas: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #1f2937;
  --ink-strong: #132235;
  --ink-soft: #64748b;
  --muted: #94a3b8;
  --line: #dce5ee;
  --line-soft: #edf2f7;
  --danger: #b42318;
  --warning: #b7791f;
  --ok: #2f7d52;

  --shadow-sm: 0 1px 2px rgba(14, 51, 86, 0.05), 0 4px 12px rgba(14, 51, 86, 0.05);
  --shadow-md: 0 12px 30px rgba(14, 51, 86, 0.10);
  --shadow-lg: 0 24px 60px rgba(5, 31, 52, 0.22);

  /* Alias untuk kode lama */
  --navy-deep: var(--brand-900);
  --navy: var(--brand-700);
  --navy-soft: var(--brand-600);
  --gold: var(--accent-gold);
  --gold-soft: #f2eaa0;
  --paper: var(--canvas);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--canvas);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { margin: 0; font-family: inherit; font-weight: 750; color: var(--ink-strong); }

/* ---------- LOGIN ---------- */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background:
    radial-gradient(circle at 14% 16%, rgba(216,198,53,.17), transparent 26%),
    radial-gradient(circle at 85% 84%, rgba(120,198,139,.13), transparent 28%),
    linear-gradient(145deg, var(--brand-950) 0%, var(--brand-900) 48%, var(--brand-700) 100%);
  position: relative;
  overflow: hidden;
}
#login-screen::before,
#login-screen::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 999px;
  pointer-events: none;
}
#login-screen::before { width: 520px; height: 520px; left: -250px; top: -260px; }
#login-screen::after { width: 420px; height: 420px; right: -190px; bottom: -220px; }
.login-stage { width: 100%; max-width: 430px; position: relative; z-index: 2; }
.login-card {
  width: 100%;
  background: rgba(255,255,255,.985);
  border: 1px solid rgba(255,255,255,.65);
  border-radius: 24px;
  padding: 34px 34px 28px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
}
.login-logo-shell {
  width: 92px; height: 92px;
  margin: 0 auto 16px;
  border-radius: 22px;
  background: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 12px 30px rgba(14,51,86,.14);
  border: 1px solid var(--line-soft);
  overflow: hidden;
}
.login-logo { width: 82px; height: 82px; object-fit: contain; display: block; }
.login-kicker {
  text-align: center;
  color: var(--brand-600);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.login-title {
  text-align: center;
  font-size: 30px;
  line-height: 1.1;
  font-weight: 850;
  color: var(--brand-900);
  letter-spacing: -.03em;
}
.login-sub {
  text-align: center;
  font-size: 13px;
  font-weight: 650;
  color: var(--ink-soft);
  margin: 5px 0 26px;
}
.login-footnote { text-align: center; color: var(--muted); font-size: 11.5px; margin-top: 14px; }
.login-submit { width: 100%; margin-top: 3px; }
.login-error {
  background: var(--accent-red-soft);
  border: 1px solid #efc6cc;
  color: var(--accent-red);
  font-size: 12.5px;
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 16px;
  display: none;
  line-height: 1.45;
}
.config-warning {
  max-width: 410px;
  margin: 13px auto 0;
  padding: 0 16px;
  color: #f7efb0;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.5;
}

/* ---------- FORM GLOBAL ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .055em;
}
input, select, textarea, .search-input, .presensi-select {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
textarea { min-height: 94px; resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #a6b3c2; }
input:focus, select:focus, textarea:focus, .search-input:focus, .presensi-select:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 4px rgba(22,72,120,.10);
}
input:disabled, select:disabled, textarea:disabled { background: #f1f5f9; color: #94a3b8; cursor: not-allowed; }

/* ---------- APP SHELL ---------- */
#app-screen { display: none; min-height: 100vh; }
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 272px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 30% 0%, rgba(255,255,255,.07), transparent 23%),
    linear-gradient(180deg, var(--brand-900) 0%, var(--brand-950) 100%);
  color: #dbe7f1;
  box-shadow: 8px 0 30px rgba(14,51,86,.08);
  z-index: 20;
  overflow: hidden;
}
.sidebar-brand {
  min-height: 102px;
  padding: 18px 18px 16px;
  display: flex;
  align-items: center;
  gap: 13px;
  border-bottom: 1px solid rgba(255,255,255,.09);
}
.sidebar-logo-shell {
  width: 56px; height: 56px;
  flex: 0 0 56px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #fff;
  border-radius: 15px;
  box-shadow: 0 8px 18px rgba(0,0,0,.16);
}
.sidebar-logo { width: 51px; height: 51px; object-fit: contain; display: block; }
.sidebar-brand-copy { min-width: 0; }
.sidebar-brand .name {
  color: #fff;
  font-size: 21px;
  line-height: 1.05;
  font-weight: 850;
  letter-spacing: -.025em;
}
.sidebar-brand .school {
  color: #d5e7f6;
  font-size: 10.5px;
  line-height: 1.35;
  margin-top: 5px;
  font-weight: 650;
}
.sidebar-section-label {
  padding: 14px 20px 7px;
  color: rgba(222,235,247,.55);
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .13em;
}
#nav-list {
  overflow-y: auto;
  padding: 0 10px 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 9px 12px;
  margin: 2px 0;
  border-radius: 11px;
  color: #bfd1e0;
  font-size: 12.8px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.nav-item:hover { background: rgba(255,255,255,.075); color: #fff; transform: translateX(1px); }
.nav-item.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(255,255,255,.15), rgba(255,255,255,.08));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.07);
}
.nav-dot {
  width: 8px; height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: .45;
  box-shadow: 0 0 0 4px rgba(255,255,255,.035);
}
.nav-item.active .nav-dot { background: var(--accent-gold); opacity: 1; box-shadow: 0 0 0 4px rgba(216,198,53,.14); }
.sidebar-footer {
  margin-top: auto;
  padding: 15px 16px 17px;
  border-top: 1px solid rgba(255,255,255,.09);
  background: rgba(3,27,46,.20);
}
.sidebar-user-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sidebar-user-copy { min-width: 0; }
.who { color: #fff; font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-role { color: #aac6dc; font-size: 10.5px; text-transform: capitalize; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-btn {
  width: 100%;
  margin-top: 12px;
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 10px;
  background: rgba(255,255,255,.055);
  color: #d7e4ee;
  font-size: 11.5px;
  font-weight: 650;
  cursor: pointer;
  transition: .15s ease;
}
.logout-btn:hover { color: #fff; background: rgba(164,36,56,.32); border-color: rgba(255,255,255,.20); }

.workspace { flex: 1; min-width: 0; min-height: 100vh; background: var(--canvas); }
.topbar {
  height: 76px;
  position: sticky;
  top: 0;
  z-index: 15;
  padding: 0 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(14px);
}
.topbar-copy { min-width: 0; }
.topbar-eyebrow { color: var(--brand-600); font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .11em; margin-bottom: 2px; }
.topbar-title { color: var(--ink-strong); font-size: 19px; line-height: 1.2; font-weight: 800; letter-spacing: -.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-user { display: flex; align-items: center; gap: 11px; min-width: 0; }
.topbar-user-text { text-align: right; min-width: 0; }
.topbar-user-name { color: var(--ink-strong); font-size: 12px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 210px; }
.topbar-user-role { color: var(--ink-soft); font-size: 10.5px; margin-top: 1px; text-transform: capitalize; }
.user-avatar {
  width: 38px; height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(145deg, var(--brand-600), var(--brand-800));
  font-size: 13px;
  font-weight: 850;
  box-shadow: 0 5px 14px rgba(14,51,86,.22);
}
.user-avatar-light { width: 40px; height: 40px; flex-basis: 40px; border-radius: 13px; }

.main {
  min-height: calc(100vh - 76px);
  padding: 30px 34px 42px;
  overflow-x: auto;
}
.page-title {
  color: var(--ink-strong);
  font-size: 25px;
  line-height: 1.22;
  font-weight: 830;
  letter-spacing: -.025em;
  margin-bottom: 5px;
}
.page-sub { color: var(--ink-soft); font-size: 12.8px; line-height: 1.55; margin-bottom: 22px; }

/* ---------- CARDS / DASHBOARD ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 13px;
  margin-bottom: 24px;
}
.stat-card {
  position: relative;
  overflow: hidden;
  min-height: 108px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  padding: 17px 17px 15px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.stat-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--brand-600);
  opacity: .88;
}
.stat-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); border-color: #cfe0ed; }
.stat-num { color: var(--brand-900); font-size: 28px; font-weight: 850; line-height: 1.1; letter-spacing: -.03em; }
.stat-label { color: var(--ink-soft); font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .055em; margin-top: 6px; }
.stat-card.tone-green::before { background: var(--accent-green-deep); }
.stat-card.tone-green .stat-num { color: var(--accent-green-deep); }
.stat-card.tone-gold::before { background: var(--accent-gold); }
.stat-card.tone-gold .stat-num { color: #9b8914; }
.stat-card.tone-red::before { background: var(--accent-red); }
.stat-card.tone-red .stat-num { color: var(--accent-red); }
.stat-card.tone-blue::before { background: var(--brand-600); }

/* ---------- BUTTONS ---------- */
.btn-primary, .btn-secondary, .btn-ghost {
  min-height: 38px;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 750;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .15s ease, background .15s ease, color .15s ease, border-color .15s ease;
}
.btn-primary {
  width: auto;
  border: 1px solid var(--brand-700);
  background: linear-gradient(145deg, var(--brand-700), var(--brand-800));
  color: #fff;
  box-shadow: 0 5px 14px rgba(22,72,120,.15);
}
.btn-primary:hover { background: linear-gradient(145deg, var(--brand-600), var(--brand-700)); transform: translateY(-1px); box-shadow: 0 8px 18px rgba(22,72,120,.18); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled, .btn-secondary:disabled { opacity: .58; cursor: default; transform: none; box-shadow: none; }
.btn-secondary {
  border: 1px solid #c7d8e6;
  background: #fff;
  color: var(--brand-700);
  box-shadow: 0 1px 2px rgba(14,51,86,.04);
}
.btn-secondary:hover { background: var(--brand-50); border-color: #adc9dd; color: var(--brand-900); }
.btn-ghost { border: none; background: transparent; color: var(--ink-soft); box-shadow: none; }
.btn-ghost:hover { background: #f1f5f9; color: var(--ink); }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.search-input { width: 250px; }

/* ---------- TABLES ---------- */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.8px; }
th {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  color: #5d6e80;
  font-size: 9.5px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .065em;
  white-space: nowrap;
}
thead th:first-child { border-top-left-radius: 12px; }
thead th:last-child { border-top-right-radius: 12px; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); color: var(--ink); vertical-align: middle; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: #f9fbfd; }
tr:last-child td { border-bottom: none; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: .01em;
  white-space: nowrap;
}
.badge-aktif, .badge-hadir { background: var(--accent-green-soft); color: var(--ok); }
.badge-nonaktif { background: #eef2f6; color: #687789; }
.badge-sakit, .badge-alpa { background: var(--accent-red-soft); color: var(--accent-red); }
.badge-izin { background: var(--accent-gold-soft); color: #897813; }

/* ---------- PRESENSI / UTIL ---------- */
.jurnal-status-line { color: var(--ink-soft); font-size: 12.5px; margin-bottom: 16px; }
.presensi-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line-soft); gap: 12px; }
.presensi-row:last-child { border-bottom: none; }
.presensi-name { color: var(--ink); font-size: 13px; font-weight: 650; }
.presensi-select { width: auto; min-width: 112px; min-height: 36px; padding: 6px 9px; }
.back-link { display: inline-flex; align-items: center; gap: 5px; color: var(--brand-700); font-size: 12px; font-weight: 700; cursor: pointer; margin-bottom: 12px; }
.back-link::before { content: "←"; }
.back-link:hover { color: var(--brand-900); text-decoration: none; }
.empty-state {
  text-align: center;
  padding: 44px 20px;
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.55;
}

/* ---------- MODAL ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  padding: 20px;
  background: rgba(8,39,64,.55);
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(5px);
}
.modal {
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: #fff;
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
}
.modal h3 { color: var(--ink-strong); font-size: 18px; font-weight: 820; margin-bottom: 18px; }
.modal .field { margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; flex-wrap: wrap; }

/* ---------- TOAST ---------- */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  display: none;
  max-width: min(420px, calc(100vw - 48px));
  padding: 12px 16px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 13px;
  background: var(--brand-900);
  color: #fff;
  font-size: 12.5px;
  line-height: 1.45;
  box-shadow: 0 16px 38px rgba(8,39,64,.25);
}
.toast.err { background: #9f2537; }

/* ---------- SPECIAL INLINE CONTENT ---------- */
.card > p:first-child:last-child { line-height: 1.55; }
hr { border: 0; border-top: 1px solid var(--line-soft); }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1100px) {
  .sidebar { width: 238px; }
  .main { padding: 26px 25px 38px; }
  .topbar { padding: 0 25px; }
}
@media (max-width: 820px) {
  .shell { display: block; }
  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    max-height: none;
  }
  .sidebar-brand { min-height: 86px; }
  .sidebar-section-label { display: none; }
  #nav-list { display: flex; overflow-x: auto; padding: 9px 10px; }
  .nav-item { flex: 0 0 auto; white-space: nowrap; margin: 0 2px; }
  .sidebar-footer { display: none; }
  .topbar { position: sticky; height: 66px; padding: 0 18px; }
  .topbar-user-text { display: none; }
  .main { padding: 22px 16px 32px; min-height: calc(100vh - 66px); }
  .page-title { font-size: 22px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 540px) {
  #login-screen { padding: 18px; }
  .login-card { padding: 28px 22px 24px; border-radius: 20px; }
  .login-logo-shell { width: 80px; height: 80px; border-radius: 19px; }
  .login-logo { width: 71px; height: 71px; }
  .topbar-eyebrow { display: none; }
  .topbar-title { font-size: 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { min-height: 100px; padding: 14px; }
  .stat-num { font-size: 24px; }
  .card { border-radius: 14px; padding: 16px; }
  .toolbar { align-items: stretch; }
  .search-input { width: 100%; }
  .btn-primary, .btn-secondary { min-height: 40px; }
}



/* Password visibility */
.password-wrap { position: relative; }
.password-wrap input { padding-right: 90px; }
.password-toggle {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  border: 1px solid #d5e1eb;
  border-radius: 8px;
  background: #f3f7fb;
  color: var(--brand-700, #164878);
  min-width: 58px;
  padding: 6px 9px;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.password-toggle:hover { background: #e7f0f7; border-color: #b8cedf; color: var(--brand-900, #0e3356); }
.password-toggle:focus-visible { outline: 2px solid var(--brand-500, #28689f); outline-offset: 2px; }

/* Password recovery */
.login-forgot {
  display:block; width:100%; border:0; background:transparent; color:var(--primary,#164878);
  font-size:13px; font-weight:700; text-align:center; padding:10px 8px 2px; cursor:pointer;
}
.login-forgot:hover { text-decoration:underline; }
.login-error.ok { background:#ecfdf5; color:#166534; border-color:#bbf7d0; }


/* Developer credit */
.developer-credit {
  margin-top: 12px;
  text-align: center;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .02em;
  color: #7a8998;
}
.developer-credit-sidebar {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,.10);
  color: rgba(255,255,255,.58);
  font-size: 10.5px;
}

/* Status koneksi pada halaman login */
.connection-status-login {
  margin-top: 8px;
  text-align: center;
  font-size: 10.5px;
  font-weight: 650;
  color: #8a98a7;
}
.connection-status-login[data-state="ok"] { color: #2f7d50; }
.connection-status-login[data-state="error"] { color: #b4232f; }
.connection-status-login[data-state="loading"] { color: #718096; }
