:root {
  --brand: #5b5ce2;
  --brand-dark: #4546c7;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f4f5f7;
  --card: #ffffff;
  --sidebar: #ffffff;
  --ok: #059669;
  --warn: #d97706;
  --danger: #dc2626;
  --wa-green: #075e54;
  --wa-teal: #128c7e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.04);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 10% -10%, #c7c8ff 0%, transparent 55%),
    linear-gradient(160deg, #0f172a, #1e1b4b 55%, #312e81);
}
.login-card {
  background: #fff; padding: 2rem; border-radius: 16px; width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-card h1 { color: var(--brand); margin-bottom: .5rem; font-size: 1.5rem; }
.login-card p { color: var(--muted); margin-bottom: 1.5rem; font-size: .9rem; }
.login-card .login-error {
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: .65rem .75rem;
  margin: 0 0 .75rem;
  font-size: .9rem;
  font-weight: 600;
  text-align: left;
}
.login-card #loginBtn:disabled { opacity: .7; cursor: wait; }
input, select, button, textarea {
  width: 100%; padding: .75rem 1rem; margin-bottom: .75rem; border: 1px solid var(--line);
  border-radius: 10px; font-size: 1rem; font-family: inherit;
}
button {
  background: var(--brand); color: #fff; border: none; cursor: pointer; font-weight: 600;
}
button:hover { background: var(--brand-dark); }
button.danger { background: var(--danger); }
button.secondary { background: #374151; }
button.ghost {
  background: #fff; color: var(--ink); border: 1px solid var(--line); font-weight: 600;
}
button.ghost:hover { background: #f9fafb; }

#app { display: none; min-height: 100vh; }
.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--sidebar); border-right: 1px solid var(--line);
  padding: 1.1rem .85rem 1rem; display: flex; flex-direction: column; gap: .35rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: .65rem; padding: .4rem .55rem 1rem;
  font-weight: 800; letter-spacing: -.02em; font-size: 1.05rem;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #a5b4fc, var(--brand));
  box-shadow: 0 0 0 4px rgba(91,92,226,.12);
}
.nav-section {
  color: var(--muted); font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; padding: .85rem .55rem .35rem;
}
.nav-item {
  display: flex; align-items: center; gap: .55rem; padding: .55rem .7rem;
  border-radius: 10px; cursor: pointer; color: #374151; font-weight: 550; font-size: .92rem;
}
.nav-item:hover { background: #f3f4f6; }
.nav-item.active { background: #111827; color: #fff; }
.sidebar-foot {
  margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--line);
}
.user-chip {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .55rem; border-radius: 12px; background: #f9fafb;
}
.user-chip strong { display: block; font-size: .9rem; }
.user-chip span { color: var(--muted); font-size: .75rem; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.35rem; background: rgba(255,255,255,.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 1.2rem; display: flex; align-items: center; gap: .5rem; }
.topbar-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.topbar-actions button { width: auto; margin: 0; padding: .55rem 0.9rem; }
.search-pill {
  min-width: 220px; margin: 0; background: #f9fafb; border-radius: 999px; padding: .55rem 1rem;
}
.content { padding: 1.25rem 1.35rem 2rem; }

/* legacy tab hide — sidebar drives panels */
.tabs { display: none !important; }
.header { display: none !important; }
.panel { display: none; }
.panel.active { display: block; }

.kpi-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 1rem; overflow: hidden;
}
@media (min-width: 1100px) {
  .kpi-row { grid-template-columns: repeat(6, 1fr); }
}
.kpi {
  padding: 1.1rem 1.2rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.kpi:nth-child(3n) { border-right: none; }
@media (min-width: 1100px) {
  .kpi { border-bottom: none; }
  .kpi:nth-child(3n) { border-right: 1px solid var(--line); }
  .kpi:last-child { border-right: none; }
}
.kpi .label { color: var(--muted); font-size: .8rem; font-weight: 600; }
.kpi .value { font-size: 1.55rem; font-weight: 800; letter-spacing: -.03em; margin: .2rem 0; }
.kpi .sub { color: var(--muted); font-size: .78rem; }

.dash-hero {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
  margin-bottom: 1rem; flex-wrap: wrap;
}
.dash-hero h2 { margin: 0 0 .35rem; font-size: 1.25rem; letter-spacing: -.02em; }
.dash-hero p { margin: 0; color: var(--muted); font-size: .9rem; max-width: 42rem; line-height: 1.45; }
.module-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: .55rem;
}
@media (min-width: 720px) {
  .module-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1100px) {
  .module-grid { grid-template-columns: repeat(4, 1fr); }
}
.module-tile {
  text-align: left; margin: 0; padding: .85rem .9rem;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 12px;
  display: flex; flex-direction: column; gap: .2rem;
}
.module-tile:hover { background: #eef2ff; border-color: #c7d2fe; }
.module-tile strong { font-size: .92rem; color: var(--ink); }
.module-tile span { font-size: .75rem; color: var(--muted); font-weight: 550; }
.overview-block { font-size: .9rem; }
.overview-kv {
  display: flex; justify-content: space-between; gap: .75rem;
  padding: .45rem 0; border-bottom: 1px solid #f1f5f9; font-size: .86rem;
}
.overview-kv span { color: var(--muted); }
.overview-actions {
  display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .85rem;
}
.overview-actions button { width: auto; margin: 0; padding: .5rem .8rem; font-size: .8rem; }
.overview-list { display: flex; flex-direction: column; gap: .55rem; }
.overview-row {
  padding: .65rem .7rem; background: #f8fafc; border: 1px solid var(--line);
  border-radius: 10px;
}
.overview-row .muted, .muted { color: var(--muted); font-size: .78rem; margin-top: .2rem; line-height: 1.35; }
.kpi-mini-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: .75rem;
}
.kpi-mini-row .label { color: var(--muted); font-size: .75rem; font-weight: 650; }
.kpi-mini-row .value { font-size: 1.35rem; font-weight: 800; }
.status-ok {
  background: #ecfdf5; color: #047857; font-size: .72rem !important; font-weight: 750 !important;
  padding: .2rem .5rem; border-radius: 999px;
}
.status-warn {
  background: #fff7ed; color: #c2410c; font-size: .72rem !important; font-weight: 750 !important;
  padding: .2rem .5rem; border-radius: 999px;
}

.nav-menu-btn {
  display: none; width: 40px; height: 40px; margin: 0; padding: 0;
  border-radius: 12px; border: 1px solid var(--line); background: #fff;
  font-size: 1.15rem; place-items: center; flex-shrink: 0;
}
.nav-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4);
  z-index: 40;
}
.mobile-bottom-nav {
  display: none;
}

.dash-grid {
  display: grid; grid-template-columns: 1.6fr 1fr; gap: 1rem; margin-bottom: 1rem;
}
.dash-grid-2 {
  display: grid; grid-template-columns: 1.4fr .9fr; gap: 1rem;
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.1rem 1.2rem;
}
.card h3 {
  font-size: .95rem; margin-bottom: .9rem; display: flex; justify-content: space-between;
  align-items: center; gap: .5rem;
}
.card h3 span { color: var(--muted); font-weight: 500; font-size: .78rem; }

.bars {
  display: flex; align-items: flex-end; gap: .55rem; height: 180px; padding-top: .5rem;
}
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .35rem; height: 100%; justify-content: flex-end; }
.bar {
  width: 100%; border-radius: 8px 8px 4px 4px; background: #e5e7eb; min-height: 4px;
  transition: height .3s ease;
}
.bar.hot { background: linear-gradient(180deg, #818cf8, var(--brand)); }
.bar-col label { font-size: .7rem; color: var(--muted); }

.donut-wrap { display: flex; gap: 1rem; align-items: center; }
.donut {
  width: 140px; height: 140px; border-radius: 50%;
  background: conic-gradient(var(--brand) 0 var(--p1), #60a5fa var(--p1) var(--p2), #f59e0b var(--p2) var(--p3), #fbbf24 var(--p3) 100%);
  position: relative; flex: 0 0 auto;
}
.donut::after {
  content: attr(data-center); position: absolute; inset: 18px; background: #fff; border-radius: 50%;
  display: grid; place-items: center; text-align: center; font-size: .78rem; font-weight: 700; color: #111;
  padding: .4rem; line-height: 1.2;
}
.legend { list-style: none; flex: 1; }
.legend li {
  display: flex; justify-content: space-between; gap: .5rem; padding: .35rem 0;
  border-bottom: 1px solid #f3f4f6; font-size: .85rem;
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: .4rem; }

.funnel-list { list-style: none; }
.funnel-list li {
  display: grid; grid-template-columns: 28px 1fr auto; gap: .75rem; align-items: center;
  padding: .7rem 0; border-bottom: 1px solid #f3f4f6;
}
.funnel-list li:last-child { border-bottom: none; }
.funnel-ico {
  width: 28px; height: 28px; border-radius: 8px; background: #eef2ff; color: var(--brand);
  display: grid; place-items: center; font-size: .75rem; font-weight: 800;
}
.funnel-list strong { display: block; font-size: .9rem; }
.funnel-list small { color: var(--muted); }
.funnel-count { font-weight: 800; }

.progress {
  height: 10px; background: #e5e7eb; border-radius: 999px; overflow: hidden; margin: .75rem 0;
}
.progress > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.team-row {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .55rem 0; border-bottom: 1px solid #f3f4f6;
}
.team-row:last-child { border-bottom: none; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: #111827; color: #fff;
  display: grid; place-items: center; font-size: .75rem; font-weight: 700;
}
.pill {
  display: inline-flex; align-items: center; padding: .2rem .55rem; border-radius: 999px;
  background: #eef2ff; color: var(--brand); font-size: .75rem; font-weight: 700;
}

/* Kanban */
.kanban {
  display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: .85rem;
  overflow-x: auto; padding-bottom: .5rem;
}
.kanban-col {
  background: #f9fafb; border: 1px solid var(--line); border-radius: 14px; min-height: 360px;
  display: flex; flex-direction: column;
}
.kanban-col header {
  padding: .75rem .85rem; font-weight: 700; font-size: .85rem;
  border-bottom: 1px solid var(--line); display: flex; justify-content: space-between;
}
.kanban-col.stage-new header { color: #1d4ed8; }
.kanban-col.stage-qualified header { color: #047857; }
.kanban-col.stage-proposal header { color: #6d28d9; }
.kanban-col.stage-won header { color: #065f46; }
.kanban-col.stage-lost header { color: #b91c1c; }
.kanban-body { padding: .65rem; display: flex; flex-direction: column; gap: .55rem; flex: 1; }
.deal-card {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .75rem;
  box-shadow: 0 1px 2px rgba(0,0,0,.04); cursor: grab;
}
.deal-card:active { cursor: grabbing; }
.deal-card h4 { font-size: .9rem; margin-bottom: .35rem; }
.deal-card .meta { color: var(--muted); font-size: .75rem; line-height: 1.45; }
.deal-card .amt { margin-top: .45rem; font-weight: 800; font-size: .9rem; }
.kanban-col.drag-over { outline: 2px dashed var(--brand); outline-offset: -2px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: #fff; padding: 1.25rem; border-radius: 12px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.stat-card h3 { font-size: 1.8rem; color: var(--brand); }
.stat-card p { color: var(--muted); font-size: .85rem; }
.quality-rating { font-weight: 800; letter-spacing: .02em; }
.quality-rating.quality-green { color: #16a34a; }
.quality-rating.quality-yellow { color: #ca8a04; }
.quality-rating.quality-red { color: #dc2626; }
.quality-rating.quality-unknown { color: var(--muted); }
table { width: 100%; background: #fff; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); border-collapse: collapse; }
th, td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid #eee; }
th { background: #f9fafb; font-weight: 600; font-size: .85rem; color: #4b5563; }
.badge { display: inline-block; padding: .2rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge.admin { background: #e3f2fd; color: #1565c0; }
.badge.supervisor { background: #fff3e0; color: #e65100; }
.badge.agent { background: #e8f5e9; color: #2e7d32; }
.badge.accountant { background: #f3e5f5; color: #6a1b9a; }
.badge.active { background: #e8f5e9; color: #2e7d32; }
.badge.inactive { background: #ffebee; color: #c62828; }
.badge.pending { background: #fff3e0; color: #e65100; }
.badge.rejected { background: #ffebee; color: #b71c1c; }
.badge.expiring_soon { background: #fff8e1; color: #f57f17; }
.badge.expired { background: #ffebee; color: #c62828; }
.badge.approved { background: #e8f5e9; color: #2e7d32; }
.badge.webhook { background: #eef2ff; color: #4338ca; }
.form-row { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: .75rem; margin-bottom: 1.5rem; align-items: end; }
.form-row input, .form-row select { margin-bottom: 0; }
.form-row button { width: auto; margin: 0; }
.toast { position: fixed; bottom: 1.5rem; right: 1.5rem; background: #111827; color: #fff; padding: .75rem 1.25rem; border-radius: 10px; display: none; z-index: 9999; }
.toast.show { display: block; }
.actions { display: flex; gap: .5rem; }
.actions button { width: auto; padding: .35rem .75rem; font-size: .85rem; margin: 0; }
.ai-card { background: #fff; padding: 1.5rem; border-radius: 14px; border: 1px solid var(--line); box-shadow: var(--shadow); margin-bottom: 1rem; }
.ai-card h3 { margin-bottom: 1rem; color: var(--ink); }
.checkbox-row { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; }
.checkbox-row label { display: flex; align-items: center; gap: .5rem; font-size: .9rem; cursor: pointer; }
.checkbox-row input { width: auto; margin: 0; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; max-height: none; }
  .kpi-row, .dash-grid, .dash-grid-2 { grid-template-columns: 1fr 1fr; }
  .kanban { grid-template-columns: repeat(5, 240px); }
}
@media (max-width: 700px) {
  .kpi-row, .dash-grid, .dash-grid-2 { grid-template-columns: 1fr; }
}

/* ── Team Inbox (light desk) ── */
#inbox.panel.active { display: block; }
#inbox .content-bleed { margin: 0; }

/*
 * Desktop inbox scrollports:
 * Previous mobile shell lock (100dvh + overflow:hidden) never fixed desktop.
 * .cw-inbox used a guessed calc(100vh - 5.5rem) + overflow:hidden, while grid
 * columns kept min-height:auto — so list/messages/details grew past the clipped
 * shell and overflow:auto never activated (composer pushed off-screen).
 * Fix: fill remaining main height via flex, and give each column min-height:0.
 */
body.inbox-tab {
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}
body.inbox-tab #app {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
}
body.inbox-tab .app-shell {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
}
body.inbox-tab .main {
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body.inbox-tab .topbar { flex-shrink: 0; }
body.inbox-tab .content {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: 1.25rem;
}
body.inbox-tab #inbox.panel.active {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  height: 100%;
}
body.inbox-tab .cw-mobile-app-bar { flex-shrink: 0; }

.cw-inbox {
  display: grid;
  grid-template-columns: minmax(300px, 340px) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "folders folders"
    "list thread";
  height: calc(100vh - 5.5rem);
  height: calc(100dvh - 5.5rem);
  min-height: 0;
  max-height: 100%;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  align-content: stretch;
  --cw-folder-accent: #1f93ff;
  --cw-folder-active-bg: #e8f4ff;
}
.cw-inbox.cw-details-open {
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr) minmax(260px, 300px);
  grid-template-areas:
    "folders folders folders"
    "list thread details";
}
body.inbox-tab .cw-inbox {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  max-height: 100%;
}
.cw-list, .cw-thread, .cw-details {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  height: 100%; overflow: hidden; background: #fff;
}
.cw-folders { grid-area: folders; }
.cw-list { grid-area: list; }
.cw-thread { grid-area: thread; }
.cw-details { grid-area: details; }
.cw-inbox:not(.cw-details-open) .cw-details { grid-area: thread; }

/* Top horizontal folder bar (full width above list | thread | details) */
.cw-folders {
  display: flex; flex-direction: row; align-items: center; gap: .3rem;
  min-width: 0; min-height: 0; height: auto; max-height: none;
  overflow-x: auto; overflow-y: hidden;
  overflow-anchor: none;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  border-right: none;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
  padding: .28rem .5rem;
}
.cw-folders-tools {
  display: flex; gap: .3rem; flex: 0 0 auto; padding: 0;
  border-bottom: none;
}
.cw-folder-tool {
  width: 30px !important; height: 30px; margin: 0 !important; padding: 0 !important;
  display: grid; place-items: center;
  background: #fff; color: #6b7280; border: 1px solid var(--line); border-radius: 8px;
}
.cw-folder-tool:hover { background: #f3f4f6; color: #111827; }
.cw-folders-section { display: contents; }
.cw-folders-label { display: none; }
.cw-folder-list {
  display: flex; flex-direction: row; align-items: center; gap: .06rem;
  flex: 1 1 auto; min-width: 0; overflow-x: auto; overflow-y: hidden;
  overflow-anchor: none;
  -webkit-overflow-scrolling: touch; scrollbar-width: thin;
}
.cw-folder {
  width: auto !important; margin: 0 !important; padding: .3rem .55rem !important;
  display: inline-flex; align-items: center; gap: .35rem;
  flex: 0 0 auto;
  background: transparent; color: #4b5563; border: none; border-radius: 999px;
  border-left: none; box-shadow: none;
  font-size: .8rem; font-weight: 600;
  text-align: center; cursor: pointer; white-space: nowrap;
  overflow-anchor: none; scroll-margin: 0;
}
.cw-folder:hover { background: #f3f4f6; color: #111827; }
.cw-folder.active {
  background: var(--cw-folder-active-bg);
  color: #0f172a;
  border-left: none;
  box-shadow: inset 0 -2px 0 var(--cw-folder-accent);
  border-radius: 8px;
  font-weight: 700;
}
.cw-folder-ico { display: none !important; }
.cw-folder-text { flex: 0 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cw-folder-count {
  font-style: normal; font-size: .68rem; font-weight: 700; color: #9ca3af;
  margin-left: 0; min-width: 1.1em; text-align: center;
}
.cw-folder.active .cw-folder-count { color: var(--cw-folder-accent); }
.cw-folder[data-folder="staff_wa"].active {
  background: #ecfdf5;
  color: #047857;
  box-shadow: inset 0 -2px 0 #047857;
}
.cw-folder[data-folder="staff_wa"].active .cw-folder-count { color: #047857; }
.cw-folders-views {
  display: flex; align-items: center; gap: .35rem;
  flex: 0 0 auto; margin-top: 0; margin-left: auto; padding-top: 0;
  border-top: none;
}
.cw-custom-views {
  display: flex; flex-direction: row; align-items: center; gap: .2rem;
  margin-bottom: 0; flex: 0 0 auto;
}
.cw-custom-view { position: relative; }
.cw-view-del {
  margin-left: .15rem; color: #9ca3af; font-size: .95rem; line-height: 1; padding: 0 .15rem;
}
.cw-view-del:hover { color: var(--danger); }
.cw-views-card { display: none !important; }
.cw-views-card strong { font-size: .82rem; color: #111827; line-height: 1.35; }
.cw-create-view-btn { display: none !important; }
.cw-folder-new {
  float: none; width: auto !important; margin: 0 !important; padding: .35rem .55rem !important;
  border: none; background: transparent; color: var(--cw-folder-accent);
  font-size: .75rem; font-weight: 750; cursor: pointer; white-space: nowrap; border-radius: 8px;
}
.cw-folder-new:hover { background: var(--cw-folder-active-bg); }
.cw-list-title-row { display: flex; align-items: flex-start; gap: .35rem; min-width: 0; }
.cw-folders-toggle { display: none !important; }
.cw-extra-filters {
  padding: .45rem .75rem; border-bottom: 1px solid var(--line); background: #f8fafc;
}
.cw-extra-filters-hint { margin: 0; font-size: .75rem; color: var(--muted); line-height: 1.4; }
.cw-empty-soft { color: #9ca3af; font-size: .92rem; }
.cw-select-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .55rem; text-align: center; padding: 2rem 1.25rem; max-width: 360px;
}
.cw-select-illust { margin-bottom: .35rem; opacity: .95; }
.cw-select-empty h3 { margin: 0; font-size: 1.35rem; color: #111827; letter-spacing: -.02em; }
.cw-select-empty p { margin: 0; color: #6b7280; font-size: .92rem; line-height: 1.45; }
.cw-initiate-btn {
  width: auto !important; margin: .55rem 0 0 !important; padding: .65rem 1.1rem !important;
  background: var(--cw-folder-accent) !important; border: none; border-radius: 8px;
  font-size: .88rem; font-weight: 650;
}
.cw-initiate-btn:hover { filter: brightness(.96); }
.cw-modal[hidden] { display: none !important; }
.cw-modal {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center;
}
.cw-modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .35); }
.cw-modal-card {
  position: relative; z-index: 1; width: min(420px, calc(100vw - 2rem));
  background: #fff; border-radius: 14px; padding: 1.25rem 1.35rem 1.15rem;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .2); border: 1px solid var(--line);
}
.cw-modal-card h3 { margin: 0 0 .4rem; font-size: 1.05rem; }
.cw-modal-card p { margin: 0 0 .9rem; color: var(--muted); font-size: .85rem; line-height: 1.45; }
.cw-modal-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.cw-modal-actions button { width: auto; margin: 0; }

.cw-list { border-right: 1px solid var(--line); }
.cw-details {
  border-left: 1px solid var(--line);
  overflow: hidden;
  background: #fff;
  position: relative;
}
.cw-details-rail {
  display: flex; flex-direction: column; align-items: center; gap: .45rem;
  width: 52px; padding: .55rem .35rem; flex-shrink: 0;
  height: 100%; background: #fafbfc;
}
.cw-details-rail-btn {
  width: 34px !important; height: 34px; margin: 0 !important; padding: 0 !important;
  display: grid; place-items: center;
  background: #fff; color: #6b7280; border: 1px solid var(--line); border-radius: 8px;
  cursor: pointer;
}
.cw-details-rail-btn:hover { background: #f3f4f6; color: #111827; }
.cw-details-panel {
  display: none;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0; min-height: 0;
  height: 100%;
  overflow-y: auto; overflow-x: hidden;
}
.cw-details-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .65rem .75rem; border-bottom: 1px solid var(--line);
  background: #fff; flex-shrink: 0; position: sticky; top: 0; z-index: 1;
}
.cw-details-panel-head strong { font-size: .88rem; color: #111827; }
.cw-details-collapse {
  width: 30px !important; height: 30px; margin: 0 !important; padding: 0 !important;
  display: grid; place-items: center;
  background: #fff; color: #6b7280; border: 1px solid var(--line); border-radius: 8px;
  cursor: pointer;
}
.cw-details-collapse:hover { background: #f3f4f6; color: #111827; }
.cw-inbox.cw-details-open .cw-details {
  display: flex; flex-direction: row;
  overflow: hidden;
}
.cw-inbox.cw-details-open .cw-details-rail { display: none; }
.cw-inbox.cw-details-open .cw-details-panel { display: flex; }
.cw-details-toggle {
  display: inline-flex !important; align-items: center; gap: 0;
  font-size: .78rem; font-weight: 650; color: #4b5563;
  padding: .35rem .5rem !important;
}
.cw-details-toggle span { display: none; }
.cw-details-toggle[aria-pressed="true"] {
  background: #e8f4ff; color: #0f172a; border-color: #bfdbfe;
}

.cw-list-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem;
  padding: .9rem 1rem .55rem; border-bottom: 1px solid var(--line);
}
.cw-list-head h2 { margin: 0; font-size: 1rem; letter-spacing: -.02em; }
.cw-list-head span { color: var(--muted); font-size: .75rem; }
.cw-list-actions { display: flex; gap: .35rem; align-items: center; }
.cw-list-actions select, .cw-list-actions button {
  width: auto; margin: 0; padding: .35rem .55rem; font-size: .78rem;
}
#inboxScopeTabs[hidden], #inboxScopeTabs { display: none !important; }
.cw-scope-tabs {
  display: flex; flex-wrap: wrap; gap: .25rem;
  padding: .55rem .65rem; border-bottom: 1px solid var(--line);
  position: relative; z-index: 2;
}
.cw-scope {
  width: auto !important; margin: 0 !important; padding: .45rem .55rem !important;
  background: #f3f4f6; color: #4b5563; border: none; border-radius: 999px;
  font-size: .78rem; font-weight: 650; cursor: pointer;
  position: relative; z-index: 2; pointer-events: auto;
}
.cw-scope em {
  font-style: normal; margin-left: .2rem; color: var(--muted); font-weight: 700;
}
.cw-scope.active { background: #111827; color: #fff; }
.cw-scope.active em { color: #d1d5db; }
.cw-calls-jump {
  padding: .35rem .65rem .55rem;
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 3;
}
.cw-calls-btn {
  width: 100% !important; margin: 0 !important;
  padding: .55rem .75rem !important;
  background: #ecfdf5 !important; color: #065f46 !important;
  border: 1px solid #a7f3d0 !important; border-radius: 10px !important;
  font-size: .82rem !important; font-weight: 700 !important;
  cursor: pointer; pointer-events: auto; position: relative; z-index: 3;
}
.cw-calls-btn:hover { background: #d1fae5 !important; }
.cw-search {
  margin: .65rem .75rem !important; width: auto !important;
  border-radius: 10px; background: #f3f4f6; border-color: transparent; font-size: .85rem;
  flex-shrink: 0;
}
.cw-list-head, .cw-scope-tabs, .cw-bulk-bar { flex-shrink: 0; }
.cw-convo-list {
  flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto;
  -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain;
  touch-action: pan-y; scroll-behavior: auto;
}
.cw-convo {
  display: grid; grid-template-columns: 36px 1fr; gap: .55rem; padding: .55rem .85rem;
  cursor: pointer; border-bottom: 1px solid #f3f4f6; border-left: 3px solid transparent;
}
.cw-convo:hover { background: #f8fafc; }
.cw-convo.active { background: #f3f4f6; border-left-color: #111827; }
.cw-convo.unread { background: #f4faf6; }
.cw-convo.unread.active { background: #eef6f0; }
.cw-convo.unread .cw-name { font-weight: 800; }
.cw-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: #e5e7eb; color: #374151;
  display: grid; place-items: center; font-weight: 800; font-size: .8rem; flex: 0 0 auto;
}
.cw-avatar.lg { width: 44px; height: 44px; font-size: .95rem; margin: 0 auto .4rem; }
.cw-convo-main { min-width: 0; }
.cw-convo-top { display: flex; justify-content: space-between; gap: .4rem; align-items: baseline; }
.cw-name-wrap { display: flex; align-items: baseline; gap: .35rem; min-width: 0; }
.cw-name { font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cw-convo-extra {
  flex: 0 0 auto; font-size: .68rem; font-weight: 650; color: #6b7280;
}
.cw-time { color: var(--muted); font-size: .7rem; flex: 0 0 auto; }
.cw-assignee { display: none; }
.cw-assignee-inline {
  color: var(--muted); font-size: .7rem; margin-left: .4rem; font-weight: 500;
}
.cw-preview { color: #4b5563; font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cw-convo-meta { display: flex; flex-wrap: nowrap; gap: .25rem; align-items: center; margin-top: .2rem; overflow: hidden; }
.cw-label-more {
  font-size: .62rem; font-weight: 700; color: #9ca3af; padding: 0 .1rem;
}
.cw-chan {
  font-size: .65rem; font-weight: 700; padding: .1rem .4rem; border-radius: 999px;
  background: #dcfce7; color: #166534;
}
.cw-chan.staff { background: #ffe4e6; color: #be123c; }
.cw-chan.biz { background: #dbeafe; color: #1d4ed8; }
.cw-label {
  font-size: .65rem; font-weight: 700; padding: .1rem .4rem; border-radius: 999px;
  background: #ffedd5; color: #c2410c;
}
.cw-unread {
  min-width: 18px; height: 18px; border-radius: 999px; background: #111827; color: #fff;
  font-size: .68rem; font-weight: 800; display: grid; place-items: center; padding: 0 .3rem; margin-left: auto;
}
.cw-empty, .cw-thread-empty, .cw-details-empty {
  display: grid; place-items: center; height: 100%; color: var(--muted); padding: 1.5rem; text-align: center;
}
.cw-empty-card {
  max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 1.5rem;
  box-shadow: var(--shadow);
}
.cw-empty-card h3 { margin: 0 0 .5rem; color: var(--ink); }
.cw-empty-card p { margin: 0; font-size: .9rem; line-height: 1.45; }

.cw-thread { background: #e6eeea; }
.cw-thread-inner {
  display: flex; flex-direction: column; flex: 1 1 auto;
  height: 100%; min-height: 0; overflow: hidden;
}
.cw-thread-empty { flex: 1 1 auto; min-height: 0; }
.cw-thread-head {
  display: flex; align-items: center; gap: .45rem; padding: .38rem .7rem;
  background: #fff; border-bottom: 1px solid var(--line); flex-shrink: 0;
  flex-wrap: nowrap; min-height: 2.85rem;
}
.cw-thread-identity {
  display: flex; align-items: center; gap: .45rem;
  flex: 1; min-width: 0; overflow: hidden;
}
.cw-thread-meta { flex: 1; min-width: 0; overflow: hidden; display: flex; flex-direction: column; gap: .08rem; }
.cw-thread-meta strong {
  display: block; font-size: .95rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  word-break: normal; overflow-wrap: normal;
}
.cw-thread-subline {
  display: flex; align-items: center; gap: .4rem; min-width: 0;
}
#inboxThreadSub {
  display: block; color: var(--muted); font-size: .75rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.cw-thread-actions { display: flex; gap: .22rem; align-items: center; flex-wrap: nowrap; flex-shrink: 0; margin-left: auto; }
.cw-thread-actions select, .cw-thread-actions button {
  width: auto; margin: 0; padding: .3rem .5rem; font-size: .76rem;
}
#inboxResolveBtn { background: #111827; color: #fff; border: none; padding: .35rem .7rem; }
#inboxResolveBtn:hover { background: #374151; }
.cw-thread-tabs {
  display: flex; gap: .15rem; padding: .2rem .75rem 0; background: #fff; border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.cw-collision, .cw-staff-wa-hint { flex-shrink: 0; }
.cw-ttab {
  width: auto !important; margin: 0 !important; padding: .4rem .75rem !important;
  background: transparent; color: #6b7280; border: none; border-bottom: 2px solid transparent;
  border-radius: 0; font-size: .78rem; font-weight: 650;
}
.cw-ttab.active { color: #111827; border-bottom-color: #111827; }
.cw-messages, .cw-notes-view {
  flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto;
  padding: .85rem 1rem 1.1rem;
  display: flex; flex-direction: column; gap: .55rem;
  -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain;
  touch-action: pan-y; scroll-behavior: auto;
  overflow-anchor: none;
  background-color: transparent;
}
.cw-bubble-row { display: flex; gap: .45rem; align-items: flex-end; max-width: min(90%, 1200px); }
.cw-bubble-row.in { align-self: flex-start; }
.cw-bubble-row.out { align-self: flex-end; flex-direction: row-reverse; }
.cw-bubble {
  padding: .55rem .75rem .4rem; border-radius: 12px; font-size: .9rem; line-height: 1.4;
  word-break: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.04);
  position: relative;
}
.cw-bubble.in { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.cw-bubble.out {
  background: #dcf8c6; color: #111827; border: 1px solid #c6ebc1;
  border-bottom-right-radius: 4px;
}
.cw-bubble.out.chan-staff { border-right: 3px solid #be123c; }
.cw-bubble.out.chan-cloud { border-right: 3px solid #1d4ed8; }
.cw-chan-mark {
  font-size: .58rem; font-weight: 800; letter-spacing: .03em;
  text-transform: uppercase; margin-right: .28rem;
}
.cw-chan-mark.staff { color: #be123c; }
.cw-chan-mark.cloud { color: #1d4ed8; }
.cw-bubble.note {
  background: #fff7ed; border: 1px dashed #fdba74; color: #9a3412; align-self: center; max-width: 90%;
}
.cw-bubble.deleted {
  background: #f3f4f6 !important;
  color: #6b7280 !important;
  border: 1px dashed #d1d5db !important;
  box-shadow: none;
}
.cw-bubble.deleted .cw-deleted-msg {
  font-style: italic;
  font-size: .88rem;
}
.cw-bubble.deleted .cw-time { color: #9ca3af !important; }
/* WhatsApp withheld / unknown message type — readable explanation card */
.cw-unsupported-msg {
  padding-left: .55rem;
  border-left: 3px solid #f59e0b;
  font-size: .9rem;
}
.cw-edited { font-style: italic; opacity: .8; }
.cw-msg-actions {
  position: absolute;
  top: .2rem;
  right: .25rem;
  z-index: 2;
}
.cw-bubble-row.in .cw-msg-actions { right: auto; left: .25rem; }
.cw-msg-menu-btn {
  width: 22px !important; height: 22px; margin: 0 !important; padding: 0 !important;
  border: none; border-radius: 6px; background: rgba(15, 23, 42, 0.08);
  color: inherit; font-size: .85rem; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity .12s ease;
}
.cw-bubble-row:hover .cw-msg-menu-btn,
.cw-msg-actions:focus-within .cw-msg-menu-btn,
.cw-msg-menu-btn:focus { opacity: 1; }
@media (hover: none) {
  .cw-msg-menu-btn { opacity: 0.65; }
}
.cw-bubble.out .cw-msg-menu-btn { background: rgba(15, 23, 42, 0.08); color: #111827; }
.cw-msg-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: .2rem;
  min-width: 168px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  padding: .25rem;
  display: flex;
  flex-direction: column;
  gap: .1rem;
}
.cw-bubble-row.in .cw-msg-menu { right: auto; left: 0; }
.cw-msg-menu[hidden] { display: none !important; }
.cw-msg-action {
  width: 100% !important; margin: 0 !important; padding: .45rem .65rem !important;
  background: transparent; color: #111827; border: none; border-radius: 8px;
  font-size: .78rem; font-weight: 600; text-align: left; cursor: pointer;
}
.cw-msg-action:hover { background: #f3f4f6; }
.cw-bubble .cw-time {
  display: flex; align-items: center; justify-content: flex-end; gap: .18rem;
  font-size: .68rem; margin-top: .2rem; opacity: .85; line-height: 1;
}
.cw-bubble.out .cw-time { color: #667781; }
.cw-ticks {
  display: inline-flex; align-items: center; flex-shrink: 0;
  font-size: .78rem; font-weight: 700; letter-spacing: -.12em; line-height: 1;
}
.cw-ticks svg { display: block; }
.cw-ticks.pending { color: #8696a0; letter-spacing: .04em; font-weight: 800; }
.cw-ticks.sent, .cw-ticks.delivered { color: #667781; }
.cw-ticks.read { color: #53bdeb; }
.cw-ticks.failed { color: #ef4444; letter-spacing: 0; font-weight: 800; }
.cw-day {
  align-self: center; background: #fff; color: #6b7280; font-size: .72rem; font-weight: 650;
  padding: .25rem .65rem; border-radius: 8px; border: 1px solid var(--line); margin: .35rem 0;
}
.cw-composer-shell {
  flex-shrink: 0; margin: .4rem .7rem .35rem; display: flex; flex-direction: column;
}
.cw-composer {
  background: #fff; border: 1px solid var(--line); padding: .1rem .75rem .45rem;
  flex-shrink: 0; margin: 0; border-radius: 12px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .06);
}
.cw-composer-head {
  display: flex; align-items: flex-end; justify-content: flex-start;
  gap: .2rem .55rem; flex-wrap: nowrap; margin-bottom: .15rem;
  border-bottom: 1px solid #f1f5f9; padding-bottom: 0;
}
.cw-composer-tabs { display: flex; gap: .7rem; margin-bottom: 0; flex-shrink: 0; }
.cw-ctab {
  width: auto !important; margin: 0 !important; padding: .45rem .05rem .5rem !important;
  background: transparent; color: #6b7280; border: none; border-radius: 0;
  border-bottom: 2px solid transparent; font-size: .82rem; font-weight: 650;
}
.cw-ctab.active { background: transparent; color: #111827; border-bottom-color: #2563eb; }
.cw-composer-meta {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; padding: .12rem .15rem .38rem; min-height: 0;
}
.cw-composer-meta[hidden] { display: none !important; }
.cw-reply-from {
  display: flex; align-items: center; flex-wrap: wrap; gap: .3rem .5rem;
  margin: 0 0 0 auto;
}
.cw-reply-from-label {
  font-size: .72rem; font-weight: 800; color: #475569; text-transform: uppercase;
  letter-spacing: .05em;
}
.cw-reply-from-options { display: flex; flex-wrap: wrap; gap: .4rem; }
.cw-reply-chip {
  width: auto !important; margin: 0 !important; padding: .34rem .82rem !important;
  background: #fff !important; color: #64748b !important;
  border: 1.5px solid #cbd5e1 !important; border-radius: 999px;
  font-size: .78rem; font-weight: 750; line-height: 1.2; letter-spacing: .01em;
}
.cw-reply-chip:hover {
  background: #f8fafc !important; color: #334155 !important; border-color: #94a3b8 !important;
}
.cw-reply-chip.active {
  background: #1d4ed8 !important; color: #fff !important; border-color: #1e40af !important;
}
.cw-reply-chip-cloud.active {
  background: #1d4ed8 !important; color: #fff !important; border-color: #1e40af !important;
  box-shadow: 0 1px 3px rgba(29, 78, 216, .35);
}
.cw-reply-chip-cloud.active:hover { background: #1e40af !important; }
.cw-reply-chip-staff.active {
  /* Crimson fill — distinct from failed-tick #ef4444 */
  background: #be123c !important; color: #fff !important; border-color: #9f1239 !important;
  box-shadow: 0 1px 3px rgba(190, 18, 60, .4);
}
.cw-reply-chip-staff.active:hover { background: #9f1239 !important; }
.cw-reply-chip:disabled,
.cw-reply-chip[aria-disabled="true"] {
  opacity: .45; cursor: not-allowed;
}
.cw-composer textarea {
  margin: 0; min-height: 56px; max-height: 140px; resize: vertical;
  border-radius: 12px; border: 1px solid var(--line); padding: .7rem .85rem; font-size: .9rem;
  background: #fafbfc;
}
.cw-composer textarea:focus {
  background: #fff; border-color: #93c5fd; outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.cw-composer-bar {
  display: flex; justify-content: flex-start; align-items: center; gap: .75rem; margin-top: .35rem;
}
.cw-hint { color: #94a3b8; font-size: .7rem; }
#inboxComposeHint.cw-send-via {
  font-size: .78rem; font-weight: 750; letter-spacing: .01em;
}
#inboxComposeHint.via-staff { color: #be123c; }
#inboxComposeHint.via-cloud { color: #1d4ed8; }
#inboxComposeHint.via-note { color: #64748b; font-weight: 600; }
#inboxSendBtn {
  width: auto; margin: 0; padding: .5rem 1.15rem; background: #2563eb; border-radius: 8px;
}
#inboxSendBtn:hover { background: #1d4ed8; }
.cw-canned-suggest {
  border: 1px solid var(--line); border-radius: 10px; background: #fff; margin-top: .35rem;
  max-height: 160px; overflow: auto; box-shadow: var(--shadow);
}
.cw-canned-suggest button {
  width: 100%; margin: 0; text-align: left; background: transparent; color: #111;
  border: none; border-bottom: 1px solid #f3f4f6; border-radius: 0; padding: .55rem .75rem; font-weight: 500;
}
.cw-canned-suggest button:hover { background: #f8fafc; }
.cw-canned-suggest strong { display: block; font-size: .8rem; color: #2563eb; }
.cw-canned-suggest span { font-size: .78rem; color: #6b7280; }

.cw-profile { text-align: center; padding: .7rem .75rem .55rem; border-bottom: 1px solid var(--line); }
.cw-profile strong { display: block; font-size: .92rem; line-height: 1.25; }
.cw-profile span { color: var(--muted); font-size: .72rem; }
.cw-avatar.lg { width: 44px; height: 44px; font-size: .95rem; margin: 0 auto .4rem; }
.cw-detail-block { padding: .55rem .75rem; border-bottom: 1px solid var(--line); }
.cw-detail-block > label {
  display: block; font-size: .62rem; font-weight: 750; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); margin-bottom: .35rem;
}
.cw-kv {
  display: flex; justify-content: space-between; gap: .45rem; padding: .18rem 0; font-size: .78rem;
  align-items: flex-start;
}
.cw-kv span { color: var(--muted); flex: 0 0 auto; }
.cw-kv strong { font-weight: 650; text-align: right; word-break: break-word; }
.cw-field { margin-bottom: .4rem; }
.cw-field:last-child { margin-bottom: 0; }
.cw-field > span { display: block; font-size: .7rem; color: var(--muted); margin-bottom: .15rem; }
.cw-field select { margin: 0; font-size: .8rem; padding: .4rem .5rem; }
.cw-tags { display: flex; flex-wrap: wrap; gap: .25rem; margin-bottom: .35rem; min-height: 1.15rem; }
.cw-tag-add { display: flex; gap: .3rem; }
.cw-tag-add input { margin: 0; font-size: .78rem; padding: .4rem .5rem; }
.cw-tag-add button { width: auto; margin: 0; padding: .35rem .55rem; }
.cw-macros { display: flex; flex-direction: column; gap: .25rem; }
.cw-macros button {
  width: 100%; margin: 0; text-align: left; background: #f8fafc; color: #111;
  border: 1px solid var(--line); font-weight: 600; font-size: .75rem; padding: .4rem .55rem;
}
.cw-macros button:hover { background: #f3f4f6; }
.cw-detail-actions {
  display: flex; flex-direction: column; gap: .3rem; padding: .55rem .75rem .9rem;
}
.cw-detail-actions button { margin: 0; padding: .45rem .65rem; font-size: .78rem; }
.cw-attrs { display: flex; flex-direction: column; gap: .3rem; }
.cw-attr { display: flex; flex-direction: column; gap: .12rem; margin: 0; font-size: .72rem; color: var(--muted); }
.cw-attr input { margin: 0; font-size: .8rem; padding: .35rem .5rem; }
.cw-attr-save { margin-top: .35rem !important; width: auto !important; padding: .35rem .6rem !important; font-size: .75rem !important; }

.cw-commerce { display: flex; flex-direction: column; gap: .45rem; }
.cw-commerce-empty {
  color: var(--muted); font-size: .75rem; line-height: 1.35;
  padding: .35rem .45rem; background: #f8fafc; border: 1px dashed #e5e7eb; border-radius: 8px;
}
.cw-commerce-meta { display: flex; flex-direction: column; gap: .15rem; }
.cw-commerce-row {
  display: flex; justify-content: space-between; gap: .4rem; font-size: .76rem; padding: .12rem 0;
}
.cw-commerce-row span { color: var(--muted); }
.cw-commerce-row strong { font-weight: 650; text-align: right; }
.cw-commerce-sub {
  font-size: .62rem; font-weight: 750; text-transform: uppercase; letter-spacing: .04em;
  color: #9ca3af; margin: .15rem 0 0;
}
.cw-commerce-list { display: flex; flex-direction: column; gap: .3rem; }
.cw-commerce-item {
  display: grid; grid-template-columns: 1fr auto; gap: .15rem .5rem;
  padding: .35rem .45rem; background: #f8fafc; border: 1px solid #eef0f3; border-radius: 8px;
  font-size: .74rem;
}
.cw-commerce-item .cw-ci-title { font-weight: 700; color: #111827; grid-column: 1 / -1; }
.cw-commerce-item .cw-ci-meta { color: var(--muted); font-size: .7rem; }
.cw-commerce-item .cw-ci-amt { font-weight: 700; text-align: right; white-space: nowrap; }
.cw-commerce-pill {
  display: inline-flex; align-items: center; font-size: .65rem; font-weight: 700;
  padding: .1rem .4rem; border-radius: 999px; background: #ecfdf5; color: #047857;
}
.cw-commerce-pill.warn { background: #fff7ed; color: #c2410c; }
.cw-commerce-pill.muted { background: #f3f4f6; color: #6b7280; }
.cw-commerce-pill.ok { background: #eff6ff; color: #1d4ed8; }

.cw-collision {
  background: #fff7ed; color: #9a3412; border-bottom: 1px solid #fed7aa;
  padding: .45rem .9rem; font-size: .8rem; font-weight: 600;
}
.cw-staff-wa-hint {
  background: #ecfdf5; color: #065f46; border-bottom: 1px solid #a7f3d0;
  padding: .45rem .9rem; font-size: .78rem; font-weight: 600;
}
.cw-sla-row { display: inline-flex; flex-wrap: nowrap; gap: .25rem; margin: 0; flex-shrink: 0; }
.cw-sla, .cw-sla-mini {
  display: inline-flex; align-items: center; gap: .2rem;
  font-size: .65rem; font-weight: 700; padding: .05rem .4rem;
  border-radius: 999px; background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0;
}
.cw-sla.compact { font-size: .65rem; padding: .04rem .4rem; font-weight: 650; }
.cw-sla.res { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.cw-sla.breach, .cw-sla-mini.breach { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.cw-shortcut-hint {
  margin-left: auto; align-self: center; color: var(--muted); font-size: .7rem; padding-right: .5rem;
}
.cw-bulk-bar {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between;
  padding: .45rem .75rem; background: #f8fafc; border-bottom: 1px solid var(--line); font-size: .8rem;
}
.cw-bulk-bar label { display: flex; align-items: center; gap: .4rem; margin: 0; }
.cw-bulk-actions { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.cw-bulk-actions button, .cw-bulk-actions select {
  width: auto; margin: 0; padding: .35rem .6rem; font-size: .78rem;
}
.cw-convo { position: relative; }
.cw-bulk-check {
  position: absolute; left: .45rem; top: .85rem; z-index: 2; width: auto; margin: 0;
}
.cw-convo:has(.cw-bulk-check) { padding-left: 1.85rem; }
.feat-catalog {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .55rem;
  margin: 0 0 1rem;
}
.feat-catalog-card {
  width: 100%; margin: 0; text-align: left; background: #f8fafc; border: 1px solid var(--line);
  border-radius: 10px; padding: .75rem .8rem; display: flex; flex-direction: column; gap: .3rem;
  color: inherit; font-weight: 500;
}
.feat-catalog-card:hover { background: #f3f4f6; border-color: #d1d5db; }
.feat-catalog-card strong { font-size: .85rem; color: #111827; }
.feat-catalog-card span { font-size: .75rem; color: var(--muted); line-height: 1.35; font-weight: 500; }

@media (max-width: 1100px) {
  .cw-inbox {
    grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
    grid-template-areas:
      "folders folders"
      "list thread";
  }
  .cw-inbox.cw-details-open {
    grid-template-columns: minmax(220px, 260px) minmax(0, 1fr) minmax(240px, 280px);
    grid-template-areas:
      "folders folders folders"
      "list thread details";
  }
}
@media (max-width: 900px) {
  /* Mobile: lock shell height so .content / inbox are the scrollports */
  html, body {
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
  }
  .login-wrap {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
  }
  #app {
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }
  /* Mobile: sidebar becomes a drawer — never permanently hide all modules */
  .app-shell {
    grid-template-columns: 1fr;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .nav-menu-btn { display: grid; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(86vw, 300px);
    z-index: 50; transform: translateX(-105%);
    transition: transform 0.22s ease; box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
    height: 100dvh;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .nav-backdrop { display: block; }

  body.inbox-tab .sidebar { display: flex; } /* keep drawer available even on inbox */
  body.inbox-tab .topbar-actions .search-pill,
  body.inbox-tab .topbar-actions button:not(#topbarRefreshBtn):not(.nav-menu-btn) { display: none; }
  body.inbox-tab .topbar { padding: 0.55rem 0.75rem; gap: 0.5rem; }
  body.inbox-tab .topbar h1 { font-size: 1.05rem; }
  body.inbox-tab #topbarRefreshBtn { padding: 0.4rem 0.65rem; font-size: 0.78rem; }
  body.inbox-tab .content { padding: 0.5rem; }
  body.inbox-tab .main { min-width: 0; }

  .main {
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
  }
  .topbar {
    flex-shrink: 0;
    position: relative;
  }
  .mobile-bottom-nav {
    display: flex; gap: 0.25rem;
    order: 100;
    flex-shrink: 0;
    position: relative;
    z-index: 30;
    padding: 0.4rem 0.45rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.06);
  }
  .mb-nav {
    flex: 1; margin: 0; padding: 0.4rem 0.2rem;
    display: flex; flex-direction: column; align-items: center; gap: 0.1rem;
    background: transparent; border: none; border-radius: 12px;
    color: var(--muted); font-size: 0.62rem; font-weight: 750;
  }
  .mb-nav span {
    width: 26px; height: 26px; border-radius: 9px;
    display: grid; place-items: center; font-size: 0.72rem; font-weight: 800;
  }
  .mb-nav.active { color: #3730a3; background: #eef2ff; }
  .mb-nav.active span {
    background: linear-gradient(145deg, #5b5ce2, #7c3aed); color: #fff;
  }
  .content {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    padding-bottom: 1rem;
  }
  /* Inbox owns its scrollports — don't nest under document scroll */
  body.inbox-tab .content {
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  body.inbox-tab #inbox.panel.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }
  body.inbox-tab .cw-mobile-app-bar { flex-shrink: 0; }

  .cw-inbox {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "folders"
      "list";
    flex: 1;
    height: auto;
    min-height: 0;
    border-radius: 14px;
    overflow: hidden;
  }
  .cw-inbox.cw-details-open {
    grid-template-columns: 1fr;
  }
  .cw-inbox.cw-chat-open {
    grid-template-areas:
      "folders"
      "thread";
  }
  .cw-folders {
    display: flex;
    position: static;
    z-index: auto;
    width: auto;
    height: auto;
    box-shadow: none;
    overflow-x: auto;
  }
  .cw-folders-toggle { display: none !important; }
  .cw-list {
    max-height: none;
    height: 100%;
    min-height: 0;
    border-right: none;
    border-bottom: none;
  }
  .cw-convo-list {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
  }
  .cw-messages, .cw-notes-view {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
  }
  .cw-thread {
    display: none;
    min-height: 0;
    height: 100%;
  }
  .cw-inbox.cw-chat-open .cw-list { display: none; }
  .cw-inbox.cw-chat-open .cw-thread { display: flex; }
  .cw-details {
    display: none;
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(320px, 92vw);
    z-index: 45;
    border-left: 1px solid var(--line);
    box-shadow: -12px 0 32px rgba(15, 23, 42, 0.14);
    background: #fff;
  }
  .cw-details-rail { display: none; }
  .cw-inbox.cw-details-open .cw-details {
    display: flex; flex-direction: column;
  }
  .cw-inbox.cw-details-open .cw-details-panel { display: flex; width: 100%; }
  .cw-details-toggle span { display: none; }

  .cw-list-head { padding: 0.75rem 0.85rem 0.45rem; }
  .cw-scope-tabs { padding: 0.4rem 0.55rem; }
  .cw-convo { padding: 0.5rem 0.75rem; gap: 0.5rem; }
  .cw-preview { font-size: 0.78rem; }
  .cw-sla-mini { font-size: 0.62rem; padding: 0.1rem 0.35rem; }
  .cw-shortcut-hint { display: none !important; }
  .cw-thread-head { padding: 0.55rem 0.65rem; gap: 0.5rem; }
  .cw-thread-actions select { display: none; }
  .cw-thread-actions button { padding: 0.4rem 0.65rem; font-size: 0.75rem; }
  .cw-thread-meta #inboxThreadSub {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 55vw;
  }
  .cw-sla-row { gap: 0.25rem; }
  .cw-sla { font-size: 0.62rem; padding: 0.12rem 0.4rem; }
  .cw-messages, .cw-notes-view { padding: 0.75rem; }
  .cw-bubble-row { max-width: 88%; }
  .cw-composer-shell { margin: .3rem .45rem .3rem; }
  .cw-composer { padding: 0.2rem 0.55rem calc(0.45rem + env(safe-area-inset-bottom, 0px)); }
  .cw-composer textarea, .cw-composer .cw-compose-editor { min-height: 44px; font-size: 0.92rem; }
  .cw-hint { display: none; }
  #inboxComposeHint.cw-send-via { display: inline; }
  .cw-compose-mdhint { display: block; }
  .cw-back {
    display: grid !important;
    width: 36px; height: 36px; margin: 0; padding: 0;
    border-radius: 10px; border: 1px solid var(--line);
    background: #fff; color: var(--ink); font-size: 1.1rem;
    place-items: center; flex-shrink: 0;
  }
  .cw-mobile-app-bar {
    display: flex !important;
    align-items: center; justify-content: space-between; gap: 0.5rem;
    margin: 0 0 0.5rem; padding: 0.55rem 0.75rem;
    background: linear-gradient(135deg, #eef2ff, #f8fafc);
    border: 1px solid #c7d2fe; border-radius: 12px;
    font-size: 0.78rem; font-weight: 650; color: #3730a3;
  }
  .cw-mobile-app-bar a {
    color: #fff; background: linear-gradient(135deg, #5b5ce2, #4f46e5);
    text-decoration: none; font-weight: 750; font-size: 0.75rem;
    padding: 0.4rem 0.7rem; border-radius: 999px; white-space: nowrap;
  }
}
.cw-back { display: none; }
.cw-mobile-app-bar { display: none; }
.cw-media {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-weight: 650; font-size: 0.88rem;
}
.cw-media-icon {
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center; font-size: 0.85rem;
  background: rgba(15, 23, 42, 0.06);
}
.cw-bubble.out .cw-media-icon { background: rgba(15, 23, 42, 0.06); }
.cw-media-block { display: flex; flex-direction: column; gap: 0.4rem; max-width: min(52vw, 420px); }
.cw-media-link { display: block; border-radius: 12px; overflow: hidden; cursor: zoom-in; position: relative; }
.cw-media-video-link { cursor: pointer; }
.cw-media-preview { pointer-events: none; }
.cw-media-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 44px; height: 44px; border-radius: 999px;
  display: grid; place-items: center;
  background: rgba(15, 23, 42, 0.55); color: #fff; font-size: 1rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
}
.cw-media-open { cursor: pointer; }
.cw-media-img {
  display: block; width: 100%; max-height: 320px; object-fit: cover;
  background: rgba(15, 23, 42, 0.06); border-radius: 12px;
}
.cw-media-video {
  width: 100%; max-height: 280px; border-radius: 12px; background: #0f172a;
}
.cw-media-audio { width: 100%; max-width: 260px; }
.cw-media-doc {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-weight: 700; color: inherit; text-decoration: underline;
}
.cw-media-caption { font-size: 0.88rem; line-height: 1.35; word-break: break-word; }
.cw-bubble.out .cw-media-img { box-shadow: 0 4px 14px rgba(15, 23, 42, 0.18); }

/* In-thread media lightbox (stay in inbox; no new tab) */
body.inbox-lightbox-open { overflow: hidden; }
.cw-lightbox {
  position: fixed; inset: 0; z-index: 1200;
  display: grid; place-items: center;
  padding: 1.25rem;
}
.cw-lightbox[hidden] { display: none !important; }
.cw-lightbox-backdrop {
  position: absolute; inset: 0; border: 0; margin: 0; padding: 0;
  background: rgba(15, 23, 42, 0.72); cursor: zoom-out;
}
.cw-lightbox-inner {
  position: relative; z-index: 1; width: min(960px, 94vw); max-height: 90vh;
  display: flex; flex-direction: column; align-items: stretch; gap: .65rem;
}
.cw-lightbox-title {
  margin: 0; text-align: center; color: #fff; font-size: .85rem; font-weight: 650;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cw-lightbox-body {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .5rem; min-height: 120px; max-height: calc(90vh - 5rem); overflow: auto;
}
.cw-lightbox-img {
  display: block; max-width: 100%; max-height: calc(90vh - 5.5rem);
  object-fit: contain; border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  background: #0f172a;
}
.cw-lightbox-video {
  display: block; width: 100%; max-height: calc(90vh - 5.5rem);
  border-radius: 12px; background: #0f172a;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}
.cw-lightbox-audio { width: 100%; max-width: 420px; }
.cw-lightbox-frame {
  display: block; width: 100%; height: min(72vh, 640px);
  border: 0; border-radius: 12px; background: #fff;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}
.cw-lightbox-hint {
  margin: 0; color: rgba(255,255,255,.85); font-size: .78rem; text-align: center; line-height: 1.4;
}
.cw-lightbox-actions {
  display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center;
}
.cw-lightbox-close, .cw-lightbox-open {
  width: auto; margin: 0; padding: .45rem .9rem; font-size: .82rem; font-weight: 700;
  border-radius: 999px; border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.12); color: #fff; text-decoration: none;
}
.cw-lightbox-close:hover, .cw-lightbox-open:hover { background: rgba(255,255,255,.22); }

/* ── Shadcn-style Platform Settings / Features ── */
.ps-shell { display: grid; grid-template-columns: 200px 1fr; gap: 1.25rem; align-items: start; }
.ps-nav {
  position: sticky; top: 5.2rem; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: .65rem;
  max-height: calc(100vh - 6.5rem); overflow: auto;
}
.ps-nav button {
  width: 100%; margin: 0 0 .2rem; padding: .55rem .7rem; text-align: left;
  background: transparent; color: #374151; border: none; border-radius: 8px;
  font-size: .82rem; font-weight: 600;
}
.ps-nav button:hover { background: #f3f4f6; }
.ps-nav button.active { background: #111827; color: #fff; }
.ps-nav .ps-nav-label {
  color: var(--muted); font-size: .65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; padding: .55rem .55rem .25rem;
}
.ps-main { min-width: 0; }
.ps-hero {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem 1.35rem; margin-bottom: 1rem;
  display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: flex-start;
}
.ps-hero h3 { margin: 0 0 .35rem; font-size: 1.05rem; }
.ps-hero p { color: var(--muted); font-size: .85rem; max-width: 52ch; line-height: 1.45; margin: 0; }
.ps-hero-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.ps-hero-actions button { width: auto; margin: 0; padding: .5rem .85rem; font-size: .85rem; }

.feat-toolbar {
  display: flex; flex-wrap: wrap; gap: .65rem; align-items: center;
  margin-bottom: 1rem;
}
.feat-search {
  flex: 1; min-width: 200px; margin: 0 !important;
  background: #fff; border-radius: 10px;
}
.feat-count {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .4rem .7rem; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; font-size: .8rem; font-weight: 650; color: #374151; white-space: nowrap;
}
.feat-count strong { color: var(--ok); font-size: .95rem; }

.feat-group { margin-bottom: 1.15rem; }
.feat-group-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: .75rem;
  margin-bottom: .55rem; padding: 0 .15rem;
}
.feat-group-head h4 { font-size: .8rem; font-weight: 700; letter-spacing: .02em; color: #111827; }
.feat-group-head span { color: var(--muted); font-size: .72rem; font-weight: 550; }

.feat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .65rem;
}
.feat-card {
  display: flex; align-items: flex-start; justify-content: space-between; gap: .85rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: .95rem 1rem; box-shadow: 0 1px 2px rgba(16,24,40,.04);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.feat-card:hover { border-color: #d1d5db; box-shadow: var(--shadow); }
.feat-card.is-off { background: #fafafa; }
.feat-card.is-off .feat-title { color: #6b7280; }
.feat-card-body { min-width: 0; flex: 1; }
.feat-ico {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  font-size: .65rem; font-weight: 800; letter-spacing: .02em; margin-bottom: .55rem;
  background: #f3f4f6; color: #374151; flex: 0 0 auto;
}
.feat-card.is-on .feat-ico { background: #ecfdf5; color: #047857; }
.feat-card.feat-card-flash {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
  background: #eff6ff;
}
.cw-shortcut-hint { cursor: pointer; }
.cw-shortcut-hint:hover { color: #111; text-decoration: underline; }
.feat-title { font-size: .9rem; font-weight: 700; letter-spacing: -.01em; margin-bottom: .2rem; }
.feat-help { color: var(--muted); font-size: .75rem; line-height: 1.4; }
.feat-meta { margin-top: .45rem; display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.feat-state {
  font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: .15rem .45rem; border-radius: 6px;
}
.feat-state.on { background: #d1fae5; color: #065f46; }
.feat-state.off { background: #f3f4f6; color: #6b7280; }

/* Switch (shadcn-like) */
.switch {
  position: relative; display: inline-flex; width: 42px; height: 24px; flex: 0 0 auto;
  margin: 0 !important; cursor: pointer;
}
.switch input {
  position: absolute; opacity: 0; width: 0; height: 0; margin: 0; pointer-events: none;
}
.switch-track {
  position: absolute; inset: 0; background: #e5e7eb; border-radius: 999px;
  transition: background .15s ease; border: 1px solid #d1d5db;
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 999px;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.18); transition: transform .15s ease;
}
.switch input:checked + .switch-track { background: #111827; border-color: #111827; }
.switch input:checked ~ .switch-thumb { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid #111827; outline-offset: 2px; }

.feat-footer {
  position: sticky; bottom: .75rem; z-index: 15;
  display: flex; flex-wrap: wrap; gap: .65rem; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.92); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  padding: .75rem 1rem; margin-top: .5rem;
}
.feat-footer p { margin: 0; color: var(--muted); font-size: .8rem; }
.feat-footer .actions { margin: 0; }
.feat-footer button { width: auto; margin: 0; }

.ps-section-card .form-row.ps-fields {
  grid-template-columns: 1fr 1fr; align-items: end;
}
.ps-section-card .ps-bool-grid {
  display: grid; grid-template-columns: 1fr; gap: .35rem; margin-bottom: .75rem;
  grid-column: 1 / -1;
}

@media (max-width: 980px) {
  .ps-shell { grid-template-columns: 1fr; }
  .ps-nav { position: relative; top: 0; max-height: none; display: flex; flex-wrap: wrap; gap: .25rem; }
  .ps-nav .ps-nav-label { width: 100%; }
  .ps-nav button { width: auto; }
}

/* Platform Settings: one section page at a time */
.ps-section-card[hidden],
.ps-section-card.is-hidden { display: none !important; }
.ps-nav .ps-nav-label + button { margin-top: 0; }
#settingsHubPages .ai-card { margin-bottom: 1rem; }


/* Labeled form fields + accounting / integration status */
.field-label { display:block; font-size:.78rem; font-weight:600; color:#556; margin:0 0 .35rem; }
.field { display:flex; flex-direction:column; min-width:0; }
.field input, .field select, .field textarea { margin-bottom:0; }
.check-line {
  display:flex; align-items:flex-start; gap:.65rem; margin:.65rem 0;
  font-size:.9rem; color:#445; line-height:1.35; cursor:pointer;
}
.check-line input[type=checkbox] {
  width:auto; min-width:1.05rem; margin:.15rem 0 0; flex-shrink:0;
  padding:0; accent-color: var(--brand);
}
.btn-row { display:flex; flex-wrap:wrap; gap:.5rem; align-items:center; margin:1rem 0 .25rem; }
.btn-row button { width:auto; margin:0; }
.btn-row .danger { margin-left:auto; }
.status-banner {
  display:flex; flex-wrap:wrap; gap:.75rem 1.25rem; align-items:center;
  padding:.85rem 1rem; border-radius:10px; border:1px solid var(--line);
  background:#f8fafc; margin-bottom:1rem; font-size:.9rem;
}
.status-banner .sb-ok { color:#047857; font-weight:700; }
.status-banner .sb-warn { color:#b45309; font-weight:700; }
.status-banner .sb-meta { color:var(--muted); font-size:.82rem; }
.status-kv-grid {
  display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr));
  gap:.65rem; margin-bottom:1rem;
}
.status-kv {
  background:#f8fafc; border:1px solid var(--line); border-radius:10px; padding:.75rem .85rem;
}
.status-kv span { display:block; font-size:.72rem; color:var(--muted); font-weight:600; text-transform:uppercase; letter-spacing:.02em; }
.status-kv strong { display:block; margin-top:.2rem; font-size:.9rem; word-break:break-word; }
.acct-section { margin:1.1rem 0 .35rem; padding-top:.85rem; border-top:1px solid #eee; }
.acct-section:first-of-type { border-top:none; padding-top:0; margin-top:0; }
.acct-section h4 { margin:0 0 .65rem; font-size:.95rem; color:var(--ink); }
.bc-filter-row { display:flex; flex-wrap:wrap; gap:.4rem; margin-bottom:.55rem; align-items:center; }
.bc-chip {
  border:1px solid var(--line); background:#fff; color:var(--ink); border-radius:999px;
  padding:.3rem .7rem; font-size:.78rem; font-weight:600; width:auto; margin:0; cursor:pointer;
}
.bc-chip.active { background:#111827; color:#fff; border-color:#111827; }
.bc-chip.exclude { background:#fff; color:#9a3412; border-color:#fdba74; }
.bc-chip.exclude.active { background:#9a3412; color:#fff; border-color:#9a3412; }
.disp-chip-row { display:flex; flex-wrap:wrap; gap:.35rem; }
.disp-chip {
  border:1px solid var(--line); background:#fff; color:var(--ink); border-radius:999px;
  padding:.28rem .65rem; font-size:.75rem; font-weight:600; width:auto; margin:0; cursor:pointer;
}
.disp-chip:hover { border-color: currentColor; }
.disp-chip.active { color:#fff !important; }
.disp-chip-mini {
  border:1px solid var(--line); background:#fff; color:var(--ink); border-radius:999px;
  padding:.2rem .45rem; font-size:.68rem; font-weight:600; width:auto; margin:0 .15rem .15rem 0; cursor:pointer;
}
.disp-select,
.lead-owner-select,
.lead-disp-select,
.crm-table-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  display: inline-block;
  width: 100%;
  max-width: 100%;
  height: 30px;
  min-height: 30px;
  margin: 0;
  padding: 0 1.35rem 0 .5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M2.6 4.2a.75.75 0 0 1 1.06 0L6 6.54l2.34-2.34a.75.75 0 1 1 1.06 1.06L6.53 8.13a.75.75 0 0 1-1.06 0L2.6 5.26a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .4rem center;
  background-size: .7rem;
  color: var(--ink);
  font-size: .75rem;
  font-weight: 550;
  font-family: inherit;
  line-height: 1.2;
  cursor: pointer;
  box-sizing: border-box;
}
.disp-select:hover,
.lead-owner-select:hover,
.lead-disp-select:hover,
.crm-table-select:hover { border-color: #cbd5e1; }
.disp-select:focus,
.lead-owner-select:focus,
.lead-disp-select:focus,
.crm-table-select:focus {
  outline: 2px solid rgba(91,92,226,.28);
  outline-offset: 1px;
  border-color: #a5b4fc;
}
.lead-disp-select {
  width: auto; min-width: 6.4rem; max-width: 8.5rem; flex: 1 1 auto;
}
.lead-row-actions {
  display:flex; flex-wrap:nowrap; gap:.25rem; align-items:center; justify-content:flex-end;
  max-width:none;
}
.lead-act-btn {
  width:auto !important; margin:0 !important; padding:.25rem .5rem !important;
  font-size:.72rem !important; line-height:1.2;
}
.lead-note-hint {
  margin-top:.2rem; font-size:.68rem; color:var(--muted); max-width:100%;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
/* Recent leads card header — equal-height toolbar, wraps without clipping */
#leadsInboundDataCard { overflow: visible; }
.leads-card-head {
  display: flex; flex-wrap: wrap; gap: .5rem .75rem;
  align-items: center; justify-content: space-between; margin-bottom: .5rem;
}
.leads-card-title { margin: 0; }
.leads-card-toolbar,
.leads-header-actions {
  display: flex; align-items: center; flex-wrap: wrap; gap: .4rem;
  min-width: 0; max-width: 100%; flex: 1 1 auto; justify-content: flex-end;
}
.leads-toolbar-btn,
.leads-card-toolbar > button,
.leads-header-actions > button {
  width: auto !important; margin: 0 !important;
  height: 36px; min-height: 36px; padding: 0 .85rem !important;
  font-size: .8125rem !important; font-weight: 600; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  white-space: nowrap; box-sizing: border-box; border-radius: 10px;
  flex: 0 0 auto;
}
.leads-toolbar-btn.secondary,
.leads-card-toolbar > button.secondary,
.leads-header-actions > button.secondary {
  background: #374151; color: #fff; border: 1px solid #374151;
}
.leads-toolbar-btn.secondary:hover,
.leads-card-toolbar > button.secondary:hover,
.leads-header-actions > button.secondary:hover {
  background: #1f2937; border-color: #1f2937;
}
.leads-toolbar-btn.ghost,
.leads-card-toolbar > button.ghost,
.leads-header-actions > button.ghost {
  background: #fff; color: var(--ink); border: 1px solid var(--line);
}
.leads-toolbar-btn.ghost:hover,
.leads-card-toolbar > button.ghost:hover,
.leads-header-actions > button.ghost:hover {
  background: #f9fafb;
}
.lead-view-toggle {
  display: inline-flex; align-items: stretch; gap: 0;
  height: 36px; min-height: 36px; flex: 0 0 auto;
  border: 1px solid #374151; border-radius: 10px; overflow: hidden;
  background: #374151; box-sizing: border-box;
}
.lead-view-btn {
  margin: 0 !important; width: auto !important;
  height: 100% !important; min-height: 0 !important;
  padding: 0 .9rem !important; font-size: .8125rem !important; font-weight: 600;
  line-height: 1; display: inline-flex; align-items: center; justify-content: center;
  box-sizing: border-box; border: none !important; border-radius: 0 !important;
  background: #4b5563 !important; color: #fff !important; flex: 0 0 auto;
}
.lead-view-btn:hover { background: #374151 !important; }
.lead-view-btn.active { background: #111827 !important; color: #fff !important; }
.lead-toolbar {
  display:flex; flex-wrap:wrap; gap:.5rem .75rem; align-items:end; margin:.35rem 0 .75rem;
}
.lead-toolbar .lead-act-btn {
  height: 36px; min-height: 36px; padding: 0 .75rem !important;
  font-size: .8125rem !important; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  box-sizing: border-box; border-radius: 10px;
}
.lead-toolbar .lead-act-btn.secondary {
  background: #374151; color: #fff; border: 1px solid #374151;
}
.lead-toolbar .lead-act-btn.ghost {
  background: #fff; color: var(--ink); border: 1px solid var(--line);
}
.lead-columns-wrap { position:relative; display:inline-flex; align-items:flex-end; }
.lead-columns-popover {
  position:absolute; top:calc(100% + 4px); right:0; z-index:80;
  width:15.75rem; min-width:15.75rem; max-width:18rem; padding:.65rem .8rem;
  background:#fff; border:1px solid var(--line); border-radius:10px;
  box-shadow:0 8px 24px rgba(15,23,42,.12);
  overflow:hidden; box-sizing:border-box;
}
.lead-columns-popover[hidden] { display:none !important; }
.lead-columns-popover-title {
  font-size:.72rem; font-weight:700; color:#4b5563; margin-bottom:.45rem;
  text-transform:uppercase; letter-spacing:.02em;
}
.lead-columns-checklist { display:flex; flex-direction:column; gap:.15rem; min-width:0; }
.lead-columns-checklist label {
  display:grid; grid-template-columns:1rem minmax(0,1fr); align-items:center;
  column-gap:.55rem; font-size:.8rem; color:var(--ink);
  cursor:pointer; user-select:none; margin:0; font-weight:500;
  width:100%; max-width:100%; line-height:1.25; padding:.12rem 0;
  box-sizing:border-box;
}
.lead-columns-checklist label > span {
  min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
/* Global `input { width:100% }` was stretching checkboxes and shoving labels outside the panel */
.lead-columns-checklist input[type="checkbox"] {
  margin:0 !important; padding:0 !important;
  width:1rem !important; height:1rem !important;
  min-width:1rem !important; max-width:1rem !important;
  justify-self:start; accent-color:var(--brand);
  box-sizing:border-box;
}
.lead-columns-popover .lead-act-btn {
  margin-top:.4rem; width:100%; box-sizing:border-box;
}
.leads-table .lt-custom { width:8.5rem; }
.leads-table .lt-campaign { width:6.5rem; }
.leads-table .lt-territory { width:5.5rem; }
.leads-table .lt-sla { width:4.8rem; }
.leads-table td.lt-custom,
.leads-table td.lt-campaign,
.leads-table td.lt-territory {
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.lead-custom-msg {
  font-size:.75rem; color:#334155; max-width:100%;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.lead-toolbar-field { display:flex; flex-direction:column; gap:.2rem; font-size:.72rem; color:var(--muted); }
.lead-toolbar-field select, .lead-toolbar-field input {
  margin:0; min-width:8rem; height:36px; padding:0 .55rem; font-size:.8rem;
  border-radius:8px; border:1px solid var(--line); box-sizing:border-box;
  background-color:#fff; color:var(--ink);
}
.lead-toolbar-field select {
  appearance: none; -webkit-appearance: none;
  padding-right: 1.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M2.6 4.2a.75.75 0 0 1 1.06 0L6 6.54l2.34-2.34a.75.75 0 1 1 1.06 1.06L6.53 8.13a.75.75 0 0 1-1.06 0L2.6 5.26a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .45rem center;
  background-size: .7rem;
}
.lead-owner-select {
  width:100%; max-width:8.5rem; min-width:0;
}
.lead-sla {
  display:inline-flex; align-items:center; padding:.1rem .35rem; border-radius:6px;
  font-size:.65rem; font-weight:700; white-space:nowrap;
}
.lead-sla.overdue { background:#fef2f2; color:#b91c1c; }
.lead-sla.due-soon { background:#fffbeb; color:#b45309; }
.lead-sla.ok { background:#f0fdf4; color:#15803d; }
.lead-sla-wrap { margin-top:.2rem; }

/* Compact Recent leads list — fit ~1100–1280px without horizontal scroll */
.leads-list-wrap {
  width:100%; max-width:100%; overflow:visible;
}
/* display:grid/block on surfaces must not defeat the hidden attribute */
.leads-list-wrap[hidden],
.lead-kanban[hidden] {
  display:none !important;
}
.leads-table {
  width:100%; table-layout:fixed; border-collapse:collapse; font-size:.8rem;
  background:transparent; border:none; border-radius:0; box-shadow:none; overflow:visible;
}
.leads-table th, .leads-table td {
  padding:.32rem .4rem; vertical-align:middle; border-bottom:1px solid #eee;
}
.leads-table th {
  background:#f9fafb; font-size:.72rem; font-weight:650; color:#4b5563;
  white-space:nowrap; vertical-align:middle;
}
.leads-table .lt-when { width:7.6rem; }
.leads-table .lt-date { width:6.2rem; font-variant-numeric:tabular-nums; white-space:nowrap; }
.leads-table .lt-time { width:3.6rem; font-variant-numeric:tabular-nums; white-space:nowrap; }
.leads-table .lt-city { width:6.5rem; }
.leads-table .lt-state { width:7rem; }
.leads-table .lt-lead { width:9.5rem; }
.leads-table .lt-source { width:5.2rem; }
.leads-table .lt-status { width:6.2rem; }
.leads-table .lt-owner { width:7.5rem; }
.leads-table .lt-msg { width:auto; max-width:0; /* remaining space; allow ellipsis */ }
.leads-table .lt-url { width:10rem; }
.leads-table .lt-actions { width:9.2rem; }
.leads-table td.lt-msg,
.leads-table td.lt-url,
.leads-table td.lt-lead,
.leads-table td.lt-source,
.leads-table td.lt-status,
.leads-table td.lt-city,
.leads-table td.lt-state {
  overflow:hidden;
}
.leads-table td.lt-city,
.leads-table td.lt-state {
  font-size:.78rem; color:#374151;
  white-space:nowrap; text-overflow:ellipsis;
}
.leads-table td.lt-date,
.leads-table td.lt-time {
  font-size:.78rem; color:#374151;
}
.leads-table td.lt-when { vertical-align:top; padding-top:.4rem; padding-bottom:.4rem; }
.leads-table td.lt-actions { overflow:visible; }
.lead-when {
  display:flex; flex-direction:column; gap:.08rem;
  font-variant-numeric:tabular-nums; line-height:1.25; min-width:0;
}
.lead-when-rel {
  font-size:.72rem; color:var(--muted); white-space:nowrap;
}
.lead-when-abs {
  font-size:.66rem; color:#6b7280; white-space:nowrap;
  overflow:hidden; text-overflow:ellipsis; max-width:100%;
}
.lead-name {
  display:block; font-weight:600; font-size:.8rem; line-height:1.2;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:100%;
}
/* Names are text links — never inherit the filled purple button (Contacts + Leads). */
button.crm-name-link,
.leads-table .crm-name-link,
.lead-name .crm-name-link,
.crm-contacts-table .crm-name-link {
  display: inline-block !important;
  width: auto !important;
  max-width: 100%;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  background-color: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  color: #0f766e !important;
  font: inherit;
  font-size: inherit;
  font-weight: 650 !important;
  line-height: 1.25;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: baseline;
}
button.crm-name-link:hover,
button.crm-name-link:focus,
button.crm-name-link:focus-visible,
.leads-table .crm-name-link:hover,
.lead-name .crm-name-link:hover,
.crm-contacts-table .crm-name-link:hover {
  background: transparent !important;
  background-color: transparent !important;
  color: #115e59 !important;
  text-decoration-thickness: 2px;
}
.leads-table .crm-name-link,
.lead-name .crm-name-link { font-size: .8rem; }
.lead-phone {
  font-size:.7rem; color:var(--muted); font-variant-numeric:tabular-nums;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:0; line-height:1.2;
}
.lead-terr {
  display:inline-block; margin-top:.15rem; padding:.05rem .3rem;
  font-size:.62rem; font-weight:650; color:#0f766e; background:#f0fdfa;
  border-radius:4px; max-width:100%;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.lead-source-badge {
  display:inline-block; padding:.08rem .35rem; border-radius:999px;
  font-size:.68rem; font-weight:600; background:#f1f5f9; color:#334155;
  border:1px solid #e2e8f0;
  max-width:100%; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.lead-gclid {
  display:inline-block; margin-top:.12rem; margin-left:0;
  font-size:.6rem !important; padding:.04rem .3rem !important;
  font-weight:600 !important; border-radius:999px !important;
  background:#f8fafc !important; color:#475569 !important;
  border:1px solid #e2e8f0;
}
.lt-status .badge,
.crm-contacts-table .crm-status-badge {
  max-width:100%; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  font-size:.68rem; padding:.08rem .4rem; border-radius:999px; font-weight:600;
  text-transform:none; letter-spacing:0;
}
.lead-msg {
  display:block; max-width:100%; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  font-size:.78rem; line-height:1.3; color:var(--ink);
}
.lead-url {
  display:block; max-width:100%; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  font-size:.72rem; line-height:1.3; color:#1d4ed8; text-decoration:none;
}
.lead-url:hover { text-decoration:underline; }
.lead-campaign {
  display:block; margin-top:.15rem; font-size:.68rem; color:var(--muted);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.lead-actions-wrap { position:relative; flex-shrink:0; }
.lead-menu-btn {
  width:1.85rem !important; height:1.85rem; margin:0 !important; padding:0 !important;
  font-size:1.05rem; line-height:1; border-radius:8px;
}
.lead-actions-menu {
  display:none; position:absolute; right:0; top:calc(100% + .2rem);
  min-width:10rem; background:#fff; border:1px solid var(--line);
  border-radius:10px; box-shadow:0 10px 28px rgba(15,23,42,.12);
  z-index:80; padding:.3rem; flex-direction:column;
}
.lead-actions-menu.open { display:flex; }
.lead-actions-menu button {
  width:100%; margin:0; text-align:left; background:transparent;
  border:none; color:var(--ink); font-size:.8rem; font-weight:600;
  padding:.4rem .55rem; border-radius:7px; cursor:pointer;
}
.lead-actions-menu button:hover { background:#f1f5f9; }

@media (max-width: 1180px) {
  .leads-table .lt-source { width:4.4rem; }
  .leads-table .lt-owner { width:6.5rem; }
  .leads-table .lt-actions { width:8.6rem; }
  .lead-owner-select { max-width:6.5rem; }
  .lead-disp-select { max-width:7.2rem; }
}
@media (max-width: 980px) {
  .leads-list-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; }
  .leads-table { min-width:700px; }
  .leads-table .lt-msg { max-width:none; }
}

.lead-kanban {
  display:grid; grid-auto-flow:column; grid-auto-columns:minmax(180px, 1fr);
  gap:.65rem; overflow-x:auto; padding-bottom:.5rem; min-height:280px;
}
.lead-kanban[hidden] { display:none !important; }
.lead-kanban-col {
  background:#f8fafc; border:1px solid var(--line); border-radius:12px; min-height:260px;
  display:flex; flex-direction:column; min-width:0;
}
.lead-kanban-col.drag-over { outline:2px dashed #0d9488; outline-offset:-2px; }
.lead-kanban-col header {
  padding:.55rem .7rem; font-size:.78rem; font-weight:700;
  display:flex; justify-content:space-between; border-bottom:1px solid var(--line);
  gap:.35rem;
}
.lead-kanban-col header span { color:var(--muted); font-weight:600; flex-shrink:0; }
.lead-kanban-body { padding:.55rem; display:flex; flex-direction:column; gap:.45rem; flex:1; min-width:0; }
.lead-kanban-card {
  background:#fff; border:1px solid var(--line); border-radius:10px; padding:.55rem .65rem;
  cursor:grab; font-size:.82rem; box-shadow:0 1px 2px rgba(0,0,0,.04);
  min-width:0; overflow:hidden;
}
.lead-kanban-card:active { cursor:grabbing; }
.lead-kanban-card strong {
  display:block; margin-bottom:.15rem;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.lead-kanban-card .muted {
  color:var(--muted); font-size:.75rem;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.lead-kanban-meta {
  color:var(--muted); font-size:.7rem; margin:.25rem 0;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.lead-kanban-empty { color:var(--muted); font-size:.75rem; padding:.5rem; text-align:center; }
.lead-modal-backdrop {
  position:fixed; inset:0; background:rgba(15,23,42,.45); z-index:1200;
  display:flex; align-items:center; justify-content:center; padding:1rem;
}
.lead-modal-backdrop[hidden] { display:none !important; }
.lead-modal {
  background:#fff; border-radius:14px; width:min(560px, 100%); max-height:90vh; overflow:auto;
  box-shadow:0 20px 50px rgba(0,0,0,.2);
}
.lead-modal-head {
  display:flex; justify-content:space-between; align-items:center;
  padding:1rem 1.1rem .5rem; border-bottom:1px solid var(--line);
}
.lead-modal-head h3 { margin:0; font-size:1.05rem; }
.lead-modal-close {
  border:0; background:transparent; font-size:1.4rem; cursor:pointer; line-height:1; width:auto; margin:0; padding:.2rem .4rem;
}
.lead-modal-body { padding:.85rem 1.1rem; }
.lead-modal-body textarea { width:100%; border:1px solid var(--line); border-radius:8px; padding:.5rem; font:inherit; }
.lead-modal-foot {
  display:flex; justify-content:flex-end; gap:.5rem; padding:.75rem 1.1rem 1rem; border-top:1px solid var(--line);
}
.lead-modal-foot button { width:auto; margin:0; }

/* Frappe-style CRM Contacts list + detail */
.crm-create-form {
  margin: 0 0 1rem;
  padding: .85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafbfc;
}
.crm-create-title, .crm-section-label {
  display: block;
  font-size: .85rem;
  margin: 0 0 .55rem;
  color: var(--ink);
}
.crm-create-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  align-items: end;
  gap: .5rem;
  margin-bottom: .35rem;
}
.crm-create-grid input, .crm-create-grid select, .crm-create-grid button { margin-bottom: 0; }
.crm-hint { color: var(--muted); font-size: .78rem; margin: .35rem 0 0; }
.crm-list-toolbar {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
  margin: 0 0 .75rem;
}
.crm-list-toolbar .crm-search {
  flex: 1 1 220px; margin: 0; max-width: 28rem; height: 36px;
  padding: 0 .75rem; font-size: .85rem;
}
.crm-list-toolbar select {
  width: auto; min-width: 11rem; margin: 0; height: 36px;
  padding: 0 1.5rem 0 .65rem; font-size: .85rem;
  appearance: none; -webkit-appearance: none;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M2.6 4.2a.75.75 0 0 1 1.06 0L6 6.54l2.34-2.34a.75.75 0 1 1 1.06 1.06L6.53 8.13a.75.75 0 0 1-1.06 0L2.6 5.26a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .45rem center;
  background-size: .7rem;
}
.crm-from-leads-toggle {
  display: flex; align-items: center; gap: .4rem;
  font-size: .82rem; white-space: nowrap; color: var(--ink); font-weight: 550;
}
.crm-from-leads-toggle input[type="checkbox"] {
  width: 1rem; height: 1rem; min-width: 1rem; max-width: 1rem;
  margin: 0; padding: 0; flex: 0 0 1rem; accent-color: var(--brand);
}
.crm-contacts-table {
  width: 100%; border-collapse: collapse; font-size: .84rem;
}
.crm-contacts-table th, .crm-contacts-table td {
  padding: .38rem .55rem; vertical-align: middle; border-bottom: 1px solid #eee;
}
.crm-contacts-table th {
  background: #f9fafb; font-size: .72rem; font-weight: 650; color: #4b5563;
  white-space: nowrap;
}
.crm-contacts-table td { font-size: .84rem; }
.crm-contacts-table .crm-name-cell { font-weight: 600; max-width: 14rem; }
.crm-contacts-table .crm-name-link { font-size: .84rem; }
.crm-contacts-table .crm-muted { color: var(--muted); font-size: .78rem; }
.crm-contacts-table .crm-phone-cell {
  font-variant-numeric: tabular-nums; color: #4b5563; white-space: nowrap;
}
.crm-contacts-table .actions {
  white-space: nowrap; gap: .35rem;
}
.crm-contacts-table .actions button {
  height: 30px; padding: 0 .65rem; font-size: .75rem; border-radius: 8px;
  font-weight: 600;
}
.crm-contacts-table .actions button.ghost {
  background: #fff; color: var(--ink); border: 1px solid var(--line);
}
.crm-contacts-table .actions button.ghost:hover { background: #f9fafb; }
.crm-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 1rem;
  margin: 0 0 1rem;
}
@media (max-width: 900px) {
  .crm-detail-layout { grid-template-columns: 1fr; }
}
.crm-profile-panel, .crm-deals-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .85rem 1rem;
  background: #fff;
}
.crm-profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .55rem .75rem;
}
.crm-profile-grid .field { margin: 0; display: flex; flex-direction: column; gap: .25rem; }
.crm-profile-grid .field-label { display: block; font-size: .72rem; color: var(--muted); font-weight: 600; }
.crm-profile-grid .field input,
.crm-profile-grid .field select { margin: 0; }
.crm-profile-grid .crm-span-2,
.crm-span-2 { grid-column: 1 / -1; }
.crm-profile-grid input[readonly] { background: #f3f4f6; color: #4b5563; }
.crm-contact-deals-table { margin: 0; font-size: .84rem; }
.crm-contact-deals-table td, .crm-contact-deals-table th { padding: .4rem .45rem; }
.crm-deal-stage {
  display: inline-block; padding: .12rem .45rem; border-radius: 999px;
  font-size: .72rem; font-weight: 700; background: #f1f5f9; color: #334155;
  text-transform: capitalize;
}
.crm-deal-stage.stage-qualified { background: #ecfdf5; color: #047857; }
.crm-deal-stage.stage-proposal { background: #eff6ff; color: #1d4ed8; }
.crm-deal-stage.stage-won { background: #d1fae5; color: #065f46; }
.crm-deal-stage.stage-lost { background: #fef2f2; color: #b91c1c; }
.crm-deal-stage.stage-new { background: #f8fafc; color: #475569; }

/* Global `input { width:100% }` would stretch checkboxes and crush name/phone text. */
#bcCrmContacts label {
  display:flex; gap:.5rem; align-items:flex-start; padding:.35rem 0;
  border-bottom:1px solid #eee; cursor:pointer; min-width:0;
}
#bcCrmContacts .bc-crm-check {
  width:auto; min-width:1.05rem; margin:.2rem 0 0; flex-shrink:0;
  padding:0; accent-color: var(--brand);
}
#bcCrmContacts .bc-crm-meta {
  min-width:0; flex:1; line-height:1.35; word-break:break-word;
}
#bcCrmContacts .bc-crm-meta strong { display:inline; font-size:.9rem; }
#bcCrmContacts .bc-crm-phone { color:var(--muted); }
#bcCrmContacts .bc-crm-tags { color:#889; font-size:.75rem; }
#bcCrmContacts .bc-crm-group {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  padding: .35rem 0;
  border-bottom: 1px solid #eee;
}
#bcCrmContacts .bc-crm-group-name { font-size: .9rem; line-height: 1.35; }
#bcCrmContacts .bc-crm-group-phones {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  padding-left: .15rem;
}
#bcCrmContacts .bc-crm-phone-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0;
  padding: .2rem 0;
  border-bottom: none;
}
.bc-lists-panel {
  margin:.75rem 0; padding:.85rem; border:1px solid var(--line); border-radius:10px; background:#fafbfc;
}
.bc-lists-panel select { width:100%; }
.bc-step { margin: 0 0 1rem; }
.bc-step-label {
  font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: #6b7280; margin: 0 0 .45rem;
}
.bc-use-list-opt {
  display:flex; align-items:center; gap:.45rem; margin:.55rem 0 .75rem;
  font-size:.82rem; color:#445; cursor:pointer;
}
.bc-use-list-opt input { width:auto; margin:0; flex-shrink:0; }

/* Team Inbox All Broadcasts dashboard */
.bc-dash-card { overflow: visible; }
.bc-dash-hero {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.bc-dash-hero h3 { margin: 0 0 .3rem; font-size: 1.15rem; letter-spacing: -.02em; }
.bc-dash-hero p { margin: 0; color: var(--muted); font-size: .85rem; max-width: 36rem; line-height: 1.45; }
.bc-toggle-create { width: auto; margin: 0; padding: .45rem .85rem; font-weight: 650; }

.bc-kpi-row {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: .65rem;
  margin: 0 0 1rem;
}
@media (min-width: 720px) {
  .bc-kpi-row { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1100px) {
  .bc-kpi-row { grid-template-columns: repeat(6, 1fr); }
}
.bc-kpi {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: .85rem .95rem; box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  position: relative; min-height: 4.5rem;
}
.bc-kpi .label {
  display: block; color: var(--muted); font-size: .72rem; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
}
.bc-kpi .value {
  display: block; margin-top: .35rem; font-size: 1.65rem; font-weight: 800;
  letter-spacing: -.03em; line-height: 1.1;
}
.bc-kpi .value.toned { color: #111827; }
.bc-kpi .value.sent { color: #059669; }
.bc-kpi .value.delivered { color: #c2410c; }
.bc-kpi .value.read { color: #2563eb; }
.bc-kpi .value.failed { color: #dc2626; }
.bc-kpi-note {
  position: absolute; right: .75rem; bottom: .55rem;
  font-size: .65rem; color: var(--muted); font-weight: 650;
}

.bc-table-toolbar {
  display: flex; flex-wrap: wrap; gap: .55rem; align-items: center;
  margin: 0 0 .85rem;
}
.bc-search-wrap {
  position: relative; flex: 1 1 180px; min-width: 160px; max-width: 280px;
}
.bc-search-wrap input {
  width: 100%; margin: 0; padding-left: 2rem; font-size: .85rem;
}
.bc-search-icon {
  position: absolute; left: .65rem; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: .95rem; pointer-events: none;
}
.bc-date-range {
  display: flex; flex-wrap: wrap; gap: .4rem; align-items: center;
}
.bc-date-range label {
  display: flex; align-items: center; gap: .3rem;
  font-size: .75rem; color: var(--muted); font-weight: 600;
}
.bc-date-range input,
.bc-table-toolbar select {
  width: auto; margin: 0; font-size: .82rem; padding: .4rem .55rem;
}

.bc-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.bc-dash-table { width: 100%; border-collapse: collapse; margin: 0; font-size: .86rem; }
.bc-dash-table thead th {
  text-align: left; padding: .7rem .85rem; background: #f8fafc;
  color: var(--muted); font-size: .7rem; font-weight: 750;
  letter-spacing: .04em; text-transform: uppercase; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.bc-dash-table tbody td {
  padding: .85rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle;
}
.bc-dash-table tbody tr:last-child td { border-bottom: none; }
.bc-dash-table tbody tr:hover { background: #fafbfc; }
.bc-empty { text-align: center; color: var(--muted); padding: 1.5rem !important; }

.bc-name-cell { display: flex; flex-direction: column; gap: .15rem; min-width: 10rem; }
.bc-name-cell strong { font-size: .9rem; color: var(--ink); }
.bc-name-meta { font-size: .78rem; color: #374151; font-weight: 600; }
.bc-name-creator { font-size: .75rem; color: var(--muted); }

.bc-creator-cell { display: flex; align-items: center; }
.bc-avatar {
  width: 1.85rem; height: 1.85rem; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #e0e7ff; color: #3730a3; font-size: .75rem; font-weight: 750;
}

.bc-ring-cell { display: inline-flex; align-items: center; gap: .4rem; }
.bc-ring { width: 2.35rem; height: 2.35rem; transform: rotate(-90deg); }
.bc-ring-track { fill: none; stroke: #e5e7eb; stroke-width: 3.5; }
.bc-ring-value {
  fill: none; stroke-width: 3.5; stroke-linecap: round;
  transition: stroke-dashoffset .35s ease;
}
.bc-ring.read .bc-ring-value { stroke: #2563eb; }
.bc-ring.failed .bc-ring-value { stroke: #dc2626; }
.bc-ring text {
  transform: rotate(90deg); transform-origin: 20px 20px;
  fill: #111827; font-size: 9px; font-weight: 750; font-family: inherit;
}
.bc-ring-pct { font-size: .78rem; color: var(--muted); font-weight: 650; min-width: 2.2rem; }

.bc-status-badge {
  display: inline-flex; align-items: center; padding: .22rem .55rem;
  border-radius: 999px; font-size: .68rem; font-weight: 750; letter-spacing: .03em;
}
.bc-status-badge.ok { background: #ecfdf5; color: #047857; }
.bc-status-badge.warn { background: #fff7ed; color: #c2410c; }
.bc-status-badge.bad { background: #fef2f2; color: #b91c1c; }
.bc-status-badge.muted { background: #f1f5f9; color: #475569; }

.bc-actions-td { width: 2.5rem; text-align: right; }
.bc-actions { position: relative; display: inline-block; }
.bc-menu-btn {
  width: 2rem !important; height: 2rem; margin: 0; padding: 0 !important;
  font-size: 1.15rem; line-height: 1; border-radius: 8px;
}
.bc-actions-menu {
  display: none; position: absolute; right: 0; top: calc(100% + .25rem);
  min-width: 9.5rem; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 10px 28px rgba(15, 23, 42, .12);
  z-index: 20; padding: .3rem; flex-direction: column;
}
.bc-actions-menu.open { display: flex; }
.bc-actions-menu button {
  width: 100%; margin: 0; text-align: left; background: transparent;
  border: none; color: var(--ink); font-size: .82rem; font-weight: 600;
  padding: .45rem .6rem; border-radius: 7px; cursor: pointer;
}
.bc-actions-menu button:hover { background: #f1f5f9; }
.bc-actions-menu button.danger { color: #9a3412; }

@media (max-width: 720px) {
  .bc-dash-table thead th:nth-child(2),
  .bc-dash-table tbody td:nth-child(2) { display: none; }
}
.canned-step {
  border:1px solid var(--line); border-radius:10px; padding:.75rem; margin-bottom:.55rem; background:#fafbfc;
}
.canned-step-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:.45rem; font-size:.85rem; font-weight:700; }
.lead-filter-row {
  display:flex; flex-wrap:wrap; gap:.4rem; margin-bottom:.75rem; align-items:center;
}
.lead-filter-row .bc-chip {
  height: 32px; min-height: 32px; padding: 0 .75rem;
  display: inline-flex; align-items: center; justify-content: center;
  box-sizing: border-box; line-height: 1;
}


/* Users, Teams & Roles hub */
.utr-hub { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1.25rem 1.35rem 1.5rem; box-shadow: var(--shadow); }
.utr-hub-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.utr-hub-head h2 { margin: 0; font-size: 1.35rem; font-weight: 700; color: #111827; }
.utr-hub-head p { margin: .35rem 0 0; color: var(--muted); font-size: .88rem; }
.utr-tabs { display: flex; gap: 1.25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.utr-tab { appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; margin: 0 0 -1px; padding: .55rem 0; font-size: .95rem; font-weight: 600; color: #6b7280; cursor: pointer; display: inline-flex; align-items: center; gap: .45rem; }
.utr-tab.active { color: #2563eb; border-bottom-color: #2563eb; }
.utr-count { display: inline-flex; align-items: center; justify-content: center; min-width: 1.4rem; height: 1.25rem; padding: 0 .4rem; border-radius: 999px; font-size: .72rem; font-weight: 700; background: #e5e7eb; color: #374151; }
.utr-tab.active .utr-count { background: #dcfce7; color: #15803d; }
.utr-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.utr-subtabs { display: flex; gap: .75rem; align-items: center; }
.utr-subtab { appearance: none; background: none; border: 0; padding: .35rem .15rem; font-size: .88rem; font-weight: 600; color: #6b7280; cursor: pointer; border-bottom: 2px solid transparent; }
.utr-subtab.active { color: #2563eb; border-bottom-color: #2563eb; }
.utr-subtab .utr-count { background: #dbeafe; color: #1d4ed8; }
.utr-toolbar-actions { display: flex; align-items: center; gap: .55rem; }
.utr-search { width: min(240px, 100%); margin: 0; padding: .5rem .75rem; border: 1px solid var(--line); border-radius: 8px; font-size: .88rem; }
.utr-name-cell { display: flex; align-items: center; gap: .7rem; }
.utr-avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; font-weight: 800; color: #7c2d12; background: #f5d0a9; flex-shrink: 0; }
.utr-avatar.lg { width: 42px; height: 42px; font-size: .8rem; }
.utr-name { font-weight: 650; color: #111827; }
.utr-muted { color: var(--muted); font-size: .8rem; }
.utr-status { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .65rem; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.utr-status.active { background: #dcfce7; color: #15803d; }
.utr-status.disabled { background: #fee2e2; color: #b91c1c; }
.utr-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.utr-menu-wrap { position: relative; display: inline-block; }
.utr-menu-btn { width: 34px; height: 34px; padding: 0; margin: 0; border-radius: 8px; background: transparent; color: #6b7280; border: 1px solid transparent; }
.utr-menu-btn:hover { background: #f3f4f6; border-color: var(--line); }
.utr-menu { position: absolute; right: 0; top: calc(100% + 4px); min-width: 160px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(15,23,42,.12); display: none; z-index: 40; padding: .35rem; }
.utr-menu.open { display: block; }
.utr-menu button { width: 100%; text-align: left; background: transparent; color: #111827; border: 0; margin: 0; padding: .55rem .7rem; border-radius: 8px; font-size: .88rem; }
.utr-menu button:hover { background: #f3f4f6; }
.utr-menu button.danger { color: #b91c1c; }
.utr-pane { display: none; }
.utr-pane.active { display: block; }
.utr-modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 200; display: none; align-items: center; justify-content: center; padding: 1rem; }
.utr-modal-backdrop.open { display: flex; }
.utr-modal { width: min(520px, 100%); background: #fff; border-radius: 12px; box-shadow: 0 20px 50px rgba(15,23,42,.2); max-height: min(92vh, 820px); overflow: auto; }
.utr-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.25rem .35rem; }
.utr-modal-head h3 { margin: 0; font-size: 1.15rem; }
.utr-modal-close { width: 34px; height: 34px; margin: 0; padding: 0; border: 0; background: transparent; color: #6b7280; border-radius: 8px; font-size: 1.2rem; }
.utr-modal-body { padding: .5rem 1.25rem 1rem; display: flex; flex-direction: column; gap: .85rem; }
.utr-field label { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: .85rem; font-weight: 600; color: #374151; margin-bottom: .35rem; }
.utr-field label .req { color: #dc2626; }
.utr-field input, .utr-field select, .utr-field .utr-multiselect { width: 100%; margin: 0; }
.utr-name-row { display: grid; grid-template-columns: 1fr auto; gap: .75rem; align-items: end; }
.utr-hint { margin: .3rem 0 0; color: var(--muted); font-size: .78rem; }
.utr-modal-foot { display: flex; justify-content: flex-end; gap: .6rem; padding: 0 1.25rem 1.25rem; }
.utr-modal-foot button { width: auto; margin: 0; }
.utr-copy { appearance: none; border: 0; background: transparent; color: #2563eb; font-size: .78rem; font-weight: 650; cursor: pointer; padding: 0; }
.utr-multiselect { min-height: 96px; border: 1px solid var(--line); border-radius: 8px; padding: .45rem .55rem; background: #fff; }
.badge.superadmin { background: #ede9fe; color: #5b21b6; }
.rbac-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.rbac-group { border: 1px solid #e8e8e8; border-radius: 10px; padding: .75rem .85rem; background: #fff; }
.rbac-group h4 { margin: 0 0 .5rem; font-size: .88rem; color: #111827; }
.rbac-checks { display: grid; gap: .4rem; font-size: .88rem; }
.rbac-checks label { display: flex; gap: .45rem; align-items: flex-start; line-height: 1.35; }
/* Global `input { width:100% }` stretches checkboxes and shoves labels outside the card */
.rbac-checks input[type="checkbox"] { width: auto; margin: 0; padding: 0; flex-shrink: 0; }
.rbac-role-access { margin-top: .45rem; background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 8px; padding: .65rem .75rem; font-size: .82rem; color: #4b5563; line-height: 1.4; }

/* Per-staff access matrix (Users → Access) */
.sac-layout { display: grid; grid-template-columns: 300px 1fr; gap: 1.25rem; align-items: start; }
.sac-staff { border: 1px solid #e8e8e8; border-radius: 10px; background: #fff; padding: .75rem; display: flex; flex-direction: column; gap: .6rem; }
.sac-staff .utr-search { width: 100%; }
.sac-staff-list { display: flex; flex-direction: column; gap: .15rem; max-height: 560px; overflow: auto; }
.sac-row { display: flex; align-items: center; gap: .65rem; width: 100%; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 10px; padding: .5rem .55rem; margin: 0; cursor: pointer; }
.sac-row:hover { background: #f3f4f6; }
.sac-row.active { background: #eff6ff; border-color: #bfdbfe; }
.sac-row .utr-avatar { width: 32px; height: 32px; font-size: .66rem; }
.sac-row-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sac-row-meta .utr-name, .sac-row-meta .utr-muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sac-badge { display: inline-flex; align-items: center; padding: .15rem .5rem; border-radius: 999px; font-size: .68rem; font-weight: 700; background: #ede9fe; color: #5b21b6; flex-shrink: 0; }
.sac-editor { min-width: 0; }
.sac-empty { border: 1px dashed var(--line); border-radius: 10px; padding: 2.25rem; text-align: center; }
.sac-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.sac-note { background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 8px; padding: .55rem .75rem; font-size: .85rem; color: #4b5563; margin: 0 0 1rem; }
.sac-mode { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: 1.1rem; }
.sac-mode-btn { appearance: none; border: 1px solid #e5e7eb; border-radius: 10px; background: #fff; padding: .65rem .8rem; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: .15rem; }
.sac-mode-btn strong { font-size: .88rem; color: #111827; }
.sac-mode-btn span { font-size: .78rem; color: var(--muted); }
.sac-mode-btn.active { border-color: #2563eb; background: #eff6ff; }
.sac-mode-btn:disabled { opacity: .6; cursor: default; }
@media (max-width: 720px) {
  .utr-name-row { grid-template-columns: 1fr; }
  .utr-search { width: 100%; }
  .rbac-groups { grid-template-columns: 1fr; }
  .sac-layout { grid-template-columns: 1fr; }
  .sac-mode { grid-template-columns: 1fr; }
}

/* ── Team Inbox Channel Settings hub ── */
.ch-hub { display:flex; flex-direction:column; gap:1rem; }
.ch-banner {
  background:#eff6ff; border:1px solid #bfdbfe; color:#1e3a8a;
  border-radius:10px; padding:.75rem 1rem; font-size:.88rem; line-height:1.45;
}
.ch-summary {
  display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:.85rem;
}
@media (max-width: 960px) {
  .ch-summary { grid-template-columns:1fr; }
}
.ch-card {
  background:#fff; border:1px solid var(--line); border-radius:12px;
  padding:1rem 1.1rem; display:flex; flex-direction:column; gap:.55rem;
}
.ch-card h4 { margin:0; font-size:.95rem; }
.ch-card .ch-muted { color:#6b7280; font-size:.82rem; line-height:1.4; }
.ch-id-row { display:flex; align-items:center; gap:.45rem; flex-wrap:wrap; }
.ch-badge {
  display:inline-flex; align-items:center; padding:.15rem .5rem;
  border-radius:999px; font-size:.68rem; font-weight:700; letter-spacing:.02em;
}
.ch-badge.ok { background:#ecfdf5; color:#047857; }
.ch-badge.warn { background:#fff7ed; color:#c2410c; }
.ch-badge.muted { background:#f1f5f9; color:#475569; }
.ch-badge.lim { background:#ecfdf5; color:#047857; }
.ch-kv { display:flex; justify-content:space-between; gap:.5rem; font-size:.84rem; padding:.2rem 0; }
.ch-kv span { color:#6b7280; }
.ch-kv strong { font-weight:650; text-align:right; word-break:break-all; }
.ch-dot { width:.55rem; height:.55rem; border-radius:50%; display:inline-block; margin-right:.35rem; }
.ch-dot.ok { background:#10b981; }
.ch-dot.muted { background:#9ca3af; }
.ch-configure { position:relative; align-self:flex-start; }
.ch-configure .ch-dot-badge {
  position:absolute; top:-2px; right:-2px; width:8px; height:8px;
  background:#ef4444; border-radius:50%; border:2px solid #fff;
}
.ch-tabs {
  display:flex; flex-wrap:wrap; gap:.15rem; border-bottom:1px solid var(--line);
  padding:0 .15rem; margin-top:.25rem;
}
.ch-tab {
  background:transparent; border:none; color:#4b5563; font-weight:600;
  font-size:.88rem; padding:.7rem .85rem; cursor:pointer; border-bottom:2px solid transparent;
  margin-bottom:-1px; border-radius:0;
}
.ch-tab:hover { color:#111827; background:transparent; }
.ch-tab.active { color:#2563eb; border-bottom-color:#2563eb; }
.ch-pane { display:none; padding:.85rem 0 1.25rem; }
.ch-pane.active { display:block; }
.ch-profile-form {
  display:grid; gap:1rem; max-width:820px;
}
.ch-profile-row {
  display:grid; grid-template-columns:minmax(180px,280px) 1fr; gap:1rem; align-items:start;
}
@media (max-width: 720px) {
  .ch-profile-row { grid-template-columns:1fr; }
}
.ch-profile-row label { font-weight:700; font-size:.9rem; display:block; margin-bottom:.2rem; }
.ch-profile-row .help { color:#6b7280; font-size:.78rem; line-height:1.4; }
.ch-profile-row input, .ch-profile-row textarea, .ch-profile-row select {
  width:100%; margin:0;
}
.ch-websites { display:flex; flex-direction:column; gap:.45rem; }
.ch-rules-card, .ch-config-item {
  background:#fff; border:1px solid var(--line); border-radius:12px; padding:1rem;
  margin-bottom:.65rem;
}
.ch-rules-head { display:flex; gap:.75rem; align-items:flex-start; margin-bottom:.85rem; }
.ch-rules-icon {
  width:2.25rem; height:2.25rem; border-radius:8px; background:#ede9fe;
  display:grid; place-items:center; flex-shrink:0; font-size:.85rem; color:#5b21b6;
}
.ch-rules-head h4 { margin:0; }
.ch-rule-line { display:flex; flex-wrap:wrap; gap:.55rem; align-items:center; margin:.55rem 0; font-size:.88rem; }
.ch-config-item {
  display:grid; grid-template-columns:auto 1fr auto; gap:.75rem; align-items:center;
  cursor:pointer;
}
.ch-config-item .ch-cfg-icon {
  width:2.4rem; height:2.4rem; border-radius:10px; display:grid; place-items:center;
  font-size:.95rem; font-weight:700; color:#1e3a8a; background:#dbeafe;
}
.ch-config-item h4 { margin:0 0 .15rem; font-size:.92rem; display:flex; align-items:center; gap:.4rem; }
.ch-config-item p { margin:0; color:#6b7280; font-size:.8rem; }
.ch-new {
  background:#ecfdf5; color:#047857; font-size:.65rem; font-weight:750;
  padding:.1rem .4rem; border-radius:999px; text-transform:uppercase;
}
.ch-config-body {
  display:none; grid-column:1 / -1; padding:.65rem 0 0; border-top:1px solid #f1f5f9; margin-top:.35rem;
}
.ch-config-item.open .ch-config-body { display:block; }
.ch-empty-block {
  text-align:center; padding:2.5rem 1rem; color:#6b7280;
}
.ch-empty-block h3 { margin:.5rem 0 .35rem; color:var(--ink); }
.ch-users-head {
  display:flex; justify-content:space-between; align-items:center; gap:.75rem; margin-bottom:.75rem;
}
.ch-modal-backdrop {
  position:fixed; inset:0; background:rgba(15,23,42,.45); z-index:80;
  display:flex; align-items:center; justify-content:center; padding:1rem;
}
.ch-modal-backdrop[hidden] { display:none !important; }
.ch-modal {
  background:#fff; border-radius:14px; width:min(640px,100%); max-height:90vh;
  overflow:auto; box-shadow:0 20px 50px rgba(15,23,42,.25);
}
.ch-modal-head {
  display:flex; justify-content:space-between; align-items:center;
  padding:1rem 1.15rem; border-bottom:1px solid var(--line);
}
.ch-modal-head h3 { margin:0; font-size:1.05rem; }
.ch-modal-body { padding:1.1rem 1.15rem; }
.ch-modal-foot {
  display:flex; justify-content:flex-end; gap:.5rem;
  padding:.85rem 1.15rem; border-top:1px solid var(--line);
}
.ch-setting-row {
  display:grid; grid-template-columns:1fr auto; gap:.75rem; align-items:center;
  padding:.85rem 0; border-bottom:1px solid #f1f5f9;
}
.ch-setting-row:last-child { border-bottom:none; }
.ch-setting-row h4 { margin:0 0 .2rem; font-size:.92rem; }
.ch-setting-row p { margin:0; color:#6b7280; font-size:.8rem; line-height:1.4; }
.ch-setting-row a { font-size:.78rem; color:#2563eb; }
.ch-toggle {
  position:relative; width:44px; height:24px; border-radius:999px; border:none;
  background:#d1d5db; cursor:pointer; padding:0; flex-shrink:0;
}
button.ch-toggle.on { background:#2563eb; }
button.ch-toggle::after {
  content:''; position:absolute; top:3px; left:3px; width:18px; height:18px;
  border-radius:50%; background:#fff; transition:transform .15s ease;
}
button.ch-toggle.on::after { transform:translateX(20px); }
.ch-mm-layout {
  display:grid; grid-template-columns:1.1fr .9fr; gap:1rem;
}
@media (max-width: 640px) {
  .ch-mm-layout { grid-template-columns:1fr; }
}
.ch-mm-preview {
  background:#eff6ff; border-radius:12px; padding:1rem; font-size:.8rem; color:#334155;
}
.ch-stub-note {
  background:#fffbeb; border:1px solid #fde68a; color:#92400e;
  border-radius:8px; padding:.65rem .75rem; font-size:.82rem; line-height:1.4; margin-top:.5rem;
}

/* Inbox folders + composer toolbar — top-bar tabs (overrides any legacy rail styles) */
.cw-folder-nav {
  display:flex; flex-direction:row; gap:.2rem; padding:.35rem .65rem .55rem;
  border-bottom:1px solid var(--line); flex-shrink:0; overflow-x:auto;
}
.cw-folder {
  display:inline-flex; justify-content:center; align-items:center; gap:.3rem;
  background:transparent; border:none; border-radius:999px; padding:.3rem .55rem;
  font-size:.8rem; font-weight:600; color:#4b5563; cursor:pointer; text-align:center;
  width:auto; box-shadow:none; white-space:nowrap;
}
.cw-folder:hover { background:#f3f4f6; color:#111827; }
.cw-folder.active {
  background:var(--cw-folder-active-bg, #e8f4ff); color:#0f172a;
  box-shadow:inset 0 -2px 0 var(--cw-folder-accent, #1f93ff);
  border-radius:8px; font-weight:700;
}
.cw-folder em { font-style:normal; font-size:.68rem; color:#9ca3af; font-weight:700; }
.cw-folder.active em { color:var(--cw-folder-accent, #1f93ff); }
.cw-assign-banner {
  display:none; align-items:center; gap:.35rem; padding:0 0 .35rem;
  background:transparent; border:none;
  color:#94a3b8; font-size:.7rem; font-weight:500; flex-shrink:0;
}
.cw-assign-banner.show { display:flex; }
.cw-composer-tools {
  display:flex; flex-wrap:nowrap; align-items:center; gap:.3rem; margin:0;
  flex: 1 1 auto; min-width: 0;
}
.cw-tool {
  width:2rem; height:2rem; border-radius:8px; border:1px solid #e5e7eb;
  background:#fff; color:#4b5563; cursor:pointer; font-size:1rem;
  display:grid; place-items:center; padding:0; margin:0;
}
.cw-tool:hover { background:#f8fafc; border-color:#d1d5db; }
.cw-ai-assist {
  display: inline-flex !important; align-items: center; gap: .28rem;
  width: auto !important; margin: 0 0 0 .1rem !important;
  background: #f3e8ff; color:#6d28d9; border:1px solid #e9d5ff;
  border-radius:8px; padding:.32rem .7rem;
  font-size:.78rem; font-weight:700; cursor:pointer;
  white-space: nowrap; flex-shrink: 0;
}
.cw-ai-assist:disabled { opacity:.45; cursor:not-allowed; }
.cw-emoji-panel, .cw-botflow-panel {
  position:absolute; bottom:calc(100% + .35rem); left:0; z-index:30;
  background:#fff; border:1px solid var(--line); border-radius:12px;
  box-shadow:0 12px 30px rgba(15,23,42,.14); width:min(320px,92vw);
  max-height:260px; overflow:auto; padding:.55rem;
}
.cw-composer { position:relative; }
.cw-emoji-grid {
  display:grid; grid-template-columns:repeat(8,1fr); gap:.2rem;
}
.cw-emoji-grid button {
  background:transparent; border:none; font-size:1.15rem; padding:.25rem; cursor:pointer;
  border-radius:6px; margin:0;
}
.cw-emoji-grid button:hover { background:#f3f4f6; }
.cw-botflow-panel h4 { margin:.15rem .35rem .45rem; font-size:.78rem; color:#6b7280; letter-spacing:.04em; }
.cw-botflow-item {
  display:flex; gap:.55rem; align-items:flex-start; width:100%; text-align:left;
  background:transparent; border:none; padding:.45rem .5rem; border-radius:8px; cursor:pointer; margin:0;
}
.cw-botflow-item:hover { background:#f8fafc; }
.cw-botflow-item strong { display:block; font-size:.85rem; }
.cw-botflow-item span { font-size:.75rem; color:#6b7280; }
.cw-views-promo {
  margin:.5rem .65rem; padding:.75rem; border:1px dashed #cbd5e1; border-radius:10px;
  font-size:.8rem; color:#64748b; text-align:center;
}

/* Channel hub (Meta Business / WhatsApp Channel) */
.ch-hub-tabs {
  display: flex; flex-wrap: wrap; gap: .15rem .55rem;
  border-bottom: 1px solid var(--line); margin: .25rem 0 1rem; padding: 0 .1rem;
}
.ch-hub-tab {
  width: auto !important; margin: 0 !important; padding: .55rem .15rem .65rem !important;
  background: transparent !important; color: #6b7280; border: none; border-bottom: 2px solid transparent;
  border-radius: 0; font-size: .88rem; font-weight: 650;
}
.ch-hub-tab:hover { color: #111827; background: transparent !important; }
.ch-hub-tab.active {
  color: #1d4ed8; border-bottom-color: #2563eb; background: transparent !important;
}
.ch-hub-pane { display: none; }
.ch-hub-pane.active { display: block; }
.ch-profile-pic {
  display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem;
}
.ch-profile-pic img {
  width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line);
}
.ch-link-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .65rem;
}
.ch-link-card {
  width: 100%; margin: 0; text-align: left; padding: .85rem 1rem;
  background: #f8fafc; color: #111; border: 1px solid var(--line); border-radius: 10px;
}
.ch-link-card:hover { background: #f1f5f9; border-color: #d1d5db; }
.ch-link-card strong { display: block; font-size: .9rem; margin-bottom: .25rem; }
.ch-link-card span { display: block; font-size: .78rem; color: var(--muted); font-weight: 500; line-height: 1.35; }
.ch-empty-state {
  text-align: center; padding: 2.5rem 1rem 2rem; color: #374151;
}
.ch-empty-state h3 { margin: .5rem 0 .35rem; font-size: 1.05rem; }
.ch-empty-state p { margin: 0 auto; max-width: 28rem; color: var(--muted); font-size: .9rem; line-height: 1.45; }
.ch-empty-icon { font-size: 2.4rem; line-height: 1; opacity: .7; }
.ch-muted { color: var(--muted); font-size: .85rem; line-height: 1.45; }
.ch-user-av {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.65rem; height: 1.65rem; border-radius: 50%; background: #fde8d8; color: #9a3412;
  font-size: .68rem; font-weight: 750; margin-right: .35rem; vertical-align: middle;
}
.ch-config-list { display: flex; flex-direction: column; gap: .55rem; }
.ch-config-row {
  display: flex; flex-wrap: wrap; align-items: stretch; gap: .35rem;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .15rem .35rem .15rem .15rem;
}
.ch-config-body {
  display: none; width: 100%; padding: .35rem .75rem .85rem; border-top: 1px solid #f1f5f9;
}
.ch-config-row.open .ch-config-body { display: block; }
.ch-claim { width: auto !important; margin: 0; padding: .2rem .55rem; font-size: .75rem; align-self: flex-start; }
.ch-web-row { margin-bottom: .4rem; }
.ch-web-row input { width: 100%; margin: 0; }
.ch-config-main {
  flex: 1; width: auto !important; margin: 0 !important; text-align: left;
  background: transparent !important; color: #111; border: none; border-radius: 10px;
  padding: .7rem .75rem !important; display: flex; justify-content: space-between; align-items: center; gap: .75rem;
}
.ch-config-main:hover { background: #f8fafc !important; }
.ch-config-main strong { display: flex; align-items: center; gap: .4rem; font-size: .9rem; }
.ch-config-main span { display: block; font-size: .78rem; color: var(--muted); font-weight: 500; margin-top: .2rem; line-height: 1.35; }
.ch-chevron { color: #9ca3af; font-size: .85rem; flex-shrink: 0; }
.ch-badge {
  display: inline-block; font-size: .65rem; font-weight: 750; text-transform: uppercase;
  letter-spacing: .03em; color: #047857; background: #d1fae5; padding: .12rem .4rem; border-radius: 999px;
}
label.ch-toggle {
  display: inline-flex; align-items: center; align-self: center; cursor: pointer; margin-right: .35rem;
  width: auto; height: auto; background: transparent;
}
label.ch-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
label.ch-toggle span {
  width: 2.2rem; height: 1.2rem; border-radius: 999px; background: #d1d5db; position: relative;
  transition: background .15s ease;
}
label.ch-toggle span::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: .9rem; height: .9rem;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.15);
  transition: transform .15s ease;
}
label.ch-toggle input:checked + span { background: #2563eb; }
label.ch-toggle input:checked + span::after { transform: translateX(1rem); }
.ch-mmlite-card { border-left: 3px solid #2563eb; }
a.btn-link { text-decoration: none; }

/* Inbox composer polish */
.cw-assign-banner {
  background: transparent; color: #94a3b8; border: none;
  padding: 0 0 .35rem; font-size: .7rem; font-weight: 500; margin-bottom: 0;
}
.cw-composer-tools {
  display: flex; flex-wrap: nowrap; align-items: center; gap: .3rem; margin-top: 0;
}
.cw-composer-tools .cw-tool {
  width: 2rem !important; height: 2rem; margin: 0 !important; padding: 0 !important;
  font-size: .88rem; font-weight: 650; border-radius: 8px;
  background: #fff !important; color: #4b5563 !important; border: 1px solid #e5e7eb !important;
}
.cw-composer-tools .cw-tool:hover {
  background: #f8fafc !important; border-color: #d1d5db !important;
}
.cw-ai-assist {
  display: inline-flex !important; align-items: center; gap: .28rem;
  width: auto !important; margin: 0 0 0 .1rem !important;
  background: #f3e8ff !important; color: #6d28d9 !important; border:1px solid #e9d5ff !important;
  white-space: nowrap; flex-shrink: 0;
}
.cw-ai-assist:hover { background: #ede9fe !important; color: #5b21b6 !important; }
.cw-ai-assist:disabled { opacity: .65; cursor: wait; }
.cw-ai-suggest { border-color: #e9d5ff; }
.cw-ai-suggest strong { color: #6d28d9; }

@media (max-width: 720px) {
  .ch-hub-tabs { gap: .1rem .4rem; overflow-x: auto; flex-wrap: nowrap; }
  .ch-hub-tab { white-space: nowrap; font-size: .82rem; }
}

/* ── Team Inbox Broadcast wizard ── */
.bc-start[hidden], .bc-detail[hidden] { display: none !important; }
.bc-start {
  background:
    radial-gradient(900px 420px at 50% 20%, rgba(91, 92, 226, .16), transparent 62%),
    var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.4rem 1.5rem 2.2rem;
  text-align: center;
}
.bc-start h2 { margin: 0 0 .45rem; font-size: 1.55rem; letter-spacing: -.03em; }
.bc-start .bc-start-sub {
  margin: 0 auto 1.6rem; max-width: 36rem; color: var(--muted); font-size: .95rem; line-height: 1.5;
}
.bc-start-cards {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem;
  max-width: 58rem; margin: 0 auto 1.6rem; text-align: left;
}
.bc-start-card {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 1rem 1rem 1.1rem; min-height: 11.5rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.bc-start-card h3 { margin: 0 0 .45rem; font-size: .95rem; }
.bc-start-illus {
  height: 7.2rem; border-radius: 10px; margin-bottom: .7rem;
  background: #f8fafc; border: 1px dashed #e5e7eb;
  display: flex; align-items: center; justify-content: center;
  color: #94a3b8; font-size: .78rem; font-weight: 650;
}
.bc-start-illus .bubble {
  background: #dcfce7; color: #14532d; border-radius: 10px 10px 10px 4px;
  padding: .45rem .6rem; font-size: .68rem; line-height: 1.3; max-width: 85%;
  text-align: left;
}
.bc-start-illus .pills { display: flex; flex-wrap: wrap; gap: .25rem; padding: .4rem; }
.bc-start-illus .pill {
  background: #e0e7ff; color: #3730a3; border-radius: 999px;
  padding: .12rem .45rem; font-size: .62rem; font-weight: 700;
}
.bc-start-illus .mini-table {
  display: grid; grid-template-columns: 1fr auto; gap: .28rem .7rem;
  width: 88%; font-size: .68rem; color: #334155; text-align: left;
}
.bc-start-illus .mini-table span:nth-child(odd) { font-weight: 700; }
.bc-start-illus .mini-table span:nth-child(even) { color: #64748b; }
.bc-start-cta { width: auto; margin: 0 auto .7rem; padding: .7rem 1.25rem; }
.bc-start-more {
  display: inline-flex; align-items: center; gap: .3rem;
  color: var(--brand); font-weight: 650; font-size: .85rem; text-decoration: none;
}
.bc-start-more:hover { text-decoration: underline; }

.bc-wiz {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.1rem 1.2rem 1.2rem;
}
.bc-stepper {
  display: flex; justify-content: center; align-items: center; gap: .35rem;
  margin: .15rem 0 1.1rem; flex-wrap: wrap;
}
.bc-stepper-item {
  display: inline-flex; align-items: center; gap: .45rem;
  color: var(--muted); font-size: .82rem; font-weight: 650;
  background: transparent; border: 0; padding: .2rem .4rem; margin: 0;
  width: auto; cursor: pointer; box-shadow: none; line-height: 1.2;
}
.bc-stepper-item:hover { background: transparent; color: var(--ink); }
.bc-stepper-item .num {
  width: 1.7rem; height: 1.7rem; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--line); font-size: .78rem; background: #fff;
}
.bc-stepper-item.active { color: var(--brand); }
.bc-stepper-item.active .num {
  border-color: var(--brand); background: #eef0ff; color: var(--brand);
}
.bc-stepper-item.done { color: var(--ink); }
.bc-stepper-item.done .num {
  border-color: var(--brand); background: var(--brand); color: #fff;
}
.bc-stepper-line {
  width: 2.4rem; height: 2px; background: var(--line); margin: 0 .15rem;
}
.bc-wiz-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap; margin-bottom: .9rem;
}
.bc-wiz-head h3 {
  margin: 0; display: flex; align-items: center; gap: .45rem; font-size: 1.15rem;
}
.bc-wiz-head .ghost { width: auto; margin: 0; padding: .4rem .65rem; }
.bc-wiz-tools {
  display: flex; align-items: center; gap: .45rem; flex-wrap: wrap;
}
.bc-wiz-tools input, .bc-wiz-tools select {
  width: auto; margin: 0; min-width: 10rem; font-size: .85rem; padding: .45rem .7rem;
}
.bc-wiz-pane { display: none; }
.bc-wiz-pane.active { display: block; }

.bc-tpl-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: .85rem;
}
.bc-tpl-card {
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff;
  padding: .85rem; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: .5rem; min-height: 12rem;
  position: relative;
}
.bc-tpl-card:hover { border-color: #c7c8ff; }
.bc-tpl-card.selected {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(91, 92, 226, .15);
}
.bc-tpl-card .check {
  position: absolute; top: .55rem; right: .55rem;
  width: 1.35rem; height: 1.35rem; border-radius: 999px;
  background: var(--brand); color: #fff; display: none;
  align-items: center; justify-content: center; font-size: .75rem; font-weight: 800;
}
.bc-tpl-card.selected .check { display: inline-flex; }
.bc-tpl-name { font-weight: 750; font-size: .88rem; padding-right: 1.6rem; word-break: break-word; }
.bc-tpl-badges { display: flex; flex-wrap: wrap; gap: .3rem; }
.bc-tpl-badge {
  font-size: .62rem; font-weight: 750; letter-spacing: .03em; text-transform: uppercase;
  padding: .12rem .4rem; border-radius: 999px; background: #f1f5f9; color: #475569;
}
.bc-tpl-badge.ok { background: #ecfdf5; color: #047857; }
.bc-tpl-badge.mkt { background: #e0e7ff; color: #3730a3; }
.bc-tpl-badge.flow { background: #fef3c7; color: #92400e; }
.bc-tpl-media, .bc-phone-preview .bc-tpl-media {
  background: linear-gradient(135deg, #c7d2fe, #e0e7ff);
  color: #3730a3; font-size: .62rem; font-weight: 800; letter-spacing: .06em;
  border-radius: 8px; padding: .55rem; text-align: center; margin-bottom: .45rem;
}
.bc-tpl-preview {
  background: #efeae2; border-radius: 10px; padding: .65rem .7rem; flex: 1;
}
.bc-tpl-preview .bubble {
  background: #dcf8c6; border-radius: 8px 8px 8px 2px; padding: .5rem .6rem;
  font-size: .75rem; line-height: 1.35; color: #1f2937; white-space: pre-wrap;
}
.bc-tpl-foot { display: flex; justify-content: space-between; color: var(--muted); font-size: .72rem; }
.bc-tpl-empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }

.bc-or {
  display: flex; align-items: center; gap: .75rem; margin: 1rem 0;
  color: var(--muted); font-size: .75rem; font-weight: 800; letter-spacing: .08em;
}
.bc-or::before, .bc-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.bc-upload-box, .bc-seg-box {
  border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.05rem; background: #fafbfc;
}
.bc-upload-row {
  display: flex; align-items: center; gap: .85rem; flex-wrap: wrap;
}
.bc-upload-ico {
  width: 2.4rem; height: 2.4rem; border-radius: 8px; background: #d1fae5;
  color: #047857; display: grid; place-items: center; font-weight: 800; flex-shrink: 0;
}
.bc-upload-row p { margin: 0; color: var(--muted); font-size: .82rem; flex: 1; min-width: 12rem; }
.bc-seg-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  flex-wrap: wrap; margin-bottom: .7rem;
}
.bc-seg-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.bc-seg-table { width: 100%; border-collapse: collapse; font-size: .84rem; margin: 0; }
.bc-seg-table th {
  text-align: left; padding: .55rem .7rem; background: #f8fafc; color: var(--muted);
  font-size: .68rem; letter-spacing: .04em; text-transform: uppercase; border-bottom: 1px solid var(--line);
}
.bc-seg-table td { padding: .65rem .7rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.bc-seg-table tr.selected { background: #eef0ff; }
.bc-seg-table input[type="checkbox"] { width: auto; margin: 0; }
.bc-filter-tag {
  display: inline-flex; background: #ede9fe; color: #5b21b6;
  border-radius: 999px; padding: .12rem .5rem; font-size: .72rem; font-weight: 650;
}
.bc-wiz-foot {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  flex-wrap: wrap; margin-top: 1rem; padding-top: .85rem; border-top: 1px solid var(--line);
}
.bc-wiz-foot .hint { color: var(--muted); font-size: .78rem; max-width: 28rem; }
.bc-wiz-foot-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.bc-wiz-foot-actions button { width: auto; margin: 0; }
.bc-wiz-foot-actions button:disabled { opacity: .45; cursor: not-allowed; }
.bc-count-pill { font-weight: 700; font-size: .82rem; color: var(--ink); }

.bc-sched-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.1rem; align-items: start;
}
.bc-limit-banner {
  background: #eef0ff; border: 1px solid #c7c8ff; color: #312e81;
  border-radius: 10px; padding: .7rem .9rem; font-size: .84rem; line-height: 1.45; margin-bottom: 1rem;
}
.bc-form-section { margin-bottom: 1.1rem; }
.bc-form-section h4 { margin: 0 0 .55rem; font-size: .92rem; }
.bc-retry-row { display: flex; align-items: center; gap: .65rem; margin-bottom: .55rem; }
.bc-retry-row label { margin: 0; font-size: .85rem; font-weight: 650; }
.bc-radio { display: flex; gap: .85rem; flex-wrap: wrap; margin: .35rem 0 .55rem; }
.bc-radio label { display: flex; align-items: center; gap: .35rem; font-size: .84rem; cursor: pointer; }
.bc-radio input { width: auto; margin: 0; }
.bc-radio-disabled { opacity: .55; cursor: not-allowed; }
.bc-wiz label.ch-toggle input:checked + span { background: var(--brand); }
.bc-rec-badge { background: #e0e7ff; color: #3730a3; font-size: .62rem; font-weight: 800; padding: .1rem .4rem; border-radius: 999px; }
.bc-audience-sum {
  display: flex; align-items: center; gap: .55rem; font-size: .9rem;
  padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 10px; background: #fafbfc;
}
.bc-preview-panel {
  border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: .9rem;
  position: sticky; top: 5rem;
}
.bc-preview-panel h4 { margin: 0 0 .55rem; font-size: .88rem; }
.bc-preview-meta { font-size: .75rem; color: var(--muted); margin-bottom: .35rem; display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.bc-preview-channel { font-size: .75rem; color: var(--muted); margin-bottom: .55rem; }
.bc-phone-preview {
  background: #efeae2; border-radius: 12px; padding: .85rem .75rem; min-height: 12rem;
}
.bc-phone-preview .bubble {
  background: #dcf8c6; border-radius: 8px 8px 8px 2px; padding: .7rem .75rem;
  font-size: .84rem; line-height: 1.4; color: #1f2937; white-space: pre-wrap;
}
.bc-phone-preview .hdr { font-weight: 800; margin-bottom: .25rem; }
.bc-phone-preview .ftr { margin-top: .4rem; color: #6b7280; font-size: .75rem; }
.bc-preview-btns { margin-top: .55rem; display: flex; flex-direction: column; gap: .28rem; }
.bc-preview-btns span {
  display: block; text-align: center; background: #fff; border-radius: 6px;
  padding: .35rem .4rem; font-size: .78rem; font-weight: 700; color: var(--brand);
}

.bc-detail { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.15rem 1.25rem; }
.bc-detail-hero { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .85rem; }
.bc-detail-hero h2 { margin: 0 0 .25rem; font-size: 1.25rem; }
.bc-detail-meta { color: var(--muted); font-size: .82rem; }
.bc-detail-tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; }
.bc-detail-actions { display: flex; gap: .45rem; flex-wrap: wrap; }
.bc-detail-actions button { width: auto; margin: 0; }
.bc-detail-kv {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .65rem; margin: 0 0 1rem; padding: .75rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.bc-detail-kv div span { display: block; color: var(--muted); font-size: .7rem; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.bc-detail-kv div strong { font-size: .88rem; }
.bc-detail-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .55rem; margin-bottom: 1rem; }
.bc-detail-stats .bc-kpi { min-height: 4.1rem; cursor: pointer; }
.bc-detail-stats .bc-kpi.active { outline: 2px solid var(--brand); }
.bc-recip-tabs { display: flex; gap: .55rem; margin-bottom: .65rem; flex-wrap: wrap; }
.bc-recip-tabs button {
  width: auto; margin: 0; background: transparent; color: var(--muted);
  border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: .35rem 0; font-weight: 650;
}
.bc-recip-tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.bc-recip-table { width: 100%; border-collapse: collapse; font-size: .84rem; margin: 0; }
.bc-recip-table th, .bc-recip-table td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid #f1f5f9; }
.bc-status-dot { display: inline-flex; align-items: center; gap: .35rem; font-weight: 650; font-size: .78rem; }

.bc-modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 220;
  display: none; align-items: center; justify-content: center; padding: 1rem;
}
.bc-modal-backdrop.open { display: flex; }
.bc-modal {
  width: min(480px, 100%); background: #fff; border-radius: 14px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .22); max-height: min(90vh, 640px); overflow: auto;
}
.bc-modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.15rem .4rem; }
.bc-modal-head h3 { margin: 0; }
.bc-modal-body { padding: .5rem 1.15rem 1rem; }
.bc-modal-info {
  background: #eef0ff; color: #312e81; border-radius: 10px; padding: .7rem .8rem;
  font-size: .8rem; line-height: 1.45; margin-bottom: .85rem;
}
.bc-test-row { display: flex; gap: .4rem; align-items: center; margin-bottom: .45rem; }
.bc-test-row select { width: 7.5rem; margin: 0; }
.bc-test-row input { margin: 0; }
.bc-test-row button { width: auto; margin: 0; padding: .45rem .55rem; }
.bc-modal-foot {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  padding: 0 1.15rem 1.15rem;
}
.bc-modal-foot button { width: auto; margin: 0; }
.bc-test-success { text-align: center; padding: 1.4rem 1rem 1.6rem; }
.bc-test-success .ok-mark {
  width: 3.2rem; height: 3.2rem; border-radius: 999px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 1.4rem; margin: 0 auto .75rem;
}

.bc-hidden-legacy { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

@media (max-width: 960px) {
  .bc-start-cards, .bc-sched-layout { grid-template-columns: 1fr; }
  .bc-preview-panel { position: static; }
}

/* Inbox composer / header extras */
.cw-header-tags { display:flex; flex-wrap:nowrap; gap:.25rem; align-items:center; max-width:18rem; overflow:hidden; }
.cw-header-tags .cw-label { display:inline-flex; align-items:center; flex-shrink:0; }
.cw-thread-actions { display:flex; align-items:center; gap:.22rem; flex-wrap:nowrap; }
.cw-thread-actions select { width:auto; margin:0; font-size:.76rem; padding:.26rem .38rem; }
.cw-icon-btn { width:auto !important; margin:0 !important; padding:.35rem .55rem !important; }
.cw-folder-new {
  float: none; border: none; background: transparent; color: #1f93ff;
  font-size: .75rem; font-weight: 750; cursor: pointer; padding: .35rem .55rem;
  border-radius: 8px; white-space: nowrap;
}
.cw-folder-new:hover { background: #e8f4ff; }
.cw-pop {
  position:absolute; bottom:calc(100% + .3rem); left:0; z-index:40;
  background:#fff; border:1px solid var(--line); border-radius:10px;
  box-shadow:0 10px 24px rgba(15,23,42,.12); padding:.35rem; min-width:8rem;
}
.cw-pop button {
  display:block; width:100%; margin:0; text-align:left; background:transparent;
  border:none; padding:.4rem .55rem; border-radius:6px; font-size:.8rem; cursor:pointer;
}
.cw-pop button:hover { background:#f3f4f6; }
.cw-empty-illust { text-align:center; padding:2.2rem 1rem; color:#64748b; }
.cw-empty-illust strong { display:block; color:#111827; margin:.35rem 0 .25rem; }
.cw-empty-illust p { margin:0 auto; max-width:16rem; font-size:.82rem; line-height:1.4; }
.cw-empty-art { font-size:1.8rem; opacity:.7; }
.cw-hover-actions {
  display:none; position:absolute; top:-.7rem; right:.35rem; gap:.15rem;
  background:#fff; border:1px solid var(--line); border-radius:8px; padding:.1rem;
  box-shadow:0 4px 12px rgba(15,23,42,.1);
}
.cw-bubble { position:relative; }
.cw-bubble-row:hover .cw-hover-actions { display:flex; }
.cw-hover-actions button {
  width:auto; margin:0; padding:.15rem .35rem; background:transparent; border:none; cursor:pointer;
}
.cw-bot-badge {
  display:inline-block; font-size:.62rem; font-weight:750; letter-spacing:.04em;
  text-transform:uppercase; background:#eef2ff; color:#3730a3;
  border-radius:999px; padding:.05rem .4rem; margin-right:.35rem;
}
.cw-sys-row { justify-content:center; }
.cw-sys {
  background:transparent !important; color:#6b7280; box-shadow:none;
  font-size:.75rem; text-align:center; width:100%;
}
.ch-web-row, .ch-websites .ch-web-row {
  display:flex; gap:.4rem; align-items:center; margin-bottom:.35rem;
}
.ch-web-row input { margin:0; }
.cw-tpl-panel { width:min(360px,94vw); }
.cw-tool-wrap { position:relative; display:inline-flex; }
.cw-header-tag-add {
  width:auto; margin:0; padding:.12rem .5rem; border-radius:999px;
  border: none; background:#f3f4f6; color:#6b7280;
  font-size:.72rem; font-weight:650; cursor:pointer; white-space:nowrap;
}
.cw-header-tag-add:hover { background:#e5e7eb; color:#374151; }
.cw-assign-banner.unassigned { background:transparent; color:#64748b; border:none; }

/* ── Analytics (Team Inbox) ── */
#analytics.panel.active {
  display: block;
  margin: -1.25rem -1.35rem -2rem;
  min-height: calc(100vh - 4.5rem);
}
.an-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 4.5rem);
  background: #f8fafc;
  border-top: 1px solid var(--line);
}
.an-nav {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: .85rem .55rem 1.25rem;
}
.an-nav-title {
  font-size: .95rem;
  font-weight: 750;
  padding: .35rem .65rem .75rem;
  color: var(--ink);
}
.an-nav-item {
  width: 100%;
  margin: 0 0 .2rem;
  display: flex;
  align-items: center;
  gap: .55rem;
  text-align: left;
  background: transparent;
  color: #374151;
  border: none;
  border-radius: 8px;
  padding: .55rem .7rem;
  font-size: .88rem;
  font-weight: 600;
  position: relative;
}
.an-nav-item:hover { background: #f3f4f6; }
.an-nav-item.active {
  background: #eff6ff;
  color: #1d4ed8;
}
.an-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #2563eb;
}
.an-nav-ico { display: inline-flex; color: inherit; flex-shrink: 0; }
.an-main { min-width: 0; padding: 1.1rem 1.25rem 1.75rem; background: #fff; }
.an-view { display: none; }
.an-view.active { display: block; }
.an-page-head { margin-bottom: .85rem; }
.an-page-head h2 { margin: 0; font-size: 1.2rem; letter-spacing: -.02em; }
.an-page-head-split {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap;
}
.an-head-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.an-head-actions select, .an-log-toolbar select, .an-filters select {
  width: auto; margin: 0; min-width: 160px; font-size: .85rem; padding: .45rem .7rem;
  background: #fff;
}
.an-tabs-row {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 1rem;
}
.an-tabs { display: flex; gap: 1.1rem; }
.an-tab {
  width: auto !important; margin: 0 !important; padding: .55rem .1rem .7rem !important;
  background: transparent !important; color: #6b7280; border: none;
  border-bottom: 2px solid transparent; border-radius: 0;
  font-size: .9rem; font-weight: 650;
}
.an-tab:hover { color: #111827; background: transparent !important; }
.an-tab.active { color: #1d4ed8; border-bottom-color: #2563eb; }
.an-filters { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.an-dates {
  display: inline-flex; align-items: center; gap: .35rem;
  border: 1px solid var(--line); border-radius: 10px; padding: .15rem .45rem;
  background: #fff; color: var(--muted); font-size: .8rem;
}
.an-dates input[type="date"] {
  width: auto; margin: 0; border: none; padding: .3rem .15rem; font-size: .8rem; background: transparent;
}
.an-exports-btn, .an-btn-export, .an-filter-btn {
  width: auto !important; margin: 0 !important;
  background: #fff !important; color: var(--ink) !important;
  border: 1px solid var(--line); font-weight: 650; font-size: .82rem;
  padding: .45rem .75rem !important;
}
.an-exports-btn:hover, .an-btn-export:hover, .an-filter-btn:hover { background: #f9fafb !important; }
.an-section-title { font-size: .95rem; margin: 0 0 .75rem; }
.an-kpi-row {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1.1rem;
}
.an-kpi {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem;
  box-shadow: var(--shadow); display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem;
}
.an-kpi .label {
  color: var(--muted); font-size: .68rem; font-weight: 750; letter-spacing: .04em; text-transform: uppercase;
}
.an-kpi .value { font-size: 1.55rem; font-weight: 800; color: var(--ink); letter-spacing: -.03em; margin-top: .2rem; }
.an-kpi-ico {
  width: 2rem; height: 2rem; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0;
  font-size: .95rem;
}
.an-kpi-ico.total { background: #f3f4f6; color: #111; }
.an-kpi-ico.open { background: #fff7ed; color: #c2410c; }
.an-kpi-ico.resolved { background: #ecfdf5; color: #047857; }
.an-kpi-ico.contacts { background: #fef2f2; color: #b91c1c; }
.an-kpi-ico.wa { background: #ecfdf5; color: #128c7e; }
.an-card {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem 1.15rem;
  box-shadow: var(--shadow);
}
.an-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.an-card-head h3 { margin: 0; font-size: .95rem; }
.an-card-hint {
  width: 1.15rem; height: 1.15rem; border-radius: 50%; border: 1px solid #d1d5db;
  display: grid; place-items: center; font-size: .7rem; color: var(--muted); font-style: italic;
}
.an-chart { width: 100%; min-height: 240px; }
.an-chart svg { width: 100%; height: 260px; display: block; }
.an-legend { display: flex; gap: 1.1rem; justify-content: center; margin-top: .35rem; font-size: .8rem; color: var(--muted); }
.an-legend i { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; margin-right: .35rem; }
.an-dash-pane, .an-report-pane { display: none; }
.an-dash-pane.active, .an-report-pane.active { display: block; }
.an-log-toolbar {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .85rem;
}
.an-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.an-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  background: #2563eb; color: #fff; border-radius: 999px; padding: .2rem .55rem;
  font-size: .78rem; font-weight: 650;
}
.an-chip button {
  width: auto; margin: 0; padding: 0; background: transparent; color: #fff; border: none;
  font-size: .9rem; line-height: 1;
}
.an-info-banner {
  margin-left: auto;
  background: #fefce8; color: #854d0e; border: 1px solid #fde68a;
  border-radius: 8px; padding: .4rem .7rem; font-size: .78rem; font-weight: 600;
  max-width: 28rem;
}
.an-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.an-table { width: 100%; border-collapse: collapse; margin: 0; font-size: .86rem; border: none; border-radius: 0; box-shadow: none; }
.an-table thead th {
  text-align: left; padding: .7rem .85rem; background: #f8fafc;
  color: var(--muted); font-size: .7rem; font-weight: 750;
  letter-spacing: .04em; text-transform: uppercase; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.an-table tbody td {
  padding: .8rem .85rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; color: #111827;
}
.an-table tbody tr:last-child td { border-bottom: none; }
.an-table tbody tr:hover { background: #fafbfc; }
.an-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; color: #2563eb; }
.an-copy {
  width: auto !important; margin: 0 0 0 .25rem !important; padding: 0 .2rem !important;
  background: transparent !important; color: var(--muted) !important; border: none; font-size: .85rem;
}
.an-empty { text-align: center; padding: 2.4rem 1rem 2rem; color: #374151; }
.an-empty h3 { margin: .45rem 0 .25rem; font-size: 1.05rem; }
.an-empty p { margin: 0 auto; color: var(--muted); font-size: .88rem; }
.an-empty-art {
  width: 88px; height: 72px; margin: 0 auto .35rem; color: #9ca3af;
}
.an-pager {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  flex-wrap: wrap; padding: .85rem 0 0; font-size: .82rem; color: var(--muted);
}
.an-pager select { width: auto; margin: 0; padding: .3rem .45rem; font-size: .8rem; }
.an-pager-right { display: flex; align-items: center; gap: .75rem; }
.an-link {
  width: auto !important; margin: 0 !important; padding: 0 !important;
  background: transparent !important; color: #2563eb !important; border: none; font-weight: 650;
}
.an-link:disabled { color: #9ca3af !important; cursor: default; }
.an-status {
  display: inline-block; background: #ecfdf5; color: #047857; font-size: .72rem; font-weight: 750;
  padding: .15rem .55rem; border-radius: 999px;
}
.an-status.expired { background: #f3f4f6; color: #6b7280; }
.an-status.failed { background: #fef2f2; color: #b91c1c; }
.an-progress {
  width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 2px solid #d1fae5;
  display: grid; place-items: center; font-size: .6rem; font-weight: 750; color: #047857;
}
.an-user {
  display: inline-flex; align-items: center; gap: .45rem;
}
.an-av {
  width: 1.7rem; height: 1.7rem; border-radius: 50%; background: #dbeafe; color: #1e40af;
  display: inline-grid; place-items: center; font-size: .68rem; font-weight: 750;
}
.an-muted { color: var(--muted); font-size: .8rem; margin: .5rem 0 0; line-height: 1.45; }
.an-stub {
  background: #f8fafc; border: 1px dashed #d1d5db; border-radius: 12px; padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.an-stub strong { display: block; margin-bottom: .25rem; }
.an-filter-panel {
  display: flex; flex-wrap: wrap; gap: .4rem; align-items: center;
}
.an-filter-panel input, .an-filter-panel select {
  width: auto; margin: 0; min-width: 140px; font-size: .85rem;
}
.an-check { width: 2.2rem; }
.an-check input { width: auto; margin: 0; }
.an-name { display: inline-flex; align-items: center; gap: .45rem; font-weight: 650; }
.an-phone { display: inline-flex; align-items: center; gap: .3rem; }
.an-row-menu {
  width: auto !important; margin: 0 !important; padding: .15rem .4rem !important;
  background: transparent !important; color: #6b7280 !important; border: none;
}
.an-icon-btn {
  width: auto !important; margin: 0 !important; padding: .25rem .4rem !important;
  background: transparent !important; color: #6b7280 !important; border: none;
}
@media (max-width: 1100px) {
  .an-shell { grid-template-columns: 1fr; }
  .an-nav { display: flex; flex-wrap: wrap; gap: .25rem; border-right: none; border-bottom: 1px solid var(--line); }
  .an-nav-title { width: 100%; }
  .an-nav-item { width: auto; }
  .an-kpi-row { grid-template-columns: 1fr 1fr; }
  .an-info-banner { margin-left: 0; }
}
@media (max-width: 700px) {
  .an-kpi-row { grid-template-columns: 1fr; }
}

/* ── Team Inbox chat chrome: patterned wallpaper, green outbound, composer card ── */
.cw-header-tag-add { padding: .12rem .5rem; font-size: .72rem; }
.cw-convo.office .cw-convo-extra { color: #1d4ed8; }
.cw-unread { margin-left: auto; flex-shrink: 0; }
.cw-thread {
  background-color: #e6eeea;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='168' height='168' viewBox='0 0 168 168'%3E%3Cg fill='none' stroke='%237d92a3' stroke-width='1.15' stroke-linecap='round' stroke-linejoin='round' opacity='0.32'%3E%3Cpath d='M20 24h32a8 8 0 018 8v16a8 8 0 01-8 8H36l-12 9v-9h-4a8 8 0 01-8-8V32a8 8 0 018-8z'/%3E%3Crect x='104' y='22' width='34' height='22' rx='3'/%3E%3Cpath d='M104 25l17 12 17-12'/%3E%3Crect x='24' y='96' width='20' height='34' rx='4'/%3E%3Cpath d='M31 124h6'/%3E%3Cpath d='M128 104a16 16 0 00-32 0v12h8v-10a8 8 0 0116 0v10h8z'/%3E%3Ccircle cx='86' cy='86' r='7.5'/%3E%3Cpath d='M86 74.5v3.5M86 94v3.5M74.5 86h3.5M94 86h3.5M78 78l2.5 2.5M91.5 91.5l2.5 2.5M78 94l2.5-2.5M91.5 80.5l2.5-2.5'/%3E%3Cpath d='M112 132l24-12-9 16z'/%3E%3Cpath d='M56 130l16-16 7 7-16 16h-7z'/%3E%3Cpath d='M68 118l5 5'/%3E%3Ccircle cx='148' cy='78' r='7'/%3E%3Crect x='141' y='86' width='14' height='10' rx='3'/%3E%3Cpath d='M70 18l2 10M66 22h10'/%3E%3Cpath d='M72 14c4 0 7 3 7 6 0 5-7 9-7 9s-7-4-7-9c0-3 3-6 7-6z'/%3E%3Cpath d='M150 128l14-6v18l-14-6-8 3v-12z'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 168px 168px;
}
.cw-thread-inner { background: transparent; }
.cw-messages, .cw-notes-view { background-color: transparent; background-image: none; }
.cw-day {
  background: rgba(255,255,255,.92); box-shadow: 0 1px 2px rgba(15,23,42,.06);
}
.cw-ctab {
  padding: .4rem .15rem .5rem !important;
  font-size: .82rem;
  background: transparent !important;
  color: #6b7280;
}
.cw-ctab.active {
  background: transparent !important;
  color: #111827;
  border-bottom-color: #2563eb;
}
.cw-composer-shell {
  position: relative;
  margin: .4rem .7rem .35rem;
}
.cw-composer {
  position: relative;
  margin: 0;
  padding: .05rem .7rem .45rem;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .06);
}
.cw-composer-row {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-top: .15rem;
  flex-wrap: nowrap;
}
.cw-tool-div {
  width: 1px;
  height: 1.15rem;
  background: #e5e7eb;
  margin: 0 .28rem;
  flex-shrink: 0;
}
.cw-composer-tools {
  margin-top: 0;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: nowrap;
}
.cw-assign-banner.show { display: flex; }
.cw-assign-banner { padding: 0; }
.cw-composer-send {
  display: flex; align-items: center; gap: .45rem; flex-shrink: 0; margin-left: auto;
}
.cw-composer-send #inboxSendBtn { width: auto !important; margin: 0 !important; }
.cw-composer-send #inboxSendBtn {
  padding: .48rem 1.15rem !important;
  background: #2563eb !important;
  color: #fff !important;
  border: none;
  border-radius: 8px;
  font-weight: 700;
}
.cw-composer-send #inboxSendBtn:hover { background: #1d4ed8 !important; }
.cw-format-bar {
  display: flex; align-items: center; gap: .02rem; margin-left: .45rem;
  padding-bottom: .12rem; flex: 0 1 auto; min-width: 0;
}
.cw-fmt {
  width: 1.7rem !important; height: 1.7rem; margin: 0 !important; padding: 0 !important;
  border: none; background: transparent; color: #9ca3af; border-radius: 6px;
  font-size: .78rem; font-weight: 750; cursor: pointer; line-height: 1;
  user-select: none; -webkit-user-select: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.cw-fmt b, .cw-fmt i, .cw-fmt s { color: inherit; font-size: inherit; }
.cw-fmt svg { display: block; }
.cw-fmt-i {
  display: block;
  font-family: "Liberation Serif", "DejaVu Serif", "Noto Serif", Georgia, "Times New Roman", Times, serif !important;
  font-style: italic !important;
  font-weight: 700 !important;
  font-size: 1.12rem !important;
  line-height: 1;
  font-synthesis: none;
}
.cw-fmt:hover { background: #f3f4f6; color: #374151; }
.cw-fmt.active { background: #e8f1ff !important; color: #2563eb !important; }
.cw-compose-wrap { position: relative; }
.cw-composer textarea,
.cw-composer .cw-compose-editor {
  min-height: 52px; max-height: 140px; border: none !important; background: transparent !important;
  padding: .35rem .1rem .45rem !important; border-radius: 0; box-shadow: none !important;
}
.cw-composer textarea:focus,
.cw-composer .cw-compose-editor:focus { outline: none; background: transparent !important; box-shadow: none !important; }
.cw-compose-editor {
  font-size: .9rem; line-height: 1.45; color: #111827;
  overflow-y: auto; white-space: pre-wrap; word-break: break-word;
  caret-color: #2563eb;
}
.cw-compose-editor b, .cw-compose-editor strong { font-weight: 700 !important; }
.cw-compose-editor i, .cw-compose-editor em { font-style: italic !important; }
.cw-compose-editor s, .cw-compose-editor strike, .cw-compose-editor del { text-decoration: line-through !important; }
.cw-compose-editor code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .84em;
  background: #f3f4f6; padding: .05rem .25rem; border-radius: 4px;
}
.cw-compose-editor blockquote {
  margin: .1rem 0; padding-left: .55rem; border-left: 3px solid #93c5fd; color: #374151;
}
.cw-compose-editor ul, .cw-compose-editor ol, .cw-compose-editor blockquote { white-space: normal; }
.cw-compose-editor ul, .cw-compose-editor ol { margin: .1rem 0 .1rem 1.15rem; padding: 0; }
.cw-compose-editor:empty:before { content: none; }
.cw-compose-ph {
  position: absolute; left: .1rem; top: .4rem; right: .25rem;
  color: #9ca3af; font-size: .9rem; pointer-events: none; line-height: 1.4;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cw-compose-ph.hidden { display: none; }
.cw-try-ai {
  pointer-events: auto; border: none; background: none; padding: 0; margin: 0;
  color: #7c3aed; font-weight: 700; font-size: inherit; cursor: pointer;
}
.cw-try-ai:hover { color: #6d28d9; text-decoration: underline; }
.cw-composer-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; padding: .42rem .2rem .2rem; min-height: 1.35rem;
}
.cw-compose-mdhint {
  position: static !important;
  inset: auto !important;
  margin-left: auto;
  color: #8b9aab; font-size: .7rem; pointer-events: none;
  line-height: 1.3; text-align: right;
}
.cw-ai-spark { width: 13px; height: 13px; flex-shrink: 0; display: block; }
.cw-canned-suggest {
  position: absolute; left: 0; right: 0; bottom: calc(100% + .25rem);
  z-index: 25; margin-top: 0; max-height: 220px;
}
.cw-attach-btn {
  border-radius: 50% !important; font-size: 1.15rem !important; font-weight: 600;
}
.cw-tool-wrap.open .cw-attach-btn { background: #e5e7eb !important; }
.cw-composer-tools .cw-tool.ghost {
  border-color: transparent !important; background: transparent !important;
}
.cw-composer-tools .cw-tool.ghost:hover,
.cw-composer-tools .cw-tool.active {
  background: #e8f1ff !important; color: #2563eb !important; border-radius: 50% !important;
}
.cw-attach-menu { min-width: 13.5rem; padding: .35rem !important; }
.cw-attach-menu button {
  display: flex !important; align-items: center; gap: .65rem;
  padding: .55rem .65rem !important; color: #4b5563;
}
.cw-attach-ico { width: 1.1rem; text-align: center; color: #6b7280; }
.cw-pay-pop {
  min-width: 13rem; padding: .55rem .65rem !important; display: flex; flex-direction: column; gap: .35rem;
}
.cw-pay-pop label { font-size: .72rem; font-weight: 700; color: #6b7280; }
.cw-pay-pop input { margin: 0; font-size: .82rem; padding: .35rem .45rem; }
.cw-pay-pop button {
  width: auto !important; margin: .2rem 0 0; padding: .4rem .65rem;
  background: #2563eb; color: #fff; border: none; border-radius: 8px;
}
.cw-botflow-panel {
  width: min(420px, 94vw); max-height: 360px; left: 50%; transform: translateX(-40%);
  padding: .85rem .9rem .7rem;
}
.cw-botflow-head {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .45rem;
}
.cw-botflow-head h4 { margin: 0; font-size: .95rem; color: #111827; letter-spacing: 0; }
.cw-botflow-learn {
  width: auto !important; margin: 0 !important; padding: 0 !important;
  background: none !important; border: none; color: #2563eb; font-size: .78rem; font-weight: 650; cursor: pointer;
}
.cw-botflow-search { width: 100%; margin: 0 0 .55rem; padding: .45rem .65rem .45rem 2rem; border-radius: 8px; }
.cw-botflow-search-wrap { position: relative; }
.cw-botflow-search-wrap::before {
  content: '⌕'; position: absolute; left: .55rem; top: .42rem; color: #9ca3af; font-size: .95rem;
}
.cw-botflow-sec { font-size: .68rem; font-weight: 750; color: #9ca3af; letter-spacing: .06em; margin: .15rem .2rem .35rem; }
.cw-botflow-item { align-items: center; }
.cw-botflow-item .cw-radio {
  width: .95rem; height: .95rem; border: 1.5px solid #d1d5db; border-radius: 50%; flex-shrink: 0;
}
.cw-botflow-item.selected .cw-radio { border-color: #2563eb; box-shadow: inset 0 0 0 3px #2563eb; }
.cw-botflow-foot { display: flex; justify-content: flex-end; padding-top: .45rem; }
.cw-botflow-trigger {
  width: auto !important; margin: 0 !important; padding: .4rem 1rem !important;
  background: #2563eb; color: #fff; border: none; border-radius: 8px; font-weight: 700;
}
.cw-botflow-trigger:disabled { background: #bfdbfe; color: #fff; cursor: not-allowed; }
.cw-bubble.out::after {
  content: ''; position: absolute; right: -5px; bottom: 7px;
  border: 6px solid transparent; border-left-color: #dcf8c6; border-bottom-color: #dcf8c6;
}
.cw-bubble blockquote { margin: .15rem 0; padding-left: .55rem; border-left: 3px solid #86efac; color: #374151; }
.cw-bubble b, .cw-bubble strong, .cw-media-caption b, .cw-media-caption strong { font-weight: 700; }
.cw-bubble i, .cw-bubble em, .cw-media-caption i, .cw-media-caption em { font-style: italic; }
.cw-bubble s, .cw-bubble strike, .cw-bubble del,
.cw-media-caption s, .cw-media-caption strike, .cw-media-caption del { text-decoration: line-through; }
.cw-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; background: rgba(15,23,42,.06); padding: .02rem .22rem; border-radius: 4px; }
@media (max-width: 900px) {
  .cw-composer-shell { margin: .3rem .45rem calc(.3rem + env(safe-area-inset-bottom, 0px)); }
  .cw-composer { margin: 0; padding: .2rem .55rem .45rem; }
  .cw-format-bar { margin-left: .15rem; }
  .cw-composer-head { flex-wrap: nowrap; }
  .cw-composer-row { flex-wrap: wrap; }
  .cw-botflow-panel { transform: none; left: 0; }
}

/* Collapsed contact rail: overlay icons on the thread instead of a reserved column */
@media (min-width: 901px) {
  .cw-inbox:not(.cw-details-open) .cw-details {
    grid-area: thread;
    justify-self: end;
    align-self: stretch;
    width: 36px;
    overflow: hidden;
    border-left: 1px solid rgba(226, 232, 240, 0.9);
    background: rgba(250, 251, 252, 0.82);
    pointer-events: none;
    z-index: 8;
    backdrop-filter: blur(8px);
  }
  .cw-inbox:not(.cw-details-open) .cw-details-rail {
    pointer-events: auto;
    width: 36px;
    padding: .4rem .18rem;
    background: transparent;
    border: none;
  }
  .cw-inbox:not(.cw-details-open) .cw-details-rail-btn {
    width: 28px !important;
    height: 28px;
  }
  .cw-inbox:not(.cw-details-open) .cw-thread-head {
    padding-right: 2.6rem;
  }
  /* Side rail already has Contact — don't duplicate that control in the thread header.
     Keep name/avatar visible so the thread still identifies who you're chatting with. */
  .cw-thread-head #inboxDetailsToggleBtn {
    display: none !important;
  }
  .cw-inbox:not(.cw-details-open) .cw-messages,
  .cw-inbox:not(.cw-details-open) .cw-notes-view {
    padding-right: 2.5rem;
  }
  .cw-inbox:not(.cw-details-open) .cw-composer-shell {
    margin-right: 2.5rem;
  }
}

/* ── Calling settings (Calls tab) ── */
.calling-config-card h4 {
  margin: 0 0 .65rem;
  font-size: .95rem;
  color: var(--ink);
}
.calling-enable-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}
.calling-hint { color: var(--muted); font-size: .85rem; margin: 0; line-height: 1.4; }
.calling-section { margin: 1.15rem 0; }
.calling-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a5f;
  border-radius: 10px;
  padding: .75rem .9rem;
  font-size: .84rem;
  line-height: 1.45;
  margin-bottom: .85rem;
}
.calling-handler-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
@media (max-width: 720px) {
  .calling-handler-grid { grid-template-columns: 1fr; }
}
.calling-handler-card {
  text-align: left;
  background: #fff;
  color: var(--ink);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  width: 100%;
  margin: 0;
  font-weight: 500;
  box-shadow: none;
}
.calling-handler-card:hover:not(:disabled) { background: #f9fafb; border-color: #c7d2fe; }
.calling-handler-card.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(91, 92, 226, .12);
}
.calling-handler-card:disabled {
  opacity: .62;
  cursor: not-allowed;
  background: #fafafa;
}
.calling-handler-card strong { display: block; margin: .35rem 0 .25rem; font-size: .95rem; }
.calling-handler-card p { margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.4; font-weight: 500; }
.calling-handler-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.calling-handler-icon {
  width: 34px; height: 34px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem;
}
.calling-handler-icon.voice-ai { background: #f3e8ff; color: #7c3aed; }
.calling-handler-icon.human { background: #eef2ff; color: var(--brand); }
.calling-badge {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  background: #f3e8ff; color: #6d28d9; padding: .2rem .45rem; border-radius: 6px;
}
.calling-radio {
  width: 18px; height: 18px; border-radius: 999px; border: 2px solid #cbd5e1;
  display: inline-block;
}
.calling-handler-card.selected .calling-radio {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 4px var(--brand);
}
.calling-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
  margin: .15rem 0 0;
}
.calling-switch input {
  position: absolute; opacity: 0; width: 0; height: 0; margin: 0; padding: 0;
}
.calling-switch-track {
  width: 46px; height: 26px; border-radius: 999px; background: #d1d5db;
  transition: background .15s ease; position: relative;
}
.calling-switch-track::after {
  content: '';
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 999px; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .15s ease;
}
.calling-switch input:checked + .calling-switch-track { background: var(--brand); }
.calling-switch input:checked + .calling-switch-track::after { transform: translateX(20px); }
.calling-share {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .75rem; padding: .85rem 1rem; border-radius: 12px;
  background: linear-gradient(90deg, #ecfdf5, #f0fdf4);
  border: 1px solid #a7f3d0; margin: 1rem 0;
}
.calling-share-copy {
  display: flex; align-items: center; gap: .55rem;
  font-size: .88rem; color: #065f46; font-weight: 600; flex: 1; min-width: 180px;
}
.calling-share-icons {
  width: 28px; height: 28px; border-radius: 8px; background: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid #a7f3d0; color: #047857; flex-shrink: 0;
}
.calling-share-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: .45rem;
}
.calling-share-link-wrap {
  display: flex; align-items: center; gap: .25rem;
  background: #fff; border: 1px solid #a7f3d0; border-radius: 10px; padding: 0 .35rem 0 .65rem;
}
.calling-share-link-wrap input {
  border: none; margin: 0; padding: .55rem 0; width: min(220px, 42vw); font-size: .82rem;
  background: transparent;
}
.calling-icon-btn { width: auto; margin: 0; padding: .4rem .55rem; }
.calling-qr-panel {
  width: 100%; text-align: center; padding-top: .5rem;
}
.calling-qr-panel img {
  display: inline-block; border-radius: 12px; border: 1px solid var(--line); background: #fff;
}
.calling-actions { justify-content: flex-end; margin-top: 1.25rem; }
.calling-actions button { width: auto; }
.req { color: var(--danger); }
#callingBusyMessage { min-height: 88px; resize: vertical; }

/* ── WhatsApp Forms ── */
.wf-page { display: flex; flex-direction: column; gap: 1rem; }
.wf-toolbar {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  flex-wrap: wrap; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .75rem 1rem; box-shadow: var(--shadow);
}
.wf-channel { display: flex; align-items: center; gap: .45rem; }
.wf-channel-label { font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.wf-channel select { width: auto; margin: 0; min-width: 12rem; }
.wf-toolbar-actions { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.wf-toolbar-actions button { width: auto; margin: 0; padding: .45rem .75rem; }
.wf-search-wrap {
  display: flex; align-items: center; gap: .35rem; background: #f9fafb;
  border: 1px solid var(--line); border-radius: 999px; padding: .2rem .7rem;
}
.wf-search-wrap input { border: 0; background: transparent; margin: 0; min-width: 10rem; padding: .35rem 0; }
.wf-view-toggle { display: inline-flex; gap: .15rem; }
.wf-view-btn { padding: .4rem .55rem !important; }
.wf-view-btn.active { background: #111827; color: #fff; }

.wf-empty {
  background:
    radial-gradient(900px 420px at 50% 18%, rgba(91, 92, 226, .14), transparent 62%),
    var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 2.2rem 1.4rem 2rem; text-align: center;
}
.wf-empty h2 { margin: 0 0 .5rem; font-size: 1.5rem; letter-spacing: -.03em; }
.wf-empty-sub {
  margin: 0 auto 1.5rem; max-width: 40rem; color: var(--muted);
  font-size: .95rem; line-height: 1.5;
}
.wf-steps {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem;
  max-width: 58rem; margin: 0 auto 1.4rem; text-align: left;
}
.wf-step-card {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 1rem 1rem 1.1rem; min-height: 12rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.wf-step-card h3 { margin: .35rem 0 .35rem; font-size: .95rem; }
.wf-step-card p { margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.wf-step-num {
  display: inline-flex; width: 1.35rem; height: 1.35rem; align-items: center; justify-content: center;
  border-radius: 999px; background: #eef2ff; color: #3730a3; font-size: .72rem; font-weight: 800;
}
.wf-step-illus {
  height: 6.4rem; border-radius: 10px; margin-bottom: .65rem;
  background: #f8fafc; border: 1px dashed #e5e7eb;
  display: flex; align-items: center; justify-content: center;
}
.wf-illus-flow, .wf-illus-tpl, .wf-illus-bc {
  display: flex; flex-direction: column; gap: .28rem; width: 78%; font-size: .68rem; color: #334155;
}
.wf-illus-bar { height: .45rem; border-radius: 6px; background: #c7d2fe; }
.wf-illus-bar.short { width: 62%; background: #e0e7ff; }
.wf-illus-chip {
  display: inline-block; background: #ecfdf5; color: #047857; border-radius: 999px;
  padding: .08rem .4rem; font-weight: 700; width: fit-content;
}
.wf-illus-tpl { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: .55rem .65rem; }
.wf-illus-tpl span { color: #64748b; }
.wf-illus-bc { flex-direction: row; justify-content: center; gap: .4rem; }
.wf-illus-bc span {
  background: #111827; color: #fff; border-radius: 999px; padding: .2rem .55rem; font-weight: 700;
}
.wf-empty-none { margin: .2rem 0 0; color: #64748b; font-size: .9rem; }

.wf-list.view-list { display: flex; flex-direction: column; gap: .65rem; }
.wf-list.view-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; }
.wf-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: .9rem 1rem; box-shadow: var(--shadow); cursor: pointer;
}
.wf-card:hover { border-color: #c7d2fe; }
.wf-card-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.wf-card-meta { margin: .35rem 0 .55rem; color: var(--muted); font-size: .82rem; }
.wf-card-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.wf-card-actions button { width: auto; margin: 0; padding: .3rem .55rem; }

.wf-modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 80;
  display: flex; align-items: flex-start; justify-content: center; padding: 4rem 1rem 2rem;
  overflow: auto;
}
.wf-modal[hidden] { display: none !important; }
.wf-modal-card {
  width: min(760px, 100%); background: #fff; border-radius: 16px; border: 1px solid var(--line);
  box-shadow: 0 20px 50px rgba(15, 23, 42, .18);
}
.wf-modal-card header, .wf-modal-card footer {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  padding: .9rem 1.1rem; border-bottom: 1px solid var(--line);
}
.wf-modal-card footer { border-bottom: 0; border-top: 1px solid var(--line); justify-content: flex-end; }
.wf-modal-card header h3 { margin: 0; }
.wf-modal-card header button, .wf-modal-card footer button { width: auto; margin: 0; }
.wf-wiz-body { padding: 1rem 1.1rem 1.2rem; }
.wf-screen-card {
  border: 1px solid var(--line); border-radius: 12px; padding: .75rem; margin: .7rem 0; background: #f8fafc;
}
.wf-screen-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .45rem; }
.wf-field-row {
  display: grid; grid-template-columns: 1.3fr 1fr 7.5rem auto auto; gap: .35rem; align-items: center;
  margin-bottom: .35rem;
}
.wf-field-row input, .wf-field-row select { margin: 0; }
.wf-field-row .wf-opts { grid-column: 1 / -1; }
.wf-req { font-size: .78rem; color: var(--muted); display: flex; align-items: center; gap: .25rem; white-space: nowrap; }
.wf-json {
  margin: 0 1.1rem 1rem; background: #0f172a; color: #e2e8f0; border-radius: 10px;
  padding: .75rem; font-size: .75rem; max-height: 220px; overflow: auto;
}
.wf-json-inline { margin: 0; font-size: .72rem; max-height: 8rem; overflow: auto; white-space: pre-wrap; }
.wf-warn { color: #9a3412; font-size: .85rem; }
.wf-gallery-filters { display: flex; gap: .5rem; margin-bottom: .85rem; flex-wrap: wrap; }
.wf-gallery-filters input, .wf-gallery-filters select { margin: 0; }
.wf-gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .65rem;
}
.wf-gallery-card {
  text-align: left; width: 100%; margin: 0; padding: .8rem .85rem;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.wf-gallery-card strong { display: block; font-size: .88rem; margin-bottom: .25rem; }
.wf-gallery-card span { display: block; color: var(--muted); font-size: .78rem; line-height: 1.4; font-weight: 500; }
.wf-gallery-card:hover { border-color: #c7d2fe; }

@media (max-width: 820px) {
  .wf-steps { grid-template-columns: 1fr; }
  .wf-field-row { grid-template-columns: 1fr 1fr; }
  .wf-field-row .wf-opts { grid-column: 1 / -1; }
}

.wf-overlay {
  position: fixed; inset: 0; z-index: 80; background: #f3f4f6;
  display: flex; flex-direction: column;
}
.wf-overlay[hidden] { display: none !important; }
.wf-gallery-inner { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.wf-gallery-head, .wf-b-top, .wf-gal-preview-head {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: 1.1rem 1.25rem .7rem; background: #fff; border-bottom: 1px solid var(--line);
}
.wf-gallery-head h2, .wf-b-top h2 { margin: 0; font-size: 1.25rem; letter-spacing: -.02em; }
.wf-x {
  width: 36px; height: 36px; margin: 0; padding: 0; border-radius: 10px;
  background: transparent; color: #374151; border: 0; font-size: 1.35rem; line-height: 1;
}
.wf-x:hover { background: #f3f4f6; }
.wf-gallery-filters {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .65rem 1.25rem; background: #fff; border-bottom: 1px solid var(--line);
}
.wf-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.wf-chip {
  width: auto; margin: 0; padding: .35rem .85rem; border-radius: 999px; font-size: .85rem;
  background: #fff; color: #111827; border: 1px solid #e5e7eb; font-weight: 600;
}
.wf-chip.active { background: #e5e7eb; border-color: #d1d5db; }
.wf-gal-search { display: flex; align-items: center; gap: .35rem; }
.wf-search-toggle { width: 36px; margin: 0; padding: .4rem; background: transparent; color: #4b5563; border: 0; }
.wf-gallery-layout { display: grid; grid-template-columns: 1fr auto; flex: 1; min-height: 0; }
.wf-gal-grid {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .75rem;
  padding: 1rem 1.25rem 1.5rem; overflow: auto; align-content: start;
}
.wf-gal-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 1.1rem .85rem .9rem;
  text-align: center; cursor: pointer; min-height: 148px;
}
.wf-gal-card:hover { border-color: #93c5fd; }
.wf-gal-card.selected { background: #eff6ff; border-color: #3b82f6; }
.wf-gal-ico { height: 36px; display: flex; align-items: center; justify-content: center; color: #9ca3af; margin-bottom: .45rem; }
.wf-gal-card strong { display: block; font-size: .88rem; margin-bottom: .25rem; line-height: 1.25; }
.wf-gal-card p { margin: 0; color: #6b7280; font-size: .75rem; line-height: 1.35; }
.wf-gal-preview {
  width: 320px; background: #fff; border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.wf-gal-preview[hidden] { display: none !important; }
.wf-gallery-layout.with-preview { grid-template-columns: 1fr 320px; }
.wf-phone-wrap { flex: 1; overflow: auto; padding: .75rem .9rem 1rem; display: flex; justify-content: center; }
.wf-phone {
  width: 260px; background: #ece5dd; border-radius: 18px; overflow: hidden;
  box-shadow: 0 12px 30px rgba(15,23,42,.18); display: flex; flex-direction: column; min-height: 460px;
}
.wf-wa-bar {
  background: #075e54; color: #fff; display: flex; align-items: center; gap: .45rem;
  padding: .55rem .65rem; font-size: .8rem;
}
.wf-wa-avatar { width: 22px; height: 22px; border-radius: 999px; background: #25d366; }
.wf-wa-tick { color: #34d399; font-weight: 800; }
.wf-flow { background: #fff; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.wf-flow-head {
  display: flex; align-items: center; justify-content: space-between; gap: .4rem;
  padding: .55rem .7rem; border-bottom: 1px solid #eee; font-size: .82rem;
}
.wf-flow-body { flex: 1; padding: .75rem .8rem; overflow: auto; }
.wf-flow-cap { color: #4b5563; font-size: .78rem; line-height: 1.4; margin-bottom: .7rem; }
.wf-flow-field { margin-bottom: .65rem; }
.wf-flow-field label { display: block; font-size: .72rem; font-weight: 700; margin-bottom: .25rem; }
.wf-flow-field .box { height: 32px; border: 1px solid #d1d5db; border-radius: 8px; background: #fafafa; }
.wf-flow-help { color: #6b7280; font-size: .68rem; margin-top: .2rem; }
.wf-choice { display: flex; align-items: center; gap: .4rem; font-size: .75rem; margin: .28rem 0; color: #374151; }
.wf-choice i { width: 14px; height: 14px; border: 1.5px solid #9ca3af; display: inline-block; border-radius: 3px; }
.wf-choice i.round { border-radius: 999px; }
.wf-flow-footer {
  margin: 0; width: calc(100% - 1.2rem); align-self: center; margin-bottom: .7rem;
  background: #25d366; color: #fff; border: 0; border-radius: 24px; padding: .7rem 1rem; font-weight: 700;
}
.wf-use-tpl {
  margin: 0 .9rem 1rem; width: calc(100% - 1.8rem); padding: .75rem 1rem; border-radius: 10px;
}
.wf-builder { background: #f8fafc; }
.wf-b-top { padding: .7rem 1rem; gap: 1rem; }
.wf-b-left, .wf-b-right { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.wf-b-left h2 { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }
.wf-icon-quiet { width: auto; margin: 0; padding: .25rem .4rem; background: transparent; color: #6b7280; border: 0; }
.wf-b-tabs { display: flex; gap: 1.1rem; }
.wf-b-tabs button {
  width: auto; margin: 0; padding: .45rem 0; background: transparent; color: #6b7280;
  border: 0; border-bottom: 2px solid transparent; border-radius: 0; font-weight: 700;
}
.wf-b-tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.wf-b-right .ghost, .wf-b-right button { width: auto; margin: 0; padding: .45rem .8rem; }
.wf-channel-pill {
  display: flex; align-items: center; gap: .35rem; border: 1px solid #e5e7eb; border-radius: 999px;
  padding: .3rem .7rem; font-size: .8rem; background: #fff;
}
.wf-b-body { display: grid; grid-template-columns: 220px 1fr 300px; flex: 1; min-height: 0; }
.wf-screens { background: #fff; border-right: 1px solid var(--line); padding: .85rem .7rem; overflow: auto; }
.wf-screens-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
.wf-link { width: auto; margin: 0; padding: 0; background: transparent; color: var(--brand); border: 0; font-weight: 700; font-size: .85rem; }
.wf-screen-item {
  display: flex; align-items: center; gap: .4rem; padding: .55rem .5rem; border-radius: 8px;
  cursor: pointer; font-size: .88rem; font-weight: 600;
}
.wf-screen-item.active { background: #f3f4f6; box-shadow: inset 3px 0 0 var(--brand); }
.wf-grip { color: #9ca3af; letter-spacing: -1px; font-size: .7rem; }
.wf-editor { overflow: auto; padding: 1rem 1.1rem 2rem; }
.wf-editor-head { display: flex; align-items: center; gap: .4rem; margin-bottom: .85rem; }
.wf-editor-head h3 { margin: 0; font-size: 1.05rem; }
.wf-field-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: .75rem .85rem .85rem;
  margin-bottom: .7rem; display: grid; grid-template-columns: 18px 1fr; gap: .55rem;
}
.wf-field-tools { display: flex; align-items: center; gap: .45rem; margin-bottom: .45rem; flex-wrap: wrap; }
.wf-field-tools select { width: auto; margin: 0; padding: .35rem .55rem; font-size: .85rem; }
.wf-tog { display: flex; align-items: center; gap: .35rem; font-size: .8rem; font-weight: 700; margin-left: auto; }
.wf-tog input { width: auto; margin: 0; }
.wf-count { float: right; color: #9ca3af; font-size: .72rem; }
.wf-field-card textarea, .wf-field-card input { margin: 0 0 .45rem; }
.wf-opt-row { display: flex; gap: .4rem; align-items: center; margin-bottom: .3rem; }
.wf-opt-row input { margin: 0; }
.wf-add-wrap { position: relative; margin-top: .4rem; }
.wf-add-btn { width: auto; }
.wf-add-menu {
  position: absolute; left: 0; top: 110%; z-index: 5; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); min-width: 180px; padding: .35rem;
}
.wf-add-menu button {
  display: block; width: 100%; text-align: left; background: transparent; color: #111;
  border: 0; margin: 0; padding: .45rem .6rem; border-radius: 8px; font-weight: 600;
}
.wf-add-menu button:hover { background: #f3f4f6; }
.wf-live-preview { background: #eef2f6; border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.wf-b-alt { flex: 1; overflow: auto; padding: 1.25rem; }
.wf-saved-card { max-width: 520px; }
.wf-saved-body { padding: 1.2rem 1.4rem; text-align: center; }
.wf-saved-check {
  width: 64px; height: 64px; margin: .2rem auto .8rem; border-radius: 999px; background: var(--brand);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; font-weight: 800;
}
.wf-locked { opacity: .65; pointer-events: none; }

@media (max-width: 1100px) {
  .wf-gal-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .wf-b-body { grid-template-columns: 180px 1fr; }
  .wf-live-preview { display: none; }
}
@media (max-width: 720px) {
  .wf-gal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wf-gallery-layout, .wf-gallery-layout.with-preview { grid-template-columns: 1fr; }
  .wf-gal-preview { width: 100%; border-left: 0; border-top: 1px solid var(--line); }
  .wf-b-body { grid-template-columns: 1fr; }
}

