/*
 * @cfm/client-tg — client Mini App styles ("Лаконичный свет" + IBM Plex).
 *
 * A NON-CUSTODIAL referral metasearch UI: an amount-hero calculator, a ranked
 * comparison board, a per-provider consent confirmation, an honest deal tracker
 * ("чей ход"), and a rating prompt. It authors no rate, initiates no payment,
 * and holds no funds. Every server/provider string is inserted via
 * textContent/esc() in app.js — this file only styles the shell.
 *
 * Design tokens + the self-hosted Plex faces live in tokens.css. This sheet is
 * component styling only; it references var(--…) tokens exclusively.
 */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  background: var(--bg);
}

body {
  color: var(--ink);
  font-family: var(--ff);
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------------ *
 * App shell — a phone-width column, one screen visible at a time.
 * ------------------------------------------------------------------ */

.app {
  max-width: var(--col);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--line);
}

.screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.tgbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 15px 11px;
  background: var(--bg);
  border-bottom: 1px solid transparent;
}

.tgbar-title {
  flex: 1;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.tgbar-back {
  position: absolute;
  left: 12px;
  width: 30px;
  height: 30px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  border-radius: var(--r-md);
}

.tgbar-back:active {
  background: var(--s2);
}

/* The scrollable body of each screen. A flex column so .foot can sink. */
.scroll {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 18px calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto;
}

.center-screen {
  text-align: center;
}

.foot {
  margin-top: auto;
  padding-top: 16px;
}

/* ------------------------------------------------------------------ *
 * Typography helpers
 * ------------------------------------------------------------------ */

.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.hd {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 6px 0 6px;
}

.sub {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 14px;
}

.quiet {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.quiet.tiny {
  font-size: 12px;
  margin-top: 8px;
}

.center {
  text-align: center;
}

.mono {
  font-family: var(--mono);
  font-weight: 500;
}

.lang {
  display: block;
  margin-top: 3px;
  color: var(--faint);
  font-size: 12px;
}

.link {
  border: 0;
  background: none;
  color: var(--accent);
  font-family: var(--ff);
  font-weight: 600;
  font-size: inherit;
  padding: 0;
}

/* ------------------------------------------------------------------ *
 * Cards / blocks
 * ------------------------------------------------------------------ */

.card {
  background: var(--s1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px;
  margin-top: 14px;
}

.block {
  margin-top: 18px;
}

.block-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 9px;
}

.mini-card {
  background: var(--s1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 12px 13px;
  margin-bottom: 10px;
}

.mini-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 3px;
}

/* ------------------------------------------------------------------ *
 * Fields
 * ------------------------------------------------------------------ */

.field {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}

.field > span {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--s1);
  color: var(--ink);
  padding: 12px 13px;
  font-size: 15px;
  font-weight: 600;
  outline: none;
}

textarea {
  min-height: 78px;
  resize: vertical;
  line-height: 1.45;
  font-weight: 400;
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
  font-weight: 400;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--asoft);
}

.field.city {
  max-width: 190px;
}

/* ------------------------------------------------------------------ *
 * Buttons
 * ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1.5px solid transparent;
  border-radius: var(--r-lg);
  background: var(--s2);
  color: var(--ink);
  padding: 14px 16px;
  font-family: var(--ff);
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
}

.btn.block {
  width: 100%;
}

.btn.primary {
  background: var(--accent);
  color: var(--on);
}

.btn.ok {
  background: var(--s1);
  color: var(--accent);
  border-color: var(--line);
}

.btn.warn {
  background: var(--s1);
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 34%, var(--line));
}

.btn.link-btn {
  background: none;
  color: var(--accent);
  padding: 11px 0 2px;
}

.btn + .btn {
  margin-top: 9px;
}

.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.is-busy {
  opacity: 0.6;
  pointer-events: none;
}

/* ------------------------------------------------------------------ *
 * Segmented control (method) + off-screen direction group
 * ------------------------------------------------------------------ */

.seg-row {
  display: flex;
  gap: 6px;
  margin-top: 16px;
}

