/* Stock Market — биржевой терминал KAPSULAS: почти чёрный фон, тёмно-фиолетовые панели, зелёный UP, красный DOWN,
   золотой Cash Out. Порядок на телефоне: шапка → график → история → портфель и Cash Out → UP/DOWN → суммы → баланс. */
#view .sm { --sm-up: #22c55e; --sm-down: #ef4444; --sm-cash: #f7c948; --sm-bg: #07050f; --sm-panel: #120a26; --sm-line: rgba(167, 139, 250, .2); }
#view .sm .case-head { margin-bottom: 10px; }
#view .sm .sm-title { white-space: nowrap; font: 800 18px/1.1 var(--display); letter-spacing: .06em; background: linear-gradient(90deg, #fff 0%, #c4b5fd 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
#view .sm .case-head .sub { font-size: 11px; font-family: ui-monospace, Menlo, monospace; }
.sm-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.sm-board { border-radius: 18px; background: radial-gradient(120% 70% at 50% 0%, #1a0d38 0%, var(--sm-bg) 70%); border: 1px solid var(--sm-line); padding: 10px 10px 8px; box-shadow: 0 18px 40px -26px rgba(74, 59, 230, .8); }
.sm-top { display: flex; align-items: center; gap: 8px; padding: 0 2px 6px; min-width: 0; }
.sm-top > * { flex-shrink: 0; } .sm-top > .sm-meta { flex-shrink: 1; }
.sm-phase { white-space: nowrap; font: 700 12px var(--body); padding: 5px 10px; border-radius: 999px; background: rgba(139, 92, 246, .18); color: #e4d9ff; }
.sm-phase[data-ph="betting"] { background: rgba(34, 197, 94, .16); color: #86efac; }
.sm-phase[data-ph="trading"] { background: rgba(247, 201, 72, .16); color: #fde68a; }
.sm-phase[data-ph="locked"], .sm-phase[data-ph="settling"] { background: rgba(239, 68, 68, .14); color: #fecaca; }
.sm-timer { font-size: 15px; color: #fff; min-width: 34px; }
.sm-cur { margin-left: auto; font-size: 22px; color: #fff; }
.sm-cur[data-sign="up"] { color: var(--sm-up); text-shadow: 0 0 18px rgba(34, 197, 94, .45); }
.sm-cur[data-sign="down"] { color: var(--sm-down); text-shadow: 0 0 18px rgba(239, 68, 68, .45); }
.sm-chart { position: relative; height: clamp(160px, 25vh, 340px); border-radius: 12px; background: linear-gradient(180deg, rgba(8, 5, 18, .6), rgba(8, 5, 18, .95)); overflow: hidden; }
.sm-chart canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.sm-banner { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: grid; justify-items: center; gap: 2px; padding: 10px 16px; border-radius: 14px;
  background: rgba(10, 6, 22, .9); border: 1px solid var(--sm-line); text-align: center; animation: popIn .3s ease-out; }
.sm-banner .num { font-size: 26px; }
.sm-banner[data-sign="up"] .num { color: var(--sm-up); } .sm-banner[data-sign="down"] .num { color: var(--sm-down); }
.sm-banner span { font-size: 12px; color: var(--muted); }
.sm-modes { display: grid; grid-template-columns: repeat(4, auto); gap: 4px; margin: 6px 0 6px; padding: 3px; border-radius: 12px; background: rgba(255, 255, 255, .04); }
.sm-modes button { min-height: 30px; min-width: 0; padding: 0 6px; border-radius: 9px; font: 600 12px var(--body); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sm-modes button[aria-selected="true"] { background: rgba(139, 92, 246, .3); color: #fff; }
.sm-hist { display: flex; flex-direction: row; gap: 3px; height: 30px; align-items: stretch; overflow: hidden; }
.sm-hb { position: relative; flex: 0 0 calc((100% - 17 * 3px) / 18); min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; border-radius: 4px; background: rgba(255, 255, 255, .03); }
.sm-hb i { display: block; border-radius: 3px; }
.sm-hb.up i { background: linear-gradient(180deg, #4ade80, #15803d); } .sm-hb.down i { background: linear-gradient(180deg, #f87171, #b91c1c); }
.sm-hb b { position: absolute; left: 0; right: 0; top: 2px; font: 700 9px/1 var(--body); text-align: center; color: rgba(255, 255, 255, .85); }
.sm-hb:first-child { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35); }
.sm-meta { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

.sm-side { display: grid; gap: 10px; align-content: start; }
.sm-pf { border-radius: 18px; padding: 10px 12px 12px; background: linear-gradient(160deg, #24124d 0%, #140a2c 100%); border: 1px solid var(--sm-line); }
.sm-pf-row { display: flex; align-items: center; gap: 6px; }
.sm-pf-row .label { flex: 1; color: var(--muted); font-size: 13px; }
.sm-pf-row .num { font-size: 22px; }
.sm-dir { font: 800 11px var(--body); padding: 3px 8px; border-radius: 999px; margin-left: 6px; }
.sm-dir[data-dir="up"] { background: rgba(34, 197, 94, .18); color: #86efac; } .sm-dir[data-dir="down"] { background: rgba(239, 68, 68, .18); color: #fca5a5; }
.sm-dir:empty { display: none; }
.sm-pf-sub { font-size: 12px; color: var(--muted); min-height: 16px; margin: 0 0 6px; }
#view .sm .btn.sm-cash { display: grid; gap: 1px; min-height: 54px; background: linear-gradient(180deg, #ffe08a 0%, #e5a92e 100%); color: #2b1b00; box-shadow: 0 12px 26px -14px rgba(247, 201, 72, .9), inset 0 1px 0 rgba(255, 255, 255, .45); }
#view .sm .btn.sm-cash span { font-size: 17px; font-weight: 800; } #view .sm .btn.sm-cash small { font-size: 11px; font-weight: 600; opacity: .8; }
#view .sm .btn.sm-cash[disabled] { background: #241b3a; color: #8e83b0; box-shadow: none; }
.sm-bets { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.sm-up, .sm-down { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 60px; border-radius: 16px; font: 800 20px var(--display); color: #fff;
  touch-action: manipulation; transition: transform .08s, box-shadow .15s, filter .15s; }
.sm-up svg, .sm-down svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.sm-up { background: linear-gradient(180deg, #34d36b 0%, #15803d 100%); box-shadow: 0 12px 24px -14px rgba(34, 197, 94, .9), inset 0 1px 0 rgba(255, 255, 255, .3); }
.sm-down { background: linear-gradient(180deg, #f25c5c 0%, #b91c1c 100%); box-shadow: 0 12px 24px -14px rgba(239, 68, 68, .9), inset 0 1px 0 rgba(255, 255, 255, .3); }
.sm-up:active, .sm-down:active { transform: scale(.97); }
.sm-up[aria-pressed="true"] { box-shadow: 0 0 0 3px #bbf7d0, 0 0 28px rgba(34, 197, 94, .8); }
.sm-down[aria-pressed="true"] { box-shadow: 0 0 0 3px #fecaca, 0 0 28px rgba(239, 68, 68, .8); }
.sm-up[disabled], .sm-down[disabled] { filter: grayscale(.55) brightness(.6); cursor: default; }
.sm-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.sm-chips::-webkit-scrollbar { display: none; }
.sm-chips .chip { flex: none; min-height: 38px; padding: 0 12px; }
.sm-chips .chip[aria-checked="true"] { background: rgba(139, 92, 246, .38); box-shadow: inset 0 0 0 1.5px #a78bfa; color: #fff; }
.sm-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.sm-tools .chip { min-height: 36px; }
.sm-stake { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sm-stake b { color: var(--text); }
.sm-auto { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); min-height: 36px; white-space: nowrap; }
.sm-auto input { width: 18px; height: 18px; accent-color: #8b5cf6; }
.sm-hint { font-size: 12px; margin: 0; }
.sm-bal { font-size: 13px; margin: 0; }
.sm-bal b { color: var(--text); }
.sm-stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 10px 0 6px; }
.sm-stat-grid > div { padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .05); display: grid; gap: 2px; }
.sm-stat-grid .num { font-size: 18px; }
.sm-stats .rows { max-height: 40vh; overflow-y: auto; margin-bottom: 14px; }
@media (min-width: 900px) {
  body:has(.sm) #view { max-width: 1180px; }
  .sm-grid { grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); align-items: start; }
  .sm-chart { height: clamp(320px, 52vh, 520px); }
}
@media (max-width: 360px) { .sm-up, .sm-down { min-height: 56px; font-size: 17px; } .sm-cur { font-size: 18px; } }
html.lite .sm-board, html.lite .sm-pf { box-shadow: none; }
html.lite .sm-up, html.lite .sm-down { box-shadow: none; }
@media (prefers-reduced-motion: reduce) { .sm-banner { animation: none; } }

.sm-ic { display: grid; place-items: center; width: 40px; min-height: 36px; padding: 0; }
.sm-ic svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 420px) { #view .sm .sm-title { font-size: 15px; letter-spacing: .03em; } .sm-stake-l { display: none; } }
/* невысокие экраны: компактнее график и полосы, чтобы UP/DOWN и суммы оставались над меню */
@media (max-height: 760px) and (max-width: 899px) {
  .sm-chart { height: clamp(130px, 21vh, 220px); }
  .sm-hist { height: 22px; } .sm-hb b { display: none; }
  .sm-modes { margin: 4px 0; } .sm-modes button { min-height: 28px; }
  .sm-up, .sm-down { min-height: 50px; font-size: 17px; }
  #view .sm .btn.sm-cash { min-height: 46px; }
  .sm-side { gap: 8px; } .sm-grid { gap: 8px; }
  .sm-hint { display: none; }
}
@media (max-width: 360px) { #view .sm .sm-title { font-size: 13px; letter-spacing: .02em; } #view .sm .case-head { gap: 6px; } .sm-ic { width: 34px; } .sm-meta { display: none; } .sm-modes button { font-size: 11px; } .sm-cur { font-size: 17px; } }
@media (max-height: 660px) and (max-width: 899px) { .sm-chart { height: 112px; } .sm-board { padding: 8px 8px 6px; } .sm-modes button { min-height: 26px; } .sm-chips .chip { min-height: 36px; } .sm-pf { padding: 8px 12px 10px; } }
/* телефон: 12 последних итогов, чтобы подписи не налезали друг на друга */
@media (max-width: 599px) {
  .sm-hb { flex-basis: calc((100% - 11 * 3px) / 12); }
  .sm-hb:nth-child(n + 13) { display: none; }
  .sm-hb b { font-size: 8.5px; letter-spacing: -.02em; }
}
