/* ============================================================
   WAApps — tema WhatsApp
   Dark #111B21 · panel #202C33 · bubble keluar #005C4B · aksen #00A884
   Light #F0F2F5 · wallpaper #EFEAE2 · bubble keluar #D9FDD3 · aksen #008069
   Inter (UI) + JetBrains Mono (angka/status)
   ============================================================ */
:root {
  /* --- WhatsApp dark mode (palet resmi WA) --- */
  --bg: #111B21;
  --bg-soft: #202C33;
  --bg-card: #202C33;
  --bg-hover: rgba(233,237,239,.05);
  --bg-active: rgba(0,168,132,.14);
  --border: #2A3942;
  --border-soft: rgba(233,237,239,.07);
  --text: #E9EDEF;
  --text-body: #D1D7DB;
  --text-dim: #8696A0;
  --text-faint: #8696A0;
  --text-mute: #667781;
  --accent: #00A884;
  --accent-hover: #06CF9C;
  --accent-2: #06CF9C;
  --accent-grad: linear-gradient(135deg, #00A884, #06CF9C);
  --accent-soft: rgba(0,168,132,.14);
  --accent-border: rgba(0,168,132,.38);
  --green: #25D366;
  --green-soft: rgba(37,211,102,.12);
  --green-border: rgba(37,211,102,.3);
  --green-btn: #00A884;
  --green-btn-hover: #017561;
  --btn-solid: #017561;
  --btn-solid-hover: #026958;
  --amber: #FFD279;
  --amber-soft: rgba(255,210,121,.12);
  --amber-border: rgba(255,210,121,.3);
  --red: #F15C6D;
  --red-soft: rgba(241,92,109,.12);
  --red-border: rgba(241,92,109,.3);
  --chat-bg: #0B141A;
  --bubble-in: #202C33;
  --bubble-out: #005C4B;
  --bubble-out-border: transparent;
  --bubble-out-text: rgba(233,237,239,.72);
  --bubble-in-meta: #8696A0;
  --bubble-card-bg: rgba(11,20,26,.38);
  --tick-sent: #B7CFC9;
  --tick-read: #6FD3FF;
  --avatar-bg: #374248;
  --avatar-fg: #AEBAC1;
  --input-bg: #2A3942;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.5);
  --radius: 10px;
  --doodle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='134' height='134' viewBox='0 0 134 134'%3E%3Cg fill='none' stroke='%23E9EDEF' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round' opacity='.055'%3E%3Ccircle cx='22' cy='24' r='7'/%3E%3Cpath d='M56 15v16M48 23h16'/%3E%3Cpath d='M92 26c3-7 13-7 15 1'/%3E%3Cpath d='M14 70h18v13H14zM14 76h18'/%3E%3Cpath d='M50 64l8 8-8 8'/%3E%3Ccircle cx='98' cy='72' r='9'/%3E%3Cpath d='M20 110c6-9 16-9 20 0'/%3E%3Cpath d='M60 104h14M67 97v14'/%3E%3Cpath d='M96 102c7 0 9 7 4 11'/%3E%3C/g%3E%3C/svg%3E");
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------- LIGHT MODE (WhatsApp terang) ---------- */
html.light {
  --bg: #F0F2F5;
  --bg-soft: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-hover: rgba(11,20,26,.04);
  --bg-active: rgba(0,128,105,.09);
  --border: #D1D7DB;
  --border-soft: rgba(11,20,26,.07);
  --text: #111B21;
  --text-body: #3B4A54;
  --text-dim: #667781;
  --text-faint: #667781;
  --text-mute: #8696A0;
  --accent: #008069;
  --accent-hover: #017561;
  --accent-2: #00A884;
  --accent-grad: linear-gradient(135deg, #008069, #00A884);
  --accent-soft: rgba(0,128,105,.09);
  --accent-border: rgba(0,128,105,.35);
  --green: #1FA855;
  --green-soft: rgba(31,168,85,.1);
  --green-border: rgba(31,168,85,.3);
  --green-btn: #008069;
  --green-btn-hover: #016b58;
  --btn-solid: #008069;
  --btn-solid-hover: #016b58;
  --amber: #B45309;
  --amber-soft: rgba(180,83,9,.12);
  --amber-border: rgba(180,83,9,.35);
  --red: #DC2626;
  --red-soft: rgba(220,38,38,.1);
  --red-border: rgba(220,38,38,.3);
  --chat-bg: #EFEAE2;
  --bubble-in: #FFFFFF;
  --bubble-out: #D9FDD3;
  --bubble-out-border: transparent;
  --bubble-out-text: rgba(17,27,33,.62);
  --bubble-in-meta: #667781;
  --bubble-card-bg: rgba(255,255,255,.75);
  --tick-sent: #5B7A70;
  --tick-read: #156EAA;
  --avatar-bg: #DFE5E7;
  --avatar-fg: #8696A0;
  --input-bg: #FFFFFF;
  --shadow: 0 1px 2px rgba(11,20,26,.08);
  --shadow-lg: 0 8px 24px rgba(11,20,26,.14);
  --doodle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='134' height='134' viewBox='0 0 134 134'%3E%3Cg fill='none' stroke='%23111B21' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round' opacity='.05'%3E%3Ccircle cx='22' cy='24' r='7'/%3E%3Cpath d='M56 15v16M48 23h16'/%3E%3Cpath d='M92 26c3-7 13-7 15 1'/%3E%3Cpath d='M14 70h18v13H14zM14 76h18'/%3E%3Cpath d='M50 64l8 8-8 8'/%3E%3Ccircle cx='98' cy='72' r='9'/%3E%3Cpath d='M20 110c6-9 16-9 20 0'/%3E%3Cpath d='M60 104h14M67 97v14'/%3E%3Cpath d='M96 102c7 0 9 7 4 11'/%3E%3C/g%3E%3C/svg%3E");
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-ui); background: var(--bg); color: var(--text-body); line-height: 1.5;
  font-size: 14px; -webkit-font-smoothing: antialiased; transition: background .18s, color .18s;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- icons (SVG, stroke currentColor) ---------- */
.ic { width: 20px; height: 20px; flex: none; }
.ic svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- status dots & pills ---------- */
.st { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 500; }
.st::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text-mute); }
.st.ok { color: var(--green); } .st.ok::before { background: var(--green); box-shadow: 0 0 8px var(--green); }
.st.pulse { color: var(--amber); } .st.pulse::before { background: var(--amber); animation: pulse 1.2s infinite; }
.st.qr { color: var(--accent-2); } .st.qr::before { background: var(--accent-2); animation: pulse 1.6s infinite; }
.st.warn { color: var(--amber); } .st.warn::before { background: var(--amber); }
.st.danger { color: var(--red); } .st.danger::before { background: var(--red); animation: pulse 1s infinite; }
.st.off { color: var(--text-mute); } .st.off::before { background: var(--text-mute); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* pill */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; border-radius: 99px; padding: 3px 10px;
}
.pill.green { color: var(--green); background: var(--green-soft); border: 1px solid var(--green-border); }
.pill.amber { color: var(--amber); background: var(--amber-soft); border: 1px solid var(--amber-border); }
.pill.red { color: var(--red); background: var(--red-soft); border: 1px solid var(--red-border); }
.pill.gray { color: var(--text-faint); background: rgba(139,143,163,.1); border: 1px solid rgba(139,143,163,.25); }
.pill.indigo { color: var(--accent-2); background: rgba(154,123,255,.12); border: 1px solid rgba(154,123,255,.3); }

/* ============================================================
   SHELL — sidebar
   ============================================================ */
.shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 264px; flex: none; display: flex; flex-direction: column;
  background: var(--bg-soft); border-right: 1px solid var(--border);
}
.sidebar .sb-head {
  padding: 16px 18px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.sb-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; color: var(--text); letter-spacing: -.2px; }
