/* ============================================================
   ИПС-ADHD — стилове · бранд TonyFil Life
   Палитра: тъмносиньо (navy) + офф-уайт (хартия) + антично злато.
   Семантика на резултатите: зелено / кехлибар / тухла.
   ============================================================ */

:root {
  --paper:      #ECE7DD;
  --surface:    #FBF9F4;
  --ink:        #1B2B45;
  --ink-soft:   #5A6675;
  --hairline:   #DAD3C5;

  --navy:       #1E3A5C;
  --navy-deep:  #15273F;
  --navy-tint:  #E3E8EF;

  --gold:       #BF9B4A;
  --gold-deep:  #8A6A22;
  --gold-tint:  #F1E7CF;

  /* Псевдоними за съвместимост — водещият акцент е navy */
  --teal:       var(--navy);
  --teal-deep:  var(--navy-deep);
  --teal-tint:  var(--navy-tint);

  --low:        #3F7D5A;
  --low-tint:   #E4EEE7;
  --moderate:   #C07C24;
  --moderate-tint: #F4E9D3;
  --elevated:   #AE473C;
  --elevated-tint: #F1DED9;
  --high:       #9A3A30;

  --radius:     14px;
  --radius-sm:  9px;
  --shadow:     0 1px 2px rgba(21,39,63,.05), 0 10px 30px rgba(21,39,63,.08);
  --maxw:       760px;

  --display: "Source Serif 4", Georgia, "Times New Roman", serif;
  --body:    "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(20px, 4vw, 48px) clamp(16px, 4vw, 28px) 80px;
}

/* ---------- Типография ---------- */
.eyebrow {
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--gold-deep);
  margin: 0 0 10px;
}
h1 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.7rem, 1.1rem + 2.4vw, 2.5rem);
  line-height: 1.12;
  letter-spacing: -.01em;
  margin: 0 0 14px;
}
h2 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.4rem;
  letter-spacing: -.01em;
  margin: 0 0 6px;
}
h3 { font-size: 1.05rem; font-weight: 700; margin: 0; }
p { margin: 0 0 14px; }
.lead { color: var(--ink-soft); font-size: 1.04rem; }
small, .muted { color: var(--ink-soft); }
.author { font-style: italic; color: var(--ink-soft); }

/* ---------- Карти ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(22px, 3.5vw, 38px);
}
.card + .card { margin-top: 20px; }

/* ---------- Бранд лого (TonyFil Life) ---------- */
.brand {
  text-align: center;
  margin-bottom: 26px;
}
.brand-mark {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  font-size: clamp(1.1rem, .9rem + 1vw, 1.45rem);
  color: var(--navy);
}
.brand-mark .li { color: var(--navy); }
.brand-tag {
  font-family: var(--display);
  font-style: italic;
  color: var(--ink-soft);
  font-size: .92rem;
  margin-top: 4px;
}
/* Сигнатурен елемент от корицата: златна линия с ромб в центъра */
.rule-diamond {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin: 12px auto; max-width: 320px;
}
.rule-diamond::before,
.rule-diamond::after {
  content: ""; height: 1px; flex: 1;
  background: linear-gradient(90deg, transparent, var(--gold) 40%, var(--gold) 60%, transparent);
}
.rule-diamond i {
  width: 7px; height: 7px; flex: 0 0 auto;
  background: var(--gold); transform: rotate(45deg);
}

.brandline {
  display: flex; align-items: baseline; gap: 12px;
  border-top: 2px solid var(--gold);
  padding-top: 18px; margin-bottom: 26px;
}
.brandline .code {
  font-family: var(--display); font-weight: 600; font-size: 1.05rem; color: var(--teal-deep);
}
.brandline .num { color: var(--ink-soft); font-size: .82rem; letter-spacing: .04em; }

