:root {
  --ink: #1B2330;
  --ink-2: #4A5568;
  --ink-3: #7A8496;
  --paper: #F3F5F8;
  --panel: #FFFFFF;
  --line: #DCE1E8;
  --line-2: #EBEEF2;
  --indigo: #2F4BB8;
  --indigo-ink: #FFFFFF;
  --indigo-soft: #E8ECFB;
  --marigold: #F2B33D;
  --marigold-soft: #FFF3D6;
  --marigold-ink: #6B4700;
  --leaf: #2E7D5B;
  --leaf-soft: #E3F3EA;
  --rose: #B4323C;
  --rose-soft: #FBE6E8;
  --bubble-customer: #FFFFFF;
  --bubble-ai: var(--indigo-soft);
  --bubble-team: var(--marigold-soft);
  --bubble-campaign: #EEF0F3;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --font: 'Onest', 'Noto Sans Devanagari', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --rail: 76px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #E7EAF0; --ink-2: #B5BCC9; --ink-3: #8790A1;
    --paper: #12161D; --panel: #1A1F28; --line: #2C3340; --line-2: #232935;
    --indigo: #7B91F0; --indigo-ink: #0E1430; --indigo-soft: #232C4F;
    --marigold: #F2B33D; --marigold-soft: #3A2E14; --marigold-ink: #F7D58E;
    --leaf: #6CC79B; --leaf-soft: #17321F; --rose: #F08A93; --rose-soft: #3B1D21;
    --bubble-customer: #222835; --bubble-campaign: #262B35;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.45;
  color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--indigo); }
:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 0.85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Buttons & inputs */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius-sm);
  padding: 7px 12px; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--indigo); border-color: var(--indigo); color: var(--indigo-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--rose); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn svg { width: 18px; height: 18px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 4px 9px; font-size: .85rem; }
