/* 06-portfolio.css — the /MySets header: value, PnL, forecast line, chart, movers.
   Part of the former single site.css. These files are ORDER-DEPENDENT: they are linked in
   numeric order in _Layout.cshtml and later rules still override earlier ones exactly as they
   did in the one big file. Do not reorder the <link> tags. */
/* ── Portfolio value chart ─────────────────────────────── */

/* /MySets header, exchange-style (task 078): ONE large figure — «Оцінка вартості» — with «PnL сьогодні» and
   «Загальний PnL» beside it, the forecast a single line under the fact, then the chart. It replaced six equal
   tiles in which the value was one of six and today's change was absent. Colours: the 077 pair, --trend-up /
   --trend-down (04-collection.css, .mysets-page). */
.pf-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 24px 16px;
  box-shadow: var(--shadow);
}

.pf-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px 40px;
}

.pf-balance h1 {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 800;
}

.pf-label,
.pf-stat dt {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

/* When the collection was valued (task 171, MySetsSummary.ValuedAgo) — beside «Оцінка вартості», amber once a row's
   BrickLink value is older than a day. */
.pf-label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--space-2);
}

.pf-asof {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.pf-asof--stale {
  color: var(--warn);
  font-weight: 600;
}

.pf-value {
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pf-value span {
  margin-left: 6px;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 700;
}

.pf-value--empty {
  color: var(--muted);
}

.pf-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.pf-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 32px;
  margin: 0;
}

.pf-stat dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pf-stat__num {
  font-size: 1.15rem;
  font-weight: 800;
}

.pf-stat__pct {
  font-size: 0.86rem;
  font-weight: 700;
}

.pf-stat--minor .pf-stat__num {
  font-size: 0.95rem;
}

.pf-forecast {
  margin: 14px 0 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}

.pf-forecast span {
  font-weight: 700;
}

.pf-movers {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.pf-movers__label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.pf-mover {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.pf-mover:hover:not(:disabled),
.pf-mover:focus-visible:not([data-focus-quiet]) {
  border-color: var(--accent);
}

.pf-mover:disabled {
  color: var(--muted);
}

.pf-mover__title {
  color: var(--muted);
}

.pf-mover__set {
  font-weight: 700;
}

.pf-mover__num {
  font-weight: 800;
}

.pf-alerts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.8rem;
}

.portfolio-chart-segmented,
.portfolio-chart-range-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.portfolio-chart-toggle,
.portfolio-chart-range {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  padding: 8px 12px;
  border-radius: 6px;
  min-width: 48px;
}

.portfolio-chart-toggle.is-active,
.portfolio-chart-range.is-active {
  background: #1d4ed8;
  color: #fff;
  box-shadow: 0 6px 16px rgba(29, 78, 216, 0.22);
}

.portfolio-chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.portfolio-chart-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px 14px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.portfolio-chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.portfolio-chart-legend__swatch {
  display: inline-block;
  width: 22px;
  height: 0;
  border-top: 3px solid currentColor;
  border-radius: 999px;
}

.portfolio-chart-legend__swatch--actual { color: var(--info); }
.portfolio-chart-legend__swatch--ask {
  color: #f97316;
  border-top-style: dashed;
}
.portfolio-chart-legend__swatch--invested {
  color: var(--text-faint);
  border-top-style: dotted;
}

.portfolio-chart-canvas-wrap {
  height: 320px;
  position: relative;
}

.portfolio-chart-period {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* «+412.30 PLN · +6.0 % за 6М» beside the period buttons (task 084); pnl--up / --down give the 077 pair. */
.portfolio-chart-change {
  font-size: 0.86rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The long note under the chart, folded (task 084). */
.portfolio-chart-explain {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.portfolio-chart-explain summary {
  cursor: pointer;
  width: fit-content;
  margin-left: auto;
  font-weight: 600;
}

.portfolio-chart-explain p {
  margin: 6px 0 0;
}

.portfolio-chart-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 10px;
  text-align: right;
}

/* «Що варто зробити» under the movers: one line each, tinted by severity. */
.collection-action {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.collection-action--info {
  background: var(--info-bg);
  border-color: color-mix(in srgb, var(--info) 35%, var(--surface-1));
}

.collection-action--warning {
  background: var(--warn-bg);
  border-color: color-mix(in srgb, var(--warn) 35%, var(--surface-1));
}

.collection-action--danger {
  background: var(--down-bg);
  border-color: color-mix(in srgb, var(--down) 35%, var(--surface-1));
}

.collection-mover-modal-open {
  overflow: hidden;
}

.collection-mover-modal[hidden] {
  display: none;
}

/* The movers' window (task 127): tabs for the four groups, a list of compact rows and the chart side by side; at
   ≤ 900 px one view at a time (data-mover-view, below). Colours are the semantic tokens only. */
.collection-mover-modal {
  position: fixed;
  inset: 0;
  z-index: 1050;
}

.collection-mover-modal__backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay);
}

.collection-mover-modal__dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1040px, calc(100vw - 32px));
  height: min(720px, calc(100vh - 48px));
  margin: 24px auto;
  overflow: hidden;
  border-radius: var(--radius-3);
  background: var(--surface-1);
  box-shadow: var(--shadow-2);
}

.collection-mover-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5) 0;
}

