:root {
  color-scheme: light;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eff6ff;
  --text: #172033;
  --muted: #64748b;
  --border: #dbe3ef;
  --surface: #ffffff;
  --background: #f4f7fb;
  --danger: #dc2626;
  --shadow: 0 12px 32px rgba(30, 64, 175, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background: var(--background);
}

button, input, select { font: inherit; }

.page-shell {
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
  padding: 48px 0 72px;
}

.page-header, .section-heading, .form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.page-header { margin-bottom: 28px; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.brand__mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 6px 14px rgba(37, 99, 235, .22);
  font-size: .95rem;
  font-weight: 850;
  letter-spacing: -.03em;
}
.brand__label {
  color: #475569;
  font-size: .84rem;
  font-weight: 750;
  letter-spacing: .01em;
}
.eyebrow { margin: 0 0 6px; color: var(--accent); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(2rem, 5vw, 2.75rem); line-height: 1.05; letter-spacing: -0.04em; }
h2 { margin-bottom: 22px; font-size: 1.25rem; }
.subtitle { margin-bottom: 0; color: var(--muted); }

.lead-counter {
  min-width: 110px;
  padding: 14px 18px;
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  text-align: center;
  background: var(--accent-soft);
}
.lead-counter span { display: block; color: var(--muted); font-size: 0.75rem; }
.lead-counter strong { color: var(--accent); font-size: 1.65rem; }

.workspace {
  padding: 28px;
  border: 1px solid rgba(219, 227, 239, 0.8);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.field-group { min-width: 0; }
.field-group--wide { grid-column: 1 / -1; }
.field-group > label:not(.switch-row) { display: block; margin-bottom: 8px; font-size: 0.88rem; font-weight: 700; }
label span[aria-hidden="true"], .required-note span { color: var(--danger); }

input[type="text"], input[type="tel"], select {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input::placeholder { color: #94a3b8; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14); }
input.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1); }
.field-error { min-height: 18px; margin: 5px 0 -3px; color: var(--danger); font-size: 0.78rem; }

.switch-row { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 650; }
.switch-row input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch { position: relative; width: 42px; height: 24px; border-radius: 999px; background: #cbd5e1; transition: background 0.2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: white; box-shadow: 0 1px 4px rgba(0,0,0,.2); transition: transform 0.2s; }
.switch-row input:checked + .switch { background: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.switch-row input:focus-visible + .switch { outline: 3px solid rgba(37, 99, 235, .25); outline-offset: 2px; }

.form-actions { margin-top: 26px; padding-top: 20px; border-top: 1px solid #eef2f7; }
.required-note { margin: 0; color: var(--muted); font-size: 0.8rem; }
.primary-button { padding: 12px 26px; border: 0; border-radius: 10px; color: #fff; background: var(--accent); font-weight: 750; cursor: pointer; box-shadow: 0 7px 18px rgba(37,99,235,.22); transition: background 0.2s, transform 0.2s; }
.primary-button:hover { background: var(--accent-dark); transform: translateY(-1px); }
.primary-button:focus-visible { outline: 3px solid rgba(37,99,235,.3); outline-offset: 3px; }

.leads-section { margin-top: 42px; }
.section-heading h2 { margin-bottom: 0; font-size: 1.45rem; }
.empty-state { margin-top: 20px; padding: 46px 20px; border: 1px dashed #cbd5e1; border-radius: 18px; text-align: center; background: rgba(255,255,255,.55); }
.empty-state[hidden] { display: none; }
.empty-icon { display: grid; place-items: center; width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 50%; color: var(--accent); background: var(--accent-soft); font-size: 1.6rem; }
.empty-state h3 { margin-bottom: 6px; }
.empty-state p { margin-bottom: 0; color: var(--muted); }

.leads-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 20px; }
.lead-card { padding: 22px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: 0 6px 22px rgba(15,23,42,.05); }
.lead-card__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.lead-card__name { margin: 0 0 5px; font-size: 1.12rem; overflow-wrap: anywhere; }
.lead-card__phone { color: var(--muted); text-decoration: none; overflow-wrap: anywhere; }
.lead-card__phone:hover { color: var(--accent); }
.badge { flex: 0 0 auto; padding: 5px 9px; border-radius: 999px; font-size: .72rem; font-weight: 750; }
.badge--cold { color: #1d4ed8; background: #dbeafe; }
.badge--warm { color: #b45309; background: #fef3c7; }
.lead-details { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 0 0 18px; }
.lead-details div { min-width: 0; }
.lead-details dt { margin-bottom: 3px; color: var(--muted); font-size: .74rem; }
.lead-details dd { margin: 0; font-size: .9rem; font-weight: 650; overflow-wrap: anywhere; }
.card-stage { padding-top: 16px; border-top: 1px solid #eef2f7; }
.card-stage label { display: block; margin-bottom: 7px; color: var(--muted); font-size: .75rem; font-weight: 700; }
.card-stage select { min-height: 40px; font-size: .88rem; font-weight: 650; }
.card-stage select[data-stage="Новый лид"] { color: #1d4ed8; background: #eff6ff; }
.card-stage select[data-stage="Квалифицирован"] { color: #047857; background: #ecfdf5; }
.card-stage select[data-stage="Назначена консультация"] { color: #7c3aed; background: #f5f3ff; }
.card-stage select[data-stage="Отказ"] { color: #b91c1c; background: #fef2f2; }

.notification { position: fixed; right: 24px; bottom: 24px; max-width: calc(100% - 48px); padding: 12px 18px; border-radius: 10px; color: #fff; background: #047857; box-shadow: 0 12px 30px rgba(15,23,42,.2); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .25s, transform .25s; }
.notification.is-visible { opacity: 1; transform: translateY(0); }
.notification.is-error { background: var(--danger); }

@media (max-width: 680px) {
  .page-shell { width: min(100% - 24px, 1080px); padding: 28px 0 48px; }
  .page-header { align-items: flex-end; }
  .lead-counter { min-width: 86px; padding: 10px 12px; }
  .workspace { padding: 20px 16px; border-radius: 16px; }
  .form-grid, .leads-grid { grid-template-columns: 1fr; }
  .field-group--wide { grid-column: auto; }
  .primary-button { width: 100%; }
  .form-actions { flex-direction: column-reverse; align-items: stretch; }
  .required-note { text-align: center; }
}

@media (max-width: 440px) {
  .page-header { align-items: flex-start; flex-direction: column; gap: 16px; }
  .lead-counter { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; }
  .lead-counter strong { margin-left: auto; }
  .lead-card__top { flex-direction: column; }
  .lead-details { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
