/* ===================== Design tokens ===================== */
:root {
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #eef0f6;
  --border: #e6e8ef;
  --border-strong: #d5d9e3;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --faint: #9ca3af;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef0ff;
  --primary-ink: #ffffff;
  --accent: #10b981;
  --accent-soft: #e7f8f1;

  --green: #059669;   --green-soft: #e6f6ef;
  --blue: #2563eb;    --blue-soft: #e8f0fe;
  --amber: #b45309;   --amber-soft: #fef3e2;
  --red: #dc2626;     --red-soft: #fdecec;
  --gray: #4b5563;    --gray-soft: #f0f1f4;

  --chat-bg: #f1efe9;
  --bubble-in: #ffffff;
  --bubble-ai: #e4f6ec;
  --bubble-agent: #e6ecfd;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, 0.18), 0 4px 8px -4px rgba(16, 24, 40, 0.06);
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --sidebar: 264px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d14; --surface: #12151f; --surface-2: #161a26; --surface-3: #1d2231;
    --border: #232838; --border-strong: #2e3447;
    --text: #eef0f6; --text-2: #cfd3df; --muted: #8b93a7; --faint: #646b7e;
    --primary: #7c74ff; --primary-hover: #8f88ff; --primary-soft: #1f1d3d; --primary-ink: #ffffff;
    --accent: #34d399; --accent-soft: #11291f;
    --green: #34d399; --green-soft: #102a20; --blue: #60a5fa; --blue-soft: #132238;
    --amber: #fbbf24; --amber-soft: #2d2410; --red: #f87171; --red-soft: #2e1515;
    --gray: #a3aab9; --gray-soft: #1d2231;
    --chat-bg: #0e1119; --bubble-in: #1b2030; --bubble-ai: #12322a; --bubble-agent: #1c2547;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4); --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0d14; --surface: #12151f; --surface-2: #161a26; --surface-3: #1d2231;
  --border: #232838; --border-strong: #2e3447;
  --text: #eef0f6; --text-2: #cfd3df; --muted: #8b93a7; --faint: #646b7e;
  --primary: #7c74ff; --primary-hover: #8f88ff; --primary-soft: #1f1d3d; --primary-ink: #ffffff;
  --accent: #34d399; --accent-soft: #11291f;
  --green: #34d399; --green-soft: #102a20; --blue: #60a5fa; --blue-soft: #132238;
  --amber: #fbbf24; --amber-soft: #2d2410; --red: #f87171; --red-soft: #2e1515;
  --gray: #a3aab9; --gray-soft: #1d2231;
  --chat-bg: #0e1119; --bubble-in: #1b2030; --bubble-ai: #12322a; --bubble-agent: #1c2547;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4); --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* ===================== Base ===================== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; line-height: 1.25; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.ic { flex: none; display: block; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
[hidden] { display: none !important; }
::selection { background: var(--primary-soft); }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }

/* ===================== Buttons & inputs ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 13.5px;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); border-color: var(--primary);
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, var(--border)); }
.btn.danger:hover { background: var(--red-soft); }
.btn.danger-solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.soft { background: var(--primary-soft); color: var(--primary); border-color: transparent; box-shadow: none; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.lg { height: 44px; padding: 0 20px; font-size: 14.5px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=time], input[type=search], input:not([type]), select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: var(--faint); }
select { appearance: none; padding-right: 34px; cursor: pointer;
  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='%236b7280' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--text-2); }
.field > small, .hint { display: block; color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-error { color: var(--red); font-size: 13px; min-height: 18px; margin: -6px 0 10px; }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.input-icon input { padding-left: 38px; }

/* Switch */
.switch-row { display: flex; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.switch-row:last-child { border-bottom: 0; }
.switch-row > span:first-child { flex: 1; }
.switch-row b { display: block; font-weight: 600; font-size: 14px; }
.switch-row small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; background: var(--border-strong); border-radius: 99px; transition: background .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + i { background: var(--primary); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }

/* Badges, chips, avatar */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge .ic { width: 12px; height: 12px; }
.badge.gray { background: var(--gray-soft); color: var(--gray); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.violet { background: var(--primary-soft); color: var(--primary); }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 7px; background: var(--surface-3); color: var(--text-2); font-size: 12px; font-weight: 500; }
.chip button { border: 0; background: none; padding: 0; margin-left: 2px; color: var(--muted); cursor: pointer; display: grid; }
.avatar { width: var(--s); height: var(--s); flex: none; border-radius: 50%; display: inline-grid; place-items: center;
  background: color-mix(in srgb, var(--av) 16%, var(--surface)); color: var(--av); font-weight: 700; font-size: calc(var(--s) * .38); letter-spacing: .02em; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--faint); }