.logo-badge {
  width: 26px; height: 26px; border-radius: 8px; background: var(--accent-grad);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700;
}
.sb-head .sb-actions { display: flex; align-items: center; gap: 6px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--avatar-bg);
  color: var(--avatar-fg); font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.avatar.gray { background: var(--text-mute); }

.sb-search { padding: 10px 12px; }
.sb-search input, .chat-list-head input {
  width: 100%; border: 1px solid var(--border); background: var(--input-bg); border-radius: 8px;
  padding: 8px 13px; font-size: 13px; outline: none; color: var(--text); font-family: var(--font-ui);
  transition: border-color .12s;
}
.sb-search input:focus, .chat-list-head input:focus { border-color: var(--accent); }
.sb-search input::placeholder, .chat-list-head input::placeholder { color: var(--text-mute); }

.sb-nav { flex: 1; overflow-y: auto; padding: 8px 8px 12px; }
.sb-nav a {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; margin: 1px 0;
  color: var(--text-dim); border-radius: 8px; font-size: 13.5px; font-weight: 500;
  transition: background .12s, color .12s;
}
.sb-nav a:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.sb-nav a.active { background: var(--accent-soft); color: var(--text); }
.sb-nav a.active .ic { color: var(--accent-2); }
.sb-nav a .ic { color: var(--text-mute); }

