:root {
  color-scheme: light;
  --bg: #ffffff;
  --paper: #ffffff;
  --ink: #151515;
  --muted: #656565;
  --line: #dfdfdf;
  --brand: #2e3f7f;
  --brand-strong: #1f2d62;
  --accent: #77bd8b;
  --danger: #a93226;
  --ok: #28724d;
  --radius-lg: 14px;
  --radius: 10px;
  font-family: Montserrat, Arial, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.35rem clamp(1rem, 4vw, 4rem);
  border-block-end: 1px solid var(--line);
  background: var(--paper);
}

h1, h2, h3, p { margin-block: 0; }
h1 { font-size: clamp(1.7rem, 4vw, 3.4rem); line-height: 1.05; font-weight: 500; text-transform: uppercase; }
h2 { font-size: 1.25rem; }
.eyebrow { color: var(--brand); font-weight: 500; text-transform: uppercase; font-size: .85rem; letter-spacing: 0; margin-block-end: .5rem; }
.brand { display: flex; align-items: center; gap: 1rem; color: var(--brand); min-width: 280px; }
.brand img { width: 70px; height: auto; display: block; }
.brand-title { font-size: 1.15rem; line-height: 1.05; font-weight: 800; text-transform: uppercase; color: var(--brand); max-width: 210px; }
.brand-subtitle { font-size: .86rem; line-height: 1.15; color: var(--brand); max-width: 220px; }
.page-title { text-align: right; }
.shell { max-width: 1040px; margin-inline: auto; padding: clamp(1rem, 4vw, 3rem); }
.bot-panel { margin: 1rem 1rem 0; }
.inline-check { display: inline-flex; gap: .6rem; align-items: center; font-weight: 600; }
.inline-check input { width: 1.25rem; height: 1.25rem; min-height: 0; flex: none; margin: 0; padding: 0; }
.admin-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); gap: 1rem; padding: 1rem; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(1rem, 3vw, 1.5rem);
  box-shadow: none;
}
.form-panel { min-height: 560px; }
.auth-panel { width: min(420px, 100%); display: grid; gap: .85rem; }
.status-row { display: flex; justify-content: space-between; gap: 1rem; margin-block-end: 1rem; color: var(--muted); }
.progress { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: .35rem; padding: 0; margin: 0 0 1.25rem; list-style: none; }
.progress li { min-height: 8px; border-radius: 999px; background: #ded8ce; font-size: 0; }
.progress li.done, .progress li.active { background: var(--brand); }
.notice { border-inline-start: 4px solid var(--accent); background: #f5fbf6; padding: .85rem 1rem; margin-block-end: 1rem; border-radius: var(--radius); }
.warning-list { border-radius: var(--radius); border: 1px solid #d8e9dc; background: #f8fcf8; padding: 1rem 1.25rem; margin-block-end: 1rem; color: #24375f; }
.warning-list ul { margin: 0; padding-inline-start: 1.2rem; display: grid; gap: .55rem; }
.health { border: 1px solid #d8e9dc; background: #fbfdfb; border-radius: var(--radius); padding: 1rem; }
.field { display: grid; gap: .35rem; margin-block-end: 1rem; }
label, legend { font-weight: 700; }
input, textarea, select, button {
  font: inherit;
  min-height: 48px;
}
input, textarea, select {
  width: 100%;
  border: 1px solid #bdb5aa;
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius);
  padding: .75rem;
}
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] {
  border-color: var(--danger);
  background: #fff8f7;
}
textarea { min-height: 104px; resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand), white 35%);
  outline-offset: 2px;
}
fieldset { border: 0; padding: 0; margin: 0 0 1rem; }
.choice-list { display: grid; gap: .5rem; margin-block-start: .4rem; }
.choice-list label { display: flex; align-items: center; gap: .55rem; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: var(--radius); font-weight: 500; }
.choice-list input { width: auto; min-height: auto; accent-color: var(--brand); }
.field-error, .error-summary { color: var(--danger); font-weight: 700; }
.error-summary { border: 1px solid #e0aaa2; background: #fff2f0; padding: .85rem; border-radius: var(--radius); margin-block: 1rem; }
.actions, .filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; }
button, .admin-link {
  border: 0;
  background: var(--brand);
  color: #fff;
  border-radius: 30px;
  padding: .75rem 1rem;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}
button:hover, .admin-link:hover { background: var(--brand-strong); }
#back-button { background: #6f6a61; }
.success { margin-block-start: 1rem; border: 1px solid #9ec8af; background: #effaf3; border-radius: var(--radius); padding: 1rem; color: var(--ok); }
.muted { color: var(--muted); }
.table-wrap { overflow-x: auto; margin-block-start: 1rem; }
table { width: 100%; border-collapse: collapse; min-width: 920px; }
th, td { text-align: left; border-block-end: 1px solid var(--line); padding: .65rem; vertical-align: top; }
th { font-size: .85rem; color: var(--muted); }
tr[data-id] { cursor: pointer; }
tr[data-id]:hover { background: #f5efe5; }
.badge { display: inline-block; border-radius: 999px; padding: .15rem .5rem; background: #e8e2d8; font-size: .85rem; }
.stack { display: grid; gap: .8rem; }
.doc-list, .event-list { padding-inline-start: 1.1rem; }
.danger { color: var(--danger); }

@media (max-width: 860px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .page-title { text-align: left; }
  .admin-layout { grid-template-columns: 1fr; }
  .progress { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Вопросы из бумажной анкеты бывают многострочными (список препаратов). */
.field > label, fieldset > legend { white-space: pre-line; }

/* Воронка в админке */
.funnel-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.funnel-filter { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
.funnel-filter select { width: auto; }
.funnel-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .75rem; margin-block: 1rem; }
.funnel-stats div { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; display: grid; gap: .2rem; }
.funnel-stats strong { font-size: 1.5rem; color: var(--brand); }
.funnel-stats span { color: var(--muted); font-size: .85rem; }
.funnel-bar { display: inline-block; width: 90px; height: 8px; background: #ece7de; border-radius: 999px; margin-inline-end: .5rem; vertical-align: middle; overflow: hidden; }
.funnel-bar span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.funnel-filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.funnel-filter input[type="date"] { width: auto; }
#funnel-custom { gap: .5rem; }
#funnel-custom label { display: flex; align-items: center; gap: .35rem; }
#funnel-custom[hidden] { display: none; }
