:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --text: #1c1f24;
  --muted: #646b76;
  --border: #dde0e5;
  --accent: #37003c;
  --accent-text: #ffffff;
  --highlight: #00a86b;
  --in-bg: #e3f6ee;
  --in-border: #00a86b;
  --out-bg: #fdecec;
  --out-text: #b42318;
  --chip-bg: #fff4d6;
  --chip-text: #7a4b00;
  --double: #1f6feb;
  --blank: #b42318;
  --bar: #00a86b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1a1d22;
    --surface-2: #23272e;
    --text: #e8eaed;
    --muted: #9aa1ab;
    --border: #2f343c;
    --accent: #c99bd0;
    --accent-text: #1a0b1c;
    --in-bg: #0f2e22;
    --out-bg: #3a1716;
    --out-text: #ff8a80;
    --chip-bg: #3a2c0c;
    --chip-text: #ffd27a;
    --double: #79b0ff;
    --blank: #ff8a80;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.top {
  padding: 20px 24px 8px;
  max-width: 1400px;
  margin: 0 auto;
}
.top h1 { margin: 0; font-size: 24px; letter-spacing: -0.01em; }
.tagline { margin: 4px 0 0; color: var(--muted); }

main { max-width: 1400px; margin: 0 auto; padding: 8px 24px 40px; }

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.panel h2 { margin: 0 0 12px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.step {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text);
  font-size: 12px; font-weight: 700;
}

.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field input:not([type="checkbox"]), .field select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; min-width: 140px;
}
fieldset.field { border: 0; padding: 0; margin: 0; }
fieldset.field legend { padding: 0; margin-bottom: 4px; }

button {
  font: inherit; font-weight: 600;
  background: var(--accent); color: var(--accent-text);
  border: 0; border-radius: 8px; padding: 8px 16px; cursor: pointer;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }

.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }

.summary { margin-top: 12px; display: grid; gap: 6px; font-size: 14px; }
.summary .name { font-weight: 700; font-size: 15px; }
#team-summary { container-type: inline-size; }
.team-overview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
/* Narrow panels: bank and free transfers across the top, chip halves below. */
@container (max-width: 340px) {
  .team-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-col.money { grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-col.money .overview-title { grid-column: 1 / -1; }
}
.overview-col {
  background: var(--surface-2); border-radius: 8px; padding: 8px 10px;
  display: grid; gap: 6px; align-content: start; min-width: 0;
}
.overview-title {
  display: flex; justify-content: space-between; gap: 4px; flex-wrap: wrap;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted);
}
.stat { display: grid; }
.stat-label { font-size: 11px; color: var(--muted); }
.stat-value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.chip-row { display: flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; min-width: 0; }
.chip-row .chip-state { overflow: hidden; text-overflow: ellipsis; }
.chip-abbr {
  flex: none; width: 28px; text-align: center; font-size: 11px; font-weight: 800;
  border-radius: 5px; padding: 2px 0; border: 1px solid transparent;
}
.chip-row.available .chip-abbr { background: var(--accent); color: var(--accent-text); }
.chip-row.available .chip-state { color: var(--highlight); font-weight: 600; }
.chip-row.later .chip-abbr { border-color: var(--accent); color: var(--accent); }
.chip-row.used .chip-abbr, .chip-row.expired .chip-abbr {
  background: var(--border); color: var(--muted); text-decoration: line-through;
}
.chip-row.used .chip-state, .chip-row.expired .chip-state, .chip-row.later .chip-state { color: var(--muted); }
.note { color: var(--muted); font-size: 13px; }
.error { color: var(--out-text); }

