/* WA Broadcast — Luxury theme (desktop) */

:root {
  --bg: #f4f2ec;
  --card: #ffffff;
  --border: #cfc9b8;
  --text: #1a2420;
  --muted: #68736d;
  --primary: #0c4a3e;
  --primary-2: #12836e;
  --gold: #c9a227;
  --gold-soft: #e9d9a6;
  --danger: #b3392f;
  --ok: #15803d;
  /* Sudut sedikit membulat — tetap tegas, tapi tidak setajam siku. Satu sumber
     untuk semua aturan; yang benar-benar lingkaran (titik status, avatar,
     spinner) memakai --radius-round. Jangan tulis angka radius di aturan lain.
       sm: badge, chip, input kecil · md: tombol, menu, input · (dasar): kartu,
       tabel · lg: dialog, lembar menu HP. */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-round: 50%;
  /* Kartu & tombol dibatasi garis tepi, bukan bayangan; bayangan hanya untuk
     lapisan yang melayang (dialog, dropdown, toast). */
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: 0 12px 32px rgba(20, 32, 27, 0.20);
  /* Bayangan hijau untuk elemen bermerek (tombol utama, pilihan aktif). */
  --shadow-brand: none;
  --shadow-brand-hover: none;
  /* Cincin fokus: hijau untuk isian (field), emas untuk aksi (tombol, chip) —
     dua warna supaya "sedang mengetik" dan "sedang memilih" terbaca berbeda. */
  --ring: 0 0 0 2px var(--primary-2);
  --ring-gold: 0 0 0 2px var(--gold);
  /* Garis rambut emas — pola yang sama dengan bingkai QR (.conn-box img.qr). */
  --hairline-gold: rgba(201, 162, 39, 0.35);
  /* Durasi tunggal untuk semua mikro-animasi hover/fokus. */
  --dur: 0.15s;
  --ease-spring: cubic-bezier(0.22, 1.2, 0.36, 1);
}

/* Fokus keyboard pada elemen aksi: cincin emas seragam. Field isian tidak ikut —
   mereka memakai --ring hijau lewat :focus masing-masing. */
.btn:focus-visible, .tab-btn:focus-visible, .chip:focus-visible, .btn-pill:focus-visible,
.lbl-act:focus-visible, .star-btn:focus-visible, .rcp-del:focus-visible,
.fd-remove:focus-visible, .pw-peek:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Plus Jakarta Sans", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  background: var(--bg);
  min-height: 100vh;
}

h2 {
  margin-top: 0;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 24px;
}
h2::after {
  content: '';
  display: block;
  width: 44px;
  height: 3px;
  margin-top: 8px;
  border-radius: var(--radius-sm);
  background: var(--gold);
}

/* ---------- Sidebar ---------- */
body { display: flex; align-items: stretch; }

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  width: 236px;
  flex-shrink: 0;
  padding: 26px 16px;
  background: var(--primary);
  color: #fff;
  box-shadow: none;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 60;
}
.brand {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
  padding: 0 10px;
  color: #fff;
}
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-head .brand { white-space: nowrap; padding-right: 0; }
/* Tombol ciut/lebar menu samping — hanya untuk layar lebar. */
.side-toggle {
  flex: none;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(233, 217, 166, 0.35);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  transition: background var(--dur), border-color var(--dur);
}
.side-toggle:hover { background: rgba(255, 255, 255, 0.12); border-color: var(--gold-soft); }
.side-toggle:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
/* Panah ganda mengarah ke kiri (ciutkan); dibalik saat menu ciut. */
.side-toggle-ico {
  width: 14px;
  height: 12px;
  background: #fff;
  clip-path: polygon(45% 0, 60% 0, 30% 50%, 60% 100%, 45% 100%, 0 50%, 45% 0, 85% 0, 100% 0, 70% 50%, 100% 100%, 85% 100%, 40% 50%, 85% 0);
}
@media (max-width: 860px) {
  .side-toggle { display: none; }
}
@media (min-width: 861px) {
  .sidebar { transition: width var(--dur); }
  .side-collapsed .sidebar { width: 68px; padding-left: 10px; padding-right: 10px; }
  .side-collapsed .side-head { flex-direction: column; gap: 14px; }
  .side-collapsed .brand { padding: 0; }
  .side-collapsed .brand-txt,
  .side-collapsed .tab-txt,
  .side-collapsed .sidebar-foot { display: none; }
  .side-collapsed .tab-btn { justify-content: center; padding-left: 0; padding-right: 0; }
  .side-collapsed .tab-btn:hover { transform: none; }
  .side-collapsed .tab-ico { font-size: 18px; }
  .side-collapsed .side-toggle-ico { transform: scaleX(-1); }
  /* Menu ciut: judul kelompok jadi garis pemisah; badge menempel di pojok ikon. */
  .side-collapsed .tab-group-title {
    height: 1px;
    margin: 0 8px 6px;
    padding: 0;
    overflow: hidden;
    font-size: 0;
    background: rgba(255, 255, 255, 0.16);
  }
  .side-collapsed .tab-btn { position: relative; }
  /* Kaki sidebar (nama + Keluar) tersembunyi saat ciut, jadi ikon Profil yang
     jadi jalan ke Profil — tombol Keluar juga ada di halaman itu. */
  .side-collapsed .tab-btn.tab-profile { display: flex; }
  .side-collapsed .tab-badge, .side-collapsed .tab-alert {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    padding: 0 4px;
    font-size: 10px;
    line-height: 16px;
  }
}
/* Menu dikelompokkan per pekerjaan (Percakapan, Broadcast, Rekap, Pengaturan).
   Daftar bisa digulir sendiri supaya layar laptop pendek tetap memuat kaki sidebar.
   overflow-y:auto memotong apa pun yang keluar dari kotak ini, jadi disediakan
   ruang 6px (padding) untuk geser hover 2px ditambah cincin fokus 2px+2px;
   margin negatif menjaga posisi menu tetap sejajar dengan sebelumnya. */
.tabs {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1 1 auto;
  min-height: 0;
  margin: -6px;
  padding: 6px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
}
.tab-group { display: flex; flex-direction: column; gap: 2px; }
.tab-group-title {
  padding: 0 14px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.48);
}
/* Profil di layar lebar dibuka lewat nama di kaki sidebar; menunya hanya di lembar HP. */
.tab-btn.tab-profile { display: none; }
/* Bar bawah + lembar "Lainnya" hanya untuk layar HP (lihat blok max-width: 860px). */
.bottom-bar, .more-backdrop { display: none; }
/* Badge jumlah (Kotak Masuk) dan tanda perlu perhatian (Sesi). */
.tab-badge, .tab-alert {
  margin-left: auto;
  flex: none;
  border-radius: var(--radius-sm);
  min-width: 20px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 800;
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.tab-badge { background: var(--gold); color: var(--primary); }
.tab-alert { background: var(--danger); color: #fff; }
.tab-badge[hidden], .tab-alert[hidden] { display: none; }
.tab-btn {
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  border: 1px solid transparent;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: color var(--dur), background var(--dur), transform var(--dur) var(--ease-spring);
}
.tab-ico { font-size: 16px; line-height: 1; }
.tab-btn:hover { background: rgba(255, 255, 255, 0.10); color: #fff; transform: translateX(2px); }
.tab-btn.active {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(233, 217, 166, 0.45);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--gold);
}

main { flex: 1; min-width: 0; padding: 32px 36px 56px; }
main > .tab-section { max-width: 980px; margin: 0 auto; }
/* Layar lebar: Pesan Masuk dibagi dua kolom supaya tidak perlu banyak menggulir.
   Di bawah lebar ini isinya kembali satu kolom berurutan. */
.ib-col { min-width: 0; }
/* Tab bagian Pesan Masuk: hanya untuk layar sempit. */
/* .seg ikut di selector: aturan dasar .seg (di bawah) menyetel display dan akan menang kalau specificity sama. */
.seg.ib-pane-tabs { display: none; }
@media (max-width: 860px) {
  .seg.ib-pane-tabs {
    display: flex;
    position: sticky;
    top: 45px; /* tinggi topbar di layar sempit (brand 16px + padding 10px atas-bawah) */
    z-index: 30;
    margin-bottom: 14px;
  }
  .ib-pane-tabs .seg-opt { flex: 1 1 0; justify-content: center; min-height: 40px; padding: 8px 6px; }
  .ib-cols[data-pane="fitur"] .ib-pane:not([data-pane-of="fitur"]),
  .ib-cols[data-pane="pengirim"] .ib-pane:not([data-pane-of="pengirim"]),
  .ib-cols[data-pane="aktivitas"] .ib-pane:not([data-pane-of="aktivitas"]) { display: none; }
}
@media (min-width: 1500px) {
  main > #tab-inbound, main > #tab-messages { max-width: 1720px; }
  .ib-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 24px; align-items: start; }
  /* Pesan Langsung: form lebih sempit dari riwayat — tabel riwayat yang butuh ruang. */
  .dm-cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 0 24px; align-items: start; }
}
.tab-section { display: none; }
.tab-section.active { display: block; animation: fade-up 0.25s var(--ease-spring); }
@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Card & form ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur);
}
/* Hanya bayangan, tanpa geser: kartu ini berisi form — kalau ikut melompat saat
   kursor lewat, teks yang sedang diketik ikut bergeser. */
.card:hover { border-color: var(--muted); }
/* Judul di dalam kartu: aksen emas kecil, gema dari garis di bawah h2. */
.card > h3::after {
  content: '';
  display: block;
  width: 28px;
  height: 2px;
  margin-top: 6px;
  border-radius: var(--radius-sm);
  background: var(--gold);
}
fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 16px;
  padding: 14px 18px;
}
legend {
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 0 6px;
}
/* Titik emas di depan legend — penanda kelompok isian. */
legend::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 7px;
  vertical-align: 1px;
  border-radius: var(--radius-round);
  background: var(--gold);
}
.radio { margin-right: 18px; font-weight: 500; }

label {
  display: block;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 14px 0 6px;
}
/* email & password IKUT di sini: tanpa keduanya, form login jatuh ke gaya
   bawaan browser dan terlihat asing di tengah aplikasi. */
input[type="text"], input[type="number"], input[type="email"], input[type="password"],
input[type="date"], input[type="search"], textarea, select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font: inherit;
  font-size: 14px;
  background: #fff;
  transition: border-color var(--dur), box-shadow var(--dur);
}
input[type="text"]:focus, input[type="number"]:focus, input[type="email"]:focus,
input[type="password"]:focus, input[type="date"]:focus, input[type="search"]:focus,
textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary-2);
  box-shadow: var(--ring);
}
input[type="file"] { padding: 6px 0; font-size: 13px; }
textarea { resize: vertical; }

