/* ============================================================
   Chat Channel — tampilan halaman user & dashboard CS.
   Ganti warna utama cukup di --brand (semua turunan warna ikut).
   ============================================================ */

/* Font Plus Jakarta Sans (SIL Open Font License, lihat fonts/OFL.txt) */
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/plus-jakarta-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/plus-jakarta-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-strong: color-mix(in oklab, var(--brand), black 24%);
  --brand-soft: color-mix(in oklab, var(--brand) 10%, var(--surface));
  --brand-text: var(--brand);
  --ring: color-mix(in oklab, var(--brand) 22%, transparent);

  /* Warna dasar netral. Gaya tampilan admin (Lembut/Penuh) mencampurkan sedikit warna tema
     ke permukaan lewat --tint-*; gaya Polos dan halaman pelanggan memakai 0%. */
  --n-page: #f2f4f7;
  --n-surface: #ffffff;
  --n-surface-2: #f6f7f9;
  --n-surface-3: #eef0f3;
  --n-raised: #ffffff;
  --n-border: #e4e7ec;
  --n-border-strong: #d0d5dd;
  --n-bubble: #ffffff;
  --n-bubble-border: #e7eaee;
  --tint-page: 0%;
  --tint-surface: 0%;
  --tint-surface-2: 0%;
  --tint-surface-3: 0%;
  --tint-border: 0%;
  --tint-bubble: 0%;

  --page: color-mix(in oklab, var(--brand) var(--tint-page), var(--n-page));
  --surface: color-mix(in oklab, var(--brand) var(--tint-surface), var(--n-surface));
  --surface-2: color-mix(in oklab, var(--brand) var(--tint-surface-2), var(--n-surface-2));
  --surface-3: color-mix(in oklab, var(--brand) var(--tint-surface-3), var(--n-surface-3));
  --surface-raised: color-mix(in oklab, var(--brand) var(--tint-surface), var(--n-raised));
  --border: color-mix(in oklab, var(--brand) var(--tint-border), var(--n-border));
  --border-strong: color-mix(in oklab, var(--brand) var(--tint-border), var(--n-border-strong));
  --bubble-them: color-mix(in oklab, var(--brand) var(--tint-bubble), var(--n-bubble));
  --bubble-them-border: color-mix(in oklab, var(--brand) var(--tint-border), var(--n-bubble-border));
  --text: #101828;
  --text-2: #475467;
  --text-3: #8a94a6;

  --online: #12b76a;
  --online-text: #067647;
  --warning: #f79009;
  --danger: #d92d20;
  --danger-text: #c01f13;
  --read-on-brand: #53bdeb; /* centang biru "dibaca" seperti WhatsApp; tema kebiruan diganti di theme.js */
  --wa: #25d366;
  --wa-icon: #1ea952; /* hijau WhatsApp yang sedikit lebih gelap supaya jelas di latar terang */

  /* Status percakapan & grafik — kombinasi lolos uji buta warna (CVD) di mode terang & gelap */
  --st-open: #d97706; /* belum selesai */
  --st-pending: #2a78d6; /* menunggu */
  --st-resolved: #16a34a; /* selesai */
  --st-hard: #dc2626; /* hard complain */
  --chart-replied: #0d9488;
  --chart-unreplied: #d97706;

  --shadow-xs: 0 1px 2px rgb(16 24 40 / 0.05);
  --shadow-sm: 0 1px 3px rgb(16 24 40 / 0.08), 0 1px 2px rgb(16 24 40 / 0.04);
  --shadow-lg: 0 24px 48px -12px rgb(16 24 40 / 0.18);
  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

/* Tema admin diatur js/theme.js lewat atribut di <html>:
   data-theme = light | dark (Terang / Gelap / Ikuti sistem), data-style = plain | soft | bold.
   Halaman chat pelanggan tidak memakai theme.js, jadi selalu terang dengan warna bawaan. */
:root[data-theme="dark"] {
  --brand-soft: color-mix(in oklab, var(--brand) 24%, var(--surface));
  --brand-text: color-mix(in oklab, var(--brand), white 48%);
  --n-page: #0b0f14;
  --n-surface: #121820;
  --n-surface-2: #0e1319;
  --n-surface-3: #1a212a;
  --n-raised: #252f3b;
  --n-border: #212a34;
  --n-border-strong: #2f3a47;
  --n-bubble: #19212a;
  --n-bubble-border: #232d38;
  --text: #e9edf2;
  --text-2: #a8b3c0;
  --text-3: #6f7c8b;
  --st-pending: #3987e5;
  --st-hard: #ef4444;
  --online-text: #47cd89;
  --danger-text: #f97066;
  --wa-icon: #25d366;
  --shadow-xs: none;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.45);
  --shadow-lg: 0 24px 48px -12px rgb(0 0 0 / 0.65);
  color-scheme: dark;
}

/* Gaya "Lembut": latar, panel, dan garis ikut bernuansa warna tema. */
:root[data-style="soft"] {
  --tint-page: 9%;
  --tint-surface: 4%;
  --tint-surface-2: 8%;
  --tint-surface-3: 11%;
  --tint-border: 14%;
}
:root[data-style="soft"][data-theme="dark"] {
  --tint-page: 9%;
  --tint-surface: 9%;
  --tint-surface-2: 7%;
  --tint-surface-3: 12%;
  --tint-border: 15%;
  --tint-bubble: 9%;
}
/* Gaya "Penuh": nuansa lebih kuat + menu samping berwarna pekat. */
:root[data-style="bold"] {
  --tint-page: 15%;
  --tint-surface: 7%;
  --tint-surface-2: 13%;
  --tint-surface-3: 17%;
  --tint-border: 20%;
  --rail-bg: color-mix(in oklab, var(--brand), black 25%);
}
:root[data-style="bold"][data-theme="dark"] {
  --tint-page: 13%;
  --tint-surface: 13%;
  --tint-surface-2: 10%;
  --tint-surface-3: 17%;
  --tint-border: 20%;
  --tint-bubble: 14%;
  --rail-bg: color-mix(in oklab, var(--brand), black 52%);
}

/* ---------- Dasar ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible { outline: none; }
::selection { background: color-mix(in oklab, var(--brand) 28%, transparent); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.messages, .conv-list, .details-body, .start { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes typing {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes slide-in { from { opacity: 0; transform: translateX(24px); } }

/* ---------- Komponen umum ---------- */
.brand-mark {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--brand);
  color: #ffffff;
}
.brand-mark.sm { width: 32px; height: 32px; border-radius: 10px; }
.brand-mark .brand-dots { fill: var(--brand); }

