/* Nabawi CRM: tema gelap & terang. Palet brand deck Nabawi Scent: emas #DDA942, coklat #7A6043, maroon #812739, coklat tua #441E18. */
:root {
  --bg: #1C0E0B;
  --bg-2: #24120E;
  --panel: rgba(44, 24, 20, 0.84);
  --panel-solid: #2C1814;
  --panel-2: rgba(255, 255, 255, 0.035);
  --line: rgba(221, 169, 66, 0.14);
  --line-strong: rgba(221, 169, 66, 0.3);
  --text: #F5ECDF;
  --muted: #B09A80;
  --dim: #7F6A58;
  --cyan: #22d3ee;
  --violet: #8b5cf6;
  --pink: #f472b6;
  --accent: #DDA942; --accent-hover: #E8B957; --accent-soft: rgba(221, 169, 66, 0.16); --nav-active: rgba(221, 169, 66, 0.12);
  --grad: var(--accent);
  --ok: #34d399; --ok-bg: rgba(52, 211, 153, 0.12);
  --warn: #fbbf24; --warn-bg: rgba(251, 191, 36, 0.12);
  --bad: #fb7185; --bad-bg: rgba(251, 113, 133, 0.13);
  --info: #DDA942; --info-bg: rgba(221, 169, 66, 0.1);
  --bubble-in: #2F1C16; --bubble-out: #4A2430; --bubble-out-line: rgba(129, 39, 57, 0.7);
  --radius: 12px;
  --shadow: 0 10px 40px -18px rgba(0, 0, 0, 0.8);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Cormorant Garamond", Georgia, serif; /* serif elegan, mengikuti wordmark brand deck */
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --strong: #ffffff;
  --nav-text: #DACBB6;
  --chrome: rgba(28, 14, 11, 0.9);
  --chrome-solid: rgba(28, 14, 11, 0.98);
  --glass: rgba(28, 14, 11, 0.6);
  --input-bg: rgba(16, 8, 6, 0.6);
  --toast-bg: rgba(44, 24, 20, 0.97); --toast-bad: rgba(60, 14, 26, 0.96); --toast-warn: rgba(52, 36, 8, 0.96);
  --info-text: #EBD9B4; --warn-text: #fde68a; --bad-text: #fecdd3; --ok-text: #a7f3d0;
  --count-text: #fecdd3; --cyan-text: #67e8f9; --violet-text: #c4b5fd;
  --grid-line: rgba(221, 169, 66, 0.05);
  /* data-viz: seri kategori (urutan tetap, lolos uji buta warna) + grid/sumbu */
  --s1: #DDA942; --s2: #B8465E; --track: rgba(221, 169, 66, 0.16);
  --viz-grid: rgba(221, 169, 66, 0.12); --viz-axis: #B09A80; --accent-text: #EBC46A;
  color-scheme: dark;
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; font-feature-settings: "cv11";
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--accent-soft); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 214, 0.18); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- kerangka ---------- */
#app { position: relative; z-index: 1; }
.layout { display: grid; grid-template-columns: 248px 1fr; height: 100vh; height: 100dvh; }
.side {
  background: var(--chrome); border-right: 1px solid var(--line);
  padding: 14px 10px; overflow-y: auto; display: flex; flex-direction: column;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 14px; }
