:root {
  --brand: #c8102e;
  --brand-ink: #9e0c24;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #1d2128;
  --muted: #6b7280;
  --line: #e4e6ea;
  --ok: #157347;
  --ok-bg: #e7f6ee;
  --warn: #9a6700;
  --warn-bg: #fff4d6;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --info: #1f5fbf;
  --info-bg: #e8f0fd;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.04);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--brand-ink); }
h1 { font-size: 1.5rem; margin: 0.2rem 0; line-height: 1.25; }
h2 { font-size: 1.05rem; margin: 0; }
h3 { font-size: 0.95rem; margin: 1.25rem 0 0.5rem; }
p { margin: 0.4rem 0; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; }
.code, .code-title { font-variant-numeric: tabular-nums; letter-spacing: 0.01em; font-weight: 700; }
.label-en { color: var(--muted); font-weight: 500; }

/* Topbar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 0 16px; height: 58px; display: flex; align-items: center; gap: 20px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--ink); text-decoration: none; }
.logo-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: #fff; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.04em; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; white-space: nowrap; }
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.active { color: var(--brand-ink); background: color-mix(in srgb, var(--brand) 9%, white); }
.userbox { display: flex; align-items: center; gap: 10px; }
.userbox form { margin: 0; }
.user-name { color: var(--ink); text-decoration: none; font-weight: 600; display: flex; gap: 6px; align-items: center; }
.role { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 2px 7px; border-radius: 99px; background: var(--bg); color: var(--muted); font-weight: 700; }
.role-admin { background: color-mix(in srgb, var(--brand) 12%, white); color: var(--brand-ink); }

.container { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back { font-size: 0.85rem; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--ink); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; font-size: 0.9rem;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #c9cdd4; background: #fafafa; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid color-mix(in srgb, var(--brand) 55%, white); outline-offset: 1px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn-warn { background: var(--warn-bg); border-color: #f0d48a; color: var(--warn); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-ghost { color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: 0.82rem; }
button.link { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 4px; }
button.link:hover { color: var(--ink); text-decoration: underline; }
form.inline { display: inline; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; }
.card.internal { border-style: dashed; background: #fcfcfd; }
.card.callout { border-color: color-mix(in srgb, var(--brand) 30%, white); }

/* Forms */
.stack { display: grid; gap: 12px; }
.narrow { max-width: 420px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.span-2 { grid-column: 1 / -1; }
.field { display: grid; gap: 4px; align-content: start; }
.field label { font-weight: 600; font-size: 0.85rem; }
.req { color: var(--danger); }
.hint { font-size: 0.78rem; color: var(--muted); }
input, select, textarea {
  width: 100%; font: inherit; font-size: 0.95rem; color: var(--ink);
  padding: 9px 11px; border: 1px solid #d3d7de; border-radius: 8px; background: #fff;
}
textarea { resize: vertical; }
input[type="color"] { padding: 3px; height: 40px; }
input[type="checkbox"] { width: auto; }
input[disabled] { background: var(--bg); color: var(--muted); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; font-size: 0.9rem; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 0.8rem; font-weight: 600; }
.computed-value { padding: 9px 11px; border: 1px dashed #d3d7de; border-radius: 8px; color: var(--muted); font-weight: 700; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 18px 0 8px; }
.guest-list { display: grid; gap: 8px; margin: 8px 0; }
.guest-row { display: flex; gap: 6px; }
.suggest:empty { display: none; }
.suggest-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px; background: var(--info-bg); border-radius: 8px; }
.suggest-item { border: 1px solid #c9d8f5; background: #fff; border-radius: 99px; padding: 5px 12px; cursor: pointer; font: inherit; font-size: 0.85rem; }
.suggest-item:hover { border-color: var(--info); }

/* Filters + tables */
.filters { display: grid; grid-template-columns: 2fr repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card .table-wrap { border: 0; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr[data-href] { cursor: pointer; }
.table tr[data-href]:hover td { background: #fafbfc; }
.table a { text-decoration: none; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

/* Badges */
.badge { display: inline-block; font-size: 0.75rem; font-weight: 700; padding: 2px 9px; border-radius: 99px; white-space: nowrap; vertical-align: middle; }
.st-draft { background: #eef0f3; color: #4b5563; }
.st-active { background: var(--ok-bg); color: var(--ok); }
.st-redeemed { background: var(--info-bg); color: var(--info); }
.st-expired { background: var(--warn-bg); color: var(--warn); }
.st-cancelled { background: var(--danger-bg); color: var(--danger); }
.pay-unpaid { background: var(--danger-bg); color: var(--danger); }
.pay-dp { background: var(--warn-bg); color: var(--warn); }
.pay-paid { background: var(--ok-bg); color: var(--ok); }
.pay-refunded { background: #eef0f3; color: #4b5563; }

/* Flash */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 600; font-size: 0.92rem; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--danger-bg); color: var(--danger); }

/* Detail */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.detail-side { position: sticky; top: 74px; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 8px 14px; margin: 0; }
.kv dt { color: var(--muted); font-size: 0.85rem; }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }
.status-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.inline-details { display: inline-block; margin-bottom: 12px; }
.inline-details > summary { list-style: none; }
.inline-details > summary::-webkit-details-marker { display: none; }
.inline-details[open] > form { margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-width: min(360px, 80vw); }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.event { border-left: 3px solid var(--line); padding: 2px 0 2px 12px; }
.event-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.ev-issued, .ev-issue_override { border-color: var(--ok); }
.ev-redeemed, .ev-auto_status { border-color: var(--info); }
.ev-cancelled { border-color: var(--danger); }
.ev-reverted, .ev-issue_override { border-color: var(--warn); }
.ev-verified, .ev-downloaded { opacity: 0.75; }
.changes { margin: 4px 0 0; padding-left: 18px; font-size: 0.85rem; }
.sheet-frame { position: relative; width: 100%; aspect-ratio: 540 / 763.5; overflow: hidden; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.sheet-frame iframe { position: absolute; top: 0; left: 0; width: 540px; height: 763.5px; border: 0; transform-origin: 0 0; }
.download-row, .share-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 6px; }
.copy-row { display: flex; gap: 6px; }
.copy-row input { font-size: 0.82rem; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.logo-preview { max-height: 60px; max-width: 200px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; }

/* Halaman tanpa login + publik */
.bare-main { max-width: 460px; margin: 0 auto; padding: 40px 16px; }
.bare-main.wide { max-width: 620px; }
.auth-card, .pub-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 24px; }
.auth-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; margin-bottom: 14px; }
.error-page { text-align: center; padding: 40px 0; }
.error-code { font-size: 3rem; font-weight: 800; color: var(--brand); }
.pub-header { display: flex; align-items: center; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.pub-logo { height: 44px; max-width: 120px; object-fit: contain; }
.pub-brand { font-weight: 800; font-size: 1.1rem; }
.pub-sub { font-size: 0.75rem; color: var(--brand); letter-spacing: 0.12em; text-transform: uppercase; font-weight: 800; }
.verify-status { border-radius: 12px; padding: 16px; margin-bottom: 18px; text-align: center; }
.vs-label { font-size: 1.6rem; font-weight: 800; }
.vs-en { font-size: 1rem; font-weight: 600; opacity: 0.75; }
.vs-note { font-weight: 600; }
.vs-note.en { font-style: italic; font-weight: 500; opacity: 0.85; }
.vs-active { background: var(--ok-bg); color: var(--ok); }
.vs-redeemed { background: var(--info-bg); color: var(--info); }
.vs-expired { background: var(--warn-bg); color: var(--warn); }
.vs-cancelled { background: var(--danger-bg); color: var(--danger); }
.pub-kv { grid-template-columns: 150px 1fr; }
.pub-foot { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.client-page { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.client-title { font-size: 1.25rem; }

@media (max-width: 900px) {
  .detail-grid, .settings-grid { grid-template-columns: 1fr; }
  .detail-side { position: static; order: -1; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters input[type="search"] { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .topbar-inner { gap: 10px; }
  .logo span:last-child { display: none; }
  .user-name { display: none; }
  .nav a { padding: 8px; }
  .form-grid { grid-template-columns: 1fr; }
  .kv, .pub-kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .container { padding-top: 14px; }
  .table th:nth-child(3), .table td:nth-child(3) { display: none; }
}

/* Builder tipe voucher */
.frow { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-top: 10px; background: #fcfcfd; display: grid; gap: 10px; }
.frow-main { display: grid; grid-template-columns: 1fr 1fr 180px; gap: 10px; }
.frow-opts { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.frow-type { padding: 8px 0; font-weight: 600; }
.frow-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.frow-only-select, .frow-only-date { display: none; }
.frow[data-type="select"] .frow-only-select, .frow[data-type="date"] .frow-only-date { display: block; }
.btn.danger { color: #b91c1c; }
.form-actions { display: flex; gap: 8px; }
.row-actions { white-space: nowrap; }
.preview-narrow { max-width: 360px; }
.flash ul { margin: 6px 0 0 18px; }
@media (max-width: 720px) { .frow-main { grid-template-columns: 1fr; } }
