:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --brand-soft: #ccfbf1;
  --accent: #ea580c;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --sidebar: #0b3b3a;
  --sidebar-end: #115e59;
  --sidebar-text: #d1fae5;
  --bg-from: #ecfeff;
  --bg-mid: #f8fafc;
  --bg-to: #fff7ed;
  --radius: 12px;
  --space-scale: 1;
  --shadow: 0 8px 28px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 18px 50px rgba(15, 23, 42, 0.12);
  --font: "Vazirmatn", "Tahoma", sans-serif;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 500px at 100% -10%, color-mix(in srgb, var(--brand) 12%, transparent), transparent 55%),
    radial-gradient(900px 420px at 0% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 50%),
    linear-gradient(165deg, var(--bg-from) 0%, var(--bg-mid) 42%, var(--bg-to) 100%);
  background-attachment: fixed;
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
body.theme-compact .content { padding: .85rem 1.1rem 1.5rem; }
body.theme-compact .card { padding: .8rem .9rem; }
body.theme-compact .topbar { padding: .7rem 1.1rem; }

a { color: var(--brand); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--brand-dark); }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 264px;
  background: linear-gradient(175deg, var(--sidebar) 0%, var(--sidebar-end) 100%);
  color: var(--sidebar-text);
  padding: 1.15rem .85rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
  box-shadow: inset -1px 0 0 rgba(255,255,255,.06);
}
.brand {
  display: flex; align-items: center; gap: .75rem;
  padding: .45rem .7rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: .95rem;
}
.brand-mark {
  width: 42px; height: 42px; border-radius: calc(var(--radius) - 2px);
  background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 55%, #fff), var(--accent));
  display: grid; place-items: center; color: #042f2e; font-weight: 800;
  box-shadow: 0 8px 20px rgba(0,0,0,.18);
}
.brand strong { display: block; color: #fff; font-size: 1rem; letter-spacing: -.01em; }
.brand span { font-size: .72rem; opacity: .72; }

.nav-group { margin-bottom: .95rem; }
.nav-label {
  font-size: .68rem; letter-spacing: .06em; opacity: .5;
  padding: .3rem .75rem; text-transform: uppercase;
}
.nav a {
  display: flex; align-items: center; gap: .65rem;
  padding: .62rem .8rem; margin: .12rem 0;
  border-radius: calc(var(--radius) - 2px); color: var(--sidebar-text); font-size: .9rem;
  transition: background .18s var(--ease), color .18s var(--ease), transform .18s var(--ease);
}
.nav a:hover { background: rgba(255,255,255,.1); color: #fff; transform: translateX(-2px); }
.nav a.active {
  background: rgba(255,255,255,.14); color: #fff;
  box-shadow: inset 3px 0 0 color-mix(in srgb, #fff 70%, var(--brand));
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.5rem; background: rgba(255,255,255,.78);
  backdrop-filter: blur(14px) saturate(1.2); border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-size: 1.22rem; letter-spacing: -.02em; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; }
.content { padding: 1.25rem 1.5rem 2rem; animation: fadeUp .35s var(--ease); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid color-mix(in srgb, var(--line) 90%, transparent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  backdrop-filter: blur(8px);
  transition: box-shadow .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.card:hover { box-shadow: var(--shadow-lg); }
.card h3 { margin: 0 0 .75rem; font-size: 1rem; letter-spacing: -.01em; }
.stat {
  display: flex; flex-direction: column; gap: .35rem;
  position: relative; overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; inset: auto -20px -30px auto;
  width: 90px; height: 90px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--brand) 18%, transparent), transparent 70%);
}
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: none; border-radius: calc(var(--radius) - 2px); padding: .55rem .95rem;
  background: var(--brand); color: #fff; cursor: pointer; font-family: inherit; font-size: .9rem;
  transition: background .15s var(--ease), transform .15s var(--ease), box-shadow .15s var(--ease);
  box-shadow: 0 1px 0 rgba(255,255,255,.2) inset;
}
.btn:hover { background: var(--brand-dark); color: #fff; transform: translateY(-1px); }
.btn:active { transform: none; }
.btn-secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
.btn-secondary:hover { background: #f8fafc; color: var(--ink); }
.btn-danger { background: var(--danger); }
.btn-accent { background: var(--accent); }
.btn-sm { padding: .35rem .65rem; font-size: .8rem; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .7rem .6rem; border-bottom: 1px solid var(--line); text-align: right; }
th { color: var(--muted); font-weight: 600; background: #f8fafc; }
tr:hover td { background: #f8fafc; }

.badge {
  display: inline-flex; padding: .15rem .55rem; border-radius: 999px;
  font-size: .75rem; background: #e2e8f0; color: #334155;
}
.badge-ok { background: #dcfce7; color: #166534; }
.badge-warn { background: #ffedd5; color: #9a3412; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: var(--brand-soft); color: #115e59; }

.form-row { display: grid; gap: .75rem; margin-bottom: .9rem; }
.form-row.two { grid-template-columns: 1fr 1fr; }
label { display: block; margin-bottom: .3rem; font-size: .85rem; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: .65rem .75rem; border: 1px solid var(--line);
  border-radius: 10px; font-family: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
.alert {
  padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: .9rem;
}
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-info { background: #e0f2fe; color: #075985; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
  position: relative; padding: 0 1.2rem 1rem 0; border-right: 2px solid var(--line); margin-right: .5rem;
}
.timeline li::before {
  content: ""; position: absolute; right: -6px; top: .35rem;
  width: 10px; height: 10px; border-radius: 50%; background: var(--brand);
}

.kanban {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr);
  gap: 1rem; overflow-x: auto; padding-bottom: .5rem;
}
.kanban-col {
  background: rgba(255,255,255,.7); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .75rem; min-height: 420px;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.kanban-col h4 {
  margin: 0 0 .75rem; font-size: .95rem;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
}
.kanban-col-body {
  min-height: 360px;
  border-radius: 10px;
}
.kanban-col.drag-over {
  background: rgba(13, 148, 136, .08);
  border-color: var(--brand);
  box-shadow: inset 0 0 0 2px rgba(15, 118, 110, .25);
}
.kanban-card {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: .7rem .7rem .7rem 1.6rem; margin-bottom: .6rem; box-shadow: var(--shadow);
  position: relative; cursor: grab; user-select: none;
  transition: opacity .15s ease, transform .15s ease, box-shadow .15s ease;
}
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging {
  opacity: .45;
  transform: scale(.98);
  box-shadow: none;
}
.kanban-card-handle {
  position: absolute; right: .35rem; top: .55rem;
  color: #94a3b8; font-size: .85rem; letter-spacing: -.05em;
  cursor: grab;
}
.kanban-card .meta { color: var(--muted); font-size: .78rem; margin-top: .35rem; }
.kanban-toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: .65rem 1rem; border-radius: 999px;
  font-size: .85rem; z-index: 100; box-shadow: var(--shadow);
}

.login-page {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(45,212,191,.25), transparent 35%),
    radial-gradient(circle at 80% 0%, rgba(251,146,60,.2), transparent 30%),
    linear-gradient(160deg, #042f2e, #0f766e 45%, #fff7ed);
  padding: 1rem;
}
.login-card {
  width: min(420px, 100%); background: rgba(255,255,255,.95);
  border-radius: 18px; padding: 1.75rem; box-shadow: 0 25px 60px rgba(0,0,0,.2);
}
.login-card h1 { margin: 0 0 .35rem; }
.login-card p { color: var(--muted); margin-top: 0; }

.pagination { display: flex; gap: .4rem; margin-top: 1rem; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: .35rem .65rem; border-radius: 8px; border: 1px solid var(--line); background: #fff;
}
.pagination .active { background: var(--brand); color: #fff; border-color: var(--brand); }

.chat { display: flex; flex-direction: column; gap: .65rem; }
.bubble {
  max-width: 82%; padding: .78rem .95rem; border-radius: 16px 16px 4px 16px;
  background: #f1f5f9; box-shadow: 0 1px 2px rgba(15,23,42,.04);
  animation: bubbleIn .28s var(--ease);
}
.bubble.agent {
  background: linear-gradient(160deg, var(--brand-soft), #fff);
  margin-right: auto; border-radius: 16px 16px 16px 4px;
  border: 1px solid color-mix(in srgb, var(--brand) 18%, transparent);
}
.bubble.customer {
  background: linear-gradient(160deg, #ffedd5, #fff7ed);
  margin-left: auto; border-radius: 16px 16px 4px 16px;
}
.bubble.system {
  background: rgba(255,255,255,.9); border: 1px solid var(--line);
  margin: 0 auto; max-width: 94%; text-align: center; font-size: .88rem;
  border-radius: 12px; color: var(--muted);
}
.bubble .who { font-size: .72rem; color: var(--muted); margin-bottom: .28rem; font-weight: 600; }
.bubble a { color: var(--brand); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.chat-product-list { display: flex; flex-direction: column; gap: .4rem; margin-top: .55rem; text-align: right; }
.chat-product-img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; flex-shrink: 0; background: #f1f5f9; }
.chat-product-body { min-width: 0; flex: 1; }
.chat-product {
  display: flex; align-items: flex-start; gap: .55rem; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; color: inherit; text-decoration: none !important;
  transition: border-color .15s ease, transform .15s ease;
}
a.chat-product:hover { border-color: var(--brand); transform: translateY(-1px); }
.chat-product-name { font-weight: 700; color: var(--brand); font-size: .88rem; line-height: 1.45; }
.chat-product-meta { font-size: .78rem; color: var(--muted); margin-top: .15rem; font-weight: 500; }

@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.chat-inbox {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 270px;
  gap: 1rem;
  align-items: stretch;
  min-height: 72vh;
}
.chat-inbox-list, .chat-inbox-main, .chat-inbox-side {
  min-height: 72vh; display: flex; flex-direction: column;
}
.chat-conv-list { display: flex; flex-direction: column; gap: .45rem; max-height: 64vh; overflow: auto; padding: .15rem; }
.chat-conv-item {
  display: block; padding: .75rem .85rem; border: 1px solid transparent; border-radius: var(--radius);
  text-decoration: none; color: inherit; background: #f8fafc;
  transition: background .18s var(--ease), border-color .18s var(--ease), transform .18s var(--ease);
}
.chat-conv-item:hover { border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); transform: translateY(-1px); }
.chat-conv-item.active {
  border-color: var(--brand); background: var(--brand-soft);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 12%, transparent);
}
.chat-conv-item .meta { font-size: .75rem; color: var(--muted); margin-top: .28rem; }
.live-chat-thread {
  display: flex; flex-direction: column; gap: .65rem;
  flex: 1; max-height: 52vh; overflow: auto; padding: .85rem;
  background:
    radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--brand) 8%, transparent), transparent 40%),
    #f8fafc;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  scroll-behavior: smooth;
}

.chat-reply-composer { margin-top: .5rem; position: relative; overflow: visible; z-index: 2; }
.chat-reply-composer textarea { margin-top: 0; display: block; width: 100%; font-family: inherit, "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; }
.chat-reply-toolbar {
  display: flex; align-items: center; justify-content: flex-start; gap: .5rem; margin-top: .5rem;
  position: relative; overflow: visible; z-index: 3;
}
.chat-inbox-main.card { overflow: visible; }
.chat-emoji-wrap { position: relative; overflow: visible; z-index: 4; }
.chat-emoji-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.4rem; height: 2.4rem; padding: 0 .55rem;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; cursor: pointer; font-size: 1.15rem; line-height: 1;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.chat-emoji-btn:hover,
.chat-emoji-wrap.is-open .chat-emoji-btn {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent);
}
.chat-emoji-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  box-sizing: border-box;
  width: min(320px, 92vw);
  max-width: calc(100vw - 16px);
  height: auto;
  max-height: 220px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  grid-template-columns: repeat(7, 40px);
  grid-auto-rows: 40px;
  justify-content: center;
  align-content: start;
  gap: 4px;
  padding: 8px;
  margin: 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .14);
  z-index: 100000;
  direction: rtl;
  -webkit-overflow-scrolling: touch;
  transform: none !important;
}
body > .chat-emoji-panel,
.chat-emoji-panel.chat-emoji-panel--portal {
  position: fixed !important;
  bottom: auto !important;
  top: auto;
  z-index: 100000 !important;
}
.chat-emoji-panel[hidden] { display: none !important; }
.chat-emoji-item {
  all: unset;
  box-sizing: border-box;
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 40px !important;
  height: 40px !important;
  min-width: 40px;
  min-height: 40px;
  max-width: 40px;
  max-height: 40px;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  border-radius: 8px;
  cursor: pointer;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif !important;
  font-size: 22px !important;
  line-height: 1 !important;
  overflow: hidden;
  text-align: center;
  transform: none !important;
  transition: background .12s ease;
}
.chat-emoji-item:hover,
.chat-emoji-item:focus-visible {
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  transform: none !important;
}
.kanban-toolbar {
  display: flex; gap: .75rem; flex-wrap: wrap; align-items: end; justify-content: space-between;
  margin-bottom: 1rem;
}
.kanban-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1rem;
  align-items: start;
}
.kanban-layout.no-panel { grid-template-columns: 1fr; }
.kanban-side-panel {
  position: sticky; top: 1rem;
  max-height: calc(100vh - 2rem); overflow: auto;
}
.kanban-side-panel[hidden] { display: none !important; }
.kanban-card.is-selected { outline: 2px solid var(--brand); background: #f0fdfa; }
.kanban-quick-actions { display: flex; flex-wrap: wrap; gap: .35rem; margin: .75rem 0; }
.kanban-quick-actions button { font-size: .78rem; }

.desk-widgets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.desk-widget h3 { margin: 0 0 .75rem; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.desk-list { list-style: none; padding: 0; margin: 0; }
.desk-list li {
  padding: .55rem 0; border-bottom: 1px dashed var(--line);
  display: flex; justify-content: space-between; gap: .75rem; align-items: start; font-size: .9rem;
}
.desk-list li:last-child { border-bottom: 0; }
.desk-shortcuts { display: flex; flex-wrap: wrap; gap: .5rem; }

@media (max-width: 1100px) {
  .chat-inbox { grid-template-columns: 1fr; }
  .chat-inbox-list, .chat-inbox-main, .chat-inbox-side { min-height: auto; }
  .chat-conv-list { max-height: 240px; }
  .kanban-layout { grid-template-columns: 1fr; }
  .desk-widgets { grid-template-columns: 1fr; }
}

.user-chip {
  display: flex; align-items: center; gap: .5rem; background: #fff;
  border: 1px solid var(--line); border-radius: 999px; padding: .25rem .7rem .25rem .25rem;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-dark);
  display: grid; place-items: center; font-weight: 700; font-size: .85rem;
}

.topbar-title-wrap { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.nav-toggle, .sidebar-close {
  display: none; border: 1px solid var(--line); background: #fff; border-radius: 10px;
  width: 40px; height: 40px; font-size: 1.15rem; cursor: pointer; color: var(--ink);
}
.sidebar-close {
  margin-right: auto; background: rgba(255,255,255,.12); border-color: transparent; color: #fff;
}
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 40;
}

.tabs { display: flex; flex-direction: column; gap: .85rem; }
.tab-nav {
  display: flex; flex-wrap: wrap; gap: .35rem; border-bottom: 1px solid var(--line); padding-bottom: .5rem;
}
.tab-btn {
  border: 1px solid transparent; background: transparent; font-family: inherit;
  padding: .45rem .85rem; border-radius: 999px; cursor: pointer; color: var(--muted); font-size: .88rem;
}
.tab-btn.active {
  background: var(--brand-soft); color: var(--brand-dark); border-color: #99f6e4; font-weight: 700;
}
.tab-btn[data-tab="chat-widget"]:not(.active) {
  border-color: #99f6e4; color: var(--brand-dark);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Chat widget settings: full-width when preview tab is open */
.grid.grid-2:has(.tab-panel[data-panel="chat-widget"].active) > .card:first-child {
  grid-column: 1 / -1;
}
.grid.grid-2:has(.tab-panel[data-panel="chat-widget"].active) > .card:last-child {
  display: none;
}

/* Chat widget live preview layout (RTL: form right, sticky preview left) */
.cw-widget-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 1.25rem;
  align-items: start;
}
.cw-widget-form-col { min-width: 0; }
.cw-widget-preview-col {
  min-width: 0;
  position: sticky;
  top: 5.25rem;
  align-self: start;
  z-index: 4;
}
.cw-widget-preview-sticky {
  display: flex;
  flex-direction: column;
  gap: .45rem;
}
.cw-widget-preview-title {
  margin: 0;
  font-size: .95rem;
}
.cw-widget-preview-hint {
  margin: 0 0 .35rem;
  font-size: .75rem;
  color: #94a3b8;
}
.cw-preview-stage {
  position: relative;
  width: 100%;
  height: 460px;
  max-height: calc(100vh - 9rem);
  border-radius: 18px;
  padding: 1rem .9rem 4.5rem;
  overflow: visible;
  direction: rtl;
  background:
    radial-gradient(ellipse 80% 60% at 50% 20%, rgba(148, 163, 184, .18), transparent 60%),
    linear-gradient(165deg, #1e293b 0%, #0f172a 55%, #111827 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 12px 32px rgba(15, 23, 42, .22);
  border: 1px solid rgba(148, 163, 184, .22);
}
.cw-preview-panel-wrap {
  width: min(268px, 100%);
  margin: 0 auto;
  pointer-events: none;
}
#cw-preview {
  width: 100%;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .35);
  font-family: Vazirmatn, Tahoma, sans-serif;
  background: #fff;
  color: #0f172a;
}
#cw-pv-head {
  padding: 12px 14px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #0f766e;
}
#cw-pv-close {
  all: unset;
  box-sizing: border-box;
  margin-inline-start: auto;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
  color: #fff;
  background: #0f172a;
  opacity: 0.92;
  cursor: default;
  flex-shrink: 0;
}
#cw-pv-av {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(255,255,255,.2);
  overflow: hidden;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 14px;
}
.cw-pv-head-text { min-width: 0; }
#cw-pv-title { font-weight: 700; font-size: 13px; }
#cw-pv-sub { font-size: 11px; opacity: .85; }
#cw-pv-msgs {
  padding: 12px;
  background: #f1f5f9;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#cw-pv-bot {
  align-self: flex-end;
  max-width: 85%;
  padding: 8px 11px;
  border-radius: 14px 14px 14px 4px;
  font-size: 12px;
  background: #ccfbf1;
  border: 1px solid rgba(15,118,110,.15);
}
#cw-pv-user {
  align-self: flex-start;
  max-width: 85%;
  padding: 8px 11px;
  border-radius: 14px 14px 4px 14px;
  font-size: 12px;
  background: #ffedd5;
}
#cw-pv-qr {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.cw-pv-chip {
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #99f6e4;
  background: #fff;
  border-radius: 999px;
  color: #0d5f59;
}
.cw-pv-composer {
  padding: 8px 10px;
  display: flex;
  gap: 6px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}