.drop {
  display: block; position: relative;
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 22px 12px; text-align: center; color: var(--muted); cursor: pointer;
}
.drop.dragging { border-color: var(--highlight); background: var(--in-bg); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.sources { margin-top: 12px; font-size: 13px; }
.sources summary { cursor: pointer; color: var(--muted); }
.source { margin-top: 10px; }
.source b { font-size: 14px; }
.source ol { margin: 4px 0 0; padding-left: 20px; }
.tag { font-size: 12px; border-radius: 999px; padding: 1px 8px; background: var(--surface-2); margin-left: 6px; }

.settings { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 14px; }
.chip-boxes { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--text); font-size: 14px; }
.chip-boxes label { display: flex; gap: 5px; align-items: center; }
.chip-boxes .none { color: var(--muted); }

.progress { margin-top: 14px; }
.stages { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; }
.stages li { padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.stages li.active { background: var(--accent); color: var(--accent-text); }
.stages li.done { color: var(--highlight); }
.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--bar); transition: width 0.3s; }
.progress-text { margin: 8px 0 0; font-size: 13px; color: var(--muted); }

.message { margin: 16px 0 0; padding: 10px 14px; border-radius: 8px; background: var(--out-bg); color: var(--out-text); }

.actions { margin-top: 16px; }
.actions h2 { font-size: 17px; }
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px 24px; }
.action-grid h3 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.move { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 3px 0; }
.move .out { color: var(--out-text); }
.move .in { color: var(--highlight); font-weight: 600; }
.badge-chip { display: inline-block; background: var(--chip-bg); color: var(--chip-text); border-radius: 6px; padding: 1px 8px; font-weight: 700; font-size: 13px; }
.chip-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.chip-table td { padding: 3px 6px 3px 0; vertical-align: top; }
.solver-line { margin-top: 12px; font-size: 13px; color: var(--muted); }

.grid-panel { margin-top: 16px; overflow-x: auto; padding-bottom: 6px; }
.grid { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(196px, 1fr); gap: 10px; min-width: min-content; }