.dot.green { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dot.amber { background: #f59e0b; box-shadow: 0 0 0 3px var(--amber-soft); }
.dot.red { background: var(--red); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 15px; font-weight: 700; }
.card-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card-body { padding: 20px; }

/* ===================== Auth ===================== */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-hero {
  position: relative; overflow: hidden; padding: 40px 56px; color: #fff; display: flex; flex-direction: column;
  background: radial-gradient(1200px 600px at -10% -10%, #6d5efc 0%, transparent 60%),
              radial-gradient(900px 600px at 110% 110%, #0ea5a4 0%, transparent 55%), #312e81;
}
.hero-copy { margin: auto 0; max-width: 520px; }
.hero-copy h1 { font-size: 38px; font-weight: 800; line-height: 1.15; margin: 18px 0 14px; letter-spacing: -0.02em; }
.hero-copy p { opacity: .85; font-size: 16px; }
.hero-copy ul { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 10px; }
.hero-copy li { display: flex; gap: 10px; align-items: center; opacity: .92; }
.hero-copy li .ic { background: rgba(255,255,255,.18); border-radius: 50%; padding: 3px; width: 22px; height: 22px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; background: rgba(255,255,255,.14); font-size: 13px; font-weight: 600; backdrop-filter: blur(6px); }
.hero-chat { display: grid; gap: 8px; max-width: 360px; margin-top: 28px; }
.hc { padding: 10px 14px; border-radius: 14px; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.hc.in { background: #fff; color: #111827; border-bottom-left-radius: 4px; justify-self: start; }
.hc.out { background: #dcfce7; color: #064e3b; border-bottom-right-radius: 4px; justify-self: end; margin-left: 40px; }
.hc.tag { justify-self: end; background: rgba(255,255,255,.16); color: #fff; padding: 5px 10px; font-size: 12px; display: inline-flex; align-items: center; gap: 6px; box-shadow: none; }
.auth-form-wrap { display: grid; place-items: center; padding: 32px 20px; background: var(--surface); }
.auth-form { width: 100%; max-width: 380px; }
.auth-form h2 { font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.auth-form > p.muted { margin-bottom: 28px; }
.auth-form .btn { margin-top: 4px; }
.auth-form .tiny { margin-top: 32px; }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.brand .ic { color: #fff; background: var(--primary); border-radius: 9px; padding: 5px; width: 32px; height: 32px; }
.brand b { color: var(--primary); font-weight: 800; }
.brand.light b { color: #c7d2fe; }
.brand.light .ic { background: rgba(255,255,255,.18); }
.mobile-only { display: none; margin-bottom: 28px; }

/* ===================== App shell ===================== */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: var(--sidebar); flex: none; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px 14px; gap: 14px; z-index: 40;
}
.sb-top { display: flex; align-items: center; justify-content: space-between; padding: 0 6px; }
.sb-close { display: none; }
.ws-switch { position: relative; }
.ws-btn {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; text-align: left;
  border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--r); cursor: pointer;
}
.ws-btn:hover { border-color: var(--border-strong); }
.ws-btn b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-btn small { display: block; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-btn > .ic { color: var(--muted); }
.ws-menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 6px; z-index: 50; max-height: 360px; overflow: auto;
}
.ws-menu-label { font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; padding: 6px 8px; }
.ws-menu button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; background: none; border-radius: 8px; cursor: pointer; text-align: left; font-weight: 500; }
.ws-menu button:hover, .ws-menu button.active { background: var(--surface-3); }
.ws-menu button[data-new] { color: var(--primary); border-top: 1px solid var(--border); border-radius: 0 0 8px 8px; margin-top: 4px; }
.ws-menu button .ic { color: var(--primary); }

.nav { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 14px; margin: 4px -4px 0; padding: 0 4px; }
.nav-label { font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .07em; padding: 0 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px; color: var(--text-2);
  font-weight: 600; font-size: 13.5px; transition: background .12s, color .12s; position: relative;
}
.nav a .ic { color: var(--muted); }
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav a.active .ic { color: var(--primary); }
.nav-badge { margin-left: auto; font-style: normal; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.sb-bottom { display: grid; gap: 10px; }
.wa-card { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.wa-card:hover { border-color: var(--border-strong); }
.wa-card small { display: block; font-size: 11px; color: var(--muted); }
.wa-card b { display: block; font-size: 13px; }
.wa-card > .ic { color: var(--faint); }
.user-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px 0; border-top: 1px solid var(--border); }
.user-row b { display: block; font-size: 13px; }
.user-row small { display: block; font-size: 11.5px; color: var(--muted); }
.user-row .icon-btn { width: 32px; height: 32px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 68px; flex: none; display: flex; align-items: center; gap: 14px; padding: 0 28px; background: var(--surface); border-bottom: 1px solid var(--border); }
.menu-btn { display: none; }
.page-title h1 { font-size: 18px; font-weight: 800; }
.page-title p { color: var(--muted); font-size: 13px; }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.view { flex: 1; overflow: auto; padding: 24px 28px 40px; }
.sb-overlay { display: none; }

/* ===================== Generic layouts ===================== */
.stack { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
.stack > *, .grid-2 > *, .grid-main > *, .kpis > *, .channel-grid > *, .pg > * { min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.section-title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.section-title h2 { font-size: 16px; font-weight: 700; }

.empty-state { text-align: center; padding: 48px 24px; display: grid; justify-items: center; gap: 6px; }
.empty-state h3 { font-size: 16px; font-weight: 700; margin-top: 8px; }
.empty-state p { color: var(--muted); max-width: 380px; }
.empty-state .btn { margin-top: 12px; }
.empty-ic { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.empty-ic.big { width: 72px; height: 72px; border-radius: 20px; }
.welcome { max-width: 520px; margin: 40px auto; padding: 40px; text-align: center; display: grid; justify-items: center; gap: 10px; }
.welcome h2 { font-size: 22px; font-weight: 800; margin-top: 6px; }
.welcome .btn { margin-top: 10px; }
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--r); background: var(--amber-soft); color: var(--amber); font-size: 13px; }
.callout.info { background: var(--blue-soft); color: var(--blue); }
.callout b { color: inherit; }
.callout p { color: var(--text-2); }

/* ===================== Beranda ===================== */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { padding: 18px; display: grid; gap: 10px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-weight: 600; font-size: 13px; }
.kpi-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.kpi-ic.violet { background: var(--primary-soft); color: var(--primary); }
.kpi-ic.blue { background: var(--blue-soft); color: var(--blue); }
.kpi-ic.green { background: var(--green-soft); color: var(--green); }
.kpi-ic.amber { background: var(--amber-soft); color: var(--amber); }
.kpi-val { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.kpi-sub { font-size: 12.5px; color: var(--muted); }
.chart { width: 100%; height: 220px; display: block; }
.chart .bar { fill: var(--primary); }
.chart .bar-ads { fill: var(--accent); }
.chart .grid { stroke: var(--border); stroke-dasharray: 3 4; }
.chart text { fill: var(--faint); font-size: 11px; font-family: var(--font); }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.funnel { display: grid; gap: 14px; }
.funnel-row { display: grid; gap: 6px; }
.funnel-row .top { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; }
.funnel-row .top span:last-child { color: var(--muted); font-weight: 500; }
.bar-track { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--primary); }
.checklist { display: grid; gap: 4px; }
.check-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--r); color: var(--text); }
.check-item:hover { background: var(--surface-2); }
.check-item .tick { width: 26px; height: 26px; flex: none; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; color: transparent; }
.check-item.done .tick { background: var(--accent); border-color: var(--accent); color: #fff; }
.check-item.done b { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.check-item small { display: block; color: var(--muted); font-size: 12.5px; }
.check-item > .ic:last-child { color: var(--faint); }
.progress-head { display: flex; align-items: center; gap: 12px; }
.ring { --p: 0; width: 44px; height: 44px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-3) 0); }
.ring span { width: 34px; height: 34px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 11.5px; font-weight: 700; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--border); color: var(--text); }
.list-row:first-child { border-top: 0; }
a.list-row:hover { background: var(--surface-2); }
.list-row b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row small { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===================== Tabel ===================== */
.toolbar { display: flex; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.toolbar .input-icon { flex: 1; min-width: 200px; max-width: 360px; }
.toolbar select { width: auto; min-width: 150px; }
.table-wrap { overflow: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 11px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; transition: background .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.cell-user { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.cell-user b { display: block; }
.cell-user small { color: var(--muted); font-size: 12.5px; }
.cell-clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.seg { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: 10px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ===================== Inbox (gaya WhatsApp) ===================== */
:root {
  --wa-bg: #efeae2;
  --wa-panel: #f0f2f5;
  --wa-in: #ffffff;
  --wa-out: #d9fdd3;
  --wa-text: #111b21;
  --wa-meta: #667781;
  --wa-tick: #53bdeb;
  --wa-green: #00a884;
  --wa-badge: #25d366;
  --wa-chip: #ffffff;
  --wa-active: #f0f2f5;
  --wa-hover: #f5f6f6;
  --wa-line: #e9edef;
  --wa-doodle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160' fill='none' stroke='%23000' stroke-opacity='.04' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 22h22a5 5 0 0 1 5 5v12a5 5 0 0 1-5 5H28l-7 6v-6h-3a5 5 0 0 1-5-5V27a5 5 0 0 1 5-5Z'/%3E%3Ccircle cx='112' cy='30' r='9'/%3E%3Cpath d='M108 30h8M112 26v8'/%3E%3Cpath d='M70 70l4 9 9 4-9 4-4 9-4-9-9-4 9-4Z'/%3E%3Cpath d='M126 92c6-8 18-2 12 7l-9 9-9-9c-6-9 6-15 6-7Z'/%3E%3Crect x='22' y='100' width='26' height='18' rx='4'/%3E%3Cpath d='M22 106h26'/%3E%3Cpath d='M98 132l14-8 14 8v14h-28Z'/%3E%3Ccircle cx='60' cy='136' r='3'/%3E%3Ccircle cx='146' cy='60' r='3'/%3E%3Cpath d='M80 18c4 0 6 3 6 6M140 136c0 4-3 6-6 6'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] {
  --wa-bg: #0b141a; --wa-panel: #202c33; --wa-in: #202c33; --wa-out: #005c4b; --wa-text: #e9edef; --wa-meta: #8696a0;
  --wa-chip: #182229; --wa-active: #2a3942; --wa-hover: #202c33; --wa-line: #222d34;
  --wa-doodle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160' fill='none' stroke='%23fff' stroke-opacity='.035' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 22h22a5 5 0 0 1 5 5v12a5 5 0 0 1-5 5H28l-7 6v-6h-3a5 5 0 0 1-5-5V27a5 5 0 0 1 5-5Z'/%3E%3Ccircle cx='112' cy='30' r='9'/%3E%3Cpath d='M108 30h8M112 26v8'/%3E%3Cpath d='M70 70l4 9 9 4-9 4-4 9-4-9-9-4 9-4Z'/%3E%3Cpath d='M126 92c6-8 18-2 12 7l-9 9-9-9c-6-9 6-15 6-7Z'/%3E%3Crect x='22' y='100' width='26' height='18' rx='4'/%3E%3Cpath d='M22 106h26'/%3E%3Cpath d='M98 132l14-8 14 8v14h-28Z'/%3E%3Ccircle cx='60' cy='136' r='3'/%3E%3Ccircle cx='146' cy='60' r='3'/%3E%3Cpath d='M80 18c4 0 6 3 6 6M140 136c0 4-3 6-6 6'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --wa-bg: #0b141a; --wa-panel: #202c33; --wa-in: #202c33; --wa-out: #005c4b; --wa-text: #e9edef; --wa-meta: #8696a0;
    --wa-chip: #182229; --wa-active: #2a3942; --wa-hover: #202c33; --wa-line: #222d34;
    --wa-doodle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160' fill='none' stroke='%23fff' stroke-opacity='.035' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 22h22a5 5 0 0 1 5 5v12a5 5 0 0 1-5 5H28l-7 6v-6h-3a5 5 0 0 1-5-5V27a5 5 0 0 1 5-5Z'/%3E%3Ccircle cx='112' cy='30' r='9'/%3E%3Cpath d='M108 30h8M112 26v8'/%3E%3Cpath d='M70 70l4 9 9 4-9 4-4 9-4-9-9-4 9-4Z'/%3E%3Cpath d='M126 92c6-8 18-2 12 7l-9 9-9-9c-6-9 6-15 6-7Z'/%3E%3Crect x='22' y='100' width='26' height='18' rx='4'/%3E%3Cpath d='M22 106h26'/%3E%3Cpath d='M98 132l14-8 14 8v14h-28Z'/%3E%3Ccircle cx='60' cy='136' r='3'/%3E%3Ccircle cx='146' cy='60' r='3'/%3E%3Cpath d='M80 18c4 0 6 3 6 6M140 136c0 4-3 6-6 6'/%3E%3C/svg%3E");
  }
}

.view.page-inbox { padding: 0; overflow: hidden; }
.inbox { display: grid; grid-template-columns: 360px minmax(0, 1fr) 320px; height: 100%; }
.inbox.no-detail { grid-template-columns: 360px minmax(0, 1fr); }

/* Daftar chat */
.ib-list { border-right: 1px solid var(--wa-line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.ib-list-head { padding: 10px 12px 8px; display: grid; gap: 10px; }
.wa-search { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 14px; border-radius: 10px; background: var(--wa-panel); color: var(--wa-meta); }
.wa-search input { border: 0; background: transparent; height: 100%; padding: 0; box-shadow: none !important; }
.pills { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.pills::-webkit-scrollbar { display: none; }
.pills button { flex: none; border: 0; height: 30px; padding: 0 12px; border-radius: 99px; background: var(--wa-panel); color: var(--wa-meta); font-weight: 600; font-size: 13px; cursor: pointer; }
.pills button.active { background: color-mix(in srgb, var(--wa-green) 16%, var(--surface)); color: var(--wa-green); }
.ib-items { flex: 1; overflow: auto; }
.ib-item { display: flex; align-items: center; gap: 13px; padding: 0 0 0 13px; cursor: pointer; height: 74px; }
.ib-item:hover { background: var(--wa-hover); }
.ib-item.active { background: var(--wa-active); }
.ib-item .ib-body { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 3px; padding-right: 14px; border-bottom: 1px solid var(--wa-line); }
.ib-item .row1, .ib-item .row2 { display: flex; align-items: center; gap: 8px; }
.ib-item .name { font-size: 15.5px; font-weight: 500; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-item .time { font-size: 12px; color: var(--wa-meta); flex: none; }
.ib-item.unread .time { color: var(--wa-badge); font-weight: 600; }
.ib-item .preview { flex: 1; min-width: 0; font-size: 13.5px; color: var(--wa-meta); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 3px; }
.ib-item .preview .ic { flex: none; }
.ib-item .tick { color: var(--wa-tick); }
.ib-item .flags { display: flex; gap: 4px; align-items: center; flex: none; }
.mini { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; }
.mini.ai { background: var(--accent-soft); color: var(--green); }
.mini.human { background: var(--amber-soft); color: var(--amber); }
.mini.ad { background: var(--blue-soft); color: var(--blue); }
.unread-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--wa-badge); color: #fff; font-size: 11.5px; font-weight: 700; display: grid; place-items: center; }
.ib-item .assignee { font-size: 11.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; flex: none; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Percakapan */
.ib-conv { display: flex; flex-direction: column; min-height: 0; position: relative; background-color: var(--wa-bg); background-image: var(--wa-doodle); }
.ib-conv-head { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: var(--wa-panel); min-height: 60px; border-left: 1px solid var(--wa-line); }
.ib-conv-head .who-box { flex: 1; min-width: 0; cursor: pointer; }
.ib-conv-head b { display: block; font-size: 15.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-conv-head small { display: block; font-size: 12.5px; color: var(--wa-meta); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-conv-head .icon-btn { color: var(--wa-meta); }
.ib-back { display: none; }
.assign-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 99px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--text-2); max-width: 180px; }
.assign-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode-pill { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 99px; border: 0; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.mode-pill.ai { background: var(--accent-soft); color: var(--green); }
.mode-pill.human { background: var(--amber-soft); color: var(--amber); }
.mode-pill:disabled { cursor: default; }
.mode-banner { align-self: center; display: flex; align-items: center; gap: 8px; margin: 10px 16px 0; padding: 6px 12px; font-size: 12.5px; border-radius: 8px; background: color-mix(in srgb, var(--wa-chip) 92%, transparent); color: var(--wa-meta); box-shadow: 0 1px .5px rgba(11, 20, 26, .13); max-width: calc(100% - 32px); text-align: center; }
.mode-banner .ic { flex: none; }

.ib-msgs { flex: 1; overflow: auto; padding: 8px 0 14px; display: flex; flex-direction: column; }
.wa-date { align-self: center; margin: 12px 0 8px; padding: 5px 12px; border-radius: 8px; background: var(--wa-chip); color: var(--wa-meta); font-size: 12.5px; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); }
.msg-row { display: flex; padding: 0 6%; margin-top: 2px; }
.msg-row.out { justify-content: flex-end; }
.msg-row.first { margin-top: 10px; }
.bubble {
  position: relative; max-width: min(65%, 560px); padding: 6px 8px 8px 9px; border-radius: 8px;
  font-size: 14.2px; line-height: 19px; color: var(--wa-text); box-shadow: 0 1px .5px rgba(11, 20, 26, .13); word-wrap: break-word;
}
.bubble.in { background: var(--wa-in); }
.bubble.out { background: var(--wa-out); }
.msg-row.first .bubble.in { border-top-left-radius: 0; }
.msg-row.first .bubble.out { border-top-right-radius: 0; }
/* Ekor bubble (hanya pesan pertama dalam satu kelompok) */
.msg-row.first .bubble::before {
  content: ""; position: absolute; top: 0; width: 8px; height: 13px;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 13'%3E%3Cpath d='M8 0v13C6.6 8.6 3.9 4.7.6 1.6A.9.9 0 0 1 1.2 0Z'/%3E%3C/svg%3E") no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 13'%3E%3Cpath d='M8 0v13C6.6 8.6 3.9 4.7.6 1.6A.9.9 0 0 1 1.2 0Z'/%3E%3C/svg%3E") no-repeat;
}
.msg-row.first .bubble.in::before { left: -8px; background: var(--wa-in); }
.msg-row.first .bubble.out::before { right: -8px; background: var(--wa-out); transform: scaleX(-1); }
.bubble .sender { display: block; font-size: 12.8px; font-weight: 600; line-height: 22px; margin-top: -2px; }
.bubble .sender.ai { color: #06a77d; }
.bubble .sender.agent { color: #3b82f6; }
.bubble .sender.owner { color: #a855f7; }
.bubble .text { white-space: pre-wrap; }
.bubble .spacer { display: inline-block; width: 52px; height: 1px; vertical-align: middle; }
.bubble.out .spacer { width: 70px; }
.bubble .meta { position: absolute; right: 7px; bottom: 3px; display: flex; align-items: center; gap: 3px; font-size: 11px; line-height: 15px; color: var(--wa-meta); }
.bubble .meta .ic { color: var(--wa-tick); width: 16px; height: 16px; }
.bubble .media { display: inline-flex; align-items: center; gap: 6px; color: var(--wa-meta); font-style: italic; }

.ib-composer { display: flex; gap: 8px; align-items: flex-end; padding: 8px 14px 10px; background: var(--wa-panel); }
.ib-composer textarea {
  flex: 1; height: 42px; min-height: 42px; max-height: 140px; resize: none; border-radius: 10px; padding: 10px 14px;
  overflow-y: hidden; border: 0; background: var(--surface); font-size: 15px; box-shadow: none;
}
.send-btn { width: 42px; height: 42px; flex: none; border: 0; border-radius: 50%; background: var(--wa-green); color: #fff; display: grid; place-items: center; cursor: pointer; }
.send-btn:disabled { opacity: .6; }
.composer-note { padding: 12px 16px; background: var(--wa-panel); color: var(--wa-meta); font-size: 13px; text-align: center; display: flex; gap: 8px; align-items: center; justify-content: center; }
.ib-empty { flex: 1; display: grid; place-items: center; background: var(--surface-2); }

/* Panel detail kontak */
.ib-detail { border-left: 1px solid var(--wa-line); background: var(--surface); overflow: auto; }
.cd-head { position: relative; text-align: center; padding: 26px 20px 18px; border-bottom: 1px solid var(--border); display: grid; justify-items: center; gap: 4px; }
.cd-head h3 { font-size: 17px; font-weight: 600; margin-top: 10px; }
.cd-head small { color: var(--muted); }
.cd-sec { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.cd-sec h4 { font-size: 12px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; }
.cd-sec h4 button { text-transform: none; letter-spacing: 0; }
.kv { display: grid; gap: 8px; margin: 0; }
.kv div { display: grid; grid-template-columns: 110px 1fr; gap: 10px; font-size: 13px; }
.kv dt { color: var(--muted); text-transform: capitalize; }
.kv dd { margin: 0; word-break: break-word; font-weight: 500; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.ad-card { border: 1px solid var(--border); border-radius: var(--r); padding: 12px; display: grid; gap: 6px; background: var(--surface-2); }
.ad-card b { font-size: 13.5px; }
.ad-card p { font-size: 12.5px; color: var(--muted); }
.stage-select { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 3px; background: var(--surface-3); border-radius: 10px; }
.stage-select button { border: 0; background: none; padding: 7px 2px; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.stage-select button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.stage-select button:disabled { cursor: default; }
@media (min-width: 1101px) { #cdClose { display: none; } }

/* Dropdown kecil (assign) */
.menu-pop { position: absolute; z-index: 70; min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 6px; }
.menu-pop button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; background: none; border-radius: 8px; cursor: pointer; text-align: left; font-size: 13.5px; }
.menu-pop button:hover { background: var(--surface-3); }
.menu-pop button small { color: var(--muted); font-size: 12px; margin-left: auto; }
.menu-pop .sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ===================== Settings form layout ===================== */
.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: start; max-width: 1100px; }
.subnav { position: sticky; top: 0; display: grid; gap: 2px; }
.subnav a { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 10px; color: var(--text-2); font-weight: 600; font-size: 13.5px; }
.subnav a:hover { background: var(--surface-3); }
.subnav a.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.subnav a .ic { color: var(--muted); }
.subnav a.active .ic { color: var(--primary); }
.form-section { scroll-margin-top: 12px; }
.form-section + .form-section { margin-top: 20px; }
.save-bar { position: sticky; bottom: -40px; margin: 20px -28px -40px; padding: 14px 28px; background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px); border-top: 1px solid var(--border); display: flex; align-items: center; gap: 12px; justify-content: flex-end; z-index: 5; }
.save-bar .muted { margin-right: auto; font-size: 13px; }
.gen-box { border: 1px dashed color-mix(in srgb, var(--primary) 45%, var(--border)); background: var(--primary-soft); border-radius: var(--r); padding: 14px 16px; margin-bottom: 16px; }
.gen-box summary { cursor: pointer; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 8px; list-style: none; }
.gen-box summary::-webkit-details-marker { display: none; }
.gen-box textarea { margin: 12px 0 10px; background: var(--surface); }
.counter { font-size: 12px; color: var(--faint); text-align: right; margin-top: 4px; }

/* ===================== Knowledge ===================== */
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--r-lg); padding: 28px 20px; text-align: center; display: grid; justify-items: center; gap: 6px; cursor: pointer; transition: border-color .15s, background .15s; background: var(--surface); }
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-soft); }
.dropzone .empty-ic { width: 48px; height: 48px; }
.dropzone b { font-size: 14px; margin-top: 6px; }
.kb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.kb-card { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.kb-card-top { display: flex; gap: 12px; align-items: flex-start; }
.kb-ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); flex: none; }
.kb-ic.pdf { background: var(--red-soft); color: var(--red); }
.kb-ic.csv { background: var(--green-soft); color: var(--green); }
.kb-card b { display: block; font-size: 14px; }
.kb-card small { color: var(--muted); font-size: 12px; }
.kb-preview { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; flex: 1; }
.kb-actions { display: flex; gap: 6px; border-top: 1px solid var(--border); padding-top: 10px; margin-top: auto; }
.usage-bar { display: grid; gap: 8px; }

/* ===================== Playground ===================== */
.pg { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 24px; align-items: start; }
.phone { border-radius: 32px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; height: min(720px, calc(100vh - 150px)); }
.phone-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: #008069; color: #fff; }
:root[data-theme="dark"] .phone-head { background: var(--wa-panel); }
.phone-head b { display: block; font-size: 14px; }
.phone-head small { display: block; font-size: 11.5px; opacity: .8; }
.phone-head .icon-btn { color: #fff; }
.phone-head .icon-btn:hover { background: rgba(255,255,255,.12); }
.phone .ib-msgs { padding: 6px 0 12px; }
.phone .msg-row { padding: 0 14px; }
.phone .bubble { max-width: 82%; }
.phone .ib-composer { padding: 8px 10px 10px; }
.typing { align-self: flex-start; margin: 10px 14px 0; background: var(--wa-in); border-radius: 12px; padding: 10px 14px; display: flex; gap: 4px; box-shadow: var(--shadow-sm); }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }
.suggests { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 12px; }
.suggests button { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 5px 11px; font-size: 12.5px; cursor: pointer; color: var(--text-2); }
.suggests button:hover { border-color: var(--primary); color: var(--primary); }
.log-list { display: grid; gap: 8px; }
.log-item { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.log-item .ic { margin-top: 2px; }
.log-item.lead .ic { color: var(--blue); } .log-item.tag .ic { color: var(--primary); } .log-item.hand .ic { color: var(--amber); }

/* ===================== Channel ===================== */
.channel-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px; align-items: start; max-width: 1100px; }
.conn-status { display: flex; align-items: center; gap: 14px; }
.conn-ic { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: #e7f8ee; color: #128c4a; flex: none; }
.qr-box { display: grid; place-items: center; padding: 24px; margin: 18px 0; border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--border); min-height: 300px; }
.qr-box img { border-radius: 12px; background: #fff; padding: 10px; box-shadow: var(--shadow); }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; counter-reset: s; }
.steps li { display: flex; gap: 12px; font-size: 13.5px; color: var(--text-2); }
.steps li::before { counter-increment: s; content: counter(s); width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 12.5px; display: grid; place-items: center; }
.provider { display: flex; gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--border); border-radius: var(--r); }
.provider + .provider { margin-top: 10px; }
.provider.active { border-color: var(--primary); background: var(--primary-soft); }
.provider b { display: block; font-size: 14px; }
.provider small { color: var(--muted); font-size: 12.5px; }

/* ===================== Modal & toast ===================== */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 18, 30, .5); display: grid; place-items: center; padding: 16px; z-index: 100; opacity: 0; transition: opacity .18s; backdrop-filter: blur(2px); }
.modal-backdrop.show { opacity: 1; }
.modal { width: 100%; max-width: 480px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--border); transform: translateY(8px) scale(.98); transition: transform .18s; }
.modal.wide { max-width: 720px; }
.modal-backdrop.show .modal { transform: none; }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.modal header h3 { font-size: 17px; font-weight: 700; }
.modal-body { padding: 10px 20px 4px; overflow: auto; }
.modal-body > p { margin-bottom: 16px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; }
#toasts { position: fixed; bottom: 20px; right: 20px; display: grid; gap: 8px; z-index: 200; }
.toast { display: flex; align-items: center; gap: 10px; max-width: 380px; padding: 12px 16px; border-radius: 12px; background: #111827; color: #fff; box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 500; transform: translateY(10px); opacity: 0; transition: all .22s; }
.toast.show { transform: none; opacity: 1; }
.toast.success .ic { color: #34d399; } .toast.error .ic { color: #f87171; } .toast.info .ic { color: #93c5fd; }

.skeleton { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }

/* ===================== Responsive ===================== */
@media (max-width: 1280px) {
  .inbox { grid-template-columns: 300px minmax(0, 1fr) 290px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .inbox, .inbox.no-detail { grid-template-columns: 300px minmax(0, 1fr); }
  .ib-detail { position: fixed; right: 0; top: 0; bottom: 0; width: min(340px, 100%); z-index: 60; box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform .2s; }
  .ib-detail.open { transform: none; }
  .grid-main, .channel-grid { grid-template-columns: 1fr; }
  .pg { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .mobile-only { display: flex; }
  .sidebar { position: fixed; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform .22s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .sidebar.open + .sb-overlay { display: block; position: fixed; inset: 0; background: rgba(15, 18, 30, .45); z-index: 30; }
  .sb-close, .menu-btn { display: inline-grid; }
  .topbar { padding: 0 16px; height: 60px; }
  .page-title p { display: none; }
  .view { padding: 16px 16px 32px; }
  .save-bar { margin: 20px -16px -32px; padding: 12px 16px; bottom: -32px; }
  .settings-layout { grid-template-columns: 1fr; }
  .subnav { position: static; display: flex; overflow: auto; gap: 4px; scrollbar-width: none; }
  .subnav::-webkit-scrollbar { display: none; }
  .subnav a { white-space: nowrap; }
  .grid-2, .field-row { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .inbox, .inbox.no-detail { grid-template-columns: 1fr; }
  .inbox.has-chat .ib-list { display: none; }
  .inbox:not(.has-chat) .ib-conv { display: none; }
  .ib-back { display: inline-grid; }
  .msg-row { padding: 0 12px; }
  .bubble { max-width: 86%; }
  .kpis { gap: 12px; }
  .kpi { padding: 14px; }
  .kpi-val { font-size: 24px; }
  .top-actions .btn .lbl { display: none; }
  .top-actions .btn { padding: 0 10px; }
  .phone { border-radius: 20px; height: calc(100vh - 140px); }
  #toasts { left: 16px; right: 16px; bottom: 16px; }
  .toast { max-width: none; }
}

/* ===================== Bahasa, tim & peran ===================== */
.lang-switch { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-3); }
.lang-switch button { border: 0; background: none; padding: 4px 10px; border-radius: 8px; font-size: 12px; font-weight: 700; color: var(--muted); cursor: pointer; }
.lang-switch button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.sb-bottom > .lang-switch { justify-self: start; }
.auth-form-wrap { position: relative; }
.auth-lang { position: absolute; top: 20px; right: 20px; }

.tabs-line { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs-line button { border: 0; background: none; padding: 10px 14px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 8px; align-items: center; }
.tabs-line button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs-line .count { font-size: 11.5px; background: var(--surface-3); color: var(--muted); border-radius: 99px; padding: 1px 7px; }
.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.role-card { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.role-card .top { display: flex; align-items: flex-start; gap: 12px; }
.role-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary); }
.role-card h3 { font-size: 15px; font-weight: 700; }
.role-card p { font-size: 13px; color: var(--muted); }
.perm-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.perm-chips .chip { font-size: 11.5px; height: 22px; }
.role-card .foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.perm-group { border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 12px; overflow: hidden; }
.perm-group > b { display: block; padding: 10px 14px; background: var(--surface-2); font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.perm-row { display: flex; gap: 12px; align-items: flex-start; padding: 11px 14px; border-top: 1px solid var(--border); cursor: pointer; }
.perm-row input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--primary); flex: none; }
.perm-row b { display: block; font-size: 13.5px; font-weight: 600; }
.perm-row small { display: block; font-size: 12.5px; color: var(--muted); }
.ws-checks { display: grid; gap: 6px; max-height: 180px; overflow: auto; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r); margin-top: 8px; }
.ws-checks label { display: flex; gap: 10px; align-items: center; font-size: 13.5px; cursor: pointer; }
.ws-checks input { accent-color: var(--primary); width: 16px; height: 16px; }
.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.you { font-size: 11px; font-weight: 700; color: var(--primary); background: var(--primary-soft); padding: 1px 7px; border-radius: 99px; margin-left: 6px; vertical-align: 1px; }

/* ===================== Follow-up berurutan ===================== */
.ic.rot180 { transform: rotate(180deg); }
.fu-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; max-width: 1150px; }
.fu-side { position: sticky; top: 0; }
.fu-builder.disabled { opacity: .55; }
.fu-steps { position: relative; display: grid; gap: 14px; }
.fu-steps::before { content: ""; position: absolute; left: 17px; top: 18px; bottom: 18px; width: 2px; background: var(--border-strong); }
.fu-step { position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 14px; align-items: start; }
.fu-dot { position: relative; z-index: 1; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: #fff; font-weight: 800; font-size: 14px; box-shadow: 0 0 0 4px var(--bg); }
.fu-step.start .fu-dot { background: var(--blue-soft); color: var(--blue); }
.fu-step.add .fu-dot { background: var(--surface); color: var(--muted); border: 2px dashed var(--border-strong); }
.fu-step.end .fu-dot { background: var(--accent-soft); color: var(--green); }
.fu-step.off .fu-dot { background: var(--surface-3); color: var(--muted); }
.fu-step.off .fu-card { opacity: .6; }
.fu-start { padding-top: 6px; }
.fu-start b { display: block; font-size: 14px; }
.fu-start small { color: var(--muted); font-size: 12.5px; }
.fu-add-row { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 1px; }
.fu-card { overflow: hidden; }
.fu-head { display: flex; align-items: center; gap: 6px; padding: 12px 14px 12px 18px; border-bottom: 1px solid var(--border); }
.fu-head b { display: block; font-size: 14.5px; }
.fu-head small { display: block; font-size: 12.5px; color: var(--muted); }
.fu-head .switch { margin-right: 6px; }
.fu-head .icon-btn:disabled { opacity: .3; cursor: default; }
.fu-body { padding: 16px 18px; display: grid; gap: 12px; }
.fu-timing { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13.5px; }
.fu-timing select { width: auto; min-width: 110px; height: 36px; }
.fu-num { width: 76px !important; height: 36px; text-align: center; }
.fu-time { width: 120px !important; height: 36px; }
.fu-mode { justify-self: start; }
.fu-mode button { display: inline-flex; align-items: center; gap: 6px; }
.fu-vars { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.fu-vars .chip { cursor: pointer; border: 0; font-family: ui-monospace, monospace; }
.fu-vars .chip:hover { background: var(--primary-soft); color: var(--primary); }
.fu-rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.fu-rules li { display: flex; gap: 10px; font-size: 13px; color: var(--text-2); }
.fu-rules li .ic { color: var(--primary); margin-top: 2px; }
.bubble .fu-tag { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--wa-meta); margin-right: 6px; padding-right: 6px; border-right: 1px solid color-mix(in srgb, var(--wa-meta) 35%, transparent); }
@media (max-width: 1100px) { .fu-layout { grid-template-columns: 1fr; } .fu-side { position: static; } }
@media (max-width: 720px) { .fu-head small { white-space: normal; } .fu-body { padding: 14px; } }
.bubble.has-fu .spacer { width: 150px; }
/* Header percakapan di layar sempit: tombol assign & mode cukup ikon supaya nama kontak terbaca */
.ib-conv-head .who-box { min-width: 90px; }
@media (max-width: 1280px) { .ib-conv-head .assign-btn .lbl, .ib-conv-head .mode-pill .lbl { display: none; } .ib-conv-head .assign-btn { padding: 0 8px; } .ib-conv-head .mode-pill { padding: 0 10px; } }

/* ===================== Multi-tenant: banner & daftar ===================== */
.banner { display: flex; align-items: center; gap: 10px; padding: 9px 28px; font-size: 13.5px; border-bottom: 1px solid var(--border); }
.banner.admin { background: #1e1b4b; color: #e0e7ff; }
.banner.admin .btn { background: rgba(255,255,255,.12); border-color: transparent; color: #fff; box-shadow: none; }
.banner.info { background: var(--blue-soft); color: var(--blue); }
.banner.warn { background: var(--amber-soft); color: var(--amber); }
.banner.danger { background: var(--red-soft); color: var(--red); }
.banner .grow { color: inherit; }
.auth-switch { text-align: center; margin-top: 18px; font-size: 13.5px; color: var(--muted); }
.auth-switch a { font-weight: 700; }
.plan-card { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.plan-name { font-size: 22px; font-weight: 800; }
.usage-row { display: grid; gap: 6px; }
.usage-row .top { display: flex; justify-content: space-between; font-size: 13.5px; }
.usage-row .top b { font-weight: 600; }
@media (max-width: 900px) { .banner { padding: 9px 16px; } }
.label-row { display: flex !important; justify-content: space-between; align-items: baseline; }
.label-row a { font-weight: 600; font-size: 12.5px; }
.auth-switch a { display: inline-flex; align-items: center; gap: 4px; }
.load-older { align-self: center; display: inline-flex; align-items: center; gap: 6px; margin: 8px 0 4px; padding: 6px 14px; border: 0; border-radius: 99px; background: var(--wa-chip); color: var(--wa-meta); font-size: 12.5px; font-weight: 600; cursor: pointer; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); }
.load-older:hover { color: var(--primary); }
.load-more { display: flex; justify-content: center; padding: 14px; border-top: 1px solid var(--border); }
