:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f5; --border: #dde1e7;
  --text: #1c2330; --muted: #677285; --accent: #2457c5; --accent-bg: #e8effc;
  --ok: #17803d; --ok-bg: #e3f4e9; --bad: #b42318; --bad-bg: #fdecea;
  --warn: #9a6200; --warn-bg: #fdf3dc;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h2 { font-size: 16px; margin: 20px 0 8px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 20px 0 6px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); font-weight: normal; }
.small { font-size: 12px; }
.bad { color: var(--bad); }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.grow { flex: 1; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 20px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { font-weight: 600; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { padding: 6px 12px; border-radius: 6px; text-decoration: none; color: var(--muted); }
.topbar nav a[aria-current="page"] { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; margin-left: auto; opacity: 0; transition: opacity .15s; }
.topbar .session { display: flex; align-items: center; gap: 8px; }
.topbar .session form { margin: 0; }
button.linklike { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; }
.login { max-width: 320px; margin: 48px auto; }
.form input[type=password] { font: inherit; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.spinner.htmx-request { opacity: 1; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { padding: 16px; max-width: 1800px; margin: 0 auto; }

.tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0 0 14px;
  border-bottom: 1px solid var(--border); }
.tabs a { padding: 7px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent;
  margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .muted.small { margin-right: 6px; }
.tabs.subtabs { margin-top: -8px; font-size: 0.92em; }
.tabs.subtabs a { padding: 5px 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 1px 8px; font-size: 0.85em; color: inherit; text-decoration: none; }
a.chip:hover { border-color: var(--accent); }

.cards { display: flex; flex-wrap: wrap; gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; min-width: 150px; color: inherit; text-decoration: none; }
.card.small { min-width: 120px; }
.card.link:hover { border-color: var(--accent); }
.card .label { font-size: 12px; color: var(--muted); }
.card .value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.card .sub { font-size: 12px; color: var(--muted); }
.card .sub.bad { color: var(--bad); }

.split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr); } }
.detail-col { position: sticky; top: 60px; }
@media (max-width: 1100px) { .detail-col { position: static; } }
.detail { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 4px 16px 16px;
  max-height: calc(100vh - 80px); overflow: auto; margin-top: 20px; }
@media (max-width: 1100px) { .detail { max-height: none; } }
.detail-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.detail-head h2 { margin-right: auto; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
input[type=search], select { font: inherit; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--surface); color: var(--text); }
input[type=search] { flex: 1; min-width: 200px; }
.check { display: flex; align-items: center; gap: 6px; color: var(--muted); }
button, .button { font: inherit; padding: 5px 12px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap; }
button:hover:not(:disabled), .button:hover { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: .4; cursor: default; }

.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.clip { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr[hx-get] { cursor: pointer; }
tr[hx-get]:hover td { background: var(--surface-2); }
tr.active td { background: var(--accent-bg); }
.pager { display: flex; align-items: center; gap: 8px; padding: 8px 0; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.succeeded, .badge.success, .badge.st-Selesai { background: var(--ok-bg); color: var(--ok); }
.badge.failed, .badge.error { background: var(--bad-bg); color: var(--bad); }
.badge.running, .badge.st-Diproses { background: var(--warn-bg); color: var(--warn); }
.badge.st-Baru { background: var(--accent-bg); color: var(--accent); }
.badge.jenis-pengaduan { background: var(--bad-bg); color: var(--bad); }
.badge.jenis-aspirasi { background: var(--warn-bg); color: var(--warn); }
.badge.jenis-pertanyaan { background: var(--accent-bg); color: var(--accent); }
.badge.jenis-apresiasi { background: var(--ok-bg); color: var(--ok); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

pre.json { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 10px; overflow: auto; max-height: 520px; margin: 8px 0; white-space: pre-wrap;
  word-break: break-word; }
pre.json.small { max-height: 200px; }
details.version { border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; }
details.version summary { cursor: pointer; display: flex; gap: 8px; align-items: center; }

.judul { font-weight: 600; margin: 4px 0; }
.isi { white-space: pre-wrap; overflow-wrap: anywhere; }
.comment { border-left: 3px solid var(--border); padding: 4px 10px; margin: 8px 0; }
.comment.instansi { border-left-color: var(--accent); }
.comment-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 2px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.thumb { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 6px; overflow: hidden;
  text-decoration: none; color: var(--muted); background: var(--surface-2); }
.thumb img { width: 100%; height: 100px; object-fit: cover; display: block; }
.thumb .caption { font-size: 11px; padding: 3px 6px; }

.error-box { background: var(--bad-bg); color: var(--bad); border-radius: 6px; padding: 10px 12px; margin: 12px 0; }

.badge.urg-tinggi { background: #fde2e1; color: #9b1c1c; }
.badge.urg-sedang { background: #fdf0d5; color: #8a5a00; }
.badge.urg-rendah { background: #e6f4ea; color: #1e6b34; }

/* Accounts */
tr.inactive td { color: var(--muted); }
td.actions { display: flex; gap: 6px; }
td.actions form { margin: 0; }
.form { display: flex; flex-direction: column; gap: 12px; margin: 8px 0 16px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.form label.check { flex-direction: row; align-items: center; color: var(--text); }
.form input[type=text], .form input[type=number], .form select { font: inherit; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.form .hint { font-size: 12px; }
.form-actions { display: flex; gap: 8px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { color: #fff; opacity: .9; }
button.danger { color: var(--bad); }
button.danger:hover:not(:disabled) { border-color: var(--bad); color: var(--bad); }

/* Staging: a channel card with its per-platform breakdown */
.channel-card { padding: 0; display: flex; flex-direction: column; }
.channel-card .card-link { padding: 10px 14px 6px; color: inherit; text-decoration: none; }
.channel-card .card-link:hover .label { color: var(--accent); }
.channel-card .breakdown { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 10px 8px; }
.channel-card .breakdown a { font-size: 12px; padding: 1px 8px; border: 1px solid var(--border); border-radius: 999px;
  color: var(--muted); text-decoration: none; }
.channel-card .breakdown a:hover { border-color: var(--accent); color: var(--accent); }
.channel-card .breakdown strong { color: var(--text); font-weight: 600; }

/* Hover tooltips: data-tip="..." on a card (or any element). A dotted
   label hints that there is one. */
[data-tip] { position: relative; }
[data-tip] > .label, .channel-card [data-tip] .label { text-decoration: underline dotted var(--muted); text-underline-offset: 3px; cursor: help; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; left: 0; top: calc(100% + 6px); z-index: 30;
  width: max-content; max-width: min(300px, 80vw); white-space: normal;
  background: var(--text); color: #fff; font-size: 12px; font-weight: normal; line-height: 1.45;
  text-align: left; text-decoration: none; padding: 8px 10px; border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .18); pointer-events: none;
}
[data-tip].tip-left:hover::after, [data-tip].tip-left:focus-visible::after { left: auto; right: 0; }

/* Staging, Enrichment: bars (meter), coverage table and breakdown panels */
.meter { display: inline-block; vertical-align: middle; width: 70px; height: 8px; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.meter-fill { display: block; height: 100%; background: var(--accent); }
.meter.warn .meter-fill { background: var(--warn); }
.meter-pct { display: inline-block; min-width: 3.2em; margin-left: 6px; font-size: 12px; color: var(--muted);
  font-variant-numeric: tabular-nums; }
table.coverage td { vertical-align: middle; }
table.coverage td.num { white-space: nowrap; }
.breakdowns { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin: 16px 0 4px; }
.breakdown-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 2px 12px 10px; }
.breakdown-panel h3 { margin-top: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: 6px;
  padding: 3px 4px; border-radius: 4px; color: inherit; text-decoration: none; font-size: 13px; }
a.bar-row:hover { background: var(--surface-2); }
.bar-row .bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar-label.mono { font-size: 11.5px; }
.bar-row .bar-count { min-width: 3em; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.bar-row .meter-pct { min-width: 2.8em; }
ul.reasons { margin: 4px 0; padding-left: 18px; }
ul.reasons li { margin: 2px 0; }
.bar-row .meter { width: 48px; }
