/* BALANCE · AI Lead Factory — базовые токены и элементы */

:root {
  color-scheme: light;
  --bg: #f6f2ea;
  --bg-deep: #efe9dd;
  --surface: #fffdf8;
  --surface-2: #f1ece2;
  --surface-3: #e9e3d7;
  --ink: #23261f;
  --ink-soft: #5a5f55;
  --ink-muted: #7c8076;
  --line: #ded7c8;
  --line-strong: #c9c1b0;
  --accent: #4f6b57;
  --accent-strong: #3e5746;
  --accent-soft: #e6ebe1;
  --accent-ink: #2f4437;
  --hot: #a34e36;
  --hot-soft: #f6e7e1;
  --warm: #8f6429;
  --warm-soft: #f4ead7;
  --cold: #4e6472;
  --cold-soft: #e8eef1;
  --unknown: #6b5b7c;
  --unknown-soft: #eee9f2;
  --danger: #9c3f36;
  --danger-soft: #f8e7e4;
  --success: #416d4f;
  --success-soft: #e5efe6;
  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 2px rgba(35, 38, 31, 0.04);
  --shadow: 0 1px 2px rgba(35, 38, 31, 0.04), 0 18px 40px -28px rgba(35, 38, 31, 0.4);
  --font-sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  --maxw: 1180px;
  --header-h: 68px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141713;
  --bg-deep: #10130f;
  --surface: #1c201a;
  --surface-2: #242920;
  --surface-3: #2c3228;
  --ink: #eeeae1;
  --ink-soft: #b6baae;
  --ink-muted: #8e9387;
  --line: #30362c;
  --line-strong: #41483b;
  --accent: #96b49e;
  --accent-strong: #b0c8b6;
  --accent-soft: #253027;
  --accent-ink: #dceade;
  --hot: #d9927a;
  --hot-soft: #3a2721;
  --warm: #d3a45f;
  --warm-soft: #362c1e;
  --cold: #9bb6c4;
  --cold-soft: #232e34;
  --unknown: #b7a5c7;
  --unknown-soft: #2d2733;
  --danger: #dd8a7f;
  --danger-soft: #3a2422;
  --success: #9ac7a5;
  --success-soft: #223026;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 18px 40px -28px rgba(0, 0, 0, 0.7);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-underline-offset: 3px;
}

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

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

::selection {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 300;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
}
.skip-link:focus {
  top: 12px;
}

.container {
  width: min(var(--maxw), calc(100% - 40px));
  margin-inline: auto;
}

.eyebrow {
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.serif {
  font-family: var(--font-serif);
}

.muted {
  color: var(--ink-muted);
}

.nowrap {
  white-space: nowrap;
}

.btn {
  --btn-bg: var(--surface);
  --btn-ink: var(--ink);
  --btn-border: var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  padding: 11px 20px;
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-size: 0.93rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}
.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0);
}
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.btn-primary {
  --btn-bg: var(--accent);
  --btn-ink: #fffdf8;
  --btn-border: var(--accent);
}
.btn-primary:hover {
  --btn-bg: var(--accent-strong);
  --btn-border: var(--accent-strong);
}

.btn-secondary {
  --btn-bg: transparent;
  --btn-border: var(--line-strong);
}
.btn-secondary:hover {
  --btn-bg: var(--surface);
}

.btn-quiet {
  --btn-bg: transparent;
  --btn-border: transparent;
  color: var(--ink-soft);
  min-height: 38px;
  padding: 7px 10px;
}
.btn-quiet:hover {
  --btn-bg: var(--surface-2);
}

.btn-danger {
  --btn-bg: var(--danger);
  --btn-ink: #fff;
  --btn-border: var(--danger);
}

.btn-sm {
  min-height: 36px;
  padding: 7px 13px;
  font-size: 0.84rem;
  border-radius: 8px;
}

.btn-lg {
  min-height: 52px;
  padding: 14px 26px;
  font-size: 1rem;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 0.73rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  line-height: 1.5;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}
.badge.no-dot::before {
  display: none;
}
.badge.hot {
  color: var(--hot);
  background: var(--hot-soft);
  border-color: color-mix(in srgb, var(--hot) 24%, transparent);
}
.badge.warm {
  color: var(--warm);
  background: var(--warm-soft);
  border-color: color-mix(in srgb, var(--warm) 24%, transparent);
}
.badge.cold {
  color: var(--cold);
  background: var(--cold-soft);
  border-color: color-mix(in srgb, var(--cold) 24%, transparent);
}
.badge.unknown {
  color: var(--unknown);
  background: var(--unknown-soft);
  border-color: color-mix(in srgb, var(--unknown) 24%, transparent);
}
.badge.success {
  color: var(--success);
  background: var(--success-soft);
  border-color: color-mix(in srgb, var(--success) 24%, transparent);
}
.badge.neutral {
  color: var(--ink-soft);
  background: var(--surface-2);
}
.badge.demo {
  color: var(--ink-muted);
  border-style: dashed;
}
.badge.demo::before {
  background: var(--ink-muted);
}

