:root {
  --bg: #f6f3ee;
  --panel: #ffffff;
  --ink: #2b2622;
  --ink-soft: #6b625a;
  --muted: #9a9087;
  --line: #e8e2d9;
  --gold: #b8924a;
  --gold-soft: #f5ecdc;
  --ok: #2f8a57;
  --ok-soft: #e6f4ec;
  --danger: #c0443a;
  --danger-soft: #fbe9e7;
  --radius: 14px;
  --sans: "Plus Jakarta Sans", system-ui, sans-serif;
  --serif: "Cormorant Garamond", Georgia, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 14.5px; line-height: 1.55; font-variant-numeric: lining-nums; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--ink); color: #efe9e1; padding: 22px 14px; display: flex; flex-direction: column; gap: 4px;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; font-family: var(--serif); font-size: 1.45rem; font-weight: 700; }
.side-brand small { display: block; font-family: var(--sans); font-size: .68rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.mark { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, #d9b877, var(--gold)); color: #fff; font-size: 1.1rem; flex: none; }
.side-label { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: #8d847b; padding: 16px 12px 6px; }
.side a, .side .soon {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: #cfc6bc; font-weight: 500;
}
.side a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side a.active { background: rgba(217, 184, 119, .16); color: #fff; }
.side .soon { opacity: .45; cursor: default; }
.side .soon em { margin-left: auto; font-style: normal; font-size: .64rem; padding: 2px 7px; border-radius: 99px; background: rgba(255, 255, 255, .1); }
.side-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, .08); }

.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 14px 28px; background: rgba(246, 243, 238, .85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.05rem; font-weight: 700; }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; border: 1px solid var(--line); background: #fff; border-radius: 10px; width: 38px; height: 38px; cursor: pointer; }
.content { padding: 28px; max-width: 1100px; }

/* ---------- komponen ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; font-weight: 600; font-size: .88rem; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .15s;
}
.btn:hover { border-color: #d6cdc1; background: #fdfbf8; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #3d3631; border-color: #3d3631; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: #f0c5c0; }
.btn-sm { padding: 6px 11px; font-size: .8rem; border-radius: 8px; }
.btn-icon { width: 32px; height: 32px; padding: 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 22px; }
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 1rem; font-weight: 700; }
.card-head p { color: var(--ink-soft); font-size: .85rem; }
.card-head .spacer { flex: 1; }

.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 18px; font-weight: 500; }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-err { background: var(--danger-soft); color: var(--danger); }
.alert-err ul { margin: 6px 0 0 18px; font-weight: 400; }

.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--bg); color: var(--ink-soft); }
.badge-on { background: var(--ok-soft); color: var(--ok); }
.badge-gold { background: var(--gold-soft); color: #8a6a2c; }
.muted { color: var(--ink-soft); }

/* statistik dashboard */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-grid .card { padding: 18px 20px; }
.stat-grid b { display: block; font-size: 1.7rem; font-family: var(--serif); }
.stat-grid span { color: var(--ink-soft); font-size: .85rem; }

/* daftar bagian home */
.section-list { display: grid; gap: 12px; }
.section-row { display: flex; align-items: center; gap: 16px; padding: 16px 20px; }
.section-row .num { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--gold-soft); color: #8a6a2c; font-weight: 700; flex: none; }
.section-row h3 { font-size: .98rem; }
.section-row p { color: var(--ink-soft); font-size: .85rem; }
.section-row .grow { flex: 1; min-width: 0; }
.section-row .actions { display: flex; gap: 8px; align-items: center; }

/* ---------- form ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > label, .field-label { font-weight: 600; font-size: .84rem; }
.field .hint { color: var(--muted); font-size: .78rem; }
.field .error { color: var(--danger); font-size: .8rem; }
.input, textarea.input, select.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 84px; resize: vertical; }
.input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(184, 146, 74, .15); }
.input.is-invalid { border-color: var(--danger); }
.color-field { display: flex; gap: 8px; }
.color-field input[type=color] { width: 46px; height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: #fff; cursor: pointer; flex: none; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }
.form-actions {
  position: sticky; bottom: 0; z-index: 10; display: flex; gap: 10px; align-items: center;
  padding: 14px 0; margin-top: 18px; background: linear-gradient(transparent, var(--bg) 30%);
}

/* gambar */
.image-field { display: flex; gap: 12px; align-items: center; }
.image-preview {
  width: 64px; height: 64px; border-radius: 12px; border: 1px dashed #d6cdc1; background: var(--bg) center/cover no-repeat;
  display: grid; place-items: center; color: var(--muted); font-size: .7rem; flex: none;
}
.image-field .stack { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.image-field input[type=file] { font-size: .8rem; max-width: 100%; }

/* ---------- repeater ---------- */
.repeater { display: grid; gap: 12px; }
.rep-item { border: 1px solid var(--line); border-radius: 12px; background: #fdfcfa; }
.rep-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.rep-head .handle { cursor: grab; color: var(--muted); padding: 0 4px; font-size: 1.1rem; user-select: none; }
.rep-head .title { flex: 1; min-width: 0; font-weight: 600; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rep-body { padding: 14px; }
.rep-item.sortable-ghost { opacity: .4; }
.rep-empty { padding: 26px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; }
.rep-foot { display: flex; align-items: center; gap: 12px; margin-top: 14px; }

/* ---------- icon picker ---------- */
.icon-picker { display: flex; gap: 12px; align-items: flex-start; }
.icon-preview {
  width: 58px; height: 58px; border-radius: 16px; background: #f3ebdd; display: grid; place-items: center; font-size: 1.7rem; flex: none;
}
.icon-preview img { width: 32px; height: 32px; object-fit: contain; }
.icon-controls { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--bg); align-self: flex-start; }
.seg label { padding: 5px 12px; border-radius: 8px; cursor: pointer; font-size: .8rem; font-weight: 600; color: var(--ink-soft); }
.seg input { display: none; }
.seg input:checked + span { color: var(--ink); }
.seg label:has(input:checked) { background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.emoji-row { display: flex; gap: 8px; }
.emoji-row .input { width: 90px; text-align: center; font-size: 1.1rem; }
.emoji-grid {
  display: none; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 4px; padding: 8px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; max-width: 420px;
}
.emoji-grid.open { display: grid; }
.emoji-grid button { border: 0; background: none; font-size: 1.3rem; padding: 4px; border-radius: 8px; cursor: pointer; }
.emoji-grid button:hover { background: var(--bg); }
.icon-picker [data-mode] { display: none; flex-direction: column; gap: 8px; }
.icon-picker[data-type=emoji] [data-mode=emoji], .icon-picker[data-type=image] [data-mode=image] { display: flex; }

/* ---------- tabel ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; background: #fcfaf7; }
tr:last-child td { border-bottom: 0; }
td .actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(circle at 80% 10%, #f3dcd8, transparent 40%), var(--bg); }
.auth-card { width: min(400px, 100%); padding: 32px; }
.auth-card h1 { font-family: var(--serif); font-size: 2rem; margin: 18px 0 4px; }
.auth-card form { display: grid; gap: 16px; margin-top: 24px; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .25s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
  .menu-btn { display: grid; place-items: center; }
  .content { padding: 20px 16px; }
  .topbar { padding: 12px 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .section-row { flex-wrap: wrap; }
  .section-row .actions { width: 100%; justify-content: flex-end; }
  .topbar .btn-view { display: none; }
}

/* item bisa dilipat: klik judul */
.rep-head .title { cursor: pointer; }
.rep-head .title::before { content: "▾"; display: inline-block; margin-right: 6px; color: var(--muted); transition: transform .15s; }
.rep-item.collapsed .rep-head { border-bottom: 0; }
.rep-item.collapsed .rep-head .title::before { transform: rotate(-90deg); }
.rep-item.collapsed .rep-body { display: none; }
.rep-head .preview-icon { font-size: 1.1rem; line-height: 1; }
.rep-head .preview-icon img { width: 20px; height: 20px; object-fit: contain; vertical-align: middle; }
@media (max-width: 640px) {
  .card-pad { padding: 14px; }
  .rep-head { gap: 4px; padding: 8px; }
  .rep-head [data-no] { display: none; }
  .rep-head .btn-danger { padding: 6px 8px; }
  .rep-body { padding: 12px; }
}
.sm-only { display: none; }
@media (max-width: 640px) { .lg-only { display: none; } .sm-only { display: inline; } }

/* jarak antar-kartu hanya untuk kartu yang bertumpuk, bukan di dalam grid */
:is(.stat-grid, .reseller-cards, .inv-grid, .section-list, .order-wrap) > .card + .card { margin-top: 0; }

/* ---------- login Google ---------- */
.btn-google { width: 100%; padding: 12px; gap: 10px; background: #fff; border: 1px solid var(--line); margin-top: 20px; }
.btn-google:hover { background: #fafafa; }
.or-line { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .8rem; margin: 14px 0 0; }
.or-line::before, .or-line::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- tema undangan ---------- */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.theme-tile { overflow: hidden; display: flex; flex-direction: column; }
.theme-tile.is-off .theme-card-mini { filter: grayscale(.8); opacity: .6; }
.theme-card-mini {
  position: relative; display: grid; place-items: center; aspect-ratio: 4 / 3; text-decoration: none; text-align: center;
  font-family: "Cormorant Garamond", serif; font-size: 1.5rem; font-weight: 700; line-height: 1.1;
}
.theme-card-mini em { position: absolute; bottom: 8px; right: 10px; font: 600 .72rem/1 "Plus Jakarta Sans", sans-serif; font-style: normal; padding: 5px 9px; border-radius: 99px; background: rgba(255, 255, 255, .85); color: #2b2622; opacity: 0; transition: opacity .2s; }
.theme-card-mini:hover em { opacity: 1; }
.theme-tile-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 4px; }
.image-preview[style*="gradient"] { font-size: .75rem; }
.theme-tile .actions { display: flex; gap: 6px; }
.theme-tile .error { color: var(--danger); font-size: .78rem; }
.theme-grid > .card { margin: 0; }

/* ---------- pustaka musik ---------- */
.song-row { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(200px, 1fr) auto auto auto; gap: 12px; align-items: center; padding: 12px 16px; }
.song-meta { display: grid; grid-template-columns: 1.3fr 1fr .8fr; gap: 6px; }
.song-meta .input { padding: 7px 10px; font-size: .85rem; }
.song-row audio { width: 100%; height: 36px; }
@media (max-width: 1000px) { .song-row { grid-template-columns: 1fr; } .song-meta { grid-template-columns: 1fr; } }
.song-row { grid-template-columns: minmax(0, 2fr) minmax(180px, 1fr) auto auto auto; }
.song-meta { grid-template-columns: 1fr 1fr; }
.song-meta .input:first-child { grid-column: 1 / -1; font-weight: 600; }
