:root {
  --ink: #183b4a; --muted: #5a6f79; --paper: #f3f6f7; --surface: #fff; --line: #d3e0e5;
  --orange: #cf420f; --orange-deep: #9e2c08; --blue: #24566d;
  --ok: #1e7a46; --ok-bg: #e3f4ea; --warn: #8a5a00; --warn-bg: #fff2d6; --new: #b8360b; --new-bg: #fde8df; --err: #b3261e;
  --display: "Playfair Display", Georgia, serif; --body: "DM Sans", Arial, sans-serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --ink: #e8eef1; --muted: #a6b7bf; --paper: #0e161a; --surface: #162126; --line: #2e4049;
  --ok: #7fe0a6; --ok-bg: #173526; --warn: #ffd27a; --warn-bg: #3a2e12; --new: #ffab87; --new-bg: #3d2117; --err: #ff8a80;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { min-height: 100vh; color: var(--ink); background: var(--paper); font: 400 15px/1.55 var(--body); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2 { margin: 0; font-family: var(--display); font-weight: 600; line-height: 1.2; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: .65rem .8rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.primary, .ghost { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.6rem; padding: .55rem 1.1rem; border-radius: 8px; font-weight: 700; text-decoration: none; cursor: pointer; white-space: nowrap; }
.primary { border: 0; color: #fff; background: var(--orange); }
.primary:hover { background: var(--orange-deep); }
.ghost { border: 1px solid var(--line); background: var(--surface); }
.ghost:hover { border-color: var(--ink); }
.small { min-height: 2.1rem; padding: .3rem .75rem; font-size: .85rem; }
button:disabled { opacity: .55; cursor: progress; }
.muted { color: var(--muted); }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* Login */
.login { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem 1rem; }
.login-card { display: grid; gap: .45rem; width: min(100%, 24rem); padding: 2rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 10px 30px rgba(0,0,0,.06); }
.login-logo { justify-self: center; width: 84px; height: auto; margin-bottom: .25rem; }
.login-card h1 { text-align: center; font-size: 1.6rem; }
.login-sub { margin: 0 0 .75rem; color: var(--muted); text-align: center; }
.login-card label { margin-top: .35rem; font-size: .85rem; font-weight: 700; }
.login-card .primary { margin-top: .5rem; }
.password-field { position: relative; }
.password-field input { padding-right: 6rem; }
.password-field button { position: absolute; top: 50%; right: .35rem; transform: translateY(-50%); }
.form-error { min-height: 1.2rem; margin: .25rem 0 0; color: var(--err); font-size: .85rem; font-weight: 600; }
.back-link { justify-self: center; margin-top: .5rem; color: var(--muted); font-size: .85rem; }

/* Kerangka dashboard: sidebar + konten */
.app { display: grid; grid-template-columns: 16.5rem minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; gap: 1.25rem; height: 100vh; padding: 1.25rem 1rem; overflow-y: auto; border-right: 1px solid var(--line); background: var(--surface); }
.side-brand { display: flex; gap: .7rem; align-items: center; padding: .25rem .5rem; text-decoration: none; }
.side-brand img { width: 44px; height: 44px; object-fit: contain; }
.side-brand strong { display: block; font-family: var(--display); font-size: 1.1rem; font-weight: 600; line-height: 1.1; }
.side-brand small { color: var(--muted); font-size: .78rem; }
.side-nav { display: grid; gap: .2rem; }
.side-label { margin: .9rem .75rem .35rem; color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.side-label:first-child { margin-top: 0; }
.side-link { display: flex; gap: .7rem; align-items: center; min-height: 2.6rem; padding: .5rem .75rem; border-radius: 8px; color: var(--ink); font-weight: 600; text-decoration: none; }
.side-link svg { flex: none; width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.side-link:hover { background: var(--paper); }
.side-link.active { color: var(--orange); background: var(--new-bg); }
.side-link.active svg { opacity: 1; }
.side-text { flex: 1; }
.side-badge { min-width: 1.5rem; padding: .05rem .45rem; border-radius: 999px; color: #fff; background: var(--orange); font-size: .75rem; font-weight: 700; text-align: center; }
.side-foot { display: grid; gap: .75rem; margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--line); }
.side-user { display: grid; margin: 0; padding: 0 .5rem; }
.side-user-label { color: var(--muted); font-size: .72rem; }
.user-email { overflow: hidden; font-size: .85rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.side-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.sidebar-backdrop { display: none; }
.mobile-bar { display: none; }
.main { min-width: 0; }
.content { max-width: 1200px; margin: 0 auto; padding: 1.75rem clamp(1rem, 3vw, 2rem) 3rem; }
.page-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1.25rem; }
.page-head h1 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
.page-head p { margin: .3rem 0 0; }
.page-actions { display: flex; gap: .5rem; }

.stats { display: grid; grid-template-columns: repeat(var(--stat-cols, 4), minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { display: grid; gap: .15rem; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: left; cursor: pointer; }
.stat strong { font-size: 1.7rem; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.stat.active { border-color: var(--orange); box-shadow: inset 0 0 0 1px var(--orange); }
.stat-slot-1 strong { color: var(--new); }
.stat-slot-2 strong { color: var(--warn); }
.stat-slot-3 strong { color: var(--ok); }
.stat[hidden] { display: none; }

.toolbar { display: grid; grid-template-columns: minmax(0, 1fr) 12rem 12rem; gap: .6rem; margin-bottom: 1rem; }
.notice { margin: 0 0 1rem; padding: .65rem .9rem; border-radius: 8px; font-weight: 600; }
.notice[data-kind="success"] { color: var(--ok); background: var(--ok-bg); }
.notice[data-kind="error"] { color: var(--err); background: var(--new-bg); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: .75rem .75rem; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .75rem; letter-spacing: .05em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: .8rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr.is-new td:first-child { box-shadow: inset 3px 0 0 var(--orange); }
.data-table td:first-child { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.data-table td:nth-child(2) { min-width: 10rem; }
.data-table td:last-child { width: 1%; }
.data-table .sub { display: block; color: var(--muted); font-size: .85rem; }
.data-table a { font-weight: 600; white-space: nowrap; }
.chip { display: inline-block; padding: .15rem .6rem; border-radius: 999px; background: var(--paper); font-size: .8rem; font-weight: 600; white-space: nowrap; }
.status-select { width: auto; min-width: 7.5rem; padding: .35rem .6rem; border-radius: 999px; font-size: .85rem; font-weight: 700; }
.status-baru { color: var(--new); background: var(--new-bg); border-color: transparent; }
.status-dihubungi { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.status-selesai, .status-tampil { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.status-disembunyikan { color: var(--muted); background: var(--paper); border-color: var(--line); }
.empty { margin: 0; padding: 2.5rem 1rem; color: var(--muted); text-align: center; }

/* Dialog detail */
.detail { width: min(100% - 2rem, 34rem); max-height: calc(100vh - 2rem); padding: 0; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: var(--surface); }
.detail::backdrop { background: rgba(8, 16, 20, .55); }
.detail-inner { display: grid; gap: .45rem; padding: 1.5rem; }
.detail-head { display: flex; gap: 1rem; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.detail-head h2 { font-size: 1.4rem; }
.detail-list { display: grid; grid-template-columns: 9rem 1fr; gap: .4rem 1rem; margin: 0 0 .75rem; }
.detail-list dt { color: var(--muted); font-size: .85rem; }
.detail-list dd { margin: 0; font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; }
.detail label { margin-top: .4rem; font-size: .85rem; font-weight: 700; }
.detail-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .5rem; }

@media (max-width: 900px) {
  .app { display: block; }
  .sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; width: min(17rem, 85vw); box-shadow: 0 0 40px rgba(0,0,0,.2); transform: translateX(-105%); visibility: hidden; transition: transform .2s ease, visibility .2s; }
  .app.nav-open .sidebar { transform: none; visibility: visible; }
  .app.nav-open .sidebar-backdrop { position: fixed; z-index: 20; inset: 0; display: block; background: rgba(8, 16, 20, .5); }
  .mobile-bar { position: sticky; top: 0; z-index: 10; display: flex; gap: .75rem; align-items: center; padding: .6rem 1rem; border-bottom: 1px solid var(--line); background: var(--surface); }
  .menu-button { font-size: 1.1rem; }
  .mobile-title { font-family: var(--display); font-size: 1.1rem; }
}
@media (max-width: 820px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .toolbar .search { grid-column: 1 / -1; }
  .table-wrap { border: 0; background: transparent; }
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; }
  .data-table tr { margin-bottom: .75rem; padding: .5rem 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
  .data-table tr.is-new { border-left: 3px solid var(--orange); }
  .data-table tr.is-new td:first-child { box-shadow: none; }
  .data-table td:nth-child(n) { min-width: 0; }
  .data-table td { display: grid; grid-template-columns: 7rem 1fr; gap: .75rem; align-items: center; padding: .35rem 1rem; border: 0; }
  .data-table td::before { content: attr(data-label); color: var(--muted); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
  .data-table td:last-child::before { content: ""; }
}
@media (max-width: 480px) {
  .page-actions { width: 100%; }
  .page-actions > * { flex: 1; }
  .detail-list { grid-template-columns: 1fr; gap: .1rem; }
  .detail-list dd { margin-bottom: .5rem; }
  .login-card { padding: 1.5rem 1.25rem; }
}
.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
@media (max-width: 820px) { .chips { justify-self: start; } }
.excerpt { display: block; max-width: 22rem; color: var(--muted); font-size: .85rem; }
#detail-wa[hidden] { display: none; }
