/* ============================================================================
   ASIA SHADRIN — Operator Mini App (S6)
   Brand design system: champagne-gold (sampled from the bot logo) on warm
   graphite. Premium international-logistics B2B. Dark-only, Telegram WebApp.

   Color anchors sampled directly from the @Aziashadrin_bot logo (AS monogram):
     gold gradient  #B29B7B → #CFAF88 → #E4D2AC
     graphite ink   #1D1D1D – #292828
   Graphite warmed (never pure black, per studio playbook). Champagne is kept
   slightly enriched so it reads as premium on dark surfaces.
   ============================================================================ */

/* ---- Fonts (Cyrillic-safe families only) -------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;500;600;700&family=Montserrat:wght@500;600;700&display=swap');

/* ---- Design tokens ------------------------------------------------------ */
:root {
  /* Brand — champagne gold ramp (from logo) */
  --gold-deep: #A8884F;
  --gold:      #CFAF88;
  --gold-soft: #DCC79B;
  --gold-hi:   #EFE2C4;
  --gold-ink:  #E8CD96;            /* gold text legible on dark */
  --gold-grad: linear-gradient(135deg, #B29B7B 0%, #CFAF88 44%, #E4D2AC 100%);
  --gold-sheen: linear-gradient(120deg, #E4D2AC 0%, #CFAF88 38%, #A8884F 100%);

  /* Warm graphite surfaces (never pure black) */
  --bg:        #15120D;
  --bg-grad:   radial-gradient(125% 90% at 50% -10%, #221C13 0%, #15120D 46%, #100E0A 100%);
  --surface:   #1F1A13;
  --surface-2: #271F17;
  --surface-3: #2F261B;
  --inset:     #14110C;

  /* Hairlines & borders (warm, low-opacity) */
  --border:      #38301F;
  --border-soft: #2A2317;
  --border-gold: rgba(207, 175, 136, 0.34);

  /* Ink */
  --ink:   #F4EEE1;
  --ink-2: #C8BFA9;
  --ink-3: #A69C83;
  --ink-4: #6E6655;

  /* Status — logistics ops palette (muted, premium) */
  --hot:       #E3A53E;
  --hot-bg:    rgba(227, 165, 62, 0.13);
  --ok:        #6FB07E;
  --ok-bg:     rgba(111, 176, 126, 0.13);
  --warn:      #D8A24A;
  --warn-bg:   rgba(216, 162, 74, 0.13);
  --bad:       #D9706A;
  --bad-bg:    rgba(207, 96, 88, 0.13);
  --info:      #7B9DC9;
  --info-bg:   rgba(123, 157, 201, 0.13);
  --neutral:   #978D79;
  --neutral-bg: rgba(139, 130, 112, 0.12);

  /* Typography */
  --font-ui:    'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  /* бренд/заголовки (бывш. serif) — теперь геометрический Montserrat */
  --font-serif: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;

  /* Radii */
  --r-sm: 9px;
  --r:    16px;
  --r-lg: 20px;
  --r-pill: 999px;

  /* Spacing rhythm (8pt) */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  /* Elevation */
  --shadow-1: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-2: 0 10px 30px -12px rgba(0,0,0,0.6);
  --shadow-gold: 0 8px 28px -10px rgba(207,175,136,0.28);

  /* Глянцевая «чернёная» панель под загруженный wavy-фон: сатиновый диагональный
     градиент (эхо волн) + тёплый блик по верхней кромке + мягкая тень-парение. */
  --panel:        linear-gradient(150deg, #251E17 0%, #1C1711 60%, #191410 100%);
  --panel-active: linear-gradient(150deg, #2C2419 0%, #221B13 100%);
  --edge-hi:      inset 0 1px 0 rgba(245, 220, 195, 0.08);
  /* тень-парение + тонкая светлая кромка по всему контуру — иначе низ панели сливается с фоном */
  --panel-shadow: 0 12px 30px -16px rgba(0,0,0,0.72), 0 0 0 1px rgba(245, 220, 195, 0.055);
  --rose:         #E8B79B;

  /* Chrome heights */
  --topbar-h: 56px;
  --tabbar-h: 60px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ---- Reset -------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }

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

body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg-grad);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
ul { list-style: none; padding: 0; }
a { color: var(--gold-ink); text-decoration: none; }

::selection { background: rgba(207,175,136,0.28); color: #fff; }

/* Scrollbar (thin, warm) */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================================
   APP SHELL
   ============================================================================ */
#app {
  max-width: 540px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  /* Брендовый бэкдроп: загруженная картинка (чёрные волны + rose-gold линия) +
     лёгкий скрим сверху/снизу для читаемости карточек. Фикс. за контентом (#app —
     высотой с вьюпорт, скроллит .screens). */
  background:
    linear-gradient(180deg, rgba(16,13,9,0.74) 0%, rgba(16,13,9,0.26) 26%, rgba(16,13,9,0.40) 64%, rgba(16,13,9,0.72) 100%),
    url('bg.jpg') center center / cover no-repeat,
    var(--bg);
}

@media (min-width: 560px) {
  #app {
    border-left: 1px solid var(--border-soft);
    border-right: 1px solid var(--border-soft);
  }
}

/* ---- Top bar ------------------------------------------------------------ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) var(--sp-4) 0;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: rgba(21,18,13,0.78);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--border-soft);
}

/* Monogram avatar — serif "AS" in gold, faithful to the logo */
.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
  flex: 1;
}
.monogram {
  width: 38px; height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 11px;
  border: 1px solid var(--border-gold);
  background:
    radial-gradient(120% 120% at 30% 20%, rgba(228,210,172,0.16), transparent 60%),
    var(--surface-2);
  box-shadow: inset 0 1px 0 rgba(239,226,196,0.10), var(--shadow-1);
}
.monogram span {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.04em;
  background: var(--gold-sheen);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}
.brand__text { min-width: 0; }
.brand__name {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
  color: var(--ink);
  white-space: nowrap;
}
.brand__sub {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
}

/* Broadcast toggle in topbar */
.broadcast {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 40px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.broadcast__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-4);
  box-shadow: 0 0 0 0 transparent;
}
.broadcast.is-live { border-color: rgba(111,176,126,0.4); color: var(--ok); }
.broadcast.is-live .broadcast__dot {
  background: var(--ok);
  box-shadow: 0 0 10px 1px rgba(111,176,126,0.5);
  animation: pulse 2.4s var(--ease) infinite;
}
.broadcast.is-paused { border-color: rgba(216,162,74,0.4); color: var(--warn); }
.broadcast.is-paused .broadcast__dot { background: var(--warn); }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ---- Screens / scroll area ---------------------------------------------- */
.screens {
  flex: 1;
  position: relative;
  z-index: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + var(--sp-4));
}
.screen { display: none; padding: var(--sp-5) var(--sp-4) 0; }
.screen.is-active { display: block; }

