:root {
  --brand: #1f6feb; --brand-d: #1758c4; --brand-l: #e8f0fe;
  --side: #0f1b2d; --side-2: #18273d; --side-t: #b6c2d4;
  --bg: #f4f6fa; --card: #fff; --line: #e4e8ef; --text: #1d2433; --muted: #6b7587;
  --ok: #12a150; --warn: #e08a00; --err: #d93025; --radius: 8px;
  --shopee: #ee4d2d; --tiktok: #111; --demo: #7b5cff; --manual: #5f6b7a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { margin: 0 0 12px; font-weight: 600; }
h1 { font-size: 20px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.ok { color: var(--ok); } .err { color: var(--err); } .warn { color: var(--warn); }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 220px 1fr; height: 100vh; }
.sidebar { background: var(--side); color: var(--side-t); display: flex; flex-direction: column; overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 700; font-size: 17px; }
.logo .mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #3b8bff, #7b5cff); display: grid; place-items: center; font-size: 15px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 18px; color: var(--side-t); border-left: 3px solid transparent; }
.nav a:hover { background: var(--side-2); color: #fff; }
.nav a.active { background: var(--side-2); color: #fff; border-left-color: #3b8bff; }
.nav .ico { width: 20px; text-align: center; }
.nav .badge { margin-left: auto; }
.nav-sec { padding: 14px 18px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #6c7a90; }
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.topbar { height: 56px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 20px; gap: 12px; flex-shrink: 0; }
.topbar .spacer { flex: 1; }
.content { padding: 20px; overflow-y: auto; flex: 1; }
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; margin-right: auto; }

/* ---------- komponen ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card.p0 { padding: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.g-2-1 { grid-template-columns: 2fr 1fr; }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3, .g-2-1 { grid-template-columns: 1fr; } }
.kpi .label { color: var(--muted); font-size: 12px; } .kpi .value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.todo { display: flex; gap: 0; } .todo a { flex: 1; text-align: center; padding: 8px; border-right: 1px solid var(--line); color: var(--text); }
.todo a:last-child { border-right: 0; } .todo b { display: block; font-size: 22px; color: var(--brand); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 7px 14px; border-radius: 6px; cursor: pointer; font: inherit; white-space: nowrap; }
.btn:hover { border-color: #c3cad6; background: #fafbfc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; } .btn.primary:hover { background: var(--brand-d); }
.btn.danger { color: var(--err); } .btn.sm { padding: 4px 10px; font-size: 12px; } .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { border-color: transparent; background: transparent; } .btn.ghost:hover { background: var(--brand-l); }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

input, select, textarea { font: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-l); }
input[type=checkbox] { width: auto; }
textarea { resize: vertical; min-height: 70px; }
label.f { display: block; margin-bottom: 12px; } label.f > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; } .filters > * { width: auto; min-width: 140px; }
.filters input[type=search] { min-width: 260px; }

table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); background: #f8f9fb; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:hover td { background: #fbfcfe; } table.t tr:last-child td { border-bottom: 0; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; cursor: pointer; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.tabs .cnt { background: #eef1f6; color: var(--muted); border-radius: 10px; padding: 0 7px; font-size: 11px; margin-left: 4px; }
.tabs a.active .cnt { background: var(--brand-l); color: var(--brand); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; background: #eef1f6; color: var(--muted); white-space: nowrap; }
.badge.red { background: #fde8e6; color: var(--err); } .badge.green { background: #e3f6eb; color: var(--ok); }
.badge.orange { background: #fff2dc; color: var(--warn); } .badge.blue { background: var(--brand-l); color: var(--brand); }
.badge.purple { background: #efeaff; color: #6a46e5; }
.plat { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.plat i { width: 16px; height: 16px; border-radius: 4px; display: inline-grid; place-items: center; color: #fff; font-style: normal; font-size: 10px; font-weight: 700; }
.plat.shopee i { background: var(--shopee); } .plat.tiktok i { background: var(--tiktok); } .plat.demo i { background: var(--demo); } .plat.manual i { background: var(--manual); }
.items-cell .it { display: flex; gap: 6px; margin-bottom: 4px; } .items-cell .it:last-child { margin-bottom: 0; }

.pager { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.bulkbar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfd; flex-wrap: wrap; }

/* ---------- modal, drawer, toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 27, 45, .45); display: flex; align-items: flex-start; justify-content: center; z-index: 50; padding: 50px 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 560px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal.wide { max-width: 860px; }
.modal-h { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); } .modal-h h2 { margin: 0; flex: 1; }
.modal-b { padding: 18px; } .modal-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.x { border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.toasts { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1d2433; color: #fff; padding: 10px 16px; border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 420px; animation: tin .2s; }
.toast.err { background: var(--err); } .toast.ok { background: var(--ok); }
@keyframes tin { from { transform: translateY(-8px); opacity: 0; } }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #0f1b2d, #1f3a66); padding: 20px; }
.login-box { background: #fff; border-radius: 12px; padding: 32px; width: 100%; max-width: 380px; }
.login-box .logo { color: var(--text); padding: 0 0 18px; }

/* ---------- chat ---------- */
.chat { display: grid; grid-template-columns: 300px 1fr 300px; height: calc(100vh - 56px - 40px); min-height: 520px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.chat-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.chat-list .head { padding: 10px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.chat-list .items { overflow-y: auto; flex: 1; }
.conv { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid #f0f2f5; cursor: pointer; }
.conv:hover { background: #f8f9fb; } .conv.active { background: var(--brand-l); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #dfe6f2; display: grid; place-items: center; font-weight: 700; color: #4a5a75; flex-shrink: 0; }
.conv .meta { flex: 1; min-width: 0; } .conv .name { font-weight: 600; display: flex; gap: 6px; align-items: center; }
.conv .last { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-main { display: flex; flex-direction: column; min-height: 0; }
.chat-main .head { padding: 10px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.msgs { flex: 1; overflow-y: auto; padding: 16px; background: #f6f8fb; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 70%; padding: 8px 12px; border-radius: 12px; background: #fff; border: 1px solid var(--line); white-space: pre-wrap; word-wrap: break-word; }
.msg.seller, .msg.ai { align-self: flex-end; background: var(--brand); color: #fff; border-color: var(--brand); }
.msg.ai { background: #6a46e5; border-color: #6a46e5; }
.msg.note { align-self: center; background: #fff8e6; border-color: #f3d58a; color: #7a5b00; font-size: 12px; max-width: 90%; }
.msg .time { font-size: 10px; opacity: .7; margin-top: 2px; text-align: right; }
.composer { border-top: 1px solid var(--line); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.composer textarea { min-height: 60px; }
.qr-pop { border: 1px solid var(--line); border-radius: 6px; max-height: 160px; overflow-y: auto; }
.qr-pop div { padding: 6px 10px; cursor: pointer; font-size: 13px; } .qr-pop div:hover { background: var(--brand-l); }
.chat-side { border-left: 1px solid var(--line); overflow-y: auto; padding: 14px; }
.ai-box { background: #f5f2ff; border: 1px solid #ddd3ff; border-radius: 8px; padding: 10px; margin-bottom: 12px; }

/* ---------- chart ---------- */
.chart svg { width: 100%; height: 220px; display: block; }
.chart .tip { font-size: 12px; color: var(--muted); }
.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.bar-row .bar { flex: 1; height: 8px; background: #eef1f6; border-radius: 4px; overflow: hidden; }
.bar-row .bar span { display: block; height: 100%; background: var(--brand); }

.steps { counter-reset: s; padding-left: 0; list-style: none; } .steps li { counter-increment: s; padding-left: 30px; position: relative; margin-bottom: 10px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 20px; height: 20px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 11px; display: grid; place-items: center; }
code, .code { background: #f2f4f8; border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; }
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; background: var(--brand-l); color: #1d3e7a; } .alert.warn { background: #fff4e0; color: #7a4d00; } .alert.err { background: #fde8e6; color: #8a1c13; }
[hidden] { display: none !important; }
