/* ============================================================
   Support System — Stylesheet
   ------------------------------------------------------------
   Struktur file:
   1. Design tokens (CSS variables)
   2. Reset & dasar
   3. Komponen umum (tombol, badge, avatar, form)
   4. Top bar
   5. Layout 3 kolom
   6. Sidebar (folder)
   7. Daftar percakapan
   8. Panel detail (thread + composer)
   9. Panel pelanggan
   10. Laporan
   11. Modal & toast
   12. Responsif (tablet & HP)
   ============================================================ */

/* ---------- 1. Design tokens ---------- */
:root {
  /* Warna utama — ubah di sini untuk re-branding */
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;      /* latar item terpilih */
  --primary-soft-2: #e0e7ff;

  /* Netral (skala slate) */
  --bg: #f8fafc;                /* latar aplikasi */
  --surface: #ffffff;           /* kartu / panel */
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;            /* teks sekunder */
  --text-3: #94a3b8;            /* teks redup / placeholder */
  --hover: #f1f5f9;             /* latar hover item/tombol */
  --row-line: #f1f5f9;          /* garis pemisah baris daftar */
  --toast-bg: #0f172a;

  /* Warna status */
  --success: #059669;
  --success-soft: #d1fae5;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #e11d48;
  --danger-soft: #ffe4e6;
  --neutral: #64748b;
  --neutral-soft: #e2e8f0;

  /* Catatan internal (kuning lembut) */
  --note-bg: #fefce8;
  --note-border: #fde68a;
  --note-accent: #ca8a04;
  --note-text: #713f12;

  /* Kanal WhatsApp */
  --wa-bg: #f0fdf4;
  --wa-border: #86efac;
  --wa-soft: #dcfce7;
  --wa-text: #15803d;

  /* Efek */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .16);
  --radius: 10px;
  --radius-sm: 8px;
  --radius-pill: 999px;         /* kontrol form bergaya elips */

  /* Ketinggian kontrol seragam */
  --control-h: 36px;
  --control-h-sm: 30px;

  /* Tipografi: Figtree untuk judul, Barlow untuk teks lainnya */
  --font-body: "Barlow", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Figtree", var(--font-body);
}

/* ---------- Tema warna (aksen) ----------
   Dipilih lewat menu profil; disimpan di localStorage 'support-accent'
   dan dituangkan sebagai atribut data-accent pada <html>.
   Tiap preset hanya menimpa keluarga --primary; sisanya ikut token dasar.
   Nilai *-soft berbeda antara mode terang & gelap agar kontras tetap aman. */