.screen__title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 2px;
}
.screen__lead {
  font-size: 13px;
  color: var(--ink-3);
  margin-bottom: var(--sp-5);
}
.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: var(--sp-6) 0 var(--sp-3);
}
.eyebrow:first-child { margin-top: 0; }

/* ============================================================================
   COMPONENTS
   ============================================================================ */

/* ---- Cards -------------------------------------------------------------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
  box-shadow: var(--edge-hi), var(--panel-shadow);
}

/* ---- Metrics (bento) ---------------------------------------------------- */
.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}
.metric {
  position: relative;
  padding: var(--sp-4);
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
  box-shadow: var(--edge-hi), var(--panel-shadow);
  overflow: hidden;
}
.metric::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--gold-grad);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.metric.metric--accent::after { opacity: 0.85; }
.metric--wide { grid-column: 1 / -1; }
.metric__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 6px;
}
.metric__value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  margin-top: var(--sp-2);
  line-height: 1.05;
}
.metric__value.is-gold {
  background: var(--gold-sheen);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.metric__unit { font-size: 14px; font-weight: 500; color: var(--ink-3); margin-left: 4px; }
.metric__foot { font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.metric__foot b { color: var(--ink-2); font-weight: 600; }

/* Funnel bar inside wide metric */
.funnel { display: flex; flex-direction: column; gap: var(--sp-3); margin-top: var(--sp-3); }
.funnel__row { display: grid; grid-template-columns: 92px 1fr auto; align-items: center; gap: var(--sp-3); }
.funnel__name { font-size: 12px; color: var(--ink-2); }
.funnel__track { height: 7px; border-radius: 99px; background: var(--inset); overflow: hidden; }
.funnel__fill { height: 100%; border-radius: 99px; background: var(--gold-grad); width: 0; transition: width 0.7s var(--ease); }
.funnel__fill.is-info { background: linear-gradient(90deg, #5d7aa6, #7B9DC9); }
.funnel__fill.is-hot  { background: linear-gradient(90deg, #c2862a, #E3A53E); }
.funnel__num { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 600; min-width: 30px; text-align: right; }

/* ---- Trend sparklines (Динамика за 7 дней) ------------------------------ */
.trend-row { padding: 10px 0; }
.trend-row + .trend-row { border-top: 1px solid var(--border-soft); }
.trend-row__head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.trend-dot { width: 8px; height: 8px; border-radius: 99px; flex: none; }
.trend-row__name { font-size: 12px; color: var(--ink-2); }
.trend-row__val { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.trend-row__delta { font-size: 11px; font-weight: 600; }
.trend-row__delta.up { color: var(--ok); }
.trend-row__delta.down { color: var(--ink-4); }
.spark { display: block; width: 100%; height: 32px; overflow: visible; }

/* ---- Pills / chips ------------------------------------------------------ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--hot   { color: var(--hot);   background: var(--hot-bg); }
.pill--ok    { color: var(--ok);    background: var(--ok-bg); }
.pill--warn  { color: var(--warn);  background: var(--warn-bg); }
.pill--bad   { color: var(--bad);   background: var(--bad-bg); }
.pill--info  { color: var(--info);  background: var(--info-bg); }
.pill--neutral { color: var(--neutral); background: var(--neutral-bg); }

.qchip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 9px;
  border-radius: var(--r-sm);
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  color: var(--ink-2);
}
.qchip b { font-weight: 600; color: var(--ink); }
.qchip.is-yes { border-color: rgba(111,176,126,0.3); color: var(--ok); }
.qchip.is-no  { border-color: rgba(207,96,88,0.28);  color: var(--bad); }
.qchip.is-unknown { opacity: 0.6; }

/* ---- Hot inbox list ----------------------------------------------------- */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: var(--sp-2) 0 var(--sp-3);
}
.section-head .count {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.lead-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.lead {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--sp-4);
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
  box-shadow: var(--edge-hi), var(--panel-shadow);
  transition: transform 0.18s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.lead::before {
  content: "";
  position: absolute;
  left: 0; top: 14px; bottom: 14px;
  width: 3px;
  border-radius: 99px;
  background: var(--gold-grad);
}
.lead:active { transform: scale(0.985); background: var(--panel-active); }
.lead.is-paused::before { background: var(--info); }

.lead__top { display: flex; align-items: flex-start; gap: var(--sp-3); }
.lead__id {
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 700;
  color: var(--gold-ink);
  background: rgba(207,175,136,0.10);
  border: 1px solid var(--border-gold);
  border-radius: 6px;
  padding: 2px 6px;
  flex: none;
}
.lead__title { flex: 1; min-width: 0; }
.lead__name {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lead__company { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead__intent {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: var(--sp-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lead__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--sp-3); }
.lead__meta { display: flex; align-items: center; gap: var(--sp-3); margin-top: var(--sp-3); font-size: 11.5px; color: var(--ink-3); }
.lead__contact { font-family: var(--font-ui); font-variant-numeric: tabular-nums; font-size: 11.5px; color: var(--ink-2); }
.chevron { flex: none; color: var(--ink-4); }

/* ---- Detail / chat (takeover) ------------------------------------------- */
.detail { display: flex; flex-direction: column; min-height: calc(100dvh - var(--topbar-h)); }
.detail__head {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) 0 var(--sp-4);
  background: linear-gradient(180deg, var(--bg) 70%, rgba(21,18,13,0));
}
.iconbtn {
  width: 44px; height: 44px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 11px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--ink-2);
  transition: background 0.2s var(--ease);
}
.iconbtn:active { background: var(--surface-2); }

.lead-banner {
  padding: var(--sp-4);
  border-radius: var(--r);
  border: 1px solid var(--border-soft);
  background:
    radial-gradient(140% 100% at 100% 0%, rgba(232,183,155,0.11), transparent 55%),
    var(--panel);
  box-shadow: var(--edge-hi), var(--panel-shadow);
  margin-bottom: var(--sp-4);
}
.lead-banner__name { font-family: var(--font-serif); font-size: 18px; font-weight: 600; color: var(--ink); }
.lead-banner__row { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); align-items: center; }
.lead-banner__history { margin-top: var(--sp-3); font-size: 12.5px; color: var(--ink-3); line-height: 1.5; }

.qual-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-top: var(--sp-3); }
.qual {
  padding: var(--sp-3);
  border-radius: var(--r-sm);
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
}
.qual__k { font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); }
.qual__v { font-size: 13px; color: var(--ink); margin-top: 3px; font-weight: 500; word-break: break-word; }
.qual__v.is-yes { color: var(--ok); }
.qual__v.is-no { color: var(--bad); }
.qual__v.is-empty { color: var(--ink-3); }

/* Transcript bubbles */
.thread { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-2) 0 var(--sp-4); }
.bubble { max-width: 84%; padding: 10px 13px; border-radius: 16px; font-size: 14px; line-height: 1.45; position: relative; }
.bubble__who { font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 3px; opacity: 0.85; }
.bubble--lead { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border-soft); border-bottom-left-radius: 5px; color: var(--ink); }
.bubble--lead .bubble__who { color: var(--ink-3); }
.bubble--agent { align-self: flex-end; background: rgba(207,175,136,0.12); border: 1px solid var(--border-gold); border-bottom-right-radius: 5px; color: var(--ink); }
.bubble--agent .bubble__who { color: var(--gold-ink); }
.bubble--operator { align-self: flex-end; background: var(--surface-3); border: 1px solid var(--border); border-bottom-right-radius: 5px; }
.bubble--operator .bubble__who { color: var(--info); }

/* Composer */
.composer {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: var(--sp-2);
  align-items: flex-end;
  padding: var(--sp-3) 0 calc(env(safe-area-inset-bottom, 0px) + var(--sp-3));
  background: linear-gradient(0deg, var(--bg) 72%, rgba(21,18,13,0));
}
.composer textarea {
  flex: 1;
  resize: none;
  font-size: 16px; /* >=16px: не даём iOS зумить при фокусе */
  min-height: 44px;
  max-height: 140px;
  padding: 11px 14px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  line-height: 1.4;
}
.composer textarea::placeholder { color: var(--ink-4); }
.composer textarea:focus { outline: none; border-color: var(--border-gold); }

.takeover-note {
  display: flex; gap: 8px; align-items: center;
  padding: 10px var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--info-bg);
  border: 1px solid rgba(123,157,201,0.28);
  color: var(--info);
  font-size: 12.5px;
  margin-bottom: var(--sp-3);
}

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 44px;
  padding: 0 var(--sp-5);
  border-radius: var(--r);
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.15s var(--ease), filter 0.2s var(--ease), opacity 0.2s var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn--gold { color: #2a210f; background: var(--gold-grad); box-shadow: var(--shadow-gold); }
.btn--gold:active { filter: brightness(1.05); }
.btn--ghost { color: var(--ink-2); border: 1px solid var(--border); background: var(--surface); }
.btn--info { color: var(--info); border: 1px solid rgba(123,157,201,0.35); background: var(--info-bg); }
.btn--danger { color: var(--bad); border: 1px solid rgba(207,96,88,0.35); background: var(--bad-bg); }
.btn--send { width: 44px; padding: 0; flex: none; }
.btn--block { width: 100%; }

.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-top: var(--sp-4); }
.action-row .btn--block { grid-column: 1 / -1; }

/* ---- Knobs (tempo) ------------------------------------------------------ */
.knob {
  padding: var(--sp-4);
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
  box-shadow: var(--edge-hi), var(--panel-shadow);
  margin-bottom: var(--sp-3);
}
.knob__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); }
.knob__hint { font-size: 12px; line-height: 1.45; color: var(--ink-3); margin-top: 7px; }
.knob__label { font-size: 13.5px; font-weight: 500; color: var(--ink); flex: 1; }
.knob__valbox { display: flex; align-items: baseline; gap: 5px; flex: none; }
.knob__value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--gold-ink); font-family: var(--font-ui); }
.knob__unit { font-size: 11px; color: var(--ink-3); }
.knob__controls { display: flex; align-items: center; gap: var(--sp-3); margin-top: var(--sp-3); }
.knob input[type=range] {
  flex: 1;
  -webkit-appearance: none; appearance: none;
  height: 6px;
  border-radius: 99px;
  background: var(--inset);
  outline: none;
}
.knob input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--gold-grad);
  border: 2px solid #1a160f;
  box-shadow: var(--shadow-gold);
  cursor: pointer;
}
.knob input[type=range]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--gold); border: 2px solid #1a160f; cursor: pointer;
}
.stepper { display: flex; align-items: center; border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; flex: none; }
.stepper button { width: 44px; height: 44px; display: grid; place-items: center; color: var(--ink-2); font-size: 18px; font-weight: 600; background: var(--surface-2); }
.stepper button:active { background: var(--surface-3); }
.knob__foot { display: flex; align-items: center; justify-content: space-between; margin-top: var(--sp-3); }
.knob__default { font-size: 11.5px; color: var(--ink-3); }
.knob__reset { font-size: 12px; font-weight: 600; color: var(--gold-ink); padding: 11px 8px; margin: -7px 0; opacity: 0; pointer-events: none; transition: opacity 0.2s var(--ease); }
.knob.is-overridden .knob__reset { opacity: 1; pointer-events: auto; }
.knob.is-overridden { border-color: var(--border-gold); }
.knob__badge { display: none; }
.knob.is-overridden .knob__badge {
  display: inline-flex; align-items: center; height: 18px; padding: 0 7px;
  border-radius: 99px; font-size: 10px; font-weight: 600; letter-spacing: 0.04em;
  color: var(--gold-ink); background: rgba(207,175,136,0.12); border: 1px solid var(--border-gold);
}