.seg {
  flex: 1;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--s1);
  color: var(--muted);
  padding: 10px 8px;
  font-size: 13px;
  font-weight: 600;
}

.seg.is-active {
  background: var(--asoft);
  color: var(--aink);
  border-color: transparent;
}

/* ------------------------------------------------------------------ *
 * Calculator — amount hero
 * ------------------------------------------------------------------ */

.hero {
  margin-top: 8px;
}

.amount-block {
  padding: 18px 2px 16px;
}

.amount-block.bordered {
  border-bottom: 1px solid var(--line);
}

.amount-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.amount-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}

.amount-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  padding: 0;
  font-family: var(--ff);
  font-weight: 700;
  font-size: 44px;
  line-height: 1;
  letter-spacing: -0.035em;
  color: var(--ink);
}

.amount-input:focus {
  box-shadow: none;
}

.amount-hint {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--faint);
}

.unit {
  flex: none;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  background: var(--s2);
  padding: 7px 13px;
  border-radius: var(--r-pill);
  white-space: nowrap;
}

.swap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin: -10px auto;
  position: relative;
  z-index: 2;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--s1);
  color: var(--accent);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.07);
}

.swap:active {
  background: var(--asoft);
}

.disclose {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
  padding: 10px 12px;
  background: var(--s2);
  border-radius: var(--r-lg);
  font-size: 12px;
  color: var(--muted);
}

.disclose .link {
  margin-left: auto;
}

/* ------------------------------------------------------------------ *
 * Offers
 * ------------------------------------------------------------------ */

.offers-head {
  padding: 4px 1px 10px;
}

.offers-count {
  font-size: 13px;
  font-weight: 600;
}

.chips-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.chip {
  flex: none;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--s1);
  color: var(--muted);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.chip.is-active {
  background: var(--asoft);
  color: var(--aink);
  border-color: transparent;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.offer-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--s1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 13px;
  color: var(--ink);
  font-family: var(--ff);
}

.offer-card.top {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.offer-card:active {
  background: var(--s2);
}

.offer-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: var(--aink);
  background: var(--asoft);
  padding: 3px 8px;
  border-radius: 5px;
  margin-bottom: 8px;
}

.offer-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.offer-get {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.offer-get small {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-left: 3px;
}

.offer-delta {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.offer-delta.best {
  color: var(--pos);
}

.offer-name {
  font-size: 13px;
  font-weight: 600;
  margin: 3px 0 9px;
}

.offer-facts {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.fact {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: var(--s2);
  padding: 4px 8px;
  border-radius: 5px;
}

.offers-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 14px;
}

.offers-foot .quiet {
  flex: 1;
}

/* ------------------------------------------------------------------ *
 * Summary list (confirm + order details + mismatch) — <dl class="sum">
 * ------------------------------------------------------------------ */

.sum {
  display: grid;
  grid-template-columns: auto 1fr;
  background: var(--s1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-top: 8px;
}

.sum dt,
.sum dd {
  padding: 11px 13px;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
}

.sum dt {
  color: var(--muted);
}

.sum dd {
  text-align: right;
  font-weight: 600;
  word-break: break-word;
}

.sum dt:first-of-type,
.sum dd:first-of-type {
  border-top: 0;
}

/* ------------------------------------------------------------------ *
 * How-it-works line + consent
 * ------------------------------------------------------------------ */

.how {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--s2);
  border-radius: var(--r-lg);
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.45;
}

.consent {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 12px;
  background: var(--s1);
  margin-top: 14px;
}

.consent input[type="checkbox"] {
  width: 21px;
  height: 21px;
  flex: none;
  margin-top: 1px;
  accent-color: var(--accent);
}

.consent-text {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink);
}

/* ------------------------------------------------------------------ *
 * Order status — "чей ход" pill, heading, timer, timeline
 * ------------------------------------------------------------------ */

.turn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--aink);
  background: var(--asoft);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  margin: 4px 0 8px;
}

.turn i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.turn.wait {
  color: var(--muted);
  background: var(--s2);
}

