:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #687385;
  --line: #d8dee8;
  --accent: #176f65;
  --accent-strong: #0f574f;
  --danger: #a33a3a;
  --shadow: 0 8px 24px rgba(20, 31, 45, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

body.landing-page {
  display: block;
  background: #f4f7f6;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

.button.ghost {
  background: #fff;
  color: var(--accent-strong);
}

button:hover {
  background: var(--accent-strong);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 15px;
}

.sidebar {
  min-height: 100vh;
  padding: 20px 16px;
  border-right: 1px solid var(--line);
  background: #111820;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 6px;
  background: #dfeee9;
  color: #0f574f;
  font-weight: 800;
}

.brand-mark-convarto {
  position: relative;
  overflow: hidden;
  background: #111820;
  color: #9ee0c8;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

.brand-mark-convarto::after {
  content: "";
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #33c6a6;
  box-shadow: 0 0 0 5px rgba(51, 198, 166, 0.14);
}

.brand-word {
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-weight: 900;
  letter-spacing: 0;
}

.brand small {
  display: block;
  margin-top: 3px;
  color: #b6c1cf;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: block;
  width: 100%;
  border-color: transparent;
  background: transparent;
  color: #dce3eb;
  text-align: left;
  text-decoration: none;
}

.nav-item:hover,
.nav-item.active {
  background: #22303c;
}

.shell {
  padding: 24px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: start;
  margin-bottom: 18px;
}

.topbar p {
  margin-top: 5px;
  color: var(--muted);
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.status {
  margin-bottom: 18px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #eef5f3;
  color: var(--accent-strong);
}

.status.error {
  background: #fff1f1;
  color: var(--danger);
}

.tab {
  display: none;
}

.tab.active {
  display: block;
}

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

.layout {
  display: grid;
  gap: 16px;
}

.layout.two {
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
}

.panel,
.chat-shell {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.form-grid {
  display: grid;
  gap: 12px;
}

.editor {
  display: grid;
  gap: 12px;
}

.list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.item.selected {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.item strong {
  display: block;
  margin-bottom: 4px;
}

.item small {
  color: var(--muted);
}

.unanswered-item {
  cursor: pointer;
}

.inline-answer-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.search-input {
  margin-top: 12px;
}

.code-block {
  min-height: 160px;
  max-height: 360px;
  overflow: auto;
  margin: 12px 0 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #111820;
  color: #dce3eb;
  white-space: pre-wrap;
  line-height: 1.45;
}

.channel-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
}

.lead-contact {
  margin: 8px 0;
  color: var(--ink);
  font-weight: 600;
}

.actions-row,
.onboarding-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.onboarding-panel {
  margin-bottom: 18px;
}

.onboarding-step {
  background: #fff;
  color: var(--accent-strong);
}

.onboarding-step.done {
  border-color: #176f65;
  background: #dfeee9;
  color: #0f574f;
}

.onboarding-step.done::after {
  content: " done";
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.lead-filters {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) minmax(120px, 0.7fr) minmax(180px, 1.4fr);
  gap: 8px;
}

.telegram-test-form {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.widget-preview iframe {
  width: 100%;
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6f7f9;
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  display: grid;
  gap: 6px;
}

.stat small {
  color: var(--muted);
}

.stat strong {
  font-size: 28px;
}

.plain-list {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.compact-list {
  align-content: start;
}

.badge {
  display: inline-grid;
  place-items: center;
  min-height: 22px;
  margin-left: 6px;
  border-radius: 999px;
  padding: 3px 8px;
  background: #eef1f5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.badge.ok,
.badge.open {
  background: #dfeee9;
  color: var(--accent-strong);
}

.badge.warning,
.badge.degraded {
  background: #fff4d8;
  color: #7a5414;
}

.badge.down,
.badge.critical {
  background: #fff1f1;
  color: var(--danger);
}

code {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  background: #f6f7f9;
  color: var(--ink);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

a {
  color: var(--accent-strong);
}

.chat-shell {
  display: grid;
  grid-template-rows: minmax(320px, 52vh) auto;
  gap: 12px;
}

.chat-log,
.messages {
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
}

.bubble {
  max-width: 78%;
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.45;
  background: #eef1f5;
}

.bubble.user {
  justify-self: end;
  background: #dfeee9;
}

.bubble.assistant {
  justify-self: start;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.checkbox {
  grid-template-columns: auto 1fr;
  align-items: center;
  color: var(--ink);
}

.checkbox input {
  width: 18px;
  height: 18px;
}

.landing-hero,
.landing-section,
.landing-footer {
  padding: 26px max(22px, calc((100vw - 1160px) / 2));
}

.landing-hero {
  min-height: 720px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(244, 247, 246, 0.94)),
    url("https://images.unsplash.com/photo-1556745757-8d76bdb6984b?auto=format&fit=crop&w=1800&q=80") center/cover;
}

.landing-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 10px 0 46px;
}

.landing-logo,
.landing-actions,
.hero-actions,
.trust-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.landing-logo {
  color: var(--ink);
  text-decoration: none;
  font-size: 18px;
}

.language-select {
  position: fixed;
  top: 14px;
  right: 18px;
  z-index: 80;
  width: 68px;
  min-height: 32px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  gap: 34px;
  align-items: center;
}

.hero-copy h1 {
  max-width: 820px;
  font-size: clamp(38px, 6vw, 70px);
  line-height: 1.02;
}

.eyebrow {
  display: inline-flex;
  margin-bottom: 14px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.lead {
  max-width: 690px;
  margin: 20px 0 24px;
  color: #4f5d6a;
  font-size: 20px;
  line-height: 1.45;
}

.trust-row {
  flex-wrap: wrap;
  margin-top: 22px;
  color: #344250;
  font-weight: 700;
}

.trust-row span {
  border: 1px solid rgba(23, 111, 101, 0.22);
  border-radius: 999px;
  padding: 8px 11px;
  background: rgba(255, 255, 255, 0.68);
}

.hero-visual {
  min-width: 0;
}

.dashboard-preview {
  border: 1px solid rgba(216, 222, 232, 0.95);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 20px 50px rgba(20, 31, 45, 0.18);
  transform: translateY(0);
  animation: previewFloat 7s ease-in-out infinite;
}

.preview-top {
  display: flex;
  justify-content: space-between;
  padding: 16px;
  background: #111820;
  color: #fff;
}

.preview-top span {
  color: #9ee0c8;
}

.preview-chat {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.preview-chat .bubble {
  transition: transform 0.28s ease, opacity 0.28s ease;
}

.preview-chat .bubble.is-live {
  transform: translateY(-2px);
}

.preview-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}

.preview-stats div {
  display: grid;
  gap: 3px;
  padding: 16px;
  background: #fff;
}

.preview-stats strong {
  font-size: 26px;
}

.preview-stats small {
  color: var(--muted);
}

.section-title {
  max-width: 760px;
  margin-bottom: 18px;
}

.section-title h2,
.split-section h2,
.cta-band h2 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.08;
}

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

.feature-card,
.lead-form,
.steps div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fff;
  box-shadow: var(--shadow);
}

.feature-card,
.steps div {
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.feature-card:hover,
.steps div:hover {
  border-color: rgba(23, 111, 101, 0.36);
  transform: translateY(-3px);
  box-shadow: 0 14px 36px rgba(20, 31, 45, 0.12);
}

.feature-card p,
.steps p,
.cta-band p {
  margin-top: 9px;
  color: var(--muted);
  line-height: 1.5;
}

.split-section,
.cta-band {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(360px, 1.1fr);
  gap: 24px;
  align-items: start;
}

.steps {
  display: grid;
  gap: 12px;
}

.steps strong {
  color: var(--accent-strong);
}

.lead-form {
  display: grid;
  gap: 10px;
}

.lead-form small.error {
  color: var(--danger);
}

.landing-footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
}

@keyframes previewFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

.auth-only {
  display: none;
}

body.authenticated .auth-only {
  display: initial;
}

body.authenticated section.auth-only {
  display: block;
}

body.authenticated .tab.auth-only:not(.active) {
  display: none;
}

body.authenticated .nav.auth-only,
body.authenticated .layout.auth-only,
body.authenticated .grid-stats.auth-only {
  display: grid;
}

@media (max-width: 920px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar,
  .layout.two,
  .lead-filters,
  .auth-panel,
  .grid-stats,
  .hero-grid,
  .feature-grid,
  .split-section,
  .cta-band {
    grid-template-columns: 1fr;
    display: grid;
  }

  .landing-hero {
    min-height: auto;
  }

  .landing-actions,
  .hero-actions,
  .landing-footer {
    flex-wrap: wrap;
  }
}
