/**
 * Shared chrome for Paper Trading: Hub, Chart (/game?mode=invest), Portfolio.
 * One header height, one stats strip shape — switching tabs should feel seamless.
 */

.pt-appbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 56px;
  min-height: 56px;
  max-height: 56px;
  padding: 0 16px;
  display: grid;
  /* Fixed right columns so Chart ↔ Portfolio tabs/stats/auth never shift */
  grid-template-columns: 220px 1fr 252px 384px 172px;
  align-items: center;
  gap: 0 12px;
  background: #ffffff;
  border-bottom: 1px solid #e4e8ee;
  box-sizing: border-box;
  overflow: hidden;
  flex-shrink: 0;
}

/* Chart page uses #stickyHud — same grid as .pt-appbar */
body.invest-mode #stickyHud {
  display: grid !important;
  grid-template-columns: 220px 1fr 252px 384px 172px !important;
  gap: 0 12px !important;
  height: 56px !important;
  min-height: 56px !important;
  max-height: 56px !important;
  padding: 0 16px !important;
  align-items: center !important;
  background: #ffffff !important;
  border-bottom: 1px solid #e4e8ee !important;
  overflow: hidden !important;
}

.pt-appbar-left {
  grid-column: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  min-width: 0;
  overflow: hidden;
}

.pt-appbar-center {
  grid-column: 2;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
}

.pt-nav-slot {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
}

.pt-stats-slot {
  grid-column: 4;
  justify-self: end;
  display: flex;
  align-items: center;
  width: 384px;
  max-width: 384px;
  min-width: 384px;
  flex-shrink: 0;
}

.pt-auth-slot {
  grid-column: 5;
  justify-self: end;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  width: 172px;
  max-width: 172px;
  min-width: 172px;
  flex-shrink: 0;
  padding-left: 12px;
  border-left: 1px solid #e4e8ee;
  box-sizing: border-box;
}

.pt-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #1a1f29;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.pt-brand-mark {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: #117a37;
  flex-shrink: 0;
}

.pt-back {
  font-size: 12px;
  font-weight: 600;
  color: #6b7480;
  text-decoration: none;
  border: 1px solid #d6dce4;
  border-radius: 6px;
  padding: 5px 11px;
  white-space: nowrap;
  line-height: 1.2;
}