:root[data-accent="violet"]  { --primary: #7c3aed; --primary-hover: #6d28d9; --primary-soft: #f3e8ff; --primary-soft-2: #e9d5ff; }
:root[data-accent="blue"]    { --primary: #2563eb; --primary-hover: #1d4ed8; --primary-soft: #dbeafe; --primary-soft-2: #bfdbfe; }
:root[data-accent="teal"]    { --primary: #0d9488; --primary-hover: #0f766e; --primary-soft: #ccfbf1; --primary-soft-2: #99f6e4; }
:root[data-accent="emerald"] { --primary: #059669; --primary-hover: #047857; --primary-soft: #d1fae5; --primary-soft-2: #a7f3d0; }
:root[data-accent="amber"]   { --primary: #d97706; --primary-hover: #b45309; --primary-soft: #fef3c7; --primary-soft-2: #fde68a; }
:root[data-accent="rose"]    { --primary: #e11d48; --primary-hover: #be123c; --primary-soft: #ffe4e6; --primary-soft-2: #fecdd3; }
:root[data-accent="slate"]   { --primary: #475569; --primary-hover: #334155; --primary-soft: #e2e8f0; --primary-soft-2: #cbd5e1; }

/* Versi tema gelap: warna aksen dicerahkan, latar lembut dibuat transparan */
:root[data-theme="dark"][data-accent="violet"]  { --primary: #a78bfa; --primary-hover: #8b5cf6; --primary-soft: rgba(139, 92, 246, .16); --primary-soft-2: rgba(139, 92, 246, .30); }
:root[data-theme="dark"][data-accent="blue"]    { --primary: #60a5fa; --primary-hover: #3b82f6; --primary-soft: rgba(59, 130, 246, .16); --primary-soft-2: rgba(59, 130, 246, .30); }
:root[data-theme="dark"][data-accent="teal"]    { --primary: #2dd4bf; --primary-hover: #14b8a6; --primary-soft: rgba(20, 184, 166, .16); --primary-soft-2: rgba(20, 184, 166, .30); }
:root[data-theme="dark"][data-accent="emerald"] { --primary: #34d399; --primary-hover: #10b981; --primary-soft: rgba(16, 185, 129, .16); --primary-soft-2: rgba(16, 185, 129, .30); }
:root[data-theme="dark"][data-accent="amber"]   { --primary: #fbbf24; --primary-hover: #f59e0b; --primary-soft: rgba(245, 158, 11, .16); --primary-soft-2: rgba(245, 158, 11, .30); }
:root[data-theme="dark"][data-accent="rose"]    { --primary: #fb7185; --primary-hover: #f43f5e; --primary-soft: rgba(244, 63, 94, .16); --primary-soft-2: rgba(244, 63, 94, .30); }
:root[data-theme="dark"][data-accent="slate"]   { --primary: #94a3b8; --primary-hover: #cbd5e1; --primary-soft: rgba(148, 163, 184, .16); --primary-soft-2: rgba(148, 163, 184, .30); }

/* Logo & gradien mengikuti warna aksen aktif */
.brand-logo { background: linear-gradient(135deg, var(--primary), var(--primary-hover)); }

/* ---------- Tema gelap ----------
   Diaktifkan lewat atribut data-theme="dark" pada <html>.
   Preferensi disimpan di localStorage ('support-theme':
   'light' | 'dark' | 'system') — lihat setupTheme() di app.js. */
:root[data-theme="dark"] {
  --primary: #818cf8;
  --primary-hover: #6366f1;
  --primary-soft: rgba(99, 102, 241, .16);
  --primary-soft-2: rgba(99, 102, 241, .30);

  --bg: #0b1120;
  --surface: #131c2e;
  --border: #253248;
  --border-strong: #3b4a63;
  --text: #e6edf6;
  --text-2: #a6b3c5;
  --text-3: #64748b;
  --hover: #1c2740;
  --row-line: #1b2538;
  --toast-bg: #334155;

  --success: #34d399;
  --success-soft: rgba(16, 185, 129, .16);
  --warning: #fbbf24;
  --warning-soft: rgba(245, 158, 11, .16);
  --danger: #fb7185;
  --danger-soft: rgba(225, 29, 72, .20);
  --neutral: #94a3b8;
  --neutral-soft: #263349;

  --note-bg: #262008;
  --note-border: #4a3d10;
  --note-accent: #eab308;
  --note-text: #e5cf7c;

  --wa-bg: rgba(37, 211, 102, .08);
  --wa-border: rgba(37, 211, 102, .35);
  --wa-soft: rgba(34, 197, 94, .16);
  --wa-text: #4ade80;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .45);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .6);
}

/* ---------- 2. Reset & dasar ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

/* Judul memakai font display (Figtree) */
h1, h2, h3,
.brand-name,
.list-header,
.stat-value,
.kpi-value,
.cust-name,
.notif-title {
  font-family: var(--font-display);
}

/* ---------- Ikon SVG (line = default, *-fill = state aktif) ---------- */
.icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: -3px;
}
.icon-sm { width: 14px; height: 14px; vertical-align: -2px; }
.icon-lg { width: 50px; height: 50px; }

/* ---------- 3. Komponen umum ---------- */

/* Tombol — SEMUA tombol memakai .btn + varian agar seragam.
   Varian: .btn-primary (aksi utama), .btn-secondary (default),
   .btn-ghost (tanpa border), .btn-danger. Ukuran: .btn-sm */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control-h);
  padding: 0 18px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); border-color: transparent; }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #be123c; }

.btn-sm { height: var(--control-h-sm); padding: 0 14px; font-size: 14.5px; }

/* Select & input seragam dengan tombol */
select, input[type="text"], input[type="email"], input[type="search"] {
  font-family: inherit;
  color: var(--text);
}
.control {
  height: var(--control-h-sm);
  padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14.5px;
  cursor: pointer;
}
.control:hover { border-color: var(--border-strong); }
.control:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* Badge status & tag */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: .2px;
}
.badge.tag { color: #fff; }
.badge.assignee { background: var(--neutral-soft); color: var(--text-2); }

/* Pil status berwarna lembut (latar soft + teks pekat) */
.badge.st-active  { background: var(--success-soft); color: var(--success); }
.badge.st-pending { background: var(--warning-soft); color: var(--warning); }
.badge.st-closed  { background: var(--neutral-soft); color: var(--neutral); }
.badge.st-spam    { background: var(--danger-soft); color: var(--danger); }

/* Avatar inisial */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: .3px;
}

/* ---------- 4. Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.2px; }
.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 800;
  box-shadow: var(--shadow-sm);
}

.search-wrap { flex: 1; max-width: 460px; }
.search-wrap input {
  width: 100%;
  height: var(--control-h);
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 15px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.search-wrap input::placeholder { color: var(--text-3); }
.search-wrap input:focus { border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px var(--primary-soft-2); }

.topbar-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.agent-switch { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-3); }
.agent-switch select {
  height: var(--control-h);
  padding: 0 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- 5. Layout ---------- */
.layout { display: flex; flex: 1; min-height: 0; }

/* ---------- 6. Sidebar ---------- */
.sidebar {
  width: 224px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 14px 0;
  flex-shrink: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.mailbox-select { padding: 0 14px 12px; }
.mailbox-select select {
  width: 100%;
  height: var(--control-h);
  padding: 0 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  font-size: 15.5px;
  font-weight: 600;
  background: var(--surface);
  cursor: pointer;
}

.folders { list-style: none; padding: 8px; border-top: 1px solid var(--border); }
.folders li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-2);
  font-size: 15.5px;
  font-weight: 500;
  transition: background .1s;
}
.folders li:hover { background: var(--hover); }
.folders li.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.folders .count {
  font-size: 13px;
  background: var(--neutral-soft);
  color: var(--text-2);
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 700;
  min-width: 26px;
  text-align: center;
}
.folders li.active .count { background: var(--primary); color: #fff; }

/* Tautan ke pusat bantuan publik, di bawah folder */
.kb-link {
  display: block;
  margin: auto 8px 4px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
}
.kb-link:hover { background: var(--hover); color: var(--text-2); }

/* ---------- 7. Daftar percakapan ---------- */
.conv-list-pane {
  width: 350px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-height: 0;
}

.list-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 17px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 57px;
}
.list-header .muted { font-weight: 500; font-size: 14px; color: var(--text-3); }

.conv-list { list-style: none; overflow-y: auto; flex: 1; }
.conv-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--row-line);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background .1s;
}
.conv-item:hover { background: var(--hover); }
.conv-item.selected { background: var(--primary-soft); border-left-color: var(--primary); }

.conv-item .row1 { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 3px; align-items: baseline; }
.conv-item .cust { font-weight: 600; font-size: 15.5px; color: var(--text-2); }
.conv-item.unread .cust { font-weight: 700; color: var(--text); }
.conv-item .time { font-size: 13.5px; color: var(--text-3); white-space: nowrap; }
.conv-item .subject {
  font-size: 15.5px;
  color: var(--text-2);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-item.unread .subject { font-weight: 700; color: var(--text); }
.conv-item .preview {
  font-size: 14.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 8px;
}
.conv-item .meta { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }

.dot-unread {
  width: 8px; height: 8px;
  background: var(--primary);
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.list-empty { padding: 48px 20px; text-align: center; color: var(--text-3); font-size: 15px; }

/* Bintang prioritas pada subjek */
.star { color: #f59e0b; }

/* Chip SLA: countdown tenggat balasan pertama */
.badge.sla-ok { background: var(--neutral-soft); color: var(--text-2); }
.badge.sla-soon { background: var(--warning-soft); color: var(--warning); }
.badge.sla-late { background: var(--danger-soft); color: var(--danger); }

/* Highlight @mention di catatan internal */
.mention {
  background: var(--primary-soft-2);
  color: var(--primary);
  font-weight: 700;
  border-radius: 5px;
  padding: 0 4px;
}

/* Baris aturan otomasi di Pengaturan */
.rule-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--row-line);
}
.rule-row.rule-off .rule-desc { opacity: .45; }
.rule-desc { flex: 1; font-size: 15px; }
.rule-desc span { color: var(--text-3); font-size: 14.5px; }
.rule-toggle input { accent-color: var(--primary); width: 16px; height: 16px; cursor: pointer; }

/* Mode laporan: daftar percakapan disembunyikan agar laporan lega */
body.report-mode .conv-list-pane { display: none; }

/* Item navigasi Laporan di bawah folder */
.folders .nav-report { margin-top: 8px; border-top: 1px solid var(--border); border-radius: 0; padding-top: 14px; }
.folders .nav-report.active { border-radius: var(--radius-sm); border-top-color: transparent; }

/* ---------- 8. Panel detail ---------- */
.detail-pane { flex: 1; display: flex; min-width: 0; min-height: 0; }

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  gap: 12px;
  font-size: 15.5px;
}
.empty-icon { font-size: 44px; opacity: .8; }

.thread-col { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.detail-header {
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.detail-title-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.btn-back { display: none; } /* hanya tampil di HP */
.detail-header h1 { font-size: 18px; font-weight: 700; letter-spacing: -.2px; flex: 1; min-width: 0; }

.detail-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.detail-controls select { max-width: 170px; }

.tag-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
}
.tag-chip button {
  background: none; border: none; color: rgba(255,255,255,.85);
  cursor: pointer; font-size: 14px; padding: 0; line-height: 1;
}
.tag-chip button:hover { color: #fff; }
.tag-add input {
  width: 104px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px dashed var(--border-strong);
  background: transparent;
  font-size: 13.5px;
  outline: none;
}
.tag-add input:focus { border-color: var(--primary); border-style: solid; }

/* Indikator presence (deteksi tabrakan): avatar agent lain yang sedang
   melihat percakapan yang sama, dengan cincin berdenyut */
.viewers { display: inline-flex; gap: 4px; }
.viewer .avatar {
  width: 26px; height: 26px; font-size: 12px;
  outline: 2px solid var(--warning);
  outline-offset: 1px;
  animation: viewer-pulse 1.6s ease-in-out infinite;
}
@keyframes viewer-pulse {
  0%, 100% { outline-color: var(--warning); }
  50% { outline-color: transparent; }
}

/* Thread pesan */
.thread { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }

.msg {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 760px;
  box-shadow: var(--shadow-sm);
}
.msg.agent { border-left: 3px solid var(--primary); }
.msg.customer { border-left: 3px solid var(--border-strong); }
.msg.note { background: var(--note-bg); border-color: var(--note-border); border-left: 3px solid var(--note-accent); box-shadow: none; }

.msg-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px 0; }
.msg-author { font-weight: 700; font-size: 15px; }
.msg-kind { font-size: 13px; color: var(--text-3); }
.msg-time { margin-left: auto; font-size: 13.5px; color: var(--text-3); white-space: nowrap; }
.msg-body { padding: 10px 16px 14px; font-size: 15.5px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; color: var(--text-2); }
.msg.note .msg-body { color: var(--note-text); }

/* Body email HTML (hasil sanitasi) di dalam thread */
.html-body { white-space: normal; overflow-x: auto; }
.html-body img { max-width: 100%; height: auto; border-radius: 6px; }
.html-body table { border-collapse: collapse; margin: 8px 0; font-size: 15px; }
.html-body td, .html-body th { border: 1px solid var(--border); padding: 6px 10px; }
.html-body a { color: var(--primary); }
.html-body h1, .html-body h2, .html-body h3 { margin: 10px 0 6px; color: var(--text); }
.html-body p { margin-bottom: 8px; }
.html-body blockquote {
  border-left: 3px solid var(--border-strong);
  padding-left: 12px;
  color: var(--text-3);
  margin: 8px 0;
}

/* Chip lampiran di bawah isi pesan */
.msg-attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 12px; }
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.attach-chip:hover { border-color: var(--primary); color: var(--primary); }
.attach-chip span { color: var(--text-3); font-weight: 500; font-size: 13px; }

/* Status pengiriman email di bawah balasan agent */
.msg-delivery {
  padding: 6px 16px 10px;
  font-size: 13.5px;
  font-weight: 600;
}
.msg-delivery.ok { color: var(--success); }
.msg-delivery.fail { color: var(--danger); }

/* Info sinkronisasi terakhir di form email masuk */
.sync-info {
  margin-right: auto;
  font-size: 13.5px;
  color: var(--text-3);
  align-self: center;
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Baris log aktivitas di tengah thread (ubah status, tunda, rating, dll.) */
.thread-event {
  text-align: center;
  font-size: 14px;
  color: var(--text-3);
  padding: 2px 12px;
}
.thread-event b { color: var(--text-2); font-weight: 600; }

/* Composer */
.composer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 20px 16px;
}
.composer-tabs { display: flex; gap: 2px; margin-bottom: 10px; }
.composer-tabs button {
  height: var(--control-h-sm);
  padding: 0 16px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  border-radius: var(--radius-pill);
}
.composer-tabs button:hover { background: var(--hover); color: var(--text-2); }
.composer-tabs button.active { color: var(--primary); background: var(--primary-soft); }
.composer-tabs button.active.note-tab { color: var(--note-accent); background: var(--note-bg); }

.composer textarea {
  width: 100%;
  min-height: 92px;
  padding: 12px 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 15.5px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.composer textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft-2); }
.composer.note-mode textarea { background: var(--note-bg); border-color: var(--note-border); }
.composer.note-mode textarea:focus { border-color: var(--note-accent); box-shadow: 0 0 0 3px var(--warning-soft); }

.composer-actions { display: flex; gap: 8px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.composer-hint { margin-left: auto; font-size: 13.5px; color: var(--text-3); }

/* ---------- 9. Panel pelanggan ---------- */
.customer-col {
  width: 272px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 20px 16px;
  overflow-y: auto;
  flex-shrink: 0;
}
.customer-col h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-3);
  margin: 20px 0 8px;
  font-weight: 700;
}
.cust-card { display: flex; align-items: center; gap: 12px; }
.cust-card .avatar { width: 42px; height: 42px; font-size: 17px; }
.cust-name { font-weight: 700; font-size: 16.5px; }
.cust-email { font-size: 14px; color: var(--text-3); word-break: break-all; }
.cust-company { font-size: 14.5px; margin-top: 2px; color: var(--text-2); }

.cust-notes {
  width: 100%;
  min-height: 72px;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
}
.cust-notes:focus { border-color: var(--primary); }

.prev-conv { list-style: none; }
.prev-conv li {
  padding: 9px 0;
  border-bottom: 1px solid var(--row-line);
  cursor: pointer;
  font-size: 14.5px;
  color: var(--text-2);
}
.prev-conv li:hover { color: var(--primary); }
.prev-conv .pc-time { font-size: 13px; color: var(--text-3); margin-top: 2px; }
.prev-conv .prev-empty { cursor: default; color: var(--text-3); }
.prev-conv .prev-empty:hover { color: var(--text-3); }

/* ---------- 10. Laporan ---------- */
.report-view { flex: 1; overflow-y: auto; padding: 24px; }
.report-view h1 { font-size: 23px; margin-bottom: 4px; letter-spacing: -.3px; }
.report-sub { color: var(--text-3); font-size: 15px; margin-bottom: 20px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-label { font-size: 14px; color: var(--text-3); font-weight: 600; margin-bottom: 6px; }
.stat-card .stat-value { font-size: 30px; font-weight: 800; letter-spacing: -.5px; }
.stat-card .stat-value small { font-size: 15px; font-weight: 600; color: var(--text-3); }

.report-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.report-section h2 { font-size: 16px; margin-bottom: 14px; }

/* Utilitas */
.hidden { display: none !important; }
.section-gap { margin-top: 18px; }
.section-gap-sm { margin-top: 10px; }
.span-full { grid-column: 1 / -1; }

/* Textarea seragam untuk form pengaturan (padanan input elips) */
.form-textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.55;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  outline: none;
}
.form-textarea:focus { border-color: var(--primary); }

/* ---------- Drill-down laporan ---------- */
.drillable { cursor: pointer; transition: background .1s, border-color .1s; }
.stat-card.drillable:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.bar-row.drillable { border-radius: var(--radius-sm); padding: 3px 6px; margin: 0 -6px 7px; }
.bar-row.drillable:hover { background: var(--hover); }
.trend-day.drillable:hover { background: var(--hover); border-radius: var(--radius-sm); }
tr.drillable:hover td { background: var(--hover); }

/* Chip filter drill-down di header daftar percakapan */
.filter-chip {
  border: none;
  background: var(--primary-soft);
  color: var(--primary);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  cursor: pointer;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.filter-chip:hover { background: var(--primary-soft-2); }
.list-header { flex-wrap: wrap; gap: 6px; }

/* ---------- Form pengaturan koneksi email ---------- */
.mail-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  align-items: end;
}
.mail-form label { font-size: 14px; font-weight: 600; color: var(--text-2); }
.mail-form input[type="text"], .mail-form input[type="number"],
.mail-form input[type="email"], .mail-form input[type="password"] {
  display: block;
  width: 100%;
  margin-top: 4px;
  height: var(--control-h-sm);
  padding: 0 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  outline: none;
}
.mail-form input:focus { border-color: var(--primary); }
.mail-form .mail-select { width: 100%; margin-top: 4px; display: block; }
.mail-form .mail-check { align-self: center; padding-top: 14px; }
.mail-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px dashed var(--border);
  margin-top: 4px;
}
.report-view code {
  background: var(--hover);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 13.5px;
}
@media (max-width: 640px) { .mail-form { grid-template-columns: 1fr; } }

/* ---------- Panel KPI ---------- */
.kpi-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.kpi-header h2 { margin-bottom: 0; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }

.kpi-card {
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--bg);
}
.kpi-card.kpi-met { border-left-color: var(--success); }
.kpi-card.kpi-miss { border-left-color: var(--danger); }

.kpi-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.kpi-label { font-size: 14px; font-weight: 700; color: var(--text-2); }
.kpi-status { font-size: 12.5px; font-weight: 700; color: var(--text-3); white-space: nowrap; }
.kpi-met .kpi-status { color: var(--success); }
.kpi-miss .kpi-status { color: var(--danger); }

.kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -.4px; }
.kpi-value small { font-size: 14px; font-weight: 600; color: var(--text-3); }
.kpi-target { font-size: 13.5px; color: var(--text-3); margin: 2px 0 10px; }

.kpi-bar { height: 6px; background: var(--hover); border-radius: 999px; overflow: hidden; }
.kpi-fill { height: 100%; border-radius: 999px; background: var(--border-strong); }
.kpi-met .kpi-fill { background: var(--success); }
.kpi-miss .kpi-fill { background: var(--danger); }

/* Form ubah target KPI */
.kpi-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}
.kpi-form label { font-size: 14px; font-weight: 600; color: var(--text-2); }
.kpi-form input {
  display: block;
  width: 100%;
  margin-top: 4px;
  height: var(--control-h-sm);
  padding: 0 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  outline: none;
}
.kpi-form input:focus { border-color: var(--primary); }
.kpi-form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 640px) { .kpi-form { grid-template-columns: 1fr; } }

