/* =========================================================
   WASek — UI
   ======================================================= */
:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --text: #0f1a14;
  --text-2: #3d4a43;
  --muted: #6b7a72;
  --line: #e4eae7;
  --line-2: #d5ddd9;

  --brand: #128c4a;
  --brand-600: #0e7a40;
  --brand-700: #0b6434;
  --brand-50: #eaf7f0;
  --brand-100: #d3efdf;

  --danger: #d93636;
  --danger-50: #fdeeee;
  --warn: #c27a0e;
  --warn-50: #fdf5e6;
  --info: #2563eb;
  --info-50: #eef3fe;

  --side-bg: #0d1f16;
  --side-text: rgba(255, 255, 255, .68);
  --side-hover: rgba(255, 255, 255, .06);
  --side-active: rgba(37, 211, 102, .14);

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 20, .05);
  --shadow: 0 1px 3px rgba(16, 24, 20, .06), 0 4px 12px rgba(16, 24, 20, .04);
  --shadow-lg: 0 12px 40px rgba(16, 24, 20, .18);
  --side-w: 248px;
  --ease: cubic-bezier(.2, .8, .2, 1);

  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
code, pre, .mono { font-family: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 12.5px; }
:not(pre) > code { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }
.i { flex: none; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Layout ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 40;
  display: flex; flex-direction: column; background: var(--side-bg); color: var(--side-text);
  transition: transform .25s var(--ease);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 18px; color: #fff; font-weight: 700; font-size: 16px; }
.brand-logo { width: 36px; height: 36px; border-radius: 10px; flex: none; box-shadow: 0 4px 14px rgba(37, 211, 102, .3); }
.wordmark { font-weight: 800; font-size: 18px; letter-spacing: -.02em; line-height: 1.1; }
.wordmark span { color: #2fdc72; }
.mobile-brand .wordmark { font-size: 20px; color: var(--text); }
.mobile-brand .wordmark span { color: var(--brand); }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--side-text); letter-spacing: .02em; }
.nav { flex: 1; overflow-y: auto; padding: 6px 12px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: rgba(255, 255, 255, .38); padding: 14px 10px 6px; }
.nav button {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 12px; margin-bottom: 2px;
  background: none; border: 0; border-radius: 9px; color: var(--side-text); font: inherit; font-weight: 500;
  cursor: pointer; text-align: left; position: relative; transition: background .15s, color .15s;
}
.nav button:hover { background: var(--side-hover); color: #fff; }
.nav button.active { background: var(--side-active); color: #fff; }
.nav button.active::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #25d366; }
.nav button.active .i { color: #25d366; }
.nav button[data-badge]:not([data-badge=""])::after { content: attr(data-badge); margin-left: auto; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: #25d366; color: #0d1f16; }
.side-foot { padding: 14px; border-top: 1px solid rgba(255, 255, 255, .07); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-100); color: var(--brand-700); font-weight: 700; font-size: 13px; flex: none; }
.sidebar .avatar { background: rgba(255, 255, 255, .1); color: #fff; }
.user-card .who { flex: 1; min-width: 0; }
.user-card .who b { display: block; color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .who span { display: block; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn-dark { background: none; border: 0; color: var(--side-text); padding: 7px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.icon-btn-dark:hover { background: var(--side-hover); color: #fff; }

.main { margin-left: var(--side-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 14px 28px; background: rgba(244, 246, 245, .86); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .title { flex: 1; min-width: 0; }
.topbar h1 { font-size: 18px; font-weight: 700; }
.topbar .sub { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.btn.menu-btn { display: none; }
.content { padding: 24px 28px 48px; width: 100%; max-width: 1280px; }
.page { animation: pageIn .25s var(--ease); }
@keyframes pageIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.backdrop { position: fixed; inset: 0; background: rgba(10, 20, 15, .45); z-index: 35; opacity: 0; pointer-events: none; transition: opacity .2s; }
.backdrop.show { opacity: 1; pointer-events: auto; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px 16px 40px; }
}

/* ---------- Progress bar ---------- */
#progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 100; background: linear-gradient(90deg, #25d366, var(--brand)); box-shadow: 0 0 8px rgba(37, 211, 102, .6); opacity: 0; transition: width .3s var(--ease), opacity .3s; pointer-events: none; }
#progress.run { opacity: 1; }

/* ---------- Cards & grid ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h3 { flex: 1; }
.card-body { padding: 20px; }
.stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.split { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); align-items: start; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.section-head { display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; flex-wrap: wrap; }
/* Panel kesehatan layanan (halaman Device) */
.health { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px; margin-bottom: 16px; border: 1px solid #cfe9da; border-radius: 14px; background: #f3fbf6; font-size: 13.5px; }
.health.hl-bad { border-color: #f1c7c7; background: var(--danger-50); }
.health.hl-warn { border-color: #f0dcb4; background: var(--warn-50); }
.hl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--brand); }
.hl-head b { color: var(--text, #111); }
.hl-bad .hl-head { color: var(--danger); }
.hl-warn .hl-head { color: var(--warn); }
.hl-item { padding: 8px 12px; border-radius: 10px; background: rgba(255, 255, 255, .7); }
.hl-item .cell-sub { display: block; }
.hl-saran { font-style: italic; }
.hl-kaki { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.hl-riwayat summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
.hl-riwayat .hl-item { margin-top: 6px; }
.section-head h2 { flex: 1; font-size: 16px; }

/* Stats */
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 24px; }
.stat { display: flex; align-items: center; gap: 14px; padding: 16px 18px; }
.stat-ic { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.stat b { display: block; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat span { color: var(--muted); font-size: 12.5px; }
.tone-green { background: var(--brand-50); color: var(--brand); }
.tone-amber { background: var(--warn-50); color: var(--warn); }
.tone-red { background: var(--danger-50); color: var(--danger); }
.tone-blue { background: var(--info-50); color: var(--info); }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
label, .label { display: block; font-weight: 600; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 5px; }
input, textarea, select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  font: inherit; background: #fff; color: var(--text); transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #a3b0a9; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(18, 140, 74, .14); }
input[readonly] { background: var(--surface-2); }
textarea { min-height: 96px; resize: vertical; }
select { appearance: none; padding-right: 34px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236b7a72' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center; }
input[type=file] { padding: 7px; background: var(--surface-2); cursor: pointer; }
input[type=file]::file-selector-button { border: 1px solid var(--line-2); background: #fff; border-radius: 6px; padding: 5px 10px; margin-right: 10px; font: inherit; font-weight: 500; cursor: pointer; }
input[type=checkbox] { width: auto; accent-color: var(--brand); }
.cols-2 { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 600px) { .cols-2 { grid-template-columns: 1fr; } }
.input-group { display: flex; }
.input-group input { border-top-right-radius: 0; border-bottom-right-radius: 0; min-width: 0; }
.input-group > .btn { border-radius: 0; margin-left: -1px; }
.input-group > .btn:last-child { border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; margin: 0; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 38px; height: 22px; border-radius: 99px; background: var(--line-2); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .2s var(--ease); }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(18, 140, 74, .25); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px;
  border-radius: var(--radius-sm); border: 1px solid var(--brand); background: var(--brand); color: #fff;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; position: relative;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--brand-600); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(18, 140, 74, .25); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--text-2); border-color: var(--line-2); }
.btn.ghost:hover { background: var(--surface-2); border-color: #c4cec9; }
.btn.danger { background: #fff; color: var(--danger); border-color: #f1c7c7; }
.btn.danger:hover { background: var(--danger-50); }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-solid:hover { background: #c22d2d; }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.icon { padding: 7px; }
.btn.sm.icon { padding: 6px; }
.btn.block { width: 100%; }
.btn.busy { color: transparent !important; pointer-events: none; }
.btn.busy::after { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-color: rgba(255, 255, 255, .9) rgba(255, 255, 255, .9) transparent transparent; animation: spin .7s linear infinite; }
.btn.ghost.busy::after, .btn.danger.busy::after { border-color: var(--brand) var(--brand) transparent transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--brand-100); border-top-color: var(--brand); animation: spin .8s linear infinite; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.connected, .badge.sent, .badge.delivered, .badge.read, .badge.received { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-100); }
.badge.failed, .badge.disconnected { background: var(--danger-50); color: var(--danger); border-color: #f5d0d0; }
.badge.pending, .badge.qr, .badge.connecting { background: var(--warn-50); color: var(--warn); border-color: #f3e0bd; }
.badge.connecting::before, .badge.qr::before, .badge.pending::before { animation: pulse 1.4s ease-in-out infinite; }
.badge.read { background: var(--info-50); color: var(--info); border-color: #d6e2fc; }
.badge.plain::before { display: none; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- Layanan aduan ---------- */
/* Kartu angka. auto-fill (bukan auto-fit) agar kartu terakhir tidak melebar sendiri. */
.cmp-kpi { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); margin-bottom: 14px; }
.kpi {
  --kpi: var(--brand); --kpi-bg: var(--brand-50);
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px;
  padding: 14px 16px 14px 18px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  animation: pageIn .3s var(--ease) both;
}
.kpi.t-amber { --kpi: var(--warn); --kpi-bg: var(--warn-50); }
.kpi.t-red { --kpi: var(--danger); --kpi-bg: var(--danger-50); }
.kpi.t-blue { --kpi: var(--info); --kpi-bg: var(--info-50); }
/* netral, sewarna dengan badge .prio-low agar prioritas rendah tidak terbaca sebagai "bagus" */
.kpi.t-grey { --kpi: var(--muted); --kpi-bg: var(--surface-2); }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--kpi); }
/* jeda masuk bertahap; hanya opacity + transform, tidak menghalangi interaksi */
.kpi:nth-child(2) { animation-delay: 40ms; }
.kpi:nth-child(3) { animation-delay: 80ms; }
.kpi:nth-child(4) { animation-delay: 120ms; }
.kpi:nth-child(5) { animation-delay: 160ms; }
.kpi:nth-child(6) { animation-delay: 200ms; }
.kpi:nth-child(7) { animation-delay: 240ms; }
.kpi:nth-child(8) { animation-delay: 280ms; }
.kpi-ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; color: var(--kpi); background: var(--kpi-bg); }
.kpi b { display: block; font-size: 23px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi > div > span { display: block; color: var(--muted); font-size: 12.5px; }
.kpi .kpi-sub { color: var(--kpi); font-weight: 600; font-size: 11.5px; margin-top: 1px; }
.kpi.urgent { background: var(--danger-50); border-color: #f5d0d0; }
.kpi.urgent .kpi-ic { background: #fff; }
.kpi.urgent b::after { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); margin-left: 7px; vertical-align: middle; animation: pulse 1.6s ease-in-out infinite; }
@media (hover: hover) and (pointer: fine) {
  .kpi { transition: transform 160ms var(--ease), box-shadow 160ms var(--ease); }
  .kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
}

/* Empat panel ringkasan. Kartu kategori memanjang dua baris sehingga bawahnya
   sejajar dengan awal tabel antrean; nama kategori yang panjang pun muat. */
.cmp-grid {
  display: grid; gap: 14px; margin-bottom: 14px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.05fr);
  grid-template-areas:
    "tren tren kategori"
    "prio status kategori";
}
.g-tren { grid-area: tren; }
.g-kategori { grid-area: kategori; }
.g-prio { grid-area: prio; }
.g-status { grid-area: status; }
@media (max-width: 1240px) {
  .cmp-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "tren tren" "prio status" "kategori kategori";
  }
}
@media (max-width: 760px) {
  .cmp-grid { grid-template-columns: 1fr; grid-template-areas: none; }
  .cmp-grid > * { grid-area: auto; }
}

/* Bentuk grafik yang dipakai ketiga panel: label + jumlah + persen, lalu bar.
   Warna bar ditentukan per baris lewat --c (status & prioritas); kategori satu hue. */
.catbar { display: grid; gap: 11px; }
.catbar-row.off { opacity: .45; }
.cb-top { display: flex; align-items: baseline; gap: 10px; font-size: 12.5px; margin-bottom: 5px; }
.cb-top b { margin-left: auto; font-variant-numeric: tabular-nums; }
.cb-top .pct { width: 34px; text-align: right; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.cb-track { height: 8px; background: var(--surface-2); border-radius: 4px; }
.cb-fill { height: 100%; background: var(--c, var(--brand)); border-radius: 4px; animation: cbGrow .55s var(--ease) both; transform-origin: left; }
@keyframes cbGrow { from { transform: scaleX(0); } }

@media (prefers-reduced-motion: reduce) {
  .kpi, .cb-fill { animation-duration: .01s; }
  .kpi.urgent b::after { animation: none; }
}

/* Tabel kosong: lebih ramah daripada sebaris teks */
.cmp-empty { display: grid; justify-items: center; gap: 8px; color: var(--muted); }
.cmp-empty .i { color: var(--line-2); }
.cmp-empty b { color: var(--text-2); font-size: 14px; }
.badge.cmp-new { background: var(--warn-50); color: var(--warn); border-color: #f3e0bd; }
.badge.cmp-new::before { animation: pulse 1.4s ease-in-out infinite; }
.badge.cmp-process { background: var(--info-50); color: var(--info); border-color: #d6e2fc; }
.badge.cmp-done { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-100); }
.badge.cmp-rejected { background: var(--danger-50); color: var(--danger); border-color: #f5d0d0; }
.badge.prio-high { background: var(--danger-50); color: var(--danger); border-color: #f5d0d0; }
.badge.prio-medium { background: var(--warn-50); color: var(--warn); border-color: #f3e0bd; }
.badge.prio-low { background: var(--surface-2); color: var(--muted); }
.cmp-report { padding: 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 18px; }
.cmp-top { display: flex; align-items: flex-start; gap: 11px; }
.cmp-av { width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--brand-100); color: var(--brand-700); font-weight: 700; font-size: 12.5px; }
.cmp-top > .grow > b { display: block; }
.cmp-top .mono { display: block; margin-top: 1px; }
.cmp-when { display: grid; justify-items: end; gap: 4px; text-align: right; }
.cmp-sum { font-weight: 600; margin-top: 11px; }
.cmp-text { white-space: pre-wrap; word-break: break-word; margin: 6px 0 10px; max-height: 260px; overflow: auto; }
.cmp-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chat-box { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; overscroll-behavior: contain; padding: 12px; margin-bottom: 18px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.bub { max-width: 86%; padding: 7px 10px; border-radius: 12px; font-size: 13px; background: var(--surface); border: 1px solid var(--line); }
.bub.in { align-self: flex-start; border-bottom-left-radius: 4px; }
.bub.out { align-self: flex-end; background: var(--brand-50); border-color: var(--brand-100); border-bottom-right-radius: 4px; }
.bub.mark { border-color: #e8c27a; box-shadow: 0 0 0 3px var(--warn-50); }
.bub-txt { white-space: pre-wrap; word-break: break-word; }
.bub-file { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; margin-top: 3px; word-break: break-all; }
.bub-meta { color: var(--muted); font-size: 11px; margin-top: 3px; }
.cmp-note { padding: 9px 0; border-top: 1px solid var(--line); font-size: 13px; }
.cmp-note:first-child { border-top: 0; }
.cmp-cat { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.cmp-cat:first-child { border-top: 0; }
.cmp-cat .cell-sub { margin-top: 1px; }

/* ---------- Ringkasan layanan aduan ---------- */
/* Peringatan di atas halaman; hanya tampil bila ada aduan yang belum dibalas */
.alert-bar { display: flex; align-items: center; gap: 12px; padding: 13px 16px; margin-bottom: 16px; border-radius: var(--radius); background: var(--warn-50); border: 1px solid #f3e0bd; color: #8a5a0b; animation: pageIn .25s var(--ease); }
.alert-bar .i { color: var(--warn); flex: none; }
.alert-bar b { display: block; color: #7a4f0a; }
.alert-bar span { font-size: 13px; }
.alert-bar .btn { flex: none; }

/* Kartu angka: label kecil, angka besar + perubahan, grafik mungil, keterangan */
.kpi { flex-direction: column; align-items: stretch; gap: 0; padding: 14px 16px 12px 18px; }
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi-val { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.kpi-val b { font-size: 25px; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-foot { color: var(--muted); font-size: 11.5px; margin-top: 6px; }
.kpi .spark { width: 100%; height: 28px; margin-top: 8px; display: block; }
.delta { font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-variant-numeric: tabular-nums; }
.delta.baik { background: var(--brand-50); color: var(--brand-700); }
.delta.buruk { background: var(--danger-50); color: var(--danger); }
.kpi.urgent .delta { background: #fff; }

/* Grafik garis */
.chart { position: relative; }
.line-chart { width: 100%; height: auto; display: block; overflow: visible; }
.line-chart .grid { stroke: var(--line); stroke-width: 1; }
.line-chart .axis { fill: var(--muted); font-size: 10.5px; }
.line-chart .crosshair { stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 3 3; }
.line-chart .hit { cursor: crosshair; }
.chart-legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-foot { margin-top: 6px; }
.chart-foot b { color: var(--text); font-variant-numeric: tabular-nums; }
.dot-sm { width: 9px; height: 9px; border-radius: 3px; flex: none; display: inline-block; }
.chart-tip { position: absolute; top: 4px; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow); padding: 7px 10px; font-size: 12px; pointer-events: none; min-width: 124px; z-index: 2; }
.chart-tip > b { display: block; margin-bottom: 4px; }
.chart-tip div { display: flex; align-items: center; gap: 6px; }
.chart-tip div b { margin-left: auto; font-variant-numeric: tabular-nums; }

/* Donat status */
.donut-wrap { display: grid; gap: 14px; justify-items: center; }
.donut { position: relative; width: 160px; max-width: 100%; }
.donut svg { width: 100%; height: auto; display: block; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut-center b { display: block; font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.donut-center span { color: var(--muted); font-size: 11.5px; }
.donut-legend { display: grid; gap: 8px; width: 100%; font-size: 13px; }
.donut-legend > div { display: flex; align-items: center; gap: 9px; }
.donut-legend > div.off { opacity: .45; }
.donut-legend b { font-variant-numeric: tabular-nums; }
.donut-legend .pct { width: 36px; text-align: right; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* Antrean: judul + tab status */
.queue-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px 10px; }
.queue-head h3 { font-size: 15px; }
.queue-tabs { padding: 0 20px 2px; border-bottom: 1px solid var(--line); gap: 2px; }
.queue-tabs button { white-space: nowrap; }
.tab-n { display: inline-block; margin-left: 5px; padding: 0 6px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.queue-tabs button.active .tab-n { background: var(--brand-100); color: var(--brand-700); }

/* Kotak balasan di bawah utas percakapan */
.reply-box { display: flex; align-items: flex-end; gap: 8px; margin: -10px 0 8px; }
.reply-box textarea { flex: 1; min-height: 40px; max-height: 120px; padding: 9px 12px; resize: none; overflow-y: auto; line-height: 1.45; }
.reply-box .btn { flex: none; height: 40px; padding: 0 14px; }

/* Dua kolom sejajar untuk form. Grid, bukan flex: label tetap sebaris walau tinggi
   isi kolomnya berbeda (flex + align-items:center membuat kolom pendek melorot). */
.form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; align-items: start; }
.form-2col .field { margin-bottom: 16px; }
@media (max-width: 520px) { .form-2col { grid-template-columns: 1fr; } }

/* Form "Teruskan ke petugas" */
.fw-switch { display: flex; width: 100%; gap: 10px; padding: 11px 13px; margin-bottom: 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.fw-switch:hover { border-color: var(--line-2); }
.fw-pratinjau-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.fw-pratinjau-head b { font-size: 13px; }
.fw-pratinjau-head .muted { margin-left: auto; }

/* Pratinjau pesan yang akan diteruskan ke petugas */
.fw-preview { margin: 0; padding: 11px 13px; max-height: 160px; overflow: auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; font: inherit; font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; color: var(--text-2); }

/* ---------- Laporan cetak / simpan PDF ---------- */
#printArea { display: none; }
@media print {
  @page { size: A4 portrait; margin: 12mm 11mm; }
  body { background: #fff; }
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block; color: var(--text); font-size: 9.5px; }
  /* tanpa ini Chrome membuang semua warna latar: bar dan kartu jadi kosong */
  #printArea, #printArea * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* Kepala laporan */
  .pr-head { display: flex; align-items: flex-end; gap: 16px; padding-bottom: 8px; margin-bottom: 12px; border-bottom: 2px solid var(--brand); }
  .pr-judul { flex: 1; }
  .pr-head h1 { font-size: 17px; margin: 0 0 3px; letter-spacing: -.02em; }
  .pr-sub, .pr-foot { font-size: 9px; color: var(--muted); }
  .pr-cap { text-align: right; line-height: 1.25; }
  .pr-cap b { display: block; font-size: 20px; color: var(--brand-700); font-variant-numeric: tabular-nums; }
  .pr-cap span { font-size: 9px; color: var(--muted); }

  /* Kartu angka */
  .pr-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 11px; }
  .pr-kpi { border: 1px solid var(--line); border-left: 3px solid var(--brand); border-radius: 7px; padding: 7px 9px; background: #fff; }
  .pr-kpi span { display: block; font-size: 8.5px; color: var(--muted); }
  .pr-kpi b { font-size: 16px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
  .pr-kpi.t-amber { border-left-color: var(--warn); }
  .pr-kpi.t-blue { border-left-color: var(--info); }
  .pr-kpi.t-red { border-left-color: var(--danger); }

  /* Panel grafik, meniru susunan dashboard */
  .pr-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin-bottom: 13px; }
  .pr-panel { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; break-inside: avoid; }
  .pr-span2 { grid-column: span 2; }
  .pr-panel h2 { font-size: 11px; margin: 0; }
  .pr-ket { display: block; font-size: 8.5px; color: var(--muted); margin-bottom: 6px; }
  .pr-kosong { font-size: 9px; color: var(--muted); padding: 14px 0; text-align: center; }
  .pr-panel .cb-top { font-size: 9px; margin-bottom: 3px; }
  .pr-panel .cb-top .pct { width: 26px; font-size: 8.5px; }
  .pr-panel .cb-track { height: 6px; }
  .pr-panel .catbar { gap: 7px; }
  .pr-panel .donut { width: 108px; }
  .pr-panel .donut-center b { font-size: 17px; }
  .pr-panel .donut-center span { font-size: 8px; }
  .pr-panel .donut-legend { gap: 5px; font-size: 9px; }
  .pr-panel .donut-wrap { gap: 9px; }
  .pr-panel .line-chart .axis { font-size: 9px; }
  .pr-panel .chart-tip, .pr-panel .crosshair, .pr-panel .dot { display: none; }
  .cb-fill, .donut circle, .comp-bar > span { animation: none !important; }

  /* Tabel */
  .pr-judul-tabel { font-size: 12px; margin: 0 0 6px; }
  .pr-judul-tabel span { font-size: 9px; font-weight: 500; color: var(--muted); }
  .pr-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
  .pr-table th:nth-child(1), .pr-table td:nth-child(1) { width: 4%; }
  .pr-table th:nth-child(2), .pr-table td:nth-child(2) { width: 10%; }
  .pr-table th:nth-child(3), .pr-table td:nth-child(3) { width: 12%; }
  .pr-table th:nth-child(4), .pr-table td:nth-child(4) { width: 24%; }
  .pr-table th:nth-child(5), .pr-table td:nth-child(5) { width: 19%; } /* balasan operator */
  .pr-table th:nth-child(6), .pr-table td:nth-child(6) { width: 11%; }
  .pr-table th:nth-child(7), .pr-table td:nth-child(7) { width: 7%; }
  .pr-table th:nth-child(8), .pr-table td:nth-child(8) { width: 7%; }
  .pr-table th:nth-child(9), .pr-table td:nth-child(9) { width: 6%; }
  .pr-table td { overflow-wrap: anywhere; }
  .pr-table th, .pr-table td { border: 1px solid #c8d2cd; padding: 3px 5px; text-align: left; vertical-align: top; }
  .pr-table th { background: var(--brand-50); font-size: 9px; }
  .pr-table td { font-size: 8px; }
  .pr-table small { color: #444; }
  .pr-table thead { display: table-header-group; } /* kepala tabel diulang di tiap halaman */
  .pr-table tr { page-break-inside: avoid; }
  .pr-tag { display: inline-block; padding: 1px 6px; border-radius: 99px; font-size: 8px; font-weight: 700; white-space: nowrap; }
  .pr-tag.s-new, .pr-tag.p-medium { background: var(--warn-50); color: var(--warn); }
  .pr-tag.s-process { background: var(--info-50); color: var(--info); }
  .pr-tag.s-done { background: var(--brand-50); color: var(--brand-700); }
  .pr-tag.s-rejected, .pr-tag.p-high { background: var(--danger-50); color: var(--danger); }
  .pr-tag.p-low { background: var(--surface-2); color: var(--muted); }
  .pr-foot { margin-top: 8px; text-align: right; }
}

/* ---------- Device cards ---------- */
.device { display: flex; flex-direction: column; transition: box-shadow .2s, transform .2s; }
.device:hover { box-shadow: var(--shadow); }
.device-head { display: flex; align-items: center; gap: 12px; padding: 18px 18px 14px; }
.device-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); flex: none; position: relative; }
.device-ic .dot { position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; background: #c4cec9; }
.device-ic .dot.connected { background: #25d366; }
.device-ic .dot.qr, .device-ic .dot.connecting { background: #f0a020; }
.device-head h3 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-body { padding: 0 18px 16px; }
.device-foot { display: flex; gap: 8px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); margin-top: auto; }
.add-card { display: grid; place-items: center; text-align: center; min-height: 240px; border: 2px dashed var(--line-2); background: transparent; box-shadow: none; cursor: pointer; color: var(--muted); transition: border-color .15s, background .15s, color .15s; font: inherit; }
.add-card:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-50); }
.add-card .plus { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); margin: 0 auto 10px; }

/* ---------- Empty & skeleton ---------- */
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .empty-ic { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; margin: 0 auto 14px; background: var(--brand-50); color: var(--brand); }
.empty h3 { color: var(--text); margin-bottom: 4px; }
.skel { position: relative; overflow: hidden; background: #e9eeeb; border-radius: 6px; }
.skel::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .6), transparent); animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

/* ---------- Toasts ---------- */
#toasts { position: fixed; top: 16px; right: 16px; z-index: 90; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; padding: 13px 14px; border-radius: 12px;
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow-lg); position: relative; overflow: hidden;
  animation: toastIn .3s var(--ease);
}
.toast.out { animation: toastOut .25s var(--ease) forwards; }
.toast .t-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.toast .t-body { flex: 1; min-width: 0; padding-top: 1px; }
.toast .t-title { font-weight: 600; font-size: 13.5px; }
.toast .t-msg { color: var(--muted); font-size: 13px; word-break: break-word; }
.toast .t-close { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px; border-radius: 6px; display: grid; }
.toast .t-close:hover { background: var(--surface-2); color: var(--text); }
.toast .t-bar { position: absolute; left: 0; bottom: 0; height: 3px; background: currentColor; opacity: .5; animation: toastBar linear forwards; }
.toast.success { color: var(--brand); } .toast.success .t-ic { background: var(--brand-50); }
.toast.error { color: var(--danger); } .toast.error .t-ic { background: var(--danger-50); }
.toast.info { color: var(--info); } .toast.info .t-ic { background: var(--info-50); }
.toast.warn { color: var(--warn); } .toast.warn .t-ic { background: var(--warn-50); }
.toast .t-title { color: var(--text); }
@keyframes toastIn { from { opacity: 0; transform: translateX(24px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(24px); } }
@keyframes toastBar { from { width: 100%; } to { width: 0; } }

/* ---------- Modal ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: rgba(10, 20, 15, .5); animation: fadeIn .2s; }
.modal { width: 100%; max-width: 440px; max-height: calc(100vh - 32px); overflow-y: auto; background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); animation: modalIn .25s var(--ease); }
.modal.wide { max-width: 560px; }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 0; }
.modal-head h3 { font-size: 16px; flex: 1; }
.modal-body { padding: 14px 20px 20px; color: var(--text-2); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 16px 16px; }
.modal-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.x-btn { background: none; border: 0; padding: 6px; border-radius: 8px; color: var(--muted); cursor: pointer; display: grid; }
.x-btn:hover { background: var(--surface-2); color: var(--text); }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* QR modal */
.qr-wrap { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: center; }
.qr-img { width: 220px; height: 220px; border-radius: 12px; border: 1px solid var(--line); display: grid; place-items: center; background: var(--surface-2); overflow: hidden; }
.qr-img img { width: 100%; height: 100%; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; display: flex; gap: 10px; margin-bottom: 12px; font-size: 13.5px; }
.steps li::before { content: counter(s); width: 22px; height: 22px; border-radius: 50%; background: var(--brand-50); color: var(--brand-700); font-weight: 700; font-size: 12px; display: grid; place-items: center; flex: none; }
@media (max-width: 560px) { .qr-wrap { grid-template-columns: 1fr; justify-items: center; } }
.pair-form { max-width: 420px; }
.pair-result { text-align: center; }
.pair-code { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 38px; font-weight: 800; letter-spacing: .14em; color: var(--brand-700); background: var(--brand-50); border: 2px dashed var(--brand-100); border-radius: 14px; padding: 16px 12px; margin-bottom: 10px; user-select: all; }
@media (max-width: 560px) { .pair-code { font-size: 28px; } }

/* ---------- Drawer (side panel) ---------- */
.drawer-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(10, 20, 15, .45); opacity: 0; pointer-events: none; transition: opacity .25s; }
.drawer-wrap.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61; width: min(500px, 100vw); background: #fff;
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg); transform: translateX(100%);
  visibility: hidden; transition: transform .3s var(--ease), visibility 0s linear .3s;
}
.drawer.open { transform: none; visibility: visible; transition: transform .3s var(--ease); }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { flex: 1; font-size: 16px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 14px 18px; }
.toolbar select { width: auto; min-width: 150px; }
.toolbar .spacer { flex: 1; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; font-size: 13px; }
.notice.info { background: var(--info-50); color: #1e40af; }
.notice.ok { background: var(--brand-50); color: var(--brand-700); }
.notice.err { background: var(--danger-50); color: #9b1c1c; }
.notice.warn { background: var(--warn-50); color: #8a5a0b; }
.media-chip { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 10px; }

/* ---------- WhatsApp preview ---------- */
.wa-preview { background: #e9e2d8; background-image: radial-gradient(rgba(0, 0, 0, .035) 1px, transparent 1px); background-size: 14px 14px; border-radius: 0 0 var(--radius) var(--radius); padding: 18px 16px; min-height: 220px; display: flex; flex-direction: column; justify-content: flex-end; }
.wa-bubble { align-self: flex-end; max-width: 88%; background: #d9fdd3; border-radius: 10px 0 10px 10px; padding: 7px 9px 5px; box-shadow: 0 1px .5px rgba(0, 0, 0, .13); font-size: 14px; white-space: pre-wrap; word-break: break-word; position: relative; }
.wa-bubble .wa-meta { display: block; text-align: right; font-size: 11px; color: #667781; margin-top: 2px; }
.wa-bubble .wa-file { display: flex; gap: 8px; align-items: center; background: rgba(0, 0, 0, .05); border-radius: 7px; padding: 8px; margin-bottom: 5px; font-size: 13px; }
.wa-empty { color: #8a8a8a; font-style: italic; }
.wa-preview { gap: 6px; }
.wa-media-bubble { padding: 4px 4px 5px; width: 270px; white-space: normal; }
.wa-media-bubble .wa-meta { padding: 0 5px; }
.wa-caption { padding: 5px 5px 0; white-space: pre-wrap; }
.wa-caption:empty { display: none; }
.wa-media { display: block; width: 100%; max-height: 320px; object-fit: cover; border-radius: 8px; background: #000; }
img.wa-media { background: #cfd8d3; }
.wa-audio { display: flex; align-items: center; gap: 8px; padding: 6px 4px 2px; }
.wa-audio audio { width: 100%; height: 36px; }
.wa-audio .mic { width: 38px; height: 38px; border-radius: 50%; background: #25d366; color: #fff; display: grid; place-items: center; flex: none; }
.wa-doc { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; background: rgba(0, 0, 0, .05); }
.wa-doc .doc-ic { width: 38px; height: 46px; border-radius: 5px; background: #fff; display: grid; place-items: center; font-size: 10px; font-weight: 800; color: #fff; flex: none; position: relative; }
.wa-doc b { display: block; font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-doc span { font-size: 11.5px; color: #667781; }

/* Pilih file */
.dropzone { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1.5px dashed var(--line-2); border-radius: 10px; background: var(--surface-2); color: var(--muted); cursor: pointer; font-weight: 400; margin: 0; transition: border-color .15s, background .15s, color .15s; }
.dropzone b { color: var(--text-2); font-weight: 600; }
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-50); color: var(--brand); }
#sFile:focus-visible + .dropzone, .dropzone:focus-within { box-shadow: 0 0 0 3px rgba(18, 140, 74, .2); }
.file-chip { display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.fc-thumb { width: 48px; height: 48px; border-radius: 8px; overflow: hidden; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--brand); }
.fc-thumb img, .fc-thumb video { width: 100%; height: 100%; object-fit: cover; }
/* Progress validasi */
.pbar { height: 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.pbar > span { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #25d366, var(--brand)); transition: width .3s var(--ease); }
.pbar.running > span { background-image: linear-gradient(45deg, rgba(255,255,255,.22) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.22) 50%, rgba(255,255,255,.22) 75%, transparent 75%), linear-gradient(90deg, #25d366, var(--brand)); background-size: 18px 18px, 100% 100%; animation: stripes .8s linear infinite; }
@keyframes stripes { to { background-position: 18px 0, 0 0; } }
.v-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.v-stats > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.v-stats b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.v-stats span { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.v-stats .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--brand); } .dot.no { background: var(--danger); } .dot.err { background: var(--warn); } .dot.left { background: #9fb0a7; }
@media (max-width: 520px) { .v-stats { grid-template-columns: repeat(2, 1fr); } }

/* Pilih baris tabel */
th.col-check, td.col-check { width: 36px; padding-right: 0 !important; }
.col-check input { width: 16px; height: 16px; cursor: pointer; margin: 0; vertical-align: middle; }
table.dataTable tbody tr.selected > * { background: var(--brand-50) !important; box-shadow: none !important; color: inherit !important; }
.bulk-bar { display: flex; align-items: center; gap: 10px; padding: 10px 18px; background: var(--brand-50); border-bottom: 1px solid var(--brand-100); animation: pageIn .2s var(--ease); }
.bulk-bar .spacer { flex: 1; }
.bulk-bar { flex-wrap: wrap; }
.bulk-bar > b { white-space: nowrap; }

/* Kontak */
.contacts-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.contacts-layout > * { min-width: 0; } /* tabel lebar digeser di dalam kartu, bukan melebarkan halaman */
@media (max-width: 1000px) {
  .contacts-layout { grid-template-columns: minmax(0, 1fr); }
  .groups-card { position: static !important; }
  .group-list { max-height: 260px; }
}
.groups-card { position: sticky; top: 86px; }
.group-list { padding: 8px; max-height: calc(100vh - 200px); overflow-y: auto; }
.group-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 8px; font: inherit; color: var(--text-2); cursor: pointer; text-align: left; }
.group-item:hover { background: var(--surface-2); }
.group-item.active { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
.group-item .gi-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-item .gi-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.group-item .gi-actions { display: none; gap: 2px; }
.group-item:hover .gi-actions, .group-item:focus-within .gi-actions { display: flex; }
.group-item:hover .gi-count { display: none; }
.gi-actions span { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; color: var(--muted); }
.gi-actions span:hover { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); }
.gi-actions span.del:hover { color: var(--danger); }
.group-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.group-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; margin: 0 4px 4px 0; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; color: var(--text-2); white-space: nowrap; }
.check-list { display: grid; gap: 2px; max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.check-list label { display: flex; align-items: center; gap: 10px; margin: 0; padding: 7px 8px; border-radius: 7px; font-weight: 500; cursor: pointer; }
.check-list label:hover { background: var(--surface-2); }
.check-list .muted { margin-left: auto; font-size: 12px; font-weight: 400; }
.check-list .empty-small { color: var(--muted); padding: 10px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 11px; border-radius: 99px; background: var(--brand-50); border: 1px solid var(--brand-100); color: var(--brand-700); font-weight: 600; font-size: 13px; }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; display: grid; padding: 2px; border-radius: 50%; }
.chip button:hover { background: rgba(0, 0, 0, .08); }
.tabs.sm button { padding: 4px 10px; font-size: 12.5px; display: inline-flex; align-items: center; gap: 5px; }

/* Balasan AI */
.ai-badge { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; color: #fff; background: linear-gradient(135deg, #d97757, #b4532f); box-shadow: 0 4px 12px rgba(217, 119, 87, .3); }
.ai-card.on { border-color: #f0c9b8; box-shadow: 0 0 0 3px rgba(217, 119, 87, .08); }
.ai-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, 1fr); gap: 24px; align-items: start; }
@media (max-width: 1100px) { .ai-grid { grid-template-columns: minmax(0, 1fr); } }
.ai-test { position: sticky; top: 86px; }
.ai-chat { border-radius: 12px; height: 380px; overflow-y: auto; justify-content: flex-start; padding: 14px 12px; }
.ai-chat .wa-bubble { max-width: 85%; }
.ai-chat .in { align-self: flex-start; background: #fff; border-radius: 0 10px 10px 10px; }
.ai-chat .typing { color: #667781; font-style: italic; }
.ai-chat .sys { align-self: center; background: #fff8e6; color: #8a5a0b; font-size: 12px; padding: 4px 10px; border-radius: 8px; box-shadow: none; white-space: normal; text-align: center; }
.ai-chat .empty-hint { margin: auto; color: #667781; font-size: 13px; text-align: center; padding: 20px; }
.ai-input { display: flex; gap: 8px; margin-top: 10px; }
.input-addon { display: inline-flex; align-items: center; padding: 0 12px; border: 1px solid var(--line-2); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--surface-2); color: var(--muted); font-size: 13px; }
.strict-box { padding: 12px 14px; border-radius: 10px; background: var(--brand-50); border: 1px solid var(--brand-100); margin-bottom: 18px; }
.strict-box .hint { margin-top: 6px; }
.strict-box.off { background: var(--warn-50); border-color: #f3e0bd; }
.doc-list { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.doc-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-top: 1px solid var(--line); }
.doc-item:first-child { border-top: 0; }
.doc-item .doc-ic { width: 32px; height: 38px; border-radius: 5px; display: grid; place-items: center; color: #fff; font-size: 9px; font-weight: 800; flex: none; }
.doc-item b { display: block; font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-item .muted { font-size: 12px; }
.doc-empty { padding: 16px; text-align: center; color: var(--muted); font-size: 13px; }
.std-texts { display: grid; gap: 4px; }
.std-texts label { font-weight: 500; font-size: 12.5px; color: var(--muted); margin: 8px 0 2px; }
.std-texts label:first-child { margin-top: 0; }
.std-texts textarea { min-height: 0; }
.ai-sources { align-self: flex-start; max-width: 92%; font-size: 11.5px; color: #54656f; background: rgba(255, 255, 255, .7); border-radius: 8px; padding: 6px 9px; margin-top: -2px; }
.ai-sources b { color: #3b4a54; }
.ai-sources .src { display: block; margin-top: 3px; padding-left: 8px; border-left: 2px solid #25d366; font-style: italic; }
.ai-chat .wa-bubble.std { background: #e7f3ff; }
.ai-chat .wa-bubble .kind { display: block; font-size: 10.5px; font-weight: 700; color: #54656f; margin-bottom: 2px; font-style: normal; }
.via-tag { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 5px; margin-left: 6px; vertical-align: middle; }
.via-ai { background: #fbeee8; color: #b4532f; }
.via-rule { background: var(--brand-50); color: var(--brand-700); }
.via-manual { background: var(--info-50); color: var(--info); }
.via-webhook { background: var(--surface-2); color: var(--muted); }

input.auto-filled { border-color: #e8c27a; background: var(--warn-50); }
.kind-tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 5px; margin-right: 6px; }
.kind-image { background: #e8f1fe; color: #1d4ed8; }
.kind-video { background: #f3e8ff; color: #7e22ce; }
.kind-audio { background: #fff1e6; color: #c2410c; }
.kind-document { background: var(--brand-50); color: var(--brand-700); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }

/* ---------- Tables (DataTables) ---------- */
.table-card .dt-container { padding: 0; }
.dt-container { font-size: 13.5px; }
.dt-container .dt-layout-row { padding: 14px 18px; margin: 0 !important; }
.dt-container .dt-layout-row.dt-layout-table { padding: 0; }
.dt-container .dt-layout-table > .dt-layout-cell { overflow-x: auto; }
div.dt-container .dt-input { width: auto; padding: 8px 12px; border: 1px solid var(--line-2) !important; border-radius: var(--radius-sm) !important; background-color: #fff; font: inherit; }
div.dt-container .dt-input:focus { border-color: var(--brand) !important; box-shadow: 0 0 0 3px rgba(18, 140, 74, .14); outline: none; }
div.dt-container .dt-length { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
div.dt-container .dt-length label { margin: 0; font-weight: 500; color: var(--muted); }
div.dt-container .dt-length select.dt-input { width: 76px; padding: 7px 28px 7px 12px !important; margin: 0 !important; background-position: right 8px center; }
div.dt-container .dt-search label { display: none; }
div.dt-container .dt-search input.dt-input {
  width: 280px; max-width: 100%; margin-left: 0 !important; padding-left: 36px !important;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236b7a72' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 12px center;
}
.dt-container .dt-info { color: var(--muted); font-size: 12.5px; }
table.dataTable { border-collapse: collapse !important; width: 100% !important; }
table.dataTable thead > tr > th {
  background: var(--surface-2); color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  padding: 11px 14px !important; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line) !important; white-space: nowrap; text-align: left;
}
table.dataTable tbody td { padding: 12px 14px !important; border-top: 1px solid var(--line) !important; vertical-align: top; }
table.dataTable tbody tr:first-child td { border-top: 0 !important; }
table.dataTable tbody tr { transition: background .12s; }
table.dataTable tbody tr:hover > * { background: #f6faf8 !important; box-shadow: none !important; }
table.dataTable tbody tr.editing > * { background: var(--brand-50) !important; }
table.dataTable.no-footer { border-bottom: 1px solid var(--line) !important; }
/* Semua kolom rata kiri, termasuk yang dideteksi sebagai angka/tanggal (mis. nomor HP) */
table.dataTable th.dt-type-numeric, table.dataTable td.dt-type-numeric,
table.dataTable th.dt-type-date, table.dataTable td.dt-type-date { text-align: left !important; }
table.dataTable th.dt-type-numeric div.dt-column-header,
table.dataTable th.dt-type-date div.dt-column-header { flex-direction: row !important; }
table.dataTable td.dt-empty { padding: 40px 14px !important; color: var(--muted); text-align: center; }
td.msg { max-width: 360px; white-space: pre-wrap; word-break: break-word; }
/* Tabel aduan punya dua kolom teks (aduan & balasan operator): jangan sampai menyempit hingga kata terpotong */
#cmpTable td.msg { min-width: 150px; }
#cmpTable th, #cmpTable td { padding-left: 10px; padding-right: 10px; }
/* Teks panjang: dipotong 2 baris + tombol "Selengkapnya" */
.clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; white-space: pre-wrap; word-break: break-word; }
.clamp.open { display: block; -webkit-line-clamp: unset; line-clamp: unset; }
.more-btn { display: inline-flex; align-items: center; gap: 3px; margin-top: 4px; padding: 0; border: 0; background: none; color: var(--brand); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.more-btn:hover { color: var(--brand-700); text-decoration: underline; }
.more-btn .i { transition: transform .2s; }
.more-btn.open .i { transform: rotate(180deg); }
.ellipsis { display: block; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-sub.ellipsis { max-width: 320px; }
.cell-sub { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.dir { display: inline-flex; align-items: center; gap: 5px; font-weight: 500; font-size: 12.5px; }
.dir.in { color: var(--info); }
.dir.out { color: var(--brand); }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.dt-container .dt-paging .dt-paging-button { border-radius: 8px !important; min-width: 34px; padding: 6px 10px !important; margin-left: 3px !important; border: 1px solid transparent !important; color: var(--text-2) !important; }
.dt-container .dt-paging .dt-paging-button:hover { background: var(--surface-2) !important; border-color: var(--line) !important; color: var(--text) !important; }
.dt-container .dt-paging .dt-paging-button.current,
.dt-container .dt-paging .dt-paging-button.current:hover { background: var(--brand) !important; border-color: var(--brand) !important; color: #fff !important; font-weight: 600; }
.dt-container .dt-paging .dt-paging-button.disabled { opacity: .4; }
div.dt-processing { border: 0 !important; box-shadow: var(--shadow) !important; border-radius: 10px !important; background: #fff !important; }
div.dt-processing > div:last-child > div { background: var(--brand) !important; }
@media (max-width: 760px) {
  .dt-container .dt-layout-row:not(.dt-layout-table) { flex-direction: column; align-items: stretch; gap: 10px; }
  .dt-container .dt-layout-cell { justify-content: flex-start !important; }
  div.dt-container .dt-search, div.dt-container .dt-search input.dt-input { width: 100%; }
  div.dt-container .dt-layout-row:first-child .dt-layout-cell.dt-layout-end { display: none; } /* "per halaman" disembunyikan di HP */
  div.dt-container .dt-layout-row:last-child .dt-layout-cell { justify-content: center !important; text-align: center; }
  /* tabel digeser ke samping, bukan diperas */
  table.dataTable { min-width: 760px; }
  td.msg { min-width: 200px; }
}

/* ---------- Docs ---------- */
.endpoint { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.method { font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: var(--brand-50); color: var(--brand-700); }
.url { font-family: ui-monospace, Consolas, monospace; font-size: 13px; color: var(--text-2); word-break: break-all; }
.code { position: relative; margin: 10px 0 0; }
.code pre { background: #0d1f16; color: #d4f0de; padding: 16px; border-radius: 10px; overflow-x: auto; margin: 0; line-height: 1.6; }
.code .copy { position: absolute; top: 8px; right: 8px; background: rgba(255, 255, 255, .08); color: #d4f0de; border: 1px solid rgba(255, 255, 255, .12); }
.code .copy:hover { background: rgba(255, 255, 255, .16); }
.params { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
.params th, .params td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.params th { background: var(--surface-2); color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.params td:first-child { white-space: nowrap; }
.tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; }
.tabs button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; font: inherit; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; }
.tabs button.active { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-hero { background: radial-gradient(circle at 20% 15%, rgba(37, 211, 102, .25), transparent 45%), radial-gradient(circle at 80% 90%, rgba(37, 211, 102, .15), transparent 40%), var(--side-bg); color: #fff; padding: 48px; display: flex; flex-direction: column; }
.auth-hero .brand { padding: 0; }
.auth-hero h1 { font-size: 34px; line-height: 1.15; font-weight: 800; margin: auto 0 14px; max-width: 460px; letter-spacing: -.02em; }
.auth-hero p { color: rgba(255, 255, 255, .7); max-width: 440px; font-size: 15px; }
.features { list-style: none; padding: 0; margin: 28px 0 auto; display: grid; gap: 12px; }
.features li { display: flex; gap: 12px; align-items: center; color: rgba(255, 255, 255, .85); }
.features .f-ic { width: 32px; height: 32px; border-radius: 9px; background: rgba(255, 255, 255, .08); display: grid; place-items: center; color: #25d366; flex: none; }
.auth-hero .foot { color: rgba(255, 255, 255, .4); font-size: 12px; margin-top: 32px; }
.auth-panel { display: grid; place-items: center; padding: 32px 20px; }
.auth-box { width: 100%; max-width: 380px; }
.auth-box h2 { font-size: 24px; margin-bottom: 6px; }
.auth-box .sub { color: var(--muted); margin-bottom: 24px; }
.auth-tabs { display: flex; background: #e9eeeb; border-radius: 10px; padding: 4px; margin-bottom: 22px; }
.auth-tabs button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 7px; font: inherit; font-weight: 500; cursor: pointer; color: var(--muted); }
.auth-tabs button.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 42px; }
.pw-wrap button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); padding: 6px; cursor: pointer; border-radius: 6px; display: grid; }
.mobile-brand { display: none; margin-bottom: 26px; color: var(--text); padding: 0 !important; }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .mobile-brand { display: flex; }
}
