:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #16202a;
  --muted: #637282;
  --line: #e2e7ec;
  --brand: #0f9d58;
  --brand-ink: #ffffff;
  --brand-soft: #e3f5ec;
  --side: #10231a;
  --side-text: #c9dbd1;
  --side-active: #1c3a2b;
  --ok: #0f9d58;
  --warn: #c77700;
  --warn-soft: #fff4e0;
  --err: #d93025;
  --err-soft: #fdeceb;
  --info: #1a73e8;
  --info-soft: #e8f0fe;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 35, 26, .06), 0 1px 3px rgba(16, 35, 26, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1512;
    --panel: #16201b;
    --text: #e4ece7;
    --muted: #93a39a;
    --line: #26332c;
    --brand: #27b872;
    --brand-ink: #06140d;
    --brand-soft: #173628;
    --side: #0a100d;
    --side-text: #a9bdb2;
    --side-active: #17271f;
    --warn-soft: #3a2a0c;
    --err-soft: #3b1614;
    --info-soft: #14243d;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--brand); }
code, .mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 13px; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.side {
  width: 230px; flex: none; background: var(--side); color: var(--side-text);
  display: flex; flex-direction: column; padding: 18px 12px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; color: #fff; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; font-weight: 800; font-size: 13px; letter-spacing: -.5px;
}
.brand b { display: block; font-size: 15px; line-height: 1.1; }
.brand small { color: var(--side-text); font-size: 11px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--side-text); text-decoration: none; margin-bottom: 2px;
}
.nav a:hover { background: var(--side-active); color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; font-weight: 600; }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav-group{padding:7px 0 9px;border-top:1px solid rgba(255,255,255,.1)}
.nav-group:first-child{border-top:0;padding-top:0}
.nav-group-title{color:var(--side-text);opacity:.7;font-size:10px;font-weight:800;text-transform:uppercase;letter-spacing:.11em;padding:5px 10px 7px}
.nav-group a{font-size:13px}
.nav-group a.nav-subitem{padding-left:35px;font-size:12px;opacity:.92}
.group-member{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:11px 0;border-bottom:1px solid var(--line)}
.group-member:last-child{border-bottom:0}
.group-member span{min-width:0;overflow-wrap:anywhere}
.group-member small{color:var(--muted)}
.group-member .btns{display:flex;gap:5px;flex:none}
.side .spacer { flex: 1; }
.side .install-app{justify-content:center;margin:8px 8px 12px;flex:none}
.install-modal{position:fixed;inset:0;z-index:80;display:grid;place-items:center;padding:18px;background:rgba(7,20,13,.72)}
.install-modal-card{width:min(100%,420px);padding:25px;background:var(--panel);color:var(--text);border:1px solid var(--line);border-radius:16px;box-shadow:0 20px 60px rgba(0,0,0,.3)}
.install-modal-icon{width:46px;height:46px;border-radius:12px;background:var(--brand-soft);color:var(--brand);display:grid;place-items:center;font-size:26px}
.install-modal h2{margin:14px 0 6px;font-size:21px}
.install-modal p{margin:8px 0 15px;line-height:1.55}
.install-modal .btns{justify-content:flex-end;margin-top:19px}
@media(max-width:480px){.install-modal .btns{flex-direction:column-reverse}.install-modal .btns .btn{justify-content:center}}