.sb-foot {
  padding: 12px 16px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-mute);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.topbar {
  padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: -.2px; }
.topbar h1 span { color: var(--text-mute); font-weight: 400; margin-left: 6px; }
.topbar .user { font-size: 13px; color: var(--text-dim); display: flex; align-items: center; gap: 12px; }

.page { padding: 24px; overflow-y: auto; flex: 1; }
.page.chat-page { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.page.chat-page .chat-layout { flex: 1; min-height: 0; }

/* theme toggle */
.theme-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); cursor: pointer;
  background: var(--input-bg); color: var(--text-dim);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
}
.theme-btn:hover { border-color: var(--accent); color: var(--text); }
.theme-btn .ic { width: 16px; height: 16px; }
.theme-btn .ic-moon { display: none; }
html.light .theme-btn .ic-sun { display: none; }
html.light .theme-btn .ic-moon { display: block; }

/* ============================================================
   CARDS
   ============================================================ */
.grid { display: grid; gap: 16px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
  transition: transform .14s, box-shadow .14s, border-color .14s;
}
.card h3 { font-size: 11px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: .8px; margin-bottom: 12px; }
.card .big { font-size: 24px; font-weight: 600; color: var(--text); letter-spacing: -.3px; font-family: var(--font-mono); }
.card .sub { color: var(--text-mute); font-size: 12px; margin-top: 3px; }

.stat-card { display: flex; align-items: center; gap: 14px; }
.stat-card .ic-box {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  background: linear-gradient(160deg, var(--accent-soft), transparent 70%);
  border: 1px solid var(--accent-border); color: var(--accent-2);
  display: inline-flex; align-items: center; justify-content: center;
}
.stat-card .ic-box .ic { width: 20px; height: 20px; }
.stat-card .label { font-size: 11px; color: var(--text-faint); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }

.vendor-card { cursor: pointer; }
.vendor-card:hover { transform: translateY(-2px); border-color: var(--accent-border); box-shadow: var(--shadow-lg); }
.vendor-card .vname { font-size: 14px; font-weight: 600; color: var(--text); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.vendor-card .vmeta { color: var(--text-mute); font-size: 12px; margin-top: 2px; }
.vendor-card .inst-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 7px 0; border-bottom: 1px solid var(--border-soft); font-size: 12.5px;
}
.vendor-card .inst-row:last-child { border-bottom: 0; }
.vendor-card .vstat { margin-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-mute); }

/* Overview — status jelas */
.ov-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.ov-dot.ok { background: var(--green); box-shadow: 0 0 6px var(--green-border); }
.ov-dot.bad { background: var(--red); box-shadow: 0 0 6px var(--red-border); }
.ov-dot.off { background: var(--text-faint); }

.rec-card {
  background: linear-gradient(160deg, var(--accent-soft), var(--bg-card) 62%);
  border: 1px solid var(--accent-border); padding: 20px;
}
.rec-card .label { font-size: 11px; color: var(--text-faint); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.rec-card .big { font-size: 18px; color: var(--text); margin: 8px 0 6px; letter-spacing: -.3px; word-break: break-all; font-family: var(--font-ui); }
.rec-card .big b { color: var(--accent-2); font-weight: 700; }
.rec-card .meta { font-size: 12.5px; color: var(--text-faint); }
.rec-card .meta strong { color: var(--text-body); font-weight: 600; }

/* ============================================================
   TABLE
   ============================================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-size: 11px; font-weight: 500; letter-spacing: .6px;
  color: var(--text-faint); text-transform: uppercase; padding: 8px 10px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg-card);
}
td { padding: 9px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tr:hover td { background: var(--bg-hover); }
td.mono { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); }

/* ============================================================
   FORMS
   ============================================================ */
label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 5px; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], select, textarea {
  width: 100%; background: var(--input-bg); border: 1px solid var(--border); color: var(--text);
  padding: 9px 12px; border-radius: 8px; font-size: 13.5px; font-family: var(--font-ui); outline: none;
  transition: border-color .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 90px; }