/* ---------- Старт форма ---------- */
.field { margin: 0 0 20px; }
.field > label {
  display: block; font-weight: 700; margin-bottom: 7px; font-size: .96rem;
}
.field .hint { display: block; font-size: .85rem; color: var(--ink-soft); margin-bottom: 9px; }
.control {
  width: 100%;
  font-family: inherit; font-size: 1rem; color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  transition: border-color .15s, box-shadow .15s;
}
.control:focus {
  outline: none; border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-tint);
}
select.control { appearance: none; background-image:
  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2356666E' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px; }

.privacy-notice {
  margin: 0 0 12px;
  padding: 11px 14px;
  border-left: 3px solid var(--gold);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: .9rem;
  line-height: 1.5;
}
.privacy-notice a {
  color: var(--navy);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.privacy-notice a:hover { color: var(--gold-deep); }
.privacy-notice a:focus-visible { outline: 2px solid var(--navy); outline-offset: 3px; }

.consent {
  display: flex; gap: 11px; align-items: flex-start;
  background: var(--gold-tint); border-radius: var(--radius-sm);
  padding: 14px 16px; margin: 0 0 24px;
}
.consent input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--teal); flex: 0 0 auto; }
.consent label { font-size: .9rem; color: var(--ink); line-height: 1.5; }