.collection-mover-modal__head h2 {
  margin: 0;
  font-size: var(--text-xl);
}

.collection-mover-modal__close {
  flex: none;
  font-size: var(--text-xl);
}

.collection-mover-modal__tabs {
  flex: none;
  margin: var(--space-2) var(--space-5) 0;
}

.collection-mover-modal__tabs .ui-tab:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.collection-mover-modal__note {
  flex: none;
  margin: var(--space-2) var(--space-5) 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.collection-mover-modal__body {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: var(--space-4);
  min-height: 0;
  padding: var(--space-3) var(--space-5) var(--space-5);
}

.collection-mover-modal__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* One row: the thumbnail, number and name on one line, the move right-aligned in its colour. */
.collection-mover-modal-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  flex: none;
  width: 100%;
  min-height: 48px;
  padding: var(--space-1) var(--space-2);
  border: 0;
  border-radius: var(--radius-2);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.collection-mover-modal-row:hover {
  background: var(--surface-2);
}

.collection-mover-modal-row[aria-pressed="true"] {
  background: var(--surface-3);
  box-shadow: inset 3px 0 0 var(--accent);
}

.collection-mover-modal-row:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}

.collection-mover-modal-row__thumb {
  width: 40px;
  height: 40px;
  overflow: hidden;
  border-radius: var(--radius-1);
  background: var(--surface-2);
}