.main { flex: 1; min-width: 0; padding: 26px 30px 40px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.topbar h1 { font-size: 21px; margin: 0; }
.btn.menu-btn { display: none; flex: none; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px;
}
.card h2 { font-size: 15px; margin: 0 0 14px; }
.card h2 small { font-weight: 400; color: var(--muted); }

/* ---------- Device info ---------- */
.kv { display: grid; grid-template-columns: 130px minmax(0, 1fr); row-gap: 14px; column-gap: 12px; align-items: center; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kv dd .mono { overflow-wrap: anywhere; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px;
  font-size: 12px; font-weight: 600; text-transform: lowercase;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.b-online, .b-sent { background: var(--brand-soft); color: var(--ok); }
.b-paused, .b-pending, .b-sending, .b-qr, .b-connecting { background: var(--warn-soft); color: var(--warn); }
.b-offline, .b-logged_out, .b-error { background: var(--err-soft); color: var(--err); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel);
  color: var(--text); padding: 7px 13px; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-sm { padding: 3px 9px; font-size: 12px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { filter: brightness(1.05); border-color: var(--brand); }
.btn-danger { color: var(--err); }
.btn-danger:hover { border-color: var(--err); }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.stat { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: var(--panel); }
.stat span { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.stat b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; margin-top: 4px; }
.stat.error b { color: var(--err); }
.stat.sent b { color: var(--ok); }
.stat.pending b { color: var(--warn); }

/* ---------- QR ---------- */
.qr-box { text-align: center; }
.qr-box img { width: 260px; max-width: 100%; border-radius: 8px; background: #fff; padding: 8px; }
.qr-box img.fresh { animation: qrIn .35s ease; }
@keyframes qrIn { from { opacity: .2; transform: scale(.97); } to { opacity: 1; transform: none; } }
.qr-timer { width: 260px; max-width: 100%; margin: 10px auto 0; }
.qr-bar { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.qr-bar span { display: block; height: 100%; width: 100%; background: var(--brand); transform-origin: left; }
.qr-timer small { display: block; margin-top: 6px; }
.qr-box ol { text-align: left; color: var(--muted); padding-left: 20px; margin: 14px 0 0; }
.connected { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22px 0; text-align: center; }
.connected .dot { width: 56px; height: 56px; border-radius: 50%; background: var(--brand-soft); color: var(--ok); display: grid; place-items: center; }
.muted { color: var(--muted); }

/* ---------- Form ---------- */
label { display: block; font-weight: 500; margin: 0 0 5px; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 160px; }

/* ---------- Tabel ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
td.msg { max-width: 360px; overflow-wrap: anywhere; }
td .err { color: var(--err); font-size: 12px; margin-top: 3px; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 12px; }

pre {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px;
  overflow-x: auto; margin: 8px 0 16px;
}
.docs h3 { font-size: 14px; margin: 20px 0 6px; }
.docs h3:first-child { margin-top: 0; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 8px; transition: .2s;
  pointer-events: none; z-index: 20;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
[hidden] { display: none !important; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; }
.login .brand { color: var(--text); justify-content: center; padding-bottom: 18px; }
.login .brand small { color: var(--muted); }
.alert { background: var(--err-soft); color: var(--err); padding: 9px 12px; border-radius: 8px; margin-bottom: 12px; }

/* ---------- Responsif ---------- */
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .side { position: fixed; inset: 0 auto 0 0; z-index: 10; transform: translateX(-100%); transition: .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .4); }
  .main { padding: 16px; }
  .btn.menu-btn { display: inline-flex; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kv { grid-template-columns: 1fr; row-gap: 4px; }
  .kv dd { margin-bottom: 10px; }
}

/* ---------- Auth & SaaS ---------- */
.btn-block { width: 100%; justify-content: center; margin-top: 6px; }
.auth-alt { text-align: center; margin: 16px 0 0; color: var(--muted); }
.auth-lead { text-align: center; color: var(--muted); margin: -6px 0 16px; }
.b-not_linked { background: var(--info-soft); color: var(--info); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 0; }
.quota { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.meter { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; margin-top: 8px; }
.meter span { display: block; height: 100%; background: var(--brand); }
.meter.full span { background: var(--warn); }
.hint { color: var(--muted); font-size: 13px; margin: 12px 0 0; }
a.btn { text-decoration: none; }
.cell-btns { display: flex; gap: 6px; flex-wrap: nowrap; }
.dev-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.dev {
  display: block; text-decoration: none; color: inherit; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.dev:hover { border-color: var(--brand); }
.dev .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.dev b { font-size: 15px; overflow-wrap: anywhere; }
.dev .meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
.dev.add { display: grid; place-items: center; min-height: 110px; border-style: dashed; color: var(--muted); cursor: pointer; font: inherit; }
.back { color: var(--muted); text-decoration: none; font-size: 13px; }
.back:hover { color: var(--text); }
.who { padding: 10px; margin: 0 0 8px; border-top: 1px solid var(--side-active); font-size: 12px; color: var(--side-text); overflow-wrap: anywhere; }
.who b { display: block; color: #fff; font-size: 13px; }
td input.num, td select.num { width: 84px; padding: 4px 6px; }
#aBody td { padding-left: 6px; padding-right: 6px; }
#aBody .cell-btns { flex-direction: column; align-items: stretch; }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
@media (max-width: 760px) { .quota { grid-template-columns: 1fr; } }
.plan-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: var(--warn-soft); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; }
.plan-banner b { color: var(--warn); }

/* ---------- Register: dropdown paket + kartu detail ---------- */
.login.register { max-width: 430px; }
.select-wrap { position: relative; }
.select-wrap select {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer; font-weight: 500;
}
.select-wrap::after {
  content: ""; position: absolute; right: 13px; top: 50%; width: 8px; height: 8px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
.plan-detail {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg);
  padding: 14px 16px; margin: 0 0 16px; animation: qrIn .2s ease;
}
.pd-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.pd-head b { font-size: 15px; }
.pd-tagline { color: var(--muted); font-size: 12px; margin-top: 2px; }
.pd-price { font-size: 18px; font-weight: 700; color: var(--brand); white-space: nowrap; }
.pd-price small { font-size: 11px; font-weight: 400; color: var(--muted); }
.plan-badge {
  display: inline-block; font-size: 10px; font-weight: 700; color: var(--brand-ink); background: var(--brand);
  padding: 2px 7px; border-radius: 99px; margin-left: 7px; vertical-align: middle; letter-spacing: .3px;
}
.pd-limits { color: var(--muted); font-size: 12px; margin-top: 8px; }
.pd-features { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.pd-features li { display: flex; gap: 8px; font-size: 13px; align-items: flex-start; }
.pd-features li::before { content: "✓"; color: var(--ok); font-weight: 700; flex: none; }
.pd-note { margin: 10px 0 0; font-size: 12px; color: var(--warn); }
.pd-note-ok { color: var(--ok); }

/* ---------- Dashboard superadmin ---------- */
.admin-stats { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stat.ic { display: flex; align-items: center; gap: 12px; }
.stat.ic > div:last-child { min-width: 0; }
.stat-ic {
  width: 38px; height: 38px; border-radius: 10px; background: var(--brand-soft); color: var(--ok);
  display: grid; place-items: center; flex: none;
}
.stat-ic svg { width: 19px; height: 19px; }
.stat.ic.sent .stat-ic { background: var(--brand-soft); color: var(--ok); }
.stat.ic span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.stat.ic b { display: block; font-size: 19px; margin-top: 2px; }

.plan-dist { display: grid; gap: 10px; }
.pd-row { display: grid; grid-template-columns: 90px minmax(0, 1fr) 40px; align-items: center; gap: 10px; font-size: 13px; }
.pd-label { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pd-bar { height: 8px; border-radius: 6px; background: var(--line); overflow: hidden; }
.pd-bar span { display: block; height: 100%; background: var(--brand); border-radius: 6px; }
.pd-count { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

#aSearch, #aDevSearch { padding: 6px 10px; font-size: 13px; }
@media (max-width: 1100px) { .admin-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .admin-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pd-row { grid-template-columns: 72px minmax(0, 1fr) 34px; }
}

/* ---------- Super admin ---------- */
.page-sub { margin: -12px 0 16px; }
.pending-box {
  background: var(--warn-soft); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 16px;
}
.pending-box > b { display: block; color: var(--warn); margin-bottom: 8px; }
.pending-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 0;
  border-top: 1px solid rgba(0, 0, 0, .06);
}
.pending-row > span:first-child { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
tr.is-admin td { background: var(--brand-soft); }
.rtable td[data-l] { vertical-align: middle; }

/* Di HP, tiap baris tabel jadi kartu berlabel supaya tidak perlu geser ke samping. */
@media (max-width: 760px) {
  .rtable thead { display: none; }
  .rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: 100%; }
  .rtable tr { border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; margin-bottom: 10px; }
  .rtable tr.is-admin { background: var(--brand-soft); }
  .rtable tr.is-admin td { background: none; }
  .rtable td { border: 0; padding: 6px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
  .rtable td[data-l]::before { content: attr(data-l); color: var(--muted); font-size: 12px; text-align: left; flex: none; }
  .rtable td[data-l="Pengguna"], .rtable td[data-l="Perangkat"]:first-child { display: block; text-align: left; font-size: 15px; }
  .rtable td[data-l="Pengguna"]::before, .rtable td[data-l="Perangkat"]:first-child::before { display: none; }
  .rtable td[data-l="Paket"] { flex-wrap: wrap; }
  .rtable td[data-l="Paket"] > * { margin-left: auto; }
  .rtable td.cell-actions:empty { display: none; }
  .rtable td.cell-actions .cell-btns { flex-direction: row; justify-content: flex-end; width: 100%; }
  .rtable td[colspan] { display: block; text-align: left; }
  #aBody .cell-btns { flex-direction: row; }
  .card .page-head input { max-width: none !important; }
}
.nav a.sub { padding-left: 18px; }
@media (max-width: 760px) { .rtable td.mono::before { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; } }

/* ---------- Google Contacts ---------- */
.gcard { margin-bottom: 16px; }
.gcard-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.g-logo { width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--line); display: grid; place-items: center; background: #fff; flex: none; }
.g-logo svg { width: 22px; height: 22px; }
.gcard-text { flex: 1 1 260px; min-width: 0; }

.gcard-foot { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.switch { display: inline-flex; align-items: center; gap: 10px; margin: 0; cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { width: 38px; height: 22px; border-radius: 22px; background: var(--line); position: relative; transition: .2s; flex: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.checks { display: grid; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; cursor: pointer; flex-wrap: wrap; }
.check input { width: auto; }
.check code { color: var(--muted); font-size: 12px; }
.secret-box { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.list-item { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.list-item:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.list-item .wh-logs-wrap { margin-top: 14px; }
.inline-form { margin: 0 0 16px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.icon-btn { padding: 0; width: 30px; height: 30px; justify-content: center; flex: none; }
.icon-btn svg { width: 16px; height: 16px; }
.log-pre { max-height: 220px; overflow: auto; font-size: 12px; margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.gcard-text b { display: inline; }
.gcard-text > b { display: block; font-size: 15px; }

/* Percakapan pribadi (tampilan seperti WhatsApp Web, penuh satu layar) */
body.page-chat{height:100vh;overflow:hidden}
body.page-chat .layout{height:100vh}
/* Menu sidebar auto-hide di halaman chat supaya layarnya penuh; buka lagi lewat tombol ☰. */
body.page-chat .side{position:fixed;inset:0 auto 0 0;z-index:10;transform:translateX(-100%);transition:.2s;overflow-y:auto}
body.page-chat .side.open{transform:none;box-shadow:0 0 0 100vmax rgba(0,0,0,.4)}
body.page-chat .btn.menu-btn{display:inline-flex}
body.page-chat .main{height:100vh;overflow:hidden;display:flex;flex-direction:column;padding-bottom:14px}
body.page-chat .topbar{flex:none;margin-bottom:12px;align-items:center}
body.page-chat .chat-topbar-row{min-width:0;align-items:center}
.chat-heading{min-width:0}
.chat-heading p{margin:2px 0 0;font-size:12px;line-height:1.3}
body.page-chat .chat-heading{display:flex;flex-direction:column;justify-content:center}
@media(max-width:760px){body.page-chat .chat-heading p{font-size:11px}}
body.page-chat section[data-view="chat"]{flex:1;min-height:0;display:flex;flex-direction:column}

.chat-layout{display:grid;grid-template-columns:minmax(260px,340px) minmax(0,1fr);gap:14px;min-height:600px}
body.page-chat .chat-layout{flex:1;min-height:0}
.chat-sidebar,.chat-panel{min-width:0;min-height:0;margin:0;display:flex;flex-direction:column;overflow:hidden}
.chat-sidebar{gap:10px}
.chat-sidebar-head{display:flex;align-items:center;justify-content:space-between;gap:8px;flex:none}
.chat-sidebar-head h2{margin:0}
.signature-card{max-width:740px}
.signature-toolbar{display:flex;flex-wrap:wrap;gap:7px;margin:8px 0}
.signature-toolbar .btn{min-width:39px;justify-content:center}
.signature-card textarea{width:100%;resize:vertical;min-height:115px}
.signature-preview{padding:14px;min-height:60px;border:1px solid var(--line);border-radius:10px;background:var(--bg);white-space:normal;overflow-wrap:anywhere}
.signature-preview code{white-space:pre-wrap;background:var(--panel);padding:1px 3px;border-radius:3px}
.signature-card small{display:block;margin-top:5px}
.chat-unread{margin-left:auto;min-width:20px;padding:1px 5px;border-radius:12px;background:var(--brand);color:var(--brand-ink);font-size:11px;text-align:center}
.chat-typing{color:var(--brand);font-size:12px;font-weight:600}
.chat-notices{position:fixed;top:16px;right:16px;z-index:30;max-width:min(360px,calc(100vw - 32px));display:flex;flex-direction:column;gap:8px;pointer-events:none}
.chat-notice{padding:11px 14px;background:var(--panel);color:var(--text);border:1px solid var(--line);border-left:4px solid var(--brand);border-radius:8px;box-shadow:var(--shadow);font-size:13px;overflow-wrap:anywhere}
.chat-notice:is(button){pointer-events:auto;cursor:pointer;text-align:left;font:inherit;font-size:13px;width:100%}
.chat-notice:is(button):hover,.chat-notice:is(button):focus-visible{border-color:var(--brand);outline:2px solid var(--brand);outline-offset:2px}
.chat-notice.typing{border-left-color:var(--info)}
.chat-new-trigger{width:34px;height:34px;padding:6px;display:inline-flex;align-items:center;justify-content:center;flex:none}
#chatNotificationsBtn:not(.enabled){color:var(--muted);background:var(--bg);border-color:var(--line)}
#chatNotificationsBtn.enabled{color:var(--brand);border-color:var(--brand)}
.chat-new-trigger svg{width:18px;height:18px}
.chat-search-row{display:contents}
@media(min-width:761px){
  body.page-chat .chat-sidebar-head{display:none}
  body.page-chat .chat-search-row{display:flex;align-items:center;gap:8px;flex:none}
  body.page-chat .chat-search-row .chat-search{flex:1;min-width:0;width:auto}
  body.page-chat #chatFilterWrap{border:0;padding:0;margin:0;width:185px;flex:none}
  body.page-chat #chatFilterWrap .chat-filter-title{display:none}
  body.page-chat #chatFunnelTopbar{max-width:none;min-width:0}
  body.page-chat #chatFunnelFilter{flex:0 1 160px;width:160px;min-width:120px}
  body.page-chat #chatContactGroupFilter{flex:0 1 170px;width:170px;min-width:125px}
}
.chat-mobile-filter-actions,.chat-mobile-filter-panel,#chatNewMobileToggle{display:none}
.chat-search{width:100%;flex:none;padding:8px 10px;border:1px solid var(--line);border-radius:8px;background:var(--bg);color:inherit;font:inherit}
.chat-filter-wrap,.chat-new-wrap{flex:none;border:1px solid var(--line);border-radius:8px;padding:8px 10px}
.chat-filter-title{display:block;font-size:13px;font-weight:600;color:var(--text);margin-bottom:9px}
.chat-device-filter{width:100%;min-width:0;font-size:13px;cursor:pointer}
.chat-funnel-row{display:flex;gap:7px;align-items:center;flex:none}
.chat-funnel-row select{flex:1;min-width:0;font-size:13px}
#chatFunnelTopbar{margin-left:auto;max-width:300px;min-width:240px}
@media(max-width:760px){body.page-chat .topbar{flex-wrap:wrap}#chatFunnelTopbar{width:100%;max-width:none;margin-left:0}}
.chat-funnel-row button{flex:none;font-size:11px;padding:7px}
.chat-unread-count{display:inline-block;min-width:17px;text-align:center;border-radius:12px;background:var(--brand);color:var(--brand-ink);padding:2px 4px}
#chatFunnelAssign{margin-left:auto;max-width:150px;min-width:75px;font-size:12px}
.funnel-manager{max-width:700px}
.funnel-manager form{margin:18px 0}.funnel-manager form input{flex:1;min-width:180px}
.funnel-color-label{display:inline-flex;align-items:center;gap:7px;font-size:12px;white-space:nowrap;flex:none}
.funnel-manager .funnel-color-label input[type="color"]{flex:none;min-width:0;width:36px;height:32px;padding:2px;cursor:pointer}
.funnel-dot{display:inline-block;width:10px;height:10px;border-radius:50%;margin-right:7px;vertical-align:middle;flex:none}
.funnel-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 0;border-top:1px solid var(--line)}
.funnel-row b{overflow-wrap:anywhere}
.chat-list{flex:1;min-height:0;overflow-y:auto;margin:0 -14px -14px;border-top:1px solid var(--line)}
.chat-item{display:flex;align-items:center;gap:10px;width:100%;padding:10px 14px;text-align:left;border:0;border-bottom:1px solid var(--line);background:transparent;color:inherit;cursor:pointer}
.chat-item.selected,.chat-item:hover{background:var(--bg)}
.chat-item-avatar{flex:none;width:40px;height:40px;border-radius:50%;background:var(--brand-soft);color:var(--brand);display:flex;align-items:center;justify-content:center;font-weight:700;font-size:15px}
.chat-item-avatar,.chat-avatar{position:relative;overflow:hidden}
.chat-item-avatar img,.chat-avatar img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;border-radius:50%;background:var(--brand-soft)}
.chat-item-body{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}
.chat-item-row{display:flex;justify-content:space-between;align-items:baseline;gap:6px}
.chat-item-body b{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px}
.chat-item-row small{flex:none;font-size:11px;color:var(--muted)}
.chat-item-body span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;color:var(--muted)}
.chat-panel{gap:12px}
.chat-head{flex:none;display:flex;align-items:center;gap:10px}
.chat-back{display:none;flex:none}
.chat-avatar{flex:none;width:38px;height:38px;border-radius:50%;background:var(--brand-soft);color:var(--brand);display:flex;align-items:center;justify-content:center;font-weight:700}
.chat-head-info{display:flex;flex-direction:column;min-width:0}
.chat-head-info b{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chat-new{flex-wrap:wrap}.chat-new select{flex:1 1 150px}.chat-new input{flex:2 1 210px}
.chat-thread{flex:1;min-height:200px;overflow-y:auto;display:flex;flex-direction:column;gap:9px;padding:14px;background:var(--bg);border-radius:8px}
.chat-bubble{max-width:82%;width:max-content;padding:9px 12px;border-radius:12px;background:var(--panel);overflow-wrap:anywhere;white-space:pre-wrap;box-shadow:var(--shadow)}
.chat-bubble.out{align-self:flex-end;background:var(--brand-soft)}.chat-bubble.in{align-self:flex-start}
.chat-bubble img{max-width:100%;max-height:260px;border-radius:8px;display:block;cursor:pointer}
.chat-bubble .chat-file{display:flex;align-items:center;gap:8px;padding:4px 2px;color:inherit;text-decoration:none}
.chat-bubble .chat-file-icon{font-size:22px;flex:none}
.chat-bubble .chat-file-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:220px;text-decoration:underline}
.chat-bubble .chat-caption{margin-top:6px}
.chat-sender{display:block;color:var(--brand);font-size:12px;margin-bottom:4px}
.chat-quote,.chat-reply-preview{border-left:3px solid var(--brand);background:var(--bg);padding:6px 9px;border-radius:4px;font-size:12px;overflow-wrap:anywhere}
.chat-quote{margin-bottom:8px;max-height:65px;overflow:hidden}
.chat-reply-preview{display:flex;align-items:center;justify-content:space-between;gap:8px;flex:none}
.chat-reply-preview span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chat-bubble-footer{display:flex;align-items:center;justify-content:space-between;gap:12px}
.chat-reply-btn{color:var(--brand);background:none;border:0;cursor:pointer;padding:2px 0;font:inherit;font-size:11px}
.chat-reply-btn:hover{text-decoration:underline}
.chat-actions{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.chat-forwarded{font-style:italic;text-align:left!important;margin:0 0 5px!important}
.chat-forward-dialog{flex:none;display:flex;align-items:center;gap:9px;flex-wrap:wrap;padding:12px;border:1px solid var(--border);border-radius:9px;background:var(--panel)}
.chat-forward-dialog label{font-size:12px;font-weight:700}
.chat-forward-dialog select{flex:1 1 220px;min-width:0}
.chat-forward-dialog .btns{display:flex;gap:7px}
.chat-bubble small{display:block;margin-top:5px;text-align:right;font-size:10px;color:#52605a}
.chat-checks{display:inline-block;font-size:14px;font-weight:800;letter-spacing:-3px;padding-right:3px;vertical-align:-1px;color:var(--muted)}
.chat-checks.read{color:#156ac5}
.chat-attach-preview{flex:none;display:flex;align-items:center;justify-content:space-between;gap:8px;padding:7px 10px;background:var(--bg);border-radius:8px;font-size:12px}
.chat-image-menu{position:fixed;z-index:1200;min-width:155px;padding:5px;background:var(--panel);border:1px solid var(--border);border-radius:8px;box-shadow:var(--shadow)}
.chat-image-menu[hidden]{display:none}
.chat-image-menu button{display:block;width:100%;padding:8px 10px;text-align:left;border:0;border-radius:5px;background:transparent;color:inherit;cursor:pointer;font:inherit;font-size:13px}
.chat-image-menu button:hover,.chat-image-menu button:focus-visible{background:var(--brand-soft);outline:2px solid var(--brand)}
.chat-compose{flex:none;display:flex;align-items:flex-end;gap:9px}
.chat-compose textarea{min-width:0;flex:1;resize:none;max-height:120px}
.chat-attach-btn{flex:none;font-size:17px;line-height:1;padding:8px 11px}
.manage-card{max-width:960px}
.manage-list{display:grid;gap:10px;margin-top:20px}
.manage-row{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:12px;border:1px solid var(--border);border-radius:9px;min-width:0}
.manage-row>div:first-child{min-width:0;overflow-wrap:anywhere}
.manage-row p{margin:5px 0;white-space:pre-wrap;overflow-wrap:anywhere}
.employee-head,.employee-list-head{display:flex;align-items:center;justify-content:space-between;gap:16px}
.employee-head{flex-wrap:wrap;padding-bottom:20px;border-bottom:1px solid var(--border)}
.employee-head h2,.employee-list-head h3{margin:0}
.employee-head p{margin:6px 0 0}
.employee-list-head{margin-top:22px}
.employee-list-head h3{font-size:16px}
.employee-list{margin-top:12px}
.employee-row{padding:14px 16px;min-height:76px}
.employee-person{display:flex;align-items:center;gap:12px;min-width:0;flex:1}
.employee-initial{width:38px;height:38px;flex:none;border-radius:50%;display:grid;place-items:center;background:var(--brand-soft);color:var(--brand);font-weight:700}
.employee-identity{min-width:0;display:grid;gap:2px}
.employee-identity b,.employee-identity span,.employee-identity small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.employee-identity span,.employee-identity small{color:var(--muted);font-size:12px}
.employee-actions{display:flex;align-items:center;gap:7px;flex:none}
.employee-status{border-radius:99px;padding:4px 9px;background:var(--brand-soft);color:var(--brand);font-size:11px;font-weight:700}
.employee-status.inactive{background:var(--bg);color:var(--muted)}
.employee-empty{border:1px dashed var(--border);border-radius:10px;padding:36px 18px;text-align:center}
.employee-empty p{margin:8px 0 0}
.employee-form-panel{border:1px solid var(--border);border-radius:10px;padding:20px;margin-top:22px;background:var(--bg)}
.employee-form-head{margin-bottom:16px}.employee-form-head h3{margin:0}.employee-form-head p{margin:6px 0 0}
.permission-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:18px 0 8px}
.permission-heading .muted{font-size:12px;white-space:nowrap}
.permission-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px;margin-bottom:18px}
.permission-grid.menu-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
.permission-grid label{display:flex;align-items:center;gap:12px;min-width:0;min-height:54px;margin:0;padding:10px 12px;border:1px solid var(--border);border-radius:9px;background:var(--panel);cursor:pointer;transition:background .15s,border-color .15s}
.permission-grid label:hover{border-color:var(--brand)}
.permission-grid label:has(input:checked){background:var(--brand-soft);border-color:var(--brand)}
.permission-grid input[type="checkbox"]{width:18px;height:18px;min-width:18px;flex:none;margin:0;padding:0;accent-color:var(--brand);cursor:pointer}
.permission-label{display:block;min-width:0;overflow-wrap:anywhere;line-height:1.3}
.permission-label strong{display:block;font-weight:600}
.permission-label small{display:block;color:var(--muted);margin-top:3px;font-weight:400}
.employee-enabled{display:inline-flex;align-items:center;gap:9px;margin:0 0 18px;cursor:pointer}
#employeeEnabled{width:18px;height:18px;flex:none;margin:0;padding:0;accent-color:var(--brand);cursor:pointer}
.quick-reply-choices{max-height:250px;overflow:auto;border:1px solid var(--border);border-radius:8px;background:var(--panel);box-shadow:var(--shadow)}
.quick-choice{display:flex;width:100%;gap:14px;align-items:center;text-align:left;padding:9px 12px;background:transparent;color:inherit;border:0;cursor:pointer}
.quick-choice:hover,.quick-choice.selected{background:var(--brand-soft)}
.quick-choice span{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;color:var(--muted)}
.pd-more{margin-top:12px}
.pd-more summary{cursor:pointer;color:var(--brand);font-weight:700;border:1px solid var(--border);border-radius:8px;padding:9px 12px;list-style:none}
.pd-more summary::-webkit-details-marker{display:none}
.pd-more summary::after{content:'⌄';float:right}
.pd-more[open] summary::after{transform:rotate(180deg)}
@media(max-width:640px){.permission-grid,.permission-grid.menu-grid{grid-template-columns:1fr}}
@media(max-width:550px){.manage-row{flex-direction:column;align-items:stretch}.employee-actions{justify-content:flex-end}.employee-head .btn{width:100%}.employee-form-panel{padding:14px}}
@media(max-width:760px){
  body.page-chat,body.page-chat .layout{height:100dvh}
  body.page-chat .main{height:100dvh;padding:0}
  body.page-chat .topbar{flex-wrap:nowrap;min-height:56px;margin:0;padding:8px 12px;background:var(--panel);border-bottom:1px solid var(--line)}
  body.page-chat .chat-topbar-row{display:flex;flex-wrap:nowrap;width:100%}
  body.page-chat .chat-topbar-row > .menu-btn{flex:0 0 40px;width:40px;height:40px;justify-content:center}
  body.page-chat .chat-topbar-row > .chat-heading{flex:1 1 auto;min-width:0}
  body.page-chat .topbar h1{font-size:20px}
  body.page-chat #chatSubtitle{display:none}
  body.page-chat #chatFunnelTopbar{display:none}
  body.page-chat .chat-sidebar,body.page-chat .chat-panel{border:0;border-radius:0;box-shadow:none;padding:0}
  body.page-chat .chat-sidebar{position:relative;overflow:visible}
  body.page-chat .chat-sidebar-head{min-height:34px;padding:10px 12px 0}
  body.page-chat #chatSignatureBtn,body.page-chat #chatNotificationsBtn{display:none}
  body.page-chat .chat-sidebar-head h2{display:none}
  body.page-chat #chatNewToggle,body.page-chat #chatFilterWrap{display:none}
  body.page-chat .chat-sidebar-head .btns{display:none}
  body.page-chat .chat-mobile-filter-actions{display:flex;gap:5px;margin-left:auto}
  body.page-chat .chat-mobile-filter-actions .btn{padding:5px 7px;font-size:11px;white-space:nowrap}
  body.page-chat .chat-mobile-filter-actions .btn[aria-expanded="true"]{color:var(--brand);border-color:var(--brand)}
  body.page-chat .chat-mobile-filter-panel{display:block;position:absolute;top:44px;right:12px;width:min(300px,calc(100% - 24px));z-index:30;padding:12px;background:var(--panel);border:1px solid var(--line);border-radius:10px;box-shadow:0 12px 30px rgba(0,0,0,.18)}
  body.page-chat .chat-mobile-filter-panel label{display:block;font-weight:700;margin-bottom:7px;font-size:12px}
  body.page-chat .chat-mobile-filter-panel select{width:100%;min-width:0}
  body.page-chat .chat-mobile-filter-panel .btn{margin-top:10px}
  body.page-chat .chat-search-row{display:flex;align-items:center;gap:8px;flex:none;padding:0 12px 10px}
  body.page-chat .chat-new-wrap{margin:0 12px}
  body.page-chat .chat-list{margin:0;border-top:1px solid var(--line)}
  body.page-chat .chat-panel{gap:0}
  body.page-chat .chat-head{padding:10px 12px;min-height:60px;border-bottom:1px solid var(--line)}
  body.page-chat .chat-head-info{flex:1;min-width:0}
  body.page-chat #chatInfo{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  body.page-chat #chatFunnelAssign{flex:0 1 115px;min-width:0;max-width:115px;font-size:11px;padding:6px}
  body.page-chat .chat-thread{min-height:0;border-radius:0}
  body.page-chat .chat-compose,body.page-chat .chat-attach-preview,body.page-chat .chat-reply-preview,body.page-chat .chat-forward-dialog{padding:9px 12px}
  body.page-chat .chat-search-row .chat-search{flex:1;min-width:0;width:auto}
  body.page-chat #chatNewMobileToggle{display:inline-flex;width:40px;height:40px;font-size:23px}
}
@media(max-width:820px){
  .chat-layout{grid-template-columns:1fr;min-height:0}
  .chat-panel{display:none}
  .chat-layout.chat-open .chat-sidebar{display:none}
  .chat-layout.chat-open .chat-panel{display:flex}
  .chat-back{display:inline-flex}
}