.avatar {
  --h: 168;
  position: relative;
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: hsl(var(--h) 72% 92%);
  color: hsl(var(--h) 62% 27%);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  user-select: none;
}
.avatar.xs { width: 28px; height: 28px; font-size: 10.5px; }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.xl { width: 72px; height: 72px; font-size: 24px; }
.avatar.online::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 28%;
  height: 28%;
  min-width: 9px;
  min-height: 9px;
  border-radius: 50%;
  background: var(--online);
  box-shadow: 0 0 0 2px var(--surface);
}
:root[data-theme="dark"] .avatar { background: hsl(var(--h) 30% 21%); color: hsl(var(--h) 72% 80%); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; opacity: 0.5; }
.btn.sm { gap: 6px; height: 34px; padding: 0 12px; border-radius: 9px; font-size: 13px; }
.btn-lg { height: 48px; border-radius: 12px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--brand); color: var(--brand-ink); box-shadow: var(--shadow-xs); }
.btn-primary:hover:not(:disabled) { background: var(--brand-strong); }
.btn-soft { border-color: var(--border-strong); background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }
.btn-soft:hover { background: var(--surface-3); }
.btn.wa svg { color: var(--wa); }

.icon-btn {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  transition: background-color 0.15s, color 0.15s;
}
.icon-btn:hover, .icon-btn.active { background: var(--surface-3); color: var(--text); }

.card {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; }
.field-hint { font-size: 12px; color: var(--text-3); }
.opt { font-weight: 500; color: var(--text-3); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > svg { position: absolute; left: 14px; color: var(--text-3); pointer-events: none; transition: color 0.15s; }
.input-wrap input {
  width: 100%;
  height: 46px;
  padding: 0 14px 0 42px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  outline: none;
  background: var(--surface);
  font-size: 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-wrap input::placeholder { color: var(--text-3); }
.input-wrap input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--ring); }
.input-wrap:focus-within > svg { color: var(--brand-text); }

.form-error, .notice-inline {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
}
.form-error { background: color-mix(in oklab, var(--danger) 10%, var(--surface)); color: var(--danger); }
.notice-inline {
  border: 1px solid color-mix(in oklab, var(--warning) 35%, transparent);
  background: color-mix(in oklab, var(--warning) 10%, var(--surface));
}
.muted { margin: 0; color: var(--text-2); font-size: 14px; }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: auto;
  color: var(--text-3);
  font-size: 13.5px;
}

.toasts {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  padding: 10px 16px;
  border-radius: 12px;
  background: #101828;
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: rise 0.2s ease-out;
  transition: opacity 0.3s, transform 0.3s;
}
.toast.out { opacity: 0; transform: translateY(6px); }
:root[data-theme="dark"] .toast { background: #f2f4f7; color: #101828; }

/* ---------- Gelembung chat (dipakai di kedua halaman) ---------- */
.chat { position: relative; display: flex; flex: 1; flex-direction: column; min-height: 0; background: var(--surface-2); }
.messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  padding: 18px 14px 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.day { display: flex; justify-content: center; margin: 18px 0 6px; }
.day span {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}
.unread-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 4px;
  color: var(--brand-text);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.unread-divider::before, .unread-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: color-mix(in oklab, var(--brand) 40%, transparent);
}

.msg, .typing-row { display: flex; align-items: flex-start; gap: 8px; margin-top: 12px; animation: rise 0.18s ease-out; }
.msg.cont { margin-top: 3px; }
.msg.mine { flex-direction: row-reverse; }
.msg-avatar { margin-top: 19px; }
.msg.cont .msg-avatar { height: 0; visibility: hidden; }
.msg-body { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: min(78%, 540px); }
.msg.mine .msg-body { align-items: flex-end; }
.msg-author { margin: 0 4px 3px; color: var(--text-2); font-size: 12px; font-weight: 600; line-height: 16px; }
.bubble {
  padding: 8px 12px 6px;
  border: 1px solid var(--bubble-them-border);
  border-radius: 18px;
  background: var(--bubble-them);
  box-shadow: var(--shadow-xs);
  overflow-wrap: anywhere;
}
.msg.theirs:not(.cont) .bubble, .typing-row .bubble { border-top-left-radius: 6px; }
.msg.mine .bubble { border-color: transparent; background: var(--brand); color: var(--brand-ink); }
.msg.mine:not(.cont) .bubble { border-top-right-radius: 6px; }
.text { font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; }
.text a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.msg.theirs .text a { color: var(--brand-text); }
.meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 3px;
  color: var(--text-3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.msg.mine .meta { color: rgb(255 255 255 / 0.75); }
.tick { display: inline-flex; }
.msg.mine .tick[data-state="read"] { color: var(--read-on-brand); }
.msg.pending .bubble { opacity: 0.7; }
.msg.failed .bubble { cursor: pointer; box-shadow: 0 0 0 2px color-mix(in oklab, var(--danger) 75%, transparent); }
.fail-note { margin: 4px 4px 0; color: var(--danger); font-size: 11.5px; font-weight: 600; cursor: pointer; }

.typing-bubble { display: inline-flex; align-items: center; gap: 4px; padding: 13px 14px; }
.typing-bubble i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: typing 1.2s infinite ease-in-out; }
.typing-bubble i:nth-child(2) { animation-delay: 0.15s; }
.typing-bubble i:nth-child(3) { animation-delay: 0.3s; }

/* ============================================================
   Halaman chat user
   ============================================================ */
body.visitor {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(1000px 520px at 50% -160px, color-mix(in oklab, var(--brand) 28%, transparent), transparent 72%),
    var(--page);
}
.widget {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  /* pita warna brand di belakang header (dan di belakang sapaan pada layar "mulai chat") */
  background:
    linear-gradient(150deg, var(--brand), var(--brand-strong)) top / 100% 300px no-repeat,
    var(--surface-2);
}
@media (min-width: 720px) {
  body.visitor { display: grid; place-items: center; padding: 32px 20px; }
  .widget {
    width: min(100%, 700px);
    height: calc(100vh - 64px);
    height: min(880px, calc(100dvh - 64px));
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
  }
}