/* ---------- Бутони ---------- */
.btn {
  font-family: inherit; font-weight: 700; font-size: 1rem;
  border: none; border-radius: var(--radius-sm);
  padding: 14px 26px; cursor: pointer;
  transition: transform .08s, background .15s, box-shadow .15s;
}
.btn-primary { background: var(--navy); color: #fff; box-shadow: 0 2px 10px rgba(30,58,92,.30); }
.btn-primary:hover { background: var(--teal-deep); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { background: #B9C4C2; box-shadow: none; cursor: not-allowed; }
.btn-ghost {
  background: transparent; color: var(--teal-deep);
  border: 1.5px solid var(--hairline);
}
.btn-ghost:hover { border-color: var(--gold); }
.btn:focus-visible { outline: 3px solid var(--teal-tint); outline-offset: 2px; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* ---------- Скала-легенда ---------- */
.legend {
  position: sticky; top: 0; z-index: 5;
  background: rgba(246,245,241,.94); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--hairline);
  margin: -1px calc(-1 * clamp(16px, 4vw, 28px)) 0;
  padding: 12px clamp(16px, 4vw, 28px);
}
.legend-grid { display: flex; gap: 8px; flex-wrap: wrap; font-size: .78rem; color: var(--ink-soft); }
.legend-grid b { color: var(--ink); }
.progress {
  display: flex; align-items: center; gap: 12px; margin-top: 10px;
}
.progress-bar { flex: 1; height: 6px; background: var(--hairline); border-radius: 99px; overflow: hidden; }
.progress-bar i { display: block; height: 100%; width: 0; background: var(--teal); border-radius: 99px; transition: width .3s ease; }
.progress-num { font-size: .82rem; font-weight: 700; color: var(--teal-deep); white-space: nowrap; }

/* ---------- Въпроси ---------- */
.q {
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 20px 20px 12px;
  margin: 0 0 16px;
  background: var(--surface);
  scroll-margin-top: 120px;
  min-inline-size: 0; /* нулиране на ширината по подразбиране на fieldset */
}
.q.unanswered-flag { border-color: var(--elevated); box-shadow: 0 0 0 2px var(--elevated-tint); }
.q-head { display: flex; gap: 12px; margin-bottom: 16px; }
.q-num {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 8px;
  background: var(--teal-tint); color: var(--teal-deep);
  font-weight: 700; font-size: .9rem;
  display: grid; place-items: center;
}
.q-cat { display: block; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--gold-deep); font-weight: 700; margin-bottom: 3px; }
.q-text { display: block; font-size: 1.02rem; line-height: 1.45; }

.scale { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.opt { position: relative; }
.opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.opt label {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 11px 4px; border: 1.5px solid var(--hairline); border-radius: var(--radius-sm);
  cursor: pointer; text-align: center; transition: all .12s; background: var(--paper);
  height: 100%;
}
.opt .val { font-weight: 800; font-size: 1.05rem; color: var(--ink); }
.opt .lbl { font-size: .68rem; color: var(--ink-soft); line-height: 1.2; }
.opt label:hover { border-color: var(--teal); }
.opt input:checked + label {
  background: var(--teal); border-color: var(--teal);
}
.opt input:checked + label .val,
.opt input:checked + label .lbl { color: #fff; }
.opt input:focus-visible + label { outline: 3px solid var(--teal-tint); outline-offset: 2px; }
.opt-na label { border-style: dashed; }
.question-section {
  margin: 28px 0 12px;
  font-family: var(--display);
  font-size: 1.12rem;
  color: var(--teal-deep);
}
.question-nav {
  display: grid;
  grid-template-columns: minmax(110px, auto) 1fr minmax(150px, auto);
  align-items: center;
  gap: 12px;
  margin: 18px 0;
}
.question-position { text-align: center; color: var(--ink-soft); font-size: .84rem; font-weight: 700; }

/* ---------- Резултати ---------- */
.result-hero { text-align: center; padding-bottom: 8px; }
.total-num {
  font-family: var(--display); font-weight: 600;
  font-size: clamp(3rem, 2rem + 6vw, 4.6rem); line-height: 1; letter-spacing: -.02em;
}
.total-num span { font-size: .4em; color: var(--ink-soft); }
.chip {
  display: inline-block; font-weight: 700; font-size: .9rem;
  padding: 7px 16px; border-radius: 99px; margin-top: 8px;
}
.chip.low { background: var(--low-tint); color: var(--low); }
.chip.moderate { background: var(--moderate-tint); color: #9A6A1E; }
.chip.elevated { background: var(--elevated-tint); color: var(--elevated); }
.chip.high { background: var(--elevated-tint); color: var(--high); }

.total-gauge { display: flex; gap: 5px; max-width: 320px; margin: 20px auto 4px; }
.total-gauge i { flex: 1; height: 7px; border-radius: 99px; background: var(--hairline); }
.total-gauge i.on-low { background: var(--low); }
.total-gauge i.on-moderate { background: var(--moderate); }
.total-gauge i.on-elevated { background: var(--elevated); }
.total-gauge i.on-high { background: var(--high); }

.band-desc { color: var(--ink-soft); font-size: .96rem; max-width: 56ch; margin: 12px auto 0; }

/* Подскали — сигнатурен елемент: 8-сегментен измервател (1 сегмент = 1 точка) */
.scales-list { margin-top: 12px; }
.srow { padding: 16px 0; border-bottom: 1px solid var(--hairline); }
.srow:last-child { border-bottom: none; }
.srow-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 9px; }
.srow-name { font-weight: 700; font-size: .98rem; }
.srow-score { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.srow-score b { font-size: 1.05rem; }
.srow-score .slash { color: var(--ink-soft); font-weight: 500; }
.srow-band { font-size: .76rem; font-weight: 700; padding: 2px 9px; border-radius: 99px; margin-left: 8px; }
.srow-band.low { background: var(--low-tint); color: var(--low); }
.srow-band.very-low { background: var(--low-tint); color: var(--low); }
.srow-band.moderate { background: var(--moderate-tint); color: #9A6A1E; }
.srow-band.elevated { background: var(--elevated-tint); color: var(--elevated); }
.srow-band.high { background: var(--elevated-tint); color: var(--high); }
.srow-band.insufficient { background: var(--hairline); color: var(--ink-soft); }

.meter { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; }
.meter i { height: 12px; border-radius: 4px; background: var(--hairline); transition: background .4s ease; }
.meter i.fill-low { background: var(--low); }
.meter i.fill-moderate { background: var(--moderate); }
.meter i.fill-elevated { background: var(--elevated); }

.srow-desc {
  margin: 11px 0 0;
  font-size: .9rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--elevated-tint);
  border-radius: 9px;
  padding: 11px 13px;
}
.mean-meter { height: 9px; overflow: hidden; border-radius: 4px; background: var(--hairline); }
.mean-meter i { display: block; height: 100%; }
.mean-meter .fill-very-low, .mean-meter .fill-low { background: var(--low); }
.mean-meter .fill-moderate { background: var(--moderate); }
.mean-meter .fill-high { background: var(--high); }
.valid-count { margin: 7px 0 0; color: var(--ink-soft); font-size: .78rem; }
.is-insufficient .srow-desc { background: var(--navy-tint); }
.profile-summary { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--hairline); }
.profile-summary h3 { margin: 0 0 8px; font-size: 1rem; }
.profile-summary p { margin: 0; color: var(--ink-soft); line-height: 1.55; }
.method-note { margin: 16px 0 0; color: var(--ink-soft); font-size: .78rem; line-height: 1.5; }
.copyright-note { margin: 12px 0 0; color: var(--ink-soft); font-size: .74rem; text-align: center; }
.recommendation-section + .recommendation-section { margin-top: 22px; }
.recommendation-section h3 { font-size: 1rem; margin-bottom: 8px; }
.recommendation-section ul { margin: 0; padding-left: 20px; }
.recommendation-section li { margin: 0 0 7px; line-height: 1.5; }

.note-box {
  background: var(--navy-tint); border-left: 4px solid var(--gold);
  border-radius: var(--radius-sm); padding: 18px 20px; margin-top: 8px;
  font-size: .92rem; color: var(--ink); line-height: 1.55;
}
.note-box b { color: var(--teal-deep); }

.saved-flag {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .85rem; color: var(--low); font-weight: 700; margin-top: 4px;
}
.report-date { margin: -8px 0 10px; color: var(--ink-soft); font-size: .82rem; }

/* ---------- Съобщения ---------- */
.alert {
  border-radius: var(--radius-sm); padding: 13px 16px; font-size: .92rem; margin: 0 0 18px;
}
.alert.error { background: var(--elevated-tint); color: var(--high); }
[hidden] { display: none !important; }
.center { text-align: center; }

/* ---------- Адаптивност ---------- */
@media (max-width: 480px) {
  body { font-size: 16px; }
  .scale { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .opt label { padding: 10px 2px; }
  .opt .lbl { font-size: .6rem; }
  .q { padding: 16px 14px 10px; }
  .question-nav { grid-template-columns: 1fr 1fr; }
  .question-position { grid-column: 1 / -1; grid-row: 1; }
  .question-nav .btn { width: 100%; }
}

/* ---------- Печат ---------- */
@media print {
  body { background: #fff; }
  .legend, .btn-row, .no-print { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: auto; }
  .srow, .recommendation-section { break-inside: avoid; }
}

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

/* ============================================================
   РАЗШИРЕНИЯ ЗА ТЕСТ-СИСТЕМАТА (рутер № 6 + специализирани)
   Добавени класове; горните дефиниции остават непроменени.
   ============================================================ */

/* Липсващи „high“ варианти към съществуващите семантики */
.srow-band.high { background: var(--elevated-tint); color: var(--high); }
.meter i.fill-high { background: var(--high); }

/* Етикет „Безплатен“ в шапката */
.free-tag {
  margin-left: auto; font-size: .72rem; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: var(--low);
  background: var(--low-tint); border-radius: 99px; padding: 4px 12px;
}

/* Уводна кутия на старта */
.intro-box {
  background: var(--navy-tint); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 20px 22px; margin: 22px 0 8px;
}
.intro-box .intro-h {
  font-family: var(--display); font-weight: 600; font-size: 1.08rem;
  color: var(--teal-deep); margin: 0 0 10px;
}
.intro-box p { font-size: .93rem; color: var(--ink); margin: 0 0 10px; }
.intro-box p:last-child { margin-bottom: 0; }
.questionnaire-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin-top: 18px;
  color: var(--ink-soft);
  font-size: .86rem;
}
.questionnaire-facts b { color: var(--ink); }

/* Радар „паяжина“ */
.radar-wrap { display: flex; justify-content: center; margin: 8px auto 0; }
#radar, #profile-radar { width: 100%; max-width: 360px; height: auto; }

/* Препоръчани тестове */
.rec-list { margin: 18px 0 6px; display: flex; flex-direction: column; gap: 10px; }
.rec-item {
  display: flex; align-items: center; gap: 13px;
  border: 1.5px solid var(--hairline); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; background: var(--paper);
  transition: border-color .15s, background .15s;
}
.rec-item:hover { border-color: var(--gold); }
.rec-item input { position: absolute; opacity: 0; width: 0; height: 0; }
.rec-check {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 6px;
  border: 2px solid var(--hairline); background: #fff; position: relative; transition: all .15s;
}
.rec-item input:checked + .rec-check {
  background: var(--navy); border-color: var(--navy);
}
.rec-item input:checked + .rec-check::after {
  content: ""; position: absolute; left: 6px; top: 2px;
  width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
.rec-item input:focus-visible + .rec-check { outline: 3px solid var(--teal-tint); outline-offset: 2px; }
.rec-item input:checked ~ .rec-info .rec-name { color: var(--teal-deep); }
.rec-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.rec-name { font-weight: 700; font-size: .96rem; }
.rec-desc { font-size: .82rem; color: var(--ink-soft); line-height: 1.4; }
.rec-price { flex: 0 0 auto; font-weight: 800; font-size: 1rem; color: var(--ink); font-variant-numeric: tabular-nums; }

.rec-summary {
  margin-top: 16px; padding: 16px 18px;
  background: var(--gold-tint); border-radius: var(--radius-sm);
}
.rec-total-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: .95rem; }
.rec-total { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.rec-total s { color: var(--ink-soft); font-weight: 500; font-size: .9rem; margin-right: 6px; }
.rec-bundle { margin-top: 6px; font-size: .84rem; font-weight: 700; color: var(--low); }

/* Опашка от закупени тестове (tests.php) */
.queue-progress { display: flex; align-items: center; gap: 14px; margin: 20px 0 22px; }
.queue-progress .progress-num { font-size: .85rem; font-weight: 700; color: var(--teal-deep); white-space: nowrap; }
.queue-progress .progress-bar { flex: 1; height: 7px; background: var(--hairline); border-radius: 99px; overflow: hidden; }
.queue-progress .progress-bar i { display: block; height: 100%; background: var(--navy); border-radius: 99px; transition: width .4s ease; }

.queue-list { display: flex; flex-direction: column; gap: 12px; }
.queue-item {
  display: flex; align-items: center; gap: 14px;
  border: 1.5px solid var(--hairline); border-radius: var(--radius);
  padding: 15px 16px; background: var(--surface);
}
.queue-item.next { border-color: var(--navy); box-shadow: 0 0 0 2px var(--navy-tint); }
.queue-item.done { background: var(--low-tint); border-color: transparent; }
.queue-item.wait { opacity: .72; }
.queue-badge {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center; font-weight: 800; font-size: 1rem;
  background: var(--teal-tint); color: var(--teal-deep);
}
.queue-item.done .queue-badge { background: var(--low); color: #fff; }
.queue-item.next .queue-badge { background: var(--navy); color: #fff; }
.queue-body { flex: 1; min-width: 0; }
.queue-name { font-weight: 700; font-size: .96rem; }
.queue-meta { font-size: .82rem; color: var(--ink-soft); margin-top: 2px; }
.queue-action { flex: 0 0 auto; }

.btn-sm { padding: 9px 16px; font-size: .88rem; }

/* Успех / потвърждение */
.alert.ok { background: var(--low-tint); color: var(--low); font-weight: 700; }

@media (max-width: 480px) {
  .rec-item { flex-wrap: wrap; }
  .rec-price { order: 3; margin-left: 35px; }
  .queue-item { flex-wrap: wrap; }
  .queue-action { width: 100%; }
  .queue-action .btn { width: 100%; text-align: center; }
}
