/* CopySmart — «Зеркало».
   Инварианты брифа: #9DB8FF только на шве, метках и статусе синхронизации;
   зелёный/красный у PnL и направления, пульсирующий зелёный (--live) — «бот работает» (решение 21.10); одна залитая кнопка (Старт/Стоп);
   глубина — только поверхность на фоне, без теней и рамок вокруг панелей. */

:root {
    --bg: #0E1626;
    --surface: #16213A;
    --surface-2: #1C2946;
    --line: #2A3756;
    --text: #E6EBF5;
    --muted: #8A96B0;
    --sync: #9DB8FF;
    --live: #3FD98A;
    --long: #4CC38A;
    --short: #F0616D;

    --r-panel: 14px;
    --r-ctl: 8px;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --row-h: 56px;
    --seam-w: 48px;
    --top-h: 64px;

    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 400 15px/1.5 "Onest", system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 15px; }
h3 { font-size: 15px; color: var(--text); font-weight: 600; }
p { margin: 0; }
button { font: inherit; color: inherit; }
[hidden], .hidden { display: none !important; }

:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: var(--r-ctl); }

.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
[data-icon] { display: inline-flex; }

/* ---------- Кнопки ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; padding: 0 18px; border: 0; border-radius: var(--r-ctl);
    background: transparent; cursor: pointer; font-weight: 500; white-space: nowrap;
    transition: background-color 0.2s var(--ease), opacity 0.2s, transform 0.12s var(--ease);
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
/* Единственная залитая кнопка на экране */
.btn-primary { background: var(--text); color: var(--bg); }
.btn-primary:hover:not(:disabled) { background: #fff; }
/* Контурная: рамка без заливки */
.btn-secondary { box-shadow: inset 0 0 0 1px var(--line); }
.btn-secondary:hover:not(:disabled) { box-shadow: inset 0 0 0 1px var(--muted); }
.btn-block { width: 100%; }

.btn-icon {
    display: inline-grid; place-items: center; width: 40px; height: 40px;
    border: 0; border-radius: var(--r-ctl); background: transparent; color: var(--muted); cursor: pointer;
    transition: color 0.2s, background-color 0.2s;
}
@media (hover: hover) { .btn-icon:hover { color: var(--text); background: var(--surface); } }
.btn-icon-filled { color: var(--text); }

.btn-text {
    border: 0; background: none; padding: 6px 0; cursor: pointer;
    color: var(--muted); font-weight: 500; text-decoration: underline; text-underline-offset: 3px;
    text-decoration-color: var(--line); transition: color 0.2s, text-decoration-color 0.2s;
}
.btn-text:hover { color: var(--text); text-decoration-color: var(--muted); }

/* ---------- Шапка ---------- */
.top {
    position: sticky; top: 0; z-index: 10;
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 24px;
    height: var(--top-h); padding: 0 32px; background: var(--bg);
}
.top-stream { display: flex; align-items: center; gap: 12px; min-width: 0; }
.top-stream-text { min-width: 0; }
.top-stream-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-stream-meta { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }

.live-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.live-dot.is-sync { background: var(--live); animation: glow 1.8s var(--ease) infinite; }
.live-dot.is-wait { animation: live 2s ease-in-out infinite; }
.live-dot.is-lost { background: transparent; box-shadow: inset 0 0 0 2px var(--muted); }
@keyframes live { 50% { opacity: 0.35; } }

.tabs { display: flex; gap: 4px; }
.tab {
    display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px;
    border: 0; background: none; cursor: pointer; color: var(--muted); font-weight: 500;
    position: relative; transition: color 0.2s;
}
.tab .i { display: none; }
@media (hover: hover) { .tab:hover { color: var(--text); } }
.tab.is-active { color: var(--text); }
.tab.is-active::after {
    content: ""; position: absolute; left: 14px; right: 14px; bottom: 2px; height: 2px;
    border-radius: 2px; background: var(--text);
}

/* ---------- Основная область ---------- */
.main { max-width: 1200px; margin: 0 auto; padding: 16px 32px 64px; }
.view { display: flex; flex-direction: column; gap: 24px; }
.panel { background: var(--surface); border-radius: var(--r-panel); padding: 24px; }
.note { color: var(--muted); font-size: 14px; }

/* ---------- Полоса аккаунтов ---------- */
.strip { display: flex; flex-wrap: wrap; gap: 12px 40px; min-height: 52px; align-items: flex-end; }
.strip-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.strip-name { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.strip-balance { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.strip-sub { font-size: 13px; color: var(--muted); }
.strip-empty { display: flex; align-items: center; gap: 16px; color: var(--muted); }
.tag {
    font-size: 11px; font-weight: 500; padding: 1px 6px; border-radius: 4px;
    color: var(--muted); box-shadow: inset 0 0 0 1px var(--line);
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.is-ok { width: 8px; height: 8px; background: var(--live); animation: glow 1.8s var(--ease) infinite; }
@keyframes glow {
    0% { box-shadow: 0 0 0 0 rgba(63, 217, 138, 0.55); }
    70%, 100% { box-shadow: 0 0 0 7px rgba(63, 217, 138, 0); }
}

.up { color: var(--long); }
.down { color: var(--short); }

/* ---------- Зеркало ---------- */
.mirror { background: var(--surface); border-radius: var(--r-panel); overflow: hidden; }
.mirror-head, .row {
    display: grid; grid-template-columns: 1fr var(--seam-w) 1fr; align-items: center;
}
.mirror-head { min-height: 64px; padding: 0 24px; }
.mirror-side { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.frame-thumb {
    position: relative; display: block; width: 72px; height: 40px; padding: 0; border: 0;
    border-radius: 6px; overflow: hidden; background: var(--bg); cursor: zoom-in;
}
.frame-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame-thumb img:not([src]) { display: none; }
.frame-thumb [data-icon] {
    position: absolute; inset: 0; display: grid; place-items: center; color: var(--text);
    background: rgba(14, 22, 38, 0.55); opacity: 0; transition: opacity 0.2s;
}
.frame-thumb:hover [data-icon], .frame-thumb:focus-visible [data-icon],
.frame-thumb:has(img:not([src])) [data-icon] { opacity: 1; }

.mirror-rows { position: relative; }
/* Шов: одна вертикальная линия через все строки, ровно по центру */
.mirror-rows::before {
    content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px;
    transform: translateX(-0.5px); background: var(--line);
}
.row {
    min-height: var(--row-h); padding: 0 24px; cursor: pointer;
    border-top: 1px solid var(--line); transition: background-color 0.2s;
}
@media (hover: hover) { .row:hover { background: rgba(230, 235, 245, 0.025); } }
.row:focus-visible { outline-offset: -2px; border-radius: 0; }

.cell { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-width: 0; padding: 8px 0; }
.cell-us { flex-direction: row-reverse; }
.sym { font-weight: 600; }
.cell-detail { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); line-height: 1.35; }
.cell-trader .cell-detail { align-items: flex-end; text-align: right; }
.cell-us .cell-detail { align-items: flex-start; }
.cell-detail strong { font-weight: 500; color: var(--text); }
.pnl { font-weight: 600; font-size: 16px; }
.side-long, .cell-detail .side-long { color: var(--long); }
.side-short, .cell-detail .side-short { color: var(--short); }
.muted { color: var(--muted); }

.seam { position: relative; display: grid; place-items: center; height: 100%; }
.mark {
    position: relative; z-index: 1; width: 8px; height: 8px; border-radius: 50%;
    background: var(--muted);
}
.mark-full { background: var(--sync); }
.mark-partial { background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--sync); }
/* Единственный оркестрованный момент: копия состоялась — метка проявляется */
.mark-full.is-new { animation: synced 600ms var(--ease); }
@keyframes synced {
    from { background: var(--muted); transform: scale(0.6); }
    to { background: var(--sync); transform: scale(1); }
}

.mirror-empty { padding: 48px 24px; text-align: center; color: var(--muted); border-top: 1px solid var(--line); position: relative; z-index: 1; background: var(--surface); }
.mirror-empty p { max-width: 44ch; margin: 0 auto; }

/* ---------- Сделки ---------- */
.totals { display: flex; flex-wrap: wrap; gap: 12px 48px; }
.total-label { font-size: 13px; color: var(--muted); }
.total-value { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.trade-list { background: var(--surface); border-radius: var(--r-panel); overflow: hidden; }
.trade {
    display: grid; grid-template-columns: 110px 1fr 1.4fr 120px; gap: 16px; align-items: center;
    padding: 14px 24px; font-size: 14px;
}
.trade + .trade { border-top: 1px solid var(--line); }
.trade-time { color: var(--muted); font-size: 13px; }
.trade-what { display: flex; flex-direction: column; }
.trade-what span { color: var(--muted); font-size: 13px; }
.trade-prices { color: var(--muted); }
.trade-pnl { text-align: right; font-weight: 600; }
.list-empty { padding: 40px 24px; text-align: center; color: var(--muted); }

/* ---------- Отчёт ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.report-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.report-account { flex: 0 1 220px; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px 32px; }
.metric-label { font-size: 13px; color: var(--muted); }
.metric-value { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.panel-title { margin-bottom: 12px; }
.list-title { margin-bottom: -12px; }

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: var(--line); stroke-dasharray: 2 4; }
.chart-zero { stroke: var(--muted); stroke-width: 1; }
.chart-label { fill: var(--muted); font-size: 12px; font-family: inherit; }
.chart-line { fill: none; stroke: var(--text); stroke-width: 2; stroke-linejoin: round; }
.chart-area { fill: rgba(230, 235, 245, 0.06); }
.chart-cross { stroke: var(--muted); stroke-dasharray: 3 3; }
.chart-dot { fill: var(--text); stroke: var(--surface); stroke-width: 2; }
.chart-tip {
    position: absolute; pointer-events: none; padding: 8px 12px; border-radius: var(--r-ctl);
    background: var(--bg); font-size: 13px; line-height: 1.45; white-space: nowrap;
}
.chart-empty { margin-top: 8px; font-size: 14px; color: var(--muted); }

.cal-head { display: flex; align-items: center; justify-content: space-between; margin: -8px -8px 12px; }
.cal-head .btn-icon:disabled { opacity: 0.3; cursor: default; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { font-size: 12px; color: var(--muted); text-align: center; padding-bottom: 4px; }
.cal-day {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 64px; border-radius: var(--r-ctl); background: var(--surface-2);
}
.cal-num { font-size: 14px; }
.cal-pnl { font-size: 12px; color: var(--muted); }
/* Цвет дня кодирует знак PnL — та же пара зелёный/красный, что у цифр */
.cal-day.is-up { background: rgba(76, 195, 138, 0.14); }
.cal-day.is-up .cal-pnl { color: var(--long); }
.cal-day.is-down { background: rgba(240, 97, 109, 0.14); }
.cal-day.is-down .cal-pnl { color: var(--short); }
.cal-day.is-future { background: none; color: var(--muted); }
.cal-day.is-today .cal-num { font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

.rank-row { display: grid; grid-template-columns: 1fr auto 120px; gap: 16px; align-items: center; padding: 10px 0; font-size: 14px; }
.rank-row + .rank-row { border-top: 1px solid var(--line); }
.rank-pnl { text-align: right; font-weight: 600; }

/* ---------- Аккаунты ---------- */
.acc-list { background: var(--surface); border-radius: var(--r-panel); overflow: hidden; }
.acc {
    display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center;
    padding: 16px 24px;
}
.acc + .acc { border-top: 1px solid var(--line); }
.acc-main { display: flex; flex-direction: column; min-width: 0; }
.acc-name { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.acc-meta { font-size: 13px; color: var(--muted); }
.acc-result { font-size: 13px; display: flex; align-items: center; gap: 6px; }
.acc-result:empty { display: none; }
.acc-result .i { width: 14px; height: 14px; color: var(--text); flex: none; }
.acc-result.is-new .i path { stroke-dasharray: 24; animation: draw 400ms var(--ease) both; }
@keyframes draw { from { stroke-dashoffset: 24; } }
.spinner {
    width: 12px; height: 12px; border-radius: 50%; flex: none;
    border: 2px solid var(--line); border-top-color: var(--text); animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.acc-actions { display: flex; gap: 16px; }

.acc-form { display: flex; flex-direction: column; gap: 14px; }

.switch { position: relative; display: inline-flex; width: 36px; height: 20px; flex: none; cursor: pointer; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: inherit; }
.switch span {
    width: 100%; height: 100%; border-radius: 10px; background: var(--line);
    transition: background-color 0.2s var(--ease);
}
.switch span::after {
    content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%;
    background: var(--muted); transition: transform 0.25s var(--ease), background-color 0.2s;
}
.switch input:checked + span { background: var(--text); }
.switch input:checked + span::after { transform: translateX(16px); background: var(--bg); }
.switch input:disabled + span { opacity: 0.45; }
.switch input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 2px; }

/* ---------- Поля ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.field > span { font-size: 13px; color: var(--muted); }
.field input, .field select, .chat-form input {
    width: 100%; height: 40px; padding: 0 12px; border: 0; border-radius: var(--r-ctl);
    background: var(--bg); color: var(--text); font: inherit; font-size: 15px;
}
.field input:focus-visible, .field select:focus-visible, .chat-form input:focus-visible { outline-offset: 0; }
.field input[readonly] { color: var(--muted); }
.field-row { display: flex; gap: 12px; }
.field-wide { flex: 2; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--text); margin: 0; }
.form-actions { display: flex; align-items: center; gap: 20px; margin-top: 4px; }
.hint { font-size: 13px; color: var(--muted); }
.hint.error { color: var(--text); }
.hint.error:empty { display: none; }
#tfaCodeRow { align-items: flex-end; }
.tfa-secret { font-size: 17px; letter-spacing: 0.08em; word-break: break-all; user-select: all; }

/* ---------- Чат ---------- */
.view-chat { gap: 16px; }
.chat-log { display: flex; flex-direction: column; gap: 12px; min-height: 240px; }
.msg { max-width: 72ch; padding: 12px 16px; border-radius: var(--r-panel); background: var(--surface); font-size: 14px; line-height: 1.55; }
.msg-user { align-self: flex-end; background: var(--surface-2); }
.msg-head { display: flex; gap: 12px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.msg-head b { font-weight: 500; color: var(--text); }
.msg code { font-size: 13px; padding: 0 4px; border-radius: 4px; background: var(--bg); }
.chat-form { display: flex; gap: 8px; position: sticky; bottom: 16px; }
.chat-form input { height: 48px; background: var(--surface); }
.chat-form .btn-icon { width: 48px; height: 48px; background: var(--surface); }
.chat-summary { align-self: flex-start; }
.chat-hint { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 14px; }

/* ---------- Листы и диалоги ---------- */
dialog { color: var(--text); border: 0; padding: 0; background: var(--surface); }
dialog::backdrop { background: rgba(6, 10, 20, 0.62); }

.sheet {
    position: fixed; inset: 0 0 0 auto; margin: 0; width: min(460px, 100vw); height: 100dvh;
    max-height: none; max-width: none; /* снимаем ограничения браузера для <dialog> */
    border-radius: var(--r-panel) 0 0 var(--r-panel); overflow-y: auto; overscroll-behavior: contain;
}
.sheet[open] { animation: sheet-in 320ms var(--ease); }
@keyframes sheet-in { from { transform: translateX(32px); opacity: 0; } }
.sheet-head {
    position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between;
    padding: 16px 16px 8px 24px; background: var(--surface);
}
.sheet-head h2 { font-size: 18px; }
.sheet-body { padding: 8px 24px 32px; display: flex; flex-direction: column; gap: 28px; }
.section { display: flex; flex-direction: column; gap: 14px; }
.section h3 + .field, .section h3 + .hint { margin-top: -4px; }
.section h3:not(:first-child) { margin-top: 12px; }

.crop summary { cursor: pointer; font-size: 14px; color: var(--muted); }
.crop[open] summary { margin-bottom: 12px; }
.preview { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--muted); }
.preview img { width: 100%; border-radius: var(--r-ctl); display: block; }
.log {
    margin: 0; max-height: 320px; overflow: auto; padding: 12px; border-radius: var(--r-ctl);
    background: var(--bg); color: var(--muted); font-size: 12px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
}

.coin-block { display: flex; flex-direction: column; gap: 8px; }
.coin-line { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; }
.coin-line span:first-child { color: var(--muted); }

/* Плавающее окно трансляции. Ширина тянется за угол (resize), высота следует пропорции кадра */
.viewer {
    position: fixed; z-index: 30; right: 24px; bottom: 24px;
    width: 440px; min-width: 280px; max-width: calc(100vw - 16px);
    background: var(--surface); border-radius: var(--r-panel); overflow: hidden; resize: horizontal;
    animation: fade-in 240ms var(--ease);
}
.viewer-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    height: 48px; padding: 0 4px 0 8px; cursor: grab; touch-action: none; user-select: none;
}
.viewer.is-dragging .viewer-bar { cursor: grabbing; }
.viewer.is-dragging iframe { pointer-events: none; }   /* иначе iframe «съедает» движение мыши */
.seg { display: flex; gap: 2px; }
.seg button {
    height: 32px; padding: 0 10px; border: 0; border-radius: var(--r-ctl); background: none;
    color: var(--muted); font-size: 13px; font-weight: 500; cursor: pointer; transition: color 0.2s, box-shadow 0.2s;
}
.seg button[aria-pressed="true"] { color: var(--text); background: var(--bg); }
.viewer-stage { position: relative; overflow: hidden; background: #000; aspect-ratio: 16 / 9; }
.viewer-stage iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; transform-origin: 0 0; }
/* В режиме области плеер увеличен и сдвинут — клики по нему не нужны и мешали бы перетаскиванию */
.viewer.is-crop .viewer-stage iframe { pointer-events: none; }

.confirm { width: min(420px, calc(100vw - 32px)); border-radius: var(--r-panel); padding: 24px; }
.confirm[open] { animation: fade-in 240ms var(--ease); }
.confirm h2 { font-size: 18px; margin-bottom: 8px; }
.confirm p { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.confirm form { display: flex; flex-direction: column; gap: 14px; }
@keyframes fade-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Уведомления ---------- */
.toasts {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100;
    display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
}
/* popover — чтобы уведомления были поверх открытых модальных окон (top layer) */
.toasts[popover] { top: auto; right: auto; margin: 0; padding: 0; border: 0; background: none; color: inherit; overflow: visible; }
.toasts[popover]:not(:popover-open) { display: none; }
.form-status { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.form-status .i { width: 14px; height: 14px; color: var(--text); }
.form-status.is-new .i path { stroke-dasharray: 24; animation: draw 400ms var(--ease) both; }
.toast {
    padding: 10px 16px; border-radius: var(--r-ctl); background: var(--surface-2); font-size: 14px;
    max-width: min(480px, calc(100vw - 32px)); animation: fade-in 240ms var(--ease);
}

/* ---------- Мобильная версия ---------- */
/* Планшет и уже: вкладки уходят вниз, шапке остаются трансляция и Старт/Стоп */
@media (max-width: 899px) {
    .top { grid-template-columns: 1fr auto; }
    .tabs {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
        display: grid; grid-template-columns: repeat(4, 1fr); gap: 0;
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--surface);
    }
    .tab { flex-direction: column; gap: 2px; height: 52px; padding: 0; font-size: 11px; justify-content: center; }
    .tab .i { display: block; width: 22px; height: 22px; }
    .tab.is-active::after { display: none; }
    .main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
    .toasts { bottom: calc(88px + env(safe-area-inset-bottom)); }
    .chat-form { bottom: calc(80px + env(safe-area-inset-bottom)); }
    .viewer { bottom: calc(80px + env(safe-area-inset-bottom)); }
}

@media (max-width: 767px) {
    .viewer { right: 8px; width: calc(100vw - 16px); }
    :root { --top-h: 60px; }
    .top { padding: 0 16px; gap: 12px; }
    /* На телефоне Старт/Стоп — только иконка, чтобы название трансляции поместилось */
    .top .btn-primary { width: 44px; padding: 0; }
    .run-label, .wide-only { display: none; }

    .main { padding: 8px 16px calc(96px + env(safe-area-inset-bottom)); }
    .view { gap: 16px; }
    .strip { gap: 12px 28px; }
    .strip-balance { font-size: 18px; }
    .panel { padding: 20px 16px; }

    /* Шов становится горизонтальной чертой внутри карточки: сверху трейдер, снизу мы */
    .mirror-head { padding: 0 16px; grid-template-columns: 1fr 1fr; column-gap: 20px; }
    .mirror-seam-head { display: none; }
    .mirror-rows::before { display: none; }
    .row { grid-template-columns: 1fr; padding: 8px 16px; }
    .seam { height: 16px; }
    .seam::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--line); }
    .cell-trader .cell-detail { align-items: flex-end; }
    .cell-us { flex-direction: row; }
    .cell-us .cell-detail { align-items: flex-start; }

    .trade { grid-template-columns: 1fr auto; padding: 14px 16px; gap: 4px 12px; }
    .trade-time { grid-column: 1 / -1; }
    .trade-prices { grid-column: 1; font-size: 13px; }
    .trade-pnl { grid-row: 2; grid-column: 2; }

    .metrics { grid-template-columns: 1fr 1fr; }
    .metric-value { font-size: 18px; }
    .report-account { flex-basis: 100%; }
    .cal-grid { gap: 4px; }
    .cal-day { min-height: 48px; }
    .cal-num { font-size: 13px; }
    .cal-pnl { font-size: 10px; }
    .rank-row { grid-template-columns: 1fr auto; }
    .rank-row .muted { display: none; }
    .acc { grid-template-columns: auto 1fr; padding: 16px; }
    .acc-actions { grid-column: 1 / -1; padding-left: 52px; }
    .field-row { flex-wrap: wrap; }
    .field-row .field { flex: 1 1 120px; }

    .sheet {
        inset: auto 0 0 0; width: 100vw; height: auto; max-height: 88dvh;
        border-radius: var(--r-panel) var(--r-panel) 0 0;
    }
    .sheet[open] { animation-name: sheet-up; }
    .sheet-body { padding: 8px 16px calc(24px + env(safe-area-inset-bottom)); }
    @keyframes sheet-up { from { transform: translateY(32px); opacity: 0; } }

    .toasts { bottom: calc(88px + env(safe-area-inset-bottom)); }
    .chat-form { bottom: calc(80px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
.tfa-qr { width: fit-content; padding: 8px; background: #fff; border-radius: var(--r-ctl); line-height: 0; }
.tfa-qr:empty { display: none; }