/* ---- Script editor ------------------------------------------------------ */
.script-area {
  width: 100%;
  min-height: 220px;
  padding: var(--sp-4);
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--inset);
  color: var(--ink);
  font-size: 16px; /* >=16px: не даём iOS зумить при фокусе */
  line-height: 1.6;
  resize: vertical;
}
.script-area:focus { outline: none; border-color: var(--border-gold); }
.note {
  display: flex; gap: 10px;
  padding: var(--sp-4);
  border-radius: var(--r);
  border: 1px solid var(--border-soft);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.55;
  margin-top: var(--sp-3);
}
.note b { color: var(--ink-2); font-weight: 600; }
.note .ic { color: var(--gold-ink); flex: none; margin-top: 1px; }

.save-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-top: var(--sp-4); }
.save-hint { font-size: 12px; color: var(--ink-3); }
.save-hint.is-dirty { color: var(--warn); }
.save-hint.is-saved { color: var(--ok); }

/* ---- Accounts mini-rows (dashboard) ------------------------------------- */
.acc-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  background: var(--panel);
  box-shadow: var(--edge-hi);
  margin-bottom: var(--sp-2);
}
.acc-row__name { flex: 1; font-size: 13.5px; font-weight: 500; color: var(--ink); }
.acc-row__sent { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--ink-3); }
.acc-row__sent b { color: var(--ink); font-weight: 600; }

