/* ===========================================================================
   NusaWA — tampilan mengikuti bahasa desain WhatsApp Web
   =========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  /* panel & permukaan */
  --bg: #f0f2f5;
  --panel: #ffffff;
  --panel-2: #f7f8fa;
  --panel-3: #f0f2f5;
  --ink: #111b21;
  --ink-2: #3b4a54;
  --muted: #667781;
  --line: #e9edef;
  --line-2: #d1d7db;
  /* WhatsApp green */
  --brand: #00a884;
  --brand-600: #017561;
  --brand-700: #008069;
  --brand-soft: #d9fdd3;
  --brand-ink: #005c4b;
  --wa-teal: #008069;
  /* chat */
  --wall: #efeae2;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --tick-read: #53bdeb;
  --unread: #25d069;
  --yellow: #ffeecd;
  /* status */
  --danger: #ea0038;
  --danger-soft: #ffe6ea;
  --amber: #b7791f;
  --amber-soft: #fff3cd;
  --blue: #027eb5;
  --blue-soft: #e3f2fb;

  --radius: 10px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  --shadow-md: 0 4px 16px rgba(11, 20, 26, 0.16);
  --sidebar-w: 264px;
  --chat-list-w: 400px;
  --detail-w: 380px;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

h1, h2, h3, h4, p, dl, dd, dt, ul, ol {
  margin: 0;
}

h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 15px; font-weight: 600; }
h4 { font-size: 13px; font-weight: 600; }

a { color: var(--brand-700); }
code, .mono { font-family: "Cascadia Mono", Consolas, "SF Mono", monospace; font-size: 12px; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

[hidden] { display: none !important; }

.i { flex: none; display: inline-block; vertical-align: -3px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.pad { padding: 16px; }
.pad-sm { padding: 8px; }
.error-text { color: var(--danger); font-size: 12px; }
.right { text-align: right; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-code {
  background: var(--panel-3);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
}

/* ------------------------------------------------------------------ shell */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--bg);
}

.view {
  flex: 1;
  overflow-y: auto;
  padding: 0 22px 26px;
  scrollbar-width: thin;
}

.view.is-chat { display: flex; flex-direction: column; }

/* di tampilan chat, seluruh area dipakai seperti WhatsApp Web */
body.view-chat .topbar { display: none; }
body.view-chat .view { padding: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px 12px;
  flex: none;
}

.topbar-title h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.topbar-title p {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}
.topbar-actions.row { flex: 1 1 100%; order: 5; }

/* ---------------------------------------------------------------- sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  background: #111b21;
  color: #aebac1;
  padding: 14px 12px;
  gap: 14px;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 6px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #25d366, #00a884);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 15px; color: #e9edef; font-weight: 600; }
.brand-text span { font-size: 10.5px; color: #8696a0; }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 8px;
  color: #aebac1;
  font-size: 13.5px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: #202c33; color: #e9edef; }
.nav-item.active { background: #2a3942; color: #e9edef; }
.nav-item.active .i { color: #00a884; }

.accounts {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 12px;
  min-height: 0;
}

.accounts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #8696a0;
  padding: 0 6px;
}

.accounts-count {
  background: #2a3942;
  padding: 1px 7px;
  border-radius: 999px;
  letter-spacing: 0;
  text-transform: none;
  font-size: 11px;
  color: #d1d7db;
}

.accounts-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 190px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.accounts-empty { font-size: 12px; color: #8696a0; padding: 6px; line-height: 1.45; }

.account {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 8px;
  text-align: left;
  transition: background 0.15s;
}

.account:hover { background: #202c33; }
.account.active { background: #2a3942; }

.account-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #06241b;
  background: linear-gradient(145deg, #7ce0ae, #35c07f);
}

.account-body { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.account-name { font-size: 12.5px; color: #e9edef; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-meta { font-size: 10.5px; color: #8696a0; display: flex; align-items: center; gap: 5px; }
.account-badge { font-size: 10.5px; color: #9fd6bb; background: rgba(0, 168, 132, 0.16); padding: 2px 6px; border-radius: 999px; }

.btn-add-account {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border-radius: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  color: #aebac1;
  font-size: 12.5px;
  transition: all 0.15s;
}

.btn-add-account:hover { background: #202c33; color: #e9edef; }

.sidebar-foot { padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.foot-note { font-size: 10.5px; color: #8696a0; line-height: 1.4; }

.conn { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: #8696a0; margin-bottom: 6px; }
.conn.online .label { color: #25d366; }
.conn.busy .label { color: #ffd279; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: #8696a0; display: inline-block; flex: none; }
.dot-connected { background: #25d366; }
.dot-connecting, .dot-busy { background: #ffd279; }
.dot-qr { background: #53bdeb; }
.dot-logged-out, .dot-disconnected { background: #f15c6d; }

/* ----------------------------------------------------------------- tombol */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-600); }
.btn-outline { background: #fff; border-color: var(--line-2); color: var(--brand-700); }
.btn-outline:hover:not(:disabled) { background: #f5f6f6; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--panel-3); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c5002f; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 7px; }
.btn.danger, .btn-icon.danger { color: var(--danger); }

.btn-icon {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--ink-2);
  transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: rgba(11, 20, 26, 0.06); color: var(--ink); }
.btn-icon.danger:hover { background: var(--danger-soft); color: var(--danger); }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 0 12px;
  height: 36px;
  color: var(--muted);
  min-width: 230px;
}
.search-box input { border: 0; outline: 0; font: inherit; font-size: 13.5px; width: 100%; background: transparent; color: var(--ink); }