.row { display: flex; gap: 16px; }
.row.actions { margin-top: 18px; align-items: center; flex-wrap: wrap; }
.col { flex: 1; }

/* ---------- Kotak centang & pilihan (pengganti gambar bawaan browser) ---------- */
input[type="checkbox"], input[type="radio"] {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  width: 18px;
  height: 18px;
  /* Tanpa gambar bawaan, kotak ini tidak punya ukuran sendiri: aturan lain yang
     menyetel width:auto akan membuatnya gepeng. Ukuran minimum menjaganya. */
  min-width: 18px;
  min-height: 18px;
  margin: 0;
  border: 2px solid var(--muted);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  vertical-align: -3px;
  transition: border-color var(--dur), background var(--dur);
}
input[type="checkbox"]:hover, input[type="radio"]:hover { border-color: var(--primary); }
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline: none; box-shadow: var(--ring); }
input[type="checkbox"]:checked, input[type="radio"]:checked { border-color: var(--primary); background: var(--primary); }
/* Centang: tanda ✓ putih. Pilihan: kotak terisi berbingkai putih — beda bentuk, sama tegasnya. */
input[type="checkbox"]:checked {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M2.5 7.5l3 3 6-7' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='square'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
}
input[type="radio"]:checked { box-shadow: inset 0 0 0 3px #fff; }
input[type="radio"]:checked:focus-visible { box-shadow: inset 0 0 0 3px #fff, var(--ring); }
input[type="checkbox"]:disabled, input[type="radio"]:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap; /* label tombol tidak boleh pecah jadi pil bertingkat; biarkan induk yang wrap */
  transition: transform var(--dur) var(--ease-spring), box-shadow var(--dur), background var(--dur), border-color var(--dur);
}
.btn:hover { background: #f6f4ee; border-color: var(--text); }
.btn:active { background: #ebe7da; }
.btn.primary {
  background: var(--primary);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-brand);
}
.btn.primary:hover { background: var(--primary-2); border-color: transparent; }
.btn.danger { background: #fff; border-color: rgba(179, 57, 47, 0.45); color: var(--danger); }
.btn.danger:hover { background: #fdf3f2; border-color: var(--danger); }
.btn.small { padding: 6px 14px; font-size: 13px; }
/* Layar sentuh: tombol kecil tetap cukup tinggi untuk jari. */
@media (max-width: 860px) {
  .btn.small { padding: 10px 14px; min-height: 40px; }
  .btn, .btn-pill, .ib-switch .seg-opt, .cs.ib-group-select > .cs-trigger { min-height: 40px; }
  /* Kotak centang & pilihan: area sentuh diperluas tanpa membesarkan gambarnya. */
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; min-width: 22px; min-height: 22px; }
}
/* Tombol aksi utama di akhir form — beri jarak dari elemen di atasnya */
#bc-form > button[type="submit"] { margin-top: 20px; }

/* Control Speed / Jeda Input yang Luxury & Rapi */
.speed-input-group {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px 4px 3px 12px;
  flex-wrap: wrap; /* di layar sempit pil "Detik/Rate" turun ke baris kedua, angkanya tetap terlihat */
  transition: border-color var(--dur), box-shadow var(--dur);
}
.speed-input-group:focus-within {
  border-color: var(--primary-2);
  box-shadow: var(--ring);
}
.speed-input-inline {
  position: relative;
  flex: 1;
  min-width: 150px; /* angka + satuan; tanpa ini input dihimpit pil sampai lebar 0 */
  display: flex;
  align-items: center;
}
.speed-input-inline input {
  border: none !important;
  box-shadow: none !important;
  padding: 7px 0 !important;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  background: transparent !important;
  width: 100%;
}
.speed-unit {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  padding-left: 6px;
  padding-right: 8px;
  pointer-events: none;
}
.speed-pill-toggle {
  display: inline-flex;
  margin-left: auto;
  background: #f4f2ec;
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.04);
}
.btn-pill {
  border: none;
  background: transparent;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--muted);
  transition: all var(--dur) var(--ease-spring);
}
.btn-pill:hover {
  color: var(--text);
}
.btn-pill.active {
  background: #fff;
  color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}
#bc-speed-preview {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-top: 6px;
}

/* Tambah nomor di detail history (hanya saat broadcast belum diproses) */
.recipient-add {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 16px 0 6px;
}
.recipient-add input {
  flex: 1;
  max-width: 520px;
}
.hint-edit {
  font-size: 12px;
  margin: 0 0 12px;
}

/* Editor baris nomor tujuan di form Buat Broadcast */
#bc-recipient-rows { margin-top: 10px; }
.rcp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}
.rcp-warn { color: var(--danger); font-weight: 600; }
.rcp-list {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  padding: 6px;
}
.rcp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 4px;
}
.rcp-idx {
  flex: none;
  width: 30px;
  text-align: right;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.rcp-row input {
  flex: 1;
  padding: 6px 10px !important;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  border-radius: var(--radius-sm);
}
.rcp-row.invalid input {
  border-color: rgba(179, 57, 47, 0.5);
  background: #fdf6f5;
}
.rcp-del {
  flex: none;
  width: 26px;
  height: 26px;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  transition: color var(--dur), border-color var(--dur), background var(--dur);
}
.rcp-del:hover { color: var(--danger); border-color: var(--danger); background: #fdf3f2; }
.rcp-more { font-size: 12px; margin: 8px 0 0; }

/* ---------- Badge ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  /* Garis rambut sewarna teks (tembus pandang) — badge terasa "dicetak", bukan
     sekadar blok warna; latar & warna teks tiap status tidak diubah. */
  box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 18%, transparent);
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: var(--radius-round);
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 16%, transparent);
}
/* Status yang masih bekerja: titiknya berdenyut pelan. Hanya titiknya — teks
   tetap diam supaya terbaca. */