.cw-pv-input-mock {
  flex: 1;
  height: 34px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}
#cw-pv-send {
  width: 40px;
  height: 34px;
  border-radius: 10px;
  background: #0f766e;
  flex-shrink: 0;
}
#cw-pv-brand {
  font-size: 9px;
  color: #94a3b8;
  text-align: center;
  padding: 0 8px 8px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
#cw-pv-brand-logo {
  max-height: 14px;
  max-width: 72px;
  width: auto;
  height: auto;
  object-fit: contain;
  vertical-align: middle;
}
#cw-pv-brand-logo[hidden] {
  display: none !important;
}
#cw-pv-brand-text {
  line-height: 1.3;
}

@media (max-width: 1100px) {
  .cw-widget-layout {
    grid-template-columns: 1fr;
  }
  .cw-widget-preview-col {
    position: static;
    order: -1;
    z-index: auto;
  }
  .cw-preview-stage {
    height: 400px;
    max-height: none;
  }
}

.bar-chart { display: flex; flex-direction: column; gap: .45rem; }
.bar-row { display: grid; grid-template-columns: 52px 1fr auto; gap: .5rem; align-items: center; }
.bar-label { font-size: .75rem; color: var(--muted); }
.bar-track { height: 10px; background: #e2e8f0; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand), color-mix(in srgb, var(--brand) 40%, #fff)); border-radius: 99px; min-width: 2px; }
.bar-value { font-size: .75rem; color: var(--muted); white-space: nowrap; }

.attention-list { list-style: none; padding: 0; margin: .5rem 0 .75rem; font-size: .85rem; }
.attention-list li { padding: .25rem 0; border-bottom: 1px dashed #fed7aa; }
.row-overdue { background: #fff7ed; }
.ticket-sidebar .sidebar-block {
  padding-bottom: 1rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line);
}
.ticket-sidebar .sidebar-block:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.settings-save-bar {
  position: sticky; bottom: 0; background: rgba(255,255,255,.95); padding: .75rem 0;
  border-top: 1px solid var(--line); margin-top: 1rem; z-index: 5;
}
a.card.stat:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(15, 23, 42, .5);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-backdrop[hidden] { display: none !important; }
.modal-dialog {
  background: #fff; border-radius: 16px; width: min(720px, 100%);
  max-height: min(85vh, 820px); display: flex; flex-direction: column;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .25); border: 1px solid var(--line);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.1rem; border-bottom: 1px solid var(--line);
}
.modal-close {
  border: 0; background: transparent; font-size: 1.4rem; cursor: pointer; line-height: 1; color: #64748b;
}
.modal-body { padding: 1rem 1.1rem; overflow: auto; }
.journey-summary {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem;
}
.journey-summary .card { margin: 0; padding: .75rem; }
.journey-timeline { list-style: none; padding: 0; margin: 0; }
.journey-timeline li {
  padding: .65rem 0; border-bottom: 1px dashed var(--line); font-size: .9rem;
}
.journey-timeline .meta { font-size: .78rem; color: #64748b; margin-top: .2rem; }
.journey-badge {
  display: inline-block; font-size: .7rem; padding: .1rem .4rem; border-radius: 6px;
  background: #f1f5f9; color: #334155; margin-left: .35rem;
}
.journey-badge.matomo { background: #ecfeff; color: #0e7490; }
.journey-badge.crm { background: #f0fdf4; color: #166534; }

.coupon-code-row { display: flex; gap: .5rem; align-items: stretch; }
.coupon-code-row input { min-width: 0; }

.page-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.page-head-title { margin: 0; font-size: 1.25rem; }
.page-head-sub { margin: .25rem 0 0; color: var(--muted); font-size: .88rem; }

.coupon-form {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 1fr);
  gap: 1rem;
  align-items: start;
  max-width: none;
  width: 100%;
}
.coupon-col-main { min-width: 0; }
.coupon-col-side { min-width: 0; }
.coupon-span-2 { grid-column: 1 / -1; }
.coupon-section {
  margin: 0;
  height: 100%;
}
.coupon-section h3 {
  margin: 0 0 1rem;
  font-size: .95rem;
  color: var(--ink);
  padding-bottom: .65rem;
  border-bottom: 1px solid var(--line);
}
.field-hint { font-size: .75rem; color: #94a3b8; margin: .35rem 0 0; }
.field-hint.is-error { color: #b91c1c; }
.opt { color: #94a3b8; font-weight: 400; font-size: .8em; }

.code-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .5rem;
  align-items: stretch;
}
.code-field input {
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-weight: 600;
  min-width: 0;
}
.code-field .btn { white-space: nowrap; min-width: 7.5rem; }

.option-list {
  display: flex; flex-wrap: wrap; gap: .55rem .9rem;
  padding-top: .25rem;
}
.option-item {
  display: inline-flex; align-items: center; gap: .4rem;
  margin: 0; color: var(--ink); font-size: .88rem; cursor: pointer;
}

.scope-toggle {
  display: flex; flex-wrap: wrap; gap: .5rem;
  margin-bottom: .85rem;
}
.scope-toggle-col { flex-direction: column; align-items: stretch; }
.scope-option {
  display: inline-flex; align-items: center; gap: .4rem;
  margin: 0; padding: .55rem .85rem;
  border: 1px solid var(--line); border-radius: 999px;
  background: #f8fafc; cursor: pointer; font-size: .88rem; color: var(--ink);
}
.scope-option:has(input:checked),
.scope-option.is-active {
  background: var(--brand-soft);
  border-color: #99f6e4;
  font-weight: 600;
}
.picker-block { margin-top: .25rem; }
.multi-select { min-height: 140px; }
#usage-limits.is-disabled { opacity: .45; pointer-events: none; }
.coupon-actions {
  display: flex; gap: .5rem; flex-wrap: wrap;
  padding: .15rem 0 .5rem;
}

@media (max-width: 980px) {
  .coupon-form { grid-template-columns: 1fr; }
  .coupon-span-2 { grid-column: auto; }
}

.entity-picker { display: flex; flex-direction: column; gap: .65rem; }
.entity-picker-selected {
  display: flex; flex-wrap: wrap; gap: .45rem; min-height: 42px;
  padding: .55rem; border: 1px dashed var(--line); border-radius: var(--radius); background: #f8fafc;
}
.entity-picker-empty { color: #94a3b8; font-size: .82rem; padding: .25rem .35rem; }
.entity-chip {
  display: inline-flex; align-items: center; gap: .45rem; max-width: 100%;
  background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: .25rem .45rem .25rem .3rem;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.entity-chip img, .entity-result img {
  width: 28px; height: 28px; border-radius: 8px; object-fit: cover; background: #e2e8f0; flex-shrink: 0;
}
.entity-chip-icon {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--brand-soft); font-size: .85rem; flex-shrink: 0;
}
.entity-chip-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; padding-left: .15rem; }
.entity-chip-body strong { font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.entity-chip-body small { font-size: .68rem; color: var(--muted); }
.entity-chip-remove {
  border: 0; background: #f1f5f9; width: 22px; height: 22px; border-radius: 50%;
  cursor: pointer; color: #64748b; line-height: 1; font-size: 14px;
}
.entity-chip-remove:hover { background: #fee2e2; color: #991b1b; }
.entity-picker-search-wrap { position: relative; }
.entity-picker-results {
  position: absolute; right: 0; left: 0; top: calc(100% + 4px); z-index: 30;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); max-height: 280px; overflow: auto; padding: .35rem;
}
.entity-picker-hint { padding: .75rem; color: var(--muted); font-size: .85rem; text-align: center; }
.entity-result {
  width: 100%; display: flex; align-items: center; gap: .55rem; text-align: right;
  border: 0; background: transparent; padding: .55rem .5rem; border-radius: 10px;
  cursor: pointer; font-family: inherit; color: inherit;
}
.entity-result:hover { background: #f8fafc; }
.entity-result.is-selected { opacity: .65; cursor: default; }
.entity-result .entity-chip-body { flex: 1; }
.entity-result .entity-chip-body strong { max-width: none; white-space: normal; }
.entity-result-badge {
  font-size: .7rem; padding: .15rem .45rem; border-radius: 999px; background: #e2e8f0; color: #475569; flex-shrink: 0;
}
.entity-result-badge.add { background: var(--brand-soft); color: var(--brand-dark); }

@media (max-width: 960px) {
  .app-shell { flex-direction: column; }
  .nav-toggle { display: inline-grid; place-items: center; }
  .sidebar-close { display: inline-grid; place-items: center; }
  .sidebar {
    position: fixed; top: 0; right: 0; bottom: 0; width: min(300px, 86vw); height: 100vh;
    z-index: 50; transform: translateX(110%); transition: transform .2s ease;
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop.is-visible { display: block; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row.two { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 40px 1fr auto; }
  .journey-summary { grid-template-columns: 1fr; }
  .kanban {
    grid-auto-columns: minmax(220px, 80vw);
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    padding-bottom: 1rem;
  }
  .kanban-col { scroll-snap-align: start; min-height: 360px; }
  .kanban-col-body { min-height: 280px; max-height: 60vh; overflow-y: auto; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .topbar { padding: .75rem 1rem; }
  .content { padding: 1rem; }
  .topbar-actions .user-chip div:last-child { display: none; }
}
