/* 6-up stock grid. Reuses .topbar/.toggle/.legend from ../style.css and
   .day-nav/.nav-btn/.day-label/.day-progress from ../inspect/inspect.css. */

.stocks-main {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  background: #ffffff;
  padding: 8px;
}

.charts-view {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  gap: 8px;
}

/* NIFTY spot + futures. Fixed share of the height so the 6-up grid below
   keeps a predictable size; collapses to just its header bar. */
.index-band {
  flex: 0 0 50%;
  display: flex; flex-direction: column;
  min-height: 0;
}
.index-band.collapsed { flex: 0 0 auto; }
.index-band.collapsed .index-band-charts { display: none; }

.index-band-head {
  display: flex; align-items: center; gap: 6px;
  flex: none; padding-bottom: 4px;
}
.index-band-title {
  font-size: 11px; font-weight: 600; color: #787b86;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.band-toggle {
  background: #ffffff; color: #4a4d57;
  border: 1px solid #d1d4dc; border-radius: 3px;
  width: 20px; height: 18px; line-height: 1;
  cursor: pointer; font-size: 10px; padding: 0;
}
.band-toggle:hover { background: #f0f3fa; }
.index-band.collapsed .band-toggle { transform: rotate(-90deg); }

.index-band-charts {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stock-grid {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
  gap: 8px;
}

/* Below ~1100px three charts side by side stop being readable; fall back
   to 2 columns, then 1, and let the page scroll rather than crush cells. */
@media (max-width: 1100px) {
  .index-band { flex: 0 0 auto; }
  .index-band-charts { grid-template-rows: minmax(280px, 1fr); }
  .stock-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(300px, 1fr));
  }
  .stocks-main { overflow-y: auto; }
}
@media (max-width: 700px) {
  .index-band-charts { grid-template-columns: minmax(0, 1fr); }
  .stock-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(3, minmax(280px, 1fr));
  }
}

.stock-cell {
  position: relative;
  border: 1px solid #e1e3eb;
  border-radius: 4px;
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  overflow: hidden;
}

.stock-cell-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: 4px 6px;
  background: #fafbfc;
  border-bottom: 1px solid #e1e3eb;
  flex: none;
}
.stock-cell-label {
  font-size: 12px; font-weight: 600; color: #131722;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stock-cell-meta {
  font-size: 11px; color: #787b86;
  font-family: ui-monospace, monospace;
  white-space: nowrap;
}
.stock-cell-meta.up { color: #0a8f6d; }
.stock-cell-meta.down { color: #d9403a; }

.stock-chart {
  flex: 1; min-height: 0;
  position: relative;
}

/* Shown instead of the chart when a symbol has no session on the
   selected date (TMCV listed 2025-11-12, later than the rest). */
.stock-nodata {
  position: absolute; inset: 0;
  display: none; align-items: center; justify-content: center;
  background: #ffffff; color: #a3a6af;
  font-size: 12px; text-align: center; padding: 12px;
}
.stock-cell.nodata .stock-nodata { display: flex; }

.status.error { color: #d9403a; }
.status.busy { color: #2962ff; }

/* --- PnL view: replaces the chart area entirely --- */
.pnl-view {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 4px 2px;
}

.pnl-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px; margin-bottom: 12px;
}
.pnl-tile {
  border: 1px solid #e1e3eb; border-radius: 4px;
  background: #fafbfc; padding: 8px 10px;
}
.pnl-tile-label {
  font-size: 11px; color: #787b86; text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pnl-tile-value {
  font-size: 19px; font-weight: 600;
  font-family: ui-monospace, monospace; margin-top: 2px;
}
.pnl-pos { color: #0a8f6d; }
.pnl-neg { color: #d9403a; }
.pnl-flat { color: #4a4d57; }

.pnl-section-title {
  font-size: 12px; font-weight: 600; color: #131722;
  margin: 14px 0 6px;
}
.pnl-source {
  font-size: 11px; color: #787b86; font-weight: 400;
  margin-left: 8px;
}

.pnl-table-wrap { overflow-x: auto; }
.pnl-table {
  width: 100%; border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.pnl-table th, .pnl-table td {
  padding: 4px 8px; text-align: right;
  border-bottom: 1px solid #f0f3fa; white-space: nowrap;
}
.pnl-table th {
  color: #787b86; font-weight: 600; text-align: right;
  border-bottom: 1px solid #e1e3eb;
}
.pnl-table th:first-child, .pnl-table td:first-child { text-align: left; }
.pnl-table tbody tr:hover { background: #fafbfc; }
.pnl-num { font-family: ui-monospace, monospace; }
.pnl-tag {
  display: inline-block; font-size: 10px; padding: 0 5px;
  border-radius: 8px; background: #f0f3fa; color: #4a4d57;
}

.pnl-empty {
  margin: 48px auto; max-width: 520px; text-align: center; color: #787b86;
}
.pnl-empty strong { color: #131722; display: block; margin-bottom: 6px; }
.pnl-empty code {
  background: #f5f7fa; border: 1px solid #e1e3eb;
  padding: 1px 4px; border-radius: 3px;
}

#toggle-pnl.active { background: #2962ff; color: #ffffff; border-color: #2962ff; }