.field {
  display: grid;
  gap: 7px;
}
.field > label,
.field-label {
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--ink-soft);
}
.field .hint {
  font-size: 0.78rem;
  color: var(--ink-muted);
  line-height: 1.45;
}
.input,
.select,
.select-sm,
.textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  padding: 11px 13px;
  font-size: 0.95rem;
  line-height: 1.4;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.input::placeholder,
.textarea::placeholder {
  color: var(--ink-muted);
  opacity: 0.8;
}
.input:hover,
.select:hover,
.select-sm:hover,
.textarea:hover {
  border-color: color-mix(in srgb, var(--line-strong) 60%, var(--ink-muted));
}
.input:focus,
.select:focus,
.select-sm:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
.textarea {
  resize: vertical;
  min-height: 84px;
}
.select,
.select-sm {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%237c8076' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 34px;
}

/* Первопричина тёмной темы: native option list не наследует фон select.
   color-scheme + явные цвета option/disabled убирают белый текст на белом фоне. */
select option,
select optgroup {
  color: var(--ink);
  background-color: var(--surface);
}

select option:checked {
  color: var(--accent-ink);
  background-color: var(--accent-soft);
}

select:disabled,
select option:disabled {
  color: var(--ink-muted);
  background-color: var(--surface-2);
  opacity: 1;
  cursor: not-allowed;
}

.select:focus-visible,
.select-sm:focus-visible,
.input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

/* Календарь: native-контрол получает схему темы, иконка не теряется. */
input[type="date"],
input[type="datetime-local"],
input[type="time"] {
  color-scheme: inherit;
  cursor: text;
}

input[type="date"]::-webkit-datetime-edit,
input[type="datetime-local"]::-webkit-datetime-edit,
input[type="time"]::-webkit-datetime-edit {
  color: var(--ink);
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.72;
}

input[type="date"]:hover::-webkit-calendar-picker-indicator,
input[type="date"]:focus::-webkit-calendar-picker-indicator,
input[type="datetime-local"]:hover::-webkit-calendar-picker-indicator,
input[type="datetime-local"]:focus::-webkit-calendar-picker-indicator,
input[type="time"]:hover::-webkit-calendar-picker-indicator,
input[type="time"]:focus::-webkit-calendar-picker-indicator {
  opacity: 1;
}

input[type="date"]:disabled,
input[type="datetime-local"]:disabled {
  color: var(--ink-muted);
  background: var(--surface-2);
  opacity: 1;
}
.input[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 14%, transparent);
}
.error-text {
  min-height: 0;
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 600;
}

.check {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  align-items: start;
  cursor: pointer;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--ink-soft);
}
.check input {
  appearance: none;
  width: 19px;
  height: 19px;
  margin: 1px 0 0;
  border: 1.5px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  display: grid;
  place-content: center;
  cursor: pointer;
}
.check input::before {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) scale(0);
  transform-origin: center;
  margin-top: -2px;
  transition: transform 100ms ease;
}
.check input:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.check input:checked::before {
  transform: rotate(-45deg) scale(1);
}
.check a {
  color: var(--ink);
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.choice {
  position: relative;
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.4;
  transition: border-color 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}
.choice:hover {
  border-color: var(--line-strong);
  background: color-mix(in srgb, var(--surface) 60%, var(--surface-2));
}
.choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.choice .choice-mark {
  width: 17px;
  height: 17px;
  margin-top: 2px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  flex: none;
  position: relative;
}
.choice input:checked ~ .choice-mark {
  border-color: var(--accent);
  background: var(--accent);
}
.choice input:checked ~ .choice-mark::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #fff;
}
.choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.choice input:focus-visible ~ .choice-mark {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}
.segmented label {
  position: relative;
  cursor: pointer;
}
.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.segmented span {
  display: inline-flex;
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
}
.segmented input:checked + span {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.divider {
  height: 1px;
  background: var(--line);
  border: 0;
  margin: 0;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.85em;
  font-variant-numeric: tabular-nums;
}

.tnum {
  font-variant-numeric: tabular-nums;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.demo-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  justify-content: center;
  padding: 7px 16px;
  background: var(--accent-ink);
  color: #eef3ec;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  text-align: center;
}
.demo-strip a {
  color: #fff;
  text-decoration-color: rgba(255, 255, 255, 0.5);
  font-weight: 600;
}
.demo-strip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c9dcc9;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 500;
  max-width: min(380px, calc(100vw - 40px));
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 0.88rem;
  transform: translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast.error {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--line));
  color: var(--danger);
}

@media (max-width: 640px) {
  .choice-grid {
    grid-template-columns: 1fr;
  }
  .container {
    width: calc(100% - 32px);
  }
}

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

@media print {
  .demo-strip,
  .site-header,
  .flow,
  .toast {
    display: none !important;
  }
}

/* Production public profile: no demo bar/demo phone controls. */
[data-public-profile="production"] .b-demo-bar,
[data-public-profile="production"] .demo-fill {
  display: none !important;
}