/* Dua kolom laporan berdampingan (agent + kanal/tag) */
.report-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .report-grid-2 { grid-template-columns: 1fr; } }

/* Grafik kolom tren harian (murni CSS, tanpa library) */
.trend { display: flex; align-items: flex-end; gap: 6px; height: 130px; }
.trend-day { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; min-width: 0; }
.trend-cols { flex: 1; display: flex; align-items: flex-end; gap: 3px; width: 100%; justify-content: center; }
.trend-col { width: 38%; max-width: 16px; border-radius: 4px 4px 0 0; min-height: 2px; }
.trend-col.created { background: var(--primary); }
.trend-col.closed { background: var(--success); }
.trend-label { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.trend-legend { display: flex; gap: 16px; margin-top: 10px; font-size: 14px; color: var(--text-2); }
.trend-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.trend-legend .dot.created { background: var(--primary); }
.trend-legend .dot.closed { background: var(--success); }

/* Tabel performa agent */
.agent-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.agent-table th {
  text-align: left;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-3);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.agent-table td { padding: 9px 8px; border-bottom: 1px solid var(--row-line); }
.agent-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.agent-table td:first-child { display: flex; align-items: center; gap: 8px; }
.avatar-xs { width: 24px; height: 24px; font-size: 11.5px; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 14.5px; }
.bar-row .bar-label { width: 130px; color: var(--text-2); flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .bar-track { flex: 1; height: 10px; background: var(--hover); border-radius: 999px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; border-radius: 999px; background: var(--primary); }
.bar-row .bar-val { width: 32px; text-align: right; font-weight: 700; color: var(--text-2); }

/* ---------- 11. Modal & toast ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--surface);
  border-radius: 14px;
  padding: 24px;
  width: 460px;
  max-width: 100%;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal h2 { font-size: 20px; margin-bottom: 18px; letter-spacing: -.2px; }
.modal label { display: block; font-size: 14.5px; font-weight: 600; margin-bottom: 14px; color: var(--text-2); }
.modal label .muted { font-weight: 400; color: var(--text-3); }
.modal input[type="text"], .modal input[type="email"], .modal select, .modal textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
/* Textarea tidak bisa elips penuh — pakai sudut membulat besar */
.modal textarea { border-radius: 16px; }
.modal input:focus, .modal select:focus, .modal textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft-2);
}
.checkbox-row { display: flex; align-items: center; gap: 8px; font-weight: 400 !important; }
.checkbox-row input { width: auto !important; margin: 0 !important; display: inline !important; accent-color: var(--primary); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--toast-bg);
  color: #fff;
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 500;
  z-index: 100;
  box-shadow: var(--shadow-lg);
  animation: toast-in .2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- Menu profil di topbar ---------- */
