/* =====================================================================
   PANEL ADMIN — Survei Poltesa
   ===================================================================== */
:root {
  --navy: #0a2559; --blue: #0b57d0; --blue-600: #0a4bb5; --blue-50: #eef4ff; --blue-100: #dbe7ff;
  --yellow: #f6b90b; --ink: #101a30; --ink-2: #48546d; --ink-3: #7d88a0; --line: #e4e9f2;
  --bg: #f3f6fb; --card: #fff; --green: #15935b; --red: #d33a3a; --amber: #c27c00;
  --shadow: 0 1px 2px rgba(16, 26, 48, .05), 0 4px 16px rgba(16, 26, 48, .05);
  --shadow-lg: 0 20px 50px rgba(16, 26, 48, .18);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --side: 258px;
  --blue-rgb: 11 87 208; --yellow-rgb: 246 185 11; --navy-rgb: 10 37 89;
  --blue-400: #4b93ff; --blue-700: #0b3f99; --blue-200: #c7d9fb; --navy-2: #0b2f6f; --yellow-300: #ffd85a; --yellow-50: #fff7dc; --yellow-800: #8a6400; --accent-ink: #0a2559;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.5; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; letter-spacing: -.01em; }
p { margin: 0 0 .8rem; }
[hidden] { display: none !important; }
code { background: #eef1f7; padding: .1rem .35rem; border-radius: 5px; font-size: .86em; }
.muted { color: var(--ink-3); } .small { font-size: .84rem; }
svg { flex: 0 0 auto; }

/* ---------- Layout ---------- */
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side); background: linear-gradient(180deg, var(--navy), var(--navy-2)); color: #c8d4ee;
  display: flex; flex-direction: column; z-index: 40; transition: transform .25s;
}
.side-brand { display: flex; gap: .7rem; align-items: center; padding: 1.1rem 1.1rem 1rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.side-brand img { width: 38px; height: 38px; }
.side-brand b { color: #fff; display: block; font-size: .95rem; }
.side-brand span { font-size: .72rem; color: #9fb0d4; }
.side nav { padding: .8rem .7rem; overflow-y: auto; flex: 1; }
.side .sec { font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: #7f93bd; font-weight: 800; padding: .9rem .7rem .4rem; }
.side nav a { display: flex; align-items: center; gap: .7rem; padding: .62rem .75rem; border-radius: 10px; color: #c8d4ee; font-weight: 600; font-size: .9rem; margin-bottom: 2px; }
.side nav a svg { width: 18px; height: 18px; opacity: .85; }
.side nav a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.side nav a.active { background: #fff; color: var(--navy); box-shadow: 0 6px 16px rgba(0,0,0,.18); }
.side nav a.active svg { color: var(--blue); opacity: 1; }
.side-foot { padding: .9rem 1rem; border-top: 1px solid rgba(255,255,255,.08); font-size: .8rem; }
.side-foot .who { display: flex; gap: .6rem; align-items: center; margin-bottom: .6rem; }
.avatar { width: 34px; height: 34px; border-radius: 10px; background: var(--yellow); color: var(--navy); display: grid; place-items: center; font-weight: 800; flex: 0 0 auto; }
.side-foot b { color: #fff; display: block; font-size: .85rem; }
.side-foot form button { width: 100%; }
.main { margin-left: var(--side); min-height: 100vh; display: flex; flex-direction: column; }
.topnav { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .8rem; padding: .7rem 1.4rem; background: rgba(243,246,251,.88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topnav h1 { font-size: 1.15rem; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topnav .crumb { font-size: .76rem; color: var(--ink-3); display: block; font-weight: 600; }
.menu-btn { display: none; }
.content { padding: 1.4rem; flex: 1; max-width: 1360px; width: 100%; }
.scrim { display: none; }

/* ---------- Komponen ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; font: inherit; font-weight: 700; font-size: .88rem; padding: .58rem 1rem; border-radius: 10px; border: 1px solid transparent; cursor: pointer; min-height: 40px; white-space: nowrap; text-decoration: none !important; transition: background .15s, box-shadow .15s; }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 4px 12px rgb(var(--blue-rgb) / .25); }
.btn-primary:hover { background: var(--blue-600); }
.btn-accent { background: var(--yellow); color: var(--accent-ink, var(--navy)); }
.btn-ghost { background: #fff; color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { border-color: #c9d2e3; background: #fafbfe; }
.btn-danger { background: #fff; color: var(--red); border-color: #f3c9c9; }
.btn-danger:hover { background: #fdeceb; }
.btn-sm { min-height: 32px; padding: .32rem .65rem; font-size: .8rem; border-radius: 8px; }
.btn-icon { width: 36px; padding: 0; min-height: 36px; }
.btn:focus-visible, .input:focus-visible { outline: 3px solid rgb(var(--yellow-rgb) / .6); outline-offset: 1px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 1.2rem; margin-bottom: 1rem; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card-head h2 { font-size: 1.05rem; margin: 0; }
.grid { display: grid; gap: 1rem; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 1.1rem; box-shadow: var(--shadow); display: flex; gap: .9rem; align-items: center; }
.stat .ic { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; background: var(--blue-50); color: var(--blue); }
.stat .ic svg { width: 22px; height: 22px; }
.stat.y .ic { background: var(--yellow-50); color: var(--yellow-800); } .stat.g .ic { background: #e6f6ee; color: var(--green); } .stat.r .ic { background: #f3eaff; color: #7c4dff; }
.stat small { display: block; color: var(--ink-3); font-weight: 700; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; }
.stat b { font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; }

.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 800; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.b-green { background: #e6f6ee; color: #11804e; } .b-blue { background: var(--blue-50); color: var(--blue); }
.b-amber { background: #fff3d6; color: #a86a00; } .b-red { background: #fdeceb; color: #c02f2f; } .b-gray { background: #eef1f6; color: #55607a; }

/* Tabel */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 12px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .86rem; }
.tbl th, .tbl td { padding: .7rem .8rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tbl th { background: #f6f8fc; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); white-space: nowrap; }
.tbl tbody tr:hover td { background: #fafbfe; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.num, .tbl th.num { text-align: center; }
.tbl td.actions { white-space: nowrap; text-align: right; }
.tbl .t-title { font-weight: 700; color: var(--ink); display: block; }
.tbl .t-sub { font-size: .78rem; color: var(--ink-3); }
.progress { height: 7px; border-radius: 999px; background: #eef1f6; overflow: hidden; min-width: 90px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--blue-400)); border-radius: inherit; }

/* Form */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.1rem; }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > label, .lbl { font-weight: 700; font-size: .84rem; color: var(--ink); }
.hint { font-size: .78rem; color: var(--ink-3); }
.input, .select, .textarea { font: inherit; font-size: .92rem; width: 100%; padding: .6rem .8rem; border: 1px solid #d6dde9; border-radius: 10px; background: #fff; color: var(--ink); min-height: 42px; transition: border-color .15s, box-shadow .15s; }
.textarea { min-height: 90px; resize: vertical; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%237d88a0' stroke-width='2'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7rem center; padding-right: 2.2rem; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgb(var(--blue-rgb) / .13); }
.switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; font-weight: 600; font-size: .88rem; user-select: none; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: #cdd5e3; position: relative; cursor: pointer; transition: background .2s; flex: 0 0 auto; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked { background: var(--blue); }
.switch input:checked::after { transform: translateX(16px); }
.switch input:focus-visible { outline: 3px solid rgb(var(--yellow-rgb) / .6); }
.toggles { display: grid; gap: .8rem; }
.section-title { font-size: .76rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin: 1.4rem 0 .8rem; display: flex; align-items: center; gap: .6rem; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.form-actions { display: flex; gap: .6rem; justify-content: flex-end; position: sticky; bottom: 0; background: rgba(243,246,251,.92); backdrop-filter: blur(8px); padding: .9rem 0; margin-top: 1rem; border-top: 1px solid var(--line); z-index: 5; }

/* Biodata config table */
.bio-tbl td { padding: .45rem .6rem; }
.bio-tbl .input { min-height: 36px; padding: .4rem .6rem; font-size: .85rem; }

/* Pilih survei dalam paket */
.pick-list { display: grid; gap: .5rem; }
.pick { display: grid; grid-template-columns: auto 1fr auto; gap: .8rem; align-items: center; padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.pick.on { border-color: var(--blue-200); background: var(--blue-50); }
.pick input[type=checkbox] { width: 19px; height: 19px; accent-color: var(--blue); }
.pick b { display: block; font-size: .9rem; }
.pick small { color: var(--ink-3); }
.pick .ord { display: flex; gap: .25rem; }

/* Question builder */
.qb { display: grid; gap: .7rem; }
.qb-item { border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: .9rem; display: grid; grid-template-columns: 34px 1fr auto; gap: .8rem; align-items: start; transition: box-shadow .15s, border-color .15s; }
.qb-item:focus-within { border-color: var(--blue-200); box-shadow: 0 0 0 3px rgb(var(--blue-rgb) / .08); }
.qb-no { width: 34px; height: 34px; border-radius: 10px; background: var(--blue-50); color: var(--blue); font-weight: 800; display: grid; place-items: center; font-size: .85rem; }
.qb-body { display: grid; gap: .55rem; min-width: 0; }
.qb-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr) auto; gap: .55rem; align-items: center; }
.qb-tools { display: flex; flex-direction: column; gap: .3rem; }
.qb-empty { text-align: center; padding: 2rem; border: 2px dashed var(--line); border-radius: 14px; color: var(--ink-3); }
.qb-bar { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .8rem; }

/* Alert & flash */
.alert { display: flex; gap: .7rem; align-items: flex-start; padding: .85rem 1rem; border-radius: 12px; margin-bottom: 1rem; font-size: .9rem; font-weight: 600; border: 1px solid; }
.alert svg { width: 19px; height: 19px; margin-top: 1px; }
.alert-success { background: #e9f8f0; color: #0f6e43; border-color: #bfe8d3; }
.alert-error { background: #fdeeee; color: #a42828; border-color: #f4c7c7; }
.alert-info { background: var(--blue-50); color: var(--blue-700); border-color: var(--blue-200); }
.alert-warn { background: #fff7e0; color: #855c00; border-color: #f4dc9c; }

/* Link berbagi */
.share { display: flex; gap: .5rem; align-items: center; background: #f6f8fc; border: 1px dashed #c6d1e6; border-radius: 12px; padding: .45rem .45rem .45rem .8rem; min-width: 0; }
.share code { background: none; padding: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .84rem; color: var(--blue); }
.qr-box { display: grid; place-items: center; gap: .8rem; text-align: center; }
.qr-box canvas, .qr-box img { width: 220px; height: 220px; image-rendering: pixelated; border: 10px solid #fff; border-radius: 12px; box-shadow: var(--shadow); }

/* Filter bar */
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.filters .field { min-width: 150px; flex: 1 1 150px; }
.filters .field.grow { flex: 2 1 220px; }

.pagination { display: flex; gap: .35rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; border: 1px solid var(--line); background: #fff; font-weight: 700; font-size: .84rem; color: var(--ink-2); padding: 0 .6rem; }
.pagination .cur { background: var(--blue); color: #fff; border-color: var(--blue); }

.empty-state { text-align: center; padding: 2.6rem 1rem; color: var(--ink-3); }
.empty-state svg { width: 42px; height: 42px; margin-bottom: .6rem; color: #b9c3d6; }

/* Modal */
dialog { border: 0; border-radius: 18px; padding: 0; box-shadow: var(--shadow-lg); width: min(560px, 94vw); max-height: 88vh; color: var(--ink); }
dialog::backdrop { background: rgba(10, 20, 45, .45); backdrop-filter: blur(2px); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.dlg-head h3 { margin: 0; font-size: 1rem; }
.dlg-body { padding: 1.2rem; overflow-y: auto; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: .4rem .9rem; font-size: .88rem; }
.kv dt { color: var(--ink-3); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }

/* Login */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: #fff; }
.login-art { background: radial-gradient(700px 400px at 80% 0%, rgb(var(--yellow-rgb) / .35), transparent 60%), linear-gradient(140deg, var(--navy), var(--blue)); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art::after { content: ""; position: absolute; inset: 0; opacity: .12; background-image: radial-gradient(#fff 1px, transparent 1px); background-size: 22px 22px; }
.login-art > * { position: relative; z-index: 1; }
.login-art h1 { font-size: 2.2rem; font-weight: 800; max-width: 16ch; }
.login-art p { color: rgba(255,255,255,.8); max-width: 44ch; }
.login-form { display: grid; place-items: center; padding: 2rem 1.2rem; }
.login-form form { width: min(380px, 100%); display: grid; gap: 1rem; }
.login-form h2 { font-size: 1.5rem; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 3rem; }
.pw-wrap button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--ink-3); cursor: pointer; padding: .5rem; }

/* Toast */
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 100; display: grid; gap: .5rem; }
.toast { background: var(--navy); color: #fff; padding: .7rem 1rem; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 600; font-size: .86rem; }

/* Laporan admin */
.report-bar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.live { display: inline-flex; align-items: center; gap: .45rem; font-size: .76rem; font-weight: 800; padding: .3rem .7rem; border-radius: 999px; background: #e6f6ee; color: #11804e; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: #22c07a; animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.print-head { display: none; }

/* ---------- Responsif ---------- */
@media (max-width: 1100px) { .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .side { transform: translateX(-100%); }
  body.nav-open .side { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10,20,45,.4); z-index: 35; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .content { padding: 1rem; }
  .topnav { padding: .6rem 1rem; }
  .g-3, .g-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .login-page { grid-template-columns: 1fr; }
  .login-art { padding: 1.6rem; min-height: 200px; }
  .login-art h1 { font-size: 1.5rem; }
  .qb-row { grid-template-columns: 1fr 1fr; }
  .qb-row > :first-child { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .g-4 { grid-template-columns: 1fr 1fr; }
  .stat { padding: .85rem; gap: .6rem; }
  .stat .ic { width: 38px; height: 38px; }
  .stat b { font-size: 1.25rem; }
  .qb-item { grid-template-columns: 1fr; }
  .qb-no { display: none; }
  .qb-tools { flex-direction: row; justify-content: flex-end; }
  .kv { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}

@media print {
  .side, .topnav, .no-print, .form-actions, .scrim, .toasts { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; font-size: 10.5pt; }
  .print-head { display: flex; gap: 1rem; align-items: center; border-bottom: 3px double #333; padding-bottom: .7rem; margin-bottom: 1rem; }
  .print-head img { width: 64px; height: 64px; }
  .print-head h1 { font-size: 15pt; margin: 0; }
  .print-head p { margin: 0; font-size: 10pt; }
  .print-sign { display: grid !important; grid-template-columns: 1fr 260px; margin-top: 2rem; break-inside: avoid; }
  @page { size: A4; margin: 14mm; }
}
.print-sign { display: none; }
.report-bar .select { max-width: 100%; }
@media (max-width: 560px) { .report-bar .btn-row { width: 100%; } .report-bar .select { flex: 1 1 100%; } }
