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

:root {
  --navy: #111d3a;
  --blue-dark: #192b55;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --orange: #f59e0b;
  --bg: #f1f5f9;
  --paper: #ffffff;
  --text: #172554;
  --muted: #64748b;
  --line: #e2e8f0;
  --ok: #15803d;
  --danger: #dc2626;
  --radius: 14px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px -18px rgba(17, 29, 58, .45);
  --side: 230px;
  --space: 16px;
  --header: 64px;
  --font: Inter, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow-x: clip;
}
body.menu-open { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; height: auto; }
a { color: var(--blue); }

.shell { min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: fixed;
  z-index: 40;
  top: 0; left: 0; bottom: 0;
  width: min(300px, calc(100vw - 48px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 12px 20px;
  background: linear-gradient(180deg, var(--navy), var(--blue-dark));
  color: white;
  transform: translateX(-105%);
  transition: transform .2s ease;
  overflow-y: auto;
}
.sidebar.is-open { transform: none; }
.side-brand { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 4px 6px 12px; }
.side-brand > span:nth-child(2) { min-width: 0; }
.side-mark {
  width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center;
  border-radius: var(--radius-sm); background: var(--orange); color: white; font-weight: 800;
}
.side-brand strong, .side-brand small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-brand small { margin-top: 2px; color: #cbd5e1; font-size: 12px; font-weight: 500; }
.side-close {
  margin-left: auto; width: 40px; height: 40px; flex: 0 0 40px; border: 0; border-radius: 10px;
  background: rgba(255,255,255,.12); color: white; font-size: 26px; line-height: 1;
}
.side-nav { display: grid; gap: 6px; }
.side-nav a {
  min-height: 46px; display: flex; align-items: center; padding: 0 12px; border-radius: var(--radius-sm);
  color: white; text-decoration: none; font-weight: 650; font-weight: 600; font-size: 14px;
  transition: background .15s ease;
}
.side-nav a:hover, .side-nav a.is-active { background: rgba(255,255,255,.14); }
.backdrop {
  position: fixed; inset: 0; z-index: 30; background: rgba(17, 29, 58, .48);
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.backdrop.is-open { opacity: 1; pointer-events: auto; }

.workspace { min-width: 0; max-width: 100%; min-height: 100vh; min-height: 100dvh; overflow-x: clip; }
.app-topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  min-height: var(--header); padding: 10px 14px; background: var(--paper);
  border-bottom: 3px solid var(--orange); box-shadow: var(--shadow);
}
.bar-title { min-width: 0; }
.bar-title strong, .bar-title small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-title strong { color: var(--text); font-size: 16px; }
.bar-title small { color: var(--muted); font-size: 12px; }
.menu-button {
  width: 44px; height: 44px; flex: 0 0 44px; display: grid; gap: 5px; place-content: center;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: white;
}
.menu-button span { width: 18px; height: 2px; background: var(--navy); }
.workspace-body {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 16px 16px 40px;
  min-width: 0;
  container-type: inline-size;
  container-name: panel;
}

.panel, .login-card, .stat-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}
.panel, .login-card { padding: 16px; }
.panel h2, .login-card h2 { margin: 0; color: var(--navy); font-size: clamp(18px, 2.4vw, 22px); }
.lead { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.panel-form { width: 100%; max-width: 100%; margin: 0; }

.stack { display: grid; gap: 12px; margin-top: 16px; min-width: 0; }
label { display: grid; gap: 6px; min-width: 0; color: var(--navy); font-size: 13px; font-weight: 700; }
input[type="text"], input[type="password"], input[type="number"], input[type="file"], select, textarea {
  width: 100%; min-width: 0; max-width: 100%; min-height: 46px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; background: #f8fafc;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .18); background: white; }
input[type="file"] { min-height: 0; padding: 10px; }

.calon {
  display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 12px; align-items: start;
  padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #f8fafc; min-width: 0;
}
.calon img { width: 88px; height: 112px; object-fit: cover; object-position: center top; border-radius: 10px; background: white; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.button, .button-link {
  min-height: 46px; border: 0; border-radius: var(--radius-sm); padding: 0 16px;
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  background: var(--blue); color: white; font-weight: 700; text-decoration: none;
  box-shadow: 0 6px 16px -8px rgba(37, 99, 235, .8);
  transition: transform .15s ease, filter .15s ease;
}
.button:hover, .button-link:hover { filter: brightness(1.05); }
.button.secondary, .button-link.secondary { color: var(--blue); background: var(--blue-soft); border: 1px solid #bfdbfe; box-shadow: none; }
.note { margin: 12px 0 0; font-size: 14px; font-weight: 700; line-height: 1.45; }
.note.ok { color: var(--ok); }
.note.bad { color: var(--danger); }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat-card { padding: 14px 16px; }
.stat-card span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.stat-card strong { display: block; margin-top: 6px; color: var(--navy); font-size: clamp(18px, 2vw, 24px); overflow-wrap: anywhere; }
.split { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(260px, .7fr); gap: 16px; margin-top: 16px; }
.calon-mini { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.calon-mini article { min-width: 0; text-align: center; }
.calon-mini img { width: 100%; aspect-ratio: 3 / 3.6; object-fit: cover; object-position: center top; border-radius: 12px; background: #f8fafc; }
.calon-mini strong { display: block; margin-top: 8px; font-size: 13px; }
.qr-panel { display: grid; justify-items: center; gap: 8px; text-align: center; }
.qr-panel img { width: min(100%, 220px); height: auto; background: white; border: 1px solid var(--line); border-radius: 12px; padding: 8px; }

.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ui-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.ui-table th, .ui-table td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.ui-table th { color: var(--muted); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.filters input, .filters select { width: min(100%, 240px); }

.login-body {
  background:
    radial-gradient(ellipse at 0 0, rgba(37, 99, 235, .16), transparent 46%),
    var(--bg);
}
.login-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
}
.login-hero {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: max(22px, env(safe-area-inset-top)) 18px 22px;
  color: white;
  background:
    radial-gradient(circle at 12% 0, rgba(245, 158, 11, .34), transparent 34%),
    linear-gradient(165deg, var(--navy), var(--blue-dark) 62%, #1d4ed8);
  border-radius: 0 0 24px 24px;
}
.login-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.login-mark {
  width: 46px; height: 46px; flex: 0 0 46px; display: grid; place-items: center;
  border-radius: 14px; background: var(--orange); color: white; font-weight: 800; font-size: 20px;
}
.login-brand strong { display: block; margin-top: 4px; font-size: 14px; }
.login-hero .badge {
  width: fit-content; padding: 3px 8px; border-radius: 999px;
  background: rgba(255,255,255,.14); color: white; font-size: 11px; font-weight: 800; letter-spacing: .06em;
}
.login-hero-copy { min-width: 0; }
.login-hero h1 {
  margin: 0; overflow-wrap: anywhere;
  font-size: clamp(28px, 8vw, 40px); line-height: 1.05; letter-spacing: -.03em;
}
.login-hero p { margin: 6px 0 0; color: #dbe4f5; font-size: 14px; line-height: 1.5; }
.login-panel {
  display: grid;
  align-items: start;
  min-width: 0;
  padding: 16px 16px max(28px, env(safe-area-inset-bottom));
}
.login-panel .login-card {
  width: min(100%, 420px);
  margin: 0 auto;
  padding: 22px 18px 18px;
  border: 0;
  box-shadow: 0 24px 50px -28px rgba(17, 29, 58, .55);
}
.login-card h2 { font-size: clamp(22px, 5vw, 28px); }
.login-card .stack { margin-top: 18px; }
.login-card .button { width: 100%; min-height: 48px; margin-top: 4px; }
.login-alert {
  margin: 14px 0 0; padding: 10px 12px; border-radius: 12px;
  background: #fef2f2; border: 1px solid #fecaca; color: var(--danger); font-size: 14px; font-weight: 700;
}
.login-back {
  display: inline-flex; margin-top: 16px; min-height: 44px; align-items: center;
  font-size: 14px; font-weight: 700; text-decoration: none;
}
.swal2-popup { width: min(32em, calc(100vw - 24px)) !important; }

@media (max-width: 991px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .calon-mini { grid-template-columns: 1fr; }
  .calon-mini { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 577px) and (max-width: 991px) {
  .login-body { display: grid; align-items: start; justify-items: center; padding: 28px 16px 36px; }
  .login-shell { width: min(100%, 480px); min-height: 0; }
  .login-hero { width: 100%; margin: 0; padding-bottom: 22px; border-radius: 24px; }
  .login-panel { width: 100%; margin: 0; padding: 12px 0 0; }
  .login-panel .login-card { width: 100%; }
}
@media (max-width: 576px) {
  .stat-grid, .calon-mini { grid-template-columns: 1fr; }
  .calon { grid-template-columns: 1fr; }
  .calon img { width: min(100%, 160px); height: 200px; }
  .actions { display: grid; }
  .button, .button-link { width: 100%; }
  .workspace-body { padding-inline: 12px; }
  .panel { padding: 14px; }
  .login-hero h1 { font-size: 30px; }
  .login-panel { padding-inline: 12px; }
  .login-panel .login-card { width: 100%; padding: 20px 16px 16px; }
  .filters { display: grid; }
  .filters input, .filters select { width: 100%; }
  .ui-table { min-width: 0; }
  .ui-table thead { display: none; }
  .ui-table, .ui-table tbody, .ui-table tr, .ui-table td { display: block; width: 100%; }
  .ui-table tr { margin-bottom: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
  .ui-table td { border: 0; padding: 6px 8px; }
  .ui-table td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 11px; font-weight: 700; }
}

@media (min-width: 992px) {
  .login-body {
    display: grid;
    align-items: center;
    justify-items: center;
    padding: 24px 16px;
    background:
      radial-gradient(ellipse at 0 0, rgba(37, 99, 235, .14), transparent 42%),
      var(--bg);
  }
  .login-shell {
    width: min(100%, 1040px);
    min-height: min(560px, calc(100dvh - 48px));
    align-content: stretch;
    grid-template-columns: minmax(0, 1.05fr) minmax(320px, 420px);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 28px 70px -36px rgba(17, 29, 58, .6);
  }
  .login-hero {
    justify-content: center;
    gap: 28px;
    min-height: 0;
    padding: 40px 36px;
    border-radius: 0;
    background:
      radial-gradient(circle at 18% 16%, rgba(245, 158, 11, .32), transparent 28%),
      linear-gradient(165deg, var(--navy), var(--blue-dark) 55%, #1d4ed8);
  }
  .login-hero h1 { max-width: 12ch; font-size: clamp(36px, 4vw, 52px); }
  .login-hero p { max-width: 34ch; font-size: 16px; }
  .login-panel {
    align-items: center;
    padding: 32px 28px;
    background: white;
  }
  .login-panel .login-card { width: 100%; max-width: none; margin: 0; padding: 0; border: 0; box-shadow: none; background: transparent; }
  .sidebar { transform: none; width: var(--side); }
  .side-close, .backdrop, .menu-button { display: none; }
  .workspace { margin-left: var(--side); }
  .workspace-body { padding: 24px 28px 48px; }
}

@container panel (min-width: 900px) {
  form.stack { grid-template-columns: 1fr 1fr; column-gap: 16px; }
  form.stack > .calon,
  form.stack > .actions,
  form.stack > label:has([name="kode"]),
  form.stack > label:has([name="logo"]),
  form.stack > label:has([name="lembar"]),
  form.stack > label:has([name="password_baru"]) { grid-column: 1 / -1; }
}
@container panel (max-width: 860px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .calon-mini { grid-template-columns: 1fr; }
  .calon-mini { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container panel (max-width: 560px) {
  .stat-grid, .calon-mini, .calon { grid-template-columns: 1fr; }
  .actions { display: grid; }
  .button, .button-link { width: 100%; }
}

@media print {
  .sidebar, .backdrop, .app-topbar, .menu-button, .no-print { display: none !important; }
  .workspace { margin: 0 !important; }
  body { background: white; overflow: visible; }
}