.form-row { margin-bottom: 14px; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--btn-solid); color: #fff; font-weight: 500; font-size: 13px;
  border: 0; padding: 9px 18px; border-radius: 8px; cursor: pointer; font-family: var(--font-ui);
  box-shadow: var(--shadow); transition: background .15s, transform .1s, opacity .12s; white-space: nowrap;
}
.btn:hover { background: var(--btn-solid-hover); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent-border); box-shadow: none; }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.dim { background: var(--bg-card); color: var(--text-dim); border: 1px solid var(--border); box-shadow: none; }
.btn.dim:hover { background: var(--bg-hover); color: var(--text); }
.btn.danger { background: transparent; color: var(--red); border: 1px solid var(--red-border); box-shadow: none; }
.btn.danger:hover { background: var(--red-soft); }
.btn.success { background: var(--btn-solid); color: #fff; }
.btn.success:hover { background: var(--btn-solid-hover); }
.btn.sm { padding: 6px 12px; font-size: 12px; }
.btn .ic { width: 16px; height: 16px; }

/* ============================================================
   CHAT
   ============================================================ */
.chat-layout { display: flex; height: 100%; min-height: 0; }

.chat-col {
  width: 330px; flex: none; display: flex; flex-direction: column;
  border-right: 1px solid var(--border); background: var(--bg-soft);
}
.chat-list { flex: 1; overflow-y: auto; }
.chat-list-head { padding: 10px 14px 8px; }
/* Filter inbox lintas vendor/nomor/tanggal (SA all-inbox, F-04) */
.chat-filters { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.chat-filters select { padding: 6px 9px; font-size: 12.5px; }
.chat-filters .cf-dates { display: flex; gap: 6px; align-items: center; }
.chat-filters .cf-dates input[type=date] { padding: 6px 8px; font-size: 12px; }
.chat-filters .cf-count { font-size: 10.5px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .5px; }
.chat-item {
  display: flex; gap: 12px; padding: 10px 14px; cursor: pointer; align-items: center;
  border-bottom: 1px solid var(--border-soft);
}
.chat-item:hover { background: var(--bg-hover); }
.chat-item.active { background: var(--bg-active); }
.chat-item .av {
  width: 40px; height: 40px; border-radius: 50%; background: var(--avatar-bg);
  color: var(--avatar-fg); display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; flex: none;
}
.chat-item .meta { flex: 1; min-width: 0; }
.chat-item .nm { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.chat-item .nm b { font-weight: 600; font-size: 13.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .nm time { color: var(--text-mute); font-size: 11px; flex: none; font-family: var(--font-mono); }
.chat-item .prev { color: var(--text-mute); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .unread { background: var(--btn-solid); color: #fff; font-size: 10.5px; font-weight: 600; border-radius: 99px; padding: 1px 7px; flex: none; min-width: 18px; text-align: center; }
.chat-item .inst-tag { font-size: 10px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .5px; }

.chat-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--chat-bg); position: relative; }
/* wallpaper doodle WhatsApp (SVG inline, ikut tema) */
.chat-pane::before {
  content: ""; position: absolute; inset: 0; opacity: 1; pointer-events: none;
  background-image: var(--doodle); background-repeat: repeat;
}
.chat-head {
  padding: 10px 18px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border); background: var(--bg-soft); z-index: 1;
}
.chat-head .back { display: none; }
.chat-head .avatar { width: 38px; height: 38px; border-radius: 50%; }
.chat-head .who { font-weight: 600; font-size: 13.5px; color: var(--text); }
.chat-head .sub { color: var(--text-mute); font-size: 11.5px; }

.chat-msgs { flex: 1; overflow-y: auto; padding: 14px 8% 18px; display: flex; flex-direction: column; gap: 3px; z-index: 1; }
/* pesan menempel ke bawah (ala WhatsApp); auto-margin aman walau isinya overflow */
.chat-msgs > :first-child { margin-top: auto; }
.bubble {
  max-width: 62%; padding: 6px 10px; border-radius: 8px; font-size: 13.8px;
  word-break: break-word; white-space: pre-wrap; box-shadow: 0 1px 1px rgba(11,20,26,.13);
  position: relative; line-height: 1.36;
}
/* ekor bubble ala WhatsApp: segitiga di sudut atas (masuk → kiri, keluar → kanan) */
.bubble::after { content: ""; position: absolute; top: 0; width: 0; height: 0; }
.bubble .txt { display: block; }
/* jam + centang: di WhatsApp meta ada di kanan bawah, sejajar baris terakhir */
.bubble .t {
  float: right; margin: 6px -2px -3px 8px; font-size: 11px; line-height: 15px;
  display: inline-flex; align-items: center; gap: 3px; white-space: nowrap;
  color: var(--bubble-in-meta); font-family: var(--font-ui);
}
.bubble.out .t { color: var(--bubble-out-text); }
/* bubble berisi kartu media: meta turun ke baris sendiri supaya tidak menimpa kartu */
.bubble .t.block { float: none; display: flex; justify-content: flex-end; margin: 5px -2px -3px 0; }
.bubble .tick {
  display: inline-flex; align-items: center; line-height: 1; color: var(--tick-sent); font-size: 13px;
}
.bubble .tick.read { color: var(--tick-read); }
.bubble.out .tick svg { width: 15px; height: 11px; display: block; }
.bubble .tick.clk svg { width: 12px; height: 12px; }
.bubble .tick svg path, .bubble .tick svg circle { fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.bubble .media { font-size: 12.5px; }
.bubble.in { align-self: flex-start; background: var(--bubble-in); border: 0; border-top-left-radius: 2px; }
.bubble.in::after { left: -7px; border-right: 8px solid var(--bubble-in); border-top: 10px solid transparent; }
.bubble.out { align-self: flex-end; background: var(--bubble-out); border: 0; border-top-right-radius: 2px; }
.bubble.out::after { right: -7px; border-left: 8px solid var(--bubble-out); border-top: 10px solid transparent; }

/* video & audio di dalam bubble */
.bub-vid { display: block; width: 100%; max-width: 360px; max-height: 420px; border-radius: 8px; background: #000; }
.bub-aud { display: block; width: 260px; max-width: 100%; margin: 2px 0; }
.media-dl { display: inline-block; margin-top: 6px; font-size: 12px; color: var(--accent); text-decoration: none; }
.media-dl:hover { text-decoration: underline; }
/* badge putar di item galeri video */
.gp-item { position: relative; }
.gp-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 34px; height: 34px; line-height: 34px; text-align: center; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; font-size: 14px; pointer-events: none; }
.gp-item.gp-vid img { object-fit: cover; }

/* ============================================================
   MEDIA (M6) — gambar/dokumen di bubble, lightbox, galeri per chat
   ============================================================ */
.chat-layout { position: relative; }
.chat-head .gal-btn { margin-left: auto; }
.chat-item .prev .pi { margin-right: 4px; opacity: .85; }

/* .bubble pakai white-space:pre-wrap — spasi/enter di HTML media harus di-reset,
   kalau tidak kartu dokumen & caption tampil berjarak aneh */
.bubble .bub-img, .bubble .media-doc, .bubble .txt.cap { white-space: normal; }

.bubble .bub-img {
  display: block; max-width: 100%; max-height: 320px; width: auto; height: auto;
  border-radius: 8px; cursor: zoom-in; background: var(--bg);
}
.bubble .txt.cap { display: block; margin-top: 6px; font-size: 13px; }
.bubble .media-broken { color: var(--text-mute); font-size: 12.5px; font-style: italic; }

/* kartu dokumen / audio / video: klik = unduh */
.bubble .media-doc {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; margin: -2px 0;
  border: 0; border-radius: 8px; background: var(--bubble-card-bg);
  text-decoration: none; color: var(--text-body); min-width: 190px;
}
.bubble .media-doc:hover { background: var(--bg-hover); text-decoration: none; }
.bubble .media-doc .mi { font-size: 19px; flex: none; }
.bubble .media-doc .mn { flex: 1; min-width: 0; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bubble .media-doc .ms { font-size: 10.5px; color: var(--text-mute); font-family: var(--font-mono); flex: none; }
.bubble .media-doc .md { color: var(--accent-2); font-size: 14px; flex: none; }

/* ---------- Lightbox (klik gambar → tampil penuh, mirip WhatsApp) ---------- */
.media-viewer { position: fixed; inset: 0; z-index: 300; display: none; }
.media-viewer.open { display: block; }
.mv-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.86); }
.mv-body { position: relative; height: 100%; display: flex; flex-direction: column; }
.mv-bar {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: rgba(11,20,26,.92); border-bottom: 1px solid var(--border); z-index: 1;
}
.mv-title { flex: 1; min-width: 0; color: var(--text); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-stage { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; min-height: 0; }
.mv-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.mv-fallback { color: var(--text-dim); font-size: 13.5px; text-align: center; }

/* ---------- Galeri media per chat ---------- */
.gallery-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: 380px; max-width: 100%;
  background: var(--bg-soft); border-left: 1px solid var(--border); z-index: 60;
  display: flex; flex-direction: column; transform: translateX(100%);
  transition: transform .18s ease; visibility: hidden; box-shadow: -8px 0 24px rgba(0,0,0,.35);
}
.gallery-panel.open { transform: none; visibility: visible; }
.gp-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text);
}
.gp-head b { flex: 1; font-weight: 600; }
.gp-body { flex: 1; overflow-y: auto; padding: 12px; }
.gp-tabs { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.gp-tabs .gp-cache { font-size: 10.5px; color: var(--text-mute); margin-left: auto; font-family: var(--font-mono); }
.gp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.gp-item {
  position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; cursor: zoom-in;
  background: var(--bg-card); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; text-decoration: none;
}
.gp-item:hover { border-color: var(--accent-border); text-decoration: none; }
.gp-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gp-item .gp-date {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 3px 5px; font-size: 9.5px;
  font-family: var(--font-mono); color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.75));
}
.gp-item.gp-doc { flex-direction: column; gap: 4px; padding: 9px; cursor: pointer; }
.gp-item.gp-doc .gp-icon { font-size: 22px; }
.gp-item.gp-doc .gp-name { font-size: 10.5px; color: var(--text-dim); text-align: center; word-break: break-word; line-height: 1.25; }
.gp-item.gp-doc .gp-date { position: static; background: none; color: var(--text-mute); padding: 0; }
/* item yang belum tersimpan lokal: ditandai supaya jelas butuh ambil dari gateway dulu */
.gp-item.uncached::after {
  content: "⏳"; position: absolute; top: 3px; right: 4px; font-size: 9px; line-height: 1;
  background: rgba(0,0,0,.55); border-radius: 4px; padding: 2px 3px; pointer-events: none;
}