.widget-header {
  position: relative;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: max(14px, env(safe-area-inset-top)) 18px 14px;
  color: var(--brand-ink);
}
.widget-header .brand-mark { background: rgb(255 255 255 / 0.16); }
.widget-header .brand-dots { fill: var(--brand-strong); }
.widget-header .titles { flex: 1; min-width: 0; }
.widget-header h1 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
.status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0 0;
  color: rgb(255 255 255 / 0.85);
  font-size: 12.5px;
  white-space: nowrap;
}
.status #statusText { overflow: hidden; text-overflow: ellipsis; }
.status .dot { flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; background: rgb(255 255 255 / 0.45); }
.status.online .dot { background: #4ade80; box-shadow: 0 0 0 3px rgb(74 222 128 / 0.25); }
.status.connecting .dot { background: #fbbf24; animation: pulse 1.2s infinite; }
/* Avatar balasan CS di halaman pelanggan: logo, bukan inisial nama CS */
.avatar.cs-avatar { background: var(--brand); color: #ffffff; }
.cs-avatar .brand-dots { fill: var(--brand); }

.boot {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 14px;
}

.start { flex: 1; min-height: 0; padding-bottom: 24px; overflow-y: auto; }
.hero { padding: 16px 24px 64px; color: var(--brand-ink); }
.hero-hello { margin: 0 0 4px; font-size: 16px; font-weight: 500; opacity: 0.85; }
.hero-title { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.start-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: -44px 16px 0;
  padding: 22px;
  animation: rise 0.25s ease-out;
}
.card-head h3 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.card-head p { margin: 4px 0 0; color: var(--text-2); font-size: 13.5px; }
.privacy { margin: 0; color: var(--text-3); font-size: 12px; text-align: center; }
.privacy svg { display: inline-block; margin-right: 4px; vertical-align: -2px; }
@media (min-width: 720px) {
  .hero { padding: 24px 32px 72px; }
  .hero-title { font-size: 30px; }
  .start-card { margin: -52px 32px 0; padding: 28px; }
}

.intro {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 4px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.intro-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-text);
}
.intro-title { margin: 0; font-size: 14.5px; font-weight: 700; }
.intro-text { margin: 2px 0 0; color: var(--text-2); font-size: 13.5px; }
@media (min-width: 720px) {
  .visitor .messages { padding: 22px 22px 12px; }
}

.composer {
  flex-shrink: 0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--ring); }
.composer-box .attach-btn {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-2);
  transition: background-color 0.15s, color 0.15s;
}
.composer-box .attach-btn:hover { background: var(--surface-3); color: var(--brand-text); }
.composer-box textarea {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  max-height: 160px;
  padding: 9px 0;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 16px; /* < 16px membuat iPhone auto-zoom */
  line-height: 1.4;
  resize: none;
}
.composer-box textarea::placeholder, .composer-card textarea::placeholder { color: var(--text-3); }
.send {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-ink);
  transition: background-color 0.15s, color 0.15s, transform 0.1s;
}
.send svg { margin-left: 2px; }
.send:hover:not(:disabled) { background: var(--brand-strong); }
.send:active:not(:disabled) { transform: scale(0.94); }
.send:disabled { background: var(--surface-3); color: var(--text-3); cursor: default; }

/* ============================================================
   Dashboard CS
   ============================================================ */
body.agent { background: var(--surface-2); }

.login {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 16px;
  background:
    radial-gradient(900px 480px at 50% -180px, color-mix(in oklab, var(--brand) 24%, transparent), transparent 70%),
    var(--page);
}
.login-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
  max-width: 400px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  animation: rise 0.25s ease-out;
}
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-kicker { margin: 0; color: var(--brand-text); font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.login-brand h1 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.25; }

.dash {
  display: grid;
  grid-template-columns: 76px clamp(280px, 26vw, 360px) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}
@media (min-width: 1200px) {
  .dash.details-open { grid-template-columns: 76px clamp(280px, 24vw, 360px) minmax(0, 1fr) 320px; }
}

/* ----- Menu samping (Inbox | Performa) ----- */
.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 0;
  padding: 14px 8px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}
.rail-brand {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 14px;
  border-radius: 12px;
  background: var(--brand);
  color: #ffffff;
}
.rail-brand .brand-dots { fill: var(--brand); }
.rail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 60px;
  padding: 8px 0 7px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}
.rail-item:hover { background: var(--surface-3); color: var(--text); }
.rail-item.active { background: var(--brand-soft); color: var(--brand-text); }
.rail-icon { position: relative; display: grid; place-items: center; }
.rail-badge {
  position: absolute;
  top: -7px;
  left: 12px;
  display: grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--st-hard);
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 700;
  box-shadow: 0 0 0 2px var(--surface);
}
.rail-spacer { flex: 1; }
.rail-me { margin: 6px 0 2px; }
/* Gaya "Penuh": menu samping berwarna tema */
:root[data-style="bold"] .rail { border-color: transparent; background: var(--rail-bg); }
:root[data-style="bold"] .rail-item { color: rgb(255 255 255 / 0.74); }
:root[data-style="bold"] .rail-item:hover { background: rgb(255 255 255 / 0.12); color: #ffffff; }
:root[data-style="bold"] .rail-item.active { background: rgb(255 255 255 / 0.2); color: #ffffff; }
:root[data-style="bold"] .rail-brand { background: rgb(255 255 255 / 0.16); }
:root[data-style="bold"] .rail-brand .brand-dots { fill: var(--rail-bg); }
:root[data-style="bold"] .rail-badge { box-shadow: 0 0 0 2px var(--rail-bg); }
:root[data-style="bold"] .rail-me .avatar { box-shadow: 0 0 0 2px rgb(255 255 255 / 0.4); }

/* ----- Sidebar ----- */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
}
.side-head { display: flex; flex-shrink: 0; align-items: center; gap: 10px; height: 64px; padding: 0 12px 0 16px; }
.side-head h1 { flex: 1; margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.conn-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 12px 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: color-mix(in oklab, var(--warning) 14%, var(--surface));
  font-size: 12.5px;
  font-weight: 600;
}
.conn-banner::before {
  content: "";
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  animation: pulse 1.2s infinite;
}
.side-tools { display: flex; flex-direction: column; gap: 10px; padding: 0 12px 12px; border-bottom: 1px solid var(--border); }
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 12px; color: var(--text-3); pointer-events: none; }
.search input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 36px;
  border: 1px solid transparent;
  border-radius: 10px;
  outline: none;
  background: var(--surface-3);
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
.search input::placeholder { color: var(--text-3); }
.search input:focus { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px var(--ring); }
/* Filter cepat (chip) per status */
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { border-color: transparent; background: var(--text); color: var(--surface); }
.chip svg { color: var(--st-hard); }
.chip.active svg { color: inherit; }
.chip-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.chip-count { font-size: 11.5px; font-variant-numeric: tabular-nums; opacity: 0.7; }

