/* ============ Tokens ============ */
:root {
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-2: #f7f9f8;
  --surface-3: #eef2f0;
  --text: #14201a;
  --text-2: #3d4a43;
  --muted: #66736c;
  --line: #e2e7e4;
  --line-strong: #cfd7d3;
  --primary: #128c4b;
  --primary-hover: #0e7a40;
  --primary-soft: #e3f4ea;
  --primary-text: #ffffff;
  --danger: #cf3a2e;
  --danger-soft: #fdebe9;
  --warn: #a76a06;
  --warn-soft: #fff4dc;
  --info: #2463d8;
  --info-soft: #e8effd;
  --read: #1d9bf0;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --wall: #ece8e1;
  --shadow-sm: 0 1px 2px rgb(16 24 20 / 0.06);
  --shadow: 0 1px 3px rgb(16 24 20 / 0.08), 0 4px 16px rgb(16 24 20 / 0.06);
  --shadow-lg: 0 12px 40px rgb(16 24 20 / 0.18);
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --sidebar: 232px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0d1210;
  --surface: #151b18;
  --surface-2: #1a211d;
  --surface-3: #212a25;
  --text: #e6ece9;
  --text-2: #c3cdc8;
  --muted: #8e9b94;
  --line: #26302b;
  --line-strong: #34403a;
  --primary: #22b566;
  --primary-hover: #2cc673;
  --primary-soft: #16301f;
  --primary-text: #04150b;
  --danger: #f0685c;
  --danger-soft: #3a1a17;
  --warn: #e9b44c;
  --warn-soft: #33280f;
  --info: #7aa7ff;
  --info-soft: #18243d;
  --read: #53bdeb;
  --bubble-in: #1f2723;
  --bubble-out: #11573a;
  --wall: #0f1513;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow: 0 1px 3px rgb(0 0 0 / 0.4), 0 6px 20px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 16px 48px rgb(0 0 0 / 0.55);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1210;
    --surface: #151b18;
    --surface-2: #1a211d;
    --surface-3: #212a25;
    --text: #e6ece9;
    --text-2: #c3cdc8;
    --muted: #8e9b94;
    --line: #26302b;
    --line-strong: #34403a;
    --primary: #22b566;
    --primary-hover: #2cc673;
    --primary-soft: #16301f;
    --primary-text: #04150b;
    --danger: #f0685c;
    --danger-soft: #3a1a17;
    --warn: #e9b44c;
    --warn-soft: #33280f;
    --info: #7aa7ff;
    --info-soft: #18243d;
    --read: #53bdeb;
    --bubble-in: #1f2723;
    --bubble-out: #11573a;
    --wall: #0f1513;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow: 0 1px 3px rgb(0 0 0 / 0.4), 0 6px 20px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 16px 48px rgb(0 0 0 / 0.55);
    color-scheme: dark;
  }
}