.turn.wait i {
  background: var(--faint);
}

.shd {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 4px;
}

.stm {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 6px;
}

.stm b {
  color: var(--ink);
  font-family: var(--mono);
  font-weight: 500;
}

.tl {
  margin: 14px 0 4px;
  padding-left: 3px;
  list-style: none;
}

.tl li {
  display: flex;
  gap: 12px;
  padding-bottom: 14px;
  position: relative;
}

.tl li:last-child {
  padding-bottom: 0;
}

.tl li::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 15px;
  bottom: -1px;
  width: 2px;
  background: var(--line);
}

.tl li:last-child::before {
  display: none;
}

.tl .d {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: none;
  margin-top: 1px;
  z-index: 1;
  border: 2px solid var(--line);
  background: var(--bg);
}

.tl .done .d {
  background: var(--accent);
  border-color: var(--accent);
}

.tl .done::before {
  background: var(--accent);
}

.tl .act .d {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--asoft);
}

.tl .t {
  font-size: 13px;
  line-height: 1.35;
}

.tl .act .t {
  font-weight: 600;
}

.tl .fut .t {
  color: var(--faint);
}

.tl .t small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  margin-top: 1px;
}

/* Requisites + trust line */

.reqs {
  background: var(--s2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 11px 12px;
  margin: 4px 0 12px;
}

.reqs pre {
  margin-top: 6px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-weight: 500;
  font-size: 12.5px;
  color: var(--ink);
}

.trust {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 13px;
}

.trust-ic {
  flex: none;
  color: var(--accent);
  margin-top: 1px;
}

/* Saved instruments (returning short path — masked, read-only) */

.saved-instrument {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 12px;
  background: var(--s1);
}

.si-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  word-break: break-word;
}

.si-masked {
  font-size: 13px;
  white-space: nowrap;
}

/* Reroute alternatives */

.reroute-alt {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 11px 12px;
  background: var(--s1);
  color: var(--ink);
}

.reroute-alt.is-selected {
  border-color: var(--accent);
  background: var(--asoft);
}

.alt-name {
  font-size: 13px;
  font-weight: 600;
  word-break: break-word;
}

.alt-amount {
  font-size: 14px;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ *
 * Rating / done
 * ------------------------------------------------------------------ */

.ok-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin: 24px auto 16px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on);
}

.ok-badge.soft {
  width: 48px;
  height: 48px;
  background: var(--asoft);
  color: var(--accent);
}

.dhd {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.dsub {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 20px;
}

.dsub b {
  color: var(--ink);
  font-weight: 600;
}

.rate {
  text-align: center;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.rate-prompt {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}

.stars {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 14px;
}

.star {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--s1);
  color: var(--faint);
  font-size: 21px;
  font-weight: 700;
}

.star.is-on {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--asoft);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 4px;
  text-align: left;
}

.toggle-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex: none;
  accent-color: var(--accent);
}

.toggle-row span {
  font-size: 13px;
  color: var(--muted);
}

/* ------------------------------------------------------------------ *
 * Notices
 * ------------------------------------------------------------------ */

.notice {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--s2);
  color: var(--ink);
  padding: 11px 12px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  margin-top: 12px;
}

.notice.is-info {
  border-color: color-mix(in srgb, var(--accent) 26%, var(--line));
  background: var(--asoft);
  color: var(--aink);
}

.notice.is-ok {
  border-color: color-mix(in srgb, var(--pos) 30%, var(--line));
  background: color-mix(in srgb, var(--pos) 9%, var(--s1));
  color: var(--pos);
}

.notice.is-error {
  border-color: color-mix(in srgb, var(--danger) 30%, var(--line));
  background: color-mix(in srgb, var(--danger) 8%, var(--s1));
  color: var(--danger);
}

/* Quiet-disclosure inline note (fallback when Telegram's native alert is absent). */
.explainer {
  margin-top: 12px;
  padding: 11px 12px;
  background: var(--s2);
  border-radius: var(--r-md);
}