.chat-input { background: var(--bg-soft); padding: 10px 16px; display: flex; gap: 10px; align-items: flex-end; z-index: 1; border-top: 1px solid var(--border); }
.chat-input textarea {
  min-height: 42px; max-height: 140px; border-radius: 8px; background: var(--input-bg);
  border: 0; resize: none;
}
.chat-input .btn-send { border-radius: 50%; width: 42px; height: 42px; padding: 0; background: var(--green-btn); box-shadow: none; }
.chat-input .btn-send:hover { background: var(--green-btn-hover); }
.chat-input .btn-send .ic { width: 19px; height: 19px; }
.chat-input .attach { width: 42px; height: 42px; border-radius: 50%; padding: 0; background: transparent; border: 0; box-shadow: none; color: var(--text-dim); }

/* ============================================================
   BADGES (alias pill)
   ============================================================ */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge.b-blue { color: var(--accent-2); background: rgba(154,123,255,.12); border: 1px solid rgba(154,123,255,.3); }
.badge.b-green { color: var(--green); background: var(--green-soft); border: 1px solid var(--green-border); }
.badge.b-orange { color: var(--amber); background: var(--amber-soft); border: 1px solid var(--amber-border); }
.badge.b-red { color: var(--red); background: var(--red-soft); border: 1px solid var(--red-border); }
.badge.b-gray { color: var(--text-faint); background: rgba(139,143,163,.1); border: 1px solid rgba(139,143,163,.25); }