input[type=text], input[type=email], input[type=password], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius-sm);
  padding: 8px 10px;
}
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
label.field { display: grid; gap: 5px; font-weight: 550; font-size: .9rem; }
label.field .hint { font-weight: 400; color: var(--ink-3); font-size: .82rem; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.form { display: grid; gap: 14px; max-width: 640px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 550; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 38px; height: 22px; border-radius: 11px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .track { background: var(--leaf); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--indigo); outline-offset: 2px; }

/* ---------- Shell */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; height: 100vh; height: 100dvh; }
.rail {
  background: var(--ink); color: #fff; display: flex; flex-direction: column; align-items: center;
  padding: 14px 0; gap: 4px;
}
@media (prefers-color-scheme: dark) { .rail { background: #0B0E13; } }
.rail .logo { width: 36px; height: 36px; margin-bottom: 14px; }
.rail a {
  width: 64px; display: grid; justify-items: center; gap: 3px; padding: 8px 0; border-radius: var(--radius);
  color: #AEB7C6; text-decoration: none; font-size: .7rem; font-weight: 550; position: relative;
}
.rail a svg { width: 22px; height: 22px; }
.rail a:hover { color: #fff; background: rgba(255,255,255,.06); }
.rail a.active { color: #fff; background: rgba(255,255,255,.12); }
.rail .badge {
  position: absolute; top: 3px; right: 9px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--marigold); color: #3A2600; font-size: .7rem; font-weight: 700;
  display: grid; place-items: center;
}
.rail .badge[hidden] { display: none; }
.rail .bottom { margin-top: auto; }
.main { min-width: 0; overflow: auto; }
.page { padding: 28px 32px 60px; max-width: 1100px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { color: var(--ink-2); margin-top: 4px; }

/* ---------- Inbox */
.inbox { display: grid; grid-template-columns: 340px 1fr; height: 100%; min-height: 0; }
.inbox.with-details { grid-template-columns: 340px 1fr 300px; }
.list-pane { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.list-head { padding: 14px 14px 10px; display: grid; gap: 10px; border-bottom: 1px solid var(--line-2); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 3px 10px;
  font-size: .82rem; font-weight: 550; cursor: pointer; color: var(--ink-2);
}
.chip[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip .n { opacity: .7; margin-left: 3px; }
.list { overflow-y: auto; flex: 1; }
.conv {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 11px 14px; border-bottom: 1px solid var(--line-2);
  cursor: pointer; text-decoration: none; color: inherit; border-left: 3px solid transparent;
}
.conv:hover { background: var(--paper); }
.conv.active { background: var(--indigo-soft); }
.conv.needs { border-left-color: var(--marigold); }
.conv .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .when { font-size: .78rem; color: var(--ink-3); }
.conv .preview { color: var(--ink-2); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .meta { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.conv .num { grid-column: 1 / -1; font-size: .76rem; color: var(--ink-3); display: flex; gap: 6px; align-items: center; }
.unread { min-width: 20px; height: 20px; border-radius: 10px; background: var(--indigo); color: var(--indigo-ink); font-size: .72rem; font-weight: 700; display: grid; place-items: center; padding: 0 6px; }
.tag {
  display: inline-flex; align-items: center; gap: 4px; font-size: .74rem; font-weight: 600; border-radius: 4px; padding: 1px 6px;
  background: var(--line-2); color: var(--ink-2);
}
.tag.needs { background: var(--marigold-soft); color: var(--marigold-ink); }
.tag.ai { background: var(--indigo-soft); color: var(--indigo); }
.tag.off { background: var(--line-2); color: var(--ink-3); }
.tag.ok { background: var(--leaf-soft); color: var(--leaf); }
.tag.bad { background: var(--rose-soft); color: var(--rose); }

.thread-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.thread-head {
  padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--panel);
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.thread-head .title { min-width: 0; }
.thread-head .title h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { display: none; }
.handoff {
  margin: 12px 18px 0; padding: 10px 14px; border-radius: var(--radius); background: var(--marigold-soft);
  color: var(--marigold-ink); display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.handoff strong { font-weight: 650; }
.thread { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.day { align-self: center; font-size: .76rem; color: var(--ink-3); margin: 10px 0 4px; }
.msg { max-width: min(560px, 82%); display: grid; gap: 2px; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; }
.bubble {
  padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere;
  border: 1px solid var(--line-2);
}
.msg.in .bubble { background: var(--bubble-customer); border-bottom-left-radius: 4px; }
.msg.out .bubble { border-bottom-right-radius: 4px; }
.msg.ai .bubble { background: var(--bubble-ai); border-color: transparent; }
.msg.agent .bubble, .msg.phone .bubble { background: var(--bubble-team); border-color: transparent; }
.msg.campaign .bubble { background: var(--bubble-campaign); border-style: dashed; border-color: var(--line); }
.msg .by { font-size: .74rem; color: var(--ink-3); display: flex; gap: 6px; align-items: center; }
.msg.out .by { justify-content: flex-end; }
.msg.failed .bubble { border-color: var(--rose); }
.msg img.media { max-width: 260px; max-height: 260px; border-radius: var(--radius); display: block; margin-bottom: 4px; }
.note { align-self: center; font-size: .8rem; color: var(--ink-2); background: var(--line-2); border-radius: 999px; padding: 3px 12px; max-width: 90%; text-align: center; }
.legend { display: flex; gap: 12px; font-size: .76rem; color: var(--ink-3); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.composer { border-top: 1px solid var(--line); background: var(--panel); padding: 10px 14px; display: grid; gap: 8px; }
.composer form { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 44px; max-height: 160px; }
.composer .closed { color: var(--ink-2); font-size: .88rem; padding: 6px 2px; }
.details { border-left: 1px solid var(--line); background: var(--panel); overflow-y: auto; padding: 16px; display: grid; gap: 18px; align-content: start; }
.details section { display: grid; gap: 8px; }
.details h3 { font-size: .88rem; color: var(--ink-2); font-weight: 600; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: .88rem; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.events { display: grid; gap: 6px; font-size: .82rem; }
.events li { list-style: none; color: var(--ink-2); }
.events ul { margin: 0; padding: 0; display: grid; gap: 6px; }
.empty { display: grid; place-items: center; text-align: center; padding: 40px 20px; color: var(--ink-2); gap: 10px; height: 100%; align-content: center; }
.empty h2 { color: var(--ink); }

/* ---------- Tables & cards */
.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; font-size: .92rem; }
.table th { font-weight: 600; color: var(--ink-2); font-size: .82rem; background: var(--paper); }
.table tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; }
.stack { display: grid; gap: 16px; }
.split { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
.picklist { display: grid; gap: 2px; }
.picklist button {
  text-align: left; border: 0; background: transparent; padding: 9px 12px; border-radius: var(--radius-sm); cursor: pointer;
  display: grid; gap: 1px;
}
.picklist button:hover { background: var(--line-2); }
.picklist button[aria-current=true] { background: var(--indigo-soft); }
.picklist .sub { font-size: .8rem; color: var(--ink-3); }
.stats { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 22px; }
.stat b { display: block; font-size: 1.5rem; font-weight: 700; }
.stat span { font-size: .85rem; color: var(--ink-2); }
.stat.attn b { color: var(--marigold-ink); }
@media (prefers-color-scheme: dark) { .stat.attn b { color: var(--marigold); } }
.code { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: .85rem; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; overflow-wrap: anywhere; }
.task { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 14px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); align-items: start; }
.task:last-child { border-bottom: 0; }
.task input[type=checkbox] { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--leaf); }
.task.done .t-title { text-decoration: line-through; color: var(--ink-3); }
.task .report { grid-column: 2 / -1; white-space: pre-wrap; background: var(--paper); border-radius: var(--radius); padding: 10px 12px; font-size: .9rem; }
.bar { height: 8px; border-radius: 4px; background: var(--line-2); overflow: hidden; display: flex; min-width: 120px; }
.bar i { display: block; height: 100%; }

/* ---------- Dialog */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 0; width: min(640px, 94vw);
  background: var(--panel); color: var(--ink); box-shadow: 0 20px 60px rgba(15, 20, 30, .25);
}
dialog::backdrop { background: rgba(15, 20, 30, .45); }
dialog .d-head { padding: 18px 22px 0; }
dialog .d-body { padding: 16px 22px; display: grid; gap: 14px; max-height: 70vh; overflow-y: auto; }
dialog .d-foot { padding: 14px 22px 18px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--line-2); }
.err { color: var(--rose); font-size: .88rem; }

/* ---------- Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(380px, 100%); display: grid; gap: 18px; }
.login .mark { display: flex; gap: 12px; align-items: center; }
.login .mark svg { width: 40px; height: 40px; }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: var(--radius); font-weight: 550;
  transition: opacity .18s, transform .18s; z-index: 50; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--rose); color: #fff; }

/* ---------- Responsive */
@media (max-width: 1180px) {
  .inbox.with-details { grid-template-columns: 320px 1fr; }
  .inbox.with-details .details { display: none; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .rail { flex-direction: row; justify-content: space-around; padding: 4px 8px; order: 2; overflow-x: auto; }
  .rail .logo, .rail .bottom { display: none; }
  .rail a { width: 56px; flex: none; }
  .main { order: 1; }
  .inbox, .inbox.with-details { grid-template-columns: 1fr; }
  .inbox.open .list-pane { display: none; }
  .inbox:not(.open) .thread-pane { display: none; }
  .back { display: inline-flex; }
  .page { padding: 20px 16px 40px; }
  .split { grid-template-columns: 1fr; }
  .msg { max-width: 90%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- Linked numbers & groups */
.tag.grp { background: #E6F0EE; color: #1F6B5C; }
@media (prefers-color-scheme: dark) { .tag.grp { background: #183630; color: #7FD4C1; } }
.gsender { font-size: .78rem; font-weight: 650; color: var(--indigo); margin-bottom: 2px; }
.note-box { background: var(--marigold-soft); color: var(--marigold-ink); border-radius: var(--radius); padding: 10px 12px; font-size: .88rem; }
.qr-body { grid-template-columns: auto 1fr; align-items: start; gap: 20px; }
.qr-box { width: 260px; min-height: 260px; display: grid; place-items: center; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.qr-box img.qr { width: 240px; height: 240px; image-rendering: pixelated; }
.qr-status { color: #4A5568; font-size: .88rem; }
.qr-steps { margin: 0; padding-left: 1.2em; display: grid; gap: 8px; color: var(--ink-2); }
@media (max-width: 640px) { .qr-body { grid-template-columns: 1fr; justify-items: center; } }

/* ---------- Number tabs above the inbox */
.inbox-wrap { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.numtabs-host { background: var(--panel); border-bottom: 1px solid var(--line); }
.numtabs { display: flex; gap: 4px; padding: 8px 12px 0; overflow-x: auto; scrollbar-width: thin; }
.ntab {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px 9px; white-space: nowrap;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0; color: var(--ink-2); text-decoration: none;
  font-weight: 550; font-size: .9rem; border-bottom: 2px solid transparent;
}
.ntab:hover { background: var(--paper); color: var(--ink); }
.ntab.active { color: var(--ink); border-bottom-color: var(--indigo); background: var(--paper); }
.ntab .unread { min-width: 18px; height: 18px; font-size: .7rem; }
.ntab-kind { font-size: .68rem; font-weight: 700; color: var(--ink-3); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.on { background: var(--leaf); box-shadow: 0 0 0 3px var(--leaf-soft); }
.dot.wait { background: var(--marigold); }
.dot.off { background: var(--rose); }
.tab-alert {
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: var(--marigold-soft); color: var(--marigold-ink); padding: 8px 16px; font-size: .9rem;
}
.inbox-wrap > .inbox { flex: 1; min-height: 0; height: auto; }
.list-more { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px 16px; border-top:1px solid var(--line, #DCE1E8); }

/* ===================== WhatsApp-style chat window ===================== */
:root {
  --wa-bg: #EFEAE2; --wa-dots: rgba(0,0,0,.035);
  --wa-in: #FFFFFF; --wa-out: #D9FDD3; --wa-out-ai: #E7F0FF; --wa-out-campaign: #F3F3F3;
  --wa-bar: #F0F2F5; --wa-green: #00A884; --wa-meta: #667781; --wa-blue: #53BDEB; --wa-ink: #111B21;
  --wa-shadow: 0 1px .5px rgba(11,20,26,.13); --wa-sel: #F0F2F5;
}
@media (prefers-color-scheme: dark) {
  :root {
    --wa-bg: #0B141A; --wa-dots: rgba(255,255,255,.025);
    --wa-in: #202C33; --wa-out: #005C4B; --wa-out-ai: #233056; --wa-out-campaign: #2A3238;
    --wa-bar: #202C33; --wa-green: #00A884; --wa-meta: #8696A0; --wa-blue: #53BDEB; --wa-ink: #E9EDEF;
    --wa-shadow: 0 1px .5px rgba(0,0,0,.4); --wa-sel: #2A3942;
  }
}

/* Avatars */
.avatar {
  flex: none; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 650; font-size: .9rem;
  background: var(--av, #6A7B8C); letter-spacing: .02em; user-select: none;
}
.avatar.grp { background: #8696A0; }
.avatar svg { width: 55%; height: 55%; }

/* Chat list rows */
.conv { grid-template-columns: auto 1fr auto; column-gap: 12px; align-items: center; border-bottom: 0; padding: 10px 14px; position: relative; }
.conv > .avatar { grid-row: 1 / span 3; }
.conv::after { content: ''; position: absolute; left: 72px; right: 0; bottom: 0; border-bottom: 1px solid var(--line-2); }
.conv .who { grid-column: 2; } .conv .when { grid-column: 3; }
.conv .preview { grid-column: 2; } .conv .meta { grid-column: 3; }
.conv .num { grid-column: 2 / -1; }
.conv.active { background: var(--wa-sel); }
.conv:hover { background: var(--wa-sel); }
.unread { background: var(--wa-green); color: #fff; }

/* Header */
.thread-head { background: var(--wa-bar); border-bottom: 0; padding: 8px 16px; min-height: 60px; gap: 12px; }
.thread-head .title h2 { font-size: 1rem; font-weight: 600; color: var(--wa-ink); }
.icon-btn { border: 0; background: transparent; color: var(--wa-meta); width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: rgba(0,0,0,.06); }
.icon-btn svg { width: 22px; height: 22px; }

/* Conversation background */
.thread {
  background-color: var(--wa-bg);
  background-image: radial-gradient(var(--wa-dots) 1px, transparent 1.2px), radial-gradient(var(--wa-dots) 1px, transparent 1.2px);
  background-size: 22px 22px; background-position: 0 0, 11px 11px;
  padding: 14px 6% 18px; gap: 2px;
}
.day { margin: 12px 0 8px; }
.day span { background: var(--wa-in); color: var(--wa-meta); font-size: .78rem; padding: 5px 12px; border-radius: 8px; box-shadow: var(--wa-shadow); text-transform: uppercase; letter-spacing: .02em; }
.note { background: #FFEECD; color: #54656F; box-shadow: var(--wa-shadow); border-radius: 8px; margin: 6px 0; }
@media (prefers-color-scheme: dark) { .note { background: #182229; color: #FFD279; } }

/* Bubbles */
.msg { max-width: min(620px, 72%); gap: 0; margin-top: 1px; }
.msg.first { margin-top: 8px; }
.bubble {
  position: relative; padding: 6px 8px 8px 9px; border: 0; border-radius: 8px; box-shadow: var(--wa-shadow);
  color: var(--wa-ink); font-size: .93rem; line-height: 1.38; white-space: normal; min-width: 72px;
}
.msg.in .bubble { background: var(--wa-in); border-radius: 8px; }
.msg.out .bubble { background: var(--wa-out); border-radius: 8px; }
.msg.ai .bubble { background: var(--wa-out-ai); }
.msg.agent .bubble, .msg.phone .bubble { background: var(--wa-out); }
.msg.campaign .bubble { background: var(--wa-out-campaign); border: 0; }
.msg.in.first .bubble { border-top-left-radius: 0; }
.msg.out.first .bubble { border-top-right-radius: 0; }
.msg.in.first .bubble::before, .msg.out.first .bubble::before {
  content: ''; position: absolute; top: 0; width: 8px; height: 13px; background: inherit;
}
.msg.in.first .bubble::before { left: -8px; clip-path: polygon(0 0, 100% 0, 100% 100%); }
.msg.out.first .bubble::before { right: -8px; clip-path: polygon(0 0, 100% 0, 0 100%); }
.bubble .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .text a.link { color: #027EB5; text-decoration: none; overflow-wrap: anywhere; }
.bubble .text a.link:hover { text-decoration: underline; }
@media (prefers-color-scheme: dark) { .bubble .text a.link { color: #53BDEB; } }
.bubble .meta {
  float: right; display: inline-flex; align-items: center; gap: 4px; font-size: .69rem; color: var(--wa-meta);
  margin: 6px 0 -4px 10px; position: relative; top: 3px; white-space: nowrap;
}
.bubble .meta .by { font-weight: 600; opacity: .9; }
.msg.ai .bubble .meta .by { color: #4C62C7; }
.tick { display: inline-flex; color: var(--wa-meta); }
.tick svg { width: 16px; height: 16px; stroke-width: 2; }
.tick.read { color: var(--wa-blue); }
.tick.failed { color: #fff; background: #E0434C; border-radius: 50%; width: 14px; height: 14px; font-size: .62rem; font-weight: 800; justify-content: center; }
.msg .err { font-size: .74rem; color: var(--rose); padding: 2px 4px; text-align: right; }
.msg.failed .bubble { outline: 1px solid var(--rose); }
.gsender { font-size: .8rem; font-weight: 600; margin-bottom: 2px; display: flex; gap: 6px; align-items: baseline; }
.gsender .gphone { color: var(--wa-meta); font-weight: 400; font-size: .74rem; }
.legend { display: none; }

/* Media in bubbles */
.m-visual { position: relative; margin: -2px -4px 4px; border-radius: 6px; overflow: hidden; background: rgba(0,0,0,.04); }
.m-visual img { display: block; max-width: 100%; width: 330px; max-height: 360px; object-fit: cover; cursor: zoom-in; }
.m-visual.sticker { background: transparent; }
.m-visual.sticker img { width: 150px; height: 150px; object-fit: contain; cursor: zoom-in; }
.msg.sticker .bubble { background: transparent !important; box-shadow: none; }
.msg.sticker .bubble::before { display: none; }
.m-open { border: 0; padding: 0; background: none; display: block; width: 100%; cursor: zoom-in; }
.m-visual video { display: block; width: 330px; max-width: 100%; max-height: 360px; background: #000; }
.m-bar { display: flex; align-items: center; gap: 8px; padding: 4px 6px; font-size: .74rem; color: var(--wa-meta); }
.m-mini { border: 0; background: transparent; color: #027EB5; font-size: .76rem; cursor: pointer; padding: 2px 0; }
.m-dl {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: var(--wa-meta);
  background: rgba(0,0,0,.05); text-decoration: none; flex: none; margin-left: auto;
}
.m-dl:hover { background: rgba(0,0,0,.1); }
.m-dl svg { width: 17px; height: 17px; }
.m-visual > .m-dl { position: absolute; right: 8px; top: 8px; background: rgba(11,20,26,.55); color: #fff; opacity: 0; transition: opacity .15s; }
.m-visual:hover > .m-dl, .m-visual:focus-within > .m-dl { opacity: 1; }
.m-audio { display: flex; align-items: center; gap: 8px; min-width: 270px; margin-bottom: 2px; }
.m-audio audio { height: 36px; flex: 1; min-width: 180px; }
.m-mic { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: #DFE5E7; color: #54656F; flex: none; }
.m-mic.voice { background: var(--wa-green); color: #fff; }
.m-mic svg { width: 20px; height: 20px; }
.m-doc {
  display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.045); border-radius: 6px; padding: 10px; margin: -2px -4px 4px; min-width: 260px;
}
.m-ext { flex: none; width: 36px; height: 44px; border-radius: 4px; background: var(--av); color: #fff; font-size: .62rem; font-weight: 800; display: grid; place-items: end center; padding-bottom: 6px; position: relative; }
.m-ext::after { content: ''; position: absolute; right: 0; top: 0; border-width: 0 10px 10px 0; border-style: solid; border-color: transparent var(--wa-in) rgba(255,255,255,.35) transparent; }
.m-docinfo { min-width: 0; flex: 1; }
.m-name { font-size: .88rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.m-sub { font-size: .74rem; color: var(--wa-meta); }
.m-icon { color: var(--wa-meta); display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; }
.m-icon:hover { background: rgba(0,0,0,.08); }
.m-icon svg { width: 17px; height: 17px; }
.m-gone { font-size: .8rem; color: var(--wa-meta); display: flex; align-items: center; gap: 6px; padding: 6px 2px; }
.m-gone svg { width: 16px; height: 16px; }

/* Composer */
.composer { background: var(--wa-bar); border-top: 0; padding: 8px 14px; }
.composer form { align-items: flex-end; gap: 10px; }
.composer textarea {
  flex: 1; border: 0; border-radius: 8px; background: var(--panel); padding: 10px 14px; min-height: 42px; max-height: 140px;
  resize: none; line-height: 1.4; box-shadow: none; outline: none;
}
.composer textarea:focus-visible { outline: 2px solid var(--wa-green); outline-offset: 0; }
.send-btn { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--wa-green); color: #fff; display: grid; place-items: center; cursor: pointer; }
.send-btn:disabled { opacity: .6; }
.send-btn svg { width: 20px; height: 20px; }

/* Details panel (contact info) */
.d-hero { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 6px 0 4px; }
.d-hero strong { font-size: 1.05rem; }
.d-shared {
  display: flex; align-items: center; gap: 10px; border: 0; background: var(--wa-sel); border-radius: 8px; padding: 10px 12px; cursor: pointer; color: var(--ink); text-align: left;
}
.d-shared span { flex: 1; font-weight: 550; }
.d-shared svg { width: 18px; height: 18px; color: var(--wa-meta); }

/* Media, links and docs dialog */
.shared-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.shared-tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--ink-2); font-weight: 550; border-bottom: 3px solid transparent; }
.shared-tabs button[aria-selected=true] { color: var(--wa-green); border-bottom-color: var(--wa-green); }
.shared { max-height: 60vh; overflow-y: auto; min-width: min(560px, 80vw); }
.shared-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 4px; padding-top: 8px; }
.sg-item { aspect-ratio: 1; border: 0; padding: 0; background: #DFE5E7; cursor: zoom-in; overflow: hidden; border-radius: 4px; display: grid; place-items: center; }
.sg-item img { width: 100%; height: 100%; object-fit: cover; }
.sg-video { color: #fff; background: rgba(11,20,26,.6); width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; }
.sg-video svg { width: 22px; height: 22px; fill: #fff; }
.shared-list { display: grid; gap: 8px; padding-top: 10px; }
.shared-list .m-doc { margin: 0; }
.sl-link { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; text-decoration: none; color: inherit; }
.sl-link:hover { background: var(--wa-sel); }
.sl-icon { width: 40px; height: 40px; border-radius: 6px; background: var(--av); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.sl-text { display: grid; min-width: 0; flex: 1; }
.sl-text .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Full-screen media viewer */
.viewer { position: fixed; inset: 0; z-index: 1000; background: rgba(11,20,26,.94); display: grid; grid-template-rows: auto 1fr; color: #E9EDEF; }
.v-top { display: flex; align-items: center; gap: 8px; padding: 10px 16px; }
.v-title { font-size: .9rem; min-width: 0; }
.v-title .muted { color: #8696A0; }
.v-cap { font-size: .85rem; color: #D1D7DB; margin-top: 2px; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: #E9EDEF; display: grid; place-items: center; cursor: pointer; text-decoration: none; }
.v-btn:hover { background: rgba(255,255,255,.1); }
.v-btn svg { width: 22px; height: 22px; }
.v-stage { display: grid; place-items: center; min-height: 0; padding: 0 70px 24px; }
.v-stage img, .v-stage video { max-width: 100%; max-height: calc(100vh - 110px); object-fit: contain; box-shadow: 0 6px 30px rgba(0,0,0,.5); }
.v-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; cursor: pointer; display: grid; place-items: center; }
.v-nav:hover { background: rgba(255,255,255,.22); }
.v-nav.prev { left: 14px; } .v-nav.next { right: 14px; }
.v-nav svg { width: 24px; height: 24px; }

@media (max-width: 760px) {
  .thread { padding: 10px 3% 14px; }
  .msg { max-width: 88%; }
  .m-visual img, .m-visual video { width: 260px; }
  .m-doc, .m-audio { min-width: 0; }
  .v-stage { padding: 0 8px 16px; }
  .v-nav { display: none; }
}
dialog.viewer { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; }
dialog.viewer::backdrop { background: transparent; }
dialog.viewer[open] { display: grid; }

/* ===================== WhatsApp-style theme for the whole app ===================== */
:root {
  --ink: #111B21; --ink-2: #3B4A54; --ink-3: #667781;
  --paper: #F0F2F5; --panel: #FFFFFF; --line: #E2E7EA; --line-2: #F0F2F5;
  --indigo: #008069; --indigo-ink: #FFFFFF; --indigo-soft: #D9FDD3;
  --leaf: #00A884; --leaf-soft: #D9FDD3;
  --font: 'Segoe UI', 'Helvetica Neue', Helvetica, 'Lucida Grande', Arial, 'Noto Sans Devanagari', 'Nirmala UI', sans-serif;
  --radius-sm: 8px; --radius: 10px; --radius-lg: 12px;
  --wa-chip: #F0F2F5; --wa-chip-on: #D9FDD3; --wa-chip-on-ink: #008069; --wa-icon: #54656F; --wa-hover: #F5F6F6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #E9EDEF; --ink-2: #AEBAC1; --ink-3: #8696A0;
    --paper: #0C1317; --panel: #111B21; --line: #222D34; --line-2: #1D282F;
    --indigo: #00A884; --indigo-ink: #111B21; --indigo-soft: #103529;
    --leaf: #00A884; --leaf-soft: #103529;
    --bubble-customer: #202C33;
    --wa-chip: #202C33; --wa-chip-on: #0A332C; --wa-chip-on-ink: #00A884; --wa-icon: #AEBAC1; --wa-hover: #202C33;
  }
}
body { font-size: 14.5px; }
a { color: var(--indigo); }
:focus-visible { outline-color: var(--leaf); }

/* Left navigation rail (like WhatsApp Web's side bar) */
.rail { background: var(--wa-bar); border-right: 1px solid var(--line); padding: 12px 0; gap: 2px; }
@media (prefers-color-scheme: dark) { .rail { background: #202C33; border-right-color: #2A3942; } }
.rail .logo { width: 34px; height: 34px; margin-bottom: 12px; }
.rail a { color: var(--wa-icon); font-size: .66rem; width: 62px; border-radius: 12px; padding: 7px 0; }
.rail a svg { width: 23px; height: 23px; }
.rail a:hover { color: var(--ink); background: rgba(0,0,0,.05); }
.rail a.active { color: var(--ink); background: rgba(0,0,0,.08); }
@media (prefers-color-scheme: dark) { .rail a:hover { background: rgba(255,255,255,.06); } .rail a.active { background: rgba(255,255,255,.1); } }
.rail .badge { background: var(--leaf); color: #fff; right: 8px; }

/* Buttons and inputs */
.btn { border-radius: 20px; padding: 7px 16px; border-color: var(--line); font-weight: 600; }
.btn.sm { padding: 4px 12px; }
.btn:hover { border-color: var(--ink-3); background: var(--wa-hover); }
.btn.primary { background: var(--leaf); border-color: var(--leaf); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #111B21; } }
.btn.primary:hover { background: #06CF9C; border-color: #06CF9C; filter: none; }
.btn.danger { color: #EA0038; }
.btn.ghost:hover { background: rgba(0,0,0,.05); }
input[type=text], input[type=email], input[type=password], input[type=datetime-local], input[type=search], select, textarea {
  border-radius: 8px; border-color: var(--line); background: var(--panel); padding: 9px 12px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--leaf); outline-offset: -1px; border-color: transparent; }
.switch input:checked + .track { background: var(--leaf); }

/* Chat list column */
.list-pane { background: var(--panel); border-right: 1px solid var(--line); }
.list-head { padding: 10px 12px 8px; gap: 10px; border-bottom: 0; }
.list-title { display: flex; align-items: baseline; gap: 8px; padding: 4px 4px 0; min-width: 0; }
.list-title h1 { font-size: 1.35rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--wa-icon); pointer-events: none; }
.search-wrap input[type=search] { background: var(--wa-chip); border: 0; border-radius: 8px; padding: 8px 12px 8px 40px; }
.chips { gap: 6px; }
.chip { border: 0; background: var(--wa-chip); color: var(--ink-3); border-radius: 16px; padding: 5px 12px; font-size: .86rem; font-weight: 500; }
.chip:hover { background: var(--line); color: var(--ink-2); }
.chip[aria-pressed=true] { background: var(--wa-chip-on); color: var(--wa-chip-on-ink); }
.conv { padding: 9px 12px; }
.conv .who { font-size: 1rem; font-weight: 500; color: var(--ink); }
.conv .preview { color: var(--ink-3); font-size: .87rem; }
.conv .when { color: var(--ink-3); font-size: .75rem; }
.conv:has(.unread) .when { color: var(--leaf); font-weight: 600; }
.conv.active { background: var(--wa-hover); }
@media (prefers-color-scheme: dark) { .conv.active { background: #2A3942; } .conv:hover { background: #202C33; } }
.conv.needs { border-left-color: transparent; box-shadow: inset 3px 0 0 #FFB84D; }
.unread { background: var(--leaf); color: #fff; border-radius: 10px; }
@media (prefers-color-scheme: dark) { .unread { color: #111B21; } }
.list-more { border-top-color: var(--line-2); }

/* Number tabs: a row of pill tabs, one per WhatsApp number */
.numtabs-host { background: var(--panel); border-bottom: 1px solid var(--line); }
.numtabs { gap: 6px; padding: 8px 12px; }
.ntab { border-radius: 18px; border: 0; padding: 6px 12px; background: var(--wa-chip); color: var(--ink-2); font-size: .86rem; font-weight: 500; }
.ntab:hover { background: var(--line); color: var(--ink); }
.ntab.active { background: var(--wa-chip-on); color: var(--wa-chip-on-ink); border-bottom-color: transparent; }
.ntab .unread { min-width: 18px; height: 18px; }
.ntab-kind { border-color: currentColor; opacity: .7; }
.dot.on { background: var(--leaf); box-shadow: 0 0 0 3px var(--leaf-soft); }
.tab-alert { background: #FFF3C4; color: #54656F; }
@media (prefers-color-scheme: dark) { .tab-alert { background: #2A2F1D; color: #E9EDEF; } }

/* Empty chat area (no chat open) */
.thread-pane > .empty { background: var(--wa-bar); border-bottom: 6px solid var(--leaf); }
.thread-pane > .empty h2 { font-size: 1.6rem; font-weight: 300; }

/* Details panel */
.details { background: var(--panel); border-left: 1px solid var(--line); }
.details h3 { color: var(--leaf); font-weight: 500; font-size: .86rem; }
.handoff { background: #FFF3C4; color: #54656F; border-radius: 8px; box-shadow: var(--wa-shadow); }
@media (prefers-color-scheme: dark) { .handoff { background: #2A2F1D; color: #E9EDEF; } }

/* Tags */
.tag { border-radius: 10px; padding: 1px 8px; font-weight: 500; }
.tag.ai { background: #E7F0FF; color: #3B5BC9; }
@media (prefers-color-scheme: dark) { .tag.ai { background: #233056; color: #9DB2FF; } }
.tag.ok { background: var(--leaf-soft); color: var(--indigo); }

/* Pages (Tasks, Numbers, Roles, Team, Broadcast, Settings) */
.main { background: var(--paper); }
.page { padding: 24px 28px 60px; }
.page-head h1 { font-size: 1.5rem; font-weight: 600; }
.panel { border: 0; border-radius: 12px; box-shadow: 0 1px 2px rgba(11,20,26,.08); }
.table { border: 0; border-radius: 12px; box-shadow: 0 1px 2px rgba(11,20,26,.08); }
.table th { background: var(--panel); color: var(--ink-3); font-weight: 600; text-transform: uppercase; font-size: .72rem; letter-spacing: .04em; border-bottom: 1px solid var(--line); }
.table td { border-bottom-color: var(--line-2); }
.table tbody tr:hover { background: var(--wa-hover); }
@media (prefers-color-scheme: dark) { .panel, .table { box-shadow: none; border: 1px solid var(--line); } .table tbody tr:hover { background: #182229; } }
.picklist button[aria-current=true] { background: var(--wa-hover); box-shadow: inset 3px 0 0 var(--leaf); }
.task input[type=checkbox] { accent-color: var(--leaf); }
.code { background: var(--wa-chip); border: 0; border-radius: 8px; }

/* Dialogs and toast */
dialog { border: 0; border-radius: 12px; box-shadow: 0 17px 50px rgba(11,20,26,.19), 0 12px 15px rgba(11,20,26,.24); }
dialog::backdrop { background: rgba(11,20,26,.55); }
dialog .d-foot { border-top: 0; }
#toast { background: #111B21; color: #E9EDEF; border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
@media (prefers-color-scheme: dark) { #toast { background: #E9EDEF; color: #111B21; } }

/* Login: green band on top, like WhatsApp Web's link screen */
.login { position: relative; background: var(--paper); }
.login::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 220px; background: var(--leaf); }
@media (prefers-color-scheme: dark) { .login::before { background: #00A884; opacity: .9; } }
.login .card { position: relative; box-shadow: 0 17px 50px rgba(11,20,26,.19); padding: 32px; }

/* Mobile: bottom tab bar like the WhatsApp app */
@media (max-width: 820px) {
  .rail { border-right: 0; border-top: 1px solid var(--line); padding: 4px 6px; background: var(--panel); }
  .rail a { width: 58px; }
  .rail a.active { background: transparent; color: var(--leaf); }
  .rail a.active svg { background: var(--wa-chip-on); border-radius: 14px; padding: 2px 10px; width: 46px; }
  .page { padding: 18px 14px 40px; }
  .list-title h1 { font-size: 1.25rem; }
}

/* Scrollbars: thin, like WhatsApp Web */
* { scrollbar-width: thin; scrollbar-color: rgba(0,0,0,.2) transparent; }
@media (prefers-color-scheme: dark) { * { scrollbar-color: rgba(255,255,255,.16) transparent; } }
.list-title { flex-direction: column; align-items: flex-start; gap: 0; }
.list-title h1 { max-width: 100%; }
.chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; }
.login { place-items: start center; padding-top: 120px; }

/* Group info */
.title-btn { border: 0; background: none; padding: 0; text-align: left; cursor: pointer; color: inherit; min-width: 0; }
.title-btn:hover h2 { text-decoration: underline; text-decoration-color: var(--ink-3); }
.group-info { display: grid; gap: 14px; }
.gi-hero { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 6px 0 4px; }
.gi-hero h2 { font-size: 1.3rem; }
.gi-pic { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; }
.gi-sec { display: grid; gap: 8px; }
.gi-sec h3 { color: var(--leaf); font-size: .86rem; font-weight: 500; }
.gi-desc { white-space: pre-wrap; overflow-wrap: anywhere; }
.gi-desc.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; color: var(--ink-2); }
.gi-facts > div { display: flex; justify-content: space-between; gap: 12px; font-size: .9rem; border-bottom: 1px solid var(--line-2); padding: 6px 0; }
.gi-panel { display: grid; gap: 8px; }
.gi-panel h3 { color: var(--leaf); font-weight: 500; font-size: .86rem; }
.member-list { display: grid; max-height: 46vh; overflow-y: auto; }
.member-list.compact { max-height: none; }
.member { display: flex; align-items: center; gap: 12px; padding: 8px 4px; border-bottom: 1px solid var(--line-2); }
.member:last-child { border-bottom: 0; }
.member-list.compact .member { padding: 6px 0; gap: 10px; }
.member-list.compact .avatar { width: 34px !important; height: 34px !important; font-size: .78rem; }
.member-info { min-width: 0; flex: 1; }
.member-top { display: flex; align-items: center; gap: 8px; }
.member-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-sub { font-size: .8rem; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-pill { flex: none; font-size: .7rem; font-weight: 600; color: var(--indigo); background: var(--leaf-soft); border-radius: 8px; padding: 1px 7px; }

/* ===================== Marketing ===================== */
.mk-page { max-width: 1200px; }
.mk-head { display: grid; gap: 14px; margin-bottom: 18px; }
.mk-head p { margin-top: 2px; }
.mk-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.mk-tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 18px; background: var(--wa-chip); color: var(--ink-2); text-decoration: none; font-weight: 500; white-space: nowrap; }
.mk-tabs a:hover { background: var(--line); }
.mk-tabs a.active { background: var(--wa-chip-on); color: var(--wa-chip-on-ink); }
.mk-tabs .unread { min-width: 18px; height: 18px; font-size: .7rem; }
.mk-sub { font-size: 1rem; font-weight: 600; color: var(--ink-2); margin-top: 6px; }
.pbadge { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 500; color: var(--ink-2); white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.pbadge i, .plogo { flex: none; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: var(--pc); color: #fff; font-style: normal; font-weight: 700; font-size: .72rem; }
.plogo { width: 38px; height: 38px; border-radius: 10px; font-size: 1.05rem; }
.mk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.mk-plat { background: var(--panel); border-radius: 12px; box-shadow: 0 1px 2px rgba(11,20,26,.08); padding: 14px; display: grid; gap: 10px; align-content: start; }
@media (prefers-color-scheme: dark) { .mk-plat { box-shadow: none; border: 1px solid var(--line); } }
.mk-plat-head { display: flex; align-items: center; gap: 10px; }
.mk-acc { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--wa-chip); }
.mk-acc-main { flex: 1 1 180px; min-width: 0; }
.mk-acc { flex-wrap: wrap; }
.mk-acc-main > .tag { margin-left: 6px; }
.mk-steps { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.mk-none { padding-left: 2px; }
.mk-box { background: var(--wa-chip); border-radius: 10px; padding: 12px; }
.mk-list { padding: 0; overflow: hidden; }
.mk-post { display: grid; grid-template-columns: 70px 1fr auto; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); align-items: start; }
.mk-post:last-child { border-bottom: 0; }
.mk-when { display: grid; text-align: center; background: var(--wa-chip); border-radius: 10px; padding: 6px 4px; }
.mk-post-main { min-width: 0; display: grid; gap: 6px; }
.mk-clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.mk-clamp1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-targets { display: flex; flex-wrap: wrap; gap: 6px; }
.mk-target { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px 3px 4px; border-radius: 14px; background: var(--wa-chip); text-decoration: none; color: inherit; }
.mk-target.ok { background: var(--leaf-soft); } .mk-target.bad { background: var(--rose-soft); } .mk-target.needs { background: #FFF3C4; }
@media (prefers-color-scheme: dark) { .mk-target.needs { background: #2A2F1D; } }
dialog:has(.mk-compose) { width: min(860px, 96vw); }
.mk-picks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.mk-pick { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--line); background: var(--panel); border-radius: 18px; padding: 4px 12px 4px 4px; cursor: pointer; font-weight: 500; color: var(--ink-2); }
.mk-pick i { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--pc); color: #fff; font-style: normal; font-size: .75rem; font-weight: 700; }
.mk-pick.on { border-color: var(--pc); background: color-mix(in srgb, var(--pc) 12%, var(--panel)); color: var(--ink); }
.mk-auto { font-size: .8rem; }
.mk-variant { display: grid; gap: 6px; }
.mk-media { display: flex; flex-wrap: wrap; gap: 8px; }
.mk-thumb { position: relative; width: 84px; height: 84px; border-radius: 8px; overflow: hidden; background: var(--wa-chip); display: grid; place-items: center; font-size: 1.6rem; text-decoration: none; }
.mk-thumb img { width: 100%; height: 100%; object-fit: cover; }
.mk-thumb button { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(11,20,26,.6); color: #fff; cursor: pointer; line-height: 1; }
.mk-queue { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 12px; }
.mk-qcard { display: grid; gap: 10px; align-content: start; }
.mk-qtext { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--wa-chip); border-radius: 8px; padding: 10px 12px; font-size: .92rem; max-height: 260px; overflow-y: auto; }
.mk-sources { display: flex; flex-wrap: wrap; gap: 8px; }
.mk-source { display: inline-flex; align-items: center; gap: 10px; background: var(--panel); border-radius: 10px; padding: 6px 8px 6px 10px; box-shadow: 0 1px 2px rgba(11,20,26,.08); }
.mk-lead { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; border-bottom: 1px solid var(--line-2); background: none; padding: 12px 16px; text-align: left; cursor: pointer; color: inherit; font: inherit; }
.mk-lead:hover { background: var(--wa-hover); }
.mk-lead.is-new { box-shadow: inset 3px 0 0 var(--leaf); }
.mk-lead-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.mk-lead-side { display: grid; justify-items: end; gap: 6px; flex: none; }
.mk-matrix td, .mk-matrix th { white-space: nowrap; }
.mk-matrix td:first-child { white-space: normal; min-width: 220px; }
.mk-cell { border: 0; cursor: pointer; }
.linklike { border: 0; background: none; padding: 0; color: var(--ink); cursor: pointer; text-align: left; font: inherit; }
.linklike:hover { text-decoration: underline; }
@media (max-width: 760px) {
  .mk-post { grid-template-columns: 56px 1fr; }
  .mk-post > .row { grid-column: 1 / -1; }
  .mk-grid, .mk-queue { grid-template-columns: 1fr; }
  .mk-lead-side { display: none; }
}
a.btn { text-decoration: none; }
.mk-page select { width: auto; min-width: 160px; }
.mk-page .field select, dialog select { width: 100%; }
dialog:has(.robot-frame) { width: min(1440px, 98vw); }
.robot-frame { width: 100%; height: min(72vh, 860px); border: 0; border-radius: 8px; background: #111; }
.robot-shot img { width: 100%; border-radius: 8px; border: 1px solid var(--line); }
dialog:has(.robot-shot) { width: min(1100px, 96vw); }