.collection-mover-modal-row__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.collection-mover-modal-row__name {
  overflow: hidden;
  font-size: var(--text-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collection-mover-modal-row__name b {
  margin-right: var(--space-1);
  color: var(--text-muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.collection-mover-modal-row__move {
  flex-direction: column;
  align-items: flex-end;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.collection-mover-modal-row__move.ui-change {
  display: inline-grid;
  justify-items: end;
}

.collection-mover-modal-row__move::before {
  content: none;
}

.collection-mover-modal-row__move small {
  font-size: var(--text-xs);
  font-weight: 500;
}

.collection-mover-modal__chart-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-3);
  background: var(--surface-2);
}

.collection-mover-modal__chart-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.collection-mover-modal__title-block {
  flex: 1 1 0;
  min-width: 0;
}

.collection-mover-modal__back {
  display: none;
  flex: none;
  font-size: var(--text-xl);
}

.collection-mover-modal__set {
  font-size: var(--text-lg);
  font-weight: 700;
}

.collection-mover-modal__source {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.collection-mover-modal__delta {
  flex: none;
  flex-direction: column;
  align-items: flex-end;
  font-size: var(--text-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.collection-mover-modal__delta.ui-change {
  display: inline-grid;
  justify-items: end;
}

.collection-mover-modal__delta.ui-change::before {
  content: none;
}

.collection-mover-modal__delta small {
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 500;
}

.collection-mover-modal__stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
  margin: 0;
}

.collection-mover-modal__stats:empty {
  display: none;
}

.collection-mover-modal__stats dt {
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 500;
}

.collection-mover-modal__stats dd {
  margin: 2px 0 0;
  font-size: var(--text-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.collection-mover-modal__stats dd.ui-change::before {
  content: none;
}

.collection-mover-modal__canvas-wrap {
  position: relative;
  min-height: 0;
  flex: 1 1 auto;
}

.collection-mover-modal__canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.collection-mover-modal__empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-align: center;
  border-radius: var(--radius-2);
  background: var(--surface-1);
}

.collection-mover-modal__footer {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 700px) {
  .portfolio-chart-toolbar {
    justify-content: flex-start;
  }
  .portfolio-chart-legend {
    justify-content: flex-start;
  }
  .portfolio-chart-period {
    flex-wrap: wrap;
    width: 100%;
    gap: 6px;
  }
  .portfolio-chart-segmented,
  .portfolio-chart-range-group {
    width: 100%;
  }
  /* Five buttons in one row; if a narrower screen cannot fit them, the group scrolls, not the page. */
  .portfolio-chart-range-group {
    overflow-x: auto;
  }
  .portfolio-chart-toggle,
  .portfolio-chart-range {
    flex: 1 1 0;
    min-width: 44px;
    padding-inline: 8px;
  }
  .portfolio-chart-canvas-wrap {
    height: 220px;
  }
  .pf-card {
    padding: 16px;
  }
  .pf-value {
    font-size: 1.7rem;
  }
}

@media (max-width: 900px) {
  /* One view at a time: the list first, a row's tap opens the chart with «‹» back (task 127). Before, the list and
     the chart stood one under the other and the chart was below the first screen at 390. */
  .collection-mover-modal__body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }
  .collection-mover-modal__dialog[data-mover-view="list"] .collection-mover-modal__chart-panel,
  .collection-mover-modal__dialog[data-mover-view="chart"] .collection-mover-modal__list,
  .collection-mover-modal__dialog[data-mover-view="chart"] .collection-mover-modal__tabs,
  .collection-mover-modal__dialog[data-mover-view="chart"] .collection-mover-modal__note {
    display: none;
  }
  .collection-mover-modal__back {
    display: inline-flex;
    width: var(--touch);
    height: var(--touch);
    margin: calc(-1 * var(--space-2)) 0 0 calc(-1 * var(--space-2));
  }
  /* The set's name and its source keep the width; the group's figure goes under them. */
  .collection-mover-modal__chart-head {
    flex-wrap: wrap;
  }
  .collection-mover-modal__delta.ui-change {
    flex-basis: 100%;
    justify-items: start;
  }
  .collection-mover-modal__stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .collection-mover-modal__canvas-wrap {
    flex: 1 1 auto;
    min-height: 220px;
  }
  /* The tabs are a segmented strip that scrolls sideways if four titles do not fit; each is a 44 px target. */
  .collection-mover-modal__tabs {
    gap: 2px;
    padding: 2px;
    border-radius: var(--radius-2);
    background: var(--surface-2);
    box-shadow: none;
  }
  .collection-mover-modal__tabs .ui-tab {
    flex: 1 0 auto;
    justify-content: center;
    min-height: var(--touch);
    padding: 0 var(--space-3);
    border-radius: var(--radius-1);
    font-size: var(--text-sm);
  }
  .collection-mover-modal__tabs .ui-tab::after {
    content: none;
  }
  .collection-mover-modal__tabs .ui-tab[aria-selected="true"] {
    background: var(--surface-3);
  }
  .collection-mover-modal__footer .ui-btn {
    width: 100%;
    height: var(--touch);
  }
}

@media (max-width: 640px) {
  /* The whole screen, under the notch and above the home bar: 100vh is taller than what a phone shows. */
  .collection-mover-modal__dialog {
    width: 100vw;
    height: 100dvh;
    margin: 0;
    border-radius: 0;
  }
  .collection-mover-modal__head {
    padding: calc(var(--space-3) + env(safe-area-inset-top, 0px)) var(--space-4) 0;
  }
  .collection-mover-modal__close {
    width: var(--touch);
    height: var(--touch);
  }
  .collection-mover-modal__tabs,
  .collection-mover-modal__note {
    margin-inline: var(--space-4);
  }
  .collection-mover-modal__body {
    padding: var(--space-3) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
  }
  .collection-mover-modal__chart-panel {
    padding: var(--space-3);
    overflow-y: auto;
  }
}