.badge-running::before, .badge-sending::before, .badge-connecting::before,
.badge-qr::before, .badge-pairing_code::before, .badge-queued::before {
  animation: badge-pulse 1.6s ease-in-out infinite;
}
@keyframes badge-pulse { 50% { opacity: 0.4; } }
@media (prefers-reduced-motion: reduce) { .badge::before { animation: none; } }
.badge-pending  { background: #fdf3d7; color: #92610e; }
.badge-running  { background: #dcebfb; color: #1d4fa1; }
.badge-sending  { background: #dcebfb; color: #1d4fa1; }
.badge-completed{ background: #d9f3e3; color: #14663a; }
.badge-sent     { background: #d9f3e3; color: #14663a; }
.badge-failed   { background: #fbe3e1; color: #a02c23; }
.badge-cancelled{ background: #e9e7e1; color: #4b5563; }
.badge-skipped  { background: #e9e7e1; color: #4b5563; }
/* Status pesan langsung (queued → sending → sent → delivered → read / failed).
   sending, sent, failed memakai aturan di atas. */
.badge-queued   { background: #fdf3d7; color: #92610e; }
.badge-delivered{ background: #d9f3e3; color: #14663a; }
.badge-read     { background: var(--primary); color: #fff; }
/* Status sesi WhatsApp */
.badge-uninitialized { background: #e9e7e1; color: #4b5563; }
.badge-connecting    { background: #dcebfb; color: #1d4fa1; }
.badge-qr            { background: #e9e3fb; color: #5b21b6; }
.badge-connected     { background: #d9f3e3; color: #14663a; }
.badge-disconnected  { background: #fbe3e1; color: #a02c23; }
.badge-auth_failure  { background: #fbe3e1; color: #a02c23; }
.badge-qr_expired    { background: #fdf3d7; color: #92610e; }
.badge-pairing_code  { background: #e9e3fb; color: #5b21b6; }

/* Jalur pembuatan broadcast (web / api / grpc). Nilai dari kolom source —
   baris lama sebelum pencatatan ini tercatat 'api'. */
.badge-src-web  { background: #e9e3fb; color: #5b21b6; }
.badge-src-api  { background: #dcebfb; color: #1d4fa1; }
.badge-src-grpc { background: #d9f3e3; color: #14663a; }

/* ---------- Toolbar riwayat (saklar admin platform) ---------- */
.hist-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 0 0 12px;
}
.scope-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.scope-toggle input {
  width: 15px;
  height: 15px;
  accent-color: #1d4fa1;
  cursor: pointer;
}
.hist-scope-note { font-size: 12px; }

/* ---------- Table ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
th {
  background: #faf8f3;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  white-space: nowrap; /* judul kolom jangan pecah dua baris saat sempit */
  border-bottom-color: var(--gold-soft); /* pemisah kepala tabel: garis emas tipis */
}
/* Pembungkus tabel (JS merender <table> di dalam .table-wrap). Bingkai, radius,
   dan bayangan pindah ke sini supaya tabel di dalamnya bebas lebih lebar dari
   layar dan di-scroll ke samping SENDIRI — bukan menyeret seluruh halaman. */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-wrap > table { border: 0; border-radius: 0; box-shadow: none; }
tbody tr { transition: background var(--dur); }
tbody td { transition: box-shadow var(--dur); }
tbody tr:hover { background: #faf8f3; }
/* Baris yang disorot dapat penanda emas di tepi kiri — pola yang sama dengan
   tab aktif di sidebar. Tanpa transform: <tr> yang digeser merusak tata letak tabel. */
tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--gold); }
tr:last-child td { border-bottom: none; }

/* ---------- Connection / Sessions ---------- */
.conn-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.conn-box img.qr {
  width: 260px;
  height: 260px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--gold-soft);
  outline: 1px solid var(--hairline-gold);
  outline-offset: 4px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.conn-connected { font-size: 18px; margin-bottom: 8px; }
.conn-error { color: var(--danger); margin-bottom: 12px; font-weight: 500; }

/* Kode pairing 8 digit — padan visual img.qr: besar, monospace, mudah disalin. */
.conn-box .pairing-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-align: center;
  margin: 14px auto;
  padding: 16px 20px;
  width: fit-content;
  background: #fff;
  border: 1px solid var(--gold-soft);
  outline: 1px solid var(--hairline-gold);
  outline-offset: 4px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  user-select: all;
}

.session-add { display: flex; gap: 10px; margin-bottom: 18px; }
.session-add input { flex: 1; max-width: 380px; }
.session-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 18px;
}
.session-card {
  text-align: left;
  padding: 22px;
  transition: transform var(--dur) var(--ease-spring), box-shadow var(--dur), border-color var(--dur);
}
.session-card:hover { border-color: var(--primary); }
.session-card h4 { margin: 10px 0 4px; font-weight: 700; }
.session-card img.qr { display: block; margin: 12px auto; }
.session-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 16px;
}
.session-head strong { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; }
.session-head .avatar {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-round);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  background: var(--primary);
  /* Cincin emas tipis di luar avatar (celah putih 2px lalu garis emas 1px). */
  box-shadow: 0 0 0 2px var(--card), 0 0 0 3px var(--gold-soft);
}
.session-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* ---------- Custom dropdown (.cs) ---------- */
.cs { position: relative; }
.cs-native { display: none; }
.cs-trigger:disabled { opacity: 0.55; cursor: not-allowed; }
/* Panel ditempel ke viewport (posisi dihitung customSelect.js) agar tidak terpotong wadah ber-scroll. */
.cs-float > .cs-panel { position: fixed; right: auto; z-index: 500; }
/* Dropdown ringkas di dalam baris tabel. */
.cs.ib-group-select { padding: 0; }
.cs.ib-group-select > .cs-trigger { padding: 7px 10px; font-size: 13px; }

.cs-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.cs-trigger:hover { border-color: #c8c2b2; }
.cs-trigger:focus-visible,
.cs-trigger[aria-expanded="true"] {
  outline: none;
  border-color: var(--primary-2);
  box-shadow: var(--ring);
}
.cs-trigger-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cs-placeholder { color: var(--muted); font-weight: 400; }
.cs-arrow {
  flex: none;
  width: 16px;
  height: 16px;
  background: var(--muted);
  clip-path: polygon(0 15%, 15% 15%, 50% 55%, 85% 15%, 100% 15%, 50% 100%);
  transition: transform var(--dur) var(--ease-spring);
}
.cs-trigger[aria-expanded="true"] .cs-arrow { transform: rotate(180deg); }

.cs-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 40;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: cs-in 0.14s var(--ease-spring);
}
@keyframes cs-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cs-search {
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-bottom: 1px solid var(--border);
  font: inherit;
  outline: none;
}
.cs-list { max-height: 260px; overflow-y: auto; padding: 5px; }
.cs-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--dur), box-shadow var(--dur);
}
.cs-option:hover,
.cs-option.active { background: #f2f5f3; }
.cs-option.selected { background: #e6f2ee; box-shadow: inset 3px 0 0 var(--gold); }
.cs-option.disabled { opacity: 0.5; cursor: not-allowed; }
.cs-avatar {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-round);
  background: #dcefec;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
}
.cs-opt-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.cs-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.cs-title .cs-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-sub { font-size: 12px; color: var(--muted); }
.cs-check { flex: none; color: var(--primary); font-weight: 800; }
.cs-media { font-size: 13px; }
.cs-mini-badge {
  flex: none;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: #dcebfb;
  color: #1d4fa1;
  white-space: nowrap;
}
.cs-empty { padding: 10px; color: var(--muted); text-align: center; font-size: 13px; }

/* ---------- Modal (pengganti confirm/prompt native) ---------- */
.modal {
  border: none;
  padding: 0;
  background: transparent;
  max-width: min(440px, 92vw);
}
.modal::backdrop {
  background: rgba(10, 18, 24, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal-card {
  position: relative;
  background: var(--card);
  border: 1px solid rgba(229, 225, 214, 0.8);
  border-radius: var(--radius-lg);
  padding: 28px 26px 24px;
  box-shadow: var(--shadow-lg);
  /* Garis rambut emas berjarak di luar kartu — pola bingkai QR. */
  outline: 1px solid rgba(233, 217, 166, 0.30);
  outline-offset: 4px;
  animation: modal-in 0.22s var(--ease-spring);
  overflow: hidden;
}
/* Garis aksen di tepi atas kartu */
.modal-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--primary);
}
.modal-card.danger::before {
  background: var(--danger);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-title {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal-icon {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-round);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background: #eef4f2;
  box-shadow: 0 0 0 1px var(--gold-soft); /* aksen ikon: cincin emas tipis */
}
.modal-card.danger .modal-icon { background: #fbe9e7; box-shadow: 0 0 0 1px #f0c4c0; }
.modal-body {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
}
.modal-input-wrap { margin-top: 16px; }
.modal-label {
  display: block;
  font-weight: 700;
  margin: 0 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.modal-input {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-md);
  transition: border-color var(--dur), box-shadow var(--dur);
}
.modal-input:focus {
  outline: none;
  border-color: var(--primary-2);
  box-shadow: var(--ring);
}
/* Mode reveal: nilai sekali-lihat (secret) — membungkus, bisa diblok utuh untuk disalin manual. */
.modal-reveal-wrap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.modal-reveal-val {
  flex: 1 1 220px;
  min-width: 0;
  padding: 9px 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  background: #faf8f3;
  border: 1px solid var(--gold);
  overflow-wrap: anywhere;
  user-select: all;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}
.modal-actions .btn { padding: 10px 20px; }
.modal-cancel { background: transparent; }
.modal-cancel:hover { background: #f4f2ec; }
.modal-ok.primary {
  background: var(--primary);
  border-color: transparent;
  box-shadow: var(--shadow-brand);
}
.modal-ok.primary:hover { background: var(--primary-2); }
.modal-ok.danger {
  background: var(--danger);
  border-color: transparent;
  color: #fff;
  box-shadow: none;
}
.modal-ok.danger:hover { background: #962c24; }

/* ---------- Misc ---------- */
.muted { color: var(--muted); font-weight: 400; }
.hidden { display: none !important; }
blockquote {
  margin: 14px 0;
  padding: 14px 16px;
  background: #faf8f3;
  border-left: 4px solid var(--gold);
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  word-break: break-word;
}
.progress {
  height: 10px;
  background: #e9e7e1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: 14px 0;
}
.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-sm);
  transition: width 0.5s;
}
.detail-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.detail-img { max-width: 220px; border-radius: var(--radius-md); margin: 8px 0; box-shadow: var(--shadow-sm); }
.preview-img { max-width: 160px; max-height: 120px; border-radius: var(--radius-sm); margin-top: 6px; box-shadow: var(--shadow-sm); }
.toast {
  position: fixed;
  top: 76px;
  right: 20px;
  background: rgba(20, 30, 26, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  z-index: 50;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.toast.error { background: rgba(150, 44, 36, 0.94); }
.toast.ok { background: rgba(12, 74, 62, 0.94); }

/* ---------- Responsive: sidebar → topbar horizontal ---------- */
@media (max-width: 860px) {
  body { display: block; }
  /* Topbar satu baris: brand + identitas pengguna. Navigasi TIDAK di sini —
     enam tab tidak pernah muat di satu baris HP (tergulung/terpotong dan
     terbaca rusak), jadi tab dipindah ke bar tetap di bawah layar. */
  .sidebar {
    /* Tinggi bar bawah dikunci di satu tempat: bar dan lembar "Lainnya" (yang
       berdiri tepat di atasnya) sama-sama keturunan .sidebar. */
    --bottom-bar-h: 66px;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    width: auto;
    height: auto;
    padding: 10px 16px;
    position: sticky;
    top: 0;
    box-shadow: none;
  }
  .brand { padding: 0; font-size: 16px; white-space: nowrap; }
  /* Selector diperkuat (.sidebar .sidebar-foot): definisi .sidebar-foot di
     bagian profil ada DI BAWAH blok ini dan akan menang kalau specificity sama. */
  .sidebar .sidebar-foot { flex: 1; min-width: 0; justify-content: flex-end; margin: 0; padding-top: 0; border-top: 0; }
  .who-name { flex: 0 1 auto; }

  /* Bar bawah: empat menu harian + "Lainnya", masing-masing selebar seperlima
     layar (±62px di 320px) supaya label utuh dan nyaman disentuh jari. Menu
     lengkap (#side-tabs) disembunyikan dan dibuka sebagai lembar "Lainnya".
     Lapisan di dalam konteks tumpuk .sidebar: latar (1) < lembar (2) < bar (3),
     jadi bar tetap bisa diketuk saat lembar terbuka. */
  .bottom-bar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    box-sizing: border-box;
    height: calc(var(--bottom-bar-h) + env(safe-area-inset-bottom, 0px));
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    background: var(--primary);
    border-top: 1px solid rgba(233, 217, 166, 0.22);
  }
  .bottom-bar .tab-btn {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 6px 0;
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.66);
  }
  .bottom-bar .tab-ico { font-size: 19px; }
  .bottom-bar .tab-txt {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* Aktif: garis emas pendek di atas ikon, pengganti garis kiri di sidebar. */
  .bottom-bar .tab-btn.active {
    border-color: transparent;
    color: #fff;
    box-shadow: inset 0 2px 0 var(--gold);
  }
  .bottom-bar .tab-badge, .bottom-bar .tab-alert {
    position: absolute;
    top: 2px;
    left: calc(50% + 6px);
    margin: 0;
    min-width: 18px;
    padding: 0 4px;
    font-size: 10px;
    line-height: 18px;
  }
  .tab-btn:hover { transform: none; }

  /* Lembar "Lainnya": menu lengkap tanpa yang sudah ada di bar bawah. */
  .tabs { display: none; }
  /* Halaman di belakang lembar tidak ikut tergulir. */
  body.more-open { overflow: hidden; }
  .more-open .tabs {
    display: flex;
    position: fixed;
    margin: 0;
    left: 0;
    right: 0;
    bottom: calc(var(--bottom-bar-h) + env(safe-area-inset-bottom, 0px));
    z-index: 2;
    max-height: min(70vh, 560px);
    padding: 16px 12px 12px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: var(--primary);
    border-top: 1px solid rgba(233, 217, 166, 0.35);
    box-shadow: var(--shadow-lg);
  }
  .tabs .tab-btn[data-primary], .tabs .tab-group[data-sheet-hidden] { display: none; }
  .tabs .tab-btn { min-height: 48px; }
  .tabs .tab-btn.tab-profile { display: flex; }
  .more-open .more-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1;
    background: rgba(12, 20, 17, 0.45);
  }
  /* Ruang bawah untuk bar tab supaya konten terakhir tidak tertutup. */
  main { padding: 20px 16px calc(88px + env(safe-area-inset-bottom, 0px)); }
  /* Tabel di layar sempit: beri lebar dasar supaya kolom tidak memecah kata
     per baris; sisanya digulung di dalam .table-wrap. */
  .table-wrap > table { min-width: 720px; }
  .table-wrap > table td { white-space: nowrap; }
  /* Kolom teks panjang (isi pesan template, pesan error) — satu-satunya yang
     boleh wrap; diberi lebar dasar supaya tidak dipaksa jadi kolom sempit. */
  .table-wrap > table td.col-wrap { white-space: normal; min-width: 240px; }
}

/* ---------- Responsive: tabel panjang jadi tumpukan kartu ----------
   Dipakai tabel yang ditandai .table-wrap.cards. Tiap <tr> jadi satu kartu dan
   tiap <td> jadi baris "label — nilai"; labelnya diambil dari data-label sel
   (kepala tabel disembunyikan, jadi tanpa ini nilai kehilangan konteks).
   Sel tanpa data-label sengaja tidak berlabel: .c-id dan .c-status membentuk
   kepala kartu, .c-actions jadi baris tombol di kakinya. */
@media (max-width: 640px) {
  .table-wrap.cards {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
  }
  .table-wrap.cards > table,
  .table-wrap.cards > table tbody { display: block; min-width: 0; width: 100%; }
  .table-wrap.cards > table thead { display: none; }
  .table-wrap.cards > table tr {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    /* Jarak antar kolom 0: kepala kartu (.c-id + .c-status) berbagi satu garis
       emas — dengan gap, garisnya putus jadi dua potong. Sel lain membentang
       penuh sehingga tak terpengaruh. */
    gap: 2px 0;
    margin-bottom: 12px;
    padding: 14px 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
  }
  .table-wrap.cards > table tr:last-child { margin-bottom: 0; }
  .table-wrap.cards > table tr:hover { background: var(--card); }
  .table-wrap.cards > table tr:hover td:first-child { box-shadow: none; }
  .table-wrap.cards > table td {
    grid-column: 1 / -1;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    padding: 3px 0;
    border: 0;
    white-space: normal;
    min-width: 0;
  }
  .table-wrap.cards > table td::before {
    content: attr(data-label);
    flex: none;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
  }
  /* Sel kosong (mis. kolom error saat pengiriman berhasil) dibuang sama sekali —
     kalau tidak, yang tersisa cuma label menggantung tanpa nilai. */
  .table-wrap.cards > table td:empty { display: none; }
  /* Teks panjang (pesan error): label di atas, isinya rata kiri di bawahnya.
     Berdampingan seperti sel lain membuatnya terhimpit jadi kolom sempit. */
  .table-wrap.cards > table td.col-wrap {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    min-width: 0;
  }
  .table-wrap.cards > table td.c-id {
    /* Nomor tujuan bisa 13 digit — biarkan memakai ruang yang tersisa. */
    min-width: 0;
    overflow-wrap: anywhere;
  }
  /* Kepala kartu: nomor di kiri, badge status di kanan, dipisah garis emas. */
  .table-wrap.cards > table td.c-id,
  .table-wrap.cards > table td.c-status {
    grid-column: auto;
    padding: 0 0 10px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--gold-soft);
  }
  .table-wrap.cards > table td.c-id { font-weight: 800; font-size: 16px; }
  .table-wrap.cards > table td.c-status { justify-content: flex-end; }
  /* Tombol aksi: satu baris penuh di kaki kartu, boleh membungkus. */
  .table-wrap.cards > table td.c-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
    margin-top: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
  }
  .table-wrap.cards > table td.c-actions::before { content: none; }
  .table-wrap.cards > table td.c-actions .btn { flex: 1 1 auto; text-align: center; }
}

/* ---------- Responsive: dua kolom jadi bertumpuk ---------- */
@media (max-width: 640px) {
  /* .row.actions dikecualikan — barisan tombol cukup wrap, bukan bertumpuk. */
  .row:not(.actions) { flex-direction: column; gap: 0; }
  .seg { display: flex; width: 100%; }
  .seg-opt { flex: 1; justify-content: center; padding: 9px 12px; }
  .picker-filters { flex-wrap: wrap; }
  .picker-filters .cs, .picker-filters select { flex: 1 1 100%; }
}

/* ---------- Loading & state (spinner, skeleton, empty/error) ---------- */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  vertical-align: -2px;
  border: 2px solid rgba(201, 162, 39, 0.30); /* jalur emas, kepala hijau */
  border-top-color: var(--primary);
  border-radius: var(--radius-round);
  animation: spin 0.7s linear infinite;
}
.btn.primary .spinner { border-color: rgba(255, 255, 255, 0.35); border-top-color: #fff; }
.btn.is-busy { opacity: 0.75; cursor: wait; }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton-wrap { display: grid; gap: 14px; }
.skeleton {
  border-radius: var(--radius);
  background: #e9e6dc;
  animation: shimmer 1.1s ease-in-out infinite alternate;
}
.sk-card { height: 118px; }
.sk-row { height: 44px; border-radius: var(--radius-md); }
@keyframes shimmer {
  from { opacity: 1; }
  to   { opacity: 0.45; }
}

.state-box {
  text-align: center;
  padding: 44px 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  /* Bingkai putus-putus emas di SISI DALAM menggantikan tepi putus-putus abu:
     tetap terbaca "kosong/placeholder", tapi rapi seperti kartu lain. */
  outline: 1px dashed var(--hairline-gold);
  outline-offset: -6px;
}
.state-icon {
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 12px;
  font-size: 30px;
  border-radius: var(--radius-round);
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--gold-soft), 0 0 0 5px rgba(201, 162, 39, 0.08);
}
.state-title { font-weight: 800; font-size: 16px; margin: 0 0 6px; letter-spacing: -0.01em; }
.state-box .muted { margin: 0 auto 18px; max-width: 420px; }
.state-box.error { border-color: rgba(179, 57, 47, 0.4); outline-color: rgba(179, 57, 47, 0.3); }
.state-box.error .state-icon { background: #fdf3f2; box-shadow: 0 0 0 1px #f0c4c0, 0 0 0 5px rgba(179, 57, 47, 0.07); }
.state-box.error .state-title { color: var(--danger); }

/* ---------- Segmented control (pengganti radio) ---------- */
.seg {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  background: #edeade;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.seg-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 9px 20px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  transition: background var(--dur), color var(--dur), box-shadow var(--dur), transform var(--dur) var(--ease-spring);
}
.seg-opt:hover { color: var(--text); }
.seg-opt:active { transform: scale(0.97); }
.seg-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg-ico { font-size: 15px; }
.seg-opt:has(input:checked) {
  background: var(--primary);
  color: #fff;
  box-shadow: none;
}
.seg-opt:has(input:focus-visible) { box-shadow: var(--ring); }

/* ---------- File dropzone ---------- */
.file-native { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.file-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: #fcfbf7;
  padding: 26px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--dur), background var(--dur), box-shadow var(--dur), transform var(--dur) var(--ease-spring);
}
.file-drop:hover, .file-drop.drag {
  border-color: var(--gold);
  background: #faf7ec;
  box-shadow: var(--ring-gold);
}
.file-drop.drag { transform: scale(1.01); }
.fd-ico { font-size: 30px; margin-bottom: 8px; }
.fd-title { font-weight: 700; font-size: 14px; margin: 0 0 2px; }
.fd-sub { font-size: 12px; color: var(--muted); margin: 0; }
.file-drop.has-file {
  border-style: solid;
  border-color: var(--primary-2);
  background: #f4faf7;
  text-align: left;
  padding: 14px 16px;
  cursor: default;
}
.fd-file { display: flex; align-items: center; gap: 14px; }
.fd-thumb {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.fd-meta { flex: 1; min-width: 0; }
.fd-name {
  font-weight: 700;
  font-size: 14px;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fd-size { font-size: 12px; color: var(--muted); margin: 2px 0 0; }
.fd-remove {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-round);
  cursor: pointer;
  font-size: 13px;
  transition: color var(--dur), border-color var(--dur), background var(--dur);
}
.fd-remove:hover { color: var(--danger); border-color: var(--danger); background: #fdf3f2; }

/* ---------- Kontak ---------- */
.label-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
}
.label-row label { margin-bottom: 0; }

.ct-labels-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 26px;
}
.ct-labels-head h3 { margin: 0; }

.ct-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 4px;
}
.lbl-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  font-size: 13px;
  font-weight: 600;
  transition: transform var(--dur) var(--ease-spring), box-shadow var(--dur), border-color var(--dur);
}
.lbl-chip:hover { border-color: var(--primary); }
.lbl-count {
  min-width: 20px;
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  background: var(--gold-soft);
  color: #6b5410;
  font-size: 11px;
  text-align: center;
}
.lbl-act {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 3px 4px;
  border-radius: var(--radius-sm);
  transition: background var(--dur), color var(--dur);
}
.lbl-act:hover { background: rgba(20, 32, 27, 0.07); color: var(--text); }

.ct-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0 12px;
  flex-wrap: wrap;
}
.ct-search { flex: 1 1 260px; margin: 0; }
.ct-label-filter { flex: 0 0 200px; margin: 0; }
.ct-count { margin-left: auto; font-size: 13px; }

.ct-notes {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
.ct-actions { white-space: nowrap; }
.ct-warn { cursor: help; }

.ct-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 14px;
}

/* ---------- Picker (dialog kaya) ---------- */
/* Lebar picker WAJIB dipasang di elemen <dialog>, dan WAJIB pakai `width` —
   bukan `max-width` saja. Dua sebab, keduanya sudah terbukti bikin salah tampil:
     1. .modal membatasi dialog ke 440px; kalau hanya kartunya yang dilebarkan,
        kartu meluber keluar dialog dan tepi kanannya terpotong (tombol hilang).
     2. <dialog> defaultnya width:fit-content — menyusut mengikuti isi. `max-width`
        cuma jadi batas atas yang tak pernah tercapai, sehingga dialog kontak
        menyempit ke ~447px meski dibatasi 700px. */
.modal.picker { width: min(560px, 92vw); max-width: 92vw; }
.modal.picker-contacts { width: min(700px, 94vw); max-width: 94vw; }
.picker-card { width: 100%; }

.picker-filters {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}
.picker-filters input { flex: 1 1 auto; margin: 0; }
.picker-filters select { flex: 0 0 190px; margin: 0; }

.picker-bulk {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.picker-bulk .pk-status { margin-left: auto; font-size: 12px; }

.picker-list {
  max-height: min(46vh, 380px);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 6px;
}
.picker-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--dur);
}
.picker-item:hover { background: rgba(18, 131, 110, 0.08); }
.picker-item input { margin: 3px 0 0; flex: 0 0 auto; }
.picker-item-body { display: flex; flex-direction: column; min-width: 0; }
.picker-item-label { font-weight: 600; }
.picker-item-sub { font-size: 12px; color: var(--muted); }
.picker-empty { padding: 22px; text-align: center; margin: 0; }

.pk-more {
  display: block;
  width: calc(100% - 12px);
  margin: 8px 6px 4px;
}
.picker .modal-actions { align-items: center; }
.pk-count { margin-right: auto; font-size: 13px; }

.picker-field { margin-top: 4px; }
.picker-field label { display: block; margin-bottom: 6px; font-weight: 600; }
.picker-field select, .picker-field input { margin: 0 0 8px; width: 100%; }
.ps-hint { font-size: 12px; margin: 0; }

/* Overlay progres untuk operasi banyak-request (simpan massal). */
.picker-progress {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 32, 27, 0.4);
  backdrop-filter: blur(2px);
}
.pp-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 24px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-lg);
  font-weight: 600;
}

/* ---------- Halaman detail kontak (/contacts/:id) ---------- */
#ct-detail .detail-head { margin-bottom: 18px; }
#ct-detail .detail-head h3 { margin: 0; }
#ct-detail .card { margin-bottom: 4px; }
.ctd-hint { font-size: 12px; margin: 2px 0 0; }
.ctd-meta { font-size: 12px; margin-top: 18px; }
#ct-detail .row.actions { margin-top: 18px; }
#ct-detail small.rcp-warn { display: block; margin-top: 6px; }

/* ---------- Favorit: bintang kontak & sematan label ---------- */
.star-btn {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  color: #c3c8c5;                     /* abu: belum difavoritkan */
  transition: color var(--dur), background var(--dur), transform var(--dur) var(--ease-spring);
}
.star-btn:hover { background: rgba(201, 162, 39, 0.14); color: var(--gold); }
.star-btn.on { color: var(--gold); }
.star-btn.on:hover { transform: scale(1.12); }
.star-btn:disabled { cursor: default; opacity: 0.6; }
.star-btn.lg { font-size: 22px; padding: 2px 6px; }
.ct-star { width: 34px; padding-right: 0; }
.star-inline { color: var(--gold); }

/* Tombol filter favorit di toolbar */
.star-toggle.on {
  border-color: var(--gold);
  background: rgba(201, 162, 39, 0.14);
  color: #6b5410;
}

/* Chip label yang disematkan */
.lbl-chip.pinned {
  border-color: var(--gold-soft);
  background: #fffdf5;
}
.lbl-chip .star-btn { padding: 2px 3px; font-size: 13px; }

/* Pintasan di pemilih kontak */
.pk-shortcuts {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.pk-shortcut-label { font-size: 12px; }
.pk-shortcut-hint { font-size: 12px; font-style: italic; }
.chip {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur), border-color var(--dur), color var(--dur), transform var(--dur) var(--ease-spring), box-shadow var(--dur);
}
.chip:hover { border-color: var(--primary-2); }
.chip.on {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ---------- Impor CSV ---------- */
.modal.picker-import { width: min(860px, 95vw); max-width: 95vw; }
.imp-sample {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 12.5px;
  overflow-x: auto;
  margin: 8px 0 12px;
}
.imp-rules { margin: 0 0 14px; padding-left: 20px; font-size: 13px; }
.imp-rules li { margin-bottom: 3px; }
.imp-rules code { background: var(--bg); padding: 1px 5px; border-radius: var(--radius-sm); }
.imp-error { color: var(--danger); font-weight: 600; }
.imp-loading { padding: 20px 0; }

.imp-counts { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.imp-stat {
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 12px;
}
.imp-stat.new { border-color: #b7dfc9; background: #f0fbf4; }
.imp-stat.existing { border-color: var(--gold-soft); background: #fffdf3; }
.imp-stat.invalid { border-color: #f0c4c0; background: #fdf3f2; }

.imp-newlabels { font-size: 12px; margin: 0 0 10px; }
.imp-lbl {
  display: inline-block;
  padding: 1px 8px;
  border-radius: var(--radius-sm);
  background: var(--gold-soft);
  color: #6b5410;
  font-size: 11px;
  font-weight: 600;
}

.imp-table-wrap {
  max-height: min(44vh, 360px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.imp-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.imp-table th, .imp-table td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.imp-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.imp-table tbody tr:last-child td { border-bottom: 0; }
.imp-line { color: var(--muted); }
.imp-reason { color: var(--muted); }
.imp-row.invalid, .imp-row.dupe { background: #fdf6f5; }
.imp-badge { padding: 2px 8px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 700; white-space: nowrap; }
.imp-badge.new { background: #dcfce7; color: #14532d; }
.imp-badge.existing { background: var(--gold-soft); color: #6b5410; }
.imp-badge.invalid { background: #fee2e2; color: #7f1d1d; }
.imp-badge.dupe { background: #ede9fe; color: #4c1d95; }
.imp-more { font-size: 12px; margin: 8px 0 0; }
.imp-summary { margin-right: auto; font-size: 13px; }
.imp-back { margin-top: 10px; }

/* Dropzone CSV di dialog impor — sejalan dengan dropzone gambar (.file-drop). */
.imp-drop { margin-bottom: 4px; }
.imp-drop .fd-ico { margin-bottom: 6px; }
.imp-choose { margin-top: 12px; pointer-events: none; } /* klik ditangani dropzone */

/* Dropdown custom di dalam dialog & toolbar kontak — menggantikan <select>
   bawaan browser, yang digambar OS sehingga menembus batas dialog. */
.picker-filters .cs { flex: 0 0 200px; }
.picker-filters .pk-label { display: none; }
.picker-field .cs { margin-bottom: 8px; }
.picker-field .ps-label { display: none; }
.ct-toolbar .cs { flex: 0 0 210px; }
.ct-toolbar .ct-label-filter { display: none; }
/* Panel dropdown harus di atas isi dialog, termasuk daftar yang bisa di-scroll. */
.picker .cs-panel, .ct-toolbar .cs-panel { z-index: 60; }
.modal-select-wrap .modal-select { display: none; }
.modal-select-wrap .cs-panel { z-index: 60; }
/* Kolom aksi tabel template: tombol harus sebaris, bukan membungkus ke bawah. */
.tpl-actions { white-space: nowrap; }
/* Kolom teks panjang di tabel (isi pesan, error): penanda bagi aturan layar
   sempit bahwa kolom ini boleh wrap — lihat blok @media (max-width: 860px). */
.col-wrap { min-width: 0; }
/* Kolom waktu di tabel: jangan pernah membungkus jadi dua baris. */
.col-time { white-space: nowrap; color: var(--muted); }

/* ---------- Layar masuk ---------- */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
/* Aplikasi di baliknya tidak boleh bisa di-scroll selagi terkunci. */
body.login-active { overflow: hidden; }

.login-card {
  position: relative;
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid rgba(229, 225, 214, 0.9);
  border-radius: var(--radius-lg);
  padding: 38px 36px 28px;
  box-shadow: var(--shadow-lg);
  outline: 1px solid var(--hairline-gold); /* pola bingkai QR, seperti kartu dialog */
  outline-offset: 4px;
  overflow: hidden;
  animation: modal-in 0.24s var(--ease-spring);
}
/* Garis aksen di tepi atas — sama seperti kartu dialog, supaya layar
   masuk terasa bagian dari aplikasi ini, bukan halaman terpisah. */
.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gold);
}

.login-brand {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.login-sub {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
  margin: 0 0 26px;
}
.login-card label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 7px;
}
.login-card input { width: 100%; margin: 0 0 18px; }

/* Bidang kata sandi + tombol intip */
.pw-field { position: relative; }
.pw-field input { padding-right: 46px; }
.pw-peek {
  position: absolute;
  top: 0;
  right: 0;
  height: 42px;
  width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 15px;
  color: var(--muted);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  transition: color var(--dur), background var(--dur);
}
.pw-peek:hover { color: var(--text); background: rgba(20, 32, 27, 0.05); }
/* Cincin fokusnya ikut aturan emas seragam di atas; offset negatif supaya tetap
   di dalam field, tidak menabrak tepi input. */
.pw-peek:focus-visible { outline-offset: -3px; }
.login-submit {
  width: 100%;
  padding: 13px 20px;
  font-size: 15px;
  margin-top: 6px;
}
.login-error, .dm-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #fdf3f2;
  border: 1px solid #f0c4c0;
  color: var(--danger);
  border-radius: var(--radius-md);
  padding: 10px 13px;
  font-size: 13px;
  line-height: 1.45;
  margin: 0 0 16px;
}
.login-error::before, .dm-error::before { content: '⚠️'; flex: 0 0 auto; }
.login-foot {
  font-size: 11px;
  text-align: center;
  margin: 18px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--gold-soft);
}

/* Identitas pengguna di kaki sidebar */
/* [hidden] HARUS menang. Atribut `hidden` bekerja lewat aturan UA
   `[hidden]{display:none}`, dan selector kelas di bawah ini punya kekhususan
   lebih tinggi — tanpa baris ini, `display: flex` membuat tombol Keluar tetap
   terlihat meski tidak ada sesi sama sekali. */
.sidebar-foot[hidden] { display: none !important; }
.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(233, 217, 166, 0.22); /* garis emas redup, bukan putih */
  display: flex;
  align-items: center;
  gap: 10px;
}
.who-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-weight: 600;
}
.who-out {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}
.who-out:hover { background: rgba(255, 255, 255, 0.18); }

/* ============================ Halaman Profil ============================ */

/* .who-name kini <button> supaya bisa diklik menuju profil. Semua gaya bawaan
   tombol dibuang — di kaki sidebar ia harus tetap terbaca sebagai teks nama. */
.who-name {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.who-name:hover { text-decoration: underline; }
/* Halaman Profil terbuka (layar lebar membukanya dari sini, bukan dari menu). */
.who-name.active { color: var(--gold-soft); text-decoration: underline; text-decoration-color: var(--gold); }
.who-name:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Kartu identitas: inisial + nama + tombol keluar sebaris. */
.pf-ident {
  display: flex;
  align-items: center;
  gap: 16px;
}
.pf-ident-text { flex: 1; min-width: 0; }
.pf-ident-text h3 { margin: 0 0 2px; }
.pf-ident-text p { margin: 0; }
.pf-avatar {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-round);
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  box-shadow: 0 0 0 2px var(--card), 0 0 0 3px var(--gold-soft); /* cincin emas, sama dengan avatar sesi */
}

/* Daftar pasangan label–nilai. Grid dua kolom supaya nilainya rata kiri
   satu sama lain; di layar sempit ia melipat jadi satu kolom. */
.pf-list { margin: 0; }
.pf-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 4px 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.pf-row:last-child { border-bottom: 0; padding-bottom: 0; }
.pf-row dt { color: var(--muted); font-size: 13px; }
.pf-row dd { margin: 0; word-break: break-word; }
.pf-row dd.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
}
@media (max-width: 640px) {
  .pf-row { grid-template-columns: 1fr; }
}

.pf-chip {
  display: inline-block;
  padding: 2px 10px;
  margin: 0 6px 6px 0;
  border-radius: var(--radius-sm);
  background: var(--gold-soft);
  color: #6b5310;
  font-size: 12.5px;
  font-weight: 600;
}
/* Dipakai di dua tempat: sebagai penjelas di bawah judul kartu (rapat ke atas),
   dan sebagai catatan setelah daftar (butuh jarak, kalau tidak ia menempel pada
   baris terakhir dan terbaca seolah bagian dari nilainya). */
.pf-note { margin: -4px 0 12px; font-size: 13px; }
.pf-list + .pf-note { margin: 14px 0 0; }

.pf-chip { min-width: 34px; text-align: center; }
.pf-ok { color: var(--ok); font-weight: 600; }
.pf-warn { color: var(--danger); font-weight: 600; }

/* Baris request id di dalam toast error. Sengaja bisa diseleksi (toast lain
   tidak) — gunanya memang untuk disalin lalu dicocokkan dengan log server. */
.toast-id {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  opacity: 0.85;
  user-select: text;
  cursor: text;
}

/* ===================== Dialog tambah kontak ===================== */

/* Kepala halaman: judul di kiri, aksi utama di kanan.
   TIDAK memakai nama .ct-actions — nama itu sudah dipakai <td> aksi di tabel
   kontak, dan aturan flex di sini sempat membuat sel tabel keluar dari tata
   letak table-cell: tingginya menyusut 18px dari barisnya, sehingga garis
   pemisah kolom terakhir tidak sejajar dengan kolom lain di SETIAP baris. */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}
.page-head > div { min-width: 0; }
.page-head h2 { margin-bottom: 6px; }
.page-head p { margin: 0; }
.page-head > .btn { flex: none; margin-top: 4px; }

@media (max-width: 720px) {
  .page-head { flex-direction: column; gap: 14px; }
  .page-head > .btn { align-self: flex-start; }
}

/* .modal dibatasi 440px — terlalu sempit untuk form dua kolom.
   `width` WAJIB, bukan cuma max-width: <dialog> berukuran fit-content, jadi
   max-width sendirian tidak pernah melebarkannya. */
.ct-form-dialog {
  width: min(680px, 94vw);
  max-width: min(680px, 94vw);
}
.ct-form-dialog .modal-card { padding: 26px 26px 22px; }
.ct-form-dialog h3 { margin: 0 0 18px; }
.ct-form-dialog .modal-actions { margin-top: 22px; }

/* Di layar sempit dua kolom jadi bertumpuk sendiri lewat .row/.col yang sudah
   ada; di sini cukup pastikan dialognya tidak melebihi tinggi layar. */
.ct-form-dialog .modal-card {
  max-height: 88vh;
  overflow-y: auto;
}

/* Chip pemilih label di dialog tambah kontak. Toggle, bukan pilih-satu:
   satu kontak boleh punya beberapa label. */
.ct-form-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 108px;
  overflow-y: auto;
  padding: 2px 0 2px;
}
.ct-lbl-pick {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background var(--dur), border-color var(--dur), color var(--dur);
}
.ct-lbl-pick:hover { border-color: var(--primary-2); }
.ct-lbl-pick.on {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.ct-lbl-pick:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Chip "+ Label baru" dibedakan dari chip label: garis putus-putus supaya
   terbaca sebagai aksi, bukan sebagai salah satu label yang bisa dipilih. */
.ct-lbl-pick.ct-lbl-new {
  border-style: dashed;
  color: var(--muted);
  font-weight: 600;
}
.ct-lbl-pick.ct-lbl-new:hover { color: var(--primary); border-color: var(--primary-2); }
.ct-lbl-kosong { align-self: center; font-size: 13px; }

/* Baris diagnostik chrome per sesi — data on-demand dari GET /api/sessions/:id/chrome */
.chrome-info {
  margin: 6px 0 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Pesan Masuk (fitur per sesi) ---------- */
.ib-toolbar { max-width: 420px; margin: 4px 0 20px; }
.ib-feature + .ib-feature { border-top: 1px solid var(--border); margin-top: 18px; padding-top: 18px; }
.ib-feature-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.ib-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
  background: #f6f4ee;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  white-space: nowrap;
}
.ib-settings .col { max-width: 240px; }
/* Saklar fitur yang tidak tersedia di server: pilihan yang dikunci terlihat redup. */
.seg.is-locked .seg-opt:has(input:disabled) { opacity: 0.45; cursor: not-allowed; }
/* Radio di dalam .seg-opt selalu tak terlihat. Tanpa ini aturan input:disabled
   (opacity 0.5) memunculkannya sebagai kotak di atas ikon/label pilihan yang dikunci. */
.seg-opt input[type="radio"]:disabled, .seg-opt input[type="checkbox"]:disabled { opacity: 0; }
.seg.is-locked .seg-opt:has(input:disabled):active { transform: none; }
.ib-warn, .doc-note {
  background: #fdf3d7;
  color: #92610e;
  border: 1px solid #f1dfa6;
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 13px;
  margin: 10px 0;
}
.ib-add { align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.ib-add-btn { padding-bottom: 1px; }
.ib-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ib-empty { margin: 10px 0 0; }
.ib-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ib-card-head h3 { margin: 0; }
/* Aksen emas yang sama dengan .card > h3 — h3 ini berada di dalam baris header. */
.ib-card-head > h3::after {
  content: '';
  display: block;
  width: 28px;
  height: 2px;
  margin-top: 6px;
  border-radius: var(--radius-sm);
  background: var(--gold);
}
/* Hasil pemrosesan di jejak aktivitas */
.badge-ib-ok       { background: #d9f3e3; color: #14663a; }
.badge-ib-no_label { background: #fdf3d7; color: #92610e; }
.badge-ib-rejected { background: #e9e7e1; color: #4b5563; }
.badge-ib-failed   { background: #fbe3e1; color: #a02c23; }
.badge-ib-help     { background: #dcebfb; color: #1d4fa1; }
@media (max-width: 640px) {
  .ib-settings .col { max-width: none; }
  /* Di layar sempit .row menjadi kolom: rata-bawah (flex-end) akan menggeser
     isian ke kanan, jadi kembalikan ke selebar kartu. */
  .ib-add { align-items: stretch; }
  .ib-add .col { flex-basis: auto; }
  .ib-add-btn .btn { width: 100%; }
}
.ib-hint { font-size: 12px; margin: 4px 2px 0; }
/* Pengaturan nyala/mati sebuah fitur: label di kiri, saklar di kanan. */
.ib-switches { display: grid; gap: 8px; margin: 12px 0; }
.ib-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border: 1px solid var(--border);
}
.ib-switch-label { font-size: 14px; font-weight: 600; }
.ib-switch .seg-opt { padding: 6px 16px; }
/* Peringatan yang bisa langsung ditindak dari tempatnya. */
.ib-warn-action { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ib-warn-action > span { flex: 1 1 260px; }

/* ---------- Izin fitur per nomor (whitelist di Pesan Masuk) ---------- */
.ib-add-form { margin-bottom: 14px; }
.ib-add-form .ib-add { margin-bottom: 0; }
.ib-add-form .ib-add-btn { margin-top: 14px; }
.ib-perm { display: flex; flex-direction: column; gap: 6px; }
/* Label global huruf besar; di sini isinya kalimat pilihan yang bisa diklik. */
.ib-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
}
.ib-opt input { width: auto; flex: none; }
.ib-perm-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-left: 24px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.ib-edit { display: flex; flex-direction: column; gap: 10px; padding: 6px 0; }
.ib-edit .row.actions { margin-top: 0; }
.ib-senders td.c-actions { white-space: nowrap; }
.ib-senders td.c-actions .btn + .btn { margin-left: 6px; }
@media (max-width: 860px) {
  /* Daftar fitur boleh membungkus — tanpa ini kolom Fitur melebar tanpa batas. */
  .table-wrap > table td.ib-perm-cell { white-space: normal; min-width: 160px; }
}
@media (max-width: 640px) {
  /* Tanpa .c-status, nomor menjadi kepala kartu selebar penuh. */
  .table-wrap.cards.ib-senders > table td.c-id { grid-column: 1 / -1; justify-content: flex-start; }
  .table-wrap.cards.ib-senders > table td.c-id::before { content: none; }
  .table-wrap.cards.ib-senders > table td.ib-perm-cell { text-align: right; min-width: 0; }
  .ib-senders td.c-actions .btn + .btn { margin-left: 0; }
  .table-wrap.cards.ib-senders > table tr.ib-edit-row td::before { content: none; }
  .ib-perm-list { margin-left: 0; }
}

/* ---------- Grup pengirim (rekap per grup, kartu di Pesan Masuk) ---------- */
.badge-ib-admin { background: #e9e3fb; color: #5b21b6; }
.ib-group-name .badge { margin-left: 8px; vertical-align: middle; }
.ib-group-form .col { max-width: 420px; }
.ib-grp-admin { margin-top: 12px; }
/* Label global punya margin atas 14px — di editor bertumpuk (gap 10px) itu dobel. */
.ib-edit label:not(.ib-opt) { margin-top: 0; }
.ib-groups .ib-edit input[type="text"] { max-width: 420px; }
/* Pilihan grup per nomor: lebih ringkas dari select form biasa, muat di sel tabel. */
.ib-group-select { width: auto; min-width: 150px; max-width: 100%; padding: 7px 10px; font-size: 13px; }
.ib-conflict { margin: 8px 0 0; font-size: 12px; white-space: normal; min-width: 240px; }
@media (max-width: 640px) {
  /* Nama grup jadi kepala kartu selebar penuh; badge boleh turun ke baris berikut. */
  .table-wrap.cards.ib-groups > table td.c-id {
    grid-column: 1 / -1;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px 10px;
  }
  .table-wrap.cards.ib-groups > table td.c-id::before,
  .table-wrap.cards.ib-groups > table tr.ib-edit-row td::before { content: none; }
  .ib-group-name .badge { margin-left: 0; }
  .ib-groups .ib-edit { flex: 1 1 auto; min-width: 0; }
  /* Label "GRUP" di kiri, pilihan di kanan; peringatan turun selebar kartu. */
  .table-wrap.cards.ib-senders > table td.ib-group-cell { flex-wrap: wrap; align-items: center; }
  .ib-group-select { min-width: 0; max-width: 70%; }
  .ib-conflict { flex: 1 1 100%; min-width: 0; }
}

/* ---------- Daftar perintah WhatsApp (kartu di Pesan Masuk) ---------- */
.ib-cmds td:first-child { width: 45%; }
.ib-cmd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  background: #f6f4ee;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 7px;
  white-space: nowrap;
  display: inline-block;
  margin: 2px 0;
}
/* Hanya 2 kolom pendek: di layar sempit cukup dibungkus, tanpa lebar dasar 720px
   & tanpa gulir samping seperti tabel umum. */
@media (max-width: 640px) {
  .table-wrap > table.ib-cmds { min-width: 0; }
  .table-wrap > table.ib-cmds td { white-space: normal; }
  .ib-cmds td:first-child { width: 50%; }
}

/* ---------- Pengumpulan data (kartu di Pesan Masuk) ---------- */
/* Teruskan ke Webhook: isian URL, hasil tes, status antrean (secret tampil di Modal.reveal). */
.ib-webhook { display: grid; gap: 12px; margin-top: 12px; min-width: 0; }
.ib-webhook > *, .ib-wh-form > * { min-width: 0; }
.ib-webhook .ib-warn, .ib-webhook .ib-hint, .ib-webhook .row.actions { margin: 0; }
.ib-wh-form label { margin-top: 0; }
.ib-wh-form .ib-warn, .ib-wh-form .ib-hint { margin-top: 8px; }
.ib-wh-url { display: flex; gap: 8px; align-items: stretch; }
.ib-wh-url input { flex: 1 1 auto; min-width: 0; }
.ib-wh-result.is-ok {
  margin: 0;
  padding: 9px 12px;
  font-size: 13px;
  background: #d9f3e3;
  color: #14663a;
  border: 1px solid rgba(20, 102, 58, 0.25);
}
.ib-wh-status-head { margin-top: 4px; }
.ib-wh-status { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 16px; margin: 0; }
.ib-wh-status dt { font-size: 12px; font-weight: 600; color: var(--muted); }
.ib-wh-status dd { margin: 2px 0 0; font-size: 14px; overflow-wrap: anywhere; }
.ib-wh-status .ib-key { white-space: normal; }
@media (max-width: 640px) {
  .ib-wh-url { flex-direction: column; }
  .ib-wh-url .btn, .ib-wh-actions .btn { width: 100%; }
}
.ib-check { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 14px; }
.ib-check input { width: auto; }

/* ---------- Tab Data (collector) ---------- */
.dt-toolbar, .dm-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.dt-toolbar .col, .dm-filters .col { min-width: 0; }
/* Tinggi bawaan date & search berbeda dari select: disamakan agar sebaris rapi. */
.dt-toolbar select, .dt-toolbar input[type="date"], .dt-toolbar input[type="search"] { height: 46px; box-sizing: border-box; }
.dt-toolbar .dt-q { grid-column: span 2; }
.dt-rules { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; }
/* Label global huruf besar; di sini isinya nama aturan yang bisa dicentang. */
.dt-rule { display: flex; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0; margin: 0; font-size: inherit; font-weight: 500; }
.dt-rule input { width: auto; }
.dt-preset + .dt-preset { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 14px; }
.dt-table td { white-space: nowrap; }
.dt-warn td:first-child::before { content: '⚠️ '; }
@media (max-width: 640px) {
  .dt-toolbar .dt-q { grid-column: auto; }
  .dt-table td { white-space: normal; }
}

/* ---------- Pesan Langsung ---------- */
.dm-filters { margin: 4px 0 14px; }
.dm-error { margin: 16px 0 0; }
.dm-error-hint { margin-top: 4px; color: var(--text); }
.dm-error-id {
  margin-top: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  user-select: text;
}
/* Isi sel Pesan: cuplikan, lampiran, lalu alasan gagal — bertumpuk. */
.dm-msg { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dm-snippet { overflow-wrap: anywhere; }
.dm-media { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.dm-fail { font-size: 13px; font-weight: 600; color: var(--danger); overflow-wrap: anywhere; }
/* Pesan yang baru dikirim: penanda emas yang sama dengan baris yang disorot. */
.dm-table tbody tr.dm-new { background: #faf8f3; }
.dm-table tbody tr.dm-new td:first-child { box-shadow: inset 3px 0 0 var(--gold); }
.dm-table td.c-id { font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Kolom Pesan mendapat porsi terbesar; tanpa ini cuplikan terhimpit jadi kolom
   sempit bertingkat-tingkat sementara kolom nomor berlebih ruang. */
.dm-table td.col-wrap { width: 40%; min-width: 160px; }
/* Sumber (web/api) menumpang di sel sesi — kolom sendiri membuat tabel melebihi
   kolom riwayat pada tata letak dua kolom. */
.dm-sess { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
@media (max-width: 640px) {
  .table-wrap.cards.dm-table > table td.col-wrap { width: auto; }
  .table-wrap.cards.dm-table > table tr.dm-new { border-color: var(--gold); }
  .table-wrap.cards.dm-table > table td.col-wrap::before { margin-bottom: 2px; }
}

/* ---------- Kotak Masuk ----------
   Layar ≥ 1024px: daftar | utas berdampingan, tinggi pas layar (--ibx-h diukur
   js/inbox.js), masing-masing menggulir di dalam panelnya. Di bawahnya satu
   panel: .ibx[data-view] memilih daftar ATAU utas; daftar ikut gulir halaman. */
.ibx { display: grid; gap: 20px; }
.ibx .card { margin-bottom: 0; }
.ibx-side { display: flex; flex-direction: column; min-width: 0; padding: 16px; }
.ibx-filters { display: grid; gap: 10px; }
.ibx-filters label { margin-top: 0; }
.seg.ibx-unread, .seg.ibx-type { display: flex; width: 100%; }
.ibx-unread .seg-opt, .ibx-type .seg-opt { flex: 1 1 0; justify-content: center; padding: 8px 10px; }
/* Grup WhatsApp: label kecil di depan nama grup, dan nama pengirim di atas isi pesan masuk. */
.ibx-group-tag {
  display: inline-block; margin-right: 6px; padding: 0 6px; border-radius: var(--radius-sm);
  background: var(--gold-soft); color: var(--text); font-size: 11px; font-weight: 700;
  line-height: 18px; vertical-align: 1px;
}
.ibx-sender { font-size: 12px; font-weight: 700; color: var(--primary-2); overflow-wrap: anywhere; }
.ibx-sender-num { font-weight: 400; color: var(--muted); }
.ibx-count { margin: 12px 0 6px; font-size: 13px; }
.ibx-count:empty { display: none; }
.ibx-list { min-width: 0; }
.ibx-items { list-style: none; margin: 0 -16px; padding: 0; border-top: 1px solid var(--border); }
.ibx-item {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 11px 16px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur);
}
.ibx-item:hover { background: #faf8f3; }
.ibx-item:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.ibx-item.is-active { background: #f1f7f4; box-shadow: inset 3px 0 0 var(--gold); }
.ibx-item-top, .ibx-item-bottom { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; min-width: 0; }
.ibx-item-bottom { align-items: center; }
.ibx-name, .ibx-item-meta, .ibx-preview { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ibx-name { font-weight: 700; }
.ibx-time { flex: none; font-size: 12px; color: var(--muted); }
.ibx-item-meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ibx-preview { font-size: 13px; color: var(--muted); }
.ibx-item.is-unread .ibx-name, .ibx-item.is-unread .ibx-preview { color: var(--text); font-weight: 700; }
.ibx-item.is-unread .ibx-time { color: var(--primary-2); font-weight: 700; }
.ibx-badge {
  flex: none;
  min-width: 22px;
  padding: 1px 6px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.ibx-more { margin: 12px 0 0; text-align: center; font-size: 13px; }
.ibx-retention { margin: 12px 0 0; font-size: 12px; }
.ibx-retention:empty { display: none; }
.ibx-list .state-box { margin-top: 12px; padding: 28px 16px; }

.ibx-thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 0; overflow: hidden; }
.ibx-placeholder { margin: auto; padding: 32px 24px; text-align: center; }
.ibx-placeholder .muted { max-width: 360px; margin: 0 auto; }
.ibx-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.ibx-back { display: none; flex: none; }
.ibx-head-txt { display: flex; flex-direction: column; min-width: 0; }
.ibx-head-name { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ibx-head-sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.ibx-msgs {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 18px;
  background: #faf8f3;
}
.ibx-msgs:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.ibx-msgs .skeleton-wrap { width: 100%; }
.ibx-older { align-self: center; margin-bottom: 4px; }
.ibx-start { align-self: center; margin: 0 0 4px; font-size: 12px; color: var(--muted); text-align: center; }
.ibx-day {
  align-self: center;
  margin: 8px 0 2px;
  padding: 2px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.ibx-msg { display: flex; flex-direction: column; max-width: min(80%, 560px); min-width: 0; }
.ibx-in { align-self: flex-start; align-items: flex-start; }
.ibx-out { align-self: flex-end; align-items: flex-end; }
.ibx-bubble { max-width: 100%; min-width: 0; padding: 7px 11px 5px; background: var(--card); border: 1px solid var(--border); }
.ibx-out .ibx-bubble { background: #e4f1ea; border-color: #bcdccc; }
.ibx-out.is-failed .ibx-bubble { background: #fdf3f2; border-color: #f0c4c0; }
.ibx-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.ibx-media { font-size: 13px; font-weight: 600; color: var(--muted); overflow-wrap: anywhere; }
.ibx-media + .ibx-text { margin-top: 3px; }
.ibx-meta { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin-top: 2px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
/* Centang ala WhatsApp: abu = terkirim/diterima, biru = dibaca. */
.ibx-tick { font-weight: 800; line-height: 1; }
.ibx-tick-delivered, .ibx-tick-read { letter-spacing: -0.3em; padding-right: 0.3em; }
.ibx-tick-read { color: #1d6fd1; }
.ibx-tick-wait { filter: grayscale(1); opacity: 0.7; font-size: 11px; }
.ibx-tick-failed { color: var(--danger); }
.ibx-fail { max-width: 100%; margin-top: 3px; font-size: 12px; font-weight: 600; color: var(--danger); overflow-wrap: anywhere; text-align: right; }
.ibx-reply { padding: 10px 18px 12px; border-top: 1px solid var(--border); background: var(--card); }
.ibx-reply .ib-warn { margin: 0 0 8px; }
.ibx-reply .dm-error { margin: 0 0 8px; }
.ibx-reply-row { display: flex; align-items: flex-end; gap: 10px; }
.ibx-reply textarea { flex: 1; min-width: 0; min-height: 46px; max-height: 160px; }
.ibx-reply-hint { margin: 6px 0 0; font-size: 12px; }
@media (hover: none) and (pointer: coarse) { .ibx-kbd { display: none; } }
/* Label hanya untuk pembaca layar — kotak balas sudah jelas dari placeholder & tombolnya. */
.ibx-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (min-width: 1024px) {
  .ibx { grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr); height: var(--ibx-h, 640px); }
  .ibx-side { min-height: 0; }
  .ibx-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin: 0 -16px; padding: 0 16px; }
}
@media (max-width: 1023px) {
  .ibx[data-view="list"] .ibx-thread,
  .ibx[data-view="thread"] .ibx-side { display: none; }
  .ibx-back { display: inline-block; }
  .ibx-thread { height: var(--ibx-h, 640px); }
  /* Utas menggantikan seluruh halaman: judul & pengantar disembunyikan supaya
     ruangnya untuk percakapan. */
  #tab-inbox:has(.ibx[data-view="thread"]) > h2,
  #tab-inbox:has(.ibx[data-view="thread"]) > #ibx-intro { display: none; }
}
@media (max-width: 640px) {
  .ibx-side { padding: 14px; }
  .ibx-items { margin: 0 -14px; }
  .ibx-item { padding: 12px 14px; }
  .ibx-head { padding: 10px 12px; gap: 10px; }
  /* Tombol kembali cukup panahnya — nama kontak butuh ruangnya (aria-label tetap lengkap). */
  .ibx-back-txt { display: none; }
  .ibx-back { padding-left: 14px; padding-right: 14px; font-size: 16px; }
  .ibx-msgs { padding: 12px; }
  .ibx-msg { max-width: 88%; }
  .ibx-reply { padding: 10px 12px; }
}
@media (min-width: 1500px) {
  main > #tab-inbox { max-width: 1320px; }
}

/* ---------- Dokumentasi API ---------- */
.doc-link, #doc-body a {
  color: var(--primary-2);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.doc-link:hover, #doc-body a:hover { color: var(--primary); }
.doc-link:focus-visible, #doc-body a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.doc-link { white-space: nowrap; }
#doc-body code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: inherit; }
/* Kode sebaris: boleh patah di mana saja supaya sel tabel & paragraf tidak melebar.
   Sedikit lebih kecil dari teks sekitarnya, tapi tidak di bawah 12px. */
#doc-body :not(pre) > code {
  font-size: max(12px, 0.9em);
  background: #f6f4ee;
  border: 1px solid var(--border);
  padding: 0 5px;
  overflow-wrap: anywhere;
}
.doc-sec { scroll-margin-top: 16px; }
.doc-sec:focus { outline: none; }
.doc-sec > h3 { margin-top: 0; }
.doc-callout {
  margin: 0 0 12px;
  padding: 10px 14px;
  background: #faf8f3;
  border-left: 4px solid var(--gold);
}
.doc-note.doc-ok { background: #d9f3e3; color: #14663a; border-color: rgba(20, 102, 58, 0.25); }
.doc-ep { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 0 0 12px; }
#doc-body .doc-ep > code { background: transparent; border: 0; padding: 0; font-size: 16px; font-weight: 700; }
.doc-method {
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
/* Versi daftar: lebar tetap supaya path di belakangnya sejajar ("DELETE" paling panjang). */
.doc-method.sm {
  flex: none;
  min-width: 58px;
  padding: 2px 0;
  font-size: 10.5px;
  line-height: 16px;
  text-align: center;
}
.doc-post { background: var(--primary); color: #fff; }
.doc-get { background: #dcebfb; color: #1d4fa1; }
.doc-delete { background: #fbe3e1; color: #a02c23; }
.doc-put, .doc-patch { background: var(--gold-soft); color: #6b5410; }
/* Kelompok bagian (Umum / Pesan Langsung / Broadcast) di kolom isi. */
.doc-group { margin: 34px 0 14px; }
.doc-group-title { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.doc-group-title::after { content: ''; display: block; width: 36px; height: 3px; margin-top: 6px; background: var(--gold); }
.doc-group .muted { margin: 8px 0 0; }
.doc-sub { margin: 26px 0 10px; padding-top: 18px; border-top: 1px solid var(--border); font-size: 15px; }
/* Blok kode: gulir samping DI DALAM bloknya, halaman tidak ikut melebar. */
.doc-code { margin: 12px 0; min-width: 0; border: 1px solid var(--border); background: #faf8f3; }
.doc-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 4px 4px 12px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.doc-code-lang { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.doc-code pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: pre;
  font-size: 13px;
  line-height: 1.55;
}
.doc-copy.is-done { border-color: var(--ok); color: var(--ok); }
/* Diagram alur dari flowmaid (SVG). Terlalu sempit → digulung di dalam kotaknya,
   bukan halaman. min-width menjaga teks diagram tetap terbaca di ponsel. */
.doc-flow { padding: 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.doc-flow svg { display: block; margin: 0 auto; max-width: 100%; height: auto; min-width: 360px; }
/* Palet bawaan flowmaid v0.39.0 diselaraskan ke token desain tegas lewat nilai
   atributnya — berkas vendor tidak diubah. Ganti engine → periksa ulang di sini. */
.doc-flow svg rect { rx: 0; ry: 0; }
.doc-flow svg rect[fill="#5b6dc0"] { fill: var(--primary); stroke: var(--primary); }
.doc-flow svg rect[fill="#33a35c"] { fill: var(--gold-soft); stroke: var(--gold); }
.doc-flow svg rect[fill="#eef1fb"] { fill: var(--gold-soft); }
.doc-flow svg rect[fill="#ffffff"] { fill: #faf8f3; }
.doc-flow svg rect[fill="#fff8c5"] { fill: var(--card); stroke: var(--gold); }
/* Peserta ketiga (mis. Pelanggan di diagram Kotak Masuk): kotak netral bergaris teks. */
.doc-flow svg rect[fill="#d99114"] { fill: var(--card); stroke: var(--text); }
.doc-flow svg [stroke="#aeb6d8"] { stroke: var(--muted); }
.doc-flow svg [stroke="#44507a"] { stroke: var(--text); }
.doc-flow svg [fill="#44507a"] { fill: var(--text); }
.doc-flow svg text[fill="#232840"], .doc-flow svg text[fill="#0a0e1a"] { fill: var(--text); }
.doc-flow-src { border-top: 1px solid var(--border); }
.doc-flow-src summary {
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.doc-flow-src summary:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.doc-flow-src pre { border-top: 1px solid var(--border); }
.doc-steps { margin: 0 0 4px; padding-left: 22px; }
.doc-steps li, .doc-list li { margin-bottom: 6px; }
.doc-list { padding-left: 20px; }
.doc-step-tag {
  padding: 1px 6px;
  background: var(--gold-soft);
  color: #6b5410;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.doc-table-wrap { margin: 12px 0; }
.doc-table td { vertical-align: top; }
/* Kolom pertama berisi token pendek (nama field, kode status) — jangan dipatah. */
#doc-body .doc-table td:first-child code { white-space: nowrap; overflow-wrap: normal; }
/* Daftar isi: kelompok dalam grid (bukan satu daftar dipotong dua kolom), tanpa
   nomor. Endpoint = lencana method berlebar tetap + path monospace, jadi path
   sejajar dan mudah dipindai; topik biasa = teks. Tanpa garis bawah — barisnya
   sendiri yang menyala saat disorot. */
.doc-toc { padding: 18px 20px 14px; }
.doc-toc-title { margin: 0 0 14px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
/* min(280px, 100%): di layar sempit kolomnya tidak melebihi wadah (tanpa scroll samping). */
.doc-toc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 18px 32px; }
.doc-toc-sec { min-width: 0; }
.doc-toc-group {
  margin: 0 0 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}
.doc-toc ul { margin: 0; padding: 0; list-style: none; }
#doc-body .doc-toc a.doc-toc-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  margin: 0 -8px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  transition: background var(--dur);
}
#doc-body .doc-toc a.doc-toc-link:hover { background: #f6f4ee; color: var(--primary); }
.doc-toc-txt { min-width: 0; }
#doc-body .doc-toc .doc-toc-path,
#doc-body .doc-ep-inline .doc-ep-path {
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow-wrap: anywhere;
}
/* Parameter path ({id}, {contact}) diredupkan supaya bagian tetapnya menonjol. */
.doc-param { color: var(--muted); font-weight: 400; }
/* Method + path sebaris di sel tabel; di layar lebar path tetap satu baris (kolomnya
   melebar), di layar sempit boleh patah di batas "/" (lihat blok max-width: 860px). */
.doc-ep-inline { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
/* min-width:auto — path tidak menyusut di bawah lebar aslinya, jadi kolom tabel yang melebar. */
#doc-body .doc-ep-inline .doc-ep-path { min-width: auto; white-space: nowrap; overflow-wrap: normal; }
@media (max-width: 860px) {
  /* Tabel dokumentasi membungkus teksnya; hanya tabel berkolom banyak yang
     diberi lebar dasar dan digulung di dalam wadahnya. */
  .table-wrap > table.doc-table { min-width: 0; }
  .table-wrap > table.doc-table.wide { min-width: 600px; }
  .table-wrap > table.doc-table td { white-space: normal; }
  .doc-sec { scroll-margin-top: 64px; } /* topbar lengket di layar sempit */
  #doc-body .doc-toc a.doc-toc-link { min-height: 40px; } /* target sentuh ≥ 40px */
  #doc-body .doc-ep-inline .doc-ep-path { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
  .doc-flow-src summary { padding: 11px 12px; }
}
/* Layar lebar: daftar isi menempel di samping isi. */
@media (min-width: 1500px) {
  main > #tab-docs { max-width: 1320px; }
  .doc-layout { display: grid; grid-template-columns: 272px minmax(0, 1fr); gap: 0 28px; align-items: start; }
  /* Kolom samping 272px: satu kolom, dan bisa digulir sendiri bila lebih tinggi dari layar. */
  .doc-toc { position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow-y: auto; }
  .doc-toc-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  #doc-body .doc-toc a.doc-toc-link { font-size: 13px; gap: 8px; }
}

/* ---------- Layar sentuh: ukuran huruf ----------
   Sengaja di AKHIR berkas: aturan ini menimpa ukuran yang ditetapkan tiap komponen di atas. */
@media (max-width: 860px) {
  /* iOS memperbesar halaman saat kotak isian berhuruf di bawah 16px difokus. */
  input[type="text"], input[type="number"], input[type="email"], input[type="password"],
  input[type="date"], input[type="search"], textarea, select, .cs-search, .modal-input,
  .speed-input-inline input { font-size: 16px; }
  /* Huruf terkecil: 12px. */
  .badge, th, .cs-mini-badge, .modal-label, .lbl-count, .imp-lbl, .imp-table thead th, .imp-badge,
  .login-card label, .login-foot, .table-wrap.cards > table td::before { font-size: 12px; }
}

/* Pesan Langsung: dua tombol pemilih tujuan berdampingan di baris label. */
.ib-wa-groups-card .actions { margin: 12px 0; }
.dm-to-actions { display: inline-flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
