/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #253449;
  --bg-row: #1e293b;
  --bg-row-alt: #172033;
  --border: #334155;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-bright: #f8fafc;
  --accent: #3b82f6;
  --accent-dim: #1e40af;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --orange: #f97316;
  --purple: #a855f7;
  --radius: 10px;
  --shadow: 0 4px 12px rgba(0,0,0,0.3);
}

html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* Sticky wrapper keeps both header and nav-tabs pinned together at the top
   on scroll. Hardcoding the nav-tabs top offset would break when the header
   height changes (safe-area inset on PWA, title wrap on narrow viewports). */
.header-stack {
  position: sticky;
  top: 0;
  z-index: 100;
}

/* Header */
.app-header {
  background: linear-gradient(135deg, var(--accent-dim), #1e3a5f);
  /* Top padding adds the iOS notch/status-bar inset on PWA so the title
     doesn't sit underneath "8:15 ⏷ ⏵ 75%". On non-notch devices the env()
     value is 0 and we get the same 16px we always had. */
  padding: calc(16px + env(safe-area-inset-top, 0px)) calc(20px + env(safe-area-inset-right, 0px)) 16px calc(20px + env(safe-area-inset-left, 0px));
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  box-shadow: var(--shadow);
}
.app-header-logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
}
/* Key Dates sidebar: fixed-width column on PC, full-width card on mobile.
   Wide enough to fit the longest label + a "Sep 1, 2026, 4:00 PM"
   value on a single line without wrapping. */
.key-dates-sidebar {
  width: 320px;
  flex-shrink: 0;
}
@media (max-width: 720px) {
  .key-dates-sidebar {
    width: 100%;
    flex-shrink: 1;
    max-width: none;
  }
}
.app-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-bright);
  flex: 1;
}
.app-header h1 a {
  color: inherit;
  text-decoration: none;
}
.app-header h1 a:hover {
  text-decoration: underline;
}
.back-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: var(--text-bright);
  font-size: 1rem;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  display: none;
}
.back-btn:hover { background: rgba(255,255,255,0.25); }
.back-btn.visible { display: inline-flex; }

/* Hamburger menu button — visible only on mobile */
.menu-btn {
  background: rgba(255,255,255,0.12);
  border: none;
  color: var(--text-bright);
  font-size: 1.4rem;
  line-height: 1;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: none;
}
.menu-btn:hover { background: rgba(255,255,255,0.22); }

/* Slide-out nav drawer (mobile) — z-index above the message board (991)
   so it can be opened from the menu icon while the board is showing. */
.nav-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s;
  z-index: 1000;
}
.nav-drawer-backdrop.open {
  opacity: 1;
  visibility: visible;
}
.nav-drawer {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  width: min(260px, 80vw);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 20px rgba(0,0,0,0.45);
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  /* Respect iOS safe area for notched devices */
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-drawer.open { transform: translateX(0); }
.nav-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: linear-gradient(135deg, var(--accent-dim), #1e3a5f);
  color: var(--text-bright);
  font-weight: 700;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.02em;
}
.nav-drawer-header .brand {
  display: flex; align-items: center; gap: 8px;
}
.nav-drawer-header .brand img {
  width: 24px; height: 24px;
  border-radius: 5px;
  display: block;
}
.nav-drawer-close {
  background: rgba(255,255,255,0.12);
  border: none;
  color: var(--text-bright);
  font-size: 1.2rem;
  line-height: 1;
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.nav-drawer-close:hover { background: rgba(255,255,255,0.22); }
.nav-drawer-list {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0;
}
.nav-drawer-item {
  background: none;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  padding: 11px 16px;
  text-align: left;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  position: relative;
  transition: background 0.15s, color 0.15s;
}
.nav-drawer-item:last-child { border-bottom: none; }
.nav-drawer-item:hover { background: rgba(255,255,255,0.04); }
.nav-drawer-item.active {
  color: var(--accent);
  background: rgba(59,130,246,0.10);
  font-weight: 700;
}
/* Right-side accent bar — doesn't shift the text on active like a left
   border would. */
.nav-drawer-item.active::after {
  content: "";
  position: absolute;
  right: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--accent);
  border-radius: 2px 0 0 2px;
}
/* User bar pinned to the bottom of the drawer — visible only on mobile */
.nav-drawer-footer {
  display: none;
  margin-top: auto;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.18);
  flex-direction: column;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text);
}
.nav-drawer-footer .user-name {
  font-weight: 700;
  color: var(--text-bright);
}
.nav-drawer-footer .user-online {
  font-size: 0.78rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-drawer-footer .user-online .dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34,197,94,0.7);
}
.nav-drawer-footer button.signout {
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.18);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
}
.nav-drawer-footer button.signout:hover {
  background: rgba(0,0,0,0.5);
}

