@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@600;700&family=Manrope:wght@400;500;600;700;800&display=swap");

:root {
  --bg: #c9cfce;
  --panel: rgba(247, 249, 248, 0.72);
  --panel-strong: rgba(255, 255, 255, 0.9);
  --border: rgba(20, 24, 28, 0.13);
  --muted: #687277;
  --text: #12161a;
  --accent: #485157;
  --accent-soft: rgba(72, 81, 87, 0.12);
  --danger: #9f2432;
  --success: #2f6f5a;
  --highlight: #fff2ba;
  --row-changed: rgba(255, 247, 214, 0.78);
  --glass-shadow: 0 24px 70px rgba(41, 50, 54, 0.16);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 8%, rgba(255,255,255,0.72), transparent 28rem),
    radial-gradient(circle at 92% 2%, rgba(133, 146, 150, 0.34), transparent 34rem),
    linear-gradient(135deg, #d7dcdb 0%, #b9c0c0 48%, #edf0ee 100%);
  color: var(--text);
  font-size: 14px;
  letter-spacing: 0;
  min-height: 100%;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.42;
  background-image:
    url("data:image/svg+xml,%3Csvg width='820' height='820' viewBox='0 0 820 820' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23939ea0' stroke-width='1.3' opacity='.44'%3E%3Cpath d='M124 602c72-146 190-214 354-204 84 5 149-25 196-91'/%3E%3Cpath d='M114 647c86-102 178-141 277-119 100 23 190 0 269-69'/%3E%3Cpath d='M556 134c-37 58-40 113-9 165 31 52 23 100-24 144'/%3E%3Ccircle cx='617' cy='199' r='107'/%3E%3Ccircle cx='617' cy='199' r='164'/%3E%3C/g%3E%3C/svg%3E"),
    linear-gradient(90deg, rgba(255,255,255,0.22) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.18) 1px, transparent 1px);
  background-size: 820px 820px, 54px 54px, 54px 54px;
  background-position: right -180px top -170px, center, center;
}

button { cursor: pointer; font: inherit; }

input, select, textarea {
  font: inherit;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,0.76);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.65);
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(72, 81, 87, 0.36);
  outline-offset: -1px;
}

.muted { color: var(--muted); font-size: 12px; }

/* ------ Login ------ */
.login-body {
  display: grid; place-items: center; min-height: 100vh;
  background:
    radial-gradient(circle at 50% 10%, rgba(255,255,255,0.86), transparent 22rem),
    radial-gradient(circle at 14% 90%, rgba(105, 118, 121, 0.34), transparent 28rem),
    linear-gradient(135deg, #d2d8d7, #aeb7b7 52%, #edf0ef);
}
.login-card {
  position: relative;
  isolation: isolate;
  background: rgba(250, 252, 251, 0.7); padding: 34px; width: min(380px, calc(100vw - 32px));
  border: 1px solid rgba(255,255,255,0.68);
  border-radius: 18px; box-shadow: var(--glass-shadow);
  display: flex; flex-direction: column; gap: 12px;
  backdrop-filter: blur(22px) saturate(1.18);
  overflow: hidden;
  animation: adminFadeUp 0.58s cubic-bezier(.2,.8,.2,1) both;
}
.login-card::before {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: -1;
  background: linear-gradient(145deg, rgba(255,255,255,0.88), transparent 42%, rgba(119,129,132,0.18));
}
.login-logo {
  width: 96px;
  height: 96px;
  object-fit: contain;
  filter: drop-shadow(0 14px 24px rgba(25, 31, 34, 0.16));
}
.login-card h1 { margin: 0; font-family: "Cormorant Garamond", serif; font-size: 34px; line-height: 0.95; }
.login-card .subtitle { margin: 0; color: var(--muted); }
.login-card label { font-size: 12px; color: var(--muted); }
.login-card input { width: 100%; }
.login-card button {
  background: linear-gradient(135deg, #22282d, #606a70); color: #fff; border: none;
  padding: 11px; border-radius: 999px; font-weight: 800;
  box-shadow: 0 14px 30px rgba(33, 39, 43, 0.18);
}
.login-card .error { color: var(--danger); margin: 0; }

/* ------ Topbar ------ */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 18px; background: rgba(244, 247, 246, 0.7);
  border-bottom: 1px solid rgba(255,255,255,0.58);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(22px) saturate(1.16);
  box-shadow: 0 16px 42px rgba(58, 68, 72, 0.12);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 178px;
  font-family: "Cormorant Garamond", serif;
  font-size: 23px;
  font-weight: 700;
  line-height: 0.82;
  letter-spacing: 0;
  color: #171b1f;
}
.brand img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  border-radius: 50%;
  filter: drop-shadow(0 8px 16px rgba(21, 27, 30, 0.15));
}
.tabs { display: flex; gap: 4px; }
.tab {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 6px 12px; border-radius: 6px;
}
.tab.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft); font-weight: 600; }
.tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 6px;
  border-radius: 999px; background: #c53030; color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1;
}
.tab-badge.is-zero { background: var(--muted); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.viewers { color: var(--muted); }
.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); padding: 6px 10px; border-radius: 6px; }
.ghost:hover { background: var(--bg); }