/* Pemilih grup di kepala sidebar */
.group-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 180px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
}
.group-btn:hover { border-color: var(--border-strong); color: var(--text); }
.group-btn.filtered { border-color: color-mix(in oklab, var(--brand) 45%, transparent); background: var(--brand-soft); color: var(--text); }
.group-btn-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.conv-list { flex: 1; min-height: 0; margin: 0; padding: 8px; overflow-y: auto; list-style: none; }
.conv-list:empty { display: none; }
.conv {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 12px;
  outline: none;
  cursor: pointer;
  transition: background-color 0.12s;
}
.conv + .conv { margin-top: 2px; }
.conv:hover { background: var(--surface-3); }
.conv:focus-visible { box-shadow: inset 0 0 0 2px var(--brand); }
.conv.active { background: var(--brand-soft); }
.conv.active::before {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
}
.conv .avatar.online::after { box-shadow: 0 0 0 2px var(--surface); }
.conv-body { flex: 1; min-width: 0; }
.conv-top, .conv-bottom { display: flex; align-items: center; gap: 8px; }
.conv-bottom { margin-top: 2px; }
.conv-name { flex: 1; min-width: 0; overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { flex-shrink: 0; color: var(--text-3); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.conv-preview { flex: 1; min-width: 0; overflow: hidden; color: var(--text-2); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.conv-you { color: var(--text-3); }
.conv-new { color: var(--brand-text); font-weight: 600; }
.conv.unread .conv-name { font-weight: 800; }
.conv.unread .conv-preview { color: var(--text); font-weight: 500; }
.conv.unread .conv-time { color: var(--brand-text); font-weight: 700; }
.conv-preview.typing { color: var(--brand-text); font-style: italic; }
.badge {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--brand);
  color: var(--brand-ink);
  font-size: 11px;
  font-weight: 700;
}
.list-empty {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 32px 28px;
  color: var(--text-2);
  font-size: 13px;
  text-align: center;
}
.list-empty svg { margin-bottom: 6px; color: var(--text-3); }
.list-empty strong { color: var(--text); font-size: 14px; }

.conv-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }

/* ----- Panel chat ----- */
.panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface-2); }
.chat-head {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 12px;
  height: 64px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.chat-head .titles { flex: 1; min-width: 0; }
.chat-head h2 { margin: 0; overflow: hidden; font-size: 15px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .sub { margin: 1px 0 0; overflow: hidden; color: var(--text-2); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.sub.typing { color: var(--brand-text); font-style: italic; }
.presence { color: var(--text-3); font-weight: 600; }
.presence.on { color: var(--online); }
.head-actions { display: flex; align-items: center; gap: 6px; }
.back { display: none; margin-left: -6px; }
.title-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.title-badges { display: flex; flex-shrink: 0; gap: 4px; }
.status-btn {
  --c: var(--text-3);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 10px 0 12px;
  border: 1px solid color-mix(in oklab, var(--c) 40%, var(--border));
  border-radius: 999px;
  background: color-mix(in oklab, var(--c) 10%, var(--surface));
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.15s;
}
.status-btn:hover { background: color-mix(in oklab, var(--c) 18%, var(--surface)); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }

.agent .messages { padding: 20px max(20px, calc((100% - 860px) / 2)) 12px; }
.agent .composer {
  padding: 0 max(16px, calc((100% - 860px) / 2)) calc(16px + env(safe-area-inset-bottom));
  border-top: 0;
  background: transparent;
}
.composer-card {
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer-card:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--ring); }
.composer-card textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  max-height: 200px;
  padding: 12px 16px 4px;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 15px;
  line-height: 1.5;
  resize: none;
}
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 8px 8px; }
.composer-foot .attach-btn:hover { color: var(--brand-text); }
.hint { color: var(--text-3); font-size: 12px; }
kbd {
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text-2);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
}
.send-btn { margin-left: auto; }
.send-btn svg { margin-right: -2px; }
@media (pointer: coarse) {
  .search input, .composer-card textarea { font-size: 16px; }
  .hint { display: none; }
}

