/* ── Цена и корзина ───────────────────────────────────────────────────────── */

.ps-card {
  margin: 0 0 14px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-card);
}
.ps-card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; font-size: 14px; }
.ps-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.ps-dim { font-size: 11.5px; color: var(--text-muted); }
.ps-up { color: var(--green-mid); }
.ps-down { color: var(--red); }

.ps-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin-bottom: 14px; }
.ps-tiles--sm { margin-bottom: 12px; }
.ps-tile { padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); }
.ps-tile__lbl { font-size: 11.5px; color: var(--text-muted); }
.ps-tile__val { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ps-tile__cmp { font-size: 11.5px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

.ps-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
/* Шапка таблицы держится у верха окна. Прокрутка вбок — только на узком
   экране: контейнер с overflow ломает прилипание к окну. */
.ps-scroll { overflow: visible; }
@media (max-width: 900px) { .ps-scroll { overflow-x: auto; } }
.ps-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.ps-table th { text-align: left; font-weight: 500; font-size: 11.5px; color: var(--text-muted); padding: 5px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.ps-table td { padding: 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.ps-table .num { text-align: right; white-space: nowrap; }
.ps-sortable { cursor: pointer; text-align: right !important; }
.ps-sortable:hover { color: var(--text-primary); }
.ps-sorted { color: var(--text-primary) !important; font-weight: 600 !important; }
.ps-table th:nth-child(n+3) { text-align: right; }
.ps-row { cursor: pointer; }
.ps-row:hover { background: var(--bg-hover); }
.ps-row--on { background: var(--green-subtle); }
.ps-tn { font-weight: 500; }
.ps-d { font-size: 10.5px; color: var(--text-muted); }
.ps-gap { font-weight: 600; }
.ps-more { text-align: center; margin-top: 8px; }

/* Роли позиции: не светофор — четыре спокойных тона */
.ps-lbl { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.ps-lbl--feeds { background: var(--green-light); color: var(--green-dark); }
.ps-lbl--turns { background: var(--orange-light); color: #92400e; box-shadow: inset 0 0 0 1px #f5d48a; }
.ps-lbl--adds  { background: var(--blue-light); color: var(--blue); }
.ps-lbl--doubt { background: var(--bg-hover); color: var(--text-secondary); }
.ps-tag { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 4px; font-size: 10.5px; background: var(--bg-hover); color: var(--text-secondary); border: 1px solid var(--border); white-space: nowrap; }
.ps-tag--promo { background: var(--red-light); color: var(--red); border-color: transparent; }

/* Сценарий */
.ps-scn { border-color: var(--text-primary); }
.ps-scn__title { font-size: 16px; }
.ps-input { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 10px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: 12px; font-size: 13px; }
.ps-input input { width: 90px; height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ps-input input#psHorizon { width: 60px; }
.ps-quick { display: inline-flex; gap: 4px; }

.ps-res__line { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-bottom: 12px; }
.ps-res__cell b { font-size: 18px; font-variant-numeric: tabular-nums; }
.ps-warn { font-size: 12px; font-weight: 600; color: var(--red); }

.ps-firm { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.ps-firm--firm  { background: var(--green); color: #fff; }
.ps-firm--guide { background: var(--orange-light); color: #92400e; box-shadow: inset 0 0 0 1px #f5d48a; }
.ps-firm--guess { background: var(--bg-hover); color: var(--text-secondary); box-shadow: inset 0 0 0 1px var(--border); }

.ps-table--scn td:first-child { font-weight: 500; }
.ps-grey td { color: var(--text-secondary); }
.ps-verdict { margin: 10px 0 4px; font-size: 14px; font-weight: 500; }
.ps-guess { padding: 10px 12px; border-radius: var(--radius); background: var(--bg-stripe); border: 1px dashed var(--border); font-size: 13.5px; }

.ps-ep { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.ps-ep__title { font-weight: 600; font-size: 13.5px; margin-bottom: 2px; }
.ps-table--ep { margin-top: 8px; }
.ps-ep--used td:first-child { box-shadow: inset 3px 0 0 var(--text-primary); }
.ps-ep--off td { opacity: .45; text-decoration: line-through; }
.ps-ep--off td:last-child { opacity: 1; text-decoration: none; }
.ps-offer { display: inline-block; margin: 0 4px 3px 0; padding: 1px 6px; border-radius: 4px; font-size: 11px; background: var(--blue-light); color: var(--blue); max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: top; }
.ps-excl { font-size: 12px; white-space: nowrap; display: block; }
.ps-reason { margin-top: 3px; width: 150px; height: 24px; padding: 0 6px; border: 1px solid var(--border); border-radius: 4px; font-size: 11.5px; }
.ps-nb { margin-top: 10px; }
.ps-nb summary { cursor: pointer; font-size: 12.5px; color: var(--text-secondary); }

@media (max-width: 700px) {
  .ps-input { gap: 8px; }
  .ps-tile__val { font-size: 16px; }
}
.ps-table--ep .ps-offer { white-space: normal; max-width: 300px; }
.ps-tag--nooffer { background: var(--orange-light); color: #92400e; border-color: #f5d48a; }
.ps-ep--out td { color: var(--text-muted); }
.ps-offer b { font-weight: 600; }

.ps-table--main > thead > tr > th { position: sticky; top: 0; z-index: 3; background: var(--bg-card); box-shadow: inset 0 -1px 0 var(--border); }

.ps-fc { margin: 4px 0 6px; }
.ps-fc__toggle { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 10px 12px;
  border: 1px dashed var(--text-secondary); border-radius: var(--radius); background: var(--bg-stripe);
  font-size: 14px; font-weight: 600; color: var(--text-primary); cursor: pointer; }
.ps-fc__toggle:hover { background: var(--bg-hover); }
.ps-fc__toggle--open { border-style: solid; margin-bottom: 10px; }
.ps-fc__chev { transition: transform var(--t-med); }
.ps-fc__toggle--open .ps-fc__chev { transform: rotate(180deg); }
#psForecast { padding: 0 2px 6px; }
.ps-row--now td { background: var(--bg-stripe); font-weight: 500; }

.ps-codes { margin: 0 0 12px; }
.ps-codes summary { cursor: pointer; font-size: 13px; color: var(--text-secondary); padding: 4px 0; }
.ps-table--codes { margin: 6px 0; }
.ps-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; white-space: nowrap; }
.ps-code sup { font-family: inherit; font-size: 9px; color: var(--orange); margin-left: 1px; }
.ps-ep__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.ps-nbtoggle { font-size: 12.5px; color: var(--text-secondary); cursor: pointer; }
.ps-ep--nb td { background: #f6f3ff; }
.ps-tag--nb { margin: 3px 0 0; background: #ece6ff; color: #5b3fc4; border-color: transparent; white-space: normal; }
a.ps-offer--link { text-decoration: none; cursor: pointer; }
a.ps-offer--link:hover { background: var(--blue); color: #fff; }

/* Свои даты периода: подсвечены, когда период задан ими */
.ps-dates { display: inline-flex; align-items: center; gap: 4px; margin-left: 4px; padding: 1px 4px;
  border-radius: 8px; color: var(--text-muted, #6b7280); font-size: 12px; }
.ps-dates input { width: 132px; }
.ps-dates--on { background: var(--green-light, #e8f5e3); color: var(--green-dark, #0d5a01); }

/* Цена ТН сейчас — рядом с названием в свёрнутой строке */
.ps-tn-price { margin-left: 6px; font-weight: 600; font-size: 12px; color: var(--text-muted, #6b7280); white-space: nowrap; }
.ps-tn-card { margin-left: 4px; color: #b41818; }

/* Карточка позиции — строкой под своей позицией в таблице. */
.ps-detail > td { padding: 0 0 10px !important; background: var(--bg-stripe, #f8fafc); white-space: normal; text-align: left; }
.ps-detail .ps-card { margin: 8px 8px 0; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.ps-detail td, .ps-detail th { font-variant-numeric: tabular-nums; }
.ps-tile__pct { font-size: 15px; font-weight: 600; color: var(--text-secondary, #4b5563); }
.ps-together { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; margin: 10px 0 4px; font-size: 13px; }
.ps-tog { background: var(--bg-stripe, #f3f4f6); border-radius: 10px; padding: 2px 9px; }
.ps-tog b { font-weight: 600; }
.ps-costnote { margin: 6px 0 4px; }
.ps-search { margin-left: 12px; min-width: 220px; }