main { padding: 16px; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ------ Toolbar ------ */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input[type="search"] { flex: 0 0 280px; }
.toolbar button { padding: 6px 12px; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.toolbar button.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.toolbar button.active-toggle { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 600; }
.toolbar button:disabled { opacity: 0.6; cursor: not-allowed; }
.toolbar button.db-mod-trigger.active-toggle {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fb923c;
}

.db-mod-panel {
  display: grid;
  gap: 10px;
  margin: -2px 0 12px;
  padding: 12px;
  border: 1px solid rgba(251, 146, 60, 0.45);
  border-left: 4px solid #fb923c;
  border-radius: 8px;
  background: rgba(255, 247, 237, 0.72);
}
.db-mod-panel[hidden] { display: none; }
.db-mod-lock,
.db-mod-tools,
.db-mod-tool {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
}
.db-mod-lock[hidden],
.db-mod-tools[hidden] { display: none; }
.db-mod-lock label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}
.db-mod-lock input { width: 220px; }
.db-mod-tool {
  padding: 8px;
  border: 1px solid rgba(120, 73, 36, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
}
.db-mod-tool strong {
  font-size: 12px;
  color: #7c2d12;
  margin-right: 2px;
}
.db-mod-tool input,
.db-mod-tool select {
  min-width: 150px;
  max-width: 260px;
}
.db-mod-tool .danger,
.db-mod-tool .primary { padding: 7px 10px; }
.db-mod-status { align-self: center; }
.error-text { color: var(--danger) !important; }

/* ------ Table ------ */
.table-wrap {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  overflow: auto; max-height: calc(100vh - 160px);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { position: sticky; top: 0; background: var(--panel); z-index: 1; }
thead th {
  text-align: left; padding: 8px; border-bottom: 1px solid var(--border);
  font-weight: 600; white-space: nowrap;
}
tbody td {
  padding: 6px 8px; border-bottom: 1px solid var(--border);
  max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer;
}
tbody tr:hover { background: var(--accent-soft); }
tbody tr.row-changed { background: var(--row-changed); }
tbody tr.row-changed-flash { animation: flashRow 1.6s ease-out; }
.db-row-select-col {
  width: 40px;
  min-width: 40px;
  max-width: 40px;
  text-align: center;
}
tbody td.db-row-select-col {
  cursor: default;
  overflow: visible;
}
.db-row-select-col input {
  width: 16px;
  height: 16px;
  padding: 0;
  vertical-align: middle;
}
@keyframes flashRow {
  0% { background: var(--highlight); }
  100% { background: var(--row-changed); }
}
td .changed-badge {
  display: inline-block; margin-left: 6px;
  font-size: 10px; color: var(--accent);
  background: var(--accent-soft); padding: 1px 6px; border-radius: 999px;
}

.rag-cell { white-space: nowrap; }
.rag-badge,
.rag-inline-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.3;
  border: 1px solid transparent;
}
.rag-badge.rag-pending,
.rag-inline-badge.rag-pending {
  color: #92400e;
  background: #ffedd5;
  border-color: #fed7aa;
}
.rag-badge.rag-ready,
.rag-inline-badge.rag-embedded {
  color: #065f46;
  background: #dcfce7;
  border-color: #86efac;
}
.rag-badge.rag-skipped,
.rag-inline-badge.rag-skipped {
  color: #374151;
  background: #f3f4f6;
  border-color: #d1d5db;
}
.rag-badge.rag-failed,
.rag-inline-badge.rag-failed {
  color: #991b1b;
  background: #fee2e2;
  border-color: #fca5a5;
}
.rag-badge.rag-empty,
.rag-inline-badge.rag-empty {
  color: var(--muted);
  background: #f9fafb;
  border-color: #e5e7eb;
}

/* ------ Chats ------ */
.chats-layout {
  display: grid;
  grid-template-columns: 560px minmax(0, 1fr) 320px;
  gap: 12px;
  height: calc(100vh - 80px);
}
.chats-list, .chat-view, .chat-side {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  display: flex; flex-direction: column; min-height: 0; min-width: 0;
}
.channels {
  display: flex;
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: rgba(41, 48, 52, 0.52) rgba(255,255,255,0.28);
  background:
    linear-gradient(90deg, transparent calc(100% - 34px), rgba(23, 29, 32, 0.13) 100%);
  background-attachment: local;
}
.channel {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid var(--border); padding: 6px 10px; border-radius: 6px;
  color: var(--text);
  flex: 0 0 auto;
  scroll-snap-align: start;
}
.channel.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.channel.disabled { opacity: 0.5; cursor: not-allowed; }
.channel img { width: 16px; height: 16px; }
.global-pause-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.global-pause-toggle input { width: 16px; height: 16px; }
.global-pause-toggle.active {
  color: #92400e;
  background: #fffbeb;
}

#chat-items { overflow-y: auto; flex: 1; }
.chat-item {
  display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border);
  cursor: pointer; align-items: center;
}
.chat-item:hover { background: var(--bg); }
.chat-item.active { background: var(--accent-soft); }
.chat-item .avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--accent);
  color: #fff; display: grid; place-items: center; font-weight: 600;
  flex: 0 0 auto; overflow: hidden;
}
.chat-item .avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-item .info { min-width: 0; flex: 1; }
.chat-item .name {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
}
.chat-name-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-item .preview { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .preview-time { color: var(--muted); font-size: 11px; margin-top: 2px; }
.chat-item.paused { border-left: 3px solid #b7791f; }
.chat-item.lead-needs_reply { border-left: 3px solid #1d4ed8; background: rgba(29, 78, 216, 0.08); }
.chat-item.lead-overdue { border-left: 3px solid #b91c1c; background: rgba(185, 28, 28, 0.1); }
.chat-item.lead-hot { border-left: 3px solid #7f1d1d; background: rgba(127, 29, 29, 0.08); }
.chat-item.lead-order_active { border-left: 3px solid #047857; background: rgba(4, 120, 87, 0.08); }
.chat-item.lead-waiting_customer { border-left: 3px solid #b7791f; background: rgba(180, 83, 9, 0.08); }
.chat-item.lead-order_done { border-left: 3px solid #15803d; background: rgba(21, 128, 61, 0.08); }
.chat-item.lead-lost,
.chat-item.lead-order_cancelled { border-left: 3px solid #9f2432; background: rgba(159, 36, 50, 0.08); }
.lead-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
  white-space: nowrap;
  color: #4b5563;
  background: rgba(255,255,255,0.64);
  border: 1px solid rgba(75, 85, 99, 0.2);
}
.lead-badge svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}
.lead-badge span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lead-badge.lead-needs_reply { color: #1d4ed8; border-color: rgba(29, 78, 216, 0.25); }
.lead-badge.lead-overdue { color: #b91c1c; border-color: rgba(185, 28, 28, 0.28); }
.lead-badge.lead-hot { color: #7f1d1d; border-color: rgba(127, 29, 29, 0.26); }
.lead-badge.lead-order_active,
.lead-badge.lead-order_done { color: #047857; border-color: rgba(4, 120, 87, 0.26); }
.lead-badge.lead-waiting_customer { color: #92400e; border-color: rgba(146, 64, 14, 0.26); }
.lead-badge.lead-lost,
.lead-badge.lead-order_cancelled { color: #9f2432; border-color: rgba(159, 36, 50, 0.24); }
.clients-list,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.client-card,
.stat-card {
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  color: var(--text);
  min-width: 0;
}
.client-card.lead-needs_reply { border-color: rgba(29, 78, 216, 0.38); box-shadow: inset 3px 0 0 #1d4ed8; }
.client-card.lead-overdue { border-color: rgba(185, 28, 28, 0.45); box-shadow: inset 3px 0 0 #b91c1c; }
.client-card.lead-hot { border-color: rgba(127, 29, 29, 0.42); box-shadow: inset 3px 0 0 #7f1d1d; }
.client-card.lead-order_active,
.client-card.lead-order_done { border-color: rgba(4, 120, 87, 0.36); box-shadow: inset 3px 0 0 #047857; }
.client-card.lead-waiting_customer { border-color: rgba(146, 64, 14, 0.34); box-shadow: inset 3px 0 0 #b7791f; }
.client-card.lead-lost,
.client-card.lead-order_cancelled { border-color: rgba(159, 36, 50, 0.36); box-shadow: inset 3px 0 0 #9f2432; }
.client-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.client-metrics,
.stat-metrics {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 12px;
}
.client-metrics span,
.stat-metrics span {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 8px;
  background: rgba(255,255,255,0.58);
}
.client-lead-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.client-lead-row .lead-badge { margin-left: 0; }
.lead-flags {
  color: var(--muted);
  font-size: 12px;
}
.client-preview {
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stat-rank {
  color: #7f1d1d;
  font-weight: 800;
  font-size: 12px;
  margin-bottom: 4px;
}
.chat-channel-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 6px;
  min-width: 22px;
  height: 16px;
  padding: 0 5px;
  border-radius: 999px;
  color: #fff;
  background: var(--muted);
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
}
.chat-channel-badge.vk { background: #0077ff; }
.chat-channel-badge.tg { background: #229ed9; }
.mini-badge {
  display: inline-block; margin-left: 6px; padding: 1px 6px;
  font-size: 10px; font-weight: 600; border-radius: 999px;
  color: #744210; background: #fef3c7;
}

.chat-header {
  padding: 10px 16px; border-bottom: 1px solid var(--border); font-weight: 600;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.pause-toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
.pause-toggle input { width: 16px; height: 16px; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 12px 16px;
  display: flex; flex-direction: column; gap: 8px;
  min-width: 0;
}
.bubble {
  max-width: 78%; padding: 8px 12px; border-radius: 12px;
  white-space: pre-wrap; word-wrap: break-word; font-size: 13px;
  min-width: 0;
  box-sizing: border-box;
}
.bubble.user { align-self: flex-start; background: var(--bg); color: var(--text); border-bottom-left-radius: 4px; }
.bubble.assistant { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bubble.system { align-self: center; background: #fef3c7; color: #78350f; font-size: 11px; }
.bubble.tool { align-self: flex-start; background: #ecfdf5; color: #065f46; font-size: 11px; font-family: monospace; }
.bubble.tool.agent-tool-bubble {
  background: #eff6ff;
  color: #1e3a8a;
  border: 1px solid #bfdbfe;
  font-family: inherit;
  max-width: 86%;
  min-width: min(280px, 100%);
}
.bubble-content {
  min-width: 0;
  max-width: 100%;
}
.tool-call-title { font-weight: 700; margin-bottom: 4px; }
.tool-call-meta { font-size: 11px; opacity: 0.85; margin-bottom: 6px; }
.tool-call-args { display: grid; gap: 4px; margin-bottom: 8px; }
.tool-call-arg { font-size: 12px; }
.tool-log-toggle {
  background: transparent;
  color: inherit;
  border: 1px solid currentColor;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
}
.tool-raw-log {
  margin: 8px 0 0;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #dbeafe;
  background: #f8fbff;
  color: #0f172a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  overflow: auto;
  max-width: 100%;
  box-sizing: border-box;
  white-space: pre;
  max-height: 220px;
}
.bubble-time { margin-top: 4px; color: currentColor; opacity: 0.65; font-size: 10px; text-align: right; }
.message-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
  margin-top: 8px;
}
.message-media-item {
  display: block;
  overflow: hidden;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.12);
  background: #fff;
}
.message-media-item img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}
.chat-composer {
  display: grid; grid-template-columns: 1fr auto; gap: 8px;
  padding: 10px 12px; border-top: 1px solid var(--border); background: #fbfcfd;
}
.chat-composer textarea { min-height: 44px; resize: vertical; }
.chat-composer button { background: var(--accent); color: #fff; border: none; padding: 8px 14px; border-radius: 6px; font-weight: 600; }
.chat-composer button:disabled, .chat-composer textarea:disabled { opacity: 0.55; cursor: not-allowed; }

.chat-side { padding: 12px 16px; overflow-y: auto; }
.chat-side h3 { margin: 12px 0 4px; font-size: 12px; text-transform: uppercase; color: var(--muted); }
dl, .cart-customer-grid { margin: 0; display: grid; grid-template-columns: 100px 1fr; gap: 6px 8px; }
dt { color: var(--muted); }
dd { margin: 0; word-break: break-word; }
dl label, .cart-customer-grid label { color: var(--muted); padding-top: 6px; }
dl input, dl textarea, .cart-customer-grid input, .cart-customer-grid textarea { width: 100%; min-width: 0; }
dl textarea, .cart-customer-grid textarea { min-height: 56px; resize: vertical; }
.cart-hint { margin-bottom: 8px; }
.cart-customer-details {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  background: #fafbfc;
  margin-bottom: 8px;
}
.cart-customer-details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  font-size: 12px;
}
.cart-customer-details[open] summary { margin-bottom: 8px; }
.side-actions { grid-column: 1 / -1; display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.cart-item-row {
  display: grid; grid-template-columns: 1fr 62px; gap: 6px; align-items: center;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px; margin-top: 8px;
}
.cart-item-title { grid-column: 1 / -1; font-weight: 600; }
.cart-item-row input[data-cart-item="note"] { grid-column: 1 / -1; }
.cart-item-row button { padding: 6px 8px; }

.order-card, .cart-block {
  background: var(--bg); border-radius: 6px; padding: 8px; margin: 6px 0; font-size: 13px;
}
.order-card .order-head { display: flex; justify-content: space-between; align-items: center; }
.order-card .status {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}

/* ------ Orders ------ */
.orders-toolbar select { min-width: 160px; }
.orders-list { display: grid; gap: 12px; max-width: 1120px; }
.empty-state {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 24px; color: var(--muted);
}
.order-editor-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; display: grid; gap: 8px;
}
.order-editor-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.order-editor-head select { min-width: 160px; }
.order-summary { color: var(--text); }
.order-editor-card summary { cursor: pointer; color: var(--accent); font-weight: 600; margin: 8px 0; }
.order-edit-grid { display: grid; grid-template-columns: repeat(3, minmax(160px, 1fr)); gap: 8px; }
.order-edit-grid label, .order-item-edit label, .full-field { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.order-edit-grid input, .order-item-edit input, .full-field textarea { width: 100%; color: var(--text); }
.full-field { margin: 8px 0; }
.full-field textarea { min-height: 64px; resize: vertical; }
.order-items-edit { display: grid; gap: 8px; margin: 8px 0; }
.order-item-edit {
  display: grid; grid-template-columns: 2fr 90px 120px 1.4fr; gap: 8px;
  padding: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
}
.order-history { display: grid; gap: 4px; margin-top: 8px; }
.history-row {
  display: grid; grid-template-columns: 110px 110px 1fr; gap: 8px;
  padding: 4px 0; border-top: 1px solid var(--border); font-size: 12px;
}
.history-row em { color: var(--muted); font-style: normal; }
.order-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ------ Agent Settings / Prompts ------ */
.agents-settings-page {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  height: calc(100vh - 80px);
}
.agent-settings-panel, .agent-prompts-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 0;
}
.agent-settings-panel {
  padding: 12px 16px;
}
.agent-settings-head, .section-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.agent-settings-head h2, .section-title-row h2 {
  margin: 0 0 4px;
  font-size: 16px;
}
.agent-settings-actions {
  display: flex;
  gap: 8px;
}
.agent-settings-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}
.agent-settings-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.agent-settings-grid input[type="number"] {
  width: 100%;
}
.setting-wide {
  grid-column: 1 / -1;
}
.model-select-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}
.model-select-row input[type="text"] {
  width: 100%;
}
.setting-toggle {
  grid-template-columns: auto 1fr;
  align-items: start;
  color: var(--text) !important;
}
.setting-toggle input { margin-top: 3px; }
.setting-toggle strong {
  display: block;
  color: var(--text);
  font-size: 13px;
}
.setting-toggle small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}
#agent-settings-status {
  align-self: center;
  min-height: 18px;
}
.agent-prompts-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}
.section-title-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.prompts-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 12px;
  min-height: 0;
  padding: 12px;
}
.prompts-list, .prompt-editor {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 0;
}
.prompts-list {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 8px;
  gap: 6px;
}
.prompt-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
}
.prompt-list-item.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.prompt-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  color: var(--muted);
  background: #f3f4f6;
}
.prompt-badge.customized {
  color: #065f46;
  background: #dcfce7;
}
.prompt-editor {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.prompt-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.prompt-editor-head h2 { margin: 0 0 4px; font-size: 16px; }
.prompt-actions { display: flex; gap: 8px; }
.prompt-text {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 16px;
  resize: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  line-height: 1.45;
}
#prompt-status {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
}

/* ------ Modal ------ */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: grid; place-items: center; z-index: 100;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--panel); border-radius: 10px; width: 720px; max-width: 95vw;
  max-height: 90vh; display: flex; flex-direction: column;
}
.modal-card.modal-card-compact {
  width: 460px;
}
.model-picker-card {
  width: 920px;
  max-width: 96vw;
}
.modal-card header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.modal-card h2 { margin: 0; font-size: 16px; }
.model-picker-header-actions {
  display: flex;
  gap: 8px;
}
.model-picker-controls {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.model-picker-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
#model-picker-meta {
  padding: 10px 16px 0;
}
.model-picker-list {
  padding: 12px 16px;
  overflow-y: auto;
  max-height: 58vh;
  display: grid;
  gap: 8px;
}
.model-picker-item {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 10px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 10px;
  text-align: left;
}
.model-picker-item:hover {
  background: #f8faff;
}
.model-picker-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.model-picker-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f3f4f6;
  overflow: hidden;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #374151;
}
.model-picker-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.model-picker-main {
  min-width: 0;
}
.model-picker-name {
  font-weight: 600;
  font-size: 13px;
}
.model-picker-id {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
  word-break: break-all;
}
.model-picker-desc {
  color: #4b5563;
  font-size: 12px;
  margin-top: 6px;
  line-height: 1.35;
}
.model-picker-price {
  text-align: right;
  font-size: 12px;
  color: #1f2937;
  white-space: nowrap;
}
.model-picker-empty {
  padding: 18px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 8px;
}
.bulk-price-form {
  padding: 16px;
  display: grid;
  gap: 10px;
}
.bulk-price-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.bulk-price-form input,
.bulk-price-form select {
  width: 100%;
}
#price-bulk-status {
  min-height: 18px;
}
#edit-modal .modal-card {
  width: min(1180px, 96vw);
  max-height: 92dvh;
}
#edit-title {
  min-width: 0;
  max-width: calc(96vw - 120px);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
#edit-modal .modal-card #edit-fields {
  padding: 0;
  overflow-y: auto;
  display: block;
}
.edit-layout {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  min-height: 0;
}
.edit-layout-new {
  grid-template-columns: 1fr;
}
.edit-media-column {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: calc(92dvh - 116px);
  overflow-y: auto;
  display: grid;
  gap: 14px;
  padding: 16px;
  border-right: 1px solid var(--border);
  background: rgba(248, 250, 249, 0.36);
}
.edit-form-column {
  min-width: 0;
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 16px;
}
.edit-product-summary {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,0.62);
}
.edit-product-name {
  font-size: 18px;
  line-height: 1.25;
  font-weight: 900;
}
.edit-product-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.edit-product-meta span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,0.64);
  color: #374151;
  font-size: 12px;
  font-weight: 700;
}
.product-photo-panel {
  display: grid;
  gap: 12px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.product-photo-preview {
  position: relative;
  min-height: 320px;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,0.68);
}
.product-photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 10px;
}
.product-photo-preview-label {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid rgba(18, 22, 26, 0.12);
  background: rgba(255,255,255,0.82);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  backdrop-filter: blur(10px);
}
.product-photo-empty {
  display: grid;
  place-items: center;
  width: calc(100% - 24px);
  height: calc(100% - 24px);
  min-height: 180px;
  border: 1px dashed rgba(18, 22, 26, 0.24);
  border-radius: 10px;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}
.product-photo-preview-error {
  border-color: rgba(159, 36, 50, 0.42);
}
.product-photo-rail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
}
.product-photo-thumb {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,0.62);
  overflow: hidden;
}
.product-photo-thumb.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(72, 81, 87, 0.18);
}
.product-photo-thumb-button {
  width: 100%;
  min-height: 132px;
  display: grid;
  grid-template-rows: 92px auto;
  gap: 7px;
  padding: 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.product-photo-thumb-button:focus-visible,
.photo-upload-button:focus-visible {
  outline: 3px solid rgba(72, 81, 87, 0.42);
  outline-offset: -3px;
}
.product-photo-thumb-media {
  display: grid;
  place-items: center;
  width: 100%;
  height: 92px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(248,250,249,0.86);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.product-photo-thumb-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.product-photo-thumb-caption {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
  font-weight: 800;
}
.product-photo-thumb-actions {
  display: block;
  padding: 0 8px 8px;
}
.edit-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,0.58);
  overflow: hidden;
}
.edit-section summary {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  list-style: none;
  cursor: pointer;
  font-weight: 900;
  color: var(--text);
  background: rgba(255,255,255,0.5);
  border-bottom: 1px solid transparent;
}
.edit-section[open] summary {
  border-bottom-color: var(--border);
}
.edit-section summary::-webkit-details-marker { display: none; }
.edit-section summary small {
  min-width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
}
.edit-section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 12px;
}
.text-fields .edit-section-grid,
.photo-fields .edit-section-grid,
.misc-fields .edit-section-grid {
  grid-template-columns: 1fr;
}
.photo-upload-controls {
  margin-top: 6px;
}
.photo-upload-wrap {
  display: inline-flex;
}
.photo-upload-button {
  min-height: 40px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
}
.photo-upload-button.compact {
  width: 100%;
  min-height: 40px;
}
.field-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  align-items: start;
}
.field-row label {
  color: #4b5563;
  font-size: 12px;
  font-weight: 800;
  padding-top: 0;
}
.field-row input:not([type="checkbox"]),
.field-row textarea,
.field-row select {
  width: 100%;
}
.field-row textarea { min-height: 92px; resize: vertical; font-family: inherit; }
.field-row .edit-checkbox {
  width: 20px;
  height: 20px;
  padding: 0;
}
.photo-field-row {
  padding: 10px;
  border: 1px solid rgba(18, 22, 26, 0.1);
  border-radius: 10px;
  background: rgba(248,250,249,0.64);
}
.photo-field-current {
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.66);
  border: 1px solid rgba(18, 22, 26, 0.08);
}
.photo-field-current span {
  font-weight: 900;
}
.photo-field-current small {
  color: var(--muted);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.photo-path-details {
  border: 1px solid rgba(18, 22, 26, 0.08);
  border-radius: 8px;
  background: rgba(255,255,255,0.42);
  overflow: hidden;
}
.photo-path-details summary {
  min-height: 34px;
  padding: 7px 10px;
  cursor: pointer;
  color: #4b5563;
  font-size: 12px;
  font-weight: 800;
}
.photo-path-details input {
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
}
.photo-field-row input[data-edit-col],
.photo-field-row textarea[data-edit-col] {
  min-height: 38px;
  color: #4b5563;
  font-size: 12px;
}
.field-row.locked { background: #fff7ed; padding: 6px; border-radius: 6px; }
.field-row .lock-note { font-size: 11px; color: #c05621; margin-top: 4px; }
.photo-rag-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.photo-rag-controls .ghost { padding: 4px 8px; font-size: 12px; }
.photo-rag-controls .primary { padding: 4px 8px; font-size: 12px; }
.modal-card footer { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.primary { background: var(--accent); color: #fff; border: none; padding: 8px 16px; border-radius: 6px; font-weight: 600; }
.danger { background: var(--danger); color: #fff; border: none; padding: 8px 16px; border-radius: 6px; }

@media (max-width: 980px) {
  .chats-layout { grid-template-columns: 1fr; height: auto; }
  .agents-settings-page { height: auto; }
  .agent-settings-grid { grid-template-columns: 1fr; }
  .model-picker-controls { grid-template-columns: 1fr; }
  .edit-layout { grid-template-columns: 1fr; }
  .edit-media-column {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .edit-section-grid { grid-template-columns: 1fr; }
  .product-photo-preview { min-height: 260px; }
  .prompts-layout { grid-template-columns: 1fr; height: auto; }
  .chats-list, .chat-view, .chat-side { min-height: 320px; }
  .prompt-editor { min-height: 520px; }
  .order-edit-grid, .order-item-edit { grid-template-columns: 1fr; }
  .history-row { grid-template-columns: 1fr; }
}

/* ------ Argentum visual layer ------ */
button,
.tab,
.channel,
.chat-item,
.prompt-list-item,
.model-picker-item,
.order-editor-card,
.cart-item-row {
  transition: transform .22s ease, background .22s ease, border-color .22s ease, box-shadow .22s ease, color .22s ease;
}

button:hover:not(:disabled),
.tab:hover,
.channel:hover:not(:disabled),
.prompt-list-item:hover,
.model-picker-item:hover {
  transform: translateY(-1px);
}

.tab {
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
}

.tab.active,
.channel.active,
.toolbar button.active-toggle,
.prompt-list-item.active,
.model-picker-item.active {
  color: #11161a;
  border-color: rgba(33, 39, 43, 0.26);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.84), rgba(209, 216, 216, 0.48));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9), 0 10px 26px rgba(49, 58, 62, 0.11);
}

.topbar .ghost,
.toolbar button,
.chat-composer button,
.primary,
.danger {
  border-radius: 999px;
}

.ghost,
.toolbar button.ghost,
.topbar .ghost {
  background: rgba(255,255,255,0.46);
  border-color: rgba(255,255,255,0.7);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.85);
}

.toolbar button,
.chat-composer button,
.primary {
  background: linear-gradient(135deg, #1d2327, #606b70);
  border: 0;
  color: #fff;
  box-shadow: 0 12px 28px rgba(31, 38, 42, 0.15);
}

.danger {
  background: linear-gradient(135deg, #8f1727, #c24c59);
}

main {
  padding: 18px;
}

.tab-pane.active {
  animation: adminFadeUp .34s cubic-bezier(.2,.8,.2,1) both;
}

.table-wrap,
.chats-list,
.chat-view,
.chat-side,
.empty-state,
.order-editor-card,
.agent-settings-panel,
.agent-prompts-panel,
.prompts-list,
.prompt-editor,
.modal-card {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.62);
  border-radius: 14px;
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(18px) saturate(1.12);
}

.table-wrap,
.chats-layout,
.orders-list,
.agents-settings-page {
  animation: adminFadeUp .44s cubic-bezier(.2,.8,.2,1) both;
}

thead {
  background: rgba(248, 250, 249, 0.86);
  backdrop-filter: blur(12px);
}

tbody tr:hover,
.chat-item:hover {
  background: rgba(255,255,255,0.46);
}

.channels {
  gap: 6px;
  padding: 10px 10px 13px;
  background:
    linear-gradient(90deg, transparent 0, transparent calc(100% - 44px), rgba(34, 41, 45, 0.15) 100%),
    linear-gradient(180deg, rgba(255,255,255,0.42), rgba(255,255,255,0.08));
  scrollbar-width: thin;
  scrollbar-color: rgba(31, 38, 42, 0.46) rgba(255,255,255,0.28);
}

.channels::-webkit-scrollbar {
  height: 9px;
}

.channels::-webkit-scrollbar-track {
  margin: 0 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,255,255,0.3), rgba(156,166,168,0.2));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.62);
}

.channels::-webkit-scrollbar-thumb {
  border: 2px solid rgba(236, 240, 239, 0.72);
  border-radius: 999px;
  background:
    linear-gradient(90deg, #f7faf9, #6d777c 45%, #20262a 100%);
  box-shadow: 0 3px 10px rgba(26, 32, 36, 0.18);
}

.channels::-webkit-scrollbar-thumb:hover {
  background:
    linear-gradient(90deg, #ffffff, #515b61 45%, #12171a 100%);
}

.channel {
  border-radius: 999px;
  background: rgba(255,255,255,0.35);
  border-color: rgba(255,255,255,0.62);
  font-weight: 700;
  white-space: nowrap;
}

.channel[data-channel="web"] span {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #15191d, #747e82);
  font-size: 10px;
  letter-spacing: .04em;
}

.global-pause-toggle.active {
  background: rgba(255, 244, 221, 0.72);
}

.chat-item {
  margin: 6px 8px;
  border: 1px solid transparent;
  border-radius: 12px;
}

.chat-item.active {
  border-color: rgba(33, 39, 43, 0.18);
  background: rgba(255,255,255,0.56);
  box-shadow: inset 3px 0 0 var(--lead-color, #2f363a);
}
.chat-item.lead-needs_reply { --lead-color: #1d4ed8; border-left: 3px solid var(--lead-color); }
.chat-item.lead-overdue { --lead-color: #b91c1c; border-left: 3px solid var(--lead-color); }
.chat-item.lead-hot { --lead-color: #7f1d1d; border-left: 3px solid var(--lead-color); }
.chat-item.lead-order_active { --lead-color: #047857; border-left: 3px solid var(--lead-color); }
.chat-item.lead-waiting_customer { --lead-color: #b7791f; border-left: 3px solid var(--lead-color); }
.chat-item.lead-order_done { --lead-color: #15803d; border-left: 3px solid var(--lead-color); }
.chat-item.lead-lost,
.chat-item.lead-order_cancelled { --lead-color: #9f2432; border-left: 3px solid var(--lead-color); }

.chat-item .avatar {
  background: conic-gradient(from 210deg, #ffffff, #8f999d, #232a2f, #dfe4e3, #ffffff);
  color: #15191d;
  border: 1px solid rgba(255,255,255,0.74);
}

.chat-channel-badge {
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35);
}
.chat-channel-badge.web { background: linear-gradient(135deg, #13171b, #727b80); }
.chat-channel-badge.vk { background: linear-gradient(135deg, #2575cf, #0b4f98); }
.chat-channel-badge.tg { background: linear-gradient(135deg, #31a9da, #1b7ea9); }

.chat-header,
.section-title-row,
.prompt-editor-head,
.modal-card header {
  background: linear-gradient(180deg, rgba(255,255,255,0.42), rgba(255,255,255,0.04));
}

.chat-messages {
  background:
    radial-gradient(circle at 20% 8%, rgba(255,255,255,0.5), transparent 18rem),
    linear-gradient(135deg, rgba(255,255,255,0.18), rgba(172,181,181,0.13));
}

.bubble {
  border: 1px solid rgba(255,255,255,0.44);
  box-shadow: 0 10px 24px rgba(38, 46, 50, 0.08);
}

.bubble.user {
  background: rgba(255,255,255,0.74);
}

.bubble.assistant {
  background: linear-gradient(135deg, #22282d, #687277);
}

.bubble.tool.agent-tool-bubble,
.bubble.tool {
  background: rgba(235, 250, 244, 0.78);
  border-color: rgba(47, 111, 90, 0.18);
  color: #19533f;
}

.chat-composer {
  background: rgba(247, 249, 248, 0.68);
  backdrop-filter: blur(14px);
}

.cart-customer-details,
.order-card,
.cart-block,
.cart-item-row,
.order-item-edit,
.model-picker-icon,
.prompt-badge,
.message-media-item {
  background: rgba(255,255,255,0.5);
}

.modal {
  background: rgba(23, 28, 31, 0.42);
  backdrop-filter: blur(8px);
}

.modal-card {
  overflow: hidden;
}

.prompt-text {
  background: rgba(255,255,255,0.74);
}

@keyframes adminFadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .brand {
    min-width: 0;
  }
  .tabs {
    order: 3;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  .topbar-right {
    margin-left: auto;
  }
  main {
    padding: 12px;
  }
  .channels {
    overflow-x: auto;
  }
}