.brand .logo { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.brand .logo { overflow: hidden; background: none; }
.brand b { font-family: var(--font); font-size: 15px; font-weight: 650; letter-spacing: -0.01em; display: block; color: var(--strong); line-height: 1.25; }
.brand small { color: var(--muted); font-size: 12px; }
.nav-group { font-size: 12px; color: var(--dim); padding: 18px 10px 4px; font-weight: 500; }
.nav { display: grid; gap: 1px; }
.nav a {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: 8px; color: var(--nav-text);
  font-size: 13.5px; position: relative; transition: background .12s, color .12s;
}
.nav a svg { width: 17px; height: 17px; flex: none; opacity: 0.75; }
.nav a span.l { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a:hover { background: var(--nav-active); color: var(--strong); text-decoration: none; }
.nav a.active { background: var(--nav-active); color: var(--strong); font-weight: 550; }
.nav a.active svg { opacity: 1; color: var(--accent); }
.count { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); border-radius: 999px; font-size: 11px; padding: 0 7px; line-height: 18px; min-width: 22px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.count.cyan { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.nav a.active .count { background: var(--panel-solid); }
.side .me { margin-top: auto; padding: 10px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; font-weight: 600; font-size: 12.5px; color: #fff; flex: none; }
.side .me .who { flex: 1; min-width: 0; font-size: 12.5px; }
.side .me .who small { color: var(--muted); display: block; }
.main { overflow-y: auto; padding: 24px 28px 40px; min-width: 0; }
.main.flush { padding: 0; overflow: hidden; }
.topbar { display: none; }

/* ---------- tipografi ---------- */
h1 { font-family: var(--font); font-size: 24px; font-weight: 650; margin: 0; letter-spacing: -0.02em; }
h2 { font-family: var(--font); font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h3 { font-size: 13px; font-weight: 600; margin: 0; color: var(--muted); }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { color: var(--muted); font-size: 13px; flex: 0 0 100%; margin-top: -6px; line-height: 1.5; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 12px; }
.mono, .num { font-family: var(--font); font-variant-numeric: tabular-nums; letter-spacing: -0.005em; }
.grad-text { color: var(--accent-text); font-weight: 600; }

/* ---------- panel ---------- */
.card {
  background: var(--panel-solid); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); position: relative; min-width: 0;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.stat { padding: 16px; }
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat .v { font-family: var(--font); font-size: clamp(20px, 0.9vw + 13px, 26px); font-weight: 600; margin-top: 6px; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; color: var(--strong); }
.stat .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }
.sep { height: 1px; background: var(--line); margin: 14px 0; }

/* ---------- tombol & input ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--panel-solid);
  border-radius: 8px; height: 34px; padding: 0 12px; cursor: pointer; font-size: 13px; font-weight: 500; white-space: nowrap; transition: background .12s, border-color .12s; color: var(--text);
}
.btn:hover { background: var(--nav-active); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ok { color: var(--ok); border-color: rgba(52, 211, 153, 0.4); }
.btn.danger { color: var(--bad); border-color: rgba(251, 113, 133, 0.35); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 28px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: 0.45; cursor: default; filter: none; }
.icon-btn { width: 34px; padding: 0; justify-content: center; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=date], input[type=time], input[type=url], input[type=tel], select, textarea {
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 11px; background: var(--input-bg); width: 100%; transition: border .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--dim); }
select option { background: var(--panel-solid); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; }
textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
label.field { display: block; margin-bottom: 12px; min-width: 0; }
label.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
label.check { display: block; position: relative; padding-left: 24px; cursor: pointer; font-size: 13px; line-height: 1.45; }
label.check > input[type=checkbox], label.check > input[type=radio] { position: absolute; left: 0; top: 1px; margin: 0; }
.hint { font-size: 11.5px; color: var(--dim); margin-top: 4px; line-height: 1.45; }
.inline { display: inline-flex; width: auto; }
.money { position: relative; }
.money::before { content: "Rp"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--dim); font-size: 12px; }
.money input { padding-left: 32px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- chip / status ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; line-height: 20px; padding: 0 7px; border-radius: 6px; background: var(--nav-active); color: var(--muted); white-space: nowrap; border: 0; font-weight: 500; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.violet { background: rgba(139, 92, 246, 0.14); color: var(--violet-text); }
.badge.ctwa { background: rgba(236, 72, 153, 0.14); color: #db2777; }
.badge.cyan { background: rgba(34, 211, 238, 0.12); color: var(--cyan-text); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); display: inline-block; flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
@keyframes pulse { 50% { opacity: 0.45; } }

/* ---------- tabel ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel-solid); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 13px; }
th { font-size: 12px; color: var(--muted); font-weight: 500; background: var(--panel-2); position: sticky; top: 0; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--panel-2); }
tr.click { cursor: pointer; }
td.r, th.r { text-align: right; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 36px; height: 36px; opacity: 0.4; display: block; margin: 0 auto 10px; }

/* ---------- tab & segmen ---------- */
.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--nav-active); border-radius: 8px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; height: 28px; padding: 0 11px; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 500; display: inline-flex; gap: 6px; align-items: center; justify-content: center; }
.tabs button:hover { color: var(--text); }
.tabs button.on { background: var(--panel-solid); color: var(--strong); box-shadow: 0 1px 2px rgba(16, 24, 40, 0.14); }
.tabs.full { display: flex; flex-wrap: nowrap; } .tabs.full button { flex: 1 1 0; padding: 0 6px; }

/* ---------- notice ---------- */
.notice { padding: 11px 14px; border-radius: 8px; background: var(--info-bg); color: var(--info-text); margin-bottom: 14px; font-size: 13px; border: 1px solid rgba(221, 169, 66, 0.3); line-height: 1.5; }
.notice.warn { background: var(--warn-bg); color: var(--warn-text); border-color: rgba(251, 191, 36, 0.25); }
.notice.bad { background: var(--bad-bg); color: var(--bad-text); border-color: rgba(251, 113, 133, 0.28); }
.notice.ok { background: var(--ok-bg); color: var(--ok-text); border-color: rgba(52, 211, 153, 0.25); }

/* ---------- grafik ---------- */
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.ring { position: relative; width: 132px; height: 132px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .c { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .c b { font-family: var(--font); font-size: 24px; font-weight: 600; letter-spacing: -0.02em; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend i.s1, .sw.s1 { background: var(--s1); } .legend i.s2, .sw.s2 { background: var(--s2); }

/* grafik batang (HTML) */
.vchart { position: relative; height: var(--h); padding: 18px 0 22px 34px; }
.vc-grid { position: absolute; inset: 18px 0 22px 34px; pointer-events: none; }
.vc-grid > div { position: absolute; left: 0; right: 0; border-top: 1px solid var(--viz-grid); }
.vc-grid > div:first-child { border-top-color: var(--line-strong); }
.vc-grid span { position: absolute; right: calc(100% + 8px); top: -7px; font-size: 11px; color: var(--viz-axis); font-variant-numeric: tabular-nums; white-space: nowrap; }
.vc-cols { position: relative; display: flex; height: 100%; }
.vc-col { flex: 1 1 0; min-width: 0; position: relative; display: flex; flex-direction: column; justify-content: flex-end; border-radius: 6px; }
.vc-col:hover { background: var(--panel-2); }
.vc-bars { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.vc-bar { position: relative; width: min(24px, 38%); border-radius: 4px 4px 0 0; }
.vc-bar.s1 { background: var(--s1); } .vc-bar.s2 { background: var(--s2); }
.vc-val { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); font-size: 11.5px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.vc-x { position: absolute; top: 100%; left: 0; right: 0; padding-top: 6px; text-align: center; font-size: 11px; color: var(--viz-axis); white-space: nowrap; font-variant-numeric: tabular-nums; }
.vtip { position: fixed; left: 0; top: 0; z-index: 1000; pointer-events: none; background: var(--panel-solid); color: var(--text); border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow); display: grid; gap: 3px; min-width: 120px; }
.vtip[hidden] { display: none; }
.vtip span { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.vtip span b { margin-left: auto; color: var(--text); font-variant-numeric: tabular-nums; }
.vtip .sw { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.bar-h { height: 6px; border-radius: 99px; background: var(--track); overflow: hidden; min-width: 80px; }
.bar-h > i { display: block; height: 100%; border-radius: inherit; background: var(--s1); }
.bar-h > i.s2 { background: var(--s2); }

/* ---------- kotak masuk ---------- */
.inbox { display: grid; grid-template-columns: 340px minmax(0, 1fr) 320px; height: 100%; }
.inbox.no-side { grid-template-columns: 340px minmax(0, 1fr); }
.chatlist { border-right: 1px solid var(--line); background: var(--glass); display: flex; flex-direction: column; min-height: 0; }
.chatlist .filters { padding: 12px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.chatlist .items { overflow-y: auto; flex: 1; }
.chatitem { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); color: inherit; position: relative; }
.chatitem:hover { background: var(--panel-2); text-decoration: none; }
.chatitem.active { background: var(--nav-active); }
.chatitem.active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--accent); }
.chatitem .top { display: flex; gap: 6px; align-items: center; }
.chatitem .name { font-weight: 600; color: var(--strong); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chatitem .time { font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }
.chatitem .last { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 3px; display: flex; gap: 6px; }
.chatitem .last span:first-child { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.chatitem .tags { display: flex; gap: 4px; margin-top: 7px; flex-wrap: wrap; }
.chatview { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chatview .head { background: var(--glass); border-bottom: 1px solid var(--line); padding: 10px 16px; display: flex; gap: 10px; align-items: center; }
.chatview .msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.chatview .tools { display: flex; gap: 6px; padding: 8px 12px 0; flex-wrap: wrap; border-top: 1px solid var(--line); background: var(--glass); }
.chatview .compose { background: var(--glass); padding: 10px 12px 12px; display: flex; gap: 8px; align-items: flex-end; }
.chatview .compose textarea { resize: none; min-height: 42px; max-height: 160px; }
.chatview .compose .icon-btn { height: 42px; width: 42px; flex: none; }
.attach-preview { display: flex; gap: 10px; align-items: center; padding: 8px 12px 0; background: var(--glass); }
.attach-preview[hidden] { display: none; }
.attach-preview img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.attach-preview span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.chatview.drop { outline: 2px dashed var(--accent); outline-offset: -8px; }
.bubble { max-width: min(560px, 78%); padding: 8px 11px 5px; border-radius: 14px 14px 14px 4px; background: var(--bubble-in); border: 1px solid var(--line); white-space: pre-wrap; word-wrap: break-word; line-height: 1.45; font-size: 13.5px; }
.bubble.out { align-self: flex-end; background: var(--bubble-out); border-color: var(--bubble-out-line); border-radius: 14px 14px 4px 14px; }
.bubble.ai { border-color: var(--bubble-out-line); }
.bubble .meta { font-size: 10px; color: var(--muted); text-align: right; margin-top: 3px; font-variant-numeric: tabular-nums; }
.bubble .tr { font-size: 12px; color: var(--muted); border-left: 2px solid var(--line-strong); padding-left: 8px; margin-top: 4px; }
.bubble img, .bubble video { max-width: 100%; max-height: 320px; border-radius: 10px; display: block; margin-bottom: 4px; }
.bubble audio { max-width: 260px; display: block; }
.daysep { align-self: center; font-size: 11px; background: rgba(148, 163, 214, 0.08); color: var(--muted); padding: 3px 12px; border-radius: 999px; margin: 10px 0; border: 1px solid var(--line); }
.sidepanel { border-left: 1px solid var(--line); background: var(--glass); overflow-y: auto; padding: 16px; }
.sidepanel .sec { margin-bottom: 18px; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 6px 10px; font-size: 12.5px; }
.kv dt { color: var(--dim); }
.kv dd { margin: 0; word-break: break-word; }
.back { display: none; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(2, 4, 10, 0.72); backdrop-filter: blur(6px); z-index: 60; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { width: 100%; max-width: 560px; max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--panel-solid); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.6); }
.modal.wide { max-width: 820px; }
.modal .mh { display: flex; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel-solid); z-index: 1; }
.modal .mb { padding: 18px; }
.modal .mf { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--panel-solid); }
@keyframes fade { from { opacity: 0; } }

#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 80; max-width: calc(100vw - 32px); }
.toast { background: var(--toast-bg); border: 1px solid var(--line-strong); color: var(--strong); padding: 11px 14px; border-radius: 12px; max-width: 360px; font-size: 13px; box-shadow: var(--shadow); animation: slide .2s; display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.toast.bad { border-color: rgba(251, 113, 133, 0.5); background: var(--toast-bad); }
.toast.warn { border-color: rgba(251, 191, 36, 0.5); background: var(--toast-warn); }
.toast.ok { border-color: rgba(52, 211, 153, 0.45); }
@keyframes slide { from { transform: translateY(10px); opacity: 0; } }

.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login .brand { padding: 0 0 22px; }

.qr { display: flex; justify-content: center; padding: 12px; background: #fff; border-radius: 14px; margin: 6px 0 10px; }
.qr img { width: 230px; height: 230px; image-rendering: pixelated; display: block; }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, rgba(148,163,214,.06), rgba(148,163,214,.14), rgba(148,163,214,.06)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.copybox { white-space: pre-wrap; font-family: var(--mono); font-size: 12px; background: var(--input-bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; line-height: 1.55; }
.photo-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-grid .ph { position: relative; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; }
.photo-grid .ph button { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.7); color: #fff; cursor: pointer; line-height: 1; }
.photo-grid .ph .n { position: absolute; left: 4px; bottom: 3px; font-size: 10px; background: rgba(0,0,0,.65); padding: 0 5px; border-radius: 4px; }
/* peringatan di sidebar */
.side-alerts { display: grid; gap: 4px; margin: 0 0 4px; }
.side-alerts:empty { display: none; }
.side-alerts a { display: flex; gap: 8px; align-items: flex-start; padding: 7px 10px; border-radius: 8px; background: var(--bad-bg); color: var(--bad-text); font-size: 12.5px; line-height: 1.35; }
.side-alerts a:hover { text-decoration: none; filter: brightness(0.97); }
.side-alerts a svg { width: 15px; height: 15px; flex: none; margin-top: 1px; }
.side-alerts a b { font-variant-numeric: tabular-nums; }
#menuBtn { position: relative; }
.menu-dot { position: absolute; top: 2px; right: 2px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); border: 2px solid var(--chrome-solid); }
.menu-dot[hidden] { display: none; }
.banners { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 70; max-width: min(360px, calc(100vw - 32px)); }
.banners a { display: flex; gap: 8px; align-items: center; padding: 10px 14px; border-radius: 10px; background: var(--panel-solid); border: 1px solid var(--line-strong); color: var(--text); font-size: 13px; box-shadow: var(--shadow); }
.banners a:hover { text-decoration: none; filter: brightness(1.15); }

@media (max-width: 1280px) {
  .inbox { grid-template-columns: 300px minmax(0, 1fr); }
  .inbox .sidepanel { display: none; }
  .inbox.show-side .sidepanel { display: block; position: fixed; right: 0; top: 0; bottom: 0; width: min(360px, 92vw); z-index: 45; box-shadow: -20px 0 60px rgba(0,0,0,.6); background: var(--panel-solid); }
}
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { display: none; position: fixed; inset: 0 22% 0 0; z-index: 50; background: var(--chrome-solid); }
  .side.open { display: flex; }
  .topbar { display: flex; align-items: center; gap: 10px; background: var(--chrome); color: var(--strong); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); padding: 10px 16px; position: relative; z-index: 2; }
  .topbar button { background: none; border: 0; color: var(--strong); cursor: pointer; padding: 4px; display: grid; }
  .topbar b { font-family: var(--font); font-weight: 650; }
  .main { padding: 16px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .inbox, .inbox.no-side { grid-template-columns: 1fr; }
  .inbox.has-chat .chatlist { display: none; }
  .inbox:not(.has-chat) .chatview { display: none; }
  .back { display: inline-flex; }
  h1 { font-size: 20px; }
  .stat .v { font-size: 22px; }
  .bubble { max-width: 88%; }
}

/* grid dua kolom yang turun jadi satu kolom di layar sempit */
.split { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.split.wide-left { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.split.wide-right { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
@media (max-width: 1100px) { .split, .split.wide-left, .split.wide-right { grid-template-columns: 1fr; } }

h1 svg, h2 svg, h3 svg { width: 18px; height: 18px; vertical-align: -3px; margin-right: 4px; color: var(--cyan); }

/* PWA di iPhone (status bar transparan): beri ruang di atas */
.topbar { padding-top: max(10px, env(safe-area-inset-top)); }
.side { padding-top: max(14px, env(safe-area-inset-top)); }

/* ---------- Tema terang (bersih) ---------- */
:root[data-theme="light"] {
  --bg: #F8F2E8;
  --bg-2: #F1E8D9;
  --panel: #ffffff;
  --panel-solid: #ffffff;
  --panel-2: #FBF7F0;
  --line: #E6DAC6;
  --line-strong: #D6C5A6;
  --text: #441E18;
  --muted: #7A6043;
  --dim: #A08C74;
  --cyan: #0891b2;
  --violet: #7c3aed;
  --accent: #812739; --accent-hover: #6B1F2F; --accent-soft: #F6E6EA; --nav-active: #F3E6CF;
  --grad: var(--accent);
  --ok: #059669; --ok-bg: #ecfdf5;
  --warn: #b45309; --warn-bg: #fffbeb;
  --bad: #e11d48; --bad-bg: #fff1f2;
  --info: #B8862B; --info-bg: #FBF3E1;
  --bubble-in: #ffffff; --bubble-out: #FBF1DF; --bubble-out-line: #EBD6A6;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 6px 20px -12px rgba(16, 24, 40, 0.14);
  --strong: #2A1410;
  --nav-text: #5E4A3A;
  --chrome: rgba(255, 255, 255, 0.92);
  --chrome-solid: #ffffff;
  --glass: #fbfcfe;
  --input-bg: #ffffff;
  --toast-bg: #ffffff; --toast-bad: #fff1f2; --toast-warn: #fffbeb;
  --info-text: #5E4A3A; --warn-text: #92400e; --bad-text: #9f1239; --ok-text: #065f46;
  --count-text: #be123c; --cyan-text: #0e7490; --violet-text: #6d28d9;
  --grid-line: transparent;
  --s1: #C8942E; --s2: #812739; --track: #EFE6D6;
  --viz-grid: #F0E9DC; --viz-axis: #7A6043; --accent-text: #6B1F2F;
  color-scheme: light;
}
:root[data-theme="light"] body { background-image: none; }
:root[data-theme="light"] .card { backdrop-filter: none; }
:root[data-theme="light"] .side { backdrop-filter: none; }
:root[data-theme="light"] .btn { background: #ffffff; }
:root[data-theme="light"] .btn:hover { background: var(--nav-active); }
:root[data-theme="light"] .btn.primary, :root[data-theme="light"] .btn.primary:hover { color: #fff; }
:root[data-theme="light"] .btn.primary { background: var(--accent); }
:root[data-theme="light"] .btn.primary:hover { background: var(--accent-hover); }
:root[data-theme="light"] .btn.ghost { background: transparent; }
:root[data-theme="light"] th { background: #f7f9fc; }
:root[data-theme="light"] .dot.ok, :root[data-theme="light"] .dot.warn, :root[data-theme="light"] .dot.bad { box-shadow: none; }
:root[data-theme="light"] .bar-h > i { box-shadow: none; }
:root[data-theme="light"] .ring svg circle:last-child { filter: none !important; }
:root[data-theme="light"] .chart path { filter: none !important; }
:root[data-theme="light"] .bubble.out { border-color: #c7d2fe; }
:root[data-theme="light"] .bubble.ai { border-color: #a5f3fc; }
:root[data-theme="light"] .daysep { background: #eef1f7; }
:root[data-theme="light"] .modal-bg { background: rgba(15, 23, 42, 0.35); }
:root[data-theme="light"] .modal { box-shadow: 0 24px 60px -20px rgba(15, 23, 42, 0.35); }
:root[data-theme="light"] .chatitem.active { background: #eef6ff; }
:root[data-theme="light"] .skeleton { background: linear-gradient(90deg, #eef1f6, #f6f8fb, #eef1f6); background-size: 200% 100%; }
:root[data-theme="light"] .banners a { box-shadow: 0 10px 24px -12px rgba(225, 29, 72, 0.35); }
:root[data-theme="light"] select option { background: #fff; }

.theme-btn { width: 34px; height: 34px; padding: 0; justify-content: center; }
.chatlist .filters select { min-width: 96px; }
.chatlist .filters .tabs { flex-wrap: nowrap; }
.chatlist .filters .tabs button { padding: 5px 9px; font-size: 12px; }

/* ---------- HP (layar sempit) ---------- */
@media (max-width: 860px) {
  .topbar { position: sticky; top: 0; z-index: 30; min-height: 52px; }
  .topbar svg { width: 22px; height: 22px; }
  .topbar .theme-btn { width: 36px; height: 36px; place-items: center; }
  .side { z-index: 75; box-shadow: 0 0 0 100vmax rgba(3, 6, 15, 0.55); overflow-y: auto; inset: 0 auto 0 0; width: min(300px, 82vw); }
  .main { padding: 14px 14px calc(90px + env(safe-area-inset-bottom)); }
  .page-head { gap: 8px; margin-bottom: 14px; }
  .page-head .sub { font-size: 12.5px; margin-top: -2px; }
  .page-head .btn { padding: 7px 11px; font-size: 13px; }
  .card { padding: 14px; }
  /* Angka ringkas 2 kolom, bukan satu kartu per baris */
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px; }
  .stat .k { font-size: 10.5px; letter-spacing: 0.05em; }
  .stat .v { font-size: 18px; }
  .stat .d { font-size: 11.5px; }
  /* 16px mencegah iPhone memperbesar layar saat mengetik */
  input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=date], input[type=time], input[type=url], input[type=tel], select, textarea { font-size: 16px; }
  [data-range] { gap: 8px; }
  [data-range] input[type=date] { width: auto !important; flex: 1 1 130px; min-width: 0; }
  [data-range] .tabs { width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  [data-range] .tabs button { white-space: nowrap; flex: 0 0 auto; }
  [data-range] select, .card select.inline, .card input.inline { width: 100% !important; }
  .tabs { max-width: 100%; }
  table { font-size: 12.5px; }
  th { white-space: nowrap; }
  .table-wrap td:first-child { min-width: 130px; }
  th, td { padding: 8px 10px; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .grid.auto { grid-template-columns: 1fr; }
  .banners, #toasts { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); max-width: none; }
  .toast { max-width: none; }
  /* Kotak masuk: tinggi pas layar, kolom tulis tidak tertutup */
  .main.flush { padding: 0; }
  .chatlist { border-right: 0; }
  .chatview .head { padding: 8px 10px; }
  .chatview .head { gap: 8px; }
  .chatview .head b, .chatview .head .small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chatview .head .avatar { display: none; }
  #headBadges { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
  #headBadges .badge { font-size: 10.5px; padding: 2px 7px; }
  .numchips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .numchips .badge { flex: 0 0 auto; }
  .chatview .msgs { padding: 12px 10px; }
  .chatview .compose { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
  .chatview .tools { padding: 6px 10px 0; overflow-x: auto; flex-wrap: nowrap; }
  .chatview .tools > * { flex: 0 0 auto; }
  .bubble { max-width: 92%; }
  .modal-bg { padding: 10px; }
  .modal .mb { padding: 14px; }
}
@media (max-width: 360px) {
  .stat .v { font-size: 16px; }
}

/* Kolom kata sandi dengan tombol mata */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 42px !important; width: 100%; }
.pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; display: grid; place-items: center; border-radius: 8px; }
.pw-eye:hover { color: var(--text); background: var(--panel-2); }
.pw-eye svg { width: 18px; height: 18px; }

/* Siapa yang membalas: AI vs staf */
.bubble .who { font-family: var(--sans, inherit); font-weight: 600; padding: 0 6px; border-radius: 6px; margin-right: 6px; font-size: 10px; }
.bubble .who.ai { color: var(--cyan); background: rgba(34, 211, 238, 0.12); }
.bubble .who.staff { color: var(--warn); background: var(--warn-bg); }
.bubble.out.staff { border-color: rgba(251, 191, 36, 0.55); box-shadow: inset 3px 0 0 rgba(251, 191, 36, 0.8); }
:root[data-theme="light"] .bubble.out.staff { border-color: #fcd34d; }

/* Saat form/modal terbuka, banner pemberitahuan disembunyikan agar tidak menutupi tombol Simpan */
body:has(.modal-bg) .banners { display: none; }

/* Kotak Masuk mode baca (Advertiser) */
.inbox.readonly [data-o]:not([data-o="copy"]), .inbox.readonly #resolve, .inbox.readonly #erpPush { display: none; }
.inbox.readonly #leadStatus, .inbox.readonly #notes { pointer-events: none; opacity: 0.6; }

/* Editor form order (Form Order → Atur form) */
.fe-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 16px; align-items: start; }
.fe-left { display: grid; gap: 16px; }
.fe-right { position: sticky; top: 12px; }
.fe-row { display: flex; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.fe-row:first-child { border-top: 0; }
.fe-row.off .fe-body input[data-k] { opacity: .5; }
.fe-move { display: flex; flex-direction: column; gap: 2px; }
.fe-body { flex: 1; min-width: 0; }
.fe-stage { background: var(--panel-2); border-radius: 12px; padding: 12px; display: flex; justify-content: center; max-height: calc(100vh - 150px); overflow: auto; }
.fe-stage iframe { width: 100%; min-height: 400px; border: 0; background: #fff; border-radius: 10px; transition: width .2s; }
.fe-stage.mobile iframe { width: 375px; max-width: 100%; }
@media (max-width: 980px) { .fe-grid { grid-template-columns: 1fr; } .fe-right { position: static; } }

/* Pilihan warna tombol (editor form order) */
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; box-shadow: 0 0 0 1px rgba(0,0,0,.12); }
.swatch.on { border-color: var(--bg, #fff); box-shadow: 0 0 0 2px var(--text, #111); }

/* Judul halaman & nama brand memakai serif brand; angka/tabel tetap Inter agar mudah dibaca. */
h1, .brand b { font-family: var(--display); letter-spacing: 0.01em; }
h1 { font-size: 30px; font-weight: 700; }
.brand b { font-size: 19px; font-weight: 700; }

/* Animasi buka halaman, sama dengan AutoWA: kartu naik berurutan. */
.rise { animation: rise .36s cubic-bezier(.2, .7, .2, 1) backwards; animation-delay: calc(var(--i, 0) * 40ms); }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.988); } }
@media (prefers-reduced-motion: reduce) { .rise { animation: none; } }

/* Cetak laporan: hanya isi halaman. */
@media print {
  .side, .topbar, .no-print, #mpFile, label.btn, .toast { display: none !important; }
  .layout, .main { display: block !important; height: auto !important; overflow: visible !important; margin: 0 !important; padding: 0 !important; }
  .table-wrap { max-height: none !important; overflow: visible !important; }
  .card { break-inside: avoid; box-shadow: none !important; }
  .rise { animation: none !important; }
}
