/* PrettyTests — деловой адаптивный интерфейс без внешних зависимостей. */

:root {
  --ink: #14212b;
  --ink-soft: #4a5a68;
  --line: #d7dee5;
  --line-soft: #e8edf2;
  --bg: #f5f7f9;
  --surface: #ffffff;
  --brand: #0b3d5c;
  --brand-soft: #e7eff5;
  --accent: #b3680b;
  --ok: #1f6b43;
  --warn-bg: #fdf3e3;
  --warn-line: #d9a441;
  --err: #a32020;
  --err-bg: #fdecec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 34, 48, .07), 0 6px 18px rgba(16, 34, 48, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.wrap { width: min(1120px, 100% - 2rem); margin-inline: auto; }
.page { padding-block: 1.25rem 2.5rem; flex: 1; }
/* Grid/flex children must be allowed to shrink below min-content. */
.results-grid > *, .section-cards > *, .kpi, .card, .card__body { min-width: 0; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: clamp(1.35rem, 1.1rem + 1.2vw, 1.85rem); color: var(--brand); }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: #0a5a86; }
small, .muted { color: var(--ink-soft); }

/* ---------------------------------------------------------------- topbar */
.topbar { background: var(--brand); color: #fff; }
.topbar__inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 56px; }
.brand { display: inline-flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; font-weight: 600; letter-spacing: .01em; }
.brand__logo { width: 36px; height: 36px; border-radius: 50%; display: block; flex: 0 0 auto; background: #fff; }
.brand__text { min-width: 0; }
.topbar a.link { color: #cfe0ec; text-decoration: none; font-size: .92rem; }
.topbar a.link:hover { color: #fff; text-decoration: underline; }

/* ----------------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.card__head { padding: .9rem 1.1rem; border-bottom: 1px solid var(--line-soft); display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.card__head h2 { margin: 0; }
.card__body { padding: 1.1rem; }

.test-intro { padding: 1.25rem 1.25rem 1rem; }
.test-intro h1 { margin-bottom: .35rem; text-wrap: balance; overflow-wrap: anywhere; }
.test-intro__subtitle { color: var(--ink-soft); max-width: 62ch; }

.scale-legend { display: flex; flex-wrap: wrap; gap: .35rem .9rem; margin: .75rem 0 0; padding: .75rem .9rem; background: var(--brand-soft); border-radius: 8px; list-style: none; font-size: .9rem; }
.scale-legend li { display: flex; gap: .35rem; }
.scale-legend b { color: var(--brand); }

/* ----------------------------------------------------------------- forms */
.field { margin-bottom: 1rem; }
.field > label, .field__label { display: block; font-weight: 600; margin-bottom: .35rem; }
.field__hint { font-size: .85rem; color: var(--ink-soft); margin: -.1rem 0 .4rem; }

input[type="text"], input[type="date"], input[type="number"], textarea, select {
  width: 100%;
  font: inherit;
  color: inherit;
  padding: .6rem .7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-height: 44px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid #7db4d8;
  outline-offset: 2px;
}
input[type="date"] { min-height: 44px; }

.meta-grid { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); }
.meta-grid .field { margin-bottom: .85rem; }

.choice-row { display: flex; flex-wrap: wrap; gap: .5rem; }
/* Single-choice groups stack on phones so labels never get clipped. */
@media (max-width: 560px) {
  .choice-row--stack { flex-direction: column; align-items: stretch; }
  .choice-row--stack .choice { width: 100%; }
}
.choice {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; cursor: pointer; min-height: 44px; font-size: .95rem;
  max-width: 100%; overflow-wrap: anywhere;
}
.choice:hover { border-color: #a9bccb; }
.choice input { margin: 0; width: 18px; height: 18px; accent-color: var(--brand); }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }

/* ------------------------------------------------------- question groups */
.section { border-top: 1px solid var(--line-soft); }
.section:first-of-type { border-top: 0; }
.section__head { padding: .8rem 1.1rem .4rem; }
.section__title { margin: 0; font-size: 1.02rem; color: var(--brand); text-transform: none; display: flex; gap: .55rem; align-items: baseline; }
.section__num { display: inline-grid; place-items: center; min-width: 1.7rem; height: 1.7rem; padding-inline: .35rem; border-radius: 6px; background: var(--brand); color: #fff; font-size: .85rem; font-weight: 700; }
.section__body { padding: 0 1.1rem 1rem; }

.q { padding: .7rem 0; border-top: 1px dashed var(--line-soft); }
.q:first-child { border-top: 0; padding-top: .2rem; }
.q__text { font-weight: 500; margin-bottom: .45rem; display: flex; gap: .4rem; overflow-wrap: anywhere; }
.q__num { color: var(--ink-soft); font-variant-numeric: tabular-nums; min-width: 1.2rem; }
.q__hint { font-size: .85rem; color: var(--ink-soft); margin: -.2rem 0 .45rem; }

.rating { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .4rem; min-width: 0; }
.rating legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.rating label {
  position: relative; display: grid; place-items: center;
  width: 46px; height: 44px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; cursor: pointer; font-weight: 600; color: var(--ink-soft);
  flex: 0 0 auto;
}
.rating input { position: absolute; opacity: 0; pointer-events: none; }
.rating label:hover { border-color: #a9bccb; }
.rating input:checked + span { color: #fff; }
.rating label:has(input:checked) { background: var(--brand); border-color: var(--brand); color: #fff; }
.rating input:focus-visible + span { outline: 3px solid #7db4d8; outline-offset: 3px; }
.rating--na label { width: auto; padding-inline: .7rem; font-size: .9rem; }
.rating label.is-na:has(input:checked) { background: #6b7783; border-color: #6b7783; }

.scale { position: relative; display: flex; gap: .3rem; align-items: center; }
.scale input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.scale .digit {
  flex: 1; display: grid; place-items: center; min-width: 44px; min-height: 44px;
  border-radius: 8px; border: 1px solid var(--line);
  background: #fff; font-weight: 600; color: var(--ink-soft); cursor: pointer;
}
.scale .digit:hover { border-color: #a9bccb; }
.scale .digit:has(input:checked) { background: var(--brand); color: #fff; border-color: var(--brand); }
.scale .digit:has(input:focus-visible) { outline: 3px solid #7db4d8; outline-offset: 2px; }

.other-input { margin-top: .45rem; max-width: 420px; }
.other-input[hidden] { display: none; }

/* ---------------------------------------------------------------- alerts */
.alert { border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; margin-bottom: 1rem; background: var(--surface); }
.alert h2 { font-size: 1rem; margin-bottom: .35rem; }
.alert--error { background: var(--err-bg); border-color: #e7b4b4; color: #6d1414; }
.alert--error ul { margin: .25rem 0 0 1.1rem; padding: 0; }
.alert--info { background: var(--brand-soft); border-color: #bcd3e2; }
.alert--warn { background: var(--warn-bg); border-color: var(--warn-line); }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 46px; padding: .65rem 1.15rem; border-radius: 8px; border: 1px solid var(--brand);
  background: var(--brand); color: #fff; font: inherit; font-weight: 600; text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: #0d4b6f; }
.btn--ghost { background: #fff; color: var(--brand); }
.btn--ghost:hover { background: var(--brand-soft); }
.btn--sm { min-height: 38px; padding: .4rem .8rem; font-size: .9rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }

/* --------------------------------------------------------------- captcha */
.captcha-box { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.captcha-box svg { border-radius: 8px; border: 1px solid var(--line); display: block; height: 52px; width: 148px; }
.captcha-box input { max-width: 150px; text-align: center; font-size: 1.1rem; letter-spacing: .3em; font-weight: 600; }

/* --------------------------------------------------------------- results */
.results-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 1rem; align-items: start; }
.filters { position: sticky; top: 1rem; }
.filters .field { margin-bottom: .8rem; }
.filters label { font-size: .88rem; }
.test-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.test-tabs a { padding: .45rem .8rem; border-radius: 999px; border: 1px solid var(--line); background: #fff; text-decoration: none; color: var(--ink); font-size: .92rem; }
.test-tabs a[aria-current="page"] { background: var(--brand); color: #fff; border-color: var(--brand); }
.results-subtitle { overflow-wrap: anywhere; }

.kpis { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); }
.kpi { padding: .85rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.kpi__label { font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.kpi__value { font-size: 1.6rem; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi__value small { font-size: .9rem; font-weight: 500; color: var(--ink-soft); }

.chart { display: grid; gap: .55rem; }
.bar { display: grid; grid-template-columns: minmax(120px, 34%) minmax(0, 1fr) 3.2rem; gap: .6rem; align-items: center; font-size: .9rem; }
.bar__label { color: var(--ink-soft); }
.bar__track { background: var(--line-soft); border-radius: 4px; height: 10px; overflow: hidden; }
.bar__fill { height: 100%; background: var(--brand); border-radius: 4px; }
.bar__value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.section-cards { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(min(215px, 100%), 1fr)); }
.section-card { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; background: #fff; }
.section-card h3 { margin: 0 0 .15rem; font-size: .95rem; }
.section-card .avg { font-size: 1.5rem; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.section-card .avg small { font-size: .8rem; color: var(--ink-soft); font-weight: 500; }
.spark { display: flex; gap: 2px; align-items: flex-end; height: 34px; margin-top: .45rem; width: 100%; overflow: visible; }
.spark span { display: block; flex: 1 1 0; min-width: 0; max-height: 100%; border-radius: 2px 2px 0 0; min-height: 3px; align-self: flex-end; }
.spark .lv1 { background: #c98a8a; }
.spark .lv2 { background: #d9ae8a; }
.spark .lv3 { background: #b9c4cc; }
.spark .lv4 { background: #9fc2d8; }
.spark .lv5 { background: var(--brand); }
.spark__legend { margin-top: .15rem; font-size: .72rem; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); font-weight: 600; background: #fbfcfd; }
tbody tr:hover { background: #f9fbfc; }
.table-scroll { overflow-x: auto; }

.dist { display: inline-flex; gap: 2px; }
.dist i { display: block; min-width: 22px; padding: 1px 3px; text-align: center; font-style: normal; font-size: .75rem; background: var(--line-soft); border-radius: 3px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.dist i.on { background: var(--brand); color: #fff; }

.details-list { display: grid; gap: 0; }
.details-list > div { display: grid; grid-template-columns: minmax(140px, 34%) minmax(0, 1fr); gap: .8rem; padding: .5rem 0; border-bottom: 1px solid var(--line-soft); font-size: .93rem; }
.details-list dt { color: var(--ink-soft); }
.details-list dd { margin: 0; }

.pager { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .8rem; align-items: center; }
.pager a, .pager span { padding: .35rem .65rem; border-radius: 6px; border: 1px solid var(--line); text-decoration: none; font-size: .9rem; background: #fff; }
.pager [aria-current="page"] { background: var(--brand); color: #fff; border-color: var(--brand); }

.empty { text-align: center; padding: 2rem 1rem; color: var(--ink-soft); }

/* ------------------------------------------------------------------- misc */
.test-list { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
.test-tile { display: flex; flex-direction: column; gap: .35rem; padding: 1.1rem; text-decoration: none; color: inherit; }
.test-tile:hover { border-color: #a9bccb; }
.test-tile h2 { color: var(--brand); margin: 0; font-size: 1.05rem; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: .8rem; font-weight: 600; }

.status-ok { color: var(--ok); font-weight: 600; }

.footer { border-top: 1px solid var(--line); background: #fff; }
.footer__inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1rem; padding-block: .9rem; font-size: .82rem; color: var(--ink-soft); }
.footer__note { display: inline-flex; align-items: center; gap: .5rem; min-width: 0; }
.footer__logo { width: 24px; height: 24px; border-radius: 50%; display: block; flex: 0 0 auto; }
.thanks__logo { display: block; margin: 0 auto .8rem; width: 72px; height: 72px; border-radius: 50%; }

.submit-bar { position: sticky; bottom: 0; background: rgba(255,255,255,.96); backdrop-filter: blur(4px); border-top: 1px solid var(--line); padding: .75rem 1.1rem; display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; border-radius: 0 0 var(--radius) var(--radius); }
.submit-bar .muted { font-size: .85rem; }

/* -------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .results-grid { grid-template-columns: minmax(0, 1fr); }
  .filters { position: static; }
}

@media (max-width: 560px) {
  .wrap { width: min(1120px, 100% - 1.25rem); }
  body { font-size: 15.5px; }
  .card__body, .section__body { padding-inline: .8rem; }
  .test-intro { padding: .9rem .8rem; }
  .section__head { padding-inline: .8rem; }
  .rating { gap: .3rem; }
  .rating label { width: 46px; }
  .rating--na label { width: auto; }
  .meta-grid { grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr)); }
  .bar { grid-template-columns: minmax(84px, 42%) minmax(0, 1fr) 2.8rem; font-size: .84rem; }
  .details-list > div { grid-template-columns: 1fr; gap: .15rem; }
  .submit-bar { flex-direction: column; align-items: stretch; }
  .submit-bar .btn { width: 100%; }
  .topbar__inner { min-height: 50px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media print {
  .topbar, .footer, .submit-bar, .filters, .pager, .btn { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