.profile-wrap { position: relative; }
.profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: var(--control-h);
  padding: 0 14px 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.profile-btn:hover { background: var(--hover); border-color: var(--border-strong); }
.profile-name { font-size: 15px; font-weight: 600; }
.profile-btn .icon-sm { color: var(--text-3); }

.profile-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 120;
  width: 268px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.profile-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.profile-head > div { flex: 1; min-width: 0; }
.profile-head-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.profile-head-mail {
  font-size: 13px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profile-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-2);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.profile-item:hover { background: var(--hover); color: var(--text); }
.profile-item.danger { color: var(--danger); }
.profile-item.danger:hover { background: var(--danger-soft); }
.profile-sep { height: 1px; background: var(--border); margin: 6px 4px; }

/* Pemilih tema warna di menu profil */
.accent-row { padding: 8px 10px 10px; }
.accent-label {
  font-size: 12.5px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px;
}
.accent-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.accent-dot {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  outline: 1px solid var(--border);
  outline-offset: 1px;
  cursor: pointer;
  padding: 0;
  transition: transform .12s;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff;
}
.accent-dot:hover { transform: scale(1.12); }
.accent-dot.active { outline-color: var(--primary); outline-width: 2px; }
.accent-dot .icon-sm { width: 12px; height: 12px; }