/* ============ Base ============ */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14.5px/1.5 var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
h4 { font-size: 13px; }
p { margin: 0; }
a { color: var(--primary); }
.hidden, .role-hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.min0 { min-width: 0; }
.grow { flex: 1; }
.spacer { flex: 1; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic-xl { width: 40px; height: 40px; stroke-width: 1.5; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ============ Controls ============ */
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 8px 11px;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
textarea { resize: vertical; line-height: 1.55; }
select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23889590' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.field > span em { font-style: normal; color: var(--muted); font-weight: 400; }
.field-inline { flex-direction: row; align-items: center; gap: 10px; }
.field-inline > span { white-space: nowrap; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 500; font-size: 13.5px;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 8px 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
  position: relative; overflow: hidden;
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-sm .ic { width: 15px; height: 15px; }
.btn-lg { padding: 12px 20px; font-size: 15px; font-weight: 600; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-icon { padding: 9px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
kbd {
  font: 600 11px/1 var(--font); padding: 3px 5px; border-radius: 5px;
  background: var(--surface-3); border: 1px solid var(--line); color: var(--muted);
}
.kbd-on-primary { background: rgb(255 255 255 / 0.18); border-color: transparent; color: inherit; opacity: 0.85; }

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

.tag {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.tag .ic { width: 12px; height: 12px; }
.tag-ok { background: var(--primary-soft); color: var(--primary); }
.tag-danger { background: var(--danger-soft); color: var(--danger); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-info { background: var(--info-soft); color: var(--info); }

.alert { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-sm); font-size: 13.5px; }
.alert .ic { margin-top: 1px; }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert.square { border-radius: 0; }
.form-error { color: var(--danger); font-size: 13px; min-height: 1em; }

.bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--primary); border-radius: inherit; transition: width 0.4s ease; }
.bar.bad > i { background: var(--danger); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot.ok { background: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent); }
.dot.warn { background: var(--warn); }

.avatar {
  --h: 150;
  display: inline-grid; place-items: center; flex: none;
  width: 38px; height: 38px; border-radius: 50%;
  font-weight: 700; font-size: 14px; letter-spacing: 0.02em;
  color: hsl(var(--h) 55% 30%); background: hsl(var(--h) 55% 88%);
}
:root[data-theme="dark"] .avatar { color: hsl(var(--h) 60% 80%); background: hsl(var(--h) 30% 22%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { color: hsl(var(--h) 60% 80%); background: hsl(var(--h) 30% 22%); } }
.avatar-sm { width: 30px; height: 30px; font-size: 12px; }
.avatar-lg { width: 56px; height: 56px; font-size: 20px; }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 48px 24px; color: var(--muted); }
.empty h2 { color: var(--text); }
.empty .ic-xl { color: var(--line-strong); margin-bottom: 4px; }
.empty p { max-width: 460px; }
.tips { text-align: left; margin: 12px 0 0; padding-left: 18px; font-size: 13.5px; display: grid; gap: 4px; }

.skeleton { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--r-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Login ============ */
.login { display: grid; place-items: center; min-height: 100vh; padding: 16px;
  background: radial-gradient(1200px 500px at 50% -10%, var(--primary-soft), transparent 70%), var(--bg); }
.login-card {
  width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 28px; box-shadow: var(--shadow);
}

/* ============ Shell ============ */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line); padding: 14px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 14px; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: #fff; flex: none; }
.brand-mark .ic { fill: currentColor; stroke: none; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: var(--muted); }
.brand-lg .brand-mark { width: 44px; height: 44px; border-radius: 12px; }
.brand-lg .brand-name { font-size: 20px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--r-sm);
  color: var(--text-2); text-decoration: none; font-weight: 500; position: relative;
}
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav a.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
.nav a span { flex: 1; }
.nav-badge { min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; text-align: center; font-weight: 700; }
.nav .dot { margin-right: 4px; }

.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.me { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; }
.me-text { min-width: 0; }
.me-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-role { font-size: 12px; color: var(--muted); }
.foot-actions { display: flex; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px;
  padding: 12px 24px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.page-title { font-size: 19px; font-weight: 700; flex: 1; }
.topbar-status { display: flex; align-items: center; gap: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text-2); font-size: 13px; font-weight: 500; text-decoration: none;
}
.chip:hover { border-color: var(--line-strong); }
.quota { width: 170px; }
.quota-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.quota-label b { color: var(--text); font-variant-numeric: tabular-nums; }

.content { padding: 20px 24px 40px; width: 100%; max-width: 1320px; margin: 0 auto; }
.view { animation: fade 0.18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.toolbar { display: flex; align-items: center; gap: 16px; padding: 12px 14px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar select { min-width: 220px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.row-end { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* ============ Kirim ============ */
.campaign-progress { display: flex; flex-direction: column; gap: 5px; min-width: 200px; font-size: 12.5px; color: var(--muted); }
.campaign-progress b { color: var(--text); font-variant-numeric: tabular-nums; }

.send-grid { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 16px; align-items: start; }
.customer-card { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.customer-head { display: flex; gap: 14px; align-items: center; }
.rank { font-size: 12px; color: var(--muted); font-weight: 500; }
.customer-name { font-size: 20px; overflow-wrap: anywhere; }
.phone-copy {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 2px; padding: 2px 6px 2px 0;
  border: 0; background: none; color: var(--text-2); font: 500 13.5px var(--font); font-variant-numeric: tabular-nums; cursor: pointer; border-radius: 6px;
}
.phone-copy .ic { width: 14px; height: 14px; color: var(--muted); }
.phone-copy:hover { color: var(--primary); }
.phone-copy:hover .ic { color: var(--primary); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.stat-v { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-l { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.stat-l .ic { width: 13px; height: 13px; }
.stat.hot .stat-v { color: var(--warn); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.kv dt .ic { width: 14px; height: 14px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.menu-chips { display: flex; flex-wrap: wrap; gap: 5px; }

.composer-card { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.composer-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; background: var(--surface-3); border-radius: 10px; }
.seg button {
  font: 500 13px var(--font); color: var(--text-2); background: transparent; border: 0; border-radius: 8px;
  padding: 6px 11px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg button .count { font-size: 11px; color: var(--muted); font-weight: 600; }
#msgText { min-height: 190px; font-size: 15px; background: var(--surface-2); }
.composer-meta { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }

.send-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.send-btn { min-width: 220px; isolation: isolate; }
.send-btn > :not(.send-fill) { position: relative; z-index: 1; }
.send-fill { position: absolute; inset: 0; width: 0; background: rgb(255 255 255 / 0.22); z-index: 0; transition: width 1s linear; }
.send-btn.waiting { background: var(--surface-3); border-color: var(--line-strong); color: var(--text-2); opacity: 1; }
.send-btn.waiting .send-fill { background: color-mix(in srgb, var(--primary) 22%, transparent); }
.send-btn.waiting kbd { display: none; }
.send-secondary { display: flex; gap: 8px; margin-left: auto; }
.cooldown-note { font-size: 13px; color: var(--muted); min-height: 1.2em; }
.session-note { font-size: 12.5px; color: var(--muted); }

/* ============ Inbox ============ */
.inbox {
  display: grid; grid-template-columns: 330px minmax(0, 1fr) 300px; gap: 12px;
  height: calc(100vh - 106px); min-height: 480px;
}
.inbox.info-hidden { grid-template-columns: 330px minmax(0, 1fr); }
.inbox.info-hidden .chat-info { display: none; }
.chat-side, .chat, .chat-info { overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.chat-side-head { padding: 12px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); }
.search { position: relative; display: block; }
.search .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.search input { padding-left: 34px; background: var(--surface-2); }
.filters { display: flex; gap: 4px; flex-wrap: wrap; }
.filters button {
  font: 500 12.5px var(--font); color: var(--text-2); background: transparent; border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 10px; cursor: pointer;
}
.filters button span { color: var(--muted); font-variant-numeric: tabular-nums; }
.filters button.active { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.filters button.active span { color: inherit; }

.chat-list { list-style: none; margin: 0; padding: 4px; overflow-y: auto; flex: 1; }
.chat-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; align-items: center;
  padding: 10px; border-radius: 10px; cursor: pointer;
}
.chat-item:hover { background: var(--surface-2); }
.chat-item.active { background: var(--primary-soft); }
.chat-item .avatar { grid-row: span 2; }
.chat-item .ci-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .ci-time { font-size: 11.5px; color: var(--muted); text-align: right; }
.chat-item .ci-prev { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 4px; align-items: center; }
.chat-item .ci-prev .ic { width: 14px; height: 14px; }
.chat-item .ci-meta { display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
.chat-item.unread .ci-name { color: var(--text); }
.chat-item.unread .ci-prev { color: var(--text-2); font-weight: 500; }
.chat-item.unread .ci-time { color: var(--primary); font-weight: 600; }
.unread-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--primary); color: var(--primary-text); font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.chat-list .empty { padding: 32px 16px; }

.chat-pane { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.chat-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; flex-wrap: wrap; }
.messages {
  flex: 1; overflow-y: auto; padding: 16px 6% 12px; display: flex; flex-direction: column; gap: 3px;
  background: var(--wall);
}
.day-sep { align-self: center; margin: 10px 0 6px; font-size: 11.5px; font-weight: 600; color: var(--text-2); background: var(--surface); padding: 3px 10px; border-radius: 8px; box-shadow: var(--shadow-sm); }
.bubble {
  max-width: min(72%, 560px); padding: 7px 10px 6px; border-radius: 10px; white-space: pre-wrap; overflow-wrap: anywhere;
  box-shadow: 0 1px 0.5px rgb(0 0 0 / 0.12); font-size: 14px; line-height: 1.45; position: relative;
}
.bubble-in { background: var(--bubble-in); align-self: flex-start; border-top-left-radius: 3px; }
.bubble-out { background: var(--bubble-out); align-self: flex-end; border-top-right-radius: 3px; }
.bubble.cont { border-radius: 10px; margin-top: 0; }
.bubble + .bubble:not(.cont) { margin-top: 6px; }
.bubble .meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.bubble .meta .ic { width: 15px; height: 15px; }
.bubble .meta .read { color: var(--read); }
.bubble .meta .failed { color: var(--danger); }
.bubble .kind { font-size: 11px; font-weight: 600; color: var(--primary); margin-bottom: 2px; }
.bubble-in .kind { color: var(--info); }

.composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--surface); }
.composer textarea { resize: none; max-height: 160px; min-height: 40px; background: var(--surface-2); border-radius: 20px; padding: 9px 14px; }
.composer .btn-icon { border-radius: 50%; width: 40px; height: 40px; }

.chat-info .info-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--line); }
.info-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.outcome-box { padding: 14px 16px 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.outcome-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.outcome-chips button {
  font: 500 12.5px var(--font); padding: 5px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2);
  display: inline-flex; align-items: center; gap: 5px;
}
.outcome-chips button:hover { border-color: var(--primary); }
.outcome-chips button.active { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.outcome-chips button.active.neg { background: var(--danger); border-color: var(--danger); color: #fff; }
.outcome-chips .ic { width: 14px; height: 14px; }

/* ============ Laporan ============ */
.report-section { margin-bottom: 18px; }
.report-section > h3 { margin-bottom: 4px; }
.report-section > .muted { margin-bottom: 12px; font-size: 13px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; }
.kpi-v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi-v small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 4px; }
.kpi-l { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi.accent { background: var(--primary-soft); border-color: transparent; }
.kpi.accent .kpi-v { color: var(--primary); }
.kpi.neg .kpi-v { color: var(--danger); }

.funnel { padding: 16px 18px; display: grid; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 150px 1fr 110px; gap: 12px; align-items: center; font-size: 13.5px; }
.funnel-row .fl { color: var(--text-2); }
.funnel-row .fb { height: 22px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.funnel-row .fb > i { display: block; height: 100%; background: var(--primary); border-radius: 6px; min-width: 2px; transition: width 0.5s ease; }
.funnel-row .fv { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.funnel-row .fv small { font-weight: 500; color: var(--muted); margin-left: 4px; }

.compare { padding: 18px; display: grid; grid-template-columns: 1fr 1fr auto; gap: 24px; align-items: center; }
.compare-bar { display: flex; flex-direction: column; gap: 6px; }
.compare-bar .cb-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); }
.compare-bar .cb-head b { font-variant-numeric: tabular-nums; color: var(--text); }
.compare-bar .bar { height: 12px; }
.compare-bar.control .bar > i { background: var(--muted); }
.uplift { text-align: center; padding: 10px 18px; border-radius: var(--r); background: var(--primary-soft); color: var(--primary); }
.uplift.neg { background: var(--danger-soft); color: var(--danger); }
.uplift-v { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.uplift-l { font-size: 12px; font-weight: 600; }
.conv-actions { display: flex; align-items: flex-end; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.conv-actions .field { width: 140px; }

.tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.table-card { overflow: hidden; }
.table-card h3 { padding: 14px 16px 10px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { text-align: left; padding: 9px 16px; border-top: 1px solid var(--line); }
.table th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); }
.table td.num, .table th.num { text-align: right; }
.table tr:hover td { background: var(--surface-2); }
.table .empty-row td { color: var(--muted); text-align: center; }

/* ============ Kampanye ============ */
.form-card { padding: 18px 20px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 14px; }
.form-card-head { display: flex; justify-content: space-between; align-items: center; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .span2 { grid-column: span 2; }
.campaign-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.campaign { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.campaign-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.campaign-name { font-weight: 700; font-size: 15px; }
.campaign-by { font-size: 12px; color: var(--muted); }
.campaign-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.campaign-nums div { background: var(--surface-2); border-radius: 8px; padding: 7px 9px; }
.campaign-nums b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
.campaign-nums span { font-size: 11.5px; color: var(--muted); }
.campaign-prog { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); }
.campaign-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ============ Template ============ */
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.tpl { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.tpl.off { opacity: 0.65; }
.tpl-top { display: flex; align-items: center; gap: 8px; }
.tpl-name { font-weight: 700; flex: 1; }
.tpl-body { white-space: pre-wrap; font-size: 13.5px; color: var(--text-2); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; line-height: 1.55; }
.ph { background: var(--info-soft); color: var(--info); border-radius: 4px; padding: 0 3px; font-weight: 600; }
.tpl-stats { font-size: 12px; color: var(--muted); }

/* ============ WhatsApp ============ */
.wa-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.wa-status { padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.wa-status-head { display: flex; align-items: center; gap: 14px; }
.wa-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--surface-3); color: var(--muted); }
.wa-icon .ic { width: 26px; height: 26px; }
.wa-icon.ok { background: var(--primary-soft); color: var(--primary); }
.wa-icon.bad { background: var(--danger-soft); color: var(--danger); }
.wa-icon.warn { background: var(--warn-soft); color: var(--warn); }
.wa-state { font-size: 20px; font-weight: 700; }
.wa-status .btn { align-self: flex-start; }
.qr-card { padding: 20px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.steps { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--text-2); display: grid; gap: 4px; }
#qrImg { width: 280px; height: 280px; background: #fff; padding: 10px; border-radius: 12px; border: 1px solid var(--line); }

/* ============ Dialog / toast ============ */
.dialog {
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0; width: min(440px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgb(8 14 11 / 0.45); backdrop-filter: blur(2px); }
.dialog form { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.dialog-wide { width: min(920px, calc(100vw - 32px)); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head h3 { font-size: 17px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; }
.tpl-editor { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; }
.tpl-edit { display: flex; flex-direction: column; gap: 12px; }
.placeholder-bar { display: flex; flex-wrap: wrap; gap: 5px; }
.placeholder-bar button { font: 600 12px var(--font); padding: 3px 8px; border-radius: 6px; border: 1px dashed var(--line-strong); background: var(--surface-2); color: var(--info); cursor: pointer; }
.placeholder-bar button:hover { border-style: solid; border-color: var(--info); }
.hint { font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.hint .ic { width: 15px; height: 15px; }
.hint.ok { color: var(--primary); }
.hint.bad { color: var(--danger); }
.tpl-preview { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.wa-wall { background: var(--wall); border-radius: var(--r); padding: 18px; flex: 1; display: flex; flex-direction: column; min-height: 240px; }
.wa-wall .bubble { max-width: 100%; }

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; min-width: 260px; max-width: 420px;
  padding: 12px 14px; border-radius: var(--r); background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg);
  font-size: 13.5px; animation: toast-in 0.2s ease;
}
.toast .ic { margin-top: 1px; }
.toast.ok .ic { color: #4ade80; }
.toast.err { background: var(--danger); color: #fff; }
.toast.out { animation: toast-out 0.2s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ============ Responsive ============ */
.only-mobile { display: none; }

@media (max-width: 1240px) {
  .inbox, .inbox.info-hidden { grid-template-columns: 300px minmax(0, 1fr); }
  .chat-info {
    position: fixed; right: 12px; top: 72px; bottom: 12px; width: 320px; z-index: 20; box-shadow: var(--shadow-lg);
  }
  .inbox.info-hidden .chat-info { display: none; }
}
@media (max-width: 1080px) {
  .send-grid { grid-template-columns: 1fr; }
  .wa-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .compare { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 30;
    flex-direction: row; padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line);
  }
  .sidebar .brand, .sidebar-foot .me { display: none; }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 10.5px; flex: 1; text-align: center; }
  .nav a span { flex: none; }
  .nav a.active::before { display: none; }
  .nav-badge { position: absolute; top: 2px; left: 55%; font-size: 10px; min-width: 17px; padding: 0 4px; }
  .nav .dot { position: absolute; top: 6px; right: 28%; margin: 0; }
  .sidebar-foot { margin: 0; padding: 0; border: 0; flex-direction: column; justify-content: center; }
  .foot-actions { flex-direction: column; }
  .foot-actions .icon-btn { width: 30px; height: 26px; }
  .main { padding-bottom: 72px; }
  .topbar { padding: 10px 14px; gap: 10px; }
  .page-title { font-size: 17px; }
  .quota { width: 110px; }
  .chip span { display: none; }
  .content { padding: 14px 12px 24px; }
  .toolbar { gap: 10px; }
  .toolbar select { min-width: 0; }
  .field-inline { flex-direction: column; align-items: stretch; gap: 5px; }
  .send-btn { flex: 1; min-width: 0; }
  .send-secondary { margin-left: 0; width: 100%; }
  .send-secondary .btn { flex: 1; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: auto; }
  .tpl-editor { grid-template-columns: 1fr; }
  .funnel-row { grid-template-columns: 100px 1fr 90px; }
  .campaign-list, .template-grid { grid-template-columns: 1fr; }

  .inbox, .inbox.info-hidden { grid-template-columns: 1fr; height: calc(100vh - 150px); }
  .inbox .chat { display: none; }
  .inbox.chat-open .chat { display: flex; }
  .inbox.chat-open .chat-side { display: none; }
  .only-mobile { display: inline-grid; }
  .chat-info { left: 8px; right: 8px; width: auto; top: 60px; bottom: 80px; }
  .messages { padding: 12px 10px; }
  .bubble { max-width: 86%; }
  .toasts { left: 12px; right: 12px; bottom: 84px; }
  .toast { max-width: none; }
}

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