/* Nav tabs */
.nav-tabs {
  display: flex;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.nav-tab {
  padding: 12px 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  border-right: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.nav-tab:last-child { border-right: none; }
.nav-tab:hover { color: var(--text); }
.nav-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Draft views: vertical pick list is mobile-only; matrix is desktop. */
.draft-list-mobile { display: none; }

/* Main content */
.main-content { padding: 16px; max-width: 1280px; margin: 0 auto; }
/* Wide views (Minors Draft grid) get extra room. */
.main-content.wide { max-width: 1480px; }

/* Team grid (home view) */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.team-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
}
.team-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.team-card-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 10px;
}
.team-card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.team-stat {
  text-align: center;
}
.team-stat-value {
  font-size: 1.15rem;
  font-weight: 700;
}
.team-stat-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.team-card-roster {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.roster-badge {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 600;
}
.badge-majors { background: rgba(59,130,246,0.2); color: var(--accent); }
.badge-callups { background: rgba(168,85,247,0.2); color: var(--purple); }
.badge-minors { background: rgba(34,197,94,0.2); color: var(--green); }

/* Team detail view */
.team-detail { display: none; }
.team-detail.active { display: block; }

.section-header {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin: 20px 0 10px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-header:first-child { margin-top: 8px; }
.section-count {
  background: var(--accent);
  color: white;
  font-size: 0.7rem;
  padding: 1px 7px;
  border-radius: 10px;
}

/* Player table */
.player-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.player-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--bg);
}
.player-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.player-table tr:nth-child(even) td { background: var(--bg-row-alt); }
.player-table tr:hover td { background: var(--bg-card-hover); }
.player-name {
  font-weight: 600;
  color: var(--text-bright);
}
.player-price {
  font-weight: 700;
  color: var(--green);
}
.player-year {
  color: var(--text-dim);
}
.contract-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.3px;
}
.contract-final { background: rgba(239,68,68,0.2); color: var(--red); }
.contract-mid { background: rgba(234,179,8,0.2); color: var(--yellow); }
.contract-new { background: rgba(34,197,94,0.2); color: var(--green); }
.contract-expiring { background: rgba(249,115,22,0.2); color: var(--orange); }
.from-minors-tag {
  font-size: 0.65rem;
  background: rgba(168,85,247,0.2);
  color: var(--purple);
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
  font-weight: 600;
}
/* AB/IP color tiers:
   - stat-warning  (orange) — past §3(c) send-down boundary (200 AB / 50 IP)
   - stat-must-call-up (red) — past §3(f) must-call-up trigger (300 AB / 75 IP) */
.stat-warning {
  color: var(--orange);
  font-weight: 700;
}
.stat-must-call-up {
  color: var(--red);
  font-weight: 700;
}
.stat-caution {
  color: var(--yellow);
  font-weight: 600;
}

