/* Techbooster operational UI. This layer intentionally overrides legacy themes. */
:root {
  --bg: #f6f7f7;
  --panel: #ffffff;
  --sidebar: #ffffff;
  --sidebar-soft: #f0f7f4;
  --sidebar-line: #e2e7e5;
  --text: #17201d;
  --muted: #66736e;
  --line: #dfe5e2;
  --line-dark: #cad3cf;
  --accent: #168b62;
  --accent-bright: #23a978;
  --accent-soft: #e9f7f1;
  --lavender: #eef1ff;
  --peach: #fff2e8;
  --sky: #eaf5fb;
  --mint: #e9f7f1;
  --warning-soft: #fff6dc;
  --danger: #c63e3e;
  --danger-soft: #fff0ef;
  --shadow-sm: 0 1px 2px rgba(24, 39, 33, .05);
  --shadow-md: 0 14px 34px rgba(24, 39, 33, .09);
}

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

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

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

h1,
h2,
h3,
.analytics-summary strong,
.operations-summary strong,
.runtime-strip strong {
  color: var(--text);
  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.small {
  width: 36px;
  height: 36px;
}

.boot-page { background: var(--bg); }

.boot-spinner {
  border-color: var(--line);
  border-top-color: var(--accent);
}

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

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

.auth-card .brand-logo { margin-bottom: 24px; }
.auth-card .eyebrow { margin-bottom: 8px; }

.auth-card h1 {
  max-width: 340px;
  font-size: 30px;
  line-height: 1.18;
}

.auth-copy {
  max-width: 340px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.form-stack { gap: 16px; }

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

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

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

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

.primary,
.secondary,
.button {
  min-height: 40px;
  border-radius: 7px;
  font-weight: 650;
  letter-spacing: 0;
}

.primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

.primary:hover {
  border-color: #117654;
  background: #117654;
}

.secondary {
  border: 1px solid var(--line-dark);
  background: #fff;
  color: var(--text);
}

.secondary:hover {
  border-color: #9daca5;
  background: #f8faf9;
}

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

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

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

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

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

.sidebar-brand span,
.product-option small,
.nav-item small,
.setup-progress p,
.sidebar-user span { color: var(--muted); }

.workspace-switcher {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--sidebar-line);
  border-radius: 8px;
  background: #fafbfb;
}

.workspace-switcher label,
.workspace-switcher select { color: var(--text); }

.workspace-switcher select {
  min-height: 38px;
  border-color: var(--line);
  background: #fff;
}

.workspace-switcher > div { gap: 6px; }
.workspace-switcher .small { min-height: 34px; }

.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(--accent-soft);
  color: var(--text);
  box-shadow: none;
}

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

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

.product-mark.web { background: var(--accent); }
.product-mark.cloud { background: #3478d4; }

.main-nav {
  gap: 4px;
  padding-top: 4px;
}

.nav-item {
  min-height: 52px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #4f5b57;
}

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

.nav-item.active {
  border-color: #cfe5da;
  background: var(--accent-soft);
  color: #125f46;
}

.nav-item strong { font-size: 13px; font-weight: 650; }
.nav-item small { font-size: 10px; }
.nav-item i { color: var(--accent); }

.step-number,
.nav-item.active .step-number {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line-dark);
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  font-size: 10px;
}

