:root {
  color-scheme: light;
  --bg: #f4f2f8;
  --panel: #ffffff;
  --panel-soft: #faf9fc;
  --line: #e7e2ef;
  --text: #241e2d;
  --muted: #7b7188;
  --primary: #6f4ea2;
  --primary-dark: #56377f;
  --primary-soft: #eee7f8;
  --success: #2f8f67;
  --warning: #c9882f;
  --danger: #b94b59;
  --shadow: 0 12px 35px rgba(45, 30, 63, 0.08);
  --radius: 16px;
}

/* One palette owner; light-dark pairs below preserve the existing light appearance. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #19161f;
  --panel: #211d29;
  --panel-soft: #282331;
  --line: #4a4057;
  --text: #eee9f5;
  --muted: #b9adc9;
  --primary: #b799e0;
  --primary-dark: #d3baf0;
  --primary-soft: #382d48;
  --success: #87d2ad;
  --warning: #e5ba72;
  --danger: #f0a4b3;
  --shadow: 0 12px 35px rgba(0, 0, 0, .3);
}
:root[data-theme="dark"] .topbar { background: rgba(33, 29, 41, .96); }
:root[data-theme="dark"] .btn-primary,
:root[data-theme="dark"] .icon-btn.primary,
:root[data-theme="dark"] .stage-pill.active,
:root[data-theme="dark"] .unread-badge { background: #6f4ea2; color: #fff; }
:root[data-theme="dark"] .btn-primary:hover { background: #7956a9; }
:root[data-theme="dark"] .message-critical-error,
:root[data-theme="dark"] .tiny-btn,
:root[data-theme="dark"] .intelligence-summary > div { background: var(--panel); }
:root[data-theme="dark"] .error-journal-badge { background: #983e52; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.app-shell { height: 100vh; display: flex; flex-direction: column; }
.topbar {
  min-height: 52px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 18px;
  background: rgba(255,255,255,0.95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  z-index: 10;
}
.brand { min-height: 44px; display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #7c5ab0, #4f326f);
  color: white; font-size: 17px;
  box-shadow: 0 8px 20px rgba(95, 64, 142, .25);
}
.brand-title { font-weight: 800; letter-spacing: .08em; font-size: 14px; }
.brand-subtitle { font-size: 10px; color: var(--muted); margin-top: 1px; }
.topbar-actions {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
}
.topbar-actions > * { flex: 0 0 auto; }
.topbar-actions .btn { min-height: 34px; padding: 7px 10px; font-size: 13px; white-space: nowrap; }
.header-disclosure-btn[aria-expanded="true"] { border-color: light-dark(#cfc3de, #405e86); background: var(--primary-soft); color: var(--primary-dark); }
.disclosure-chevron { display: inline-block; font-size: 14px; line-height: 1; transition: transform .16s ease; }
[aria-expanded="true"] > .disclosure-chevron { transform: rotate(180deg); }
.topbar-status-hidden { display: none !important; }
.topbar-drawer {
  order: 10;
  flex: 1 0 100% !important;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 0 1px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}
.topbar-drawer > * { flex: 0 0 auto; }
.topbar-drawer .btn { min-height: 34px; padding: 7px 10px; font-size: 12px; }
.mode-switch { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: light-dark(#f6f2f8, #24212c); }
.mode-switch-btn { border: 0; background: transparent; color: var(--muted); border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.mode-switch-btn:disabled { cursor: wait; opacity: .58; }
.mode-switch-btn.active { background: light-dark(#fff, #24212c); color: var(--primary); box-shadow: 0 2px 8px rgba(40,25,55,.12); }
.mode-switch-btn.active[data-automation-mode="automatic"] { background: light-dark(#e8f7ea, #203b32); color: light-dark(#19632b, #93dbb5); }
.conversation-mode-switch { background: light-dark(#f2f4fb, #24212c); border-color: light-dark(#dfe3f2, #405e86); }
.mode-switch-btn.active[data-conversation-mode="system-v2"] { background: light-dark(#e9e6ff, #24324b); color: light-dark(#5136a5, #a7c4f1); }
.mode-switch-btn.active[data-conversation-mode="thought"] { background: light-dark(#fff0d5, #423521); color: light-dark(#8a510b, #f1cc89); }
.mode-switch-btn.active[data-conversation-mode="upsell"] { background: light-dark(#e5f7ea, #203b32); color: light-dark(#176b35, #93dbb5); }
.mode-switch-btn.active[data-conversation-mode="system"] { color: light-dark(#536174, #a7c4f1); }
.automation-console { min-height: 27px; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 4px 16px; border-bottom: 1px solid var(--line); background: light-dark(#fbf9fc, #24212c); color: var(--muted); font-size: 10px; }
.automation-console-mode { border-radius: 999px; padding: 3px 8px; background: light-dark(#eee7f3, #24212c); color: var(--primary); font-weight: 800; }
.automation-console.automatic .automation-console-mode { background: light-dark(#dff3e3, #203b32); color: light-dark(#17602a, #93dbb5); }
.automation-console-error { color: var(--danger); font-weight: 700; }
.server-resources {
  min-height: 33px; display: flex; align-items: center; flex-wrap: wrap; gap: 7px 12px;
  padding: 4px 16px; border-bottom: 1px solid var(--line); background: light-dark(#fff, #24212c);
  color: var(--muted); font-size: 10px;
}
.server-resources-title { color: var(--text); font-weight: 850; letter-spacing: .02em; }
.server-resource-metric { display: grid; grid-template-columns: 26px 64px minmax(112px, auto); align-items: center; gap: 6px; }
.server-resource-metric > span { font-weight: 750; color: light-dark(#6f6679, #d0b5f2); }
.server-resource-metric > strong { color: var(--text); font-size: 10px; font-weight: 760; white-space: nowrap; }
.server-resource-track { width: 64px; height: 5px; overflow: hidden; border-radius: 999px; background: light-dark(#ece8f0, #24212c); }
.server-resource-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--success); transition: width .35s ease, background .2s ease; }
.server-resource-metric.warning .server-resource-track i { background: var(--warning); }
.server-resource-metric.critical .server-resource-track i { background: var(--danger); }
.server-resource-metric.warning > strong { color: light-dark(#9a651e, #f1cc89); }
.server-resource-metric.critical > strong { color: var(--danger); }
.server-passive-badge { border-radius: 999px; padding: 5px 9px; background: light-dark(#e8edf8, #24324b); color: light-dark(#3f5688, #a7c4f1); font-weight: 800; white-space: nowrap; }
.server-resource-warning { border-radius: 9px; padding: 5px 9px; background: light-dark(#fff1d9, #423521); color: light-dark(#925d13, #f1cc89); font-weight: 800; }
.server-resource-warning.critical { background: light-dark(#fde7e9, #452932); color: light-dark(#a63846, #f0a8b6); }
.server-resource-updated { margin-left: auto; color: light-dark(#9a91a3, #d0b5f2); font-size: 9px; white-space: nowrap; }
.local-badge { font-size: 11px; color: var(--primary-dark); background: var(--primary-soft); padding: 5px 8px; border-radius: 999px; }
.error-journal-button { white-space: nowrap; }
.error-journal-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center; background: var(--danger); color: #fff; font-size: 11px; font-weight: 800; }

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 650;
  transition: .16s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 8px 18px rgba(111,78,162,.18); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: light-dark(#fff, #24212c); border: 1px solid var(--line); color: var(--text); }
.btn-secondary:hover { border-color: light-dark(#cfc3de, #405e86); background: var(--panel-soft); }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: light-dark(#fff0f2, #31283f); }
.btn-text { background: transparent; color: var(--primary); padding: 8px; }
.full-width { width: 100%; }
.file-label { cursor: pointer; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--line); background: light-dark(#fff, #24212c); color: var(--text);
  display: grid; place-items: center; font-size: 18px;
}
.icon-btn:hover { background: var(--panel-soft); }
.icon-btn.primary { background: var(--primary); color: #fff; border-color: transparent; }

.workspace {
  position: relative;
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 310px minmax(480px, 1fr) 340px;
  gap: 1px;
  background: var(--line);
  transition: grid-template-columns .2s ease;
}
.clients-panel, .conversation-panel, .details-panel { background: var(--panel); min-height: 0; }
.clients-panel { position: relative; display: flex; flex-direction: column; overflow: hidden; }
.panel-header { padding: 12px 14px 8px; display: flex; align-items: center; justify-content: space-between; }
.panel-header h1 { margin: 0; font-size: 18px; }
.panel-header p { margin: 2px 0 0; font-size: 11px; color: var(--muted); }
.panel-header-actions { display: flex; align-items: center; gap: 7px; }
.statistics-toggle-btn { color: var(--primary); font-size: 18px; font-weight: 800; }
.client-source-tabs {
  margin: 0 12px 8px;
  padding: 3px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: light-dark(#f5f3f7, #24212c);
}
.client-source-tab {
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}
.client-source-tab span {
  display: inline-flex;
  min-width: 20px;
  height: 20px;
  margin-left: 4px;
  padding: 0 6px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(103,78,132,.1);
  font-size: 10px;
}
.client-source-tab.active {
  border-color: light-dark(#d7cae5, #405e86);
  background: light-dark(#fff, #24212c);
  color: var(--primary-dark);
  box-shadow: 0 3px 10px rgba(48,32,67,.07);
}
.client-source-tab.active span { background: var(--primary-soft); color: var(--primary-dark); }
.client-statistics-drawer {
  position: absolute; inset: 0; z-index: 18; display: flex; flex-direction: column;
  overflow-y: auto; padding: 20px 16px 18px; background: light-dark(#fbfafc, #24212c);
  transform: translateX(-102%); visibility: hidden;
  transition: transform .22s ease, visibility 0s linear .22s;
  box-shadow: 14px 0 34px rgba(40,25,55,.12);
}
.client-statistics-drawer.open {
  transform: translateX(0); visibility: visible;
  transition: transform .22s ease, visibility 0s;
}
.statistics-drawer-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.statistics-drawer-header h2 { margin: 0; font-size: 20px; }
.statistics-drawer-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.statistics-section { margin-top: 22px; }
.statistics-section h3 { margin: 0 0 9px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.statistics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.statistics-card {
  min-width: 0; min-height: 92px; padding: 12px; border: 1px solid var(--line);
  border-radius: 14px; background: light-dark(#fff, #24212c); display: flex; flex-direction: column; justify-content: space-between;
}
.statistics-card strong { display: block; margin-top: 10px; font-size: 24px; line-height: 1; overflow-wrap: anywhere; }
.statistics-card-label { color: var(--muted); font-size: 11px; line-height: 1.3; }
.statistics-card-label i { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; }
.statistics-card.new-clients { border-color: light-dark(#b9d9aa, #3e725c); background: light-dark(#f5fbf2, #24212c); }
.statistics-card.new-clients i { background: #5f963f; }
.statistics-card.returning-clients { border-color: light-dark(#b8daf0, #405e86); background: light-dark(#f2f9fd, #24212c); }
.statistics-card.returning-clients i { background: #55a9dc; }
.statistics-card.usage-card strong { font-size: 20px; color: light-dark(#5f4682, #a7c4f1); }
.statistics-card.cost-card strong { font-size: 17px; color: light-dark(#28765d, #93dbb5); }
.statistics-sales-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.statistics-card.sales-card { min-height: 104px; padding: 10px 8px; }
.statistics-card.sales-card strong { margin: 8px 0 5px; font-size: 23px; }
.sales-card-revenue { color: light-dark(#28765d, #93dbb5); font-size: 11px; font-weight: 750; line-height: 1.25; overflow-wrap: anywhere; }
.statistics-card.tarot-sales-card { border-color: light-dark(#d8c9e7, #405e86); background: light-dark(#faf7fd, #24212c); }
.statistics-card.additional-sales-card { border-color: light-dark(#c5d9ed, #405e86); background: light-dark(#f6faff, #24212c); }
.statistics-card.other-sales-card { border-color: light-dark(#d8dfbe, #3e725c); background: light-dark(#fafcf4, #24212c); }
.statistics-sales-history {
  margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; background: light-dark(#fff, #24212c); overflow: hidden;
}
.statistics-sales-history summary {
  cursor: pointer; padding: 11px 12px; color: var(--text); font-size: 11px; font-weight: 750; user-select: none;
}
.statistics-sales-history[open] summary { border-bottom: 1px solid var(--line); }
.statistics-sales-history-list { max-height: 360px; overflow-y: auto; }
.statistics-sales-day { padding: 10px 12px; border-bottom: 1px solid light-dark(#eeeaf2, #4a4255); }
.statistics-sales-day:last-child { border-bottom: 0; }
.statistics-sales-day-date { margin-bottom: 6px; color: var(--text); font-size: 11px; font-weight: 800; }
.statistics-sales-day-line { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 10px; line-height: 1.55; }
.statistics-sales-day-line span:last-child { color: var(--text); font-weight: 700; text-align: right; }
.statistics-sales-empty { margin: 0; padding: 14px 12px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.statistics-provider-breakdown {
  margin-top: 10px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 11px;
  background: light-dark(#fff, #24212c); color: var(--muted); font-size: 10px; line-height: 1.55;
}
.statistics-provider-breakdown strong { color: var(--text); font-weight: 750; }
.statistics-note { margin: auto 0 0; padding-top: 22px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.statistics-updated { margin: 8px 0 0; color: var(--muted); font-size: 10px; }
.search-stack { padding: 0 12px 7px; display: grid; gap: 5px; }
.client-search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.client-filters-panel { display: grid; gap: 6px; }
.filters-toggle-btn { min-width: 80px; padding: 6px 8px; font-size: 10px; }
.search-box {
  height: 34px; border: 1px solid var(--line); border-radius: 9px;
  display: flex; align-items: center; gap: 7px; padding: 0 9px; background: var(--panel-soft);
}
.search-box input { border: 0; outline: 0; background: transparent; width: 100%; color: var(--text); }
.compact-select, .field-control {
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 9px;
  background: light-dark(#fff, #24212c); color: var(--text); outline: none;
}
.compact-select:focus, .field-control:focus, input:focus, textarea:focus { border-color: light-dark(#9b83bd, #405e86); box-shadow: 0 0 0 3px rgba(111,78,162,.09); }
.automation-chat-legend { display: flex; flex-wrap: wrap; gap: 4px 8px; padding: 1px 2px 0; color: var(--muted); font-size: 9px; }
.automation-legend-item { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.automation-legend-item i { width: 7px; height: 7px; border-radius: 50%; background: #a49cac; }
.automation-legend-item.processing i { background: #2d8a62; }
.automation-legend-item.queued i { background: #5277b8; }
.automation-legend-item.missed i { background: #d47b23; }
.automation-legend-item strong { color: var(--text); }
.duplicate-check-card {
  margin: 0 14px 12px;
  border: 1px dashed light-dark(#cbbdde, #405e86); background: light-dark(#fbf9fe, #24212c);
  padding: 12px; border-radius: 12px; display: flex; align-items: center; text-align: left; gap: 10px;
}
.client-filters-panel .duplicate-check-card { margin: 0; padding: 9px 10px; }
.duplicate-check-card:hover { background: var(--primary-soft); }
.duplicate-check-card strong { display: block; font-size: 13px; }
.duplicate-check-card small { display: block; color: var(--muted); margin-top: 2px; }
.duplicate-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.chevron { margin-left: auto; font-size: 22px; color: var(--muted); }
/* app.js owns stable item anchors; browser anchoring must not compensate a second time. */
.client-list, .messages { overflow-anchor: none; }
.client-list { overflow-y: auto; padding: 0 8px 16px; }
.client-export-selection-bar { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 6px 10px; font-size: 11px; }
.client-export-row { display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: center; gap: 4px; }
.client-export-row > input { margin: 0; width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }
.client-export-row > .client-card { min-width: 0; }
#frozenExportClientSummary { overflow-wrap: anywhere; }
.client-list-more,
.message-history-more {
  display: block;
  width: calc(100% - 8px);
  margin: 8px auto 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: light-dark(#fff, #24212c);
  color: var(--primary);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.client-list-more:hover,
.message-history-more:hover { background: var(--primary-soft); }
.client-card {
  background: var(--panel); color: var(--text);
  padding: 9px 8px; border-radius: 11px; display: grid; grid-template-columns: 36px minmax(0,1fr) auto; gap: 8px;
  align-items: center; margin-bottom: 3px; cursor: pointer; border: 1px solid transparent;
  /* Pagination bounds DOM size. Exact card heights keep restored scroll anchors stable. */
}
.client-card:hover { background: var(--panel-soft); }
.client-card.active { background: var(--primary-soft); border-color: light-dark(#d8cae9, #405e86); }
.client-card.has-unread:not(.active) { background: light-dark(#fbf7ff, #24212c); }
.client-card.has-unread .client-name { font-weight: 800; }
.avatar { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: linear-gradient(145deg,#8f73b8,#63418d); color: #fff; font-weight: 800; }
.client-card.today-new .avatar, .avatar.today-new { background: linear-gradient(145deg,#79ad58,#4f8531); }
.client-card.today-returning .avatar, .avatar.today-returning { background: linear-gradient(145deg,#72bce6,#4197cc); }
.client-main { min-width: 0; }
.client-name-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.client-name { flex: 1 1 auto; min-width: 0; font-weight: 720; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-online { flex: 0 0 auto; color: var(--muted); font-size: 10px; white-space: nowrap; }
.client-meta { margin-top: 5px; color: var(--muted); font-size: 12px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; min-width: 0; }
.client-side { min-width: 24px; text-align: right; }
.client-time { font-size: 11px; color: var(--muted); }
.stage-badge { display: inline-flex; border-radius: 999px; padding: 4px 7px; font-size: 10px; background: light-dark(#f1edf5, #24212c); color: light-dark(#675977, #a7c4f1); }
.reactivation-badge { display: inline-flex; max-width: 100%; border-radius: 999px; padding: 4px 7px; font-size: 10px; font-weight: 750; background: light-dark(#fff1cf, #423521); color: light-dark(#875600, #f1cc89); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reactivation-badge.pending { background: light-dark(#eef2ff, #24324b); color: light-dark(#4d5a91, #a7c4f1); }
.reactivation-badge.sent { background: light-dark(#e8f5ef, #203b32); color: var(--success); }
.reactivation-badge.error { background: light-dark(#fdebec, #452932); color: light-dark(#a33a42, #f0a8b6); }
.client-card.has-reactivation:not(.active) { border-color: light-dark(#efd8a5, #81643a); }
.client-card.automation-processing:not(.automation-red) { border-color: light-dark(#abd8c5, #3e725c); background: light-dark(#f1faf6, #24212c); box-shadow: inset 3px 0 0 #2d8a62; }
.client-card.automation-queued:not(.automation-red) { border-color: light-dark(#c7d4e9, #405e86); background: light-dark(#f4f7fc, #24212c); box-shadow: inset 3px 0 0 #5277b8; }
.client-card.automation-retry:not(.automation-red) { border-color: light-dark(#e7cca0, #81643a); background: light-dark(#fff9ed, #31283f); box-shadow: inset 3px 0 0 #c28328; }
.client-card.automation-missed:not(.automation-red) { border-color: light-dark(#dda15d, #81643a); border-style: dashed; background: light-dark(#fff8ee, #31283f); box-shadow: inset 3px 0 0 #d47b23; }
.client-card.automation-disabled:not(.automation-red) { border-color: light-dark(#d6d1dc, #4a4255); background: light-dark(#f7f6f8, #24212c); box-shadow: inset 3px 0 0 #8d8496; }
.automation-task-badge { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; border-radius: 999px; padding: 4px 7px; font-size: 10px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.automation-task-badge.processing { background: light-dark(#dcefe7, #203b32); color: light-dark(#236d4f, #93dbb5); }
.automation-task-badge.queued { background: light-dark(#e4ebf7, #24324b); color: light-dark(#3d5f98, #a7c4f1); }
.automation-task-badge.retry { background: light-dark(#f9e9cf, #423521); color: light-dark(#895816, #f1cc89); }
.automation-task-badge.priority { background: light-dark(#ede4fa, #24324b); color: light-dark(#65428f, #a7c4f1); }
.automation-task-badge.missed { background: light-dark(#ffead2, #423521); color: light-dark(#985715, #f1cc89); }
.automation-task-badge.disabled { background: light-dark(#e9e6ed, #24212c); color: light-dark(#675f70, #d0b5f2); }
.automation-task-pulse { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #2d8a62; animation: automationTaskPulse 1.5s ease-in-out infinite; }
@keyframes automationTaskPulse { 0%, 100% { opacity: .45; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.15); } }
.unread-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 23px; height: 23px; padding: 0 6px; border-radius: 999px; background: var(--primary); color: #fff; font-size: 10px; font-weight: 800; line-height: 1; box-shadow: 0 3px 8px rgba(84,52,122,.18); }
.client-card.active .unread-badge { background: var(--primary-dark); }
.empty-list { text-align: center; color: var(--muted); padding: 36px 18px; font-size: 14px; }

.conversation-panel { position: relative; }
.empty-state { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; text-align: center; }
.empty-illustration { width: 78px; height: 78px; border-radius: 24px; display: grid; place-items: center; font-size: 34px; background: var(--primary-soft); color: var(--primary); }
.empty-state h2 { margin: 18px 0 8px; }
.empty-state p { margin: 0 0 18px; color: var(--muted); }
.conversation-content { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.conversation-header { position: relative; z-index: 5; flex: 0 0 auto; min-height: 52px; padding: 6px 12px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 8px; overflow: visible; }
.conversation-person { flex: 1 1 260px; display: flex; align-items: center; gap: 7px; min-width: 180px; }
.conversation-person > div { min-width: 0; }
.conversation-header .avatar { width: 32px; height: 32px; flex: 0 0 32px; border-radius: 9px; }
.conversation-person h2 { margin: 0; font-size: 15px; line-height: 1.15; }
.name-row { display: flex; align-items: center; gap: 6px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); }
.conversation-profile-meta, .conversation-usage-meta { display: flex; align-items: center; gap: 6px; min-width: 0; min-height: 13px; }
.conversation-usage-meta { margin-top: 1px; }
.conversation-person a { flex: 0 1 auto; display: inline-block; margin: 0; color: var(--primary); font-size: 9px; line-height: 1.25; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deepseek-chat-usage { flex: 1 1 auto; display: block; min-width: 0; margin: 0; color: var(--muted); font-size: 9px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation-actions { flex: 1 1 450px; min-width: 0; display: flex; align-items: center; justify-content: flex-start; flex-wrap: nowrap; gap: 5px; padding: 0 0 2px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
.conversation-actions > * { flex: 0 0 auto; }
.conversation-actions .btn { min-height: 30px; padding: 5px 8px; font-size: 11px; }
.conversation-actions .icon-btn { width: 30px; height: 30px; font-size: 15px; }
.conversation-actions::-webkit-scrollbar, .topbar-drawer::-webkit-scrollbar { height: 5px; }
.details-toggle-btn[aria-expanded="true"] { border-color: light-dark(#cfc3de, #405e86); background: var(--primary-soft); color: var(--primary-dark); }
.btn-priority-reply { border-color: light-dark(#6a4a99, #405e86); background: #6a4a99; color: #fff; white-space: nowrap; box-shadow: 0 5px 14px rgba(84,52,122,.2); }
.btn-priority-reply:hover:not(:disabled) { background: #56377f; border-color: light-dark(#56377f, #405e86); }
.btn-priority-reply:disabled { opacity: .72; cursor: wait; }
.chat-automation-toggle { white-space: nowrap; }
.chat-automation-toggle.automation-disabled { border-color: light-dark(#8fc9ad, #3e725c); background: light-dark(#eef8f3, #24212c); color: light-dark(#267052, #93dbb5); }
.avito-chat-open { text-decoration: none; white-space: nowrap; }
.stage-strip { flex: 0 0 auto; display: flex; gap: 4px; padding: 5px 12px 3px; overflow-x: auto; background: light-dark(#fbfafc, #24212c); border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.stage-strip::-webkit-scrollbar { height: 6px; }
.stage-pill { flex: 0 0 auto; font-size: 10px; border-radius: 999px; padding: 4px 7px; background: light-dark(#f0edf3, #24212c); color: light-dark(#8a8094, #d0b5f2); }
.stage-cycle-marker { flex: 0 0 auto; align-self: center; margin-left: 7px; padding-left: 12px; border-left: 1px solid light-dark(#d9cce8, #405e86); color: var(--primary); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.stage-pill.repeat-sale { background: light-dark(#f3edfb, #31283f); color: light-dark(#75598e, #a7c4f1); border: 1px solid light-dark(#e2d6ef, #405e86); }
.stage-pill.complete { background: light-dark(#e8f4ef, #24212c); color: var(--success); }
.stage-pill.active { background: var(--primary); color: #fff; font-weight: 700; }
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 22px 24px; background: linear-gradient(180deg,light-dark(#faf9fc, #24212c),light-dark(#f6f4f9, #24212c)); }
.message-history-more { max-width: 420px; }
.message-row { display: flex; margin-bottom: 14px; }
.message-row.client { justify-content: flex-start; }
.message-row.assistant, .message-row.tarologist { justify-content: flex-end; }
.message-row.note { justify-content: center; }
.message-row.admin { justify-content: center; }
.message-bubble { max-width: min(72%, 680px); padding: 12px 14px; border-radius: 15px; box-shadow: 0 5px 14px rgba(47,35,60,.05); border: 1px solid var(--line); background: light-dark(#fff, #24212c); }
.message-row.assistant .message-bubble, .message-row.tarologist .message-bubble { background: light-dark(#eee7f8, #31283f); border-color: light-dark(#d9cce8, #405e86); }
.message-row.note .message-bubble { max-width: 86%; background: light-dark(#fff8e9, #31283f); border-color: light-dark(#efdbaa, #81643a); color: light-dark(#705b2b, #f1cc89); }
.message-row.admin .message-bubble { max-width: 86%; background: light-dark(#eef3ff, #24324b); border-color: light-dark(#cbd8f1, #405e86); color: light-dark(#344d78, #a7c4f1); }
.message-row.admin .message-author { color: light-dark(#42649b, #a7c4f1); }
.message-row.critical-error .message-bubble {
  border: 2px solid light-dark(#d94b5d, #8c4b5d);
  background: linear-gradient(145deg, light-dark(#fff7f8, #24212c), light-dark(#ffecef, #452932));
  box-shadow: 0 0 0 3px rgba(217,75,93,.13), 0 8px 22px rgba(137,33,49,.12);
}
.message-row.critical-error .message-author { color: light-dark(#9e2333, #f0a8b6); }
.message-critical-error {
  display: grid;
  gap: 3px;
  margin-top: 10px;
  padding: 9px 10px;
  border: 1px solid light-dark(#efb9c1, #8c4b5d);
  border-radius: 10px;
  background: rgba(255,255,255,.72);
  color: light-dark(#8f2635, #f0a8b6);
  font-size: 11px;
  line-height: 1.4;
}
.message-critical-error strong { font-size: 11px; }
.message-critical-error span { white-space: pre-wrap; word-break: break-word; }
.message-critical-error small { color: light-dark(#ad5965, #f0a8b6); font-size: 9px; }
.message-author { font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
.message-text { white-space: pre-wrap; line-height: 1.45; word-break: break-word; }
.message-attachments { display: grid; gap: 8px; margin-top: 8px; }
.message-author + .message-attachments { margin-top: 2px; }
.message-image-link { display: block; overflow: hidden; border-radius: 11px; background: light-dark(#f1eef4, #24212c); border: 1px solid rgba(96,70,120,.12); }
.message-image-link img { display: block; width: 100%; max-width: 440px; max-height: 420px; object-fit: contain; background: light-dark(#f4f1f6, #24212c); }
.message-image-description { display: grid; gap: 5px; max-width: 440px; padding: 10px 11px; border-radius: 11px; font-size: 11px; line-height: 1.4; }
.message-image-description.done { background: light-dark(#f2f7f4, #24212c); border: 1px solid light-dark(#d7e9de, #3e725c); color: light-dark(#344a3d, #93dbb5); }
.message-image-description.pending { grid-template-columns: auto 1fr; align-items: center; background: light-dark(#f5f2f8, #24212c); border: 1px solid light-dark(#e1d9e8, #59436e); color: var(--muted); }
.message-image-description.error { background: light-dark(#fff4f4, #24212c); border: 1px solid light-dark(#efd4d7, #8c4b5d); color: light-dark(#91414d, #f0a8b6); }
.message-image-description.error span { color: light-dark(#a4616a, #f0a8b6); }
.message-image-description p { margin: 0; white-space: pre-wrap; word-break: break-word; }
.image-description-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.image-type-badge { display: inline-flex; align-items: center; padding: 3px 7px; border-radius: 999px; background: light-dark(#fff, #24212c); color: light-dark(#4e7160, #93dbb5); font-size: 9px; font-weight: 700; white-space: nowrap; }
.image-description-spinner { width: 12px; height: 12px; border: 2px solid light-dark(#d8cee2, #59436e); border-top-color: var(--primary); border-radius: 50%; animation: image-description-spin .8s linear infinite; }
@keyframes image-description-spin { to { transform: rotate(360deg); } }
.tarot-image-panel { display: grid; gap: 10px; margin-top: 11px; padding: 11px; border-radius: 12px; border: 1px solid light-dark(#d9cce8, #405e86); background: rgba(255,255,255,.72); }
.tarot-image-panel.ready { grid-template-columns: minmax(0,1fr) auto; align-items: center; }
.tarot-image-panel.ready > div, .tarot-image-panel.error > div, .tarot-image-panel.processing > div { display: grid; gap: 4px; min-width: 0; }
.tarot-image-panel strong { font-size: 11px; }
.tarot-image-panel span { color: var(--muted); font-size: 10px; line-height: 1.4; }
.tarot-image-panel.ready span, .tarot-image-info > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tarot-generate-btn { white-space: nowrap; }
.tarot-image-panel.processing { grid-template-columns: auto 1fr; align-items: center; background: light-dark(#f5f2f8, #24212c); }
.tarot-image-panel.error { grid-template-columns: minmax(0,1fr) auto; align-items: center; border-color: light-dark(#efd4d7, #8c4b5d); background: light-dark(#fff4f4, #24212c); }
.tarot-image-panel.done { padding: 0; overflow: hidden; background: light-dark(#f7f4fa, #24212c); }
.tarot-image-link { display: block; background: light-dark(#ece8f0, #24212c); }
.tarot-image-link img { display: block; width: 100%; max-height: 430px; object-fit: contain; }
.tarot-image-info { display: grid; gap: 5px; padding: 0 11px 11px; min-width: 0; }
.tarot-image-actions { display: flex; gap: 6px; margin-top: 3px; }
.tarot-image-actions a { display: inline-flex; align-items: center; text-decoration: none; }
.message-meta { margin-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 10px; }
.runtime-release-chip { display: inline-flex; align-items: center; border: 1px solid light-dark(#c9b6e8, #405e86); border-radius: 999px; padding: 1px 6px; color: light-dark(#64448c, #a7c4f1); background: light-dark(#f7f1ff, #31283f); font-weight: 700; white-space: nowrap; }
.message-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.tiny-btn { border: 0; background: rgba(255,255,255,.65); border-radius: 7px; padding: 4px 7px; color: var(--primary-dark); font-size: 10px; }
.tiny-btn:hover { background: light-dark(#fff, #24212c); }
.tiny-btn:disabled { cursor: wait; opacity: .55; }
.draft-cancel-btn { color: light-dark(#9a3f3f, #f0a8b6); }
.draft-regenerate-btn { color: light-dark(#315f8d, #a7c4f1); }
.draft-label { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; color: var(--primary); font-weight: 700; }
.composer-wrap { flex: 0 0 auto; border-top: 1px solid var(--line); background: light-dark(#fff, #24212c); }
#messageInput { background: var(--panel); color: var(--text); }
.composer-tabs { display: flex; gap: 3px; padding: 4px 12px 0; }
.composer-tab { border: 0; background: transparent; color: var(--muted); padding: 4px 7px; border-radius: 7px; font-size: 11px; }
.composer-tab.active { color: var(--primary-dark); background: var(--primary-soft); font-weight: 700; }
.composer-tab.admin-tab.active { color: light-dark(#315c9e, #a7c4f1); background: light-dark(#eaf1ff, #24324b); }
.admin-command-panel { display: flex; align-items: center; gap: 6px; padding: 9px 18px 3px; overflow-x: auto; }
.admin-command-panel > span { flex: 0 0 auto; color: var(--muted); font-size: 10px; }
.admin-command-scope { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; margin-right: 6px; }
.admin-command-scope select { border: 1px solid light-dark(#ccd9ef, #405e86); border-radius: 8px; padding: 5px 8px; background: light-dark(#fff, #24212c); color: light-dark(#315c9e, #a7c4f1); font: inherit; font-weight: 700; }
.admin-command-panel button { flex: 0 0 auto; border: 1px solid light-dark(#ccd9ef, #405e86); border-radius: 999px; padding: 5px 8px; background: light-dark(#f1f5ff, #24324b); color: light-dark(#42649b, #a7c4f1); font-size: 10px; cursor: pointer; }
.admin-command-panel button:hover { background: light-dark(#e5edff, #24324b); }
.admin-command-divider { margin-left: 5px; padding-left: 10px; border-left: 1px solid light-dark(#dce3ef, #405e86); }
.saved-admin-commands { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.saved-admin-command { display: inline-flex; align-items: stretch; flex: 0 0 auto; }
.admin-command-panel .saved-admin-command-use { border-radius: 999px 0 0 999px; padding-left: 9px; }
.admin-command-panel .saved-admin-command-delete { margin-left: -1px; border-radius: 0 999px 999px 0; padding: 5px 7px; color: light-dark(#9e3f4c, #f0a8b6); background: light-dark(#fff6f7, #24212c); }
.admin-command-panel .saved-admin-command-delete:hover { background: light-dark(#ffe9ec, #452932); }
.admin-command-panel .admin-command-add { border-style: dashed; background: light-dark(#fff, #24212c); font-weight: 700; }
.saved-admin-commands-empty { color: var(--muted); font-size: 10px; white-space: nowrap; }
.admin-command-form-grid { grid-template-columns: 1fr; }
.admin-correct-btn { color: light-dark(#315c9e, #a7c4f1); background: light-dark(#edf3ff, #24324b); }
.composer { padding: 4px 12px 7px; }
.composer textarea { width: 100%; resize: vertical; max-height: 84px; min-height: 38px; border: 1px solid var(--line); border-radius: 9px; padding: 7px 9px; outline: none; color: var(--text); font-size: 14px; }
.composer-footer { margin-top: 4px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.composer-hint { font-size: 9px; color: var(--muted); max-width: 60%; }
.composer-buttons { display: flex; gap: 8px; }
.composer-buttons .btn { min-height: 30px; padding: 5px 9px; font-size: 11px; white-space: nowrap; }

.details-panel { position: relative; overflow-y: auto; transition: opacity .16s ease, transform .2s ease, visibility .16s ease; }
.details-panel-close { position: absolute; top: 14px; right: 14px; z-index: 2; }
.details-empty { height: 100%; display: grid; place-items: center; color: var(--muted); padding: 24px; text-align: center; }
.details-content { padding-bottom: 20px; }
.details-header { padding: 20px 64px 14px 18px; display: flex; justify-content: space-between; align-items: start; border-bottom: 1px solid var(--line); }
.details-header h2 { margin: 0; font-size: 18px; }
.details-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.details-section { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.details-section h3 { margin: 0 0 10px; font-size: 14px; }
.intelligence-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.intelligence-summary > div { min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255, 255, 255, .55); }
.intelligence-summary span, .intelligence-summary strong { display: block; }
.intelligence-summary span { margin-bottom: 3px; color: var(--muted); font-size: 11px; }
.intelligence-summary strong { overflow-wrap: anywhere; font-size: 12px; line-height: 1.35; }
.intelligence-summary .intelligence-wide { grid-column: 1 / -1; }
.intelligence-control-points { display: grid; gap: 7px; margin-top: 10px; }
.intelligence-control-point { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 9px; background: light-dark(#f5f3ee, #24212c); font-size: 12px; }
.intelligence-control-point > span { color: light-dark(#75634d, #f1cc89); font-size: 10px; text-transform: uppercase; }
.intelligence-control-point.due, .intelligence-control-point.reached { background: light-dark(#fff2dc, #423521); }
.intelligence-control-point small { color: var(--muted); }
.grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.field-control { width: 100%; }
.field-help { margin-top: 7px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.field-help.error { color: var(--danger); }
.note-control { resize: vertical; }
.detail-row { display: grid; grid-template-columns: 110px minmax(0,1fr); gap: 10px; padding: 8px 0; border-bottom: 1px dashed light-dark(#eee9f3, #4a4255); }
.detail-row:last-child { border-bottom: 0; }
.detail-row span { font-size: 12px; color: var(--muted); }
.detail-row strong { font-size: 12px; font-weight: 650; text-align: right; word-break: break-word; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.section-title-row h3 { margin: 0; }
.section-title-row .muted { font-size: 10px; }
.profile-analysis-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; text-align: right; }
.profile-analysis-actions .analysis-error { color: var(--danger); }
.btn-compact { padding: 4px 6px; font-size: 11px; }
.related-people-list { display: grid; gap: 10px; }
.related-people-empty { padding: 13px; border: 1px dashed light-dark(#d7cde2, #59436e); border-radius: 11px; background: light-dark(#fbf9fd, #24212c); color: var(--muted); font-size: 11px; line-height: 1.45; }
.related-person-card { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-soft); }
.related-person-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.related-person-header strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.related-person-remove { width: 26px; height: 26px; flex: 0 0 26px; border: 0; border-radius: 8px; background: light-dark(#fff0f2, #31283f); color: var(--danger); font-size: 18px; line-height: 1; }
.related-person-remove:hover { background: light-dark(#faddE2, #452932); }
.check-row { display: flex; align-items: center; gap: 9px; padding: 7px 0; font-size: 12px; }
.check-row input { accent-color: var(--primary); width: 15px; height: 15px; }
.stats-card { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; background: light-dark(#faf9fc, #24212c); }
.stats-card div { background: light-dark(#fff, #24212c); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.stats-card div:last-child { grid-column: 1 / -1; }
.stats-card span { display: block; font-size: 10px; color: var(--muted); }
.stats-card strong { display: block; margin-top: 4px; font-size: 14px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(27,20,35,.48); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { width: min(760px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; background: light-dark(#fff, #24212c); border-radius: 18px; box-shadow: 0 26px 80px rgba(24,15,34,.25); }
.small-modal { width: min(520px, 100%); }
.message-editor-modal { width: min(920px, 100%); overflow: hidden; }
.message-editor-body { padding: 18px 22px 4px; }
.message-editor-body textarea { display: block; width: 100%; min-height: min(56vh, 540px); max-height: calc(100vh - 250px); resize: vertical; border: 1px solid var(--line); border-radius: 12px; padding: 16px; outline: none; color: var(--text); background: light-dark(#fff, #24212c); font: inherit; font-size: 14px; line-height: 1.55; }
.message-editor-body textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(113,75,139,.12); }
.message-editor-meta { display: flex; justify-content: space-between; gap: 12px; padding: 8px 2px 0; color: var(--muted); font-size: 10px; }
.modal-header { padding: 20px 22px 14px; display: flex; align-items: start; justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 20px; }
.modal-header p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.form-grid { padding: 20px 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid label { display: grid; gap: 6px; }
.form-grid label span { font-size: 12px; color: var(--muted); }
.form-grid input, .form-grid select, .form-grid textarea, .quick-check-form input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; outline: none; color: var(--text); background: light-dark(#fff, #24212c);
}
.full-span { grid-column: 1 / -1; }
.modal-footer { padding: 14px 22px 20px; display: flex; justify-content: flex-end; gap: 8px; }
.duplicate-alert { margin: 0 22px; padding: 12px; border-radius: 10px; background: light-dark(#fff4e5, #423521); border: 1px solid light-dark(#f0d2a0, #81643a); color: light-dark(#755523, #f1cc89); font-size: 13px; }
.quick-check-form { padding: 20px 22px 12px; display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.quick-result { padding: 0 22px 22px; }
.result-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--panel-soft); }
.result-card.found { border-color: light-dark(#e4c887, #81643a); background: light-dark(#fff9ec, #31283f); }
.result-card.clear { border-color: light-dark(#b9decf, #3e725c); background: light-dark(#f0faf6, #24212c); }
.result-card h3 { margin: 0 0 7px; font-size: 14px; }
.result-card p { margin: 4px 0; color: var(--muted); font-size: 12px; }
.result-card .btn { margin-top: 10px; }

.broadcasts-modal { width: min(1180px, 100%); overflow: hidden; }
.error-journal-modal { width: min(1120px, 100%); height: min(860px, calc(100vh - 40px)); display: flex; flex-direction: column; overflow: hidden; }
.action-history-modal { width: min(1180px, 100%); }
.action-history-modal .error-journal-body { min-height: 0; padding: 16px 20px 22px; overflow-y: auto; }
.action-history-toolbar { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)) auto; gap: 8px; margin: 12px 0; }
.action-history-list { display: grid; gap: 10px; }
.action-history-entry.blocked, .action-history-entry.failed, .action-history-entry.handed_off { border-color: light-dark(#e6b7bd, #8c4b5d); }
.action-history-decision { display: grid; gap: 4px; margin-top: 9px; padding: 9px 11px; border-radius: 10px; background: light-dark(#f7f4fa, #24212c); }
.action-history-decision span, .action-history-decision small { color: var(--muted); }
.action-history-runtime code { overflow-wrap: anywhere; }
.action-history-runtime ul { display: grid; gap: 4px; padding-left: 18px; }
.action-history-runtime li { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 8px; }
.action-history-more-wrap { display: flex; justify-content: center; padding-top: 12px; }
#actionHistoryBtn.feature-disabled { opacity: .68; border-style: dashed; }
.processing-chain-entry { border-left: 4px solid var(--accent); }
.processing-chain-source { white-space: pre-wrap; margin: 10px 0; padding: 10px; border-radius: 10px; background: var(--surface-soft); }
.processing-chain-timeline { display: grid; gap: 6px; margin: 10px 0 12px; padding-left: 22px; }
.processing-chain-entry pre { max-height: 420px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11px; }
.processing-chain-entry .action-history-runtime li { display: grid; gap: 3px; margin-bottom: 8px; }
#testGroupsBtn.feature-disabled { opacity: .68; border-style: dashed; }
#autonomyLabBtn.feature-disabled { opacity: .68; border-style: dashed; }

.test-groups-modal { width: min(1180px, calc(100vw - 32px)); }
.test-groups-body { display: grid; grid-template-columns: minmax(300px, .82fr) minmax(420px, 1.4fr); gap: 18px; }
.test-group-create-panel,
.test-group-list-panel { min-width: 0; }
.test-group-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.test-group-form-grid label { display: grid; gap: 6px; color: var(--muted); font-size: .88rem; }
.test-group-form-grid .test-group-draft { display: flex; align-items: center; gap: 8px; align-self: end; min-height: 42px; }
.test-group-entry { align-items: flex-start; gap: 14px; }
.test-group-entry-main { min-width: 0; flex: 1; }
.test-group-entry-main p { margin: 6px 0; color: var(--muted); }
.test-group-runtime-chips { display: grid; gap: 5px; }
.test-group-runtime-chips code { overflow-wrap: anywhere; font-size: .73rem; }
.test-group-entry-actions { display: flex; flex-direction: column; gap: 7px; align-items: stretch; max-width: 230px; }

@media (max-width: 920px) {
  .test-groups-body { grid-template-columns: 1fr; }
  .test-group-form-grid { grid-template-columns: 1fr; }
  .test-group-entry { flex-direction: column; }
  .test-group-entry-actions { max-width: none; width: 100%; }
}
.error-journal-content { min-height: 0; flex: 1; display: flex; flex-direction: column; padding: 18px 22px 22px; gap: 14px; }
.error-journal-stats { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 10px; }
.error-journal-stat { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-soft); }
.error-journal-stat strong { display: block; font-size: 21px; }
.error-journal-stat span { color: var(--muted); font-size: 12px; }
.error-journal-stat.critical strong { color: light-dark(#8f2230, #f0a8b6); }
.error-journal-stat.error strong { color: var(--danger); }
.error-journal-stat.warning strong { color: var(--warning); }
.error-journal-stat.server-running strong { color: var(--success); }
.error-journal-filters { display: grid; grid-template-columns: 150px 180px 190px minmax(220px, 1fr) auto; gap: 8px; }
.server-history-filters { grid-template-columns: 150px 180px 210px minmax(220px, 1fr) auto; }
.server-history-summary { display: flex; flex-wrap: wrap; gap: 7px; }
.server-history-summary span { padding: 5px 8px; border-radius: 999px; background: var(--panel-soft); color: var(--muted); font-size: 10px; }
.error-journal-list { min-height: 0; flex: 1; overflow-y: auto; display: grid; align-content: start; gap: 10px; padding-right: 4px; }
.error-journal-entry { border: 1px solid var(--line); border-left: 4px solid var(--warning); border-radius: 12px; padding: 13px 14px; background: light-dark(#fff, #24212c); }
.error-journal-entry.info { border-left-color: var(--success); }
.error-journal-entry.error { border-left-color: var(--danger); }
.error-journal-entry.critical { border-left-color: light-dark(#861d2c, #f0a8b6); background: light-dark(#fffafb, #24212c); }
.error-journal-entry.resolved { opacity: .68; border-left-color: light-dark(#9a93a2, #d0b5f2); }
.error-journal-entry-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.error-journal-entry-title { min-width: 0; }
.error-journal-entry-title strong { display: block; overflow-wrap: anywhere; }
.error-journal-entry-meta { margin-top: 5px; color: var(--muted); font-size: 11px; display: flex; flex-wrap: wrap; gap: 7px; }
.error-journal-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.error-journal-tag { border-radius: 999px; padding: 3px 7px; background: var(--primary-soft); color: var(--primary-dark); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.error-journal-tag.severity-critical { background: light-dark(#f8dce1, #452932); color: light-dark(#861d2c, #f0a8b6); }
.error-journal-tag.severity-error { background: light-dark(#fde8eb, #452932); color: var(--danger); }
.error-journal-tag.severity-warning { background: light-dark(#fff1da, #423521); color: light-dark(#925e17, #f1cc89); }
.error-journal-tag.severity-info { background: light-dark(#e8f5ef, #203b32); color: var(--success); }
.error-journal-context { margin-top: 10px; }
.error-journal-context summary { cursor: pointer; color: var(--primary); font-size: 12px; }
.error-journal-context pre { max-height: 260px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; padding: 10px; border-radius: 9px; background: light-dark(#f7f5f9, #24212c); color: light-dark(#50475a, #d0b5f2); font-size: 11px; }
.error-journal-resolve { flex: 0 0 auto; padding: 7px 9px; font-size: 11px; }
.error-journal-empty { padding: 36px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; }
.broadcasts-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, .85fr); max-height: calc(100vh - 145px); }
.broadcast-editor { min-width: 0; overflow-y: auto; padding-bottom: 20px; }
.broadcast-form-grid { padding: 18px 22px 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.broadcast-form-grid label { display: grid; gap: 6px; }
.broadcast-form-grid label > span { color: var(--muted); font-size: 11px; }
.broadcast-form-grid input, .broadcast-form-grid select, .broadcast-form-grid textarea, .broadcast-test-row select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; background: light-dark(#fff, #24212c); color: var(--text); outline: none;
}
.broadcast-form-grid textarea { resize: vertical; min-height: 140px; line-height: 1.45; }
.broadcast-form-grid small { color: var(--muted); font-size: 10px; }
.broadcast-safety-check { display: flex !important; border: 1px solid light-dark(#b9decf, #3e725c); border-radius: 10px; padding: 10px 12px; background: light-dark(#f0faf6, #24212c); color: light-dark(#2c7659, #93dbb5); }
.broadcast-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 22px 12px; }
.broadcast-preview { margin: 0 22px 12px; border: 1px solid var(--line); border-radius: 12px; padding: 13px; background: var(--panel-soft); color: var(--muted); font-size: 11px; }
.broadcast-preview-summary { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.broadcast-preview-summary strong { color: var(--text); font-size: 14px; }
.broadcast-preview ul { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-height: 180px; overflow-y: auto; margin: 0; padding: 0; list-style: none; }
.broadcast-preview li { display: grid; gap: 2px; border-radius: 8px; padding: 7px 9px; background: light-dark(#fff, #24212c); }
.broadcast-preview li strong { color: var(--text); }
.broadcast-preview li span { font-size: 10px; }
.broadcast-test-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 0 22px; }
.broadcast-campaigns { min-width: 0; overflow-y: auto; border-left: 1px solid var(--line); padding: 18px; background: light-dark(#fbf9fd, #24212c); }
.broadcast-campaigns .section-title-row small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.broadcast-campaign-list { display: grid; gap: 10px; margin-top: 12px; }
.broadcast-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: light-dark(#fff, #24212c); }
.broadcast-card.completed { border-color: light-dark(#b9decf, #3e725c); }
.broadcast-card.partial, .broadcast-card.review_required { border-color: light-dark(#e4c887, #81643a); background: light-dark(#fffaf0, #31283f); }
.broadcast-card.failed { border-color: light-dark(#efc8ce, #8c4b5d); background: light-dark(#fff6f7, #24212c); }
.broadcast-card-head { display: flex; justify-content: space-between; gap: 8px; }
.broadcast-card-head span { border-radius: 999px; padding: 3px 7px; background: light-dark(#eee8f5, #31283f); color: var(--primary); font-size: 9px; font-weight: 700; }
.broadcast-card p { max-height: 58px; overflow: hidden; margin: 8px 0; color: var(--muted); font-size: 11px; white-space: pre-wrap; }
.broadcast-card > small { color: var(--muted); font-size: 9px; }
.broadcast-counts { margin-top: 8px; color: var(--text); font-size: 10px; }
.broadcast-card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.broadcast-empty { border: 1px dashed var(--line); border-radius: 11px; padding: 18px; text-align: center; color: var(--muted); font-size: 11px; }
.broadcast-empty.error { border-color: light-dark(#efc8ce, #8c4b5d); color: var(--danger); }

.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  display: grid;
  width: min(260px, calc(100vw - 24px));
  max-height: calc(100vh - 36px);
  gap: 5px;
  overflow-y: auto;
  pointer-events: none;
}
.toast { width: 100%; min-width: 0; padding: 7px 9px; border-radius: 8px; background: #2d2634; color: #fff; box-shadow: 0 7px 20px rgba(45,30,63,.14); font-size: 11px; line-height: 1.3; overflow-wrap: anywhere; animation: toastIn .2s ease; }
.toast.success { background: #2c7659; }
.toast.error { background: #9e3f4c; }
.toast.warning { background: #8a651d; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (min-width: 1181px) {
  .workspace.details-collapsed { grid-template-columns: 310px minmax(480px, 1fr) 0; }
  .workspace.details-collapsed .details-panel { visibility: hidden; opacity: 0; pointer-events: none; }
}

@media (max-width: 1180px) {
  .workspace, .workspace.details-collapsed { grid-template-columns: 280px minmax(420px, 1fr); }
  .details-panel { position: absolute; right: 0; top: 0; bottom: 0; width: 340px; z-index: 30; box-shadow: -18px 0 45px rgba(30,18,40,.12); transform: translateX(100%); transition: .2s ease; }
  .details-panel.open { transform: translateX(0); }
}
@media (max-width: 760px) {
  body { overflow: auto; }
  .topbar { min-height: 68px; align-items: center; padding: 10px 12px; gap: 10px; }
  .brand-title { font-size: 13px; }
  .topbar-actions { flex: 1; flex-wrap: wrap; overflow: visible; }
  .topbar-drawer { width: 100%; padding-top: 4px; }
  .mode-switch-btn { padding: 6px 8px; font-size: 11px; }
  .brand-subtitle, .local-badge { display: none; }
  .workspace { display: block; background: light-dark(#fff, #24212c); }
  .clients-panel { height: 100vh; }
  .conversation-panel { position: fixed; inset: 0; z-index: 20; transform: translateX(100%); transition: .2s ease; }
  .conversation-panel.mobile-open { transform: translateX(0); }
  .details-panel { position: fixed; top: 0; width: 100%; z-index: 40; }
  .conversation-header { align-items: stretch; flex-direction: column; }
  .conversation-person { flex: 0 0 auto; min-width: 0; }
  .conversation-actions { flex: 0 0 auto; justify-content: flex-start; }
  .composer-footer { align-items: stretch; flex-direction: column; }
  .composer-hint { max-width: none; }
  .composer-buttons { width: 100%; }
  .composer-buttons .btn { flex: 1; }
  .message-bubble { max-width: 88%; }
  .form-grid { grid-template-columns: 1fr; }
  .full-span { grid-column: auto; }
  .broadcasts-layout { display: block; max-height: calc(100vh - 120px); overflow-y: auto; }
  .broadcast-editor, .broadcast-campaigns { overflow: visible; }
  .broadcast-campaigns { border-top: 1px solid var(--line); border-left: 0; }
  .broadcast-form-grid, .broadcast-preview ul { grid-template-columns: 1fr; }
  .broadcast-form-grid .full-span { grid-column: auto; }
  .broadcast-test-row { grid-template-columns: 1fr; }
  .server-resources { align-items: stretch; gap: 7px; padding: 8px 12px; }
  .server-resources-title { width: 100%; }
  .server-resource-metric { width: 100%; grid-template-columns: 34px 76px minmax(0, 1fr); }
  .server-resource-updated { width: 100%; margin-left: 0; }
}

/* Server/API additions */
.api-online { background: light-dark(#e8f5ef, #203b32) !important; color: var(--success) !important; border-color: light-dark(#cbe7da, #3e725c) !important; }
.api-offline { background: light-dark(#fff1f2, #31283f) !important; color: var(--danger) !important; border-color: light-dark(#efc8ce, #8c4b5d) !important; }
.profile-missing { display: inline-block; margin-top: 4px; font-size: 12px; color: var(--muted); }
.conversation-person .profile-missing { flex: 1 1 auto; display: inline-block; min-width: 0; max-width: 100%; margin: 0; overflow: hidden; color: var(--muted); font-size: 9px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.history-retry-button { appearance: none; padding: 0; border: 0; background: transparent; color: var(--accent); font: inherit; font-weight: 750; text-decoration: underline; cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }
.field-label.spaced, .spaced { margin-top: 12px; }
.attention-tag { border-radius: 999px; padding: 4px 7px; font-size: 10px; background: light-dark(#ffe9e9, #452932); color: var(--danger); font-weight: 700; }
.client-card.automation-red { border-color: light-dark(#d94b5d, #8c4b5d); background: light-dark(#fff0f2, #31283f); box-shadow: inset 3px 0 0 #d94b5d; }
.client-card.automation-red .client-name { color: light-dark(#9e2333, #f0a8b6); }
.automation-chat-alert { position: relative; flex: 0 0 auto; display: block; margin: 0; color: var(--danger); font-size: 9px; }
.automation-chat-alert summary { display: inline-flex; align-items: center; gap: 5px; padding: 2px 6px; border-radius: 6px; background: light-dark(#fff0f2, #31283f); font-weight: 750; cursor: pointer; user-select: none; list-style: none; white-space: nowrap; }
.automation-chat-alert summary::-webkit-details-marker { display: none; }
.automation-alert-disclosure { color: light-dark(#a55d67, #f0a8b6); font-size: 8px; font-weight: 650; }
.automation-chat-alert-text { position: absolute; top: calc(100% + 4px); right: 0; z-index: 25; width: min(520px, 80vw); max-height: 82px; padding: 6px 8px; overflow-y: auto; border: 1px solid light-dark(#efc3ca, #8c4b5d); border-left: 2px solid light-dark(#e5a8b1, #8c4b5d); border-radius: 7px; background: light-dark(#fff8f9, #24212c); box-shadow: 0 8px 22px rgba(80,30,42,.14); color: light-dark(#9e3443, #f0a8b6); line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; }
.automation-mode-backdrop { z-index: 180; }
.automation-mode-modal { overflow: hidden; }
.automation-mode-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 20px 22px 12px; }
.automation-mode-option { display: flex; min-height: 130px; flex-direction: column; align-items: flex-start; justify-content: center; gap: 8px; padding: 18px; border: 2px solid var(--line); border-radius: 16px; background: light-dark(#fff, #24212c); text-align: left; cursor: pointer; }
.automation-mode-option:hover, .automation-mode-option.current { border-color: var(--primary); background: light-dark(#faf7fc, #24212c); }
.automation-mode-option.automatic:hover, .automation-mode-option.automatic.current { border-color: light-dark(#39864b, #3e725c); background: light-dark(#effaf1, #24212c); }
.automation-mode-option.cancel-queue:hover { border-color: var(--danger); background: light-dark(#fff1f2, #31283f); }
.automation-mode-option strong { font-size: 17px; }
.automation-mode-option span { color: var(--muted); font-size: 12px; line-height: 1.45; }
.automation-mode-current { padding: 4px 22px 20px; color: var(--muted); font-size: 12px; }
.queue-choice-options { padding-bottom: 8px; }
.queue-choice-footer { padding-top: 8px; }
.automation-console.draining { border-color: light-dark(#dfc77c, #81643a); background: light-dark(#fff9e8, #31283f); }
.message-row.alert { justify-content: center; }
.message-row.alert .message-bubble { max-width: 88%; background: light-dark(#fff1f2, #31283f); border-color: light-dark(#efc5cb, #8c4b5d); color: light-dark(#793440, #f0a8b6); }
.message-row.alert .message-author { color: var(--danger); }
.empty-conversation { min-height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px; color: var(--muted); text-align: center; }
.empty-conversation strong { color: var(--text); }

.prompt-modal { width: min(1100px, 100%); height: min(900px, calc(100vh - 40px)); display: flex; flex-direction: column; overflow: hidden; }
.prompt-settings-grid { display: grid; grid-template-columns: 2fr repeat(4, 1fr); gap: 10px; padding: 14px 22px; border-bottom: 1px solid var(--line); background: var(--panel-soft); }
.prompt-settings-grid label { display: grid; gap: 6px; }
.prompt-settings-grid label span { color: var(--muted); font-size: 11px; }
.prompt-settings-grid input { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; background: light-dark(#fff, #24212c); }
.prompt-meta { grid-column: 1 / -1; color: var(--muted); font-size: 11px; }
.prompt-editors { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.prompt-editor-wrap { min-height: 0; padding: 14px 11px 14px 22px; display: flex; flex-direction: column; gap: 8px; }
.prompt-editor-wrap + .prompt-editor-wrap { padding: 14px 22px 14px 11px; }
.prompt-editor-heading { display: grid; gap: 2px; }
.prompt-editor-heading strong { font-size: 12px; }
.prompt-editor-heading span { color: var(--muted); font-size: 10px; }
.prompt-editor-wrap textarea { width: 100%; flex: 1; min-height: 330px; resize: none; border: 1px solid var(--line); border-radius: 12px; padding: 14px; outline: none; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; line-height: 1.45; }
.navigation-editor-wrap textarea { background: light-dark(#fbf9fd, #24212c); }
.prompt-release-description { overflow-y: auto; padding-right: 22px; }
.prompt-release-description label { display: grid; gap: 5px; }
.prompt-release-description label > span { color: var(--muted); font-size: 11px; }
.prompt-release-description input,
.prompt-release-description textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; background: light-dark(#fff, #24212c); font: inherit; }
.prompt-release-description textarea { flex: 0 0 auto; min-height: 54px; resize: vertical; font-family: inherit; }
.prompt-parent-version { padding: 9px 10px; border-radius: 9px; background: var(--panel-soft); color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.prompt-footer { flex-wrap: wrap; }
.component-releases-modal { width: min(1320px, calc(100vw - 28px)); height: min(920px, calc(100vh - 28px)); display: flex; flex-direction: column; overflow: hidden; }
.component-releases-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(520px, 1.15fr) minmax(380px, .85fr); gap: 16px; padding: 16px 20px 20px; overflow: hidden; }
.component-release-publisher,
.component-release-history { min-height: 0; border: 1px solid var(--border); border-radius: 14px; padding: 14px; background: var(--surface-soft); }
.component-release-publisher { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.component-release-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.component-release-fields label,
.component-release-content-label { display: grid; gap: 5px; }
.component-release-fields label > span,
.component-release-content-label > span { color: var(--muted); font-size: 11px; }
.component-release-fields .full-span { grid-column: 1 / -1; }
.component-release-fields input,
.component-release-fields select,
.component-release-fields textarea,
.component-release-content-label textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; background: light-dark(#fff, #24212c); font: inherit; }
.component-release-fields textarea { resize: vertical; }
.component-release-content-label textarea { min-height: 240px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; line-height: 1.45; }
.component-release-publisher-actions { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.component-release-history { display: flex; flex-direction: column; overflow: hidden; }
.component-release-list { display: grid; gap: 10px; min-height: 0; overflow-y: auto; }
.component-release-card { border: 1px solid var(--border); border-radius: 11px; padding: 11px; background: var(--surface); display: grid; gap: 7px; }
.component-release-card header { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.component-release-card header span,
.component-release-card small { color: var(--muted); font-size: 11px; }
.component-release-card p { margin: 0; font-size: 12px; white-space: pre-wrap; }
.component-release-card ul { margin: 0; padding-left: 18px; font-size: 12px; }
.component-release-card code { font-size: 10px; overflow-wrap: anywhere; }
.mode-bundles-modal { width: min(1220px, calc(100vw - 28px)); height: min(860px, calc(100vh - 28px)); display: flex; flex-direction: column; overflow: hidden; }
.mode-bundles-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(460px, 1fr) minmax(420px, 1fr); gap: 16px; padding: 16px 20px 20px; overflow: hidden; }
.mode-bundle-editor,
.mode-bundle-history { min-height: 0; border: 1px solid var(--border); border-radius: 14px; padding: 14px; background: var(--surface-soft); }
.mode-bundle-editor { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.mode-bundle-history { display: flex; flex-direction: column; overflow: hidden; }
.mode-bundle-mode-field,
.mode-bundle-activation-fields label,
.mode-bundle-role-selector { display: grid; gap: 5px; }
.mode-bundle-mode-field > span,
.mode-bundle-activation-fields span,
.mode-bundle-role-selector > span { color: var(--muted); font-size: 11px; }
.mode-bundle-mode-field select,
.mode-bundle-activation-fields input,
.mode-bundle-activation-fields textarea,
.mode-bundle-role-selector select { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; background: light-dark(#fff, #24212c); font: inherit; }
.mode-bundle-status { border: 1px solid var(--border); border-radius: 10px; padding: 11px; background: var(--surface); display: grid; gap: 5px; font-size: 12px; }
.mode-bundle-status strong { overflow-wrap: anywhere; }
.mode-bundle-status.warning { border-color: light-dark(#d9a84e, #81643a); background: light-dark(#fff8e7, #31283f); }
.mode-bundle-status.error { border-color: var(--danger); background: light-dark(#fff1f2, #31283f); }
.mode-bundle-role-selectors { display: grid; gap: 10px; }
.mode-bundle-role-selector small { color: var(--muted); font-size: 11px; }
.mode-bundle-activation-fields { display: grid; gap: 10px; }
.mode-bundle-history-list { display: grid; gap: 10px; min-height: 0; overflow-y: auto; }
.mode-bundle-history-card { border: 1px solid var(--border); border-radius: 11px; padding: 11px; background: var(--surface); display: grid; gap: 7px; }
.mode-bundle-history-card header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.mode-bundle-history-card small { color: var(--muted); font-size: 11px; }
.mode-bundle-history-card code { font-size: 10px; overflow-wrap: anywhere; }
.mode-bundle-history-components { display: grid; gap: 5px; font-size: 11px; }
.mode-bundle-history-components span { display: block; }
.mode-bundle-history-card .btn { justify-self: end; }

.connections-modal { width: min(760px, 100%); }
.autonomy-features-modal { width: min(900px, 100%); }
.feature-control-badge { margin-left: 5px; padding: 2px 5px; border-radius: 999px; background: var(--panel-soft); color: var(--muted); font-size: 9px; }
.feature-control-badge.active { background: light-dark(#dff3e9, #203b32); color: light-dark(#267052, #93dbb5); }
.autonomy-feature-summary { margin: 0 20px 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-soft); color: var(--muted); font-size: 12px; }
.autonomy-feature-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 0 20px 20px; }
.autonomy-feature-card { display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 10px; min-width: 0; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-soft); }
.autonomy-feature-card.effective { border-color: light-dark(#72b997, #3e725c); background: light-dark(#eef8f3, #24212c); }
.autonomy-feature-card.blocked { border-color: light-dark(#c99b46, #81643a); background: light-dark(#fff8e9, #31283f); }
.autonomy-feature-card input { margin-top: 3px; accent-color: var(--primary); }
.autonomy-feature-copy { display: grid; min-width: 0; gap: 4px; }
.autonomy-feature-copy strong { font-size: 13px; }
.autonomy-feature-copy > span { color: var(--muted); font-size: 11px; line-height: 1.4; }
.autonomy-feature-copy .autonomy-feature-dependencies { color: var(--primary-dark); font-size: 10px; overflow-wrap: anywhere; }
.autonomy-feature-copy em { color: var(--muted); font-size: 10px; font-style: normal; line-height: 1.35; }
.autonomy-feature-card.effective em { color: light-dark(#267052, #93dbb5); }
.autonomy-feature-card.blocked em { color: light-dark(#8a651d, #f1cc89); }
.autonomy-feature-error { grid-column: 1 / -1; padding: 14px; border: 1px solid light-dark(#dca7ad, #8c4b5d); border-radius: 12px; background: light-dark(#fff1f2, #31283f); color: light-dark(#8b3540, #f0a8b6); font-size: 12px; }
.connections-content { padding: 18px 22px 4px; display: grid; gap: 14px; }
.connection-card { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: var(--panel-soft); }
.connection-card-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.connection-card-title h3 { margin: 0; font-size: 16px; }
.connection-card-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.connection-state { white-space: nowrap; padding: 5px 8px; border-radius: 999px; background: light-dark(#fff1f2, #31283f); color: var(--danger); font-size: 11px; font-weight: 700; }
.connection-state.ready { background: light-dark(#e8f5ef, #203b32); color: var(--success); }
.connection-card label { display: grid; gap: 6px; }
.connection-card label > span { color: var(--muted); font-size: 11px; }
.connection-card input:not([type="checkbox"]) { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; background: light-dark(#fff, #24212c); }
.connection-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.avito-profile-settings { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.avito-profile-settings label { display: grid; gap: 6px; }
.avito-profile-settings select,
.avito-profile-picker select { border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; background: light-dark(#fff, #24212c); color: var(--text); }
.connection-hint { margin: 0 0 12px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.avito-profile-picker { display: flex; align-items: center; gap: 7px; padding: 4px 7px 4px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.avito-profile-picker > span { color: var(--muted); font-size: 11px; white-space: nowrap; }
.avito-profile-picker select { max-width: 190px; padding: 6px 8px; font-size: 12px; }
.connection-card .clear-connection { display: flex; align-items: center; gap: 7px; margin-top: 11px; color: var(--muted); font-size: 11px; }
.connection-test-result { padding: 11px 12px; border-radius: 10px; background: light-dark(#f5f2f8, #24212c); color: var(--muted); font-size: 12px; }
.connection-test-result.success { background: light-dark(#e8f5ef, #203b32); color: var(--success); }
.connection-test-result.error { background: light-dark(#fff1f2, #31283f); color: var(--danger); }
.avito-chat-import { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.avito-chat-import > div:first-child { display: grid; gap: 3px; margin-bottom: 9px; }
.avito-chat-import strong { font-size: 12px; }
.avito-chat-import span { color: var(--muted); font-size: 11px; }
.avito-chat-import-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.avito-chat-import-result { margin-top: 9px; padding: 9px 10px; border-radius: 9px; background: light-dark(#f5f2f8, #24212c); color: var(--muted); font-size: 11px; }
.avito-chat-import-result.success { background: light-dark(#e8f5ef, #203b32); color: var(--success); }
.avito-chat-import-result.error { background: light-dark(#fff1f2, #31283f); color: var(--danger); }

@media (max-width: 900px) {
  .error-journal-stats { grid-template-columns: 1fr 1fr; }
  .error-journal-filters { grid-template-columns: 1fr 1fr; }
  .error-journal-filters input { grid-column: 1 / -1; }
  .prompt-settings-grid { grid-template-columns: 1fr 1fr; }
  .prompt-settings-grid label:first-child { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .autonomy-feature-list { grid-template-columns: 1fr; }
  .action-history-toolbar { grid-template-columns: 1fr; }
  #promptSettingsBtn { display: inline-flex; }
  .prompt-modal { height: calc(100vh - 12px); }
  .prompt-settings-grid { grid-template-columns: 1fr; max-height: 240px; overflow-y: auto; }
  .prompt-settings-grid label:first-child { grid-column: auto; }
  .prompt-editors { grid-template-columns: 1fr; overflow-y: auto; }
  .prompt-editor-wrap { padding: 10px; }
  .prompt-editor-wrap + .prompt-editor-wrap { padding: 0 10px 10px; }
  .prompt-editor-wrap textarea { min-height: 280px; }
  .prompt-release-description textarea { min-height: 54px; }
  .component-releases-body { display: block; overflow-y: auto; }
  .component-release-history { min-height: 420px; margin-top: 14px; }
  .component-release-fields { grid-template-columns: 1fr; }
  .component-release-fields .full-span { grid-column: auto; }
  .mode-bundles-body { display: block; overflow-y: auto; }
  .mode-bundle-history { min-height: 420px; margin-top: 14px; }
  .connection-fields, .avito-profile-settings { grid-template-columns: 1fr; }
  .message-editor-body { padding: 12px 12px 2px; }
  .message-editor-body textarea { min-height: 52vh; max-height: calc(100vh - 220px); font-size: 16px; }
  .message-editor-meta { align-items: flex-end; }
  .avito-chat-import-row { grid-template-columns: 1fr; }
  .tarot-image-panel.ready, .tarot-image-panel.error { grid-template-columns: 1fr; }
  .tarot-generate-btn { width: 100%; }
}

.avito-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.avito-info-grid > div {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: var(--surface-soft, light-dark(#faf9f7, #24212c));
  min-width: 0;
}
.avito-info-grid span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.avito-info-grid strong {
  display: block;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attention-tag.avito-unread,
.avito-unread {
  background: light-dark(#fff2d9, #423521);
  color: light-dark(#8a5400, #f1cc89);
}

.refund-emergency {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: clamp(18px, 4vw, 64px);
  overflow-y: auto;
  background:
    radial-gradient(circle at 50% 18%, rgba(255,255,255,.18), transparent 35%),
    linear-gradient(145deg, #8f1027, #cf233f 55%, #8d0b20);
  color: #fff;
  animation: emergency-background-pulse 1.1s ease-in-out infinite alternate;
}
.refund-emergency-card {
  width: min(1180px, 100%);
  min-height: min(760px, calc(100vh - 80px));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 3vh, 30px);
  padding: clamp(28px, 6vw, 86px);
  text-align: center;
  border: 5px solid rgba(255,255,255,.88);
  border-radius: 32px;
  box-shadow: 0 36px 120px rgba(38,0,7,.5);
}
.refund-emergency-kicker {
  padding: 9px 18px;
  border-radius: 999px;
  background: light-dark(#fff, #24212c);
  color: light-dark(#a31029, #f0a8b6);
  font-size: clamp(14px, 1.6vw, 22px);
  font-weight: 950;
  letter-spacing: .14em;
}
.refund-emergency h2 {
  margin: 0;
  font-size: clamp(44px, 8vw, 118px);
  line-height: .92;
  letter-spacing: -.045em;
  text-wrap: balance;
}
.refund-emergency-client {
  margin: 0;
  font-size: clamp(20px, 2.3vw, 34px);
  font-weight: 850;
}
.refund-emergency blockquote {
  width: min(880px, 100%);
  margin: 0;
  padding: 20px 24px;
  border: 2px solid rgba(255,255,255,.48);
  border-radius: 18px;
  background: rgba(64,0,12,.22);
  font-size: clamp(17px, 1.7vw, 25px);
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.refund-emergency-note {
  max-width: 780px;
  margin: 0;
  color: rgba(255,255,255,.88);
  font-size: clamp(14px, 1.25vw, 18px);
  line-height: 1.45;
}
.refund-emergency-action {
  min-height: 70px;
  padding: 18px 30px;
  border: 0;
  border-radius: 16px;
  background: light-dark(#fff, #24212c);
  color: light-dark(#951027, #f0a8b6);
  box-shadow: 0 14px 38px rgba(45,0,8,.25);
  font-size: clamp(16px, 1.6vw, 23px);
  font-weight: 900;
}
.refund-emergency-action:hover { transform: translateY(-2px); }

@keyframes emergency-background-pulse {
  from { filter: brightness(.9); }
  to { filter: brightness(1.2); }
}

@media (prefers-reduced-motion: reduce) {
  .refund-emergency { animation: none; }
}

@media (max-width: 720px) {
  .automation-mode-options { grid-template-columns: 1fr; }
  .automation-console { padding-inline: 10px; gap: 8px; }
  .refund-emergency { padding: 10px; }
  .refund-emergency-card { min-height: calc(100vh - 20px); padding: 28px 18px; border-width: 3px; border-radius: 22px; }
  .refund-emergency h2 { font-size: clamp(40px, 15vw, 70px); }
  .refund-emergency-action { width: 100%; }
}

.frozen-export-modal { max-width: 1080px; }
.frozen-export-body { min-height: 0; flex: 1; display: grid; grid-template-columns: minmax(320px, .9fr) minmax(360px, 1.1fr); align-items: stretch; gap: 18px; padding: 16px 20px 22px; overflow: hidden; }
.frozen-export-selection,
.frozen-export-history { min-height: 0; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--border); border-radius: 14px; padding: 16px; background: var(--surface-soft); }
.frozen-export-selection-content { min-height: 0; flex: 1; overflow-y: auto; padding-right: 4px; }
.frozen-export-client { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.frozen-export-client span,
.frozen-export-note,
.frozen-export-history-header p { color: var(--muted); font-size: 12px; }
.frozen-export-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.frozen-export-modes legend { padding: 0 6px; font-weight: 700; }
.frozen-export-modes label { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.frozen-export-scope,
.frozen-export-include,
.frozen-export-versions { margin-bottom: 14px; }
.frozen-export-versions { border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.frozen-export-versions legend { padding: 0 6px; font-weight: 700; }
.frozen-export-versions > p { margin: 0 0 10px; color: var(--muted); font-size: 12px; }
.frozen-export-version-list { display: grid; gap: 8px; max-height: 240px; overflow: auto; }
.frozen-export-version-list label { display: flex; align-items: flex-start; gap: 8px; padding: 8px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.frozen-export-version-list label span { display: grid; min-width: 0; }
.frozen-export-version-list label small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.frozen-export-bundle-list { max-height: 320px; }
.frozen-export-period { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.frozen-export-period label { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
.frozen-export-actions { flex: 0 0 auto; justify-content: space-between; padding: 12px 0 0; }
.frozen-export-history-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.frozen-export-history-header h3 { margin: 0 0 4px; }
.frozen-export-history-header p { margin: 0; }
.frozen-export-entry { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.frozen-export-entry code { display: block; max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.frozen-export-entry-modes { color: var(--muted); font-size: 12px; }

@media (max-width: 900px) {
  .frozen-export-body { display: block; overflow-y: auto; }
  .frozen-export-selection,
  .frozen-export-selection-content { overflow: visible; }
  .frozen-export-history { min-height: 320px; margin-top: 18px; }
  .frozen-export-modes,
  .frozen-export-period { grid-template-columns: 1fr; }
}

.autonomy-lab-modal { width: min(1240px, calc(100vw - 32px)); height: min(920px, calc(100vh - 32px)); }
.autonomy-lab-status { margin: 12px 20px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-soft); color: var(--muted); font-size: 12px; }
.autonomy-lab-body { min-height: 0; flex: 1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 16px; padding: 16px 20px; overflow-y: auto; }
.autonomy-lab-card { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel-soft); }
.autonomy-lab-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.autonomy-lab-card-header h3 { margin: 0 0 4px; font-size: 15px; }
.autonomy-lab-card-header p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.autonomy-lab-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.autonomy-lab-grid label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; }
.autonomy-lab-grid .autonomy-lab-wide { grid-column: 1 / -1; }
.autonomy-lab-grid .test-group-draft { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; color: var(--text); }
.autonomy-lab-actions { padding: 12px 0 0; }
.autonomy-lab-card .connection-test-result { margin-top: 10px; }
.autonomy-lab-list { max-height: 240px; margin-top: 12px; overflow-y: auto; }
.autonomy-lab-entry { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.autonomy-lab-entry-main { min-width: 0; display: grid; gap: 4px; }
.autonomy-lab-entry-main code { overflow-wrap: anywhere; font-size: 10px; }
.autonomy-lab-entry-meta { color: var(--muted); font-size: 11px; line-height: 1.45; }
.autonomy-lab-entry-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.autonomy-lab-entry-actions .btn { padding: 7px 9px; font-size: 11px; }
.autonomy-lab-footer { flex-wrap: wrap; align-items: center; border-top: 1px solid var(--line); }
.autonomy-lab-footer > span { margin-right: auto; color: var(--muted); font-size: 11px; }

@media (max-width: 960px) {
  .autonomy-lab-body { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .autonomy-lab-grid { grid-template-columns: 1fr; }
  .autonomy-lab-entry { flex-direction: column; }
  .autonomy-lab-entry-actions { width: 100%; justify-content: stretch; }
  .autonomy-lab-entry-actions .btn { flex: 1; }
}

.frozen-export-picked-clients { display: grid; gap: 8px; border: 1px solid var(--border); border-radius: 8px; }
.frozen-export-picked-clients input[type="search"] { width: 100%; min-width: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); }