/* ---------- Aksi massal ---------- */
.conv-item { position: relative; }
.bulk-check {
  position: absolute;
  top: 16px; left: 4px;
  width: 15px; height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s;
}
.conv-item:hover .bulk-check,
.conv-item.bulk-on .bulk-check { opacity: 1; }
.conv-item.bulk-on { background: var(--primary-soft); }

.bulk-bar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.bulk-count { font-size: 13.5px; font-weight: 700; color: var(--primary); margin-right: auto; }

/* Tombol muat bertahap di akhir daftar */
.load-more { padding: 14px; text-align: center; }

/* ---------- Lampiran keluar di composer ---------- */
.attach-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.attach-row:empty { display: none; }
.attach-row .attach-chip button {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); display: inline-flex; padding: 0;
}
.attach-row .attach-chip button:hover { color: var(--danger); }

/* Balasan terjadwal di thread */
.msg.scheduled {
  border-left: 3px solid var(--warning);
  border-style: dashed;
  background: var(--warning-soft);
}
.msg.scheduled .msg-body { color: var(--text-2); }

/* ---------- Editor artikel KB ---------- */
.kb-cat {
  font-size: 13px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-3); margin: 16px 0 6px;
}
.kb-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--row-line);
}
.kb-row-title {
  flex: 1; text-align: left; background: none; border: none;
  font-family: inherit; font-size: 15px; font-weight: 600;
  color: var(--text); cursor: pointer; padding: 0;
}
.kb-row-title:hover { color: var(--primary); }
.kb-row.kb-draft .kb-row-title { color: var(--text-3); }
.kb-views { font-size: 13px; color: var(--text-3); white-space: nowrap; }

