/* =====================================================================
   Sistem reka bentuk: sidebar biru tua, kad bersih dengan bayang lembut, aksen indigo-ungu,
   mod cerah/gelap. Semua warna melalui token supaya satu tempat mengawal rupa.
   ===================================================================== */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
}

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --surface-3: #eef1f8;
  --text: #0f172a;
  --muted: #5f6b85;
  --border: #e3e8f2;
  --primary: #5a2de8;
  --primary-2: #8b5cf6;
  --primary-ink: #ffffff;
  --primary-soft: #efe9fe;
  --gradient: linear-gradient(135deg, #4f26e6 0%, #8b5cf6 100%);
  --ok: #0f9d6b;
  --ok-soft: #e1f6ee;
  --info: #2b78d4;
  --info-soft: #e4f0fc;
  --danger: #d12c1f;
  --danger-soft: #fdebe9;
  --warn: #a35a00;
  --warn-soft: #fff3d9;
  --bubble-in: #ffffff;
  --bubble-out: #e3e7ff;
  --chart: #5a2de8;
  --chart-2: #8b5cf6;
  --chart-3: #22a6b3;
  --chart-4: #f59e0b;
  --chart-5: #e5484d;
  --c-buttons: #2b78d4;
  --c-text: #b7791f;
  --c-handoff: #d12c1f;
  --c-end: #6b7794;
  --nav-bg: #0b1224;
  --nav-bg-2: #111a33;
  --nav-text: #a9b4cf;
  --nav-muted: #6a7798;
  --nav-hover: rgba(255, 255, 255, .06);
  --nav-active: rgba(139, 92, 246, .2);
  --nav-border: rgba(255, 255, 255, .07);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 20px rgba(15, 23, 42, .05);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .18);
  --ring: 0 0 0 3px rgba(90, 45, 232, .22);
  --radius: 14px;
  --radius-sm: 10px;
  --nav-w: 252px;
  --nav-w-collapsed: 72px;
  --top-h: 64px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #080d1a;
  --surface: #0f1729;
  --surface-2: #131d33;
  --surface-3: #18243d;
  --text: #e8ecf7;
  --muted: #8f9bb8;
  --border: #1d2944;
  --primary: #9a82ff;
  --primary-2: #b18bff;
  --primary-ink: #0a0f1f;
  --primary-soft: #221b4f;
  --gradient: linear-gradient(135deg, #7a55ff 0%, #a67cff 100%);
  --ok: #3ccf98;
  --ok-soft: #11342a;
  --info: #6aa8f0;
  --info-soft: #122a47;
  --danger: #ff8d85;
  --danger-soft: #3b1c1b;
  --warn: #f3c46d;
  --warn-soft: #3a2e14;
  --bubble-in: #172139;
  --bubble-out: #232a5e;
  --chart: #9a82ff;
  --chart-2: #b18bff;
  --chart-3: #4fd1dc;
  --chart-4: #f7b955;
  --chart-5: #ff7e84;
  --c-buttons: #6aa8f0;
  --c-text: #f3c46d;
  --c-handoff: #ff8d85;
  --c-end: #8f9bb8;
  --nav-bg: #060a16;
  --nav-bg-2: #0b1224;
  --nav-border: rgba(255, 255, 255, .06);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
  --ring: 0 0 0 3px rgba(140, 140, 255, .3);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #080d1a; --surface: #0f1729; --surface-2: #131d33; --surface-3: #18243d;
    --text: #e8ecf7; --muted: #8f9bb8; --border: #1d2944;
    --primary: #9a82ff; --primary-2: #b18bff; --primary-ink: #0a0f1f; --primary-soft: #221b4f;
    --gradient: linear-gradient(135deg, #7a55ff 0%, #a67cff 100%);
    --ok: #3ccf98; --ok-soft: #11342a; --info: #6aa8f0; --info-soft: #122a47;
    --danger: #ff8d85; --danger-soft: #3b1c1b; --warn: #f3c46d; --warn-soft: #3a2e14;
    --bubble-in: #172139; --bubble-out: #232a5e;
    --chart: #9a82ff; --chart-2: #b18bff; --chart-3: #4fd1dc; --chart-4: #f7b955; --chart-5: #ff7e84;
    --c-buttons: #6aa8f0; --c-text: #f3c46d; --c-handoff: #ff8d85; --c-end: #8f9bb8;
    --nav-bg: #060a16; --nav-bg-2: #0b1224; --nav-border: rgba(255, 255, 255, .06);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
    --ring: 0 0 0 3px rgba(140, 140, 255, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.02rem; font-weight: 650; }
h3 { font-size: .93rem; font-weight: 650; }
p { margin: 0 0 .6rem; }
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
::selection { background: var(--primary-soft); }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ico.lg { width: 22px; height: 22px; }

/* ---------- butang & borang ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 40px; padding: 0 1rem; border-radius: var(--radius-sm); cursor: pointer; font-weight: 550;
  border: 1px solid var(--border); background: var(--surface); text-decoration: none; color: var(--text);
  box-shadow: var(--shadow-sm); transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--gradient); color: var(--primary-ink); border-color: transparent; box-shadow: 0 2px 10px rgba(90, 45, 232, .35); }
.btn.primary:hover { filter: brightness(1.07); background: var(--gradient); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 55%, transparent); background: transparent; box-shadow: none; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.small { min-height: 32px; padding: 0 .75rem; font-size: .84rem; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .9rem; }
.field > span, .field > label { font-size: .83rem; font-weight: 600; }
.field .hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
input[type=text], input[type=search], input[type=password], input[type=email], input[type=url], input[type=tel], input[type=number], input[type=time], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; min-height: 40px; padding: .5rem .75rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.check { display: flex; align-items: center; gap: .55rem; min-height: 32px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row > select { width: auto; min-width: 150px; }
.grow { flex: 1; min-width: 0; }
.between { justify-content: space-between; }

/* ---------- kad, lencana ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.15rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.card > h2 { margin-bottom: .85rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .9rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.chip {
  display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .6rem; border-radius: 999px; font-size: .74rem; font-weight: 600;
  background: var(--primary-soft); color: var(--primary); white-space: nowrap;
}
.chip.s-baru { background: var(--info-soft); color: var(--info); }
.chip.s-berminat { background: var(--primary-soft); color: var(--primary); }
.chip.s-demo { background: var(--warn-soft); color: var(--warn); }
.chip.s-closed { background: var(--ok-soft); color: var(--ok); }
.chip.s-tak_berminat { background: var(--danger-soft); color: var(--danger); }
.chip.neutral { background: var(--surface-3); color: var(--muted); }
.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--gradient); color: #fff; font-size: .7rem; font-weight: 700;
}
.notice { padding: .75rem .95rem; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn); font-size: .88rem; border: 1px solid color-mix(in srgb, var(--warn) 22%, transparent); }
.notice.error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.notice.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.notice.info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 22%, transparent); }
.notice a { color: inherit; font-weight: 600; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.spinner { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--primary); animation: spin .7s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- rangka aplikasi ---------- */
.app { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); height: 100dvh; transition: grid-template-columns .2s ease; }
.app[data-sidebar="collapsed"] { grid-template-columns: var(--nav-w-collapsed) minmax(0, 1fr); }
.sidebar {
  display: flex; flex-direction: column; min-height: 0; background: linear-gradient(180deg, var(--nav-bg) 0%, var(--nav-bg-2) 100%);
  color: var(--nav-text); border-right: 1px solid var(--nav-border); z-index: 40;
}
.sb-head { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1.15rem .9rem; min-height: var(--top-h); }
.brand { display: flex; align-items: center; gap: .65rem; color: #fff; text-decoration: none; }
.brand-word { height: 40px; width: auto; display: block; }
.brand-icon { width: 34px; height: 34px; border-radius: 9px; display: none; box-shadow: 0 4px 14px rgba(91, 63, 217, .45); }
.logo { height: 68px; width: auto; display: block; }
.logo-dark { display: none; }
.sb-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: .25rem .8rem 1rem; }
.sb-group { margin-top: 1.1rem; }
.sb-label { padding: 0 .7rem .4rem; font-size: .68rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--nav-muted); white-space: nowrap; }
.nav a, .sb-link {
  position: relative; display: flex; align-items: center; gap: .75rem; padding: .58rem .75rem; border-radius: 10px;
  color: var(--nav-text); text-decoration: none; font-weight: 520; white-space: nowrap; margin-bottom: 2px;
}
.nav a:hover, .sb-link:hover { background: var(--nav-hover); color: #fff; }
.nav a[aria-current="page"], .sb-link[aria-current="page"] { background: var(--nav-active); color: #fff; }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -.8rem; top: 22%; bottom: 22%; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary-2); }
.nav .ico { width: 19px; height: 19px; }
.nav .badge { margin-left: auto; }
.sb-foot { padding: .8rem; border-top: 1px solid var(--nav-border); }
.sb-status {
  display: flex; align-items: center; gap: .65rem; padding: .65rem .75rem; border-radius: 12px; background: rgba(255, 255, 255, .05);
  color: var(--nav-text); text-decoration: none; font-size: .8rem; line-height: 1.3;
}
.sb-status:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.sb-status .dot { flex: none; }
.sb-status b { color: #fff; display: block; font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border); flex: none; align-self: center; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.dot.bad { background: var(--danger); }
.dot.warn { background: var(--chart-4); }
.app[data-sidebar="collapsed"] .brand-word { display: none; }
.app[data-sidebar="collapsed"] .brand-icon { display: block; }
.app[data-sidebar="collapsed"] .sb-label,
.app[data-sidebar="collapsed"] .nav a > span:not(.badge),
.app[data-sidebar="collapsed"] .sb-status > div { display: none; }
.app[data-sidebar="collapsed"] .nav a { justify-content: center; padding-inline: 0; }
.app[data-sidebar="collapsed"] .nav a .badge { position: absolute; top: 2px; right: 8px; margin: 0; min-width: 16px; height: 16px; font-size: .62rem; }
.app[data-sidebar="collapsed"] .sb-head { justify-content: center; padding-inline: 0; }
.app[data-sidebar="collapsed"] .sb-status { justify-content: center; padding-inline: 0; }
.app[data-sidebar="collapsed"] .nav a[aria-current="page"]::before { left: 0; }
.app[data-sidebar="collapsed"] .nav a::after {
  content: attr(data-tip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%); background: var(--text); color: var(--bg);
  padding: .25rem .6rem; border-radius: 8px; font-size: .78rem; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 60;
}
.app[data-sidebar="collapsed"] .nav a:hover::after { opacity: 1; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: .6rem; height: var(--top-h); padding: 0 1.25rem; flex: none;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border); position: relative; z-index: 30;
}
.tb-btn {
  position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; border: 1px solid transparent;
  background: transparent; color: var(--muted); cursor: pointer;
}
.tb-btn:hover { background: var(--surface-3); color: var(--text); }
.tb-btn .ico { width: 20px; height: 20px; }
.tb-btn .pip { position: absolute; top: 8px; right: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--chart-5); border: 2px solid var(--surface); }
.tb-menu-btn { display: none; }
.tb-search {
  display: flex; align-items: center; gap: .6rem; flex: 1; max-width: 460px; height: 40px; padding: 0 .8rem; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); cursor: pointer; text-align: left;
}
.tb-search:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.tb-search > span:not(.kbd) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-search .kbd { flex: none; }
.kbd { font: 600 .72rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; padding: .22rem .4rem; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); }
.tb-spacer { flex: 1; }
.tb-conn { display: inline-flex; align-items: center; gap: .5rem; height: 36px; padding: 0 .8rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: .8rem; font-weight: 600; color: var(--text); text-decoration: none; white-space: nowrap; }
.tb-conn:hover { background: var(--surface-3); }
.tb-create { gap: .4rem; }
.avatar-btn { display: inline-flex; align-items: center; gap: .55rem; height: 40px; padding: 0 .35rem 0 .3rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.avatar-btn:hover { background: var(--surface-2); }
.avatar-btn .avatar { width: 32px; height: 32px; font-size: .78rem; }
.avatar-btn .ico { width: 14px; height: 14px; color: var(--muted); }
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; padding: .4rem; border-radius: 14px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg); z-index: 70;
}
.menu-title { padding: .45rem .65rem .3rem; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.menu-item {
  display: flex; align-items: center; gap: .65rem; width: 100%; padding: .55rem .65rem; border: 0; border-radius: 9px; background: none; cursor: pointer;
  text-align: left; color: var(--text); text-decoration: none; font-size: .88rem;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-3); }