.no-chat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 440px;
  margin: auto;
  padding: 32px 24px;
  text-align: center;
}
.no-chat h2 { margin: 14px 0 0; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.no-chat > p { margin: 0; color: var(--text-2); font-size: 14px; }
.art-soft { fill: color-mix(in oklab, var(--brand) 14%, var(--surface)); }
.art-line { fill: color-mix(in oklab, var(--brand) 32%, var(--surface)); }
.art-brand { fill: var(--brand); }
.art-dot { fill: #ffffff; }
.share {
  width: 100%;
  margin-top: 20px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  text-align: left;
}
.share-label { display: block; margin-bottom: 8px; color: var(--text-2); font-size: 11.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.share-row { display: flex; align-items: center; gap: 8px; }
.share-row code {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  overflow: hidden;
  border-radius: 9px;
  background: var(--surface-3);
  font-family: var(--mono);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.share-hint { display: block; margin-top: 10px; color: var(--text-3); font-size: 12px; }
.share-hint code { color: var(--text-2); font-family: var(--mono); }

/* ----- Panel detail pelanggan ----- */
.details {
  display: none;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
}
.details-head {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 12px 0 20px;
  border-bottom: 1px solid var(--border);
}
.details-head h3 { margin: 0; font-size: 14px; font-weight: 700; }
.details-body { flex: 1; min-height: 0; padding: 24px 20px; overflow-y: auto; }
.profile { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.profile .avatar { margin-bottom: 10px; }
.profile .avatar.online::after { box-shadow: 0 0 0 3px var(--surface); }
.profile-name { font-size: 16px; font-weight: 700; overflow-wrap: anywhere; }
.profile-status { color: var(--text-3); font-size: 12.5px; font-weight: 600; }
.profile-status.on { color: var(--online); }
.profile-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 16px 0 20px; }
.profile-actions:empty { display: none; }
.info { margin: 0; border-top: 1px solid var(--border); }
.info-row { padding: 12px 0; border-bottom: 1px solid var(--border); }
.info-row dt {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.info-row dd { margin: 4px 0 0; font-size: 13.5px; font-weight: 500; overflow-wrap: anywhere; }
.details-backdrop { display: none; }

@media (min-width: 1200px) {
  .dash.details-open .details { display: flex; }
}
@media (max-width: 1199px) {
  .dash.details-open .details {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: flex;
    width: min(340px, 100%);
    box-shadow: var(--shadow-lg);
    animation: slide-in 0.2s ease-out;
  }
  .dash.details-open .details-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: block;
    background: rgb(16 24 40 / 0.45);
  }
}

/* ----- HP: daftar chat dan isi chat bergantian ----- */
@media (max-width: 760px) {
  .dash { grid-template-columns: minmax(0, 1fr); }
  .dash .panel { display: none; }
  .dash.open .sidebar { display: none; }
  .dash.open .panel { display: flex; }
  .back { display: grid; }
  /* menu samping menjadi navigasi bawah, disembunyikan saat chat dibuka */
  .rail {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 25;
    flex-direction: row;
    justify-content: space-around;
    gap: 0;
    padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    border-right: 0;
  }
  .rail-brand, .rail-spacer, .rail-me { display: none; }
  .rail-item { flex: 1; width: auto; max-width: 120px; }
  .dash.open .rail { display: none; }
  .sidebar { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .chat-head { gap: 10px; padding: 0 10px 0 12px; }
  .title-badges { display: none; }
  .status-btn { padding: 0 8px 0 10px; }
  .status-btn > span:not(.status-dot) { display: none; }
  .head-actions .wa { width: 36px; padding: 0; }
  .head-actions .wa span { display: none; }
  .agent .messages { padding: 16px 12px 8px; }
  .agent .composer { padding: 0 10px calc(10px + env(safe-area-inset-bottom)); }
  .rail-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* kotak balasan satu baris: teks + tombol kirim */
  .composer-card { display: flex; align-items: flex-end; }
  .composer-card textarea { flex: 1; width: auto; min-width: 0; padding: 12px 4px 12px 14px; }
  .composer-foot { padding: 6px; }
  .hint { display: none; }
}

/* HP sempit: 6 menu di navigasi bawah tetap berjarak */
@media (max-width: 400px) {
  .rail { padding-right: 2px; padding-left: 2px; }
  .rail-item { font-size: 10px; }
}

/* ============================================================
   Badge status, menu klik kanan, dialog
   ============================================================ */
.pill {
  --c: var(--text-3);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  height: 20px;
  padding: 0 8px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in oklab, var(--c) 14%, var(--surface));
  color: color-mix(in oklab, var(--c), var(--text) 32%);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}
.pill[class*="st-"]::before { content: ""; flex-shrink: 0; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.pill.hard { --c: var(--st-hard); }
.pill.group { --c: hsl(var(--h) 55% 45%); }
/* Warna status dipakai badge, chip, menu, tombol status, dan grafik. Ditulis setelah .pill supaya tidak tertimpa. */
.st-open { --c: var(--st-open); }
.st-pending { --c: var(--st-pending); }
.st-resolved { --c: var(--st-resolved); }
.pill svg { flex-shrink: 0; }
.profile-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-top: 10px; }

.menu {
  position: fixed;
  z-index: 200;
  min-width: 230px;
  max-width: 300px;
  max-height: min(72vh, 520px);
  padding: 6px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
  animation: pop 0.12s ease-out;
}
@keyframes pop { from { opacity: 0; transform: scale(0.97); } }
.menu-section {
  padding: 8px 10px 4px;
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.menu-divider { height: 1px; margin: 6px 4px; background: var(--border); }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
}
.menu-item:hover, .menu-item:focus-visible { outline: none; background: color-mix(in oklab, var(--text) 7%, transparent); }
.menu-item > svg { flex-shrink: 0; color: var(--text-2); }
.menu-item.danger, .menu-item.danger > svg { color: var(--danger); }
.menu-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-hint { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.menu-check { display: inline-flex; color: var(--brand-text); }
.menu-dot { flex-shrink: 0; width: 10px; height: 10px; margin: 0 3px; border-radius: 50%; background: var(--c); }
.menu-dot.swatch { border-radius: 3px; background: hsl(var(--h) 55% 50%); }
.menu-lead { width: 16px; flex-shrink: 0; }

/* Panel tema: mode tampilan + warna brand */
.theme-panel { width: 292px; max-width: calc(100vw - 16px); padding: 8px; }
.theme-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 2px 4px 8px; }
.theme-mode {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 4px 9px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}
.theme-mode:hover { border-color: var(--border-strong); color: var(--text); }
.theme-mode.active { border-color: var(--brand); background: var(--brand-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--brand); }
.theme-mode.active svg { color: var(--brand-text); }
.theme-styles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 2px 4px 8px; }
.theme-style {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 7px 6px 8px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}
.theme-style:hover { border-color: var(--border-strong); color: var(--text); }
.theme-style.active { border-color: var(--brand); color: var(--text); box-shadow: inset 0 0 0 1px var(--brand); }
/* Pratinjau mini: menu samping, daftar chat, area chat */
.style-pv {
  --pv-1: 0%;
  --pv-2: 0%;
  display: grid;
  grid-template-columns: 9px 24px minmax(0, 1fr);
  width: 100%;
  height: 40px;
  overflow: hidden;
  border: 1px solid var(--n-border);
  border-radius: 6px;
}
.style-pv i { display: flex; flex-direction: column; gap: 3px; padding: 5px 3px; }
.pv-rail, .pv-list { background: color-mix(in oklab, var(--brand) var(--pv-1), var(--n-surface)); }
.pv-rail { border-right: 1px solid var(--n-border); }
.pv-list b { height: 3px; border-radius: 2px; background: color-mix(in oklab, var(--brand) calc(var(--pv-1) + 12%), var(--n-border)); }
.pv-chat { justify-content: center; background: color-mix(in oklab, var(--brand) var(--pv-2), var(--n-surface-2)); }
.pv-chat b { height: 6px; border-radius: 3px; }
.pv-in { width: 55%; background: var(--n-bubble); box-shadow: 0 0 0 1px var(--n-border); }
.pv-out { width: 45%; align-self: flex-end; background: var(--brand); }
.pv-soft { --pv-1: 4%; --pv-2: 9%; }
.pv-bold { --pv-1: 6%; --pv-2: 14%; }
.pv-bold .pv-rail { border-right: 0; background: color-mix(in oklab, var(--brand), black 25%); }
.theme-swatches { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; padding: 4px 8px 2px; }
.swatch-btn {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--sw);
  color: #ffffff;
  cursor: pointer;
  transition: transform 0.12s;
}
.swatch-btn:hover { transform: scale(1.08); }
.swatch-btn svg { opacity: 0; }
.swatch-btn.active { box-shadow: 0 0 0 2px var(--surface-raised), 0 0 0 4px var(--sw); }
.swatch-btn.active svg { opacity: 1; }
.swatch-btn.custom { background: conic-gradient(#ef4444, #f59e0b, #22c55e, #06b6d4, #6366f1, #d946ef, #ef4444); }
.swatch-btn.custom svg { opacity: 1; filter: drop-shadow(0 1px 1px rgb(0 0 0 / 0.5)); }
.swatch-btn.custom.active { box-shadow: 0 0 0 2px var(--surface-raised), 0 0 0 4px var(--brand); }
.swatch-btn.custom input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.swatch-btn:focus-within { outline: 2px solid var(--brand); outline-offset: 3px; }
.theme-note { margin: 10px 8px 4px; color: var(--text-3); font-size: 11.5px; line-height: 1.4; }
.login-theme { position: fixed; top: 16px; right: 16px; z-index: 5; }

.btn-danger { background: var(--danger); color: #ffffff; }
.btn-danger:hover { background: color-mix(in oklab, var(--danger), black 12%); }
.icon-btn.danger:hover { background: color-mix(in oklab, var(--danger) 12%, var(--surface)); color: var(--danger); }
.icon-btn.bordered { border: 1px solid var(--border); background: var(--surface); }

.dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.dialog[open] { animation: pop 0.15s ease-out; }
.dialog::backdrop { background: rgb(16 24 40 / 0.45); }
.dialog-form { display: flex; flex-direction: column; gap: 14px; padding: 22px; }
.dialog-title { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.dialog-text { margin: 0; color: var(--text-2); font-size: 14px; }
.dialog-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  outline: none;
  background: var(--surface);
  font-size: 16px;
}
.dialog-input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--ring); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.group-manage { display: flex; flex-direction: column; gap: 2px; }
.group-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px 6px 10px; border-radius: 10px; }
.group-row:hover { background: var(--surface-3); }
.group-row-name { flex: 1; min-width: 0; overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.group-row-count { color: var(--text-3); font-size: 12px; }
.group-manage > .btn { align-self: flex-start; margin-top: 10px; }

/* ============================================================
   Lampiran (gambar, video, audio, PDF): gelembung, unggah, drag & drop, pratinjau, lightbox
   ============================================================ */
.bubble.has-image { position: relative; padding: 4px; }
.bubble.has-image .text { padding: 4px 8px 0; }
.bubble.has-image .meta { padding: 0 8px 4px; }
.msg-image {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 14px;
  background: var(--surface-3);
  line-height: 0;
  cursor: zoom-in;
}
.msg.theirs:not(.cont) .msg-image { border-top-left-radius: 4px; }
.msg.mine:not(.cont) .msg-image { border-top-right-radius: 4px; }
.msg-image img { display: block; width: min(280px, 62vw); height: auto; max-height: 360px; object-fit: cover; }
.bubble.image-only .meta {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.45);
  color: #ffffff;
}
.msg.mine .bubble.image-only .tick[data-state="read"] { color: var(--read-on-brand); }
.msg.pending .msg-image img { filter: brightness(0.8); }
.msg.pending .bubble.has-image { opacity: 1; }
.upload-progress {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.4);
}
.bubble.image-only .upload-progress { right: 80px; }
.upload-progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: #ffffff; transition: width 0.2s; }
.upload-progress.inline { position: static; display: block; margin-top: 8px; }

/* Video, audio (termasuk pesan suara WhatsApp), dan PDF */
.msg-video { position: relative; overflow: hidden; border-radius: 14px; background: #000000; line-height: 0; }
.msg.theirs:not(.cont) .msg-video { border-top-left-radius: 4px; }
.msg.mine:not(.cont) .msg-video { border-top-right-radius: 4px; }
.msg-video video { display: block; width: min(300px, 62vw); height: auto; max-height: 380px; }
.msg-audio { display: flex; align-items: center; gap: 8px; width: min(300px, 62vw); }
.msg-audio-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-text);
}
.msg.mine .msg-audio-icon { background: rgb(255 255 255 / 0.2); color: #ffffff; }
.msg-audio audio { flex: 1; min-width: 0; height: 40px; }
.msg-file {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(280px, 62vw);
  padding: 8px 10px;
  border-radius: 12px;
  background: color-mix(in oklab, var(--text) 5%, transparent);
  color: inherit;
  text-decoration: none;
  transition: background-color 0.15s;
}
.msg-file:hover { background: color-mix(in oklab, var(--text) 9%, transparent); }
.msg.mine .msg-file { background: rgb(255 255 255 / 0.14); }
.msg.mine .msg-file:hover { background: rgb(255 255 255 / 0.22); }
.msg-file-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: color-mix(in oklab, var(--danger) 12%, var(--surface));
  color: var(--danger-text);
}
.msg-file-body { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.msg-file-name { overflow: hidden; font-size: 13.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.msg-file-meta { font-size: 11.5px; opacity: 0.7; }
.msg-file > svg { flex-shrink: 0; opacity: 0.7; }
.bubble.has-file .text { margin-top: 6px; }

.drop-overlay {
  position: absolute;
  inset: 10px;
  z-index: 15;
  display: grid;
  place-items: center;
  border: 2px dashed var(--brand);
  border-radius: 18px;
  background: color-mix(in oklab, var(--surface) 90%, transparent);
  pointer-events: none;
}
.drop-card { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; text-align: center; }
.drop-card svg { color: var(--brand-text); }
.drop-card strong { color: var(--text); font-size: 15px; }

.attach-dialog { width: min(560px, calc(100vw - 24px)); }
.attach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
  max-height: 52vh;
  overflow-y: auto;
}
.attach-thumb { position: relative; aspect-ratio: 1; overflow: hidden; border-radius: 12px; background: var(--surface-3); }
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; }
.attach-grid.single { grid-template-columns: minmax(0, 1fr); }
.attach-grid.single .attach-thumb { display: grid; place-items: center; aspect-ratio: auto; }
.attach-grid.single .attach-thumb img { width: auto; max-width: 100%; height: auto; max-height: 46vh; object-fit: contain; }
.attach-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.6);
  color: #ffffff;
}
.attach-add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  aspect-ratio: 1;
  border: 2px dashed var(--border-strong);
  border-radius: 12px;
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
}
.attach-add:hover { border-color: var(--brand); color: var(--brand-text); }
.attach-grid.single .attach-add { flex-direction: row; aspect-ratio: auto; height: 42px; }
.attach-thumb video { display: block; width: 100%; height: 100%; object-fit: cover; background: #000000; }
.attach-grid.single .attach-thumb video { height: auto; max-height: 46vh; object-fit: contain; }
.attach-play { position: absolute; inset: 0; display: grid; place-items: center; color: #ffffff; pointer-events: none; filter: drop-shadow(0 1px 3px rgb(0 0 0 / 0.6)); }
.attach-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  height: 100%;
  padding: 10px;
  text-align: center;
}
.attach-tile svg { flex-shrink: 0; margin-bottom: 2px; color: var(--brand-text); }
.attach-tile-name { max-width: 100%; overflow: hidden; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.attach-tile-size { color: var(--text-3); font-size: 11px; }
.attach-grid.single .attach-tile { flex-direction: row; gap: 12px; padding: 16px 44px 16px 16px; text-align: left; }
.attach-grid.single .attach-tile-name { flex: 1; font-size: 13.5px; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 64px 16px 24px;
  background: rgb(8 12 16 / 0.92);
  animation: fade 0.15s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.lightbox img {
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 96px);
  border-radius: 8px;
  object-fit: contain;
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.5);
}
.lightbox-bar { position: absolute; top: 12px; right: 12px; display: flex; gap: 8px; }
.lightbox-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.12);
  color: #ffffff;
}
.lightbox-btn:hover { background: rgb(255 255 255 / 0.22); }

