:root {
  --navy: #132257;
  --navy-dark: #0b1638;
  --white: #ffffff;
  --grey-bg: #f4f5f8;
  --grey-line: #dde1ea;
  --text: #1b1f2a;
  --muted: #6b7280;

  --undecided: #9ca3af;
  --going: #16a34a;
  --not_going: #dc2626;
  --for_sale: #d97706;
  --ticket_exchange: #0e7490;
  --sold: #132257;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--grey-bg);
  color: var(--text);
}

/* Login gate */
.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--navy), var(--navy-dark));
  padding: 16px;
}
.gate-card {
  background: var(--white);
  border-radius: 16px;
  padding: 32px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.gate-badge { display: block; height: 110px; width: auto; margin: 0 auto 12px; }
.gate-card h1 { margin: 0 0 4px; color: var(--navy); }
.gate-card p { margin: 0 0 20px; color: var(--muted); }
.gate-card input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--grey-line);
  font-size: 16px;
  margin-bottom: 12px;
}
.gate-card button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--navy);
  color: var(--white);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.gate-card button:hover { background: var(--navy-dark); }
.error { color: var(--not_going); font-size: 14px; margin-top: 10px; }

/* App shell */
.topbar {
  background: var(--navy);
  color: var(--white);
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; }
.crest { flex-shrink: 0; height: 48px; width: auto; }
.brand h1 { margin: 0; font-size: 20px; }
.brand .subtitle { margin: 0; font-size: 13px; color: #c9d0e6; }

.acting-as { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #c9d0e6; }
.acting-as strong { color: var(--white); }
.current-person-badge { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  border: 1.5px solid rgba(255,255,255,0.4);
}
.avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.15);
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
}

.ghost-btn {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.35);
  background: transparent;
  color: var(--white);
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
}
.ghost-btn:hover { background: rgba(255,255,255,0.12); }

main { max-width: 1000px; margin: 0 auto; padding: 20px; }

.legend {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin-bottom: 16px;
}
.chip {
  flex-shrink: 0;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--white);
  opacity: 0.9;
  white-space: nowrap;
}
.chip-short { display: none; }
.chip.undecided { background: var(--undecided); }
.chip.going { background: var(--going); }
.chip.not_going { background: var(--not_going); }
.chip.for_sale { background: var(--for_sale); }
.chip.ticket_exchange { background: var(--ticket_exchange); }
.chip.sold { background: var(--sold); }

.tabs {
  display: flex;
  border-bottom: 2px solid var(--grey-line);
  margin-bottom: 16px;
}
.tab-btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.tab-btn.active {
  color: var(--navy);
  border-bottom-color: var(--navy);
}

.overview-stats {
  background: var(--white);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Overview grid: dense, single-line-per-fixture, colour is on the cell
   itself (not a pill inside it) so a season's worth of games fits on one
   screen at a glance — this is deliberately NOT the card-per-fixture
   layout Manage uses. */
#overview-table { table-layout: fixed; min-width: 0; }
#overview-table th, #overview-table td { padding: 0; }
#overview-table thead th {
  padding: 8px 6px;
  font-size: 10px;
}
#overview-table .col-fixture { width: 46%; }
#overview-table tbody tr.played { opacity: 0.5; }
.overview-fixture-cell {
  padding: 7px 8px !important;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.overview-fixture-cell .overview-date-short { color: var(--muted); margin-right: 6px; }
.overview-fixture-cell.christmas { background: #fdf6e3 !important; }
.overview-status-cell {
  padding: 7px 4px !important;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--white);
  line-height: 1.15;
}
.overview-status-cell.undecided { background: var(--undecided); }
.overview-status-cell.going { background: var(--going); }
.overview-status-cell.not_going { background: var(--not_going); }
.overview-status-cell.for_sale { background: var(--for_sale); }
.overview-status-cell.ticket_exchange { background: var(--ticket_exchange); }
.overview-status-cell.sold { background: var(--sold); }

@media (max-width: 640px) {
  .overview-fixture-cell { font-size: 11px; padding: 6px 6px !important; }
  .overview-status-cell { font-size: 9px; padding: 6px 2px !important; }
}

.table-wrap {
  background: var(--white);
  border-radius: 12px;
  overflow-x: auto;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

table { border-collapse: collapse; width: 100%; min-width: 720px; }
thead th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 12px 14px;
  border-bottom: 1px solid var(--grey-line);
}
tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--grey-line);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr.played { opacity: 0.55; }

.opponent { font-weight: 600; }
.opponent-badge { vertical-align: middle; margin-right: 6px; object-fit: contain; }
.competition { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.gw { font-size: 12px; color: var(--muted); }
.played-tag {
  font-size: 11px;
  background: var(--grey-line);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
}
.christmas-tag {
  display: inline-block;
  font-size: 11px;
  background: #166534;
  color: var(--white);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
  white-space: nowrap;
}
tbody tr.christmas { background: #fdf6e3; }

.time-cell {
  min-width: 230px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.time-changed-chip {
  background: var(--for_sale);
  color: var(--white);
  font-size: 10px;
  padding: 2px 7px;
  cursor: help;
}

.person-cell { min-width: 150px; }
.status-select {
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--grey-line);
  font-size: 13px;
  font-weight: 600;
  color: var(--white);
  appearance: none;
  cursor: pointer;
}
.status-select.undecided { background: var(--undecided); }
.status-select.going { background: var(--going); }
.status-select.not_going { background: var(--not_going); }
.status-select.for_sale { background: var(--for_sale); }
.status-select.ticket_exchange { background: var(--ticket_exchange); }
.status-select.sold { background: var(--sold); }

.sold-to-input {
  width: 100%;
  margin-top: 6px;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--grey-line);
  font-size: 13px;
}
.exchange-value {
  font-size: 11px;
  color: var(--ticket_exchange);
  font-weight: 600;
  margin-top: 6px;
}

.status-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}
.status-meta.error {
  color: var(--not_going);
  font-weight: 600;
}