.menu-item .ico { color: var(--muted); }
.menu-item.danger { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: .35rem .2rem; }
.menu.notif { width: min(380px, calc(100vw - 24px)); padding: 0; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
.notif-list { max-height: 380px; overflow: auto; }
.notif-item { display: flex; gap: .7rem; padding: .75rem 1rem; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unseen { background: color-mix(in srgb, var(--primary-soft) 55%, transparent); }
.notif-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary); }
.notif-ico.warn { background: var(--warn-soft); color: var(--warn); }
.notif-ico.bad { background: var(--danger-soft); color: var(--danger); }
.notif-ico.ok { background: var(--ok-soft); color: var(--ok); }
.notif-body { min-width: 0; }
.notif-body b { display: block; font-size: .87rem; }
.notif-body span { color: var(--muted); font-size: .8rem; }
.notif-empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }
.view { flex: 1; min-height: 0; overflow: auto; padding: 1.5rem; min-width: 0; }
.view.flush { padding: 0; overflow: hidden; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head p { margin: .15rem 0 0; color: var(--muted); font-size: .9rem; }
.page { max-width: 1240px; margin: 0 auto; }
.page.narrow { max-width: 980px; }
.scrim { display: none; }

/* palet arahan (Ctrl+K) */
dialog.palette { width: min(640px, calc(100vw - 24px)); margin-top: 12vh; border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden; }
.pal-input { display: flex; align-items: center; gap: .7rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); color: var(--muted); }
.pal-input input { border: 0; background: transparent; min-height: 28px; padding: 0; box-shadow: none !important; font-size: 1rem; color: var(--text); }
.pal-list { max-height: min(55vh, 420px); overflow: auto; padding: .4rem; }
.pal-group { padding: .55rem .7rem .25rem; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.pal-item { display: flex; align-items: center; gap: .75rem; width: 100%; padding: .6rem .7rem; border: 0; border-radius: 10px; background: none; cursor: pointer; text-align: left; color: var(--text); }
.pal-item .ico { color: var(--muted); }
.pal-item[aria-selected="true"] { background: var(--primary-soft); }
.pal-item[aria-selected="true"] .ico { color: var(--primary); }
.pal-item small { margin-left: auto; color: var(--muted); }
.pal-foot { display: flex; gap: 1rem; padding: .6rem 1rem; border-top: 1px solid var(--border); color: var(--muted); font-size: .76rem; background: var(--surface-2); }

/* ---------- dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.kpi { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); overflow: hidden; }
.kpi > a { text-decoration: none; color: inherit; display: flex; flex-direction: column; flex: 1; }
.kpi-top { flex: 1; align-items: flex-start; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .55rem; }
.kpi .l { color: var(--muted); font-size: .84rem; font-weight: 550; }
.kpi .v { font-size: 1.75rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .v.money { font-size: 1.5rem; white-space: nowrap; }
.kpi-ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.kpi-ico.ok { background: var(--ok-soft); color: var(--ok); }
.kpi-ico.warn { background: var(--warn-soft); color: var(--warn); }
.kpi-ico.info { background: var(--info-soft); color: var(--info); }
.kpi-ico.bad { background: var(--danger-soft); color: var(--danger); }
.kpi-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .5rem; min-height: 28px; }
.kpi-foot:empty, .kpi-foot:has(> span:empty:only-child) { display: none; }
.delta { display: inline-flex; align-items: center; gap: .2rem; font-size: .78rem; font-weight: 650; padding: .1rem .45rem; border-radius: 999px; }
.delta.up { background: var(--ok-soft); color: var(--ok); }
.delta.down { background: var(--danger-soft); color: var(--danger); }
.delta.flat { background: var(--surface-3); color: var(--muted); }
.spark { width: 92px; height: 30px; display: block; flex: none; }
.spark path.line { fill: none; stroke: var(--chart); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark path.area { fill: var(--chart); opacity: .12; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.two > .card + .card { margin-top: 0; }
.three { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; margin-top: 1rem; }
.three > .card + .card { margin-top: 0; }
.two > *, .three > * { min-width: 0; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .bar { fill: var(--chart); }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart .grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; opacity: .8; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart text.val { fill: var(--text); font-weight: 600; }
.chart .area { fill: url(#areaGrad); }
.chart .line { fill: none; stroke: var(--chart); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.chart .hit { fill: transparent; }
.chart .hit:hover + .pt, .chart g:hover .pt { opacity: 1; }
.chart .pt { fill: var(--surface); stroke: var(--chart); stroke-width: 2.4; opacity: 0; pointer-events: none; }
.chart .guide { stroke: var(--primary); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; pointer-events: none; }
.chart g:hover .guide { opacity: .6; }
.stop-a { stop-color: var(--chart); stop-opacity: .32; }
.stop-b { stop-color: var(--chart); stop-opacity: 0; }
.chart-tip {
  position: fixed; z-index: 90; pointer-events: none; padding: .4rem .65rem; border-radius: 9px; background: var(--text); color: var(--bg);
  font-size: .78rem; line-height: 1.35; box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .1s; max-width: 240px;
}
.chart-tip b { display: block; }
.donut-wrap { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.donut { width: 160px; height: 160px; flex: none; }
.donut circle.seg { fill: none; stroke-width: 18; }
.donut circle.base { fill: none; stroke: var(--surface-3); stroke-width: 18; }
.donut text.c { fill: var(--text); font-size: 26px; font-weight: 700; text-anchor: middle; }
.donut text.s { fill: var(--muted); font-size: 11px; text-anchor: middle; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; flex: 1; min-width: 150px; }
.legend li { display: flex; align-items: center; gap: .55rem; font-size: .88rem; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend b { margin-left: auto; font-variant-numeric: tabular-nums; }
.legend i.c1, .donut circle.seg.c1 { background: var(--chart); stroke: var(--chart); }
.legend i.c2, .donut circle.seg.c2 { background: var(--chart-2); stroke: var(--chart-2); }
.legend i.c3, .donut circle.seg.c3 { background: var(--chart-3); stroke: var(--chart-3); }
.legend i.c4, .donut circle.seg.c4 { background: var(--chart-4); stroke: var(--chart-4); }
.legend i.c5, .donut circle.seg.c5 { background: var(--chart-5); stroke: var(--chart-5); }
.donut circle.seg { cursor: pointer; transition: stroke-width .12s; }
.donut circle.seg:hover { stroke-width: 22; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .7rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; background: var(--surface-2); }
th:first-child { border-top-left-radius: 9px; border-bottom-left-radius: 9px; }
th:last-child { border-top-right-radius: 9px; border-bottom-right-radius: 9px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.link { cursor: pointer; }
tr.link:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
.row + .table-wrap { margin-top: .9rem; }
.statbars { display: grid; gap: .7rem; }
.statbar { display: grid; grid-template-columns: 110px 1fr 36px; gap: .6rem; align-items: center; font-size: .88rem; }
.statbar svg { width: 100%; height: 10px; display: block; }
.statbar .track { fill: var(--surface-3); }
.statbar .fill { fill: var(--chart); }
.recent { display: grid; gap: .1rem; }
.recent a { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: .7rem; align-items: center; padding: .55rem .4rem; border-radius: 10px; color: var(--text); text-decoration: none; }
.recent a:hover { background: var(--surface-2); }
.recent .avatar { width: 38px; height: 38px; font-size: .82rem; }
.recent .nm { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent .pv { color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent .tm { color: var(--muted); font-size: .75rem; }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; }
.quick a { display: flex; align-items: center; gap: .6rem; padding: .7rem .8rem; border: 1px solid var(--border); border-radius: 12px; text-decoration: none; color: var(--text); font-weight: 550; font-size: .88rem; background: var(--surface-2); }
.quick a:hover { border-color: var(--primary); background: var(--primary-soft); }
.quick .ico { color: var(--primary); }

/* ---------- inbox ---------- */
.inbox { display: grid; grid-template-columns: 350px minmax(0, 1fr); height: 100%; }
.inbox.has-info { grid-template-columns: 350px minmax(0, 1fr) 330px; }
.inbox-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); background: var(--surface); }
.list-head { padding: .85rem; display: grid; gap: .65rem; border-bottom: 1px solid var(--border); }
.seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-2); }
.seg button { flex: 1; min-height: 32px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-size: .84rem; font-weight: 550; color: var(--muted); }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--primary); font-weight: 650; box-shadow: var(--shadow-sm); }
#clist { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; }
.citem {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: .7rem; align-items: center;
  padding: .8rem .9rem; border-bottom: 1px solid var(--border); cursor: pointer; width: 100%;
  background: none; border-left: 3px solid transparent; border-right: 0; border-top: 0; text-align: left;
}
.citem:hover { background: var(--surface-2); }
.citem[aria-current="true"] { background: var(--primary-soft); border-left-color: var(--primary); }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--gradient); color: #fff; font-weight: 650; font-size: .9rem;
}
.avatar.lg { width: 56px; height: 56px; font-size: 1.2rem; }
.citem .t { display: flex; gap: .4rem; align-items: baseline; justify-content: space-between; }
.citem .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.citem .mid { display: block; min-width: 0; }
.citem .pv { display: block; color: var(--muted); font-size: .84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.citem .when { color: var(--muted); font-size: .74rem; white-space: nowrap; }
.citem .side { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; }
.citem.unread .name, .citem.unread .pv { color: var(--text); font-weight: 700; }

.inbox-chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg); }
.chat-empty { margin: auto; text-align: center; color: var(--muted); padding: 1rem; }
.chat-head { display: flex; align-items: center; gap: .7rem; padding: .7rem .9rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.chat-head .who { min-width: 0; flex: 1; }
.chat-head .who b, .chat-head .who span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { width: 40px; height: 40px; border-radius: 11px; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn[aria-pressed="true"] { color: var(--primary); background: var(--primary-soft); }
#back-btn { display: none; }
.msgs { flex: 1; overflow: auto; padding: 1.1rem .9rem; display: flex; flex-direction: column; gap: .4rem; }
.day-sep { align-self: center; font-size: .74rem; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .12rem .75rem; margin: .6rem 0; }
.msg { max-width: min(76%, 580px); padding: .55rem .8rem .4rem; border-radius: 16px; border: 1px solid var(--border); overflow-wrap: anywhere; box-shadow: var(--shadow-sm); }
.msg .text { white-space: pre-wrap; }
.msg.in { align-self: flex-start; background: var(--bubble-in); border-top-left-radius: 5px; }
.msg.out { align-self: flex-end; background: var(--bubble-out); border-top-right-radius: 5px; border-color: color-mix(in srgb, var(--primary) 18%, var(--border)); }
.msg .meta { display: flex; justify-content: flex-end; gap: .5rem; font-size: .7rem; color: var(--muted); margin-top: .15rem; white-space: normal; }
.msg .who-tag { font-weight: 650; }
.msg.failed { border-color: var(--danger); }
.msg .err { color: var(--danger); }
.chat-banner { margin: .5rem .75rem 0; }
.composer { display: flex; flex-wrap: wrap; gap: .55rem; padding: .7rem .9rem calc(.7rem + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); align-items: flex-end; }
.composer textarea { min-height: 44px; max-height: 140px; resize: none; border-radius: 14px; flex: 1; min-width: 0; }
.composer .btn { min-height: 44px; border-radius: 12px; }

.info { display: none; overflow: auto; background: var(--surface); border-left: 1px solid var(--border); padding: 1.1rem; }
.inbox.has-info .info { display: block; }
.info-top { display: flex; align-items: center; gap: .8rem; margin-bottom: 1rem; }
.info h3 { margin: 1.1rem 0 .5rem; }
.tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .5rem; }
.tag { display: inline-flex; align-items: center; gap: .25rem; padding: .1rem .2rem .1rem .65rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: .8rem; font-weight: 600; }
.tag button { border: 0; background: none; cursor: pointer; color: inherit; width: 22px; height: 22px; border-radius: 50%; }
.src { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .75rem; font-size: .85rem; margin-bottom: .5rem; background: var(--surface-2); overflow-wrap: anywhere; }

/* ---------- peraturan ---------- */
.rule { display: flex; gap: .85rem; align-items: flex-start; padding: .9rem 0; border-bottom: 1px solid var(--border); }
.rule:last-child { border-bottom: 0; }
.rule .body { flex: 1; min-width: 0; }
.rule .reply { color: var(--muted); font-size: .88rem; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 4.4em; overflow: hidden; }
.kw { display: inline-block; font-size: .78rem; padding: 0 .5rem; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); margin: 0 .25rem .25rem 0; }
.switch { position: relative; display: inline-block; vertical-align: middle; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; width: 100%; height: 100%; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: color-mix(in srgb, var(--muted) 35%, var(--border)); transition: background .15s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.switch input:checked + i { background: var(--primary); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 2px solid var(--primary); outline-offset: 2px; }
dialog { border: 1px solid var(--border); border-radius: 18px; padding: 0; width: min(580px, calc(100vw - 24px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(6, 10, 22, .55); backdrop-filter: blur(3px); }
dialog form { padding: 1.25rem; max-height: 88dvh; overflow: auto; }
dialog .actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
dialog .actions .left { margin-right: auto; }

/* ---------- tetapan ---------- */
.hours-row { display: grid; grid-template-columns: 100px minmax(0, 1fr) minmax(0, 1fr); gap: .5rem; align-items: center; margin-bottom: .45rem; }
.hours-row .check { grid-column: 1; }
.hours-row input[type=time] { min-width: 0; }
@media (max-width: 480px) {
  .hours-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .hours-row .check { grid-column: 1 / -1; }
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.copy-row { display: flex; gap: .5rem; align-items: center; }
.copy-row code { flex: 1; min-width: 0; overflow-wrap: anywhere; padding: .5rem .65rem; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); }
.status-list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .45rem; }
.status-list li { display: flex; gap: .55rem; align-items: baseline; }

/* ---------- log masuk ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; position: relative; overflow: hidden; background: var(--nav-bg); }
.login::before, .login::after { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; filter: blur(90px); opacity: .5; pointer-events: none; }
.login::before { background: #5a2de8; top: -180px; left: -140px; }
.login::after { background: #8b5cf6; bottom: -200px; right: -120px; opacity: .4; }
.login form { position: relative; z-index: 1; width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 2rem 1.75rem; box-shadow: var(--shadow-lg); }
.login .brand { padding: 0 0 1.25rem; color: var(--text); }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo-dark { display: block; }
}
.login p.tag-line { color: var(--muted); font-size: .88rem; margin: -.6rem 0 1.25rem; }

#toast { position: fixed; right: 1.25rem; bottom: 1.25rem; display: grid; gap: .5rem; z-index: 100; width: min(400px, calc(100vw - 24px)); pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: .75rem 1rem; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: .88rem; border-left: 4px solid var(--primary-2); animation: toast-in .18s ease; }
.toast.error { background: var(--danger); color: #fff; border-left-color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- broadcast & templat ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.1rem; overflow-x: auto; }
.tabs a { padding: .6rem 1rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--primary); border-bottom-color: var(--primary); }
.chip.b-sending, .chip.t-APPROVED { background: var(--ok-soft); color: var(--ok); }
.chip.b-scheduled, .chip.t-PENDING, .chip.b-paused, .chip.t-PAUSED { background: var(--warn-soft); color: var(--warn); }
.chip.t-REJECTED, .chip.t-DISABLED { background: var(--danger-soft); color: var(--danger); }
.chip.b-draft, .chip.t-DRAFT, .chip.b-cancelled { background: var(--surface-3); color: var(--muted); }
.chip.b-completed { background: var(--text); color: var(--bg); }
.progress { width: 100%; height: 10px; display: block; }
.progress .track { fill: var(--surface-3); }
.progress .fill { fill: var(--chart); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: .7rem; margin: 1rem 0; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: .7rem .9rem; }
.stat .v { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; letter-spacing: -.02em; }
.stat .l { font-size: .8rem; color: var(--muted); }
.stat.bad .v { color: var(--danger); }
.bubble { background: var(--bubble-out); border: 1px solid var(--border); border-radius: 14px; border-top-right-radius: 4px; padding: .7rem .9rem; max-width: 420px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .92rem; }
.bubble .h { font-weight: 700; margin-bottom: .2rem; }
.bubble .f { color: var(--muted); font-size: .8rem; margin-top: .3rem; }
.bubble-btns { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .4rem; max-width: 420px; }
.bubble-btns span { flex: 1; min-width: 90px; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: .3rem .5rem; color: var(--primary); font-weight: 600; font-size: .85rem; }
.tpl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; align-items: start; }
.tpl-meta { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
.tpl-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .6rem; }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.checks { display: flex; flex-wrap: wrap; gap: .3rem 1rem; }
.audience { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: .85rem 1.1rem; margin: .5rem 0 1rem; }
.audience b { font-variant-numeric: tabular-nums; }
.var-row { display: grid; grid-template-columns: 48px 1.2fr 1.4fr 1.4fr; gap: .5rem; align-items: end; margin-bottom: .4rem; }
.var-row .tag-n { font-weight: 700; padding-bottom: .5rem; }
.pill-list { display: flex; flex-wrap: wrap; gap: .3rem; }

/* ---------- iklan Meta & susulan ---------- */
.chip.c-pending, .chip.c-sending { background: var(--warn-soft); color: var(--warn); }
.chip.c-failed { background: var(--danger-soft); color: var(--danger); }
.chip.c-simulated, .chip.c-cancelled, .chip.c-skipped { background: var(--surface-3); color: var(--muted); }
.mode .seg { margin-top: .5rem; }
.seg button { white-space: nowrap; padding: 0 .8rem; }
.kpis.compact { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-top: 1rem; }
.kpis.compact .kpi { padding: .8rem .95rem; }
.kpis.compact .v { font-size: 1.4rem; white-space: nowrap; }
#fu-form h3 { margin-top: 1.2rem; }
#fu-form #add-step { margin-bottom: .4rem; }
.perf td.label { min-width: 220px; }
.perf td.num, .perf th.num { white-space: nowrap; }
.perf tr.total td { font-weight: 700; border-top: 2px solid var(--border); }
.perf tr.organic td { color: var(--muted); }
.map-row { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: .5rem; align-items: center; margin-bottom: .4rem; }
.step-card { border: 1px solid var(--border); border-radius: 12px; padding: .9rem; margin-bottom: .75rem; background: var(--surface-2); }
.step-head { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
.step-head input[type="number"] { width: 90px; }
.step-head select { width: auto; min-width: 150px; }
.mini-list { display: grid; gap: .35rem; margin: .3rem 0 .8rem; }
.mini-list > div { font-size: .85rem; }

/* ---------- flow chatbot ---------- */
.flow-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.flow-grid > *, .flow-side > * { min-width: 0; }
.flow-side { position: sticky; top: 0; display: grid; gap: 1rem; }
.page.wide { max-width: 1440px; }
.node-card > .row { margin-bottom: .6rem; }
.node-card > .row select { width: auto; min-width: 0; max-width: 200px; }
.flow-side .card + .card { margin-top: 0; }
.node-card.flash { outline: 3px solid var(--primary); outline-offset: 2px; }
.opt-box { border: 1px solid var(--border); border-radius: 12px; padding: .65rem; margin-bottom: .5rem; background: var(--surface-2); }
.opt-row { display: grid; grid-template-columns: 1.1fr 1.1fr 1.1fr auto; gap: .4rem; align-items: center; }
.act-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-top: .5rem; }
.act-row label { display: flex; flex-direction: column; gap: .2rem; color: var(--muted); font-size: .78rem; }
.node-card details { margin-top: .6rem; }
.node-card summary { cursor: pointer; }
.diagram-wrap { overflow: auto; max-height: 440px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.diagram { display: block; }
.diagram .dn { cursor: pointer; }
.diagram .dn rect { fill: var(--surface); stroke: var(--border); stroke-width: 1.5; }
.diagram .dn.message rect { stroke: var(--primary); }
.diagram .dn.buttons rect { stroke: var(--c-buttons); }
.diagram .dn.text rect { stroke: var(--c-text); }
.diagram .dn.handoff rect { stroke: var(--c-handoff); }
.diagram .dn.end rect { stroke: var(--c-end); }
.diagram .dn.start rect { stroke-width: 3.5; }
.diagram .dn:focus-visible rect, .diagram .dn:hover rect { fill: var(--primary-soft); }
.diagram text { font-family: inherit; }
.diagram .dn-id { font-size: 10px; font-weight: 700; fill: var(--muted); }
.diagram .dn-tx { font-size: 11px; fill: var(--text); }
.diagram .dn-st { font-size: 9px; fill: var(--muted); }
.diagram .edge { fill: none; stroke: var(--muted); stroke-width: 1.4; }
.diagram .edge.dashed { stroke-dasharray: 4 3; }
.diagram .arrow { fill: var(--muted); }
.diagram .elabel { font-size: 9px; fill: var(--muted); paint-order: stroke; stroke: var(--surface-2); stroke-width: 3px; }
.tester { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: .7rem; height: 290px; overflow: auto; display: flex; flex-direction: column; gap: .4rem; margin: .6rem 0; }
.tmsg { max-width: 88%; padding: .45rem .7rem; border-radius: 12px; border: 1px solid var(--border); white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9rem; }
.tmsg.bot { align-self: flex-start; background: var(--bubble-in); }
.tmsg.user { align-self: flex-end; background: var(--bubble-out); }
.tchips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .45rem; }
.tchip { border: 1px solid var(--primary); color: var(--primary); background: var(--surface); border-radius: 999px; padding: .25rem .8rem; cursor: pointer; font-size: .85rem; }
.tchip:hover { background: var(--primary-soft); }
.tend { align-self: center; color: var(--muted); font-size: .8rem; margin-top: .3rem; }
.notice ul { margin: .3rem 0 0; padding-left: 1.2rem; }

/* ---------- backup ---------- */
.bk-list { margin: .5rem 0 1rem; }
.bk-item { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; padding: .75rem 0; border-bottom: 1px solid var(--border); }
.bk-item:last-child { border-bottom: 0; }
.bk-info { min-width: 0; }

/* lajur perbualan memenuhi ketinggian supaya mesej boleh tatal dan kotak tulis kekal di bawah */
.chat-col { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* Sambungan WhatsApp melalui kod QR */
.wa-tabs { display: flex; width: 100%; margin: .25rem 0 1rem; }
.wa-tabs button { white-space: normal; line-height: 1.25; padding: .45rem .6rem; }
.qr-box { display: block; width: fit-content; max-width: 100%; margin: .25rem auto 1rem; padding: .75rem; background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.qr-img { display: block; max-width: 100%; height: auto; image-rendering: pixelated; }

/* ---------- responsif ---------- */
@media (max-width: 1180px) {
  .inbox.has-info { grid-template-columns: 330px minmax(0, 1fr); }
  .inbox.has-info .info { position: fixed; inset: 0 0 0 auto; width: min(360px, 100vw); z-index: 55; box-shadow: -8px 0 30px rgba(0, 0, 0, .25); }
  .three { grid-template-columns: 1fr; }
}
@media (max-width: 1000px) {
  .tb-conn span.lbl { display: none; }
  .tb-search .kbd { display: none; }
}
@media (max-width: 860px) {
  .app, .app[data-sidebar="collapsed"] { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(290px, 86vw); transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-lg);
  }
  .app.drawer-open .sidebar { transform: none; }
  .app.drawer-open .scrim { display: block; position: fixed; inset: 0; background: rgba(6, 10, 22, .5); z-index: 35; backdrop-filter: blur(2px); }
  .app[data-sidebar="collapsed"] .brand-word { display: block; }
  .app[data-sidebar="collapsed"] .brand-icon { display: none; }
  .app[data-sidebar="collapsed"] .sb-label,
  .app[data-sidebar="collapsed"] .nav a > span:not(.badge),
  .app[data-sidebar="collapsed"] .sb-status > div { display: revert; }
  .app[data-sidebar="collapsed"] .nav a { justify-content: flex-start; padding-inline: .75rem; }
  .app[data-sidebar="collapsed"] .nav a::after { display: none; }
  .app[data-sidebar="collapsed"] .sb-head { justify-content: flex-start; padding-inline: 1.15rem; }
  .tb-menu-btn { display: grid; }
  .tb-collapse { display: none; }
  .topbar { padding: 0 .75rem; gap: .4rem; }
  .tb-search { max-width: none; }
  .tb-search span { display: none; }
  .tb-search { flex: none; width: 40px; padding: 0; justify-content: center; }
  .tb-create span, .avatar-btn .ico { display: none; }
  .app.chat-open .topbar { display: none; }
  .view { padding: 1rem; }
  .view.flush { padding: 0; }
  .inbox, .inbox.has-info { grid-template-columns: 1fr; position: relative; }
  .inbox .inbox-chat { display: none; }
  .inbox.show-chat .inbox-chat { display: flex; }
  .inbox.show-chat .inbox-list { display: none; }
  #back-btn { display: grid; }
  .inbox.has-info .info { width: 100vw; }
  .two, .three { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .msg { max-width: 88%; }
  #toast { right: .75rem; left: .75rem; bottom: .75rem; width: auto; }
  .filter-grid, .flow-grid { grid-template-columns: 1fr; }
  .flow-side { position: static; }
  .opt-row, .act-row { grid-template-columns: 1fr; }
  .tpl { grid-template-columns: 1fr; }
  .var-row { grid-template-columns: 1fr; }
  .var-row .tag-n { padding-bottom: 0; }
  .map-row { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
  .kpi .v { font-size: 1.45rem; }
  .spark { width: 70px; }
  .page-head h1 { font-size: 1.3rem; }
}
@media (max-width: 420px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .tb-conn { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- AI (Fasa 6) ---------- */
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.bad { background: var(--danger-soft); color: var(--danger); }
.chip.sky { background: var(--info-soft); color: var(--info); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.row.between { justify-content: space-between; }
.off { opacity: .6; }
ul.plain { margin: 0 0 .6rem; padding-left: 1.1rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: 0 0 1rem; font-size: .88rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* belanjawan */
progress.meter { appearance: none; -webkit-appearance: none; width: 100%; height: 12px; border: 0; border-radius: 999px; overflow: hidden; background: var(--surface-3); display: block; margin: .25rem 0 .6rem; }
progress.meter::-webkit-progress-bar { background: var(--surface-3); border-radius: 999px; }
progress.meter::-webkit-progress-value { background: var(--gradient); border-radius: 999px; }
progress.meter::-moz-progress-bar { background: var(--gradient); border-radius: 999px; }
progress.meter.warn::-webkit-progress-value { background: var(--warn); }
progress.meter.warn::-moz-progress-bar { background: var(--warn); }
progress.meter.bad::-webkit-progress-value { background: var(--danger); }
progress.meter.bad::-moz-progress-bar { background: var(--danger); }

/* ejen */
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem; }
.agent-grid > .card { margin: 0; display: flex; flex-direction: column; gap: .6rem; }
.agent-head { display: flex; gap: .75rem; align-items: flex-start; }
.agent-ico { width: 38px; height: 38px; flex: none; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.agent-ico svg { width: 20px; height: 20px; }
.agent-meta { display: flex; flex-wrap: wrap; gap: .4rem; }
.agent-body { margin: 0; color: var(--muted); font-size: .88rem; white-space: pre-wrap; overflow-wrap: anywhere; flex: 1; }
.agent-actions { margin-top: .25rem; }
.agent-actions .btn svg { width: 15px; height: 15px; margin-right: .3rem; }
fieldset.scope { border: 0; padding: 0; margin: 0 0 .9rem; }
fieldset.scope legend { font-size: .83rem; font-weight: 600; padding: 0; margin-bottom: .35rem; }
.scope-list { display: flex; flex-direction: column; gap: .2rem; max-height: 180px; overflow: auto; padding: .5rem .7rem; border: 1px solid var(--border); border-radius: 10px; margin-top: .4rem; }

/* playground */
.pg { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 1rem; align-items: start; }
.pg-chat { display: flex; flex-direction: column; padding: 0; overflow: hidden; margin: 0; min-height: 520px; }
.pg-msgs { flex: 1; min-height: 360px; max-height: 60vh; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .6rem; background: var(--chat-bg, var(--surface-2)); }
.pg-msg { max-width: min(82%, 560px); padding: .55rem .8rem; border-radius: 16px; border: 1px solid var(--border); overflow-wrap: anywhere; box-shadow: var(--shadow-sm); }
.pg-msg .text { white-space: pre-wrap; }
.pg-msg.user { align-self: flex-start; background: var(--bubble-in); border-top-left-radius: 5px; }
.pg-msg.assistant { align-self: flex-end; background: var(--bubble-out); border-top-right-radius: 5px; border-color: color-mix(in srgb, var(--primary) 18%, var(--border)); }
.pg-msg .meta { font-size: .74rem; color: var(--muted); margin-top: .3rem; }
.pg-note { align-self: center; max-width: 90%; font-size: .82rem; padding: .35rem .75rem; border-radius: 999px; background: var(--surface-3); color: var(--muted); text-align: center; }
.pg-note.warn { background: var(--warn-soft); color: var(--warn); }
.pg-note.error { background: var(--danger-soft); color: var(--danger); }
.pg-compose { display: flex; gap: .55rem; padding: .7rem; border-top: 1px solid var(--border); background: var(--surface); align-items: flex-end; }
.pg-compose textarea { flex: 1; min-width: 0; resize: none; border-radius: 12px; }
.pg-compose .btn { min-height: 44px; }
.pg-compose .btn svg { width: 16px; height: 16px; margin-right: .35rem; }
.pg-side > .card { margin: 0 0 1rem; }
.prompt-view { max-height: 320px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .76rem; padding: .7rem; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); margin-top: .5rem; }

/* cadangan AI dalam Inbox */
.ai-strip { flex: 0 0 100%; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.ai-strip select { width: auto; max-width: 220px; min-height: 32px; font-size: .84rem; padding: .15rem .5rem; }
.ai-btn { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); background: var(--primary-soft); }
.ai-btn svg { width: 15px; height: 15px; margin-right: .35rem; }
.ai-info { color: var(--muted); display: inline-flex; align-items: center; gap: .4rem; flex-wrap: wrap; min-width: 0; }
.who-tag.ai { color: var(--primary); display: inline-flex; align-items: center; gap: .2rem; }
.who-tag.ai svg { width: 11px; height: 11px; }

@media (max-width: 1000px) {
  .pg { grid-template-columns: 1fr; }
  .agent-grid { grid-template-columns: 1fr; }
}
#ai-card h3 { margin: 1.3rem 0 .55rem; }
#ai-card form > .btn.primary + a { margin-left: .85rem; }
.ai-key-form { margin-top: .7rem; }
.ai-key-form .field > label { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* ---------- akaun: log masuk / daftar / tetap semula ---------- */
.login-title { font-size: 1.3rem; margin: 0 0 .35rem; }
.login .btn.block { width: 100%; justify-content: center; margin-top: .25rem; }
.login .field .hint { font-size: .78rem; }
.login form p.hint { margin: -.55rem 0 .9rem; font-size: .78rem; color: var(--muted); }
.login .check.small { margin: -.2rem 0 1rem; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); cursor: pointer; font: inherit; text-decoration: underline; }
.link-btn:hover { filter: brightness(1.15); }
.menu-sub { padding: 0 .65rem .45rem; font-size: .78rem; color: var(--muted); overflow-wrap: anywhere; }
#account-card h3 { margin: 1.3rem 0 .55rem; }
#account-card #logout { margin-top: 1.1rem; }
#account-card button + .hint { margin-left: .7rem; color: var(--muted); font-size: .82rem; }