/* ============================================================
   Halaman Performa
   ============================================================ */
.perf-app { display: grid; grid-template-columns: 76px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.perf { min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 48px; overflow-y: auto; background: var(--surface-2); }
.perf-inner { display: flex; flex-direction: column; gap: 16px; max-width: 1180px; margin: 0 auto; }
.perf.is-loading .perf-inner > :not(.perf-head) { opacity: 0.55; transition: opacity 0.2s; }
.perf-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.perf-head h1 { margin: 0 0 2px; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.perf-controls { display: flex; align-items: center; gap: 8px; }
.perf-updated { margin: -6px 0 0; color: var(--text-3); font-size: 12.5px; }
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--surface-3); }
.seg-btn {
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow-sm); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.kpi-label { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; font-weight: 600; }
.kpi-flag { display: inline-flex; }
.kpi-flag.warning { color: var(--st-open); }
.kpi-flag.danger { color: var(--st-hard); }
.kpi-value { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.kpis.secondary .kpi { padding: 14px 18px; }
.kpis.secondary .kpi-value { font-size: 21px; }
.kpi-sub { color: var(--text-3); font-size: 12.5px; }
.meter {
  height: 6px;
  margin: 6px 0 2px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in oklab, var(--chart-replied) 18%, var(--surface));
}
.meter i { display: block; height: 100%; border-radius: inherit; background: var(--chart-replied); }

