:root {
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-2: #f6f8f7;
  --border: #e3e8e6;
  --text: #10201c;
  --muted: #5f706b;
  --primary: #0f7b6c;
  --primary-hover: #0b6357;
  --primary-soft: #e2f3ef;
  --accent: #25d366;
  --danger: #d03a2f;
  --danger-soft: #fdecea;
  --warn-bg: #fff5d9;
  --warn-text: #6b5300;
  --sidebar: #0b3a33;
  --sidebar-text: #c6dcd6;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --chat-bg: #efeae2;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1412;
    --surface: #121d1a;
    --surface-2: #17241f;
    --border: #243530;
    --text: #e5eeeb;
    --muted: #8ea19b;
    --primary: #22a08c;
    --primary-hover: #2ab39d;
    --primary-soft: #133a33;
    --danger-soft: #3a1714;
    --warn-bg: #3a300c;
    --warn-text: #f0d98c;
    --sidebar: #07120f;
    --bubble-in: #1f2c33;
    --bubble-out: #005c4b;
    --chat-bg: #0b141a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 4px 0 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- form controls ---------- */
input, textarea {
  font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { resize: vertical; }
.field { display: grid; gap: 6px; font-weight: 500; margin-top: 14px; }
.hint { font-weight: 400; font-size: 12.5px; color: var(--muted); }
.hint.right { text-align: right; }
.form-error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 13px; }
.input-suffix { display: flex; align-items: stretch; }
.input-suffix input { border-radius: 10px 0 0 10px; }
.input-suffix span { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--border); border-left: 0; border-radius: 0 10px 10px 0; background: var(--surface-2); color: var(--muted); font-weight: 400; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 10px; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.block { width: 100%; padding: 11px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn:disabled { opacity: .35; cursor: default; background: transparent; }
.link-btn { background: none; border: 0; color: var(--primary); font: inherit; font-weight: 500; cursor: pointer; padding: 0; }

.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #c4ceca; border-radius: 99px; transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--primary-soft); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.logo {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  background: linear-gradient(135deg, #25d366, #0f7b6c); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 15px; letter-spacing: .02em;
}
.logo.lg { width: 60px; height: 60px; border-radius: 18px; font-size: 22px; margin: 0 auto 6px; }
.logo.sm { width: 34px; height: 34px; border-radius: 50%; font-size: 13px; }

.avatar { width: 42px; height: 42px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-weight: 600; flex: none; }
.avatar .ic { width: 20px; height: 20px; }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 10% -10%, var(--primary-soft), transparent), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 32px 28px; box-shadow: var(--shadow-lg); text-align: center; }
.login-card .field { text-align: left; }
.login-card .btn { margin-top: 8px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; height: 100vh; height: 100dvh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; gap: 22px; padding: 18px 12px; min-width: 0; }
.sb-brand { display: flex; align-items: center; gap: 11px; padding: 2px 6px; min-width: 0; }
.sb-brand-text { min-width: 0; }
.sb-brand .brand-name { color: #fff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-sub { font-size: 12px; opacity: .7; }
.nav { display: grid; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px;
  border: 0; border-radius: 10px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.active { background: rgba(255, 255, 255, .13); color: #fff; font-weight: 600; }
.nav-badge { margin-left: auto; background: var(--accent); color: #053321; font-size: 11.5px; font-weight: 700; border-radius: 99px; padding: 1px 8px; }
.sb-foot { margin-top: auto; display: grid; gap: 8px; }
.status-pill { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 8px 12px; border-radius: 10px; background: rgba(255,255,255,.06); }
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #8a9a95; }
.status-pill.on .dot { background: var(--accent); box-shadow: 0 0 0 3px rgba(37, 211, 102, .25); }

.main { min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.page { flex: 1; overflow-y: auto; padding: 28px 32px 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; max-width: 1200px; }
.head-chip { background: var(--surface); border: 1px solid var(--border); border-radius: 99px; padding: 5px 12px; font-size: 13px; color: var(--muted); white-space: nowrap; }

/* ---------- dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; max-width: 1200px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; gap: 14px; align-items: flex-start; box-shadow: var(--shadow); }
.stat-ic { width: 40px; height: 40px; border-radius: 11px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex: none; }
.stat-val { font-size: 26px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-weight: 500; margin-top: 2px; }
.stat-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 14px; margin-top: 14px; max-width: 1200px; }
.recent { list-style: none; margin: 12px 0 0; padding: 0; }
.recent li { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 10px; cursor: pointer; }
.recent li:hover { background: var(--surface-2); }
.recent .r-main { flex: 1; min-width: 0; }
.recent .r-empty { cursor: default; color: var(--muted); justify-content: center; padding: 28px 8px; }
.recent .r-empty:hover { background: none; }
.flow { display: grid; gap: 8px; margin-top: 14px; }
.flow-step { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-weight: 500; }
.flow-step span { width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }

/* ---------- chats ---------- */
.page.chats { padding: 0; overflow: hidden; display: grid; grid-template-columns: 360px 1fr; }
.chat-list { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.cl-top { padding: 18px 16px 10px; display: grid; gap: 12px; border-bottom: 1px solid var(--border); }
.search { position: relative; }
.search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search input { padding-left: 34px; background: var(--surface-2); border-color: transparent; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; justify-self: start; }
.seg button { font: inherit; font-weight: 500; font-size: 13px; border: 0; background: none; color: var(--muted); padding: 5px 14px; border-radius: 8px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.contacts { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.contacts li { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 12px; cursor: pointer; }
.contacts li:hover { background: var(--surface-2); }
.contacts li.active { background: var(--primary-soft); }
.contacts .c-empty { cursor: default; color: var(--muted); text-align: center; display: block; padding: 32px 16px; }
.contacts .c-empty:hover { background: none; }
.c-main { min-width: 0; flex: 1; }
.c-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.c-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-time { color: var(--muted); font-size: 12px; flex: none; }
.c-time.unread { color: var(--primary); font-weight: 600; }
.c-preview { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; font-size: 13px; }
.badge { background: var(--accent); color: #053321; border-radius: 99px; min-width: 20px; height: 20px; padding: 0 6px; font-size: 11.5px; font-weight: 700; display: grid; place-items: center; flex: none; }

.chat-thread { min-height: 0; display: flex; flex-direction: column; background: var(--chat-bg); }
.thread-empty, .empty-state { margin: auto; text-align: center; max-width: 340px; padding: 40px 20px; }
.te-icon { width: 64px; height: 64px; border-radius: 20px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; margin: 0 auto 14px; }
.te-icon .ic { width: 28px; height: 28px; }
.thread { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.thread-head { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.th-info { flex: 1; min-width: 0; }
.th-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back-btn { display: none; }
.messages { flex: 1; overflow-y: auto; padding: 18px 7%; display: flex; flex-direction: column; gap: 4px; }
.msg {
  position: relative; max-width: min(520px, 78%); padding: 6px 9px 5px; border-radius: 10px;
  background: var(--bubble-in); align-self: flex-start; box-shadow: 0 1px .5px rgba(0, 0, 0, .13); word-wrap: break-word;
}
.msg.out { align-self: flex-end; background: var(--bubble-out); }
.msg.gap { margin-top: 8px; }
.msg .body { white-space: pre-wrap; }
.msg img, .msg video { display: block; width: 300px; max-width: 100%; max-height: 300px; object-fit: cover; border-radius: 7px; margin-bottom: 4px; cursor: zoom-in; }
.msg audio { max-width: 260px; }
.msg .meta { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; display: flex; justify-content: flex-end; gap: 4px; align-items: center; }
.msg .tick.read { color: #34b7f1; }
.msg .err { font-size: 12px; color: var(--danger); margin-top: 3px; }
.msg .tag { font-size: 10.5px; font-weight: 600; color: var(--primary); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 3px; display: flex; align-items: center; gap: 4px; }
.msg .tag .ic { width: 12px; height: 12px; }
.msg.failed { outline: 1px solid var(--danger); }
.day { align-self: center; background: var(--surface); color: var(--muted); font-size: 12px; padding: 4px 12px; border-radius: 8px; margin: 10px 0 6px; box-shadow: var(--shadow); }
.window-note { background: var(--warn-bg); color: var(--warn-text); padding: 9px 16px; font-size: 12.5px; }
.composer { display: flex; gap: 10px; align-items: flex-end; padding: 10px 14px; background: var(--surface); border-top: 1px solid var(--border); }
.composer textarea { resize: none; max-height: 140px; border-radius: 20px; padding: 10px 16px; background: var(--surface-2); border-color: transparent; }
.send-btn { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
.send-btn:hover { background: var(--primary-hover); }
.send-btn:disabled { opacity: .6; }

/* ---------- media ---------- */
.upload-card { max-width: 1200px; padding: 14px; }
.dropzone {
  display: grid; justify-items: center; gap: 4px; text-align: center; padding: 26px 16px; cursor: pointer;
  border: 2px dashed var(--border); border-radius: 12px; background: var(--surface-2); transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dz-icon { width: 46px; height: 46px; border-radius: 14px; background: var(--surface); color: var(--primary); display: grid; place-items: center; box-shadow: var(--shadow); margin-bottom: 6px; }
.queue { display: grid; gap: 8px; margin-top: 12px; }
.q-item { display: flex; align-items: center; gap: 12px; padding: 8px; border: 1px solid var(--border); border-radius: 12px; }
.q-item.bad { border-color: var(--danger); background: var(--danger-soft); }
.q-thumb { width: 56px; height: 56px; border-radius: 9px; overflow: hidden; background: #000; flex: none; }
.q-thumb img, .q-thumb video { width: 100%; height: 100%; object-fit: cover; }
.q-main { flex: 1; min-width: 0; display: grid; gap: 6px; }
.q-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-err { color: var(--danger); font-size: 13px; }
.q-actions { display: flex; justify-content: flex-end; gap: 8px; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-top: 16px; max-width: 1200px; }
.media-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s, opacity .15s; }
.media-card.inactive .thumb > img, .media-card.inactive .thumb > video { opacity: .4; filter: grayscale(.6); }
.media-card.dragging { opacity: .4; }
.media-card.drop-target { box-shadow: 0 0 0 3px var(--primary); transform: scale(1.01); }
.thumb { position: relative; aspect-ratio: 4 / 3; background: #0c0f0e; cursor: zoom-in; }
.thumb > img, .thumb > video { width: 100%; height: 100%; object-fit: cover; display: block; }
.pos { position: absolute; top: 10px; left: 10px; background: rgba(0, 0, 0, .62); color: #fff; border-radius: 8px; padding: 2px 9px; font-size: 12px; font-weight: 600; }
.off-chip { position: absolute; top: 10px; right: 10px; background: rgba(0, 0, 0, .62); color: #fff; border-radius: 8px; padding: 2px 9px; font-size: 12px; }
.play { position: absolute; inset: 0; margin: auto; width: 48px; height: 48px; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; display: grid; place-items: center; pointer-events: none; }
.play .ic { fill: #fff; stroke: none; width: 20px; height: 20px; margin-left: 3px; }
.grip { position: absolute; bottom: 10px; right: 10px; width: 32px; height: 32px; border-radius: 9px; background: rgba(255, 255, 255, .92); color: #333; display: grid; place-items: center; cursor: grab; border: 0; }
.grip .ic { stroke-width: 3.2; }
.mc-body { padding: 12px; display: grid; gap: 10px; }
.mc-meta { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; min-width: 0; }
.mc-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-meta .ic { width: 15px; height: 15px; }
.mc-body textarea { min-height: 60px; font-size: 13.5px; }
.mc-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mc-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; cursor: pointer; }
.mc-actions { display: flex; gap: 2px; }
.save-cap { padding: 5px 12px; font-size: 13px; }

/* ---------- settings ---------- */
.settings-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; max-width: 1200px; align-items: start; }
.settings-col { display: grid; gap: 14px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.choice input { width: auto; margin-top: 3px; accent-color: var(--primary); }
.choice span { display: grid; gap: 2px; }
.choice small { color: var(--muted); font-size: 12.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { background: var(--primary-soft); color: var(--primary); border-radius: 99px; padding: 3px 10px; font-size: 12.5px; font-weight: 500; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.save-bar {
  position: sticky; bottom: 0; display: flex; justify-content: flex-end; align-items: center; gap: 12px;
  padding: 12px 0; background: linear-gradient(transparent, var(--bg) 35%);
}
.preview-col { position: sticky; top: 0; }
.phone { border-radius: 26px; overflow: hidden; border: 8px solid #1d2422; box-shadow: var(--shadow-lg); background: var(--chat-bg); }
.phone-head { display: flex; align-items: center; gap: 10px; background: #075e54; color: #fff; padding: 10px 12px; }
.phone-head .brand-name { font-weight: 600; font-size: 14px; }
.phone-sub { font-size: 11.5px; opacity: .8; }
.phone-body { display: flex; flex-direction: column; gap: 5px; padding: 12px 10px 16px; min-height: 420px; max-height: 560px; overflow-y: auto; }
.pv-msg { max-width: 82%; padding: 6px 8px; border-radius: 8px; font-size: 13px; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px .5px rgba(0, 0, 0, .13); background: var(--bubble-in); align-self: flex-start; }
.pv-msg.out { align-self: flex-end; background: var(--bubble-out); }
.pv-msg.media { padding: 3px; width: 62%; }
.pv-msg.media img, .pv-msg.media video { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 6px; display: block; }
.pv-cap { padding: 4px 5px 2px; }
.pv-note { align-self: center; font-size: 12px; color: var(--muted); background: var(--surface); border-radius: 8px; padding: 3px 10px; margin: 4px 0; }

/* ---------- overlays ---------- */
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .85); z-index: 50; display: grid; place-items: center; padding: 24px; }
.lb-body img, .lb-body video { max-width: 92vw; max-height: 86vh; border-radius: 10px; display: block; }
.lb-close { position: absolute; top: 16px; right: 16px; color: #fff; background: rgba(255, 255, 255, .12); }
.lb-close:hover { background: rgba(255, 255, 255, .22); color: #fff; }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: #1f2a27; color: #fff; padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px);
}
.toast.error { background: var(--danger); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .settings-layout { grid-template-columns: 1fr; }
  .preview-col { position: static; max-width: 380px; width: 100%; margin: 0 auto; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { flex-direction: row; align-items: center; gap: 8px; padding: 8px 12px; }
  .sb-brand-text, .status-pill, .nav-item span, .nav-badge { display: none; }
  .sb-brand { padding: 0; }
  .logo { width: 34px; height: 34px; border-radius: 10px; font-size: 13px; }
  .nav { display: flex; gap: 2px; flex: 1; justify-content: center; }
  .nav-item { width: auto; padding: 10px 14px; position: relative; }
  .nav-item[data-tab="chats"]:has(.nav-badge:not(.hidden))::after { content: ""; position: absolute; top: 8px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
  .sb-foot { margin: 0; }
  .page { padding: 20px 16px 40px; }
  .page.chats { grid-template-columns: 1fr; }
  .page.chats.has-thread .chat-list { display: none; }
  .page.chats:not(.has-thread) .chat-thread { display: none; }
  .back-btn { display: inline-grid; }
  #send-catalog span { display: none; }
  .messages { padding: 14px 12px; }
  .page-head { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; flex-direction: column; gap: 10px; }
  .choices, .two-col { grid-template-columns: 1fr; }
  .media-grid { grid-template-columns: 1fr; }
}

/* ---------- box enquiry ---------- */
.enquiry-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; padding: 9px 16px; background: var(--surface); border-bottom: 1px solid var(--border); font-size: 13px; }
.eq-item { display: flex; gap: 6px; align-items: baseline; }
.eq-label { color: var(--muted); }
.eq-status { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--warn-bg); color: var(--warn-text); }
.eq-status.done { background: var(--primary-soft); color: var(--primary); }
.e-tag { flex: none; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--warn-bg); color: var(--warn-text); }
.e-tag.done { background: var(--primary-soft); color: var(--primary); }

.guide-row { display: flex; gap: 14px; align-items: center; font-weight: 400; }
.guide-thumb { width: 96px; height: 96px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); display: grid; place-items: center; flex: none; }
.guide-thumb img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.guide-actions { display: grid; gap: 4px; }
.btn-row.tight { margin-top: 4px; }
.disabled { opacity: .45; pointer-events: none; }
.chip.bad { background: var(--danger-soft); color: var(--danger); }

.pv-msg.list { padding-bottom: 0; overflow: hidden; }
.pv-list-btn { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 6px -8px 0; padding: 8px; border-top: 1px solid var(--border); color: #027eb5; font-weight: 500; }
.pv-list-btn .ic { width: 15px; height: 15px; }
@media (max-width: 560px) { .guide-row { align-items: flex-start; } }
.phone-body > * { flex-shrink: 0; }

/* ---------- inquiries ---------- */
select {
  font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 30px 9px 12px; cursor: pointer; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%; background-size: 5px 5px; background-repeat: no-repeat;
}
select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
a.btn { text-decoration: none; }
.nowrap { white-space: nowrap; }
.enq-stats { margin-bottom: 14px; }
.stat-btn { font: inherit; color: inherit; text-align: left; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.stat-btn:hover { border-color: var(--primary); }
.stat-btn.on { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.cat-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; max-width: 1200px; }
.cat-chip { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-size: 13px; font-weight: 500; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.cat-chip b { font-size: 11.5px; background: var(--surface-2); color: var(--muted); border-radius: 99px; padding: 0 7px; }
.cat-chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.cat-chip.on b { background: rgba(255,255,255,.22); color: #fff; }
.enq-card { padding: 0; max-width: 1200px; overflow: hidden; }
.enq-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.enq-toolbar .search { flex: 1; min-width: 220px; }
.enq-toolbar .seg { margin-left: auto; }
.table-wrap { overflow-x: auto; }
.enq-table { width: 100%; border-collapse: collapse; }
.enq-table th { text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 10px 16px; background: var(--surface-2); white-space: nowrap; }
.enq-table td { padding: 12px 16px; border-top: 1px solid var(--border); vertical-align: middle; }
.enq-table tbody tr { cursor: pointer; transition: background .12s; }
.enq-table tbody tr:hover, .enq-table tbody tr:focus-visible { background: var(--surface-2); outline: none; }
.enq-table .chev { width: 36px; color: var(--muted); }
.cust-in { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cust-in .avatar { width: 36px; height: 36px; font-size: 13px; }
.cust-text { min-width: 0; }
.count-pill { display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 8px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 12.5px; }
.chips.tight { margin: 0; gap: 4px; }

.pill { display: inline-block; white-space: nowrap; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; }
.pill.green { background: #e2f6ea; color: #137a3f; }
.pill.amber { background: var(--warn-bg); color: var(--warn-text); }
.pill.blue { background: #e3eefc; color: #1d5fb8; }
.pill.purple { background: #efe6fb; color: #6b3fb0; }
.pill.grey { background: var(--surface-2); color: var(--muted); }
@media (prefers-color-scheme: dark) {
  .pill.green { background: #133a25; color: #7ddca3; }
  .pill.blue { background: #15283f; color: #8fbcf5; }
  .pill.purple { background: #2a1d3f; color: #c7a8f3; }
}

.eq-open { margin-left: auto; display: inline-flex; align-items: center; gap: 2px; font-size: 13px; }
.eq-open .ic { width: 15px; height: 15px; }

/* drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(8, 20, 17, .45); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); background: var(--surface); z-index: 41; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: slide-in .18s ease-out; }
@keyframes slide-in { from { transform: translateX(24px); opacity: .6; } }
.dr-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.dr-title { flex: 1; min-width: 0; }
.dr-body { flex: 1; overflow-y: auto; padding: 16px 18px 28px; display: grid; gap: 16px; align-content: start; }
.dr-actions { display: flex; gap: 8px; }
.dr-section { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.dr-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dr-section .field:first-of-type { margin-top: 10px; }
.size-inputs { display: flex; align-items: center; gap: 6px; }
.size-inputs input { min-width: 0; text-align: center; padding-left: 6px; padding-right: 6px; }
.size-inputs span { color: var(--muted); }
.size-inputs select { flex: none; width: 84px; }
.stage-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stage-pick button { font: inherit; font-size: 13px; font-weight: 500; padding: 8px 4px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.stage-pick button.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.dr-save { display: flex; justify-content: space-between; margin-top: 16px; }
.danger-text { color: var(--danger); }
.history { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.history li { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; cursor: pointer; display: grid; gap: 3px; }
.history li:hover { background: var(--surface-2); }
.history li.current { border-color: var(--primary); background: var(--primary-soft); cursor: default; }
.hi-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hi-note { font-size: 12.5px; color: var(--text); background: var(--surface); border-radius: 8px; padding: 5px 8px; margin-top: 3px; }

/* mobile: table rows become cards */
@media (max-width: 760px) {
  .enq-toolbar .search { min-width: 100%; }
  .enq-toolbar select { flex: 1; }
  .enq-toolbar .seg { margin-left: 0; }
  .enq-table thead { display: none; }
  .enq-table, .enq-table tbody, .enq-table tr, .enq-table td { display: block; }
  .enq-table tr { position: relative; padding: 12px 16px; border-top: 1px solid var(--border); }
  .enq-table td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; }
  .enq-table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; }
  .enq-table td.cust { padding-bottom: 8px; }
  .enq-table td.chev { position: absolute; top: 18px; right: 12px; width: auto; }
  .stage-pick { grid-template-columns: repeat(2, 1fr); }
}
