:root {
  --accent: #0070f0;
  --accent-dark: #0058bd;
  --accent-soft: #e8f1fd;
  --green: #12864a;
  --green-soft: #e4f5ea;
  --red: #c93030;
  --red-soft: #fbeaea;
  --amber: #a35c00;
  --amber-soft: #fdf1dc;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --line: #e2e6ec;
  --line-strong: #cdd4de;
  --text: #1a2230;
  --muted: #67718a;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 50, 0.05), 0 1px 3px rgba(20, 30, 50, 0.06);
}

/* Акценты панели для магазина «ГранитПро»: карминовая палитра. */
body[data-tenant="tiles"] {
  --accent: #c62828;
  --accent-dark: #a81f1f;
  --accent-soft: #fceeee;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }

p { margin: 0; }

button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- black stand bar ---------- */

.stand-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #0B0B0B;
  color: #F4F4F4;
  border-bottom: 1px solid #232323;
}

.stand-bar-inner {
  max-width: 1480px;
  margin: 0 auto;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.stand-bar-left {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  min-width: 0;
}

.stand-brand {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #ffffff;
  white-space: nowrap;
}

.stand-tabs { display: flex; gap: 4px; flex-wrap: wrap; }

.stand-tab {
  font-size: 13px;
  font-weight: 600;
  color: #c9c9c9;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.stand-tab:hover { color: #ffffff; border-color: #3a3a3a; }

.stand-tab.is-active {
  color: #0b0b0b;
  background: #ffffff;
  border-color: #ffffff;
}

/* Переключатель магазинов в чёрной полосе — единый вид с /demo/. */
.stand-bar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.stand-tenant-switch { display: flex; gap: 6px; overflow-x: auto; max-width: 100%; }

/* Управление стендом — в демо-полосе, вне рабочей шапки панели. */
.stand-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.stand-action {
  border: 1px solid #3a3a3a;
  background: transparent;
  color: #d7d7d7;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.stand-action:hover { background: #1e1e1e; color: #fff; border-color: #4a4a4a; }
.stand-action:focus-visible { outline: 2px solid #8a8a8a; outline-offset: 2px; }

.stand-action-danger { color: #f0a9a9; border-color: #5a2e2e; }
.stand-action-danger:hover { background: #3a1c1c; color: #ffd0d0; border-color: #7a3b3b; }

.tenant-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #ffffff;
  color: #4a4a4a;
  border-radius: 999px;
  padding: 7px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.tenant-pill:hover { border-color: var(--accent); color: var(--accent-dark); }

.tenant-pill.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.stand-tenant-switch .tenant-pill {
  border: 1px solid #3a3a3a;
  background: transparent;
  color: #d6d6d6;
}

.stand-tenant-switch .tenant-pill:hover {
  border-color: #ffffff;
  color: #ffffff;
}

.stand-tenant-switch .tenant-pill.is-active {
  background: #ffffff;
  border-color: #ffffff;
  color: #0b0b0b;
}

/* Мягкая пометка об общих аккаунтах ЮKassa/МойСклад на демо-стенде. */
.tenant-note {
  padding: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- login ---------- */

.login-screen {
  min-height: calc(100vh - 46px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 50% -10%, #e3efff 0%, transparent 60%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(15, 30, 60, 0.08);
  padding: 30px 28px 26px;
}

.login-brand {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.login-card h1 { margin-bottom: 8px; }

.login-hint {
  color: var(--muted);
  margin-bottom: 20px;
  font-size: 13px;
}

.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.login-error {
  min-height: 20px;
  margin-top: 12px;
  color: var(--red);
  font-size: 13px;
}

/* ---------- controls ---------- */

.input,
.select {
  width: 100%;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.input:focus,
.select:focus,
.chat-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 112, 240, 0.14);
}

.select { width: auto; min-width: 130px; padding-right: 26px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  font-weight: 550;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.btn:hover { background: #f2f5f9; border-color: #b9c2d0; }
.btn:disabled { opacity: 0.55; cursor: progress; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: #eef1f6; color: var(--text); }

.btn-danger-ghost { color: var(--red); border-color: #eccfcf; background: #fff; }
.btn-danger-ghost:hover { background: var(--red-soft); border-color: #e0b6b6; }

.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #0e6d3c; border-color: #0e6d3c; }

.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #ad2626; border-color: #ad2626; }

.btn-sm { padding: 4px 9px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; margin-top: 14px; padding: 10px; }

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
}

/* ---------- topbar ---------- */

.app { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 15px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.brand-sub {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding-left: 2px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
  padding: 0 4px;
  cursor: pointer;
}

.toggle input { accent-color: var(--accent); }

.banner {
  margin: 14px 20px 0;
  padding: 10px 14px;
  border-radius: 9px;
  border: 1px solid #f0d9a8;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 13px;
  font-weight: 550;
}

/* ---------- layout ---------- */

.layout {
  max-width: 1480px;
  margin: 0 auto;
  padding: 16px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.card-head h2 { display: flex; align-items: center; gap: 8px; }

.card-head-side {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Заголовки разделов страницы: обзор / операции. */
.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.section-head h2 {
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- KPI ---------- */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 11px 13px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.kpi.warn { border-left-color: var(--amber); }
.kpi.ok { border-left-color: var(--green); }

.kpi-label {
  font-size: 11.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-value {
  font-size: 20px;
  font-weight: 700;
  margin: 4px 0 2px;
  font-variant-numeric: tabular-nums;
}

.kpi-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- overview ---------- */

.overview {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 14px;
}

.funnel-card, .digest-card { min-width: 0; }

.funnel {
  display: flex;
  align-items: stretch;
  gap: 4px;
  min-height: 108px;
}

.funnel-step {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  padding: 9px 10px;
  background: #f8fafd;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.funnel-step-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.funnel-step-value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.funnel-step-note {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.funnel-track {
  height: 6px;
  background: #e6ebf2;
  border-radius: 99px;
  overflow: hidden;
}

.funnel-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.3s ease;
}

.funnel-link {
  flex: 0 0 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: 16px;
}

.funnel-conv {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.digest-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  background: #f8fafd;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 13px;
  max-height: 168px;
  overflow: auto;
  color: #26303f;
}

/* ---------- tabs ---------- */

.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0;
}

.tab {
  border: none;
  background: transparent;
  padding: 9px 14px;
  border-radius: 8px 8px 0 0;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab:hover { color: var(--text); background: #eef2f8; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); background: #fff; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 5px;
  border-radius: 99px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  vertical-align: 1px;
}

.panel { display: none; flex-direction: column; gap: 14px; }
.panel.active { display: flex; }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th, .table td {
  text-align: left;
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
  background: #f8fafd;
  border-bottom: 1px solid var(--line-strong);
}

.table tbody tr:hover { background: #f7fafe; }
.table td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.empty { text-align: center; color: var(--muted); padding: 18px; }

.table a { color: var(--accent); text-decoration: none; }
.table a:hover { text-decoration: underline; }

.stack { display: flex; flex-direction: column; gap: 10px; }

/* ---------- request cards ---------- */

.request-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fff;
}

.request-card.pending { border-left: 3px solid var(--accent); }
.request-card.failed { border-left: 3px solid var(--red); }

.request-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.request-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.request-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 18px;
}

.req-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 2px;
}

.req-value { font-size: 13px; }

/* Состав правки: было/стало рядом, чтобы решение принималось по фактам. */
.req-items {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}

.req-items-col { min-width: 0; }

.req-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  padding: 2px 0;
}

.req-item-name { min-width: 0; overflow-wrap: anywhere; }
.req-item-sum { flex: 0 0 auto; font-variant-numeric: tabular-nums; color: var(--text); }

.request-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}

.request-actions .field { flex: 1 1 150px; min-width: 130px; }
.request-actions .input { padding: 6px 9px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 650;
  background: #eef1f6;
  color: var(--muted);
  white-space: nowrap;
}

.status-pill.status-pending_approval { background: var(--accent-soft); color: var(--accent-dark); }
.status-pill.status-failed { background: var(--red-soft); color: var(--red); }
.status-pill.status-executed,
.status-pill.status-paid { background: var(--green-soft); color: var(--green); }
.status-pill.status-rejected,
.status-pill.status-cancelled { background: #f0f1f4; color: #6a7385; }
.status-pill.status-pending_payment { background: var(--amber-soft); color: var(--amber); }

.tag {
  display: inline-flex;
  padding: 1px 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 650;
  background: #f0f3f8;
  color: #4a5568;
}

/* ---------- audit ---------- */

.audit-row {
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}

.audit-row:last-child { border-bottom: none; }
.audit-time { color: var(--muted); font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.audit-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.audit-action { font-weight: 650; }
.audit-details {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  word-break: break-word;
  white-space: pre-wrap;
}

.audit-details-more { margin-top: 2px; }
.audit-details-more summary { cursor: pointer; color: var(--accent-dark); font-family: inherit; }
.audit-details-full {
  margin: 4px 0 0;
  padding: 6px 8px;
  background: #f8fafd;
  border: 1px solid var(--line);
  border-radius: 6px;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 11px;
}

/* ---------- dialogs ---------- */

.dialogs-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.6fr);
  gap: 14px;
  align-items: start;
}

.session-list-card { max-height: 72vh; overflow: auto; }
.session-list { display: flex; flex-direction: column; gap: 6px; }

.session-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: border-color 0.12s, background 0.12s;
}

.session-item:hover { border-color: #b9c6d8; background: #f8fbff; }
.session-item.active { border-color: var(--accent); background: var(--accent-soft); }

.session-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.session-item-id { font-family: var(--mono); font-size: 12px; font-weight: 650; }
.session-item-meta { font-size: 11.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.session-item-money { font-size: 11.5px; color: #3d4759; }

.session-detail { display: flex; flex-direction: column; gap: 14px; }

.detail-head { display: flex; flex-direction: column; gap: 4px; }
.detail-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 700; }
.detail-meta { font-size: 12px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }

.messages { display: flex; flex-direction: column; gap: 8px; max-height: 42vh; overflow: auto; padding-right: 4px; }

.message {
  max-width: 78%;
  padding: 8px 11px;
  border-radius: 10px;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user { align-self: flex-start; background: #f1f4f9; border: 1px solid var(--line); }
.message.assistant { align-self: flex-end; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 28%, white); }
.message.tool { align-self: center; background: #f7f7f9; border: 1px dashed var(--line-strong); color: var(--muted); font-family: var(--mono); font-size: 11.5px; max-width: 100%; }

.tool-details summary {
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  user-select: none;
}

.tool-details .tool-body {
  margin-top: 6px;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Поле + кнопка в одну строку: кнопка справа от инпута. */
.row-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  margin-bottom: 10px;
}

.row-inline .input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

.row-inline .btn {
  flex: 0 0 auto;
}

.msg-role {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 3px;
}

/* ---------- chat ---------- */

.chat-card { display: flex; flex-direction: column; gap: 12px; }

/* Чат живёт в верхнем блоке рядом с МойСклад: ограничиваем высоту, чтобы
 * он не растягивал всю страницу. */
.ops-row .chat-log { min-height: 160px; max-height: 320px; }

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 220px;
  max-height: 52vh;
  overflow: auto;
  padding: 6px 2px;
}

.chat-bubble {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13.5px;
}

.md-li { position: relative; padding-left: 14px; }
.md-bullet { position: absolute; left: 2px; top: 0; opacity: 0.75; }
.chat-bubble code,
.message code {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 4px;
  border-radius: 4px;
}
.chat-bubble.user code { background: rgba(255, 255, 255, 0.2); }

.chat-bubble.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.chat-bubble.assistant { align-self: flex-start; max-width: 88%; background: #f1f4f9; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-bubble.system { align-self: center; background: var(--amber-soft); color: var(--amber); font-size: 12.5px; }

.chat-degraded {
  align-self: flex-start;
  font-size: 11.5px;
  color: var(--amber);
  font-weight: 600;
}

.trace {
  align-self: flex-start;
  max-width: 88%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafd;
  padding: 6px 10px;
  font-size: 12px;
}

.trace summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.trace-row {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 3px 0;
  border-bottom: 1px dotted var(--line);
  white-space: pre-wrap;
  word-break: break-word;
}
.trace-row:last-child { border-bottom: none; }

.chips { display: flex; gap: 7px; flex-wrap: wrap; }

.chip {
  border: 1px solid #cfe0f6;
  background: #f3f8ff;
  color: var(--accent-dark);
  border-radius: 99px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 550;
}

.chip:hover { background: var(--accent-soft); }

.chat-form { display: flex; gap: 9px; align-items: flex-end; }

.chat-input {
  flex: 1 1 auto;
  resize: vertical;
  min-height: 44px;
  max-height: 160px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  outline: none;
}

.chat-wait { font-size: 12.5px; color: var(--muted); font-style: italic; }

/* ---------- logs ---------- */

.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.status-counters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }

.status-counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 99px;
  background: #f1f4f9;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: #45506a;
}

.status-counter strong { font-variant-numeric: tabular-nums; }
.status-counter.is-ok { background: var(--green-soft); border-color: #c2e6d1; color: var(--green); }
.status-counter.is-error { background: var(--red-soft); border-color: #eec9c9; color: var(--red); }
.status-counter.is-fallback { background: var(--amber-soft); border-color: #f0d9a8; color: var(--amber); }

.log-params { font-family: var(--mono); font-size: 11px; color: var(--muted); max-width: 340px; white-space: pre-wrap; word-break: break-all; }
.log-error { color: var(--red); font-size: 12px; max-width: 300px; white-space: pre-wrap; word-break: break-word; }

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.toast {
  padding: 10px 13px;
  border-radius: 9px;
  background: #1f2a3d;
  color: #fff;
  font-size: 13px;
  font-weight: 550;
  box-shadow: 0 8px 24px rgba(10, 20, 40, 0.22);
  border-left: 4px solid #6b7a94;
  animation: toast-in 0.18s ease;
}

.toast-success { border-left-color: #3ccf7e; }
.toast-error { border-left-color: #ff6b6b; }
.toast-info { border-left-color: #4da3ff; }

.toast-detail {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 400;
  color: #c3ccdb;
  white-space: pre-wrap;
  word-break: break-word;
}

.toast-out { opacity: 0; transform: translateY(6px); transition: opacity 0.25s, transform 0.25s; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- demo mode & integrations ---------- */

.demo-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.02em;
  background: var(--amber-soft);
  color: var(--amber);
  white-space: nowrap;
}

.ops-row {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.ms-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ms-status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.quick-result {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-banner {
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
}

.quick-banner.ok { background: var(--green-soft); color: var(--green); }
.quick-banner.warn { background: var(--amber-soft); color: var(--amber); }

.quick-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.quick-metric {
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 0;
}

.quick-metric-label {
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.quick-metric-value {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quick-summary {
  font-size: 12.5px;
  color: var(--text);
  white-space: pre-wrap;
}

.status-pill.status-sync_failed { background: var(--amber-soft); color: var(--amber); }

/* ---------- responsive ---------- */

@media (max-width: 1180px) {
  .kpi-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ops-row { grid-template-columns: 1fr; }
  .overview { grid-template-columns: 1fr; }
  .request-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dialogs-layout { grid-template-columns: 1fr; }
  .session-list-card { max-height: 40vh; }
  .funnel { flex-wrap: wrap; }
  .funnel-link { flex-basis: 100%; flex-direction: row; gap: 6px; height: 18px; }
  .request-grid { grid-template-columns: 1fr; }
  .layout { padding: 12px 12px 48px; }
  .topbar { padding: 9px 12px; }
  .brand { flex-wrap: wrap; row-gap: 4px; font-size: 13.5px; }
  .brand-sub { display: none; }
  .demo-badge { margin-left: 0; }
  .stand-bar-inner { padding: 8px 12px; }
  .stand-bar-left { gap: 10px; }
  .stand-brand { font-size: 11.5px; }
  .stand-tab { font-size: 12px; padding: 4px 8px; }
  .login-screen { min-height: calc(100vh - 62px); }
}