/* Summary bar */
.summary-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}
.summary-item { text-align: center; }
.summary-value {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-bright);
}
.summary-label {
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* League overview tab */
.league-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.league-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  padding: 10px;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  cursor: pointer;
}
.league-table th:hover { color: var(--text); }
.league-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
}
.league-table tr:hover td { background: var(--bg-card-hover); }
.league-table .team-link {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.league-table .team-link:hover { text-decoration: underline; }

/* Keeper calculator view */
.calc-team-selector {
  margin-bottom: 16px;
}
.calc-team-selector select {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.95rem;
  width: 100%;
  cursor: pointer;
}
.calc-team-selector select:focus {
  outline: none;
  border-color: var(--accent);
}
.keeper-projection {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.keeper-projection h3 {
  font-size: 0.9rem;
  margin-bottom: 10px;
  color: var(--text-bright);
}

/* Trade UI */
.trade-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.trade-btn:hover { background: var(--accent-dim); }
.trade-btn-submit { background: var(--green); }
.trade-btn-submit:hover { background: #16a34a; }
.trade-btn-cancel { background: var(--border); color: var(--text); }
.trade-btn-cancel:hover { background: #475569; }
.trade-select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.88rem;
  width: 100%;
  cursor: pointer;
}
.trade-select:focus { outline: none; border-color: var(--accent); }

/* Responsive */
@media (max-width: 600px) {
  html { font-size: 14px; }
  .main-content { padding: 10px; }
  .team-grid { grid-template-columns: 1fr; }
  .summary-bar { padding: 10px; }
  .summary-value { font-size: 1.05rem; }
  .player-table { font-size: 0.78rem; }
  .player-table td, .player-table th { padding: 4px 5px; }
  .player-table { font-size: 0.74rem; }
  /* Mobile: hide the horizontal tab row, show the hamburger menu instead. */
  .nav-tabs { display: none; }
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  /* Hide the in-header user bar on mobile — it's rendered at the bottom of
     the drawer instead so it doesn't crowd the title row. */
  #user-bar { display: none !important; }
  .nav-drawer-footer { display: flex; }

  /* iOS Safari auto-zooms when a focused input has font-size < 16px. Force
     all interactive form fields to ≥16px on mobile so the page never shifts
     under the user when they tap a field. */
  input, textarea, select {
    font-size: 16px !important;
  }

  /* Minors-draft: swap the wide matrix for a one-pick-per-row vertical list. */
  .draft-board-desktop { display: none; }
  .draft-list-mobile { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 16px; }
  .draft-pick-row {
    display: grid;
    grid-template-columns: 38px minmax(0, 80px) 1fr;
    gap: 8px;
    align-items: center;
    padding: 8px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.82rem;
    line-height: 1.25;
  }
  .draft-pick-row.current { background: rgba(59,130,246,0.15); border-color: var(--accent); }
  .draft-pick-row.made { background: rgba(34,197,94,0.06); }
  .draft-pick-row.passed { background: rgba(249,115,22,0.08); }
  .draft-pick-row .pick-id { font-weight: 700; color: var(--accent); font-size: 0.78rem; }
  .draft-pick-row .pick-team { color: var(--text-bright); font-size: 0.75rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .draft-pick-row .pick-traded { color: var(--orange); font-size: 0.65rem; font-weight: 700; }
  .draft-pick-row .pick-content { color: var(--text); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .draft-pick-row .pick-player { font-weight: 600; }
  .draft-pick-row .pick-notes { color: var(--text-dim); font-size: 0.68rem; }
  .draft-pick-row .pick-status { color: var(--text-dim); font-style: italic; }
  .draft-pick-row .pick-status.passed { color: var(--orange); font-style: normal; font-weight: 700; font-size: 0.72rem; }
  .draft-pick-row .pick-status.current { color: var(--accent); }

  /* Tables: fit the viewport; let player names wrap so we don't need to
     scroll horizontally. Numeric / short cells stay nowrap. */
  .player-table {
    width: 100%;
    table-layout: auto;     /* let numeric cols shrink to content */
    border-collapse: collapse;
  }
  .player-table th, .player-table td {
    padding: 5px 4px;
  }
  /* Player-name cell wraps at word boundaries (spaces). overflow-wrap
     handles the rare case of an unbroken string longer than the column;
     but word-break:normal stops the mid-word breaks that turned
     "Fernando Tatis Jr." into "Fernand"/"o Tatis"/"Jr." */
  .player-table .player-name {
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    hyphens: none;
    -webkit-hyphens: none;
    line-height: 1.25;
  }
  /* Numeric / short columns stay tight on a single line, hugging their
     content so the Player column gets the remaining width. Skipped on
     mobile-stack-table because those cells are display:flex rows where
     width:1% would collapse the whole row to 3px. */
  .player-table:not(.mobile-stack-table) .player-year,
  .player-table:not(.mobile-stack-table) .player-price,
  .player-table:not(.mobile-stack-table) td.stat-warning,
  .player-table:not(.mobile-stack-table) td.stat-caution {
    white-space: nowrap;
    width: 1%;
  }

  /* Select Keepers tables: hide Source (col 2) and CURRENT-SEASON $ (col 3)
     on mobile so Player, NEXT $, Expiry, Rule 5, Keep, Block have room. */
  .eligible-keepers-table tr > *:nth-child(2),
  .eligible-keepers-table tr > *:nth-child(3) {
    display: none;
  }
  /* Eligible Keepers: explicit narrow widths on the trailing 5 columns so
     Player gets every leftover pixel. Padding tightened on the 3 checkbox
     cols since the checkbox itself is only ~16px and they're center-aligned. */
  .eligible-keepers-table { table-layout: fixed; }
  .eligible-keepers-table tr > *:nth-child(1) { width: auto; }          /* Player */
  .eligible-keepers-table tr > *:nth-child(4) { width: 44px; white-space: nowrap; }   /* Next $ */
  .eligible-keepers-table tr > *:nth-child(5) { width: 48px; white-space: nowrap; }   /* Expiry */
  .eligible-keepers-table tr > *:nth-child(6),
  .eligible-keepers-table tr > *:nth-child(7) { width: 34px; padding: 5px 2px; }      /* Rule 5 / Keep */
  .eligible-keepers-table tr > *:nth-child(8) { width: 42px; padding: 5px 2px; }      /* On the Block */

  /* Status badges (e.g. "2027 Must Call Up", "Called up") that crowd the
     player-name cell on phone screens. Still rendered on desktop. */
  .hide-on-mobile { display: none !important; }

  /* Two-column inline grids (trade form, composer, thread detail's
     "You get / You give") stack vertically. The attribute selector matches
     the literal substring used in the rendered inline styles. */
  [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  /* Trade card swap (Team1 receives | arrow | Team2 receives) — stack. */
  [style*="grid-template-columns:1fr auto 1fr"] {
    grid-template-columns: 1fr !important;
  }
  /* The Trade Inbox card's two-col "you get / you give" preview also stacks. */
  [style*="grid-template-columns:1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Modals: tighter padding so content has room, plus iOS notch / status-bar
     inset on top so the modal close (×) isn't hidden underneath. */
  #thread-detail-modal,
  #proposal-composer-modal,
  #commish-editor-modal,
  #pick-editor-modal,
  #trophy-detail-modal,
  #manager-history-modal {
    padding-top: calc(12px + env(safe-area-inset-top, 0px)) !important;
    padding-right: 8px !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    padding-left: 8px !important;
  }

  /* Message Board on mobile: full-width but anchored below the app header
     so the hamburger menu icon stays visible/tappable while the panel is
     open. */
  #msgboard-panel {
    top: var(--header-stack-height, 60px) !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: auto !important;
    max-width: none !important;
    border-radius: 0 !important;
    border: none !important;
  }

  /* Notification preference tables (Settings page): collapse the dense
     6-column grid into one card per event. The thead is hidden; each
     <td> displays its data-label inline next to the radio/checkbox. */
  .mobile-stack-table { display: block !important; max-width: none !important; }
  .mobile-stack-table thead { display: none !important; }
  .mobile-stack-table colgroup { display: none !important; }
  .mobile-stack-table tbody { display: block !important; }
  .mobile-stack-table tr {
    display: block !important;
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    margin-bottom: 10px !important;
    padding: 10px 12px !important;
    background: var(--bg) !important;
  }
  .mobile-stack-table tr:nth-child(even) td,
  .mobile-stack-table tr:hover td { background: transparent !important; }
  .mobile-stack-table td { display: block !important; padding: 0 !important; border: none !important; }
  .mobile-stack-table td.notif-row-label {
    font-weight: 700 !important;
    color: var(--text-bright) !important;
    font-size: 0.95rem !important;
    text-align: left !important;
    padding-bottom: 8px !important;
    margin-bottom: 8px !important;
    border-bottom: 1px solid var(--border) !important;
  }
  .mobile-stack-table td:not(.notif-row-label) {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 6px 0 !important;
  }
  .mobile-stack-table td:not(.notif-row-label)::before {
    content: attr(data-label);
    color: var(--text-dim);
    font-size: 0.84rem;
  }
  .mobile-stack-table td.notif-na { display: none !important; }
  .mobile-stack-table tfoot { display: none !important; }
  .mobile-stack-table .mobile-stack-table-wrap, .mobile-stack-table-wrap { overflow: visible !important; }
}

/* Sub-tab buttons (e.g. inside Trades) */
.trades-subnav-btn.active {
  color: var(--accent) !important;
  border-bottom-color: var(--accent) !important;
}
.trades-subnav-btn:hover { color: var(--text); }

/* View transitions */
.view { display: none; }
.view.active { display: block; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ============================================================
   THEME: ESPN-style (v2) — opt-in via Settings → Appearance.
   Two variants share the same ESPN-red accent + black header but
   swap surface colors. <body class="theme-v2"> = light;
   <body class="theme-v2-dark"> = dark. The structural rules
   below target both via grouped selectors; only the variable
   blocks differ.
   ============================================================ */
body.theme-v2 {
  /* Surfaces (light) */
  --bg:             #f4f5f7;
  --bg-card:        #ffffff;
  --bg-card-hover:  #f9fafb;
  --bg-row:         #ffffff;
  --bg-row-alt:     #fafbfc;
  /* Borders + text */
  --border:         #e2e8f0;
  --text:           #1a202c;
  --text-dim:       #718096;
  --text-bright:    #0f172a;
  /* Brand (ESPN red) replaces the legacy blue accent everywhere */
  --accent:         #d50a0a;
  --accent-dim:     #a40808;
  /* Status colors — slightly muted so they read against white */
  --green:          #16a34a;
  --yellow:         #d97706;
  --red:            #dc2626;
  --orange:         #ea580c;
  --purple:         #7c3aed;
  --shadow:         0 1px 3px rgba(15,23,42,0.08), 0 0 0 1px rgba(15,23,42,0.04);
}
body.theme-v2-dark {
  /* Surfaces (dark) — slightly cooler than legacy navy */
  --bg:             #0f172a;
  --bg-card:        #1e293b;
  --bg-card-hover:  #2a3a52;
  --bg-row:         #1e293b;
  --bg-row-alt:     #1a2436;
  /* Borders + text */
  --border:         #334155;
  --text:           #e2e8f0;
  --text-dim:       #94a3b8;
  --text-bright:    #f8fafc;
  /* Same ESPN red as the light variant */
  --accent:         #d50a0a;
  --accent-dim:     #a40808;
  /* Status colors — keep punchy on dark */
  --green:          #22c55e;
  --yellow:         #eab308;
  --red:            #ef4444;
  --orange:         #f97316;
  --purple:         #a855f7;
  --shadow:         0 4px 12px rgba(0,0,0,0.45);
}

/* Header: replace the blue gradient with the v2 black bar + red underline. */
body.theme-v2 .app-header,
body.theme-v2-dark .app-header {
  background: linear-gradient(180deg, #1a1d22 0%, #0e1115 100%);
  border-bottom: 4px solid var(--accent);
  box-shadow: none;
}
body.theme-v2 .app-header h1, body.theme-v2 .app-header h1 a,
body.theme-v2-dark .app-header h1, body.theme-v2-dark .app-header h1 a { color: #ffffff; }
body.theme-v2 .menu-btn,
body.theme-v2-dark .menu-btn {
  background: rgba(255,255,255,0.10);
  color: #ffffff;
}
body.theme-v2 .menu-btn:hover,
body.theme-v2-dark .menu-btn:hover { background: rgba(255,255,255,0.18); }

/* Nav tabs */
body.theme-v2 .nav-tabs,
body.theme-v2-dark .nav-tabs {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
body.theme-v2 .nav-tab,
body.theme-v2-dark .nav-tab {
  background: transparent;
  color: var(--text-dim);
  border-right: none;
  border-bottom: 3px solid transparent;
  font-weight: 600;
}
body.theme-v2 .nav-tab:hover,
body.theme-v2-dark .nav-tab:hover {
  color: var(--text);
  background: var(--bg-card-hover);
}
body.theme-v2 .nav-tab.active,
body.theme-v2-dark .nav-tab.active {
  color: var(--accent);
  background: transparent;
  border-bottom-color: var(--accent);
}

/* Buttons: keep submit-green / cancel-gray semantics, the default
   .trade-btn picks up the new red accent automatically. */
body.theme-v2 .trade-btn-cancel,
body.theme-v2-dark .trade-btn-cancel {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}
body.theme-v2 .trade-btn-cancel:hover,
body.theme-v2-dark .trade-btn-cancel:hover { background: var(--bg-card-hover); }

/* Cards / section headers */
body.theme-v2 .keeper-projection, body.theme-v2 .summary-bar,
body.theme-v2-dark .keeper-projection, body.theme-v2-dark .summary-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
body.theme-v2 .section-header,
body.theme-v2-dark .section-header {
  background: var(--bg-row-alt);
  border-left: 3px solid var(--accent);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  margin-top: 16px;
}

/* Tables */
body.theme-v2 .player-table,
body.theme-v2-dark .player-table {
  background: var(--bg-card);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
body.theme-v2 .player-table th,
body.theme-v2-dark .player-table th {
  background: var(--bg-card);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.7rem;
  color: var(--text-dim);
}
/* Red-tinted row hover — different opacity per variant so the red is
   subtle on white but readable on dark surface. */
body.theme-v2 .player-table tr:hover td { background: rgba(213,10,10,0.08); }
body.theme-v2-dark .player-table tr:hover td { background: rgba(213,10,10,0.18); }

/* Mobile nav drawer (opens via ☰) */
body.theme-v2 .nav-drawer-header,
body.theme-v2-dark .nav-drawer-header {
  background: linear-gradient(180deg, #1a1d22 0%, #0e1115 100%);
}
body.theme-v2 .nav-drawer-item.active,
body.theme-v2-dark .nav-drawer-item.active {
  color: var(--accent);
  background: rgba(213,10,10,0.10);
}
body.theme-v2 .nav-drawer-item.active::after,
body.theme-v2-dark .nav-drawer-item.active::after { background: var(--accent); }

/* Inputs / selects */
body.theme-v2 input, body.theme-v2 select, body.theme-v2 textarea,
body.theme-v2-dark input, body.theme-v2-dark select, body.theme-v2-dark textarea {
  background: var(--bg-card);
  color: var(--text);
  border-color: var(--border);
}
