/* КардиоМетабол — дизайн-система v2: прохладный монохром + электрический индиго
   Ключевые принципы: воздух, 1px-границы вместо теней, скруглённые пилюли,
   градиентные акценты, крупная типографика с плотным трекингом. */
:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --line: #e2e8f0;
  --line-soft: #eef2f7;
  --ink: #0f172a;
  --ink-2: #334155;
  --ink-soft: #64748b;
  --ink-faint: #64748b;
  --indigo: #4f46e5;
  --indigo-2: #6366f1;
  --violet: #8b5cf6;
  --indigo-soft: #eef2ff;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #a78bfa 100%);
  --grad-dark: linear-gradient(135deg, #1e1b4b 0%, #312e81 55%, #4c1d95 100%);
  --green: #10b981;
  --green-soft: #ecfdf5;
  --amber: #f59e0b;
  --amber-soft: #fffbeb;
  --red: #ef4444;
  --red-soft: #fef2f2;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px -12px rgba(15, 23, 42, 0.08);
  --font: "Inter", "SF Pro Display", "Segoe UI Variable", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  font-size: 15.5px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.wrap { max-width: 1140px; margin: 0 auto; padding: 0 24px; }

/* ============ topbar ============ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(248, 250, 252, 0.8);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar-inner { display: flex; align-items: center; gap: 18px; min-height: 64px; }
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; color: var(--ink); text-decoration: none; font-size: 16.5px;
  letter-spacing: -0.02em;
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px;
  background: var(--grad); color: #fff;
  display: grid; place-items: center; font-size: 12.5px; font-weight: 800;
  letter-spacing: 0.02em;
}
.brand-platform {
  font-size: 11.5px; color: var(--ink-soft); text-decoration: none;
  padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line-soft);
  white-space: nowrap; letter-spacing: 0.01em;
}
.brand-platform strong { color: var(--ink); font-weight: 700; }
.brand-platform:hover { border-color: var(--indigo); color: var(--indigo); }
.brand-platform:hover strong { color: var(--indigo); }
@media (max-width: 720px) { .brand-platform { display: none; } }
.nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.nav a {
  color: var(--ink-soft); text-decoration: none; font-weight: 600; font-size: 13.5px;
  padding: 8px 13px; border-radius: 999px; letter-spacing: -0.01em;
}
.nav a:hover { color: var(--ink); background: var(--line-soft); }
.nav a.active { color: var(--indigo); background: var(--indigo-soft); }
.auth-box { display: flex; gap: 8px; align-items: center; }

/* ============ buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 12px 22px;
  font-family: var(--font); font-weight: 650; font-size: 14px;
  letter-spacing: -0.01em;
  cursor: pointer; text-decoration: none; transition: 0.16s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--grad); color: #fff;
  box-shadow: 0 6px 18px -6px rgba(99, 102, 241, 0.5);
}
.btn-primary:hover { filter: brightness(1.06); box-shadow: 0 10px 26px -8px rgba(99, 102, 241, 0.55); }
.btn-teal { background: var(--indigo); color: #fff; }
.btn-teal:hover { background: #4338ca; }
.btn-ghost {
  background: transparent; color: var(--ink-2);
  border: 1px solid var(--line); font-weight: 600;
}
.btn-ghost:hover { border-color: var(--indigo-2); color: var(--indigo); background: var(--indigo-soft); }
.btn-danger { background: var(--red-soft); color: var(--red); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 8px 14px; font-size: 12.5px; border-radius: 999px; }
.btn-block { width: 100%; }

/* ============ hero ============ */
.hero {
  display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 40px;
  padding: 56px 0 44px; align-items: center;
}
.hero h1 {
  font-size: 46px; line-height: 1.08; letter-spacing: -0.035em; margin: 0 0 18px;
  font-weight: 800;
}
.hero h1 em {
  font-style: normal;
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.hero p.lead { font-size: 17.5px; color: var(--ink-soft); margin: 0 0 28px; max-width: 33em; line-height: 1.6; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-note {
  margin-top: 16px; font-size: 12px; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: 0.09em; font-weight: 600;
}

/* тёмная карточка скоринга — сигнатурный элемент */
.score-card {
  background: var(--grad-dark);
  border-radius: var(--radius-lg); padding: 30px;
  color: #e2e8f0;
  box-shadow: 0 24px 60px -24px rgba(49, 46, 129, 0.55);
  position: relative; overflow: hidden;
}
.score-card::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(420px 220px at 85% -10%, rgba(139, 92, 246, 0.45), transparent 60%),
    radial-gradient(320px 200px at 0% 110%, rgba(99, 102, 241, 0.35), transparent 60%);
  pointer-events: none;
}
.score-card > * { position: relative; z-index: 1; }
.score-card .label {
  font-size: 11px; font-weight: 700; color: #a5b4fc;
  text-transform: uppercase; letter-spacing: 0.12em;
}
.score-big {
  font-size: 68px; font-weight: 800; letter-spacing: -0.045em; color: #fff;
  line-height: 1; margin: 10px 0; font-variant-numeric: tabular-nums;
}
.score-big span { font-size: 20px; color: #a5b4fc; letter-spacing: 0; font-weight: 600; }
.score-card .muted { color: #c7d2fe; }
.score-card .alert { background: rgba(255, 255, 255, 0.08); color: #e0e7ff; border: 1px solid rgba(255,255,255,0.12); }
.score-card .zone-pill { background: rgba(255,255,255,0.12); color: #fff; border: 1px solid rgba(255,255,255,0.18); }
.score-card .btn-ghost {
  color: #e0e7ff; border-color: rgba(255, 255, 255, 0.28); background: rgba(255, 255, 255, 0.06);
}
.score-card .btn-ghost:hover { background: rgba(255, 255, 255, 0.14); color: #fff; border-color: rgba(255,255,255,0.4); }

.zone-pill {
  display: inline-flex; padding: 5px 13px; border-radius: 999px; font-size: 12px; font-weight: 700;
  letter-spacing: 0.01em;
}
.zone-green { background: var(--green-soft); color: #047857; }
.zone-yellow { background: var(--amber-soft); color: #b45309; }
.zone-red { background: var(--red-soft); color: #b91c1c; }

/* кольцевой гейдж METABO-score (сигнатурный элемент) */
.score-ring {
  width: 190px; height: 190px; border-radius: 50%;
  background: conic-gradient(#a5b4fc calc(var(--p, 0) * 1%), rgba(255, 255, 255, 0.13) 0);
  display: grid; place-items: center; margin: 16px auto 10px;
}
.score-ring .score-ring-in {
  width: 158px; height: 158px; border-radius: 50%;
  background: #242150; display: grid; place-items: center; text-align: center;
}
.score-ring .score-big { margin: 0; font-size: 52px; }

/* ============ sections ============ */
.section { padding: 38px 0; }
.section h2 {
  font-size: 30px; letter-spacing: -0.03em; margin: 0 0 10px; font-weight: 750;
}
.section .sub { color: var(--ink-soft); margin: 0 0 24px; max-width: 46em; font-size: 15.5px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.card {
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 8px; font-size: 16.5px; letter-spacing: -0.02em; font-weight: 700; }
.card p { margin: 0; color: var(--ink-soft); font-size: 14px; line-height: 1.6; }
.card .icon {
  width: 42px; height: 42px; border-radius: 13px; background: var(--indigo-soft);
  display: grid; place-items: center; margin-bottom: 14px; font-size: 19px; color: var(--indigo);
}

/* ============ pricing ============ */
.price-card { position: relative; display: flex; flex-direction: column; transition: 0.18s ease; }
.price-card:hover { transform: translateY(-3px); box-shadow: 0 18px 40px -18px rgba(15, 23, 42, 0.18); }
.price-card.featured {
  border: 1.5px solid transparent;
  background:
    linear-gradient(var(--card), var(--card)) padding-box,
    var(--grad) border-box;
}
.price-card .price {
  font-size: 34px; font-weight: 800; letter-spacing: -0.035em; margin: 12px 0 2px;
  font-variant-numeric: tabular-nums;
}
.price-card .price span { font-size: 14px; font-weight: 600; color: var(--ink-faint); letter-spacing: 0; }
.price-card ul { padding-left: 18px; margin: 16px 0 20px; color: var(--ink-soft); font-size: 13.5px; }
.price-card li { margin: 7px 0; }
.badge {
  position: absolute; top: -12px; right: 18px;
  background: var(--grad); color: #fff;
  font-size: 11px; font-weight: 750; padding: 5px 12px; border-radius: 999px;
  letter-spacing: 0.03em;
}

/* ============ forms ============ */
.field { margin-bottom: 15px; }
.field label {
  display: block; font-size: 11px; font-weight: 750; margin-bottom: 7px;
  color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.08em;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 15px; border-radius: 13px; border: 1px solid var(--line);
  font-family: var(--font); font-size: 16px; background: var(--card); color: var(--ink);
  transition: 0.15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--indigo-2);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.steps { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.step-dot {
  padding: 7px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line);
  color: var(--ink-soft); font-size: 12px; font-weight: 650;
  cursor: pointer; font-family: var(--font);
}
.step-dot.on {
  background: var(--ink); color: #fff; border-color: var(--ink);
}

/* ============ tables & text ============ */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; padding: 10px 9px; color: var(--ink-faint);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 750;
  border-bottom: 1px solid var(--line);
}
td { padding: 12px 9px; border-bottom: 1px solid var(--line-soft); }
tr:last-child td { border-bottom: 0; }
.muted { color: var(--ink-soft); font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; font-weight: 700; letter-spacing: -0.01em; }

/* ============ portal / kpi ============ */
.portal { display: grid; grid-template-columns: 216px 1fr; gap: 22px; padding: 30px 0; align-items: start; }
.side {
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 10px; position: sticky; top: 82px; box-shadow: var(--shadow);
}
.side button {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 11px 13px; border-radius: 11px; font-family: var(--font); font-weight: 650;
  font-size: 13px; color: var(--ink-soft); cursor: pointer; letter-spacing: -0.01em;
}
.side button:hover { background: var(--line-soft); color: var(--ink); }
.side button.on { background: var(--indigo-soft); color: var(--indigo); }
.kpi { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin-bottom: 20px; }
.kpi .card { padding: 17px; }
.kpi .v {
  font-size: 27px; font-weight: 800; letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.kpi .l {
  font-size: 10px; color: var(--ink-faint); font-weight: 750;
  text-transform: uppercase; letter-spacing: 0.11em; margin-bottom: 4px;
}

/* ============ timeline ============ */
.timeline { display: flex; flex-direction: column; }

.bubble { max-width: 78%; padding: 11px 15px; border-radius: 18px; font-size: 14px; }
.bubble.patient {
  align-self: flex-end; background: var(--grad); color: #fff;
  border-bottom-right-radius: 6px;
}
.bubble.doctor, .bubble.system {
  align-self: flex-start; background: var(--card);
  border: 1px solid var(--line); border-bottom-left-radius: 6px;
}
.chat-input { display: flex; gap: 8px; margin-top: 12px; }
.chat-input input {
  flex: 1; padding: 12px 15px; border-radius: 999px; border: 1px solid var(--line);
  font-family: var(--font); font-size: 16px;
}
.chat-input input:focus { outline: none; border-color: var(--indigo-2); box-shadow: 0 0 0 4px rgba(99,102,241,0.12); }

/* ============ toast ============ */
#toast-host {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 400; pointer-events: none;
}
.toast {
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; box-shadow: 0 12px 32px -10px rgba(15, 23, 42, 0.4);
  opacity: 0; transform: translateY(8px); transition: 0.25s ease;
  max-width: 78vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-err { background: var(--red); }
.toast-ok { background: var(--ink); }

/* ============ misc ============ */
.alert { padding: 13px 15px; border-radius: 13px; font-size: 13.5px; margin: 12px 0; line-height: 1.55; }
.alert-info { background: var(--indigo-soft); color: #3730a3; }
.alert-warn { background: var(--amber-soft); color: #92400e; }
.alert-danger { background: var(--red-soft); color: #991b1b; }
.factor {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 10px 0; border-bottom: 1px dashed var(--line);
  font-size: 13.5px;
}
.factor:last-child { border-bottom: 0; }
.tag {
  display: inline-block; padding: 3px 11px; border-radius: 999px;
  font-size: 11px; font-weight: 700; background: var(--line-soft); color: var(--ink-soft);
  letter-spacing: 0.02em;
}
.tag-teal { background: var(--indigo-soft); color: var(--indigo); }
.tag-coral { background: var(--red-soft); color: var(--red); }
.footer { border-top: 1px solid var(--line-soft); margin-top: 52px; padding: 28px 0 44px; color: var(--ink-faint); font-size: 12.5px; }
.footer-inner { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.footer-links { display: flex; gap: 14px; }
.footer a { color: var(--ink-soft); text-decoration: none; }
.footer a:hover { color: var(--indigo); }

.steps-list { counter-reset: s; padding: 0; margin: 0; list-style: none; }
.steps-list li { counter-increment: s; display: grid; grid-template-columns: 36px 1fr; gap: 13px; margin: 15px 0; align-items: start; }
.steps-list li::before {
  content: counter(s); width: 36px; height: 36px; border-radius: 12px;
  background: var(--indigo-soft); color: var(--indigo); font-weight: 800;
  display: grid; place-items: center; font-size: 13.5px;
}
.skeleton-hero { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* таблица в карточке — компактнее */
.card table th { border-bottom-color: var(--line-soft); }
.card .btn-sm { margin: 2px 2px; }

@media (max-width: 900px) {
  .hero, .grid-3, .grid-2, .grid-4, .portal, .form-row, .kpi, .skeleton-hero {
    grid-template-columns: 1fr;
  }
  .hero h1 { font-size: 32px; }
  .section h2 { font-size: 24px; }
  .side { position: static; }
  /* широкие таблицы прокручиваются, а не сжимаются в нечитаемые колонки */
  .card { overflow-x: auto; }
  .card table { min-width: 620px; }
  .kpi { grid-template-columns: repeat(2, 1fr); }
}

/* ============ modal (вместо нативных confirm/prompt) ============ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  opacity: 0; transition: opacity 0.18s ease;
}
.modal-overlay.show { opacity: 1; }
.modal {
  background: var(--card); border-radius: 20px; padding: 24px;
  width: min(420px, calc(100vw - 40px));
  box-shadow: 0 24px 64px -16px rgba(15, 23, 42, 0.35);
  transform: translateY(8px) scale(0.98); transition: transform 0.18s ease;
}
.modal-overlay.show .modal { transform: translateY(0) scale(1); }
.modal p { margin: 0 0 6px; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ============ skeleton ============ */
.skel {
  height: 12px; border-radius: 8px; margin: 10px 0;
  background: linear-gradient(90deg, var(--line-soft) 25%, #f1f5f9 50%, var(--line-soft) 75%);
  background-size: 200% 100%; animation: skel 1.3s ease-in-out infinite;
}
.skel-title { width: 42%; height: 18px; }
@keyframes skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============ avatar ============ */
.avatar {
  display: inline-grid; place-items: center; border-radius: 50%;
  background: var(--indigo-soft); color: var(--indigo);
  font-weight: 800; letter-spacing: 0; flex: none;
}

/* ============ empty state ============ */
.empty {
  padding: 28px 16px; text-align: center; color: var(--ink-faint);
  font-size: 13.5px;
}
.empty strong { display: block; color: var(--ink-soft); font-size: 14.5px; margin-bottom: 4px; }

/* ============ FAQ (лендинг) ============ */
.faq-item {
  border: 1px solid var(--line-soft); border-radius: 14px; padding: 2px 18px;
  background: var(--card); margin-bottom: 10px;
}
.faq-item summary {
  cursor: pointer; font-weight: 650; padding: 14px 0; list-style: none;
  letter-spacing: -0.01em; display: flex; justify-content: space-between; align-items: center;
}
.faq-item summary::after { content: "+"; color: var(--indigo); font-size: 20px; font-weight: 500; }
.faq-item[open] summary::after { content: "−"; }
.faq-item p { margin: 0 0 14px; color: var(--ink-soft); font-size: 14px; }

/* ============ trust strip ============ */
.trust-strip {
  display: flex; gap: 12px; flex-wrap: wrap; justify-content: center;
  padding: 18px 0 4px;
}
.trust-strip .chip {
  display: inline-flex; gap: 8px; align-items: center;
  padding: 9px 16px; border-radius: 999px; background: var(--card);
  border: 1px solid var(--line-soft); font-size: 12.5px; font-weight: 650; color: var(--ink-2);
}
.trust-strip .chip span { color: var(--indigo); }

/* ============ tabs ============ */
.tab-bar {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px;
  border-bottom: 1px solid var(--line-soft); padding-bottom: 12px;
}
.tab-bar button {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-soft);
  padding: 9px 16px; border-radius: 999px; font-family: var(--font);
  font-size: 13px; font-weight: 650; cursor: pointer; letter-spacing: -0.01em;
}
.tab-bar button:hover { border-color: var(--indigo-2); color: var(--indigo); }
.tab-bar button.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ============ states & a11y ============ */
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn:focus-visible, .step-dot:focus-visible, .tab-bar button:focus-visible {
  outline: 2px solid var(--indigo-2); outline-offset: 2px;
}
tbody tr:hover { background: #fafbfd; }
.list-note { margin-top: 8px; font-size: 12px; color: var(--ink-faint); }

/* ============ утилиты (вместо повторяющихся inline-стилей) ============ */
.row { display: flex; align-items: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.wrap { flex-wrap: wrap; }
.flex1 { flex: 1; }
.nowrap { white-space: nowrap; }

.mb-12 { margin-bottom: 12px; }
.input-pill, .select-pill {
  padding: 11px 15px; border: 1px solid var(--line); border-radius: 999px;
  font-family: var(--font); font-size: 16px; background: var(--card); color: var(--ink);
}
.input-pill:focus, .select-pill:focus {
  outline: none; border-color: var(--indigo-2); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}
.input-rect {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-family: var(--font); font-size: 16px; background: var(--card);
}
