:root {
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-muted: #f3f6fb;
  --line: #dbe3ee;
  --line-strong: #c9d5e5;
  --text: #223145;
  --text-soft: #6f7f95;
  --text-muted: #8f9db1;
  --blue: #2fc6f6;
  --blue-strong: #1aaee0;
  --blue-soft: #e9f8ff;
  --green: #67d28f;
  --green-soft: #ebfaef;
  --shadow: 0 10px 24px rgba(26, 46, 76, 0.05);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #f4f7fb 0%, #eef2f6 100%);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

.bitrix-shell {
  width: min(1320px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 36px;
}

.page-header,
.utility-bar,
.crm-panel,
.bitrix-tabs {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 20px;
  margin-bottom: 14px;
}

.page-header h1,
.panel-head h2,
.crm-panel h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.micro-label {
  margin: 0 0 6px;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7d91ab;
}

.context-line,
.utility-copy p,
.side-muted,
.inline-status {
  margin: 6px 0 0;
  color: var(--text-soft);
  line-height: 1.45;
}

.header-actions,
.utility-auth,
.panel-actions,
.stack-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pill,
.soft-chip,
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.85rem;
}

.muted-pill {
  background: var(--surface-muted);
  color: var(--text-soft);
  border: 1px solid var(--line);
}

.soft-chip {
  background: var(--blue-soft);
  color: #277db1;
  border: 1px solid rgba(47, 198, 246, 0.2);
}

.status-badge.neutral {
  background: var(--surface-muted);
  color: var(--text-soft);
  border: 1px solid var(--line);
}

.status-badge.positive {
  background: var(--green-soft);
  color: #2f8a55;
  border: 1px solid rgba(103, 210, 143, 0.35);
}

.status-badge.negative {
  background: #fff4f4;
  color: #b45b5b;
  border: 1px solid #f0d2d2;
}

.bitrix-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
}

.bitrix-tab {
  padding: 9px 14px;
  border-radius: 10px;
  color: var(--text-soft);
  white-space: nowrap;
  font-size: 0.95rem;
}

.bitrix-tab.active {
  background: #edf7ff;
  color: #117cac;
  box-shadow: inset 0 -2px 0 var(--blue);
}

.bitrix-tab.disabled {
  opacity: 0.5;
}

.utility-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px 18px;
  margin-bottom: 14px;
}

.utility-copy {
  min-width: 0;
}

.utility-copy strong {
  display: block;
  font-size: 0.96rem;
}

.utility-auth {
  margin-left: auto;
  display: grid;
  justify-items: end;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.utility-auth-summary,
.utility-auth-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.utility-auth-form {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.utility-auth-form input {
  width: min(240px, 100%);
}

.button.ghost {
  background: transparent;
  color: var(--text-soft);
  border-color: var(--line);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(290px, 0.75fr);
  gap: 14px;
  margin-bottom: 14px;
}

.sidebar-stack {
  display: grid;
  gap: 14px;
}

.crm-panel {
  padding: 18px 20px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.compact-field {
  max-width: 220px;
}

.field span {
  font-size: 0.92rem;
  color: var(--text-soft);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #8cdaf4;
  box-shadow: 0 0 0 4px rgba(47, 198, 246, 0.12);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button.primary {
  background: linear-gradient(180deg, var(--blue) 0%, var(--blue-strong) 100%);
  color: #fff;
  box-shadow: 0 8px 18px rgba(47, 198, 246, 0.22);
}

.button.secondary {
  background: var(--surface-muted);
  color: var(--text);
  border-color: var(--line);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.panel-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.form-panel {
  margin-bottom: 8px;
}

.form-root {
  display: grid;
  gap: 14px;
}

.form-section {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  padding: 14px;
}

.form-section-header,
.array-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.array-list {
  display: grid;
  gap: 12px;
}

.array-card {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 14px;
}

.button-danger {
  background: #fff4f4;
  color: #b45b5b;
  border-color: #f0d2d2;
}

.step-list,
.bullet-list {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--text-soft);
  line-height: 1.55;
}

.step-list li,
.bullet-list li {
  margin-bottom: 8px;
}

.result-box {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  background: var(--surface-soft);
  color: var(--text);
}

.hidden {
  display: none;
}

@media (max-width: 1040px) {
  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .bitrix-shell {
    width: min(100% - 16px, 1320px);
  }

  .page-header,
  .utility-bar,
  .panel-head,
  .header-actions,
  .utility-auth,
  .utility-auth-summary,
  .utility-auth-form,
  .panel-actions,
  .stack-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .utility-auth {
    width: 100%;
    justify-items: stretch;
  }

  .compact-field {
    max-width: none;
  }
}