.loading { text-align: center; padding: 30px; color: var(--muted); }
.disclaimer { font-size: 12px; color: var(--muted); margin-top: 14px; }
.disclaimer a { color: var(--navy); }

.activity-list {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  overflow: hidden;
}
.activity-item {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--grey-line);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
}
.activity-dot.undecided { background: var(--undecided); }
.activity-dot.going { background: var(--going); }
.activity-dot.not_going { background: var(--not_going); }
.activity-dot.for_sale { background: var(--for_sale); }
.activity-dot.ticket_exchange { background: var(--ticket_exchange); }
.activity-dot.sold { background: var(--sold); }
.activity-text { font-size: 13px; line-height: 1.4; }
.activity-status { font-weight: 600; }
.activity-time { font-size: 11px; color: var(--muted); margin-top: 2px; }

.settings { margin-top: 28px; }
.settings h2 { margin: 0 0 10px; font-size: 18px; color: var(--navy); }
.settings-row {
  background: var(--white);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.settings-row label { font-size: 13px; }
.settings-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--grey-line);
  border-radius: 8px;
  padding: 6px 10px;
}
.settings-input-wrap .currency-prefix { color: var(--muted); font-size: 13px; }
.settings-input-wrap input {
  border: none;
  width: 80px;
  font-size: 13px;
  outline: none;
}
#settings-meta { margin-top: 8px; }

.nominations { margin-top: 28px; }
.nominations h2 { margin: 0 0 6px; font-size: 18px; color: var(--navy); }

.nominations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.nomination-card {
  background: var(--white);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.nomination-card h3 {
  margin: 0 0 4px;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nomination-card .count { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.nomination-card .count.full { color: var(--for_sale); font-weight: 600; }
.nomination-slot { margin-bottom: 8px; }
.nomination-slot input {
  width: 100%;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--grey-line);
  font-size: 13px;
}
.nomination-slot input:disabled { background: var(--grey-bg); color: var(--muted); }
.locked-badge {
  font-size: 11px;
  background: var(--for_sale);
  color: var(--white);
  padding: 2px 8px;
  border-radius: 999px;
}

.archive { margin-top: 28px; }
#archive-content {
  margin-top: 12px;
  background: var(--white);
  border-radius: 12px;
  padding: 16px;
  overflow-x: auto;
}
#archive-content table { min-width: 640px; }
#archive-content th, #archive-content td {
  padding: 8px 10px;
  font-size: 13px;
  border-bottom: 1px solid var(--grey-line);
  text-align: left;
}
#archive-content tfoot td { font-weight: 700; }

@media (max-width: 640px) {
  .topbar { padding: 14px; }
  main { padding: 14px; }

  /* All 6 chips don't fit on one line at phone widths using their full
     labels, so mobile swaps in shorter text (e.g. "Ticket Exchange" ->
     "Tkt Exch.") and tightens sizing until the whole legend fits without
     wrapping or scrolling. */
  .legend { gap: 4px; }
  .chip { font-size: 10px; padding: 4px 6px; }
  .chip-full { display: none; }
  .chip-short { display: inline; }

  /* Fixtures table becomes a compact card per fixture: fixture name and
     date/kick-off each span the full width, then Gav/Matt/KC sit side by
     side as a 3-column row instead of stacking one below the other — the
     point is fitting more of the season on screen per scroll. */
  .manage-table-wrap { overflow-x: visible; }
  .responsive-table { min-width: 0; }
  .responsive-table thead { display: none; }
  .responsive-table tbody tr {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    column-gap: 8px;
    padding: 10px 14px;
    border-bottom: 8px solid var(--grey-bg);
  }
  .responsive-table tbody tr:last-child { border-bottom: none; }
  .responsive-table tbody td {
    display: block;
    padding: 4px 0;
    border-bottom: none;
    min-width: 0;
  }
  .responsive-table tbody td.fixture-cell,
  .responsive-table tbody td.time-cell {
    grid-column: 1 / -1;
  }
  .responsive-table tbody td.fixture-cell { padding-bottom: 4px; }
  .responsive-table tbody td.time-cell {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding-bottom: 8px;
    font-size: 12px;
  }
  .responsive-table tbody td[data-label] { padding-top: 6px; }
  .responsive-table tbody td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    margin-bottom: 3px;
  }

  .responsive-table .status-select { font-size: 11px; padding: 6px 4px; }
  .responsive-table .sold-to-input { font-size: 11px; padding: 5px 6px; }
  .responsive-table .status-meta { font-size: 10px; }
}
