/* Baseball-Reference-style emulation: light theme, dark navy masthead, dense
   bordered stat tables with gray sticky headers, blue links, yellow row hover. */
:root {
  color-scheme: light;
  --bg: #ebecee;
  --panel: #ffffff;
  --ink: #16191c;
  --muted: #5c6670;
  --line: #ccd1d7;
  --line-strong: #b3b9c0;
  --navy: #13294b;        /* masthead + table headers */
  --navy-2: #1d3a64;
  --link: #0b53a8;
  --red: #9d2235;         /* B-Ref accent */
  --th: #e7e9ec;
  --stripe: #f5f6f7;
  --hover: #fff3bf;       /* signature yellow hover */
  --me: #fff0c2;          /* highlight user's club */
  --gold: #8a6d00;
  font-family: Helvetica, Arial, "Helvetica Neue", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); min-height: 100vh; font-size: 14px; line-height: 1.4; }
a { color: var(--link); }

/* ---- masthead ---- */
.hero { display: flex; justify-content: space-between; gap: 1rem; padding: .85rem 1.25rem; align-items: center; background: var(--navy); color: #fff; border-bottom: 3px solid var(--red); }
h1 { margin: 0; font-size: clamp(1.4rem, 3vw, 2.1rem); letter-spacing: -0.01em; color: #fff; font-weight: 800; }
h2, h3, h4 { margin-top: 0; color: var(--navy); }
.subhead { color: var(--muted); max-width: 900px; font-size: .82rem; }
.hero .subhead { color: #c7d2e0; }
.eyebrow { color: #9fc1ef; text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.66rem; font-weight: 800; margin: 0 0 .15rem; }
.status-card { background: #fff; color: var(--ink); border: 1px solid var(--line); padding: .7rem; border-radius: 4px; min-width: 260px; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.status-card strong { color: var(--navy); }

main { width: min(1500px, calc(100% - 1.5rem)); margin: 1rem auto 3rem; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: .9rem; box-shadow: 0 1px 2px rgba(0,0,0,.06); }

.import-panel, .toolbar, .section-head { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.toolbar.panel { background: var(--navy-2); border-color: var(--navy); }
.toolbar.panel label { color: #cfdaea; }
details.import-panel { display: block; }
details.import-panel > summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; cursor: pointer; list-style: none; }
details.import-panel > summary::-webkit-details-marker { display: none; }
details.import-panel > summary h2 { margin: 0; }
details.import-panel > summary::after { content: "Open ▸"; color: var(--link); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
details.import-panel[open] > summary::after { content: "Close ▾"; }
details.import-panel[open] > summary { margin-bottom: 1rem; }

.form-grid, .sim-buttons, .gm-box { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; }
.search-box label { width: 100%; }
label { color: var(--muted); font-size: .78rem; display: grid; gap: .25rem; font-weight: 600; }
input, select, button { border: 1px solid var(--line-strong); background: #fff; color: var(--ink); border-radius: 3px; padding: .45rem .55rem; font-size: .85rem; font-family: inherit; }
input[type="file"] { max-width: 360px; }
select { max-width: 520px; }
.order-list { display: grid; gap: .4rem; margin-bottom: .8rem; }
.order-list label { grid-template-columns: 4.5rem minmax(0, 1fr); align-items: center; }
.order-list select { max-width: 100%; width: 100%; }
.lineup-row, .pitching-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem; align-items: center; }
.lineup-row label { margin: 0; }
.lineup-player { display: flex; align-items: center; gap: .55rem; min-height: 2.3rem; padding: .35rem .6rem; border: 1px solid var(--line); border-radius: 3px; background: var(--stripe); font-size: .8rem; }
.lineup-player strong { font-weight: 600; color: var(--ink); }
.lineup-rank { color: var(--muted); font-weight: 800; min-width: 1.7rem; }
.pitching-row .lineup-rank { min-width: 3.1rem; }
.lineup-move, .pitching-move { display: inline-flex; gap: .3rem; }
.lineup-move button, .pitching-move button { width: 2.3rem; min-height: 2.3rem; padding: 0; border: 1px solid var(--line-strong); background: #fff; font-size: 1rem; line-height: 1; color: var(--navy); }

/* ---- buttons: B-Ref small gray/blue ---- */
button { cursor: pointer; background: #f0f1f3; border: 1px solid var(--line-strong); font-weight: 700; color: var(--link); }
button:hover { background: #e3e6ea; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
button.primary:hover { background: var(--navy-2); }
button.link { background: none; border: 0; color: var(--link); font-weight: 700; padding: .2rem .35rem; text-decoration: underline; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 1px; }

/* ---- tabs / section nav ---- */
.tabs { display: flex; gap: .25rem; margin: .75rem 0; flex-wrap: wrap; position: sticky; top: 0; z-index: 20; padding: .4rem 0; background: var(--bg); border-bottom: 2px solid var(--navy); }
.tabs button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; background: #fff; border: 1px solid var(--line-strong); border-bottom: 0; border-radius: 4px 4px 0 0; color: var(--navy); padding: .45rem .7rem; font-size: .82rem; }
.tabs button .tab-ico { font-size: 1rem; line-height: 1; }
.tabs button.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.tab { display: none; }
.tab.active { display: block; }

.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: minmax(0, 1.1fr) minmax(340px, .9fr); }
.messages { margin: .6rem 0; }
.message { padding: .55rem .8rem; border-radius: 3px; background: #eef4ff; border: 1px solid #bcd0ee; color: #234; font-size: .85rem; }
.message.error { background: #fdecec; border-color: #e4a9a9; color: #7a1f1f; }

/* ---- tables (the B-Ref signature) ---- */
.table-wrap { overflow: auto; max-height: 680px; border: 1px solid var(--line-strong); border-radius: 3px; background: #fff; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
table { width: 100%; border-collapse: collapse; font-size: .8rem; }
th, td { padding: .3rem .5rem; border-bottom: 1px solid #e4e6e9; white-space: nowrap; text-align: right; }
th:first-child, td:first-child, td.name, th.name { text-align: left; position: sticky; left: 0; background: #fff; z-index: 1; font-weight: 600; }
td.name { color: var(--link); }
th { position: sticky; top: 0; background: var(--th); z-index: 2; color: var(--navy); font-weight: 800; border-bottom: 2px solid var(--line-strong); }
th:first-child, th.name { background: var(--th); }
tbody tr:nth-child(even) td { background: var(--stripe); }
tbody tr:nth-child(even) td:first-child { background: #eef0f2; }
tr:hover td, tr:hover td:first-child { background: var(--hover) !important; }
td.rank, th.rank { width: 2.2rem; color: var(--muted); }

/* highlight the user's club */
tr.me td { background: var(--me); font-weight: 700; }
tr.me td:first-child { background: #ffe9a8; box-shadow: inset 3px 0 0 var(--red); }

.table-wrap::-webkit-scrollbar { height: 10px; width: 10px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }

/* ---- bits ---- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .45rem; border-radius: 3px; background: #eef0f2; color: var(--muted); border: 1px solid var(--line); font-size: .72rem; font-weight: 700; }
.count { display: inline-block; font-size: .68rem; font-weight: 800; color: var(--navy); background: #e7edf6; border: 1px solid #c2d2e8; padding: .05rem .45rem; border-radius: 3px; vertical-align: middle; }
h3 .count { margin-left: .2rem; }
p.count { margin: 0 0 .5rem; }
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; margin-top: .6rem; }
.kpi { background: #f7f8f9; border: 1px solid var(--line); border-radius: 3px; padding: .55rem .6rem; }
.kpi span { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.kpi strong { display: block; font-size: 1.15rem; color: var(--navy); }
.news-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .35rem; }
.news-list li { padding: .4rem .55rem; background: #f7f8f9; border: 1px solid var(--line); border-radius: 3px; color: var(--ink); font-size: .82rem; }
.staff-card { padding: .5rem .6rem; border: 1px solid var(--line); background: #f7f8f9; border-radius: 3px; margin-bottom: .45rem; }
.staff-card strong { color: var(--navy); }
.score { font-weight: 800; color: var(--red); }

/* section headers + grouped GM cards */
.panel > h2 { display: flex; align-items: center; gap: .5rem; font-size: 1.05rem; border-bottom: 2px solid var(--navy); padding-bottom: .35rem; margin-bottom: .7rem; }
.section-head h2 { border: 0; padding: 0; margin: 0; }
.panel h3 { margin-top: 1.1rem; font-size: .95rem; }
.panel h4 { margin: .6rem 0 .35rem; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.gm-box { background: #f7f8f9; border: 1px solid var(--line); border-radius: 3px; padding: .65rem; margin-bottom: .6rem; }
#leaders h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1rem 0 .4rem; border-bottom: 1px solid var(--line); padding-bottom: .25rem; }
#leaders h3:first-child { margin-top: 0; }

footer { color: var(--muted); text-align: center; padding: 1.5rem; font-size: .78rem; }

@media (max-width: 900px) {
  .hero, .import-panel, .toolbar, .section-head { align-items: stretch; flex-direction: column; }
  .grid.two { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  body { padding-bottom: 4.75rem; }
  .hero { padding: 1rem; gap: .4rem; }
  .status-card { min-width: 0; width: 100%; }
  main { width: calc(100% - 1rem); margin: .75rem auto 1.5rem; }
  .panel { padding: .7rem; }
  .form-grid, .gm-box { gap: .5rem; }
  .form-grid > label, .gm-box > label { width: 100%; }
  input, select, button { width: 100%; max-width: none; min-height: 2.8rem; font-size: 1rem; }
  .lineup-row, .pitching-row { grid-template-columns: minmax(0, 1fr) 6.2rem; }
  .lineup-move button, .pitching-move button { width: 2.8rem; min-height: 2.8rem; }
  .sim-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
  .table-wrap { max-height: 70vh; -webkit-overflow-scrolling: touch; }
  th, td { padding: .35rem .45rem; }

  /* fixed bottom tab bar for one-thumb navigation */
  .tabs {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0;
    margin: 0; padding: .25rem .2rem calc(.25rem + env(safe-area-inset-bottom, 0px));
    gap: .15rem; flex-wrap: nowrap; border: 0; border-top: 2px solid var(--navy);
    background: #fff; box-shadow: 0 -4px 16px rgba(0,0,0,.12); z-index: 50;
  }
  .tabs button {
    flex: 1; flex-direction: column; gap: .1rem; padding: .35rem .1rem; min-height: 0;
    border: 0; border-radius: 4px; background: #fff; color: var(--muted); font-size: .56rem; font-weight: 700;
  }
  .tabs button .tab-ico { font-size: 1.15rem; }
  .tabs button.active { background: #fff; color: var(--navy); }
}
