:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1c2430;
  --muted: #6b7686;
  --line: #e7eaef;
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --ok-bg: #e7f7ec; --ok-ink: #1c7a40;
  --err-bg: #fdeced; --err-ink: #b5283a;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20,30,50,.06), 0 8px 24px rgba(20,30,50,.05);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.5; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #eef0f4; padding: .1em .4em; border-radius: 6px; font-size: .9em; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: .75rem 1.5rem; position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--ink); }
.mainnav { display: flex; gap: .25rem; flex: 1; }
.mainnav a {
  color: var(--muted); padding: .4rem .8rem; border-radius: 8px; font-weight: 500;
}
.mainnav a:hover { background: #f0f1f5; text-decoration: none; }
.mainnav a.active { color: var(--brand); background: #eef0fe; }
.logout { margin: 0; }

/* ---------- Layout ---------- */
.container { max-width: 960px; margin: 0 auto; padding: 1.75rem 1.5rem 4rem; }
.page-title { font-size: 1.5rem; margin: 0 0 1.25rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head .page-title { margin: 0; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
@media (max-width: 760px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .mainnav { display: none; }
}

/* ---------- Panel ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.25rem;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.panel-head h2 { font-size: 1.05rem; margin: 0; }
.hint, .muted { color: var(--muted); font-size: .9rem; }
.hint { margin: .6rem 0 0; }

/* ---------- Stat cards ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; }
.stat-label { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.9rem; font-weight: 700; margin-top: .25rem; }
.stat-value.sm { font-size: 1rem; font-weight: 500; word-break: break-all; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.table th, .table td { text-align: left; padding: .65rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.truncate { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: .75rem; align-items: center; }
.row-actions form { margin: 0; }

.badge { font-size: .72rem; padding: .15rem .5rem; border-radius: 999px; font-weight: 600; background: #eef0f4; color: var(--muted); }
.badge.on { background: var(--ok-bg); color: var(--ok-ink); }
.badge.off { background: #eef0f4; color: var(--muted); }
.badge.warn { background: #fff3da; color: #9a6a06; }
.badge.lock { background: transparent; padding: 0 .2rem; }

/* ---------- Forms ---------- */
.form label, .form .check { display: block; margin-bottom: .9rem; }
.form label > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .3rem; }
.form input[type=text], .form input[type=url], .form input[type=password],
.form textarea, .form select {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: #fff;
}
.form input:focus, .form textarea:focus, .form select:focus { outline: 2px solid #c7cbf7; border-color: var(--brand); }
.form .check { display: flex; align-items: center; gap: .5rem; }
.form .check.sm { font-size: .85rem; }

.form-inline { display: flex; flex-wrap: wrap; gap: .6rem; }
.form-inline input { flex: 1 1 180px; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; }

.btn, button.btn {
  background: var(--brand); color: #fff; border: 0; border-radius: 8px;
  padding: .6rem 1.1rem; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn-sm { display: inline-block; background: #eef0f4; color: var(--ink); border: 0; border-radius: 7px; padding: .35rem .7rem; font-size: .85rem; font-weight: 500; cursor: pointer; }
.btn-sm:hover { background: #e2e5ec; text-decoration: none; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: .45rem .8rem; cursor: pointer; font: inherit; }
.btn-ghost:hover { background: #f0f1f5; }
.link-danger { background: none; border: 0; color: var(--err-ink); cursor: pointer; font: inherit; padding: 0; }
.link-danger:hover { text-decoration: underline; }

/* ---------- Alerts ---------- */
.alert { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1.25rem; font-size: .92rem; }
.alert.ok { background: var(--ok-bg); color: var(--ok-ink); }
.alert.err { background: var(--err-bg); color: var(--err-ink); }

/* ---------- Bar chart ---------- */
.chart { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-top: 1rem; }
.chart .bar {
  flex: 1; min-height: 2px; background: linear-gradient(var(--brand), #8b85f0);
  border-radius: 4px 4px 0 0; position: relative; display: flex; justify-content: center;
}
.chart .bar-val { position: absolute; top: -1.2rem; font-size: .7rem; color: var(--muted); }

/* ---------- Bio editor items ---------- */
.bio-items { display: flex; flex-direction: column; gap: .6rem; }
.bio-item { display: flex; align-items: center; gap: .5rem; padding: .5rem; border: 1px solid var(--line); border-radius: 10px; }
.bio-item-move { display: flex; flex-direction: column; gap: 2px; }
.bio-item-move form { margin: 0; }
.bio-item-move button { border: 1px solid var(--line); background: #fff; border-radius: 5px; cursor: pointer; width: 24px; line-height: 1; padding: 1px 0; }
.bio-item-form { display: flex; flex: 1; align-items: center; gap: .4rem; margin: 0; flex-wrap: wrap; }
.bio-item-form input { padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 7px; font: inherit; }
.i-icon { width: 48px; text-align: center; }
.i-title { flex: 1 1 120px; }
.i-url { flex: 2 1 180px; }
.i-clicks { font-size: .8rem; color: var(--muted); white-space: nowrap; }

/* ---------- Auth ---------- */
body.auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 2rem; width: 100%; max-width: 360px; }
.brand-lg { text-align: center; font-size: 1.4rem; margin: 0 0 .5rem; }
.auth-title { text-align: center; font-size: 1.1rem; color: var(--muted); margin: 0 0 1.5rem; font-weight: 500; }
.auth-card .btn { width: 100%; }

/* ---------- 404 / Expired ---------- */
body.public { display: flex; flex-direction: column; min-height: 100vh; }
.notfound { margin: auto; text-align: center; padding: 2rem; }
.notfound-code { font-size: 4rem; font-weight: 800; color: var(--brand); }

/* ---------- Opsi lanjutan & UTM ---------- */
.advanced { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .75rem; }
.advanced > summary { cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--brand); margin-bottom: .75rem; }
.advanced .grid-2, .advanced .grid-3 { margin-bottom: .75rem; }
fieldset.utm { border: 1px solid var(--line); border-radius: 10px; padding: .75rem 1rem 1rem; margin: 0 0 .75rem; }
fieldset.utm legend { font-size: .82rem; color: var(--muted); padding: 0 .4rem; }
fieldset.utm input { width: 100%; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 7px; font: inherit; }

/* ---------- QR ---------- */
.qr-box { display: flex; align-items: center; gap: .75rem; margin-top: .35rem; }
.qr-box img { border: 1px solid var(--line); border-radius: 8px; background: #fff; }

/* ---------- Daftar checkbox pixel ---------- */
.check-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.check-list .check { display: flex; align-items: center; gap: .5rem; margin: 0; }

/* ---------- Gate (password / interstitial) ---------- */
.gate { margin: auto; padding: 2rem 1rem; width: 100%; max-width: 420px; }
.gate-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 2rem; text-align: center; }
.gate-icon { font-size: 2.5rem; margin-bottom: .5rem; }
.gate-card h1 { font-size: 1.25rem; margin: 0 0 .35rem; }
.gate-card p { color: var(--muted); margin: 0 0 1.25rem; }
.gate-card .form input { margin-bottom: .9rem; }
.gate-card .btn { width: 100%; }

/* ---------- Public bio page ---------- */
.bio-page { min-height: 100vh; width: 100%; display: flex; justify-content: center; padding: 3rem 1rem; }
.bio-card { width: 100%; max-width: 480px; text-align: center; }
.bio-avatar { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; margin: 0 auto 1rem; display: block; }
.bio-avatar.placeholder { display: flex; align-items: center; justify-content: center; font-size: 2.5rem; font-weight: 700; color: #fff; background: var(--brand); text-transform: uppercase; }
.bio-name { font-size: 1.4rem; margin: 0 0 .35rem; }
.bio-desc { color: var(--muted); margin: 0 0 1.75rem; }
.bio-links { display: flex; flex-direction: column; gap: .75rem; }
.bio-link {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  padding: .9rem 1rem; border-radius: 12px; background: var(--panel);
  border: 1px solid var(--line); color: var(--ink); font-weight: 600;
  box-shadow: var(--shadow); transition: transform .08s ease;
}
.bio-link:hover { transform: translateY(-2px); text-decoration: none; }
.bio-link-icon { font-size: 1.2rem; }
.bio-empty { color: var(--muted); }
.bio-footer { margin-top: 2.5rem; font-size: .8rem; color: var(--muted); }

/* Themes */
.bio-page.theme-default { background: linear-gradient(160deg, #eef0fe, #f7f8ff); }
.bio-page.theme-dark { background: #14161c; }
.bio-page.theme-dark .bio-name { color: #f3f4f8; }
.bio-page.theme-dark .bio-desc, .bio-page.theme-dark .bio-footer { color: #9aa3b2; }
.bio-page.theme-dark .bio-link { background: #1e2129; border-color: #2a2e38; color: #f3f4f8; }
.bio-page.theme-mint { background: linear-gradient(160deg, #d8f5e6, #eefef6); }