/* ------------------------------------------------------------------ kartu */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 1px rgba(11, 20, 26, 0.04);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.card-head p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.kpi { display: flex; gap: 12px; padding: 15px 16px; align-items: flex-start; }
.kpi-icon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.tone-brand { background: var(--brand-soft); color: var(--brand-600); }
.tone-blue { background: var(--blue-soft); color: var(--blue); }
.tone-amber { background: var(--amber-soft); color: var(--amber); }
.tone-green { background: #dcf8c6; color: #15803d; }
.kpi-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { font-size: 25px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
.kpi-note { font-size: 11.5px; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.grid-2.align-start { align-items: start; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* -------------------------------------------------------------- dasbor */
.device-list { padding: 6px 18px 14px; display: flex; flex-direction: column; }
.device-row { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.device-row:last-child { border-bottom: 0; }
.device-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 13px;
  color: #fff;
  background: linear-gradient(145deg, #2fbd7d, #00a884);
  flex: none;
}
.device-info { flex: 1; min-width: 0; }
.device-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.device-top strong { font-size: 13.5px; font-weight: 600; }
.dot-label { font-size: 11px; padding: 1px 8px; border-radius: 999px; display: inline-flex; align-items: center; gap: 4px; }
.dot-label::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.dot-label.dot-connected { background: var(--brand-soft); color: var(--brand-600); }
.dot-label.dot-connecting, .dot-label.dot-qr { background: var(--amber-soft); color: var(--amber); }
.dot-label.dot-disconnected, .dot-label.dot-logged-out { background: var(--danger-soft); color: var(--danger); }

.progress { height: 4px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 7px; }
.progress span { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width 0.4s ease; }

.device-count { display: flex; align-items: baseline; gap: 1px; flex-direction: column; text-align: right; }
.device-count strong { font-size: 20px; line-height: 1; }
.device-count span { font-size: 12px; color: var(--muted); }
.device-count small { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.device-count.full strong { color: var(--danger); }

.chart { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; height: 160px; padding: 20px 20px 8px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; height: 100%; }
.chart-bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.bar { width: 9px; border-radius: 3px 3px 2px 2px; min-height: 3px; transition: height 0.5s ease; }
.bar-sent { background: var(--brand); }
.bar-recv { background: #cfd8d3; }
.chart-label { font-size: 11px; color: var(--muted); }
.legend { display: flex; gap: 16px; padding: 0 20px 16px; font-size: 12px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.sw { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.sw-sent { background: var(--brand); }
.sw-recv { background: #cfd8d3; }

.activity-list { list-style: none; padding: 6px 18px 14px; display: flex; flex-direction: column; }
.activity-item { display: flex; gap: 11px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.activity-item:last-child { border-bottom: 0; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--muted); }
.activity-dot.t-success { background: #25d366; }
.activity-dot.t-error { background: var(--danger); }
.activity-dot.t-message { background: var(--blue); }
.activity-dot.t-info { background: #8696a0; }
.activity-text p { font-size: 13px; }
.activity-text span { font-size: 11.5px; }

/* =====================================================  PERCAKAPAN (WA)  */
.chat-shell {
  display: grid;
  grid-template-columns: var(--chat-list-w) minmax(0, 1fr) var(--detail-w);
  flex: 1;
  min-height: 0;
  gap: 0;
  background: var(--panel);
}

.chat-list-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line-2);
}

.wa-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  min-height: 59px;
  flex: none;
}
.wa-me { display: flex; align-items: center; gap: 11px; min-width: 0; }
.wa-me .avatar { width: 40px; height: 40px; font-size: 14px; }
.wa-me-body { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.wa-me-body strong { font-size: 15px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-me-body small { font-size: 12px; color: var(--muted); }
.wa-panel-actions { display: flex; gap: 2px; flex: none; }
.wa-panel-actions .btn-icon { color: var(--ink-2); }

.wa-search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 12px 8px;
  padding: 0 12px;
  height: 35px;
  border-radius: 8px;
  background: var(--panel-3);
  color: var(--muted);
  flex: none;
}
.wa-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
}

.chat-filters {
  display: flex;
  gap: 7px;
  padding: 2px 12px 8px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: none;
}
.chat-filters::-webkit-scrollbar { display: none; }

.chip {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  color: var(--muted);
  white-space: nowrap;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.chip:hover { background: #f5f6f6; }
.chip.active { background: var(--brand-soft); border-color: var(--brand-soft); color: #0b3d2c; }

.chat-list { flex: 1; overflow-y: auto; scrollbar-width: thin; background: var(--panel); }

.chat-item {
  display: flex;
  gap: 13px;
  width: 100%;
  padding: 10px 16px 10px 13px;
  text-align: left;
  transition: background 0.12s;
  position: relative;
  align-items: center;
}
.chat-item:hover { background: #f5f6f6; }
.chat-item.active { background: var(--panel-3); }
.chat-item.archived { opacity: 0.6; }
.chat-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.chat-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chat-name { font-size: 16px; font-weight: 400; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { font-size: 12px; color: var(--muted); flex: none; }
.chat-item.unread .chat-time { color: var(--unread); }
.chat-item-bottom { display: flex; align-items: center; gap: 6px; }
.chat-preview {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-item.unread .chat-preview { color: var(--ink-2); }
.chat-preview em { font-style: normal; color: var(--muted); }
.tick-mini { color: #8696a0; display: inline-flex; }
.tick-mini.read { color: var(--tick-read); }
.chat-badges { display: flex; align-items: center; gap: 5px; color: var(--muted); }
.badge-unread {
  min-width: 21px;
  height: 21px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--unread);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: grid;
  place-items: center;
}
.chat-labels { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.label-chip {
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--lc) 14%, #fff);
  color: var(--lc);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.label-chip button { display: inline-flex; color: inherit; opacity: 0.7; }
.label-chip button:hover { opacity: 1; }

/* avatar bulat seperti WhatsApp */
.avatar {
  width: 49px;
  height: 49px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 500;
  color: #fff;
  background: #aebac1;
  flex: none;
  position: relative;
  overflow: hidden;
  text-transform: uppercase;
  user-select: none;
}
.avatar > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.lg { width: 60px; height: 60px; font-size: 20px; }
.avatar.xl { width: 110px; height: 110px; font-size: 36px; }
.avatar.me { width: 40px; height: 40px; font-size: 14px; }
.avatar-badge {
  position: absolute;
  right: 0;
  bottom: 0;
  background: #fff;
  border-radius: 50%;
  padding: 2px;
  color: #54656f;
  display: none;
}

/* thread */
.thread { display: flex; flex-direction: column; min-height: 0; background: var(--panel); }

.thread-empty, .thread-loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  text-align: center;
  padding: 32px;
  background: var(--panel-2);
  border-bottom: 6px solid var(--brand);
}
.thread-empty .i { color: #c5cdd1; }
.thread-empty h3 { color: var(--ink-2); font-size: 30px; font-weight: 300; }
.thread-empty p { max-width: 440px; font-size: 13.5px; }
.encrypt-hint { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: #8696a0; margin-top: 6px; }
.thread-loading { flex-direction: row; gap: 10px; }
.thread-loading .i { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.thread-head {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 8px 16px;
  min-height: 59px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 2;
  flex: none;
}
.thread-head .avatar { width: 40px; height: 40px; font-size: 14px; }
.thread-head-body { flex: 1; min-width: 0; }
.thread-name-row { display: flex; align-items: center; gap: 7px; }
.thread-name { font-size: 16px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-presence { font-size: 13px; color: var(--muted); }
.thread-presence.typing { color: var(--brand-600); }
.thread-head-actions { display: flex; gap: 2px; flex: none; }
.thread-head-actions .btn-icon { color: var(--ink-2); }

.tag-soft {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 4px;
  background: var(--panel-3);
  color: var(--ink-2);
  white-space: nowrap;
}
.tag-idle { background: var(--panel-3); color: var(--ink-2); }
.tag-running { background: var(--blue-soft); color: var(--blue); }
.tag-done, .tag-sent { background: var(--brand-soft); color: var(--brand-600); }
.tag-cancelled { background: var(--panel-3); color: var(--muted); }
.tag-pending { background: var(--amber-soft); color: var(--amber); }
.tag-failed { background: var(--danger-soft); color: var(--danger); }

/* --------------------------------------------------- wallpaper & pesan */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 6.5% 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background-color: var(--wall);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='260' height='260' viewBox='0 0 260 260' fill='none' stroke='%23cfc7ba' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round' opacity='0.55'><path d='M28 34c-5-6-15-4-15 4 0 6 9 11 15 17 6-6 15-11 15-17 0-8-10-10-15-4Z'/><path d='M150 24h34a7 7 0 0 1 7 7v18a7 7 0 0 1-7 7h-19l-9 8v-8h-6a7 7 0 0 1-7-7V31a7 7 0 0 1 7-7Z'/><path d='M60 96h26l6-8h14l6 8h10v22H60V96Z'/><circle cx='86' cy='108' r='7'/><path d='M186 84v26'/><path d='M186 84c6-5 12-2 12 2s-6 6-12 2Z'/><path d='M30 168l5 14 14 5-14 5-5 14-5-14-14-5 14-5 5-14Z'/><path d='M150 150h20v20h-20zM156 156h8v8h-8z'/><path d='M222 150a10 10 0 1 0 0 20 10 10 0 0 0 0-20Z'/><path d='M216 162l4 4 8-8'/><path d='M70 216c0 10 8 18 18 18s18-8 18-18H70Z'/><path d='M88 216v-14'/><path d='M196 210c-8 0-12 5-12 12h24c0-7-4-12-12-12Z'/><path d='M180 214l-6 6M212 214l6 6'/></svg>");
  background-attachment: local;
  scrollbar-width: thin;
}

.encrypt-notice {
  align-self: center;
  max-width: 78%;
  background: var(--yellow);
  color: #54656f;
  font-size: 12.5px;
  line-height: 1.45;
  padding: 6px 12px;
  border-radius: 8px;
  text-align: center;
  margin: 4px 0 10px;
  display: flex;
  gap: 6px;
  align-items: flex-start;
}
.encrypt-lock { color: #8696a0; display: inline-flex; margin-top: 1px; }

.day-sep { display: flex; justify-content: center; margin: 10px 0 8px; }
.day-sep span {
  font-size: 12.5px;
  color: #54656f;
  background: #fff;
  padding: 5px 12px;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  text-transform: capitalize;
}

.system-msg {
  align-self: center;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: #54656f;
  background: #fff;
  padding: 5px 12px;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  margin: 4px 0;
  max-width: 85%;
  text-align: center;
}
.system-msg .i { color: #8696a0; }

.msg { display: flex; flex-direction: column; max-width: 65%; position: relative; }
.msg.in { align-self: flex-start; align-items: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.msg.grouped { margin-top: 1px; }
.msg:not(.grouped) { margin-top: 8px; }

.bubble {
  position: relative;
  padding: 6px 8px 7px 9px;
  border-radius: 8px;
  font-size: 14.2px;
  line-height: 19px;
  color: var(--ink);
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  word-wrap: break-word;
  max-width: 100%;
}
.msg.in .bubble { background: var(--bubble-in); }
.msg.out .bubble { background: var(--bubble-out); }

/* ekor gelembung: hanya pada gelembung pertama dalam satu kelompok */
.msg:not(.grouped).in .bubble { border-top-left-radius: 0; }
.msg:not(.grouped).out .bubble { border-top-right-radius: 0; }
.msg:not(.grouped).in .bubble::before {
  content: "";
  position: absolute;
  top: 0;
  left: -8px;
  width: 8px;
  height: 12px;
  background: var(--bubble-in);
  clip-path: polygon(100% 0, 0 0, 100% 100%);
}
.msg:not(.grouped).out .bubble::before {
  content: "";
  position: absolute;
  top: 0;
  right: -8px;
  width: 8px;
  height: 12px;
  background: var(--bubble-out);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

.bubble-body { position: relative; }
.bubble-text { white-space: pre-wrap; }
.bubble-body a { color: #027eb5; text-decoration: underline; word-break: break-word; }

/* ruang untuk waktu + centang di akhir baris terakhir, persis WhatsApp */
.meta-pad { display: inline-block; width: 66px; height: 1px; }

.bubble-meta {
  position: absolute;
  right: 8px;
  bottom: 4px;
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: #667781;
  line-height: 1;
  pointer-events: none;
}
.bubble-meta .msg-more { pointer-events: auto; }
.msg-time { font-size: 11px; }
.ticks { display: inline-flex; color: #8696a0; margin-left: 1px; }
.ticks.read { color: var(--tick-read); }
.starred { display: inline-flex; color: #f0b429; }

/* pesan dengan media: waktu menimpa pojok gambar */
.msg.has-media .bubble { padding: 4px 4px 6px; }
.msg.has-media .media { margin-bottom: 0; }
.msg.has-media .bubble-meta {
  right: 10px;
  bottom: 9px;
  color: #fff;
  background: linear-gradient(to right, rgba(11, 20, 26, 0), rgba(11, 20, 26, 0.45));
  padding: 3px 6px 3px 10px;
  border-radius: 6px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.msg.has-media .ticks { color: #fff; }
.msg.has-media .ticks.read { color: #a7e3ff; }

/* pesan berbentuk kartu (polling, lokasi, kontak, produk): waktu di bawah kartu */
.msg.card-msg .bubble-meta {
  position: static;
  justify-content: flex-end;
  margin-top: 2px;
  padding-right: 1px;
  pointer-events: auto;
}

.msg.is-sticker .bubble { background: transparent !important; box-shadow: none; padding: 0; }
.msg.is-sticker .bubble::before { display: none; }
.msg.is-sticker .bubble-meta { background: rgba(0, 0, 0, 0.35); color: #fff; }

.msg-author { font-size: 12.5px; font-weight: 600; color: var(--sender, #00a084); margin: 0 0 2px 2px; }

.msg-actions {
  display: flex;
  gap: 1px;
  opacity: 0;
  transition: opacity 0.15s;
  margin-top: 3px;
  background: #fff;
  border-radius: 999px;
  padding: 2px;
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 3;
}
.msg:hover .msg-actions { opacity: 1; }
.msg-actions .btn-icon,
.msg-actions button { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #54656f; }
.msg-actions button:hover { background: var(--panel-3); }
.msg-actions .i { width: 14px; height: 14px; }

.msg-more { display: none; width: 22px; height: 22px; border-radius: 50%; color: inherit; place-items: center; }

.quoted {
  border-left: 4px solid var(--tick-read);
  background: rgba(11, 20, 26, 0.05);
  border-radius: 5px;
  padding: 5px 8px;
  margin-bottom: 4px;
  font-size: 13px;
  color: #54656f;
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg.out .quoted { background: rgba(11, 20, 26, 0.07); border-left-color: #06cf9c; }

.reactions {
  display: inline-flex;
  gap: 2px;
  align-items: center;
  background: #fff;
  border-radius: 999px;
  padding: 1px 5px;
  box-shadow: var(--shadow-sm);
  margin-top: 3px;
  margin-bottom: -2px;
  font-size: 12.5px;
  align-self: flex-start;
}
.msg.out .reactions { align-self: flex-end; }
.reaction { line-height: 1.4; }

.media { margin-bottom: 4px; border-radius: 6px; overflow: hidden; }
.media img, .media video { display: block; max-width: 330px; max-height: 320px; border-radius: 6px; }
.media.sticker img { max-width: 148px; max-height: 148px; background: transparent; }
.media.audio audio { width: 250px; height: 40px; }

.file-card, .loc-card, .contact-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  padding: 8px;
  border-radius: 6px;
  background: rgba(11, 20, 26, 0.05);
  text-decoration: none;
  color: var(--ink);
  margin-bottom: 4px;
}
.file-icon, .loc-pin {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: #fff;
  flex: none;
}
.file-meta, .loc-info { display: flex; flex-direction: column; min-width: 0; }
.file-meta strong, .loc-info strong { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta small, .loc-info small { font-size: 11px; color: var(--muted); }
.file-dl { margin-left: auto; color: var(--muted); }

.contact-card .contact-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-600);
  font-size: 12px;
  font-weight: 600;
}
.contact-card .contact-info { display: flex; flex-direction: column; min-width: 0; }
.contact-card .contact-info small { color: var(--muted); font-size: 11px; }

.poll-card { background: rgba(11, 20, 26, 0.05); border-radius: 8px; padding: 9px 11px; margin-bottom: 4px; min-width: 210px; }
.poll-card ul { list-style: none; margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.poll-card li { background: #fff; border-radius: 6px; padding: 4px 9px; font-size: 13px; }

.product-msg { display: flex; flex-direction: column; gap: 3px; }
.product-tag { display: flex; align-items: center; gap: 4px; font-size: 10.5px; color: var(--brand-600); text-transform: uppercase; letter-spacing: 0.05em; }
.product-price { font-size: 13px; color: var(--brand-600); font-weight: 600; }

.order-msg { display: flex; flex-direction: column; gap: 4px; min-width: 220px; }
.order-head { display: flex; align-items: center; gap: 6px; color: var(--brand-600); }
.order-sub { font-size: 12px; color: var(--muted); }

.deleted { display: inline-flex; align-items: center; gap: 5px; font-style: italic; color: var(--muted); font-size: 13px; }
.no-messages { text-align: center; color: #8696a0; font-size: 13px; background: #fff; padding: 6px 12px; border-radius: 8px; align-self: center; box-shadow: var(--shadow-sm); }

/* -------------------------------------------------------------- komposer */
.composer {
  position: relative;
  padding: 6px 16px 10px;
  background: var(--panel-3);
  flex: none;
}
.composer-row { display: flex; align-items: center; gap: 4px; }
.composer .btn-icon { color: var(--ink-2); width: 38px; height: 38px; }

.composer-field {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  background: #fff;
  border-radius: 8px;
  padding: 3px 4px 3px 12px;
  min-width: 0;
}
.composer-field textarea {
  flex: 1;
  border: 0;
  outline: 0;
  resize: none;
  font: inherit;
  font-size: 15px;
  line-height: 20px;
  padding: 8px 0;
  max-height: 130px;
  background: transparent;
  color: var(--ink);
}
.composer-field .btn-icon { width: 30px; height: 30px; color: #8696a0; }

.btn-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: #fff;
  flex: none;
  transition: background 0.15s;
}
.btn-send:hover:not(:disabled) { background: var(--brand-600); }
.btn-send:disabled { opacity: 0.5; }

.attach-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  background: #fff;
  border-radius: 8px;
  padding: 7px 9px;
  margin-bottom: 6px;
}
.attach-file { color: var(--brand-600); display: grid; place-items: center; }
.attach-info { display: flex; flex-direction: column; min-width: 0; max-width: 170px; }
.attach-info strong { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-info span { font-size: 10.5px; }
.attach-bar input {
  flex: 1;
  border: 0;
  outline: 0;
  border-radius: 6px;
  padding: 6px 9px;
  font: inherit;
  font-size: 13.5px;
  background: var(--panel-3);
  min-width: 0;
}

.reply-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-left: 4px solid var(--tick-read);
  border-radius: 8px;
  padding: 6px 8px 6px 10px;
  margin-bottom: 6px;
}
.reply-quote { flex: 1; min-width: 0; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.rec-bar { display: flex; align-items: center; gap: 10px; padding: 6px 4px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: recPulse 1s infinite; flex: none; }
@keyframes recPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.rec-time { font-family: "Cascadia Mono", Consolas, monospace; font-size: 13px; color: var(--danger); min-width: 42px; }
.rec-hint { flex: 1; font-size: 13px; color: var(--muted); }

.popover {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 12px;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  padding: 8px;
  z-index: 20;
  width: 250px;
  max-height: 250px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
}
.popover-wide { width: 320px; display: block; padding: 6px; }
.popover-attach { left: 8px; width: 208px; display: flex; flex-direction: column; gap: 1px; }
.emoji-btn { font-size: 19px; padding: 5px; border-radius: 6px; }
.emoji-btn:hover { background: var(--panel-3); }
.popover-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 6px 9px; }

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  text-align: left;
  color: var(--ink);
}
.menu-item:hover { background: var(--panel-3); }
.menu-item .mono { color: var(--brand-600); font-size: 12px; flex: none; }
.menu-item.danger { color: var(--danger); }
.menu-pop {
  position: absolute;
  top: calc(100% - 4px);
  right: 8px;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 30;
  min-width: 218px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.thread-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  flex: none;
}
.thread-search input {
  flex: 1;
  border: 0;
  border-radius: 6px;
  padding: 6px 10px;
  font: inherit;
  font-size: 14px;
  outline: 0;
  min-width: 0;
  background: #fff;
}
.search-count { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

/* --------------------------------------------------------- panel detail */
.detail-panel {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--panel);
  border-left: 1px solid var(--line-2);
  scrollbar-width: thin;
}
.detail-head {
  padding: 26px 16px 20px;
  border-bottom: 1px solid var(--line);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  position: relative;
}
.detail-head h3 { font-size: 21px; font-weight: 400; margin-top: 6px; }
.detail-head p { font-size: 14px; }
.detail-section { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.detail-section h4 {
  margin-bottom: 9px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
.detail-actions { display: flex; flex-direction: column; gap: 2px; align-items: stretch; }
.detail-actions .btn { justify-content: flex-start; color: var(--ink); padding: 9px 8px; border-radius: 6px; }
.detail-actions .btn:hover { background: var(--panel-3); }
.label-row { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.label-add { position: relative; }
.info-list { display: flex; flex-direction: column; gap: 8px; }
.info-list div { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.info-list dt { color: var(--muted); flex: none; }
.info-list dd { text-align: right; word-break: break-all; overflow-wrap: anywhere; min-width: 0; margin: 0; }
.mini-products { display: flex; flex-direction: column; gap: 5px; }
.mini-product { display: flex; align-items: center; gap: 9px; padding: 6px; border-radius: 8px; text-align: left; }
.mini-product:hover { background: var(--panel-3); }
.mini-product img { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; }
.mini-ph { width: 36px; height: 36px; border-radius: 6px; background: var(--panel-3); color: var(--muted); display: grid; place-items: center; }
.mini-product span:last-child { display: flex; flex-direction: column; min-width: 0; }
.mini-product strong { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-product small { font-size: 11.5px; color: var(--brand-600); }

/* ---------------------------------------------------------------- tabel */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.table td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfb; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.cell-person { display: flex; align-items: center; gap: 10px; }
.cell-text { max-width: 340px; color: var(--ink-2); }
.shortcut { background: var(--brand-soft); color: var(--brand-600); padding: 2px 7px; border-radius: 4px; }

.list-empty, .list-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 20px;
  color: var(--muted);
  text-align: center;
  font-size: 13.5px;
}
.list-empty .i { color: #c5cdd1; }
.table-loading { padding: 30px; text-align: center; color: var(--muted); }

/* ----------------------------------------------------------------- grup */
.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; padding: 16px; }
.group-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 9px; }
.group-head { display: flex; gap: 10px; align-items: center; }
.group-head h3 { font-size: 14.5px; }
.group-head p { font-size: 12.5px; }
.group-desc { font-size: 13px; color: var(--ink-2); min-height: 36px; }
.group-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.group-detail { display: flex; flex-direction: column; gap: 14px; }
.group-meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.group-meta-grid > div { background: var(--panel-3); padding: 10px 12px; border-radius: 8px; }
.group-meta-grid p { font-size: 13px; margin-top: 2px; }
.group-toolbar { display: flex; gap: 6px; flex-wrap: wrap; }
.section-title { margin-top: 2px; }
.member-list { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.member-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.member-info strong { font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 4px; }
.add-member { display: flex; gap: 8px; }
.add-member select { flex: 1; }

/* -------------------------------------------------------------- katalog */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(228px, 1fr)); gap: 14px; padding: 16px; }
.product-card { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.product-img { position: relative; aspect-ratio: 4/3; background: var(--panel-3); display: grid; place-items: center; }
.product-img img { width: 100%; height: 100%; object-fit: cover; }
.img-ph { color: #b0bcc1; }
.img-flag {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 10px;
  background: rgba(11, 20, 26, 0.72);
  color: #fff;
  padding: 2px 8px;
  border-radius: 999px;
}
.product-body { padding: 11px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.product-body h3 { font-size: 14px; font-weight: 500; }
.product-body p { font-size: 12.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-price-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: auto; }
.product-price-row strong { color: var(--brand-600); font-size: 14px; }
.sku { background: var(--panel-3); padding: 1px 6px; border-radius: 4px; color: var(--muted); font-size: 10.5px; }
.product-actions { display: flex; gap: 5px; align-items: center; padding: 0 12px 12px; }
.product-actions .btn-primary { flex: 1; justify-content: center; }

.head-tabs { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.collection-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; padding: 16px; }
.collection-card { border: 1px solid var(--line); border-radius: 10px; padding: 13px; display: flex; flex-direction: column; gap: 10px; }
.collection-head { display: flex; gap: 10px; align-items: center; }
.collection-head h3 { font-size: 14.5px; }
.collection-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-600);
  flex: none;
}
.collection-products { display: flex; flex-direction: column; gap: 4px; }
.collection-product { display: flex; align-items: center; gap: 9px; padding: 5px; border-radius: 6px; }
.collection-product:hover { background: var(--panel-3); }
.collection-product img { width: 32px; height: 32px; border-radius: 5px; object-fit: cover; }
.collection-product .mini-ph { width: 32px; height: 32px; }
.collection-product span:last-child { display: flex; flex-direction: column; min-width: 0; }
.collection-product strong { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.collection-product small { font-size: 11px; color: var(--brand-600); }

/* -------------------------------------------------------------- otomasi */
.rule-list, .job-list { display: flex; flex-direction: column; }
.rule-item, .job-item { display: flex; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.rule-item:last-child, .job-item:last-child { border-bottom: 0; }
.rule-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.rule-top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.rule-keywords { font-size: 12.5px; color: var(--muted); }
.rule-response { font-size: 13px; color: var(--ink-2); background: var(--panel-3); padding: 7px 9px; border-radius: 6px; }

.switch { position: relative; width: 38px; height: 22px; flex: none; margin-top: 2px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #c5cdd1; border-radius: 999px; transition: 0.18s; cursor: pointer; }
.slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.18s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::before { transform: translateX(16px); }

.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line-2); padding: 3px; border-radius: 999px; gap: 2px; }
.seg-btn { padding: 6px 12px; border-radius: 999px; font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--brand-soft); color: var(--brand-600); font-weight: 600; }

.form { display: flex; flex-direction: column; gap: 13px; padding: 16px 18px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.field input, .field select, .field textarea, .add-member select {
  font: inherit;
  font-size: 13.5px;
  padding: 9px 11px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  outline: 0;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus, .add-member select:focus { border-color: var(--brand); }
.field textarea { resize: vertical; min-height: 74px; }
.field-sm { max-width: 210px; }
.field.checkbox { flex-direction: row; align-items: center; gap: 8px; }
.field.checkbox input { width: 16px; height: 16px; accent-color: var(--brand); }
.multi-select { min-height: 130px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-full { grid-column: 1 / -1; }

.job-item { flex-direction: column; gap: 8px; }
.job-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.job-text { font-size: 13px; color: var(--ink-2); background: var(--panel-3); padding: 7px 9px; border-radius: 6px; }

.poll-options { display: flex; flex-direction: column; gap: 8px; }
.poll-opt-row { display: flex; gap: 6px; align-items: center; }
.poll-opt-row input {
  flex: 1;
  font: inherit;
  font-size: 13.5px;
  padding: 9px 11px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  outline: 0;
}
.poll-opt-row input:focus { border-color: var(--brand); }

/* ------------------------------------------------------------ pengaturan */
.profile-head { display: flex; gap: 14px; align-items: center; }
.file-btn { cursor: pointer; }
.biz-box { margin: 0 18px 16px; padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.biz-box h3 { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-bottom: 9px; color: var(--brand-600); }
.device-hero { display: flex; gap: 16px; align-items: center; padding: 16px 18px; }
.device-ring {
  --pct: 0%;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: conic-gradient(var(--brand) var(--pct), var(--line) 0);
  display: grid;
  place-items: center;
  flex: none;
  position: relative;
}
.device-ring::before { content: ""; position: absolute; inset: 7px; background: var(--panel); border-radius: 50%; }
.device-ring strong { font-size: 19px; position: relative; z-index: 1; line-height: 1; }
.device-ring span { position: relative; z-index: 1; font-size: 11px; color: var(--muted); }
.device-tree { list-style: none; padding: 0 18px 16px; display: flex; flex-direction: column; gap: 8px; }
.device-tree li { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.device-tree li div { display: flex; flex-direction: column; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.danger-zone:last-child { border-bottom: 0; }
.danger-zone strong { font-size: 13.5px; }

.wame-box { display: flex; gap: 16px; padding: 16px 18px; align-items: center; flex-wrap: wrap; }
.wame-box img { width: 148px; height: 148px; border-radius: 10px; border: 1px solid var(--line); }
.wame-actions { display: flex; flex-direction: column; gap: 9px; min-width: 200px; flex: 1; }
.wame-link { font-size: 13px; background: var(--panel-3); padding: 8px 10px; border-radius: 6px; word-break: break-all; }

/* ---------------------------------------------------------------- modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 20, 26, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  z-index: 60;
  opacity: 0;
  transition: opacity 0.18s;
}
.modal-backdrop.show { opacity: 1; }
.modal {
  background: #fff;
  border-radius: 10px;
  width: min(520px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(11, 20, 26, 0.3);
  transform: translateY(8px) scale(0.99);
  transition: transform 0.18s;
}
.modal-backdrop.show .modal { transform: none; }
.modal.wide { width: min(720px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
}
.confirm-text { font-size: 14px; color: var(--ink-2); }

.link-steps { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.steps { list-style: none; display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--ink-2); width: 100%; padding: 0; }
.steps li { display: flex; align-items: center; gap: 9px; }
.steps span {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-600);
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex: none;
}
.qr-box {
  width: 248px;
  height: 248px;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 10px;
  display: grid;
  place-items: center;
  background: #fff;
}
.qr-box img { width: 100%; height: 100%; border-radius: 6px; }
.qr-wait { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.qr-wait .i { animation: spin 1.2s linear infinite; color: var(--brand); }
.divider { display: flex; align-items: center; gap: 10px; width: 100%; color: var(--muted); font-size: 11.5px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.pairing-row { display: flex; gap: 8px; width: 100%; }
.pairing-row input {
  flex: 1;
  font: inherit;
  font-size: 14px;
  padding: 9px 12px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  outline: 0;
}
.pairing-row input:focus { border-color: var(--brand); }
.pairing-code { font-size: 13.5px; text-align: center; line-height: 1.6; }
.pairing-code strong { font-size: 19px; letter-spacing: 0.12em; color: var(--brand-600); }
.callout {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  background: var(--brand-soft);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: #0b3d2c;
  width: 100%;
}
.callout .i { margin-top: 1px; flex: none; }
.link-success { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 12px 0; }
.success-ring { width: 76px; height: 76px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-600); display: grid; place-items: center; }
.file-drop { position: relative; }
.file-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-drop span {
  display: flex;
  align-items: center;
  gap: 7px;
  justify-content: center;
  border: 1px dashed var(--line-2);
  border-radius: 8px;
  padding: 14px;
  font-size: 13px;
}
.picker-search {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 0 10px;
  height: 36px;
  color: var(--muted);
  margin-bottom: 10px;
}
.picker-search input { border: 0; outline: 0; font: inherit; font-size: 14px; flex: 1; }
.picker-list { display: flex; flex-direction: column; gap: 2px; max-height: 330px; overflow-y: auto; }
.picker-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; text-align: left; }
.picker-item:hover { background: var(--panel-3); }
.picker-item span:last-child { display: flex; flex-direction: column; min-width: 0; }
.picker-item strong { font-size: 13.5px; font-weight: 500; }
.picker-item small { font-size: 11.5px; }

.sheet-handle { display: none; }
.sheet-actions { display: flex; flex-direction: column; gap: 3px; }
.sheet-action { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 12px; border-radius: 8px; font-size: 14px; text-align: left; }
.sheet-action:hover { background: var(--panel-3); }
.delete-options { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.delete-opt {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
  text-align: left;
  padding: 11px 13px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  transition: all 0.15s;
}
.delete-opt:hover { border-color: var(--brand); background: var(--panel-2); }
.delete-opt strong { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 500; }
.delete-opt span { font-size: 12px; color: var(--muted); }

.order-detail { display: flex; flex-direction: column; gap: 12px; }
.order-products { display: flex; flex-direction: column; gap: 8px; }
.order-product { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.order-product img { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; }
.order-product .mini-ph { width: 44px; height: 44px; }
.order-product div { display: flex; flex-direction: column; min-width: 0; }
.order-product strong { font-size: 13px; font-weight: 500; }
.order-product small { font-size: 11.5px; color: var(--muted); }

/* ---------------------------------------------------------------- toast */
.toast-root { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #202c33;
  color: #e9edef;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  transform: translateY(12px);
  opacity: 0;
  transition: all 0.22s;
  max-width: 340px;
}
.toast.show { transform: none; opacity: 1; }
.toast-success .i { color: #4be08f; }
.toast-error .i { color: #ff8298; }
.toast-info .i { color: #8fd2ff; }

/* ---------------------------------------------------------------- kosong */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  padding: 48px 24px;
  margin: 12px auto;
  max-width: 560px;
}
.empty-illustration { width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-600); }
.empty-state h2 { font-size: 18px; }
.empty-state p { font-size: 13.5px; color: var(--ink-2); }
.empty-state .muted { color: var(--muted); font-size: 13px; }

.skeleton-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.skeleton { height: 92px; border-radius: var(--radius); background: linear-gradient(90deg, #eef1f3 25%, #f7f9fa 37%, #eef1f3 63%); background-size: 400% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.chat-skeleton { height: 72px; background: #fafbfb; }

.conn-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  background: var(--yellow);
  color: #7a5b16;
  font-size: 12.5px;
  flex-wrap: wrap;
  flex: none;
}
.conn-banner .i { flex: none; }
.conn-banner span { flex: 1; min-width: 140px; }
.conn-banner .btn { margin-left: auto; }

.mobile-only { display: none; }
.bottom-nav { display: none; }
.drawer-backdrop { display: none; }

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: none; }
}

/* ------------------------------------------------------------ responsif */
@media (max-width: 1400px) {
  :root { --chat-list-w: 360px; --detail-w: 320px; }
}

@media (max-width: 1320px) {
  .chat-shell { grid-template-columns: var(--chat-list-w) minmax(0, 1fr); }
  .detail-panel { display: none !important; }
  .grid-2 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* -------------------------------------------------------------- ponsel */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }

  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 86vw);
    z-index: 75;
    transform: translateX(-104%);
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.4);
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .sidebar.open { transform: none; }

  .drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(11, 20, 26, 0.5);
    z-index: 70;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }
  .drawer-backdrop.show { opacity: 1; pointer-events: auto; }

  .main { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }

  .topbar { padding: 10px 12px; gap: 6px; align-items: center; flex-wrap: wrap; }
  .topbar-title { flex: 1 1 auto; min-width: 0; }
  .topbar-title h1 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-title p { display: none; }
  .topbar-actions { gap: 4px; }
  .topbar-actions .btn-text { display: none; }
  .topbar-actions .search-box { order: 5; flex: 1 1 100%; min-width: 0; }
  .btn-icon { width: 38px; height: 38px; }

  .view { padding: 0 10px 10px; -webkit-overflow-scrolling: touch; }
  body.view-chat .view { padding: 0; }
  .mobile-only { display: inline-grid; }

  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(56px + env(safe-area-inset-bottom));
    padding: 3px 6px env(safe-area-inset-bottom);
    background: #fff;
    border-top: 1px solid var(--line);
    z-index: 55;
  }
  .bn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 10.5px;
    color: var(--muted);
    border-radius: 8px;
  }
  .bn-item span { font-weight: 500; }
  .bn-item.active { color: var(--brand-600); }

  /* percakapan: dua panel penuh */
  .chat-shell { grid-template-columns: 1fr; gap: 0; }
  .chat-list-panel { display: flex; border-right: 0; }
  .thread { display: none; }
  .chat-shell.mobile-thread .chat-list-panel { display: none; }
  .chat-shell.mobile-thread .thread { display: flex; }

  .detail-panel.sheet-open {
    display: flex !important;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 86dvh;
    z-index: 72;
    border-left: 0;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -16px 40px rgba(11, 20, 26, 0.28);
    animation: sheetUp 0.26s cubic-bezier(0.32, 0.72, 0, 1);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .detail-close { position: absolute; right: 8px; top: 8px; }
  .detail-head { padding-top: 22px; }
  .avatar.xl { width: 92px; height: 92px; font-size: 30px; }

  .messages { padding: 10px 4% 8px; }
  .msg { max-width: 86%; }
  .bubble { font-size: 15px; line-height: 20px; }
  .meta-pad { width: 62px; }
  .media img, .media video { max-width: 260px; max-height: 300px; }
  .msg-actions { display: none; }
  .msg-more { display: grid; opacity: 0.7; }
  .msg.has-media .bubble-meta { bottom: 10px; }

  .thread-head { padding: 6px 10px; gap: 9px; min-height: 54px; }
  .thread-name { font-size: 15.5px; }
  .thread-head-actions .btn-icon { width: 36px; height: 36px; }

  .composer { padding: 5px 8px calc(6px + env(safe-area-inset-bottom)); }
  .composer-row { gap: 2px; }
  .composer .btn-icon { width: 34px; height: 34px; }
  .composer-field { padding: 2px 2px 2px 10px; }
  .composer-field textarea { font-size: 16px; }
  .composer-field .btn-icon { display: none; }
  .btn-send { width: 40px; height: 40px; }
  .attach-bar { flex-wrap: wrap; }
  .attach-bar input { flex: 1 1 100%; order: 5; font-size: 16px; }
  .popover { left: 6px; right: 6px; width: auto; }
  .popover-wide { width: auto; }
  .popover-attach { width: auto; left: 6px; right: 6px; }

  .wa-panel-head { min-height: 56px; padding: 8px 12px; }
  .wa-search { margin: 0 10px 6px; }
  .chat-item { padding: 9px 12px; }
  .chat-name { font-size: 16px; }

  /* tabel jadi kartu */
  .table thead { display: none; }
  .table, .table tbody { display: block; width: 100%; }
  .table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .table td { display: block; padding: 0; border: 0; font-size: 13.5px; }
  .table td::before {
    content: attr(data-label);
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 2px;
  }
  .table td:first-child, .table td:last-child { grid-column: 1 / -1; }
  .table td.right { text-align: left; }
  .row-actions { justify-content: flex-start; flex-wrap: wrap; gap: 4px; }

  .product-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 10px; }
  .collection-grid { grid-template-columns: 1fr; padding: 10px; }
  .group-grid { grid-template-columns: 1fr; gap: 10px; padding: 10px; }

  .seg { width: 100%; overflow-x: auto; scrollbar-width: none; border-radius: 8px; }
  .seg::-webkit-scrollbar { display: none; }
  .seg-btn { flex: 1 0 auto; justify-content: center; padding: 8px 8px; }
  .rule-item, .job-item { padding: 12px 14px; }
  .form { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; gap: 11px; }
  .field-sm { max-width: none; }
  .multi-select { min-height: 110px; }

  /* modal jadi bottom sheet */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal {
    width: 100%;
    max-height: 92dvh;
    border-radius: 12px 12px 0 0;
    transform: translateY(100%);
    transition: transform 0.26s cubic-bezier(0.32, 0.72, 0, 1);
  }
  .modal.wide { width: 100%; }
  .modal-backdrop.show .modal { transform: none; }
  .modal-head { padding: 12px 16px; }
  .modal-body { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
  .modal-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; justify-content: center; }
  .sheet-handle { display: block; width: 38px; height: 4px; border-radius: 999px; background: var(--line-2); margin: 8px auto 0; flex: none; }

  .field input, .field select, .field textarea, .add-member select,
  .search-box input, .pairing-row input, .attach-bar input { font-size: 16px; }

  .qr-box { width: 210px; height: 210px; }
  .empty-state { padding: 30px 18px; }
  .empty-state h2 { font-size: 16px; }
  .toast-root { left: 12px; right: 12px; bottom: calc(66px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; }
  .wame-box { flex-direction: column; align-items: stretch; }
  .wame-box img { margin: 0 auto; }
  .thread-empty h3 { font-size: 22px; }
}

@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 19px; }
  .product-grid { grid-template-columns: 1fr 1fr; }
  .chart-label { font-size: 10px; }
  .device-ring { width: 64px; height: 64px; }
}

/* tombol gulir ke pesan terbaru (khas WhatsApp) */
.thread { position: relative; }
.scroll-bottom {
  position: absolute;
  right: 20px;
  bottom: 78px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #fff;
  color: #54656f;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 8px rgba(11, 20, 26, 0.22);
  z-index: 6;
  transition: transform 0.15s;
}
.scroll-bottom:hover { transform: translateY(-1px); }
@media (max-width: 900px) {
  .scroll-bottom { right: 14px; bottom: 74px; }
}

/* pemberitahuan bila backend belum tersambung (mis. UI di Vercel tanpa server) */
.backend-banner {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 16px;
  background: #ffeecd;
  color: #7a5b16;
  font-size: 13px;
  border-bottom: 1px solid #f3dfae;
  flex: none;
}
.backend-banner .i { flex: none; margin-top: 2px; }
.backend-banner code { background: rgba(11, 20, 26, 0.08); padding: 1px 5px; border-radius: 4px; }
.backend-banner .muted { color: #9a7b3a; font-size: 12px; }

/* ========================================================== layar kunci PWA */
body.gated .app { display: none; }
body.gated .bottom-nav { display: none; }

.gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(20px + env(safe-area-inset-top)) 18px calc(20px + env(safe-area-inset-bottom));
  background: linear-gradient(165deg, #075e54 0%, #0b3d33 55%, #0a2b25 100%);
  overflow-y: auto;
}
.gate-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 22px;
  padding: 28px 22px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  text-align: center;
}
.gate-mark {
  width: 70px;
  height: 70px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-600);
}
.gate-card h1 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 8px;
}
.gate-sub {
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--muted);
  margin-bottom: 22px;
}
.gate-field { display: block; text-align: left; margin-bottom: 14px; }
.gate-field > span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 7px;
}
.gate-input {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-3);
  border: 2px solid var(--line-2);
  border-radius: 14px;
  padding: 4px 6px 4px 14px;
  transition: border-color .15s, background .15s;
}
.gate-input:focus-within { border-color: var(--brand); background: #fff; }
.gate-input input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 12px 0;
  color: var(--ink);
}
.gate-input input::placeholder { font-size: 15px; font-weight: 400; color: #97a7a1; letter-spacing: 0; }
.gate-eye {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  flex: none;
}
.gate-eye:hover { background: rgba(11, 20, 26, .06); color: var(--ink); }
.gate-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  text-align: left;
  background: var(--danger-soft);
  color: #9f1239;
  font-size: 13.5px;
  line-height: 1.45;
  padding: 11px 13px;
  border-radius: 12px;
  margin-bottom: 14px;
}
.gate-error .i { flex: none; margin-top: 1px; }
.gate-submit {
  width: 100%;
  height: 52px;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  display: grid;
  place-items: center;
  transition: background .15s;
  box-shadow: 0 6px 18px rgba(0, 168, 132, .3);
}
.gate-submit:hover { background: var(--brand-600); }
.gate-submit:active { transform: translateY(1px); }
.gate-note { font-size: 12px; color: #8696a0; margin-top: 14px; }

@media (max-width: 420px) {
  .gate-card { padding: 24px 18px 20px; border-radius: 20px; }
  .gate-card h1 { font-size: 20px; }
  .gate-sub { font-size: 14px; }
  .gate-input input { font-size: 17px; padding: 11px 0; }
}

/* PWA: rasa aplikasi native di HP */
@media (display-mode: standalone) {
  .topbar { padding-top: calc(10px + env(safe-area-inset-top)); }
  body.view-chat .wa-panel-head { padding-top: calc(10px + env(safe-area-inset-top)); }
  body.view-chat .thread-head { padding-top: calc(8px + env(safe-area-inset-top)); }
}
@media (max-width: 900px) {
  html { -webkit-text-size-adjust: 100%; }
  body { overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent; }
  .chat-item, .bn-item, .btn, .btn-icon, .gate-submit { touch-action: manipulation; }
  .bn-item { min-height: 46px; }
  .msg-actions button, .msg-more { min-width: 34px; min-height: 34px; }
}

/* ================================================= tampilan saat data kosong */
.hero-empty {
  position: relative;
  overflow: hidden;
  margin-bottom: 14px;
  background: linear-gradient(160deg, #f3fbf7 0%, #ffffff 45%, #ffffff 100%);
  border: 1px solid #dfeee7;
}
.hero-orb {
  position: absolute;
  top: -120px;
  right: -80px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(37, 211, 102, .35), rgba(0, 168, 132, .08) 60%, transparent 70%);
  filter: blur(6px);
  pointer-events: none;
}
.hero-content {
  position: relative;
  padding: 34px 30px 30px;
  max-width: 640px;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-700);
  background: var(--brand-soft);
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.hero-empty h2 {
  font-size: 25px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 8px;
}
.hero-sub {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--muted);
  margin-bottom: 22px;
}
.hero-steps {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
  padding: 0;
}
.hero-steps li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}
.hero-steps li > span {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex: none;
}
.hero-steps strong { display: block; font-size: 13.5px; margin-bottom: 2px; }
.hero-steps p { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.hero-cta { height: 46px; padding: 0 22px; font-size: 14.5px; border-radius: 12px; }
.hero-note { font-size: 12px; color: #8696a0; margin-top: 12px; }

.feature-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 18px;
}
.feature-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex: none;
}
.feature-card h3 { font-size: 14.5px; margin-bottom: 3px; }
.feature-card p { font-size: 13px; color: var(--muted); line-height: 1.5; }

.empty-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  padding: 26px 18px 24px;
}
.empty-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--panel-3);
  color: #8696a0;
  margin-bottom: 6px;
}
.empty-block p { font-size: 13.5px; }
.empty-block .btn { margin-top: 8px; }

@media (max-width: 900px) {
  .hero-content { padding: 22px 18px 22px; }
  .hero-empty h2 { font-size: 21px; }
  .hero-sub { font-size: 14px; margin-bottom: 18px; }
  .hero-steps { grid-template-columns: 1fr; gap: 8px; margin-bottom: 18px; }
  .hero-steps li { padding: 10px; }
  .hero-cta { width: 100%; }
  .feature-card { padding: 15px; }
}

/* ============================================ polesan tampilan ponsel (v8) */
@media (max-width: 900px) {
  /* sidebar benar-benar hilang saat tertutup (tidak menembus navigasi) */
  .sidebar {
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.26s;
  }
  .sidebar.open { visibility: visible; pointer-events: auto; }

  /* bilah atas seperti app bar */
  .topbar {
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: 8px 12px;
    min-height: 54px;
    align-items: center;
    flex-wrap: nowrap;
  }
  .topbar-title { order: 2; }
  .topbar-title h1 { font-size: 17px; font-weight: 600; }
  .topbar-actions { order: 3; flex: 0 0 auto; }
  #btnMenu { order: 1; }
  .btn-icon { width: 40px; height: 40px; }

  /* navigasi bawah */
  .main { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .bottom-nav {
    height: calc(64px + env(safe-area-inset-bottom));
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid var(--line);
    box-shadow: 0 -2px 12px rgba(11, 20, 26, 0.06);
  }
  .bn-item {
    gap: 3px;
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0;
    padding: 4px 2px;
    border-radius: 12px;
    color: #667781;
    min-height: 52px;
  }
  .bn-item .i { width: 23px; height: 23px; }
  .bn-item span { font-weight: 500; }
  .bn-item.active { background: var(--brand-soft); color: var(--brand-700); }
  .bn-item.active .i { color: var(--brand-600); }

  /* kartu sambutan lebih ringkas dan seimbang */
  .hero-empty { border-radius: 14px; }
  .hero-content { padding: 20px 16px 18px; }
  .hero-badge { font-size: 11px; padding: 4px 10px; margin-bottom: 12px; }
  .hero-empty h2 { font-size: 20px; line-height: 1.3; }
  .hero-sub { font-size: 13.5px; line-height: 1.55; margin-bottom: 16px; }
  .hero-steps { gap: 8px; margin-bottom: 16px; }
  .hero-steps li { padding: 10px 12px; gap: 9px; border-radius: 10px; }
  .hero-steps li > span { width: 22px; height: 22px; font-size: 11px; }
  .hero-steps strong { font-size: 13px; }
  .hero-steps p { font-size: 12px; }
  .hero-cta { height: 48px; border-radius: 12px; font-size: 15px; }
  .hero-note { font-size: 11.5px; margin-top: 10px; }
  .feature-card { padding: 14px; gap: 12px; }
  .feature-icon { width: 40px; height: 40px; }

  /* jarak antar kartu */
  .view { padding: 10px 12px 16px; }
  body.view-chat .view { padding: 0; }
  .grid-2 { gap: 10px; }
  .kpi-grid { gap: 10px; }
}

/* status "idle" = sesi ada tetapi belum ditautkan */
.dot-idle { background: #f59e0b; }
.dot-label.dot-idle { background: var(--amber-soft); color: #a16207; }

/* ================================================ pairing & halaman pengaturan */
.pair-code {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--brand-700);
  background: var(--brand-soft);
  border-radius: 12px;
  padding: 14px 18px;
  text-align: center;
  user-select: all;
}
.pair-note { font-size: 13.5px; color: var(--muted); text-align: center; }
.steps li > div { font-size: 13px; line-height: 1.45; }

.settings-head {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.settings-head-body { flex: 1; min-width: 0; }
.settings-head-body h2 { font-size: 18px; font-weight: 600; }
.settings-head-body p { font-size: 13px; margin-top: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}
.settings-row:last-child { border-bottom: 0; }
.settings-row strong { font-size: 13.5px; }
.settings-row p { margin-top: 2px; }
.settings-row.danger strong { color: var(--danger); }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pad-x { padding: 14px 18px; }
.empty-block.compact { padding: 18px 12px; }

@media (max-width: 900px) {
  .settings-grid { grid-template-columns: 1fr; gap: 10px; }
  .settings-head { padding: 12px 14px; margin-bottom: 10px; }
  .settings-head-body h2 { font-size: 16px; }
  .pair-code { font-size: 24px; letter-spacing: 0.14em; padding: 12px 14px; }
  .settings-row { padding: 12px 14px; }
  .pad-x { padding: 12px 14px; }
}

/* ============================== ikon hapus sambungan + pemilih label */
.account-row { display: flex; align-items: center; gap: 2px; border-radius: 8px; }
.account-row:hover { background: #202c33; }
.account-row .account { flex: 1; min-width: 0; background: transparent; }
.account-row .account:hover { background: transparent; }
.account-del {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  color: #8696a0; opacity: 0; transition: all .15s;
}
.account-row:hover .account-del { opacity: 1; }
.account-del:hover { background: rgba(234, 0, 56, .15); color: #ff8298; }

.label-picker { display: flex; flex-direction: column; gap: 4px; margin: 10px 0 12px; }
.label-opt {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); font-size: 14px;
}
.label-opt:hover { background: var(--panel-3); }
.label-opt input { width: 17px; height: 17px; accent-color: var(--brand); }
.label-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.label-new { display: flex; gap: 8px; }
.label-new input {
  flex: 1; font: inherit; font-size: 14px; padding: 9px 11px;
  border: 1px solid var(--line-2); border-radius: 9px; outline: 0; min-width: 0;
}
.label-new input:focus { border-color: var(--brand); }

/* ===================================================== pengaturan (rapi v22) */
.settings-head {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 1px rgba(11, 20, 26, .04);
}
.settings-head .avatar.lg { width: 62px; height: 62px; font-size: 20px; }
.settings-head-body { flex: 1; min-width: 0; }
.settings-head-body h2 { font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.settings-head-body p { font-size: 13px; margin-top: 3px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.settings-head .btn { flex: none; }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.settings-grid > section { align-self: start; }
.settings-grid .card { border-radius: 14px; }
.settings-grid .card-head { padding: 16px 20px 14px; align-items: center; }
.settings-grid .card-head h2 { font-size: 15px; font-weight: 600; }
.settings-grid .card-head p { font-size: 12.5px; margin-top: 2px; }

/* daftar info: garis pemisah rapi */
.info-list.pad-x { padding: 6px 20px 16px; }
.info-list div {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}
.info-list div:last-child { border-bottom: 0; padding-bottom: 0; }
.info-list dt { font-size: 12.5px; color: var(--muted); }
.info-list dd { font-size: 13px; }

/* baris keamanan */
.settings-row { padding: 15px 20px; align-items: center; }
.settings-row + .settings-row { border-top: 1px solid var(--line); }
.settings-row > div { min-width: 0; }
.settings-row strong { display: block; font-size: 13.5px; }
.settings-row p { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.45; }
.settings-row .btn { flex: none; }
.settings-row.danger { background: #fff7f8; }
.settings-row.danger strong { color: var(--danger); }

/* formulir profil */
.settings-grid .form { padding: 16px 20px 18px; gap: 14px; }
.settings-grid .form .field > span { font-size: 12.5px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: flex-start; }

/* kartu perangkat */
.device-hero { padding: 18px 20px 8px; gap: 18px; }
.device-ring { width: 82px; height: 82px; }
.device-tree { padding: 6px 20px 16px; }
.device-tree li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.device-tree li:last-child { border-bottom: 0; }

/* tautan & QR */
.wame-box { padding: 18px 20px 20px; }
.wame-box img { width: 140px; height: 140px; border-radius: 12px; }
.wame-link { font-size: 12.5px; }
.biz-box { margin: 0 20px 18px; }

@media (max-width: 1100px) {
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .settings-head { padding: 14px; gap: 12px; margin-bottom: 12px; border-radius: 12px; }
  .settings-head .avatar.lg { width: 54px; height: 54px; font-size: 18px; }
  .settings-head-body h2 { font-size: 17px; }
  .settings-grid { gap: 12px; }
  .settings-grid .card-head { padding: 14px 16px 12px; }
  .settings-grid .form { padding: 14px 16px 16px; }
  .info-list.pad-x { padding: 4px 16px 14px; }
  .settings-row { padding: 13px 16px; flex-wrap: wrap; }
  .settings-row .btn { width: 100%; justify-content: center; margin-top: 4px; }
  .device-hero { padding: 16px 16px 6px; }
  .device-tree { padding: 4px 16px 14px; }
  .wame-box { padding: 16px; }
}