/* ============================================================
   EMPTY / ALERT / TOAST
   ============================================================ */
.empty { text-align: center; color: var(--text-mute); padding: 44px 16px; font-size: 12.5px; }
.empty .big { font-size: 30px; margin-bottom: 10px; }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; border: 1px solid; display: flex; align-items: center; gap: 9px; }
.alert .ic { width: 16px; height: 16px; flex: none; }
.alert.err { background: var(--red-soft); color: var(--red); border-color: var(--red-border); }
.alert.ok { background: var(--green-soft); color: var(--green); border-color: var(--green-border); }
.alert.info { background: var(--accent-soft); color: var(--accent-2); border-color: var(--accent-border); }

#toasts { position: fixed; top: 16px; right: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg-card); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  padding: 11px 14px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow-lg);
  animation: slidein .18s; max-width: 340px; color: var(--text-body);
}
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============================================================
   QR
   ============================================================ */
.qr-box { text-align: center; padding: 20px; }
.qr-canvas { display: inline-block; background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow-lg); }
.qr-tip { color: var(--text-mute); font-size: 13px; max-width: 320px; margin: 0 auto; }
pre.qr-text { font-size: 10px; line-height: 1.2; color: #0f172a; max-width: 320px; overflow-wrap: break-word; white-space: pre-wrap; text-align: left; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--bg); position: relative; }
.login-wrap::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 0%, var(--accent-soft), transparent 55%);
}
.login-box {
  width: 100%; max-width: 380px; background: var(--bg-card); border-radius: 14px;
  border: 1px solid var(--border); box-shadow: var(--shadow-lg); padding: 34px 30px; position: relative;
}
.login-box .logo { font-size: 20px; font-weight: 600; color: var(--text); text-align: center; margin-bottom: 4px; display: flex; align-items: center; justify-content: center; gap: 10px; letter-spacing: -.3px; }
.login-box .logo .logo-badge { width: 32px; height: 32px; font-size: 15px; border-radius: 9px; }
.login-box .sub { text-align: center; color: var(--text-mute); font-size: 12.5px; margin-bottom: 26px; }
.login-box .err { color: var(--red); font-size: 12.5px; margin-bottom: 12px; background: var(--red-soft); border-radius: 8px; padding: 8px 12px; }
.login-theme { position: absolute; top: 16px; right: 16px; }