.nav-item.active .step-number {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.nav-item:focus-visible,
.product-option:focus-visible,
.primary:focus-visible,
.secondary:focus-visible,
.icon-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.setup-progress {
  margin: auto 0 12px;
  padding: 13px;
  border: 1px solid var(--sidebar-line);
  border-radius: 8px;
  background: #fafbfb;
}

.setup-progress .row { color: var(--text); font-size: 11px; }

.progress-track {
  height: 5px;
  background: #e7ece9;
}

.progress-track span { background: var(--accent); }

.sidebar-user {
  border-color: var(--sidebar-line);
  color: var(--text);
}

.user-avatar {
  border-radius: 7px;
  background: #e7eefb;
  color: #2e5e9e;
}

.icon-button {
  color: var(--muted);
  background: transparent;
}

.icon-button:hover { background: #eef2f0; color: var(--text); }

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

.route-view:not(.inbox-view) {
  padding: 30px 34px 52px;
}

.page-header {
  max-width: 1320px;
  min-height: 0;
  align-items: flex-end;
  margin: 0 auto 24px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.page-header h1 {
  margin: 5px 0 7px;
  font-size: 29px;
  line-height: 1.2;
}

.page-header p:not(.eyebrow) {
  max-width: 720px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.eyebrow,
.page-header .eyebrow,
.instruction-panel .eyebrow,
.telegram-settings .eyebrow {
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0;
}

.content-grid,
.channel-type-overview,
.analytics-layout,
.telegram-settings,
.operations-summary,
.operations-grid,
.background-activity-section,
.readiness-strip { max-width: 1320px; }

.channel-type-overview {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 auto 18px;
}

.channel-type-card {
  min-height: 122px;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line) !important;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.channel-type-card.web-channel,
.channel-type-card.cloud-channel,
.channel-type-card.instagram-channel {
  background: #fff;
  color: var(--text);
}

.channel-type-card.web-channel { border-top: 3px solid var(--accent) !important; }
.channel-type-card.cloud-channel { border-top: 3px solid #3478d4 !important; }
.channel-type-card.instagram-channel { border-top: 3px solid #d84f8c !important; }

.channel-type-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
}

.cloud-channel .channel-type-icon { background: #edf3fc; color: #3478d4; }
.instagram-channel .channel-type-icon { background: #fceef5; color: #c63c78; }

.channel-type-card > div:nth-child(2) > span {
  color: var(--muted);
  font-size: 9px;
  opacity: 1;
}

.channel-type-card strong {
  margin-top: 2px;
  font-size: 21px;
  line-height: 1.2;
}

.channel-type-card small {
  max-width: 240px;
  color: var(--muted);
  opacity: 1;
}

.channel-type-card > :last-child { grid-column: 2; align-self: end; justify-self: start; }

.content-grid { gap: 16px; }
.channels-layout,
.bitrix-layout { grid-template-columns: minmax(0, 1fr) 310px; }

.content-section,
.instruction-panel,
.connection-card,
.integration-item,
.binding-row,
.operation-row,
.meta-campaign,
.meta-adset,
.analytics-ad-row,
.analytics-report-row,
.workspace-dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.content-section,
.instruction-panel { padding: 22px; }

.section-heading { margin-bottom: 18px; }
.section-heading h2 { font-size: 18px; }
.section-heading p { color: var(--muted); line-height: 1.45; }

.runtime-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.runtime-strip span {
  padding: 13px 15px;
  border-right: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

.runtime-strip span:last-child { border-right: 0; }
.runtime-strip strong { margin-bottom: 2px; font-size: 18px; }

.connection-list { gap: 10px; }
.connection-card { padding: 16px; }

.connection-card:hover,
.integration-item:hover { border-color: #bdc8c3; }

.channel-avatar,
.contact-avatar,
.instruction-list li > span {
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
}

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

.status.connected,
.telegram-status.ready {
  border-color: #cce9dc;
  background: var(--accent-soft);
  color: #117654;
}

.status.waiting_qr,
.status.waiting_code,
.status.connecting,
.status.reconnecting {
  border-color: #eadba6;
  background: var(--warning-soft);
  color: #76580d;
}

.status.error,
.status.banned,
.status.logged_out {
  border-color: #f0cfcb;
  background: var(--danger-soft);
  color: var(--danger);
}

.empty-block,
.empty-inline,
.empty-list {
  border-color: var(--line);
  border-radius: 8px;
  background: #fafbfb;
}

.instruction-list { gap: 16px; }
.instruction-list p { line-height: 1.45; }
.notice { border-color: #d8e4df; background: #f4faf7; }

.toggle-field { position: relative; }

.toggle-field > input {
  width: 1px;
  height: 1px;
  min-height: 0;
  margin: 0;
}

.readiness-strip,
.analytics-summary,
.operations-summary {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  border: 0;
  background: transparent;
}

.readiness-strip > div,
.analytics-summary > div,
.operations-summary > div {
  min-height: 112px;
  justify-content: start;
  padding: 18px;
  border: 1px solid var(--line) !important;
  border-radius: 8px;
  background: #fff !important;
  box-shadow: var(--shadow-sm);
}

.readiness-strip > div::after,
.analytics-summary > div::after,
.operations-summary > div::after { display: none; }

.readiness-strip > div:nth-child(1),
.analytics-summary > div:nth-child(1),
.operations-summary > div:nth-child(1) { border-top: 3px solid var(--accent) !important; }

.readiness-strip > div:nth-child(2),
.analytics-summary > div:nth-child(2),
.operations-summary > div:nth-child(2) { border-top: 3px solid #6d68c9 !important; }

.readiness-strip > div:nth-child(3),
.analytics-summary > div:nth-child(3),
.operations-summary > div:nth-child(3) { border-top: 3px solid #dc7a43 !important; }

.analytics-summary > div:nth-child(4),
.operations-summary > div:nth-child(4) { border-top: 3px solid #3484aa !important; }

.readiness-strip span,
.readiness-strip small,
.analytics-summary span,
.analytics-summary small,
.operations-summary span,
.operations-summary small { color: var(--muted); opacity: 1; }

.readiness-strip strong,
.analytics-summary strong,
.operations-summary strong {
  margin: 9px 0 3px;
  color: var(--text);
  font-family: inherit;
  font-size: 28px;
}

.analytics-filters {
  border-color: var(--line);
  border-radius: 8px;
  background: #fff;
}

.analytics-chart { min-height: 280px; }

.analytics-bar {
  border: 0;
  border-radius: 5px 5px 0 0;
  background: var(--accent);
}

.analytics-bar-column:nth-child(6n) .analytics-bar,
.analytics-bar-column:nth-child(6n + 1) .analytics-bar { background: #4c83ca; }

.meta-metrics {
  border-color: var(--line);
  border-radius: 7px;
  background: var(--line);
}

.inbox-view { background: var(--bg); }
.inbox-topbar { min-height: 72px; border-color: var(--line); }

.inbox-grid {
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.chat-column,
.contact-column,
.conversation-header,
.composer { background: #fff; }

.conversation-column,
.message-list { background-color: #f3f6f5; }
.chat-row { border-radius: 0; }

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

.chat-row.active { box-shadow: inset 3px 0 var(--accent); }

.message-bubble {
  border-color: var(--line);
  border-radius: 8px 8px 8px 3px;
  background: #fff;
}

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

.composer-icon,
.send-button { background: var(--accent); }

.profile-avatar {
  border-radius: 8px;
  background: #edf3fc;
  color: #3478d4;
}

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

@media (prefers-reduced-motion: no-preference) {
  .content-section,
  .channel-type-card,
  .connection-card { animation: none; }
}

@media (max-width: 1180px) {
  .app-layout { grid-template-columns: 232px minmax(0, 1fr); }
  .sidebar { width: 232px; padding-inline: 12px; }
  .route-view:not(.inbox-view) { padding-inline: 24px; }
  .channels-layout,
  .bitrix-layout { grid-template-columns: 1fr; }
  .instruction-panel { order: 2; }
}

@media (max-width: 900px) {
  .channel-type-overview { grid-template-columns: 1fr; }
  .channel-type-card { min-height: 104px; }
}

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

  .app-layout {
    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; }
  .workspace-switcher { display: none; }

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

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

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

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

  .nav-item small,
  .setup-progress,
  .sidebar-user { display: none; }

  .workspace { min-width: 0; max-width: 100%; }
  .route-view:not(.inbox-view) { min-width: 0; padding: 20px 14px 40px; }
  .page-header { align-items: flex-start; flex-direction: column; gap: 14px; }
  .page-header h1 { font-size: 26px; }

  .readiness-strip,
  .analytics-summary,
  .operations-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .runtime-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .runtime-strip span:nth-child(2) { border-right: 0; }
  .runtime-strip span:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 520px) {
  .auth-page { padding: 16px; }
  .auth-card { padding: 28px 22px; }
  .auth-card h1 { font-size: 27px; }
  .content-section,
  .instruction-panel { padding: 18px; }
  .readiness-strip,
  .analytics-summary,
  .operations-summary { grid-template-columns: 1fr; }
  .channel-type-card { grid-template-columns: 38px minmax(0, 1fr); }
  .channel-type-icon { width: 38px; height: 38px; }
}