/* ---- Empty / loading states --------------------------------------------- */
.empty {
  text-align: center;
  padding: var(--sp-10) var(--sp-5);
  color: var(--ink-3);
}
.empty__mark {
  width: 56px; height: 56px; margin: 0 auto var(--sp-4);
  display: grid; place-items: center;
  border-radius: 16px;
  border: 1px solid var(--border-gold);
  background: var(--surface);
  color: var(--gold-ink);
}
.empty__title { font-family: var(--font-serif); font-size: 16px; font-weight: 600; color: var(--ink-2); }
.empty__text { font-size: 13px; margin-top: 4px; }

.skel {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
  border-radius: var(--r);
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skel--card { height: 92px; margin-bottom: var(--sp-3); }
.skel--metric { height: 104px; }

/* ---- Toast -------------------------------------------------------------- */
.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 14px);
  transform: translateX(-50%);
  z-index: 100;
  display: flex; flex-direction: column; gap: 8px;
  width: calc(100% - 32px); max-width: 460px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--surface-3);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2);
  font-size: 13.5px;
  color: var(--ink);
  animation: toast-in 0.32s var(--ease);
}
.toast.is-out { animation: toast-out 0.25s var(--ease) forwards; }
.toast--ok { border-color: rgba(111,176,126,0.4); }
.toast--ok .ic { color: var(--ok); }
.toast--bad { border-color: rgba(207,96,88,0.4); }
.toast--bad .ic { color: var(--bad); }
.toast .ic { flex: none; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ---- Bottom tab bar ----------------------------------------------------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 540px;
  z-index: 50;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: rgba(19,16,11,0.9);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-top: 1px solid var(--border-soft);
}
.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  color: var(--ink-3);
  font-size: 10px; font-weight: 600; letter-spacing: 0.01em;
  position: relative;
  transition: color 0.2s var(--ease);
}
.tab svg { width: 22px; height: 22px; stroke-width: 1.7; }
.tab.is-active { color: var(--gold-ink); }
.tab.is-active::before {
  content: "";
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 26px; height: 2px; border-radius: 99px;
  background: var(--gold-grad);
}
.tab__badge {
  position: absolute;
  top: 6px; left: calc(50% + 8px);
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--hot);
  color: #20180a;
  font-size: 10px; font-weight: 700;
  display: none; align-items: center; justify-content: center;
  border: 2px solid var(--bg);
}
.tab__badge.is-shown { display: flex; }

/* ---- Utilities ---------------------------------------------------------- */
.row { display: flex; align-items: center; gap: var(--sp-2); }
.spacer { flex: 1; }
.muted { color: var(--ink-3); }
.tabnum { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ============================================================================
   MOTION — entrance & stagger (paired with Motion / app.js). CSS fallback.
   ============================================================================ */
.reveal { opacity: 0; transform: translateY(10px); }
.reveal.is-in { opacity: 1; transform: none; transition: opacity 0.45s var(--ease), transform 0.45s var(--ease); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
  .broadcast.is-live .broadcast__dot { animation: none; }
}

/* Focus visibility (a11y) */
:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 2px; border-radius: 6px; }
.knob input[type=range]:focus-visible { outline: none; }
.knob input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--gold-ink), var(--shadow-gold); }
.knob input[type=range]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--gold-ink); }

/* Screen-reader-only (visually hidden, announced by AT) */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