.perf-card { padding: 18px 20px; }
.perf-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.card-head-row { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head-row h2 { margin: 0; font-size: 15px; font-weight: 700; }
.muted.sm { margin-top: 2px; font-size: 12.5px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; flex-shrink: 0; border-radius: 3px; background: var(--c); }
.sw.replied { --c: var(--chart-replied); }
.sw.unreplied { --c: var(--chart-unreplied); }
.empty-note { margin: 8px 0; color: var(--text-3); font-size: 13px; }

/* Grafik kolom bertumpuk: terbalas (bawah) + belum terbalas (atas) */
.vchart { --cols: 7; }
.vchart-plot { position: relative; height: 220px; margin-left: 34px; }
.vchart-grid { position: absolute; inset: 0; }
.gridline { position: absolute; right: 0; left: 0; height: 1px; background: var(--border); }
.gridline.base { background: var(--border-strong); }
.gridline span {
  position: absolute;
  top: -8px;
  right: calc(100% + 8px);
  color: var(--text-3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.vchart-cols { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); }
.vcol {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: default;
}
.vcol:hover, .vcol:focus-visible { outline: none; background: color-mix(in oklab, var(--text) 5%, transparent); }
.vbar { display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; width: min(24px, 64%); height: 100%; }
.vbar .vseg { flex-shrink: 0; width: 100%; }
.vbar .vseg:first-child { border-radius: 4px 4px 0 0; } /* ujung data membulat, dasar tetap datar */
.vseg.replied { background: var(--chart-replied); }
.vseg.unreplied { background: var(--chart-unreplied); }
.vcol-value { position: absolute; left: 0; right: 0; color: var(--text-2); font-size: 11.5px; font-weight: 700; text-align: center; }
.vchart-x {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  margin: 8px 0 0 34px;
  color: var(--text-3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}
.chart-tip {
  position: fixed;
  z-index: 150;
  min-width: 170px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
  font-size: 12.5px;
  pointer-events: none;
}
.tip-title { margin-bottom: 6px; color: var(--text-2); font-weight: 600; }
.tip-row { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.tip-row + .tip-row { margin-top: 3px; }
.tip-row b { min-width: 30px; color: var(--text); font-size: 14px; font-variant-numeric: tabular-nums; }
.tip-key { width: 12px; height: 3px; border-radius: 2px; background: var(--c); }
.tip-key.replied { --c: var(--chart-replied); }
.tip-key.unreplied { --c: var(--chart-unreplied); }
.tip-key.none { background: transparent; }

/* Batang horizontal (kecepatan membalas, chat per grup) */
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar-row { display: grid; grid-template-columns: 120px minmax(0, 1fr) 84px; align-items: center; gap: 12px; font-size: 13px; }
.hbar-label { min-width: 0; overflow: hidden; color: var(--text-2); text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 12px; border-left: 1px solid var(--border-strong); }
.hbar-fill { display: block; min-width: 2px; height: 100%; border-radius: 0 4px 4px 0; background: var(--chart-replied); }
.hbar-value { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.hbar-value small { color: var(--text-3); font-size: 12px; font-weight: 500; }

/* Status percakapan: batang 100% bertumpuk + legenda */
.stack { display: flex; gap: 2px; height: 14px; margin: 4px 0 16px; overflow: hidden; border-radius: 4px; }
.stack i { height: 100%; background: var(--c); }
.stack-legend { display: flex; flex-direction: column; gap: 8px; }
.stack-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.stack-label { flex: 1; color: var(--text-2); }
.stack-row b { font-variant-numeric: tabular-nums; }
.stack-row small { width: 44px; color: var(--text-3); font-size: 12px; text-align: right; }
.hard-note { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; }
.hard-note svg { color: var(--st-hard); }
.hard-note span { flex: 1; color: var(--text-2); }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-align: right;
  text-transform: uppercase;
  white-space: nowrap;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.data-table th:first-child, .data-table td:first-child { padding-left: 0; text-align: left; }
.data-table tr:last-child td { border-bottom: 0; }
.agent-cell { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; }
.table-view summary { margin-top: 14px; color: var(--text-2); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.table-view .data-table { margin-top: 8px; }

@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .perf-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .perf-app { grid-template-columns: minmax(0, 1fr); }
  .perf { padding: 20px 14px calc(84px + env(safe-area-inset-bottom)); }
  .perf-head h1 { font-size: 21px; }
  .kpi-value { font-size: 23px; }
  .vchart-plot, .vchart-x { margin-left: 28px; }
  .hbar-row { grid-template-columns: 92px minmax(0, 1fr) 70px; gap: 8px; }
}

/* ============================================================
   Channel WhatsApp: tanda di Inbox + halaman Pengaturan
   ============================================================ */
.ch-wa { display: inline-flex; flex-shrink: 0; margin-right: 5px; color: var(--wa-icon); vertical-align: -2px; }
.chat-head .sub .ch-wa { margin-right: 4px; vertical-align: -3px; }
.agent-cell .ch-wa { margin: 0; }
.agent-cell > svg { color: var(--text-2); }
.chip[data-filter="wa"] svg, .chip[data-filter="wa"].active svg { color: var(--wa-icon); }
.chip[data-filter="web"] svg { color: var(--text-2); }
.chip[data-filter="web"].active svg { color: inherit; }
.rail-dot {
  position: absolute;
  top: -3px;
  right: -4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--surface);
}
:root[data-style="bold"] .rail-dot { box-shadow: 0 0 0 2px var(--rail-bg); }

/* Pengingat di atas kotak balasan saat WhatsApp terputus */
.wa-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 max(16px, calc((100% - 860px) / 2)) 8px;
  padding: 9px 12px;
  border: 1px solid color-mix(in oklab, var(--warning) 35%, transparent);
  border-radius: 12px;
  background: color-mix(in oklab, var(--warning) 10%, var(--surface));
  font-size: 13px;
  font-weight: 500;
}
.wa-notice svg { flex-shrink: 0; color: var(--warning); }
.wa-notice span { flex: 1; min-width: 0; }
.wa-notice a { color: var(--brand-text); font-weight: 700; }
.share + .share { margin-top: 12px; }
.wa-share-text { flex: 1; min-width: 0; color: var(--text-2); font-size: 13px; }
.wa-share-text.on { color: var(--online-text); font-weight: 600; }

/* ----- Halaman Pengaturan ----- */
.set-inner { max-width: 880px; }
.set-inner .conn-banner { margin: 0; }
.set-card { padding: 20px 22px; }
.set-head { display: flex; align-items: flex-start; gap: 14px; }
.set-icon { display: grid; flex-shrink: 0; place-items: center; width: 42px; height: 42px; border-radius: 12px; }
.set-icon.wa { background: color-mix(in oklab, var(--wa) 14%, var(--surface)); color: var(--wa-icon); }
.set-icon.web { background: var(--brand-soft); color: var(--brand-text); }
.set-titles { flex: 1; min-width: 0; }
.set-titles h2 { margin: 0; font-size: 16px; font-weight: 700; }
.conn-pill {
  --c: var(--text-3);
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--c) 12%, var(--surface));
  color: color-mix(in oklab, var(--c), var(--text) 35%);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.conn-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.conn-pill.on { --c: var(--online); }
.conn-pill.wait { --c: var(--st-pending); }
.conn-pill.busy { --c: var(--warning); }
.conn-pill.busy::before { animation: pulse 1.2s infinite; }
.conn-pill.bad { --c: var(--danger); }
.set-body { display: flex; flex-direction: column; gap: 16px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.set-body .share-hint { margin-top: -8px; }
.set-text { margin: 0; color: var(--text-2); font-size: 14px; }
.set-text b { color: var(--text); }
.set-hint { margin: 0; color: var(--text-3); font-size: 13px; }
.set-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.set-wait { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 14px; font-weight: 500; }
.set-notice { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; font-size: 13.5px; font-weight: 500; }
.set-notice svg { flex-shrink: 0; margin-top: 2px; }
.set-notice.warning { border: 1px solid color-mix(in oklab, var(--warning) 35%, transparent); background: color-mix(in oklab, var(--warning) 10%, var(--surface)); }
.set-notice.warning svg { color: var(--warning); }
.set-notice.danger { border: 1px solid color-mix(in oklab, var(--danger) 30%, transparent); background: color-mix(in oklab, var(--danger) 8%, var(--surface)); }
.set-notice.danger svg { color: var(--danger-text); }
.btn-danger-soft { border-color: color-mix(in oklab, var(--danger) 35%, var(--border)); background: var(--surface); color: var(--danger-text); box-shadow: var(--shadow-xs); }
.btn-danger-soft:hover:not(:disabled) { background: color-mix(in oklab, var(--danger) 8%, var(--surface)); }
.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand-text);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Langkah menautkan + kode QR */
.wa-link { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 28px; }
.wa-steps { display: flex; flex-direction: column; gap: 18px; }
.steps { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { position: relative; padding-left: 36px; color: var(--text-2); font-size: 14px; counter-increment: step; }
.steps li::before {
  content: counter(step);
  position: absolute;
  top: -1px;
  left: 0;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-text);
  font-size: 12px;
  font-weight: 800;
}
.steps b { color: var(--text); font-weight: 700; }
/* Kode QR selalu di atas putih (juga di mode gelap) supaya mudah dipindai kamera HP */
.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 12px 12px 8px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #ffffff;
}
.qr-box img { display: block; width: 240px; height: 240px; image-rendering: pixelated; }
.qr-box img:not([src]) { visibility: hidden; }
.qr-box figcaption { color: #667085; font-size: 12px; }
.pair { display: flex; flex-direction: column; gap: 16px; }
.pair-code {
  align-self: flex-start;
  padding: 12px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.14em;
  user-select: all;
}
.pair-form { display: flex; flex-direction: column; gap: 14px; max-width: 440px; }

/* Sudah tersambung */
.wa-ok { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 14px; background: color-mix(in oklab, var(--online) 9%, var(--surface)); }
.wa-ok-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: color-mix(in oklab, var(--online) 18%, var(--surface));
  color: var(--online-text);
}
.wa-ok-title { font-size: 17px; font-weight: 800; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.wa-ok-sub { color: var(--text-2); font-size: 13px; }
.tips { border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.tips summary { display: flex; align-items: center; gap: 8px; padding: 10px 14px; color: var(--text-2); font-size: 13px; font-weight: 700; cursor: pointer; }
.tips summary svg { color: var(--brand-text); }
.tips ul { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0 16px 12px 36px; color: var(--text-2); font-size: 13px; }

/* Hapus riwayat otomatis */
.set-icon.clean { background: var(--surface-3); color: var(--text-2); }
.ret-rule { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.ret-check { display: inline-flex; align-items: center; gap: 10px; font-size: 14.5px; font-weight: 600; cursor: pointer; }
.ret-check input { flex-shrink: 0; width: 18px; height: 18px; margin: 0; accent-color: var(--brand); cursor: inherit; }
.ret-days { display: inline-flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 600; }
.ret-days input {
  width: 76px;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  outline: none;
  background: var(--surface);
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ret-days input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--ring); }
.ret-days input[aria-invalid="true"] { border-color: var(--danger); }
.ret-days input:disabled { opacity: 0.6; }
/* Pilihan chat yang ikut dihapus: menjorok sejajar teks centang utama */
.ret-filter { display: flex; flex-direction: column; gap: 8px; padding-left: 28px; }
.ret-filter-label { margin: 0; color: var(--text-2); font-size: 13px; font-weight: 700; }
.ret-statuses { display: flex; flex-wrap: wrap; gap: 8px; }
.ret-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.ret-status:hover { border-color: var(--text-3); }
.ret-status:has(input:checked) { border-color: color-mix(in oklab, var(--brand) 45%, var(--border)); background: var(--brand-soft); }
.ret-status input { flex-shrink: 0; width: 16px; height: 16px; margin: 0; accent-color: var(--brand); cursor: inherit; }
.ret-status .chip-dot { flex-shrink: 0; width: 8px; height: 8px; }
.ret-status.hard svg { flex-shrink: 0; color: var(--st-hard); }
.ret-info { display: flex; align-items: flex-start; gap: 8px; margin: 0; color: var(--text-3); font-size: 13px; }
.ret-info:empty { display: none; }
.ret-info svg { flex-shrink: 0; margin-top: 2px; }

/* ----- Database SQL Server ----- */
.set-icon.db { background: var(--surface-3); color: var(--text-2); }
.db-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.text-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  outline: none;
  background: var(--surface);
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.text-input::placeholder { color: var(--text-3); }
.text-input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--ring); }
.db-option { display: flex; flex-direction: column; gap: 4px; }
.db-option .set-hint { padding-left: 28px; }
.set-hint code, .db-help code { font-family: var(--mono); font-size: 0.92em; }
.db-result {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 13.5px;
}
.db-result > svg { flex-shrink: 0; margin-top: 2px; }
.db-result.ok { border-color: color-mix(in oklab, var(--online) 35%, transparent); background: color-mix(in oklab, var(--online) 8%, var(--surface)); }
.db-result.ok > svg { color: var(--online-text); }
.db-result.warn { border-color: color-mix(in oklab, var(--warning) 35%, transparent); background: color-mix(in oklab, var(--warning) 10%, var(--surface)); }
.db-result.warn > svg { color: var(--warning); }
.db-result.bad { border-color: color-mix(in oklab, var(--danger) 30%, transparent); background: color-mix(in oklab, var(--danger) 8%, var(--surface)); }
.db-result.bad > svg { color: var(--danger-text); }
.db-result-lines { display: flex; flex-direction: column; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.db-result-lines p { margin: 0; }
.db-help { display: flex; flex-direction: column; gap: 10px; padding: 0 16px 14px; color: var(--text-2); font-size: 13px; }
.db-help p { margin: 0; }
.db-help ul { display: flex; flex-direction: column; gap: 6px; margin: 0; padding-left: 20px; }
.db-script { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
/* Skrip SQL selalu gelap (juga di mode terang), seperti editor SQL */
.db-script pre {
  align-self: stretch;
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  border-radius: 10px;
  background: #0f172a;
  color: #e2e8f0;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
}

@media (max-width: 760px) {
  .wa-notice { margin: 0 10px 8px; }
  .set-card { padding: 16px; }
  /* status pindah ke bawah judul supaya keterangan tidak terlalu sempit */
  .set-head { flex-wrap: wrap; row-gap: 8px; }
  .set-titles { flex-basis: calc(100% - 56px); }
  .set-head .conn-pill { margin-left: 56px; }
  .ret-filter { padding-left: 0; }
  .db-grid { grid-template-columns: minmax(0, 1fr); }
  .db-option .set-hint { padding-left: 0; }
  .text-input { font-size: 16px; } /* iPhone tidak memperbesar halaman saat mengetik */
  .wa-link { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .qr-box { justify-self: center; order: -1; }
  .qr-box img { width: 220px; height: 220px; }
  .pair-code { align-self: stretch; font-size: 28px; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
