/* Techbooster operational UI. This layer intentionally overrides legacy themes. */
:root {
  --ink: #17201d;
  --muted: #66736e;
  --line: #dfe5e2;
  --surface: #ffffff;
  --canvas: #f6f7f7;
  --sidebar: #ffffff;
  --sidebar-soft: #f0f7f4;
  --teal: #168b62;
  --teal-dark: #117654;
  --teal-soft: #e9f7f1;
  --blue: #3478d4;
  --blue-soft: #edf3fc;
  --amber: #856313;
  --amber-soft: #fff6dc;
  --danger: #c63e3e;
  --danger-soft: #fff0ef;
  --lime: #e9f7f1;
  --lavender: #eef1ff;
  --peach: #fff2e8;
  --shadow-sm: 0 1px 2px rgba(24, 39, 33, .05);
  --shadow-md: 0 14px 34px rgba(24, 39, 33, .09);
}

html { background: var(--canvas); }

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-weight: 400;
  letter-spacing: 0;
}

body,
button,
input,
select,
textarea { font-feature-settings: "tnum" 1, "cv02" 1; }

h1,
h2,
h3,
.metric strong,
.template-metrics strong {
  color: var(--ink);
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-logo {
  display: block;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: var(--shadow-sm);
}

.brand-logo.compact {
  width: 36px;
  height: 36px;
}

.login-shell {
  min-height: 100vh;
  padding: 32px 20px;
  background: #f4f7f6;
}

.login-shell::before { display: none; }

.login-panel {
  width: min(420px, 100%);
  padding: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.login-panel .brand-logo { margin-bottom: 24px; }
.login-panel .eyebrow { margin-bottom: 8px; }

.login-panel h1 {
  max-width: 340px;
  margin: 0;
  font-size: 30px;
  line-height: 1.18;
}

.login-panel > .muted {
  max-width: 340px;
  margin: 10px 0 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

label {
  color: #3d4a45;
  font-size: 12px;
  font-weight: 600;
}

input,
select,
textarea {
  min-height: 42px;
  border: 1px solid #cad3cf;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-weight: 400;
}

input:hover,
select:hover,
textarea:hover { border-color: #aebbb5; }

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(22, 139, 98, .12);
}

.button,
.widget-template-launch,
.widget-template-panel button {
  min-height: 40px;
  border-radius: 7px;
  font-weight: 650;
  letter-spacing: 0;
}

.button.primary,
.widget-template-panel .template-send {
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #fff;
}

.button.primary:hover,
.widget-template-panel .template-send:hover {
  border-color: var(--teal-dark);
  background: var(--teal-dark);
}

.button.secondary,
.widget-template-launch,
.widget-template-panel button {
  border: 1px solid #cad3cf;
  background: #fff;
  color: var(--ink);
}

.button.secondary:hover,
.widget-template-launch:hover,
.widget-template-panel button:hover {
  border-color: #9daca5;
  background: #f8faf9;
}

.text-button { color: var(--teal); }

.app-shell {
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--canvas);
}

.sidebar {
  width: 252px;
  padding: 22px 16px 16px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  color: var(--ink);
}

.sidebar-brand {
  gap: 10px;
  padding: 0 6px 18px;
  border-bottom: 1px solid var(--line);
}

.sidebar-brand strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 720;
}

.sidebar-brand span,
.product-option small,
.step,
.sidebar-foot { color: var(--muted); }

.product-switcher {
  gap: 6px;
  margin: 14px 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.product-option {
  min-height: 54px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #44504c;
}

.product-option:hover {
  border-color: var(--line);
  background: #f8faf9;
}

.product-option.active {
  border-color: #cfe5da;
  background: var(--teal-soft);
  color: var(--ink);
  box-shadow: none;
}

.product-option strong { font-size: 12px; }
.product-option small { color: var(--muted); }

.product-mark {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  color: #fff;
  font-size: 11px;
}

.product-mark.web { background: var(--teal); }
.product-mark.cloud { background: var(--blue); }

.steps {
  gap: 4px;
  padding-top: 4px;
}

.step {
  min-height: 48px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #4f5b57;
  font-size: 13px;
  font-weight: 600;
}

.step:hover {
  border-color: var(--line);
  background: #f8faf9;
  color: var(--ink);
}

.step.active {
  border-color: #cfe5da;
  background: var(--teal-soft);
  color: #125f46;
}

.step > span,
.step.active > span {
  width: 26px;
  height: 26px;
  border: 1px solid #cad3cf;
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  font-size: 10px;
}

.step.active > span {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.step:focus-visible,
.product-option:focus-visible,
.button:focus-visible,
.text-button:focus-visible,
.channel-rename-button:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.nav-alert { border-radius: 999px; }

.sidebar-foot {
  border-color: var(--line);
  color: var(--muted);
}

.sidebar-foot .text-button { color: var(--teal); }

.workspace { min-width: 0; background: var(--canvas); }

.topbar {
  min-height: 78px;
  padding: 17px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
}

.topbar .eyebrow,
.eyebrow {
  color: var(--teal);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0;
}

.topbar h1 {
  margin-top: 3px;
  font-size: 25px;
  line-height: 1.2;
}

.topbar-status { gap: 7px; }

.badge {
  min-height: 24px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 650;
}

.badge.success {
  border-color: #cce9dc;
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.badge.warning {
  border-color: #eadba6;
  background: var(--amber-soft);
  color: #76580d;
}

.badge.neutral {
  border-color: var(--line);
  background: #f3f5f4;
  color: #52605a;
}

.badge.danger {
  border-color: #f0cfcb;
  background: var(--danger-soft);
  color: var(--danger);
}

.workspace > .content-section,
.content-section {
  width: min(1180px, calc(100% - 56px));
  max-width: 1180px;
  margin: 28px auto 48px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.section-heading {
  align-items: flex-end;
  margin-bottom: 20px;
}

.section-heading h2 {
  margin-bottom: 4px;
  font-size: 20px;
}

.section-heading p {
  max-width: 720px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.status-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.status-grid .metric,
.template-metrics div {
  min-height: 116px;
  justify-content: start;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.metric + .metric { border-left: 1px solid var(--line); }

.status-grid .metric:nth-child(1),
.template-metrics div:nth-child(1) {
  border-top: 3px solid var(--teal);
  background: #fff;
}

.status-grid .metric:nth-child(2),
.template-metrics div:nth-child(2) {
  border-top: 3px solid var(--blue);
  background: #fff;
}

.status-grid .metric:nth-child(3),
.template-metrics div:nth-child(3) {
  border-top: 3px solid #d88643;
  background: #fff;
}

.template-metrics div:nth-child(4) {
  border-top: 3px solid #6d68c9;
  background: #fff;
}

.status-grid .metric::after,
.template-metrics div::after { display: none; }

.metric span,
.metric small,
.template-metrics span {
  color: var(--muted);
  opacity: 1;
}

.metric strong,
.template-metrics strong {
  margin: 9px 0 3px;
  color: var(--ink);
  font-family: inherit;
  font-size: 24px;
}

.settings-list {
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.setting-row {
  min-height: 68px;
  padding: 13px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.setting-row:last-child { border-bottom: 0; }

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #eadba6;
  border-radius: 8px;
}

.warning-notice {
  background: var(--amber-soft);
  color: #76580d;
}

.connect-layout {
  grid-template-columns: minmax(0, 1fr) minmax(340px, .75fr);
  gap: 16px;
  align-items: start;
}

.connect-layout:has(.details-panel[hidden]) { grid-template-columns: minmax(0, 1fr); }

.flow-panel,
.details-panel,
.bitrix-panel,
.bitrix-help,
.bitrix-bindings,
.channel-card,
.template-card,
.template-editor,
.template-browser,
.template-preview-panel,
.chat-shell,
.call-layout > section,
.call-layout > aside,
.template-metrics {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.flow-panel,
.details-panel,
.call-layout > section,
.call-layout > aside { padding: 22px; }

.connect-layout:has(.details-panel[hidden]) .flow-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, .75fr);
  gap: 0 28px;
}

.connect-layout:has(.details-panel[hidden]) .flow-panel .connection-mode,
.connect-layout:has(.details-panel[hidden]) .flow-panel .mode-notice,
.connect-layout:has(.details-panel[hidden]) .flow-panel > .button,
.connect-layout:has(.details-panel[hidden]) .flow-panel > .form-error { grid-column: 1; }

.connect-layout:has(.details-panel[hidden]) .flow-list {
  grid-column: 2;
  grid-row: 1 / span 4;
  align-self: center;
  margin: 0;
}

.connection-mode { gap: 8px; margin-bottom: 12px; }
.connection-mode legend { color: var(--ink); font-size: 12px; }

.mode-option {
  min-height: 66px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mode-option:hover { border-color: #b8c5bf; }

.mode-option:has(input:checked) {
  border-color: #9dd5bd;
  background: var(--teal-soft);
  box-shadow: inset 3px 0 var(--teal);
}

.mode-option input { accent-color: var(--teal); }

.mode-option small,
.mode-notice,
.completion-note,
#registrationPinField small { color: var(--muted); }

.mode-notice,
.completion-note,
.chat-template-panel,
.widget-template-preview,
.chat-template-preview {
  border: 1px solid #cfe5da;
  border-radius: 8px;
  background: #f4faf7;
  color: var(--ink);
}

.mode-notice {
  margin-bottom: 16px;
  padding: 11px 12px;
  border-left: 3px solid var(--teal);
}

.flow-list li { min-height: 58px; }

.flow-list li > span,
.flow-list li.current > span,
.flow-list li.done > span,
.bitrix-help li > span {
  border-color: var(--line);
  background: #fff;
  color: var(--muted);
}

.flow-list li.current > span,
.flow-list li.done > span {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.selected-mode,
.id-grid,
.flow-list li,
.setting-row,
.bitrix-binding-row { border-color: var(--line); border-radius: 8px; }

.selected-mode { background: #f4faf7; }
.id-grid { overflow: hidden; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

th {
  background: #f7f9f8;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
}

td { font-size: 13px; }

.channel-actions { white-space: nowrap; }

.channel-rename-button {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}

.channel-rename-button:hover { border-color: #9daca5; background: #f8faf9; }

.panel-heading { border-color: var(--line); }
.bitrix-layout { gap: 16px; }
.bitrix-panel,
.bitrix-help { padding: 20px; }

.bitrix-help li > span {
  border-radius: 7px;
  background: var(--teal-soft);
  color: var(--teal);
}

.bitrix-binding-row { background: #fff; }

.channel-card:hover,
.template-card:hover,
.template-card.selected,
.template-card:focus-visible {
  border-color: #aab8b1;
  background: #fff;
}

.channel-avatar,
.conversation-avatar,
.template-phone-avatar {
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
}

.chat-shell { overflow: hidden; }

.chat-list,
.conversation-sidebar,
.chat-header,
.chat-composer,
.message-composer,
.template-toolbar,
.widget-template-panel {
  border-color: var(--line);
  background: #fff;
}

.chat-item:hover,
.chat-item.active,
.conversation-item:hover,
.conversation-item.active {
  background: #edf5f1;
  box-shadow: none;
}

.chat-item.active,
.conversation-item.active { box-shadow: inset 3px 0 var(--teal); }

.phone-preview,
.chat-messages,
.message-list,
.template-chat-canvas {
  background-color: #f3f6f5;
  background-image: none;
}

.message-bubble,
.preview-message,
.template-message-bubble {
  border: 1px solid var(--line);
  border-radius: 8px 8px 8px 3px;
  background: #fff;
  box-shadow: none;
}

.message-bubble.outbound,
.template-message-bubble {
  border-color: #cce9dc;
  border-radius: 8px 8px 3px 8px;
  background: var(--teal-soft);
}

.message-composer button { background: var(--teal); }

.call-layout { gap: 16px; }

.active-call-card,
.incoming-call-modal {
  border: 1px solid #2d3d36;
  border-radius: 8px;
  background: #21302a;
  color: #fff;
}

.template-preview-button { border-radius: 7px; }

.toast {
  border: 0;
  border-radius: 8px;
  background: #21302a;
  box-shadow: var(--shadow-md);
}

@media (prefers-reduced-motion: no-preference) {
  .content-section,
  .flow-panel,
  .details-panel { animation: none; }
}

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 232px minmax(0, 1fr); }
  .sidebar { width: 232px; padding-inline: 12px; }
  .topbar { padding-inline: 24px; }
  .workspace > .content-section { width: min(1180px, calc(100% - 40px)); }
  .connect-layout:has(.details-panel[hidden]) .flow-panel { grid-template-columns: 1fr; }
  .connect-layout:has(.details-panel[hidden]) .flow-panel .connection-mode,
  .connect-layout:has(.details-panel[hidden]) .flow-panel .mode-notice,
  .connect-layout:has(.details-panel[hidden]) .flow-panel > .button,
  .connect-layout:has(.details-panel[hidden]) .flow-panel > .form-error,
  .connect-layout:has(.details-panel[hidden]) .flow-list { grid-column: 1; grid-row: auto; }
  .connect-layout:has(.details-panel[hidden]) .flow-list { margin: 0 0 16px; }
}

@media (max-width: 800px) {
  html,
  body { overflow-x: hidden; }

  .app-shell {
    width: 100%;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
    overflow: hidden;
  }

  .sidebar {
    position: relative;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    max-height: none;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: hidden;
  }

  .sidebar-brand { padding-bottom: 12px; }

  .product-switcher {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 10px 0;
  }

  .product-option { min-width: 0; }

  .steps {
    width: 100%;
    max-width: 100%;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .step {
    flex: 0 0 auto;
    width: 118px;
    max-width: 118px;
    min-width: 118px;
  }

  .sidebar-foot { display: none; }

  .workspace { min-width: 0; max-width: 100%; }

  .topbar {
    min-height: 70px;
    align-items: flex-start;
    gap: 10px;
    padding: 14px;
  }

  .topbar h1 { font-size: 22px; }
  .workspace > .content-section { width: calc(100% - 28px); margin: 20px 14px 36px; }
  .connect-layout { grid-template-columns: 1fr; }
  .status-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .login-shell { padding: 16px; }
  .login-panel { padding: 28px 22px; }
  .login-panel h1 { font-size: 27px; }
  .topbar { flex-direction: column; }
  .topbar-status { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .flow-panel,
  .details-panel,
  .bitrix-panel,
  .bitrix-help { padding: 18px; }
  .id-grid { grid-template-columns: 1fr; }
  .id-grid div + div { border-top: 1px solid var(--line); border-left: 0; }
}