.week {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); display: flex; flex-direction: column; min-width: 196px;
}
.week-head { padding: 10px 12px 8px; border-bottom: 1px solid var(--border); }
.week-head .gw { font-weight: 700; font-size: 16px; display: flex; justify-content: space-between; align-items: baseline; }
.week-head .xp { font-size: 13px; font-weight: 600; color: var(--muted); }
.week-head .meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.week-body { padding: 8px; display: grid; gap: 4px; flex: 1; align-content: start; }
.week-body .empty { color: var(--muted); font-size: 13px; text-align: center; padding: 24px 6px; }
.line-label {
  font-size: 11px; line-height: 16px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted);
  margin: 6px 4px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.card {
  display: grid; grid-template-columns: 30px 1fr auto; gap: 6px; align-items: center;
  width: 100%; text-align: left; font: inherit; font-weight: 400; color: var(--text);
  background: var(--surface-2); border-radius: 8px; padding: 4px 6px; font-size: 13px;
  border: 1px solid transparent; cursor: pointer;
}
.card:hover:not(:disabled) { border-color: var(--border); filter: brightness(0.98); }
.card:disabled { opacity: 1; cursor: default; }
.pin { font-size: 11px; }
.card.in { background: var(--in-bg); border-color: var(--in-border); }
.card.bench { opacity: 0.8; }
.shirt {
  width: 30px; height: 22px; border-radius: 5px; display: grid; place-items: center;
  font-size: 10px; font-weight: 700; border: 1px solid rgba(0, 0, 0, 0.15);
}
.card .who { min-width: 0; }
.card .pname { font-weight: 600; white-space: nowrap; display: flex; gap: 4px; align-items: center; min-width: 0; }
.card .pname .nm { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.card .pname .pin, .card .pname .cap { flex: none; }
.card .fix { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Every card is the same height, double fixtures included. */
.card { height: 46px; }.card .fix .dbl { color: var(--double); font-weight: 600; }
.card .fix .blank { color: var(--blank); font-weight: 600; }
.card .pxp { font-variant-numeric: tabular-nums; font-weight: 600; }
.cap { font-size: 10px; font-weight: 800; border-radius: 4px; padding: 0 4px; background: var(--accent); color: var(--accent-text); }
.cap.vice { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }

.week-foot { border-top: 1px solid var(--border); padding: 4px 12px 10px; font-size: 12px; color: var(--muted); display: grid; gap: 2px; }
.week-foot .line-label { margin: 4px 0 0; }
.week-foot .move-line { color: var(--text); }
.week-foot .out { color: var(--out-text); }
.week-foot .in { color: var(--highlight); font-weight: 600; }
.week-foot .dbl { color: var(--double); font-weight: 600; margin-top: 4px; }
.week-foot .blank { color: var(--blank); margin-top: 4px; }

.squad-list { margin-top: 10px; display: grid; gap: 3px; }

.requests { margin-top: 16px; }
.requests-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.requests-head h2 { margin: 0; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--chip-bg); color: var(--chip-text); border: 1px solid transparent;
  border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 13px; font-weight: 600;
}
.pill.clash { background: var(--out-bg); color: var(--out-text); border-color: var(--out-text); }
.pill.outside { opacity: 0.55; }
.pill-remove {
  background: transparent; color: inherit; padding: 0 6px; font-size: 15px; line-height: 1; border-radius: 999px;
}
.pill-remove:hover:not(:disabled) { background: rgba(0, 0, 0, 0.08); }
.stale { margin: 0 0 10px; padding: 8px 12px; border-radius: 8px; background: var(--chip-bg); color: var(--chip-text); }

.chip-toggles { display: flex; flex-wrap: nowrap; gap: 4px; margin-top: 6px; min-height: 22px; }
.chip-toggle.played:not(.on) { background: var(--chip-bg); color: var(--chip-text); border-color: var(--chip-text); }
.chip-toggle {
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px;
  background: transparent; color: var(--muted); border: 1px solid var(--border);
}
.chip-toggle.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.chip-toggle.off { color: var(--out-text); border-color: var(--out-text); text-decoration: line-through; }
.chip-toggle.blocked.auto { border-style: dashed; opacity: 0.6; }

.add-player {
  margin-top: 6px; background: transparent; color: var(--muted); border: 1px dashed var(--border);
  font-size: 12px; font-weight: 600; padding: 5px;
}
.add-player:hover:not(:disabled) { color: var(--text); border-color: var(--muted); }

.dialog {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 0;
  background: var(--surface); color: var(--text); width: min(520px, calc(100vw - 32px));
}
.dialog::backdrop { background: rgba(10, 12, 16, 0.45); }
.dialog-body { padding: 16px 18px; display: grid; gap: 12px; }
.dialog-title { display: flex; gap: 10px; align-items: center; }
.dialog-title .shirt { width: 38px; height: 28px; font-size: 11px; }
.dialog-row { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: flex-end; }
.dialog-row .hint { flex-basis: 100%; margin: 0; }
.dialog-existing h3 { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.xp-strip { display: flex; flex-wrap: wrap; gap: 4px; }
.xp-strip > div {
  display: grid; justify-items: center; background: var(--surface-2); border-radius: 6px; padding: 3px 7px; font-size: 13px;
}
.xp-strip .note { font-size: 10px; }
.row.end { justify-content: flex-end; }
button.small { padding: 2px 10px; font-size: 12px; }
.dialog input[type="search"], .dialog select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
}
.dialog input[type="search"] { flex: 1; min-width: 160px; }
.search-list { display: grid; gap: 3px; max-height: min(50vh, 420px); overflow-y: auto; }
.search-row {
  display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: center; width: 100%;
  text-align: left; font: inherit; font-weight: 400; font-size: 13px; color: var(--text);
  background: var(--surface-2); border: 1px solid transparent; border-radius: 8px; padding: 5px 8px;
}
.search-row:hover { border-color: var(--border); }
.search-row .pxp { font-variant-numeric: tabular-nums; font-weight: 600; }

@media (max-width: 640px) {
  .top, main { padding-left: 16px; padding-right: 16px; }
}