.pt-back:hover { color: #1a1f29; border-color: #15569e; }

.pt-view-nav {
  display: inline-flex;
  border: 1px solid #d6dce4;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  height: 34px;
}

.pt-view-tab {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  height: 34px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  color: #15569e;
  background: #fff;
  border: none;
  border-right: 1px solid #d6dce4;
  font-family: inherit;
  white-space: nowrap;
  line-height: 1;
  box-sizing: border-box;
}

.pt-view-tab:last-child { border-right: none; }

.pt-view-tab.active {
  background: #eef4fb;
  color: #0f3d72;
  pointer-events: none;
}

.pt-view-tab:not(.active):hover { background: #f7f9fb; }

/* Three equal stat pills — Chart + Portfolio use identical markup */
.pt-stats {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 6px;
  width: 384px;
  height: 40px;
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
  box-sizing: border-box;
  flex-shrink: 0;
}

.pt-stat-pill {
  width: 124px;
  min-width: 124px;
  max-width: 124px;
  height: 40px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 2px;
  padding: 5px 10px;
  background: #f7f9fb;
  border: 1px solid #e3e8ee;
  border-radius: 6px;
  flex-shrink: 0;
}

.pt-stat-pill .pt-stat-k {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b7480;
  line-height: 1;
}

.pt-stat-pill .pt-stat-v {
  font-size: 11px;
  font-weight: 700;
  color: #1a1f29;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pt-stat-pill--pnl.pt-stat-pill--up .pt-stat-v { color: #117a37; }
.pt-stat-pill--pnl.pt-stat-pill--down .pt-stat-v { color: #b4232a; }
.pt-stat-pill .pt-stat-v.pos { color: #117a37; }
.pt-stat-pill .pt-stat-v.neg { color: #b4232a; }

/* Legacy single-strip stats (hub etc.) */
.hud-pnl-equity.pt-stats-compact {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: none;
  flex-shrink: 0;
  min-width: 0;
  box-sizing: border-box;
}

.pt-stat,
.hud-pnl-equity.pt-stats-compact .hud-stat-line {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  align-items: flex-start;
  white-space: nowrap;
  min-width: 0;
}

.pt-stat-k,
.hud-pnl-equity.pt-stats-compact .hud-stat-lbl {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b7480;
  line-height: 1;
  font-family: 'Inter', sans-serif;
}

.pt-stat-v,
.hud-pnl-equity.pt-stats-compact .hud-equity,
.hud-pnl-equity.pt-stats-compact .hud-pnl-val,
.hud-pnl-equity.pt-stats-compact .hud-cash-val {
  font-size: 13px;
  font-weight: 700;
  color: #1a1f29;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  font-family: 'Inter', sans-serif;
}

.pt-stat-v.pos,
.hud-pnl-equity.pt-stats-compact .hud-stat-line--pnl.hud-pnl-up .hud-pnl-val { color: #117a37; }

.pt-stat-v.neg,
.hud-pnl-equity.pt-stats-compact .hud-stat-line--pnl.hud-pnl-down .hud-pnl-val { color: #b4232a; }

[data-sim-header-auth] {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-shrink: 1;
}

body.paper-trading .sim-settings-btn,
body.paper-trading #sim-settings-btn,
body.invest-mode .sim-settings-btn,
body.invest-mode #sim-settings-btn {
  color: #1a1f29 !important;
  border: 1px solid #c5cdd6 !important;
  background: #ffffff !important;
}

body.paper-trading .sim-settings-btn:hover,
body.paper-trading #sim-settings-btn:hover,
body.invest-mode .sim-settings-btn:hover,
body.invest-mode #sim-settings-btn:hover {
  color: #000000 !important;
  background: #eef1f5 !important;
  border-color: #1a1f29 !important;
  transform: none !important;
}

body.paper-trading [data-sim-header-auth] #sim-user-name,
body.invest-mode [data-sim-header-auth] #sim-user-name {
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Page shell — footer pinned to bottom */
.pt-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f4f6f8;
}

.pt-main {
  flex: 1 0 auto;
  width: 100%;
}

.pt-wrap {
  max-width: 1480px;
  margin: 0 auto;
  padding: 22px 24px 32px;
  width: 100%;
  box-sizing: border-box;
}

.pt-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 22px;
  align-items: stretch;
}

.pt-col-main { min-width: 0; }

.pt-col-side {
  position: sticky;
  top: 68px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.pt-lb-panel {
  background: #ffffff;
  border: 1px solid #e4e8ee;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 460px;
}

.pt-lb-head {
  padding: 14px 16px 10px;
  border-bottom: 1px solid #e4e8ee;
  background: #f7f9fb;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.pt-lb-title {
  font-size: 13px;
  font-weight: 700;
  color: #1a1f29;
  margin: 0;
}

.pt-lb-meta {
  font-size: 11px;
  color: #8a93a0;
}

.pt-lb-scroll {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 400px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.pt-lb-fade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 36px;
  background: linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.98));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.pt-lb-fade.show { opacity: 1; }

.pt-lb-panel .lb-table td,
.pt-lb-panel .lb-table th {
  padding-top: 11px;
  padding-bottom: 11px;
}

.pt-footer {
  flex-shrink: 0;
  margin-top: auto;
  width: 100%;
  border-top: 1px solid #e4e8ee;
  background: #ffffff;
  padding: 16px 24px;
  font-size: 11px;
  color: #8a93a0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  box-sizing: border-box;
}

.pt-footer a { color: #6b7480; text-decoration: none; }
.pt-footer a:hover { color: #1a1f29; }

.pt-footer-disc {
  flex: 1;
  min-width: 200px;
  margin: 0;
  line-height: 1.5;
}

@media (max-width: 960px) {
  .pt-layout { grid-template-columns: 1fr; }
  .pt-col-side { position: static; }
  .pt-lb-panel { max-height: none; }
  .pt-lb-scroll { max-height: 360px; }
}

@media (max-width: 900px) {
  .pt-stats,
  .hud-pnl-equity.pt-stats-compact { display: none !important; }
  .pt-appbar {
    padding: 0 12px;
    grid-template-columns: 1fr auto auto;
    gap: 0 8px;
  }
  .pt-appbar-center { display: none; }
  .pt-appbar-left { grid-column: 1; }
  .pt-nav-slot { grid-column: 2; }
  .pt-stats-slot { display: none; }
  .pt-auth-slot { grid-column: 3; min-width: 0; }
}