/* ============================================================
   PROGRESS
   ============================================================ */
.prog { height: 5px; background: var(--bg-hover); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.prog > i { display: block; height: 100%; background: var(--accent-grad); transition: width .3s; }

/* ============================================================
   VENDOR MODE — topbar variant
   ============================================================ */
body.vendor .topnav {
  display: flex; align-items: center; gap: 14px; padding: 12px 20px;
  background: var(--bg-soft); border-bottom: 1px solid var(--border);
}
body.vendor .topnav .logo { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 9px; color: var(--text); letter-spacing: -.2px; }
body.vendor .topnav .who { color: var(--text-mute); font-size: 13px; margin-left: auto; }
body.vendor .topnav .nav-actions { display: flex; align-items: center; gap: 12px; }
body.vendor .page { max-width: 860px; margin: 0 auto; width: 100%; }
body.vendor .page.chat-page { max-width: none; margin: 0; }

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60; display: none;
  background: var(--bg-soft); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottomnav a { flex: 1; text-align: center; color: var(--text-mute); font-size: 10.5px; padding: 5px 2px; border-radius: 8px; }
.bottomnav a .ic { width: 20px; height: 20px; margin: 0 auto 2px; display: block; }
.bottomnav a.active { color: var(--accent-2); font-weight: 600; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 860px) {
  .sidebar { width: 70px; }
  .sidebar .sb-brand .txt, .sb-foot .who, .sb-foot .gw-txt { display: none; }
  .sidebar .sb-brand { justify-content: center; }
  .sb-nav a { justify-content: center; padding: 11px 0; }
  .sb-nav a .lbl { display: none; }
  .sb-search { display: none; }
  .sb-foot { justify-content: center; }
  .page { padding: 16px; }
  .chat-col { width: 100%; }
  .chat-msgs { padding: 14px 12px; }
}
@media (max-width: 640px) {
  .bottomnav { display: flex; }
  body.vendor .page { padding-bottom: 84px; }
  .chat-layout { flex-direction: column; }
  .chat-col { width: 100%; border-right: 0; }
  .chat-list { display: none; }
  .chat-list.open { display: block; position: fixed; inset: 0; z-index: 55; background: var(--bg-soft); }
  .chat-head .back { display: inline-flex; }
  .bubble { max-width: 85%; }
  /* media di layar sempit: gambar penuh, galeri & lightbox ikut lebar layar */
  .bubble .bub-img { max-height: 260px; }
  .bubble .media-doc { min-width: 0; }
  .gallery-panel { width: 100%; border-left: 0; }
  .gp-grid { grid-template-columns: repeat(2, 1fr); }
  .mv-bar { padding: 10px 12px; }
  .mv-stage { padding: 10px; }
}