/* ---------- Command palette ---------- */
.palette-backdrop {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(15, 23, 42, .5);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
}
.palette {
  width: 620px; max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.palette input {
  width: 100%; border: none; outline: none;
  padding: 18px 22px;
  font-family: inherit; font-size: 17px;
  background: var(--surface); color: var(--text);
  border-bottom: 1px solid var(--border);
}
.palette ul { list-style: none; max-height: 380px; overflow-y: auto; }
.palette li {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 22px;
  font-size: 15px; color: var(--text-2); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.palette li.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.palette li.palette-empty { color: var(--text-3); cursor: default; }

kbd {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--bg);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
}

/* ---------- Kanal WhatsApp ---------- */
/* Badge kanal WA di daftar percakapan */
.badge.ch-wa { background: var(--wa-soft); color: var(--wa-text); }

/* Panel pengganti composer untuk percakapan WA:
   balasan dilakukan langsung di WhatsApp via tautan wa.me */
.wa-panel {
  border: 1px dashed var(--wa-border);
  background: var(--wa-bg);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
}
.wa-panel p { font-size: 15px; color: var(--text-2); line-height: 1.6; }
.wa-no-phone { color: var(--danger) !important; font-weight: 600; }

.btn-wa { background: #25d366; border-color: #25d366; color: #fff; text-decoration: none; }
.btn-wa:hover { background: #1eb958; border-color: #1eb958; color: #fff; }

/* ---------- Kartu notifikasi pesan masuk ---------- */
#notif-stack {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 200; /* di atas topbar & modal agar selalu terlihat */
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 320px;
  max-width: calc(100vw - 24px);
}
.notif {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px 14px;
  cursor: pointer;
  animation: notif-in .25s ease;
}
.notif:hover { border-color: var(--primary); }
.notif-icon { font-size: 24px; }
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-size: 13px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .5px; }
.notif-from { font-size: 15.5px; font-weight: 700; margin-top: 2px; }
.notif-subject { font-size: 14.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-close {
  background: none; border: none; color: var(--text-3);
  cursor: pointer; font-size: 15px; padding: 2px;
}
.notif-close:hover { color: var(--text); }
@keyframes notif-in { from { opacity: 0; transform: translateX(20px); } }

/* ---------- 12. Responsif ---------- */

/* Layar lebar: kolom ikut melebar + padding lebih lega agar tidak terasa
   sempit; isi thread & composer dipusatkan (ala Help Scout) supaya tidak
   menempel di kiri dengan ruang kosong besar di kanan. */
@media (min-width: 1440px) {
  .sidebar { width: 252px; }
  .conv-list-pane { width: 412px; }
  .customer-col { width: 304px; padding: 24px 20px; }

  .list-header { padding: 18px 20px; }
  .conv-item { padding: 16px 20px; }
  .folders li { padding: 10px 14px; }
  .folders { padding: 10px; }
  .mailbox-select { padding: 0 16px 14px; }

  .detail-header { padding: 16px 32px; }
  .thread { padding: 28px 32px; gap: 16px; }
  .composer { padding: 12px 32px 20px; }
  .composer textarea { min-height: 104px; }

  /* Kolom baca terpusat dengan lebar nyaman */
  .msg, .thread-event { width: 100%; max-width: 840px; margin-left: auto; margin-right: auto; }
  .composer-tabs, .composer textarea, .composer-actions, .wa-panel {
    width: 100%; max-width: 840px; margin-left: auto; margin-right: auto;
  }
  .composer-tabs { margin-bottom: 8px; }
  .detail-title-row, .detail-controls { max-width: 1040px; }
}

@media (min-width: 1800px) {
  .conv-list-pane { width: 456px; }
  .customer-col { width: 328px; }
  .msg, .thread-event,
  .composer-tabs, .composer textarea, .composer-actions, .wa-panel { max-width: 900px; }
  .report-view { max-width: 1280px; margin: 0 auto; width: 100%; }
}

/* Tablet lebar: panel pelanggan menyempit */
@media (max-width: 1250px) {
  .customer-col { width: 232px; }
  .conv-list-pane { width: 320px; }
}
/* Tablet: panel pelanggan disembunyikan */
@media (max-width: 1050px) {
  .customer-col { display: none; }
  .sidebar { width: 196px; }
}
@media (max-width: 860px) {
  .conv-list-pane { width: 272px; }
  .sidebar { width: 176px; }
  .agent-switch label { display: none; }
}

/* HP: layout satu kolom, pola master-detail.
   - Default: daftar percakapan tampil penuh, panel detail disembunyikan.
   - body.show-detail (di-set saat percakapan dibuka): detail tampil penuh,
     tombol ← Kembali muncul untuk balik ke daftar.
   - Sidebar berubah menjadi bar folder horizontal yang bisa digulir. */
@media (max-width: 700px) {
  .topbar { padding: 0 12px; gap: 8px; height: 56px; }
  .brand-name { display: none; }
  .search-wrap { max-width: none; min-width: 0; }
  .search-wrap input { padding: 0 12px; }
  .btn-new-label { display: none; }        /* tombol baru cukup ikon + */
  #btn-new { width: var(--control-h); padding: 0; flex-shrink: 0; font-size: 20px; }
  .agent-switch select { max-width: 104px; padding: 0 10px; }
  .topbar-right { gap: 8px; flex-shrink: 0; }

  .layout { flex-direction: column; }

  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .mailbox-select { padding: 0; flex-shrink: 0; }
  .mailbox-select select { width: auto; }
  .folders { display: flex; gap: 4px; padding: 0; border-top: none; }
  .folders li { white-space: nowrap; padding: 8px 12px; flex-shrink: 0; }
  .folders .nav-report { margin-top: 0; border-top: none; padding-top: 8px; border-radius: var(--radius-sm); }

  .conv-list-pane { width: 100%; flex: 1; border-right: none; }
  .detail-pane { display: none; }
  body.show-detail .conv-list-pane { display: none; }
  body.show-detail .detail-pane { display: flex; }
  body.report-mode .detail-pane { display: flex; }

  .btn-back { display: inline-flex; flex-shrink: 0; }
  .msg { max-width: none; }
  .detail-header { padding: 12px 14px; }
  .detail-controls select { max-width: 136px; }
  .thread { padding: 14px; }
  .composer { padding: 10px 14px 14px; }
  .report-view { padding: 16px; }

  /* Target sentuh lebih nyaman */
  .conv-item { padding: 14px; }
  .btn { min-height: 40px; }
  .btn-sm, .btn-back { min-height: 34px; }
}
