/* ==========================================================================
   ComunioBot — theme
   Modern take on the Comunio look (grass-green brand, light airy surfaces)
   layered on top of Pico v2. See CSS_CONVENTIONS.md before editing.
   ========================================================================== */

:root {
  /* --- Brand palette (single source of truth for colour) --------------- */
  --fx-brand:        #54a12e;   /* Comunio grass green — primary actions   */
  --fx-brand-strong: #3f7d20;   /* hover / active / links                  */
  --fx-brand-dark:   #2c5c15;   /* headers, high-contrast text on tint     */
  --fx-brand-tint:   #eef6e7;   /* filled surfaces, table row hover        */
  --fx-brand-tint-2: #f6faf2;   /* zebra stripes, subtle fills             */
  --fx-accent:       #0072b2;   /* data-viz / info accent (charts, links)  */

  /* --- Neutrals -------------------------------------------------------- */
  --fx-ink:     #1f2a1c;        /* body text                               */
  --fx-muted:   #667085;        /* secondary text                          */
  --fx-line:    #e4e9df;        /* borders / dividers                      */
  --fx-surface: #ffffff;        /* cards                                   */
  --fx-bg:      #f4f7f1;        /* page background                         */

  /* --- Elevation & shape ---------------------------------------------- */
  --fx-radius:    .7rem;
  --fx-radius-sm: .45rem;
  --fx-shadow:    0 1px 2px rgba(16,24,16,.05), 0 2px 8px rgba(16,24,16,.06);
  --fx-shadow-lg: 0 8px 24px rgba(16,24,16,.14);

  /* --- Squad comparison highlight (added green / left red) ------------ */
  --fx-added-bg:        #dcf1d2;   /* row tint: joined since compare date     */
  --fx-added-bg-strong: #cbe9bb;   /* same, on hover                          */
  --fx-added-ink:       #2c5c15;   /* "Neu" tag text                          */
  --fx-removed-bg:      #fbe0e0;   /* row tint: left since compare date       */
  --fx-removed-bg-strong: #f6cfcf; /* same, on hover                          */
  --fx-removed-ink:     #a12e2e;   /* "Abgegeben" tag text                    */

  /* --- Metro tile palette (cycled by .tile:nth-of-type) --------------- */
  --fx-tile-1: #2f8f4e;   /* green   */
  --fx-tile-2: #2f7dbf;   /* blue    */
  --fx-tile-3: #d98324;   /* orange  */
  --fx-tile-4: #c0453b;   /* red     */
  --fx-tile-5: #2f9d9d;   /* teal    */
  --fx-tile-6: #6c4bb0;   /* purple  */

  /* --- Re-theme Pico v2 (green primary, softer chrome) ---------------- */
  --pico-primary:                    var(--fx-brand-strong);
  --pico-primary-background:         var(--fx-brand);
  --pico-primary-hover-background:   var(--fx-brand-strong);
  --pico-primary-border:             var(--fx-brand);
  --pico-primary-hover-border:       var(--fx-brand-strong);
  --pico-primary-underline:          transparent;
  --pico-primary-focus:              rgba(84,161,46,.32);
  --pico-border-radius:              var(--fx-radius-sm);
  --pico-form-element-active-border-color: var(--fx-brand);
  --pico-form-element-focus-color:   rgba(84,161,46,.32);
  --pico-background-color:           var(--fx-bg);
  --pico-color:                      var(--fx-ink);
  --pico-font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body { background: var(--fx-bg); }
h1, h2, h3, h4 { color: var(--fx-brand-dark); letter-spacing: -.01em; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Environment banner ---------------------------------------------- */
.env-banner {
  background: #e69f00; color: #1a1a1a; text-align: center;
  font-weight: 700; padding: .35rem; letter-spacing: .05em;
}

.muted { color: var(--fx-muted); }
.error { color: #d55e00; font-weight: 600; }

/* --- Top bar (brand bar + hamburger) --------------------------------- */
.topbar {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: .7rem;
  background: var(--fx-brand);
  border-radius: var(--fx-radius);
  padding: .35rem 1rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--fx-shadow);
}
.topbar a, .topbar strong { color: #fff; }
.topbar a:hover { text-decoration: none; opacity: .85; }
.topbar .brand { margin-left: auto; }
.topbar .brand strong { font-size: 1.05rem; }
.menu-btn {
  cursor: pointer;
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  padding: .15rem .45rem;
  border-radius: var(--fx-radius-sm);
  user-select: none;
}
.menu-btn:hover { background: rgba(255, 255, 255, .18); }

/* --- Off-canvas side menu (CSS-only, checkbox toggle) ---------------- */
.menu-cb { position: absolute; opacity: 0; pointer-events: none; }

.drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 17rem;
  max-width: 82vw;
  display: flex;
  flex-direction: column;
  padding: 1rem 1rem 1.25rem;
  background: var(--fx-surface);
  box-shadow: var(--fx-shadow-lg);
  transform: translateX(-100%);
  transition: transform .25s ease;
  z-index: 1000;
}
.menu-cb:checked ~ .drawer { transform: translateX(0); }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: .75rem;
  margin-bottom: .5rem;
  border-bottom: 1px solid var(--fx-line);
}
.drawer-title { font-weight: 600; color: var(--fx-brand-dark); }
.menu-close {
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--fx-muted);
  padding: .15rem .4rem;
  border-radius: var(--fx-radius-sm);
  user-select: none;
}
.menu-close:hover { background: var(--fx-brand-tint); color: var(--fx-ink); }

.drawer-nav { display: flex; flex-direction: column; gap: .1rem; }
.drawer-nav a {
  display: block;
  padding: .6rem .7rem;
  border-radius: var(--fx-radius-sm);
  color: var(--fx-ink);
  text-decoration: none;
  font-weight: 500;
}
.drawer-nav a:hover { background: var(--fx-brand-tint); color: var(--fx-brand-strong); }

.drawer-foot {
  margin-top: auto;
  padding-top: .75rem;
  border-top: 1px solid var(--fx-line);
}
.menu-logout {
  display: block;
  padding: .55rem .7rem;
  border-radius: var(--fx-radius-sm);
  color: var(--fx-muted);
  text-decoration: none;
  font-weight: 500;
}
.menu-logout:hover { background: var(--fx-removed-bg); color: var(--fx-removed-ink); }

.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 16, .42);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease;
  z-index: 999;
}
.menu-cb:checked ~ .menu-overlay { opacity: 1; visibility: visible; }

/* --- Login ------------------------------------------------------------ */
.login-wrap { max-width: 26rem; margin: 4rem auto; }
.login-card {
  border: 1px solid var(--fx-line); border-radius: var(--fx-radius);
  box-shadow: var(--fx-shadow); background: var(--fx-surface);
}
.login-card button { width: 100%; }

/* ==========================================================================
   Home feature tiles — flat Metro/Modern-UI cards (see tiles.png)
   One <a.tile-link> wrapping one <div.tile> per feature. Colour is assigned
   automatically by position; just add the tile in FEATURES.
   ========================================================================== */
.tilegrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: .6rem;
  margin: 1.5rem 0;
}
.tile-link { text-decoration: none; }
.tile-link:hover { text-decoration: none; }
.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.1rem 1.2rem;
  color: #fff;
  background: var(--fx-tile-1);
  border-radius: var(--fx-radius-sm);
  overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--fx-shadow-lg); filter: brightness(1.06); }
.tile-icon { font-size: 2.6rem; line-height: 1; }
.tile h3 { margin: 0 0 .15rem; color: #fff; font-size: 1.2rem; }
.tile p { margin: 0; font-size: .82rem; line-height: 1.35; color: rgba(255,255,255,.88); }

/* Colour cycle — mirror the tiles palette; extend if >6 features exist. */
.tile-link:nth-of-type(6n + 1) .tile { background: var(--fx-tile-1); }
.tile-link:nth-of-type(6n + 2) .tile { background: var(--fx-tile-2); }
.tile-link:nth-of-type(6n + 3) .tile { background: var(--fx-tile-3); }
.tile-link:nth-of-type(6n + 4) .tile { background: var(--fx-tile-4); }
.tile-link:nth-of-type(6n + 5) .tile { background: var(--fx-tile-5); }
.tile-link:nth-of-type(6n + 6) .tile { background: var(--fx-tile-6); }

/* --- Filters (rounded control row, Comunio-style) -------------------- */
/* Top-align so every caption sits on the same line even when controls differ
   in height (e.g. a native date input is taller than the segmented picker). */
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: start; }
.filters label { margin: 0; font-size: .8rem; color: var(--fx-muted); }
.filters select, .filters input { min-width: 9rem; border-radius: 2rem; }
/* Drop Pico's control margin inside a field so captions line up exactly. */
.filters .field > input, .filters .field > select { margin: 0; }

/* "Abgänge ausblenden" switch: a Pico role="switch" toggle in the filter row.
   Lay the track + caption out inline and opt the checkbox out of the wide pill
   sizing (.filters input) the text/select controls get, or it stretches. Nudge
   it down so it visually aligns with the taller adjacent controls. */
.filters .toggle-field {
  display: inline-flex; align-items: center; gap: .5rem;
  align-self: center; white-space: nowrap; cursor: pointer;
}
.filters .toggle-field input[type="checkbox"] {
  min-width: 0; width: auto; margin: 0; flex: 0 0 auto;
}

/* News source multi-select: a wrapping row of checkbox chips inside a .field.
   Opt the checkboxes out of the wide-pill sizing text inputs get (.filters input),
   same as the toggle switch above. */
.source-choices { display: flex; flex-wrap: wrap; gap: .35rem 1rem; align-items: center; }
.source-choices label {
  display: inline-flex; align-items: center; gap: .35rem; margin: 0;
  font-size: .85rem; white-space: nowrap; cursor: pointer; color: inherit;
}
.source-choices input[type="checkbox"] {
  min-width: 0; width: auto; margin: 0; flex: 0 0 auto;
}

/* Dedicated "apply all filters" button, sits on its own row below the filters.
   Compact (content width) on desktop, full-row on phones (see media query).
   Pico makes buttons full-width via a higher-specificity selector, so the width
   needs !important to shrink here. Themed green with --fx tokens directly —
   Pico's default primary is blue and the app's :root override loses to it. */
.filter-apply {
  display: inline-block; width: fit-content !important;
  margin: .85rem 0 0; padding: .5rem 1.4rem;
  background: var(--fx-brand); border: 1px solid var(--fx-brand); color: #fff;
}
.filter-apply:hover { background: var(--fx-brand-strong); border-color: var(--fx-brand-strong); }

/* Segmented radio picker (season selector) */
.filters .field { display: flex; flex-direction: column; gap: .25rem; }
.field-cap { font-size: .8rem; color: var(--fx-muted); }
.seg { display: inline-flex; align-self: start; overflow: hidden;
  border: 1px solid var(--fx-line); border-radius: 2rem; background: #fff; }
.seg .seg-option { margin: 0; }
.seg .seg-option input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.seg .seg-option span {
  display: block; padding: .5rem 1rem; font-size: .85rem; cursor: pointer;
  color: var(--fx-ink); transition: background .15s, color .15s;
}
.seg .seg-option:not(:last-child) span { border-right: 1px solid var(--fx-line); }
.seg .seg-option input:checked + span { background: var(--fx-brand); color: #fff; font-weight: 600; }
.seg .seg-option input:focus-visible + span { outline: 2px solid var(--fx-brand-strong); outline-offset: -2px; }

/* --- Table ------------------------------------------------------------ */
table.players {
  font-size: .9rem; background: var(--fx-surface);
  /* Separate (not collapsed) borders so the first column can be position:sticky
     — browsers ignore sticky cells in a border-collapse:collapse table. The card
     border/radius/shadow live on .table-wrap instead; the table can't clip its
     own overflow here, or that clip (not .table-wrap) would anchor the sticky. */
  border-collapse: separate; border-spacing: 0;
}
table.players thead th {
  background: var(--fx-brand-tint); color: var(--fx-brand-dark);
  border-bottom: 1px solid var(--fx-line);
}
table.players td, table.players th { padding: .45rem .6rem; }
table.players tbody tr:nth-child(even) { background: var(--fx-brand-tint-2); }
table.players tbody tr:hover { background: var(--fx-brand-tint); }

/* --- Player avatar thumbnails (list name cell) ----------------------- */
/* Fixed small box; the source photo is larger, so it stays sharp on
   high-DPI screens (the browser downsamples). Shrinks a touch on phones. */
/* Keep the name cell readable: a floor width stops the column collapsing when the
   table is wider than the viewport (the stats then scroll under the sticky first
   column), and break-word wraps a genuinely long name to a second line instead of
   letting it bleed into the next column. Without the floor, break-word/anywhere
   would shrink the column to one character per line on a narrow screen. */
.player-cell { display: flex; align-items: center; gap: .55rem; min-width: 7.5rem; }
.player-cell a { overflow-wrap: break-word; }
.avatar {
  width: 36px; height: 36px; flex: 0 0 auto;
  border-radius: 50%; object-fit: cover;
  background: var(--fx-brand-tint); border: 1px solid var(--fx-line);
}
@media (max-width: 560px) { .avatar { width: 28px; height: 28px; } }

/* --- Transfers: buyer/seller owner cell ------------------------------ */
/* Small club crest beside the manager name (transparent crest -> contain,
   keep its shape, no circular crop). */
.owner-cell { display: flex; align-items: center; gap: .5rem; }
.owner-mini { width: 28px; height: 28px; flex: 0 0 auto; object-fit: contain; }
@media (max-width: 560px) { .owner-mini { width: 22px; height: 22px; } }

/* Club crest beside the team name (browse table + detail "Verein" stat).
   Inline-flex so it nests cleanly inside the detail stat's <strong>. */
.team-cell { display: inline-flex; align-items: center; gap: .5rem; }
.team-mini { width: 28px; height: 28px; flex: 0 0 auto; object-fit: contain; }
@media (max-width: 560px) { .team-mini { width: 22px; height: 22px; } }

/* --- Squads: single selected squad + comparison ---------------------- */
.squad-head {
  display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap;
  margin: 1.25rem 0 .5rem;
}
.squad-head h3 { margin: 0; }
/* Club emblem next to the selected squad's name (transparent crest, keep shape). */
.squad-emblem { width: 56px; height: 56px; flex: 0 0 auto; object-fit: contain; align-self: center; }
@media (max-width: 560px) { .squad-emblem { width: 44px; height: 44px; } }
/* Kontostand: random play-money balance + clickable crystal-ball to reroll. */
.kontostand { display: flex; align-items: center; gap: .6rem; margin: .35rem 0 1rem; }
.kontostand .field-cap { margin: 0; }
.kontostand-value { font-size: 1.4rem; font-weight: 700; color: var(--fx-brand-dark); }
.kontostand-value.neg { color: var(--fx-removed-ink); }
.kontostand-icon {
  font-size: 1.9rem; line-height: 1; flex: 0 0 auto; user-select: none;
  cursor: pointer; transition: transform .15s ease, filter .15s ease;
}
.kontostand-icon:hover { transform: scale(1.08); filter: brightness(1.05); }
.kontostand-icon:active { transform: scale(.96); }

.comp-head { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; margin: 1.25rem 0 .35rem; }
.comp-head h4 { margin: 0; }
/* Sortable column headers */
table.players th a.sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
table.players th a.sort-link:hover { text-decoration: underline; }
table.players.comp td:nth-child(n+2), table.players.comp th:nth-child(n+2) { text-align: right; }
table.players.comp .comp-total td { border-top: 2px solid var(--fx-line); }

/* Squad comparison: highlighted rows + legend + inline tags. Placed after the
   zebra/hover rules above so equal-specificity selectors win by source order. */
table.players tbody tr.squad-row-added { background: var(--fx-added-bg); }
table.players tbody tr.squad-row-added:hover { background: var(--fx-added-bg-strong); }
table.players tbody tr.squad-row-left { background: var(--fx-removed-bg); }
table.players tbody tr.squad-row-left:hover { background: var(--fx-removed-bg-strong); }
/* Departed players are no longer in the squad — mute and strike their name. */
table.players tbody tr.squad-row-left .player-cell a { color: var(--fx-muted); text-decoration: line-through; }
.squad-tag {
  margin-left: .4rem; padding: .05rem .4rem; border-radius: 1rem;
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
}
.squad-tag-added { background: var(--fx-added-bg-strong); color: var(--fx-added-ink); }
.squad-tag-left  { background: var(--fx-removed-bg-strong); color: var(--fx-removed-ink); }
.cmp-legend { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: .25rem 0 .75rem; }
.legend-chip { padding: .1rem .55rem; border-radius: 1rem; font-size: .78rem; font-weight: 600; }
.legend-chip.legend-added { background: var(--fx-added-bg); color: var(--fx-added-ink); }
.legend-chip.legend-left  { background: var(--fx-removed-bg); color: var(--fx-removed-ink); }

.pager { display: flex; align-items: center; gap: 1rem; margin: 1rem 0 .5rem; }
.pager button { width: auto; padding: .3rem .8rem; margin: 0; }
.pageinfo { color: var(--fx-muted); font-size: .85rem; }

/* --- Transfers: "suggest a fix" affordance ---------------------------- */
.link-btn {
  background: none; border: none; padding: 0; margin: 0; width: auto;
  color: var(--fx-accent); font-size: .8rem; cursor: pointer;
}
.link-btn:hover { color: var(--fx-brand-strong); text-decoration: underline; }
.suggest-form {
  display: flex; flex-direction: column; gap: .35rem; min-width: 12rem;
  padding: .5rem; margin: 0; background: var(--fx-brand-tint-2);
  border-radius: var(--fx-radius-sm);
}
.suggest-form input, .suggest-form select, .suggest-form textarea { margin: 0; font-size: .82rem; }
.suggest-form div { display: flex; gap: .5rem; align-items: center; }
.suggest-form button.secondary { width: auto; padding: .3rem .7rem; margin: 0; font-size: .82rem; }
.suggest-thanks { font-size: .82rem; }

/* --- Admin: transfer-suggestion review -------------------------------- */
.admin-tabs { display: flex; gap: 1rem; margin: 0 0 1rem; }
.admin-tabs .tab { color: var(--fx-muted); }
.admin-tabs .tab-active { color: var(--fx-brand-strong); font-weight: 600; }
.admin-actions { display: flex; gap: .5rem; align-items: center; }
.admin-actions button.secondary { width: auto; padding: .3rem .7rem; margin: 0; font-size: .82rem; }

/* --- Player detail: prev/next nav ------------------------------------ */
.player-nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: .5rem 0 1rem; }
.player-nav button {
  width: auto; margin: 0; padding: .35rem .8rem; max-width: 45%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.player-nav .nav-next { margin-left: auto; }

/* --- Player detail: header photo + name --------------------------------- */
.player-head { display: flex; align-items: center; gap: 1rem; margin: .5rem 0; }
.player-head .player-headtext { min-width: 0; }
.player-head h2 { margin: 0 0 .35rem; }
.player-photo {
  width: 88px; height: 88px; flex: 0 0 auto;
  border-radius: 50%; object-fit: cover;
  background: var(--fx-brand-tint); border: 1px solid var(--fx-line);
}
@media (max-width: 560px) { .player-photo { width: 64px; height: 64px; } }

/* --- Player detail: header meta + external link ---------------------- */
/* flex-end so the Sofascore/Transfers pills line up with the season control's
   segmented buttons, not the vertical centre of its (caption + buttons) block. */
.detail-meta { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.sofascore-link {
  display: inline-block; font-size: .82rem; font-weight: 600; line-height: 1;
  color: #fff; background: var(--fx-accent);
  padding: .4rem .85rem; border-radius: 2rem; text-decoration: none;
  transition: filter .15s ease;
}
.sofascore-link:hover { filter: brightness(1.08); text-decoration: none; }
/* Transfers pill: same shape, neutral fill so it reads as secondary to Sofascore. */
.transfers-link { color: var(--fx-accent); background: var(--fx-surface); border: 1px solid var(--fx-line); }
.transfers-link:hover { filter: none; background: var(--fx-line); }

/* --- Player detail: stat grid ---------------------------------------- */
.statgrid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: .75rem; margin: 1rem 0 1.5rem;
}
.stat {
  background: var(--fx-surface); border: 1px solid var(--fx-line);
  border-radius: var(--fx-radius); padding: .6rem .8rem; box-shadow: var(--fx-shadow);
}
.statval { font-size: 1.2rem; color: var(--fx-brand-dark); }

/* --- Player detail: position-comparison card -------------------------- */
.cmp-section {
  background: var(--fx-surface); border: 1px solid var(--fx-line);
  border-radius: var(--fx-radius); box-shadow: var(--fx-shadow);
  padding: 1rem 1.2rem; margin: 0 0 1.5rem;
}
.cmp-section h3 { margin: 0; }
.cmpgrid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: .9rem 1.5rem; margin-top: .9rem;
}
.cmp-row-head { display: flex; justify-content: space-between; align-items: baseline; }
.cmp-value { font-weight: 600; color: var(--fx-brand-dark); }
.cmp-bar {
  height: .5rem; border-radius: 1rem; background: var(--fx-brand-tint);
  overflow: hidden; margin: .35rem 0 .25rem;
}
.cmp-bar-fill { height: 100%; background: var(--fx-brand); border-radius: 1rem; }
.cmp-rank { display: block; }
.cmp-empty { font-style: italic; margin-top: .2rem; }

/* Editable Kadermarktwert on the Gehaltsrechner card (frontend what-if). */
.mv-editor { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin-top: .3rem; }
.mv-input {
  /* !important beats Pico's full-width form-control rule (higher specificity). */
  width: 5rem !important; flex: 0 0 auto; margin: 0; padding: .25rem .4rem;
  text-align: right; font-size: 1.1rem; color: var(--fx-brand-dark);
  border: 1px solid var(--fx-line); border-radius: var(--fx-radius-sm);
}
.mv-input::-webkit-outer-spin-button, .mv-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.mv-input { -moz-appearance: textfield; }
.mv-step {
  width: 1.9rem; height: 1.9rem; flex: 0 0 auto; margin: 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.1rem; line-height: 1;
  background: var(--fx-brand); border: 1px solid var(--fx-brand); color: #fff;
  border-radius: var(--fx-radius-sm); cursor: pointer;
}
.mv-step:hover { background: var(--fx-brand-strong); border-color: var(--fx-brand-strong); }
.mv-reset {
  width: 1.9rem; height: 1.9rem; flex: 0 0 auto; margin: 0 0 0 .1rem; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem; line-height: 1;
  background: transparent; border: 1px solid var(--fx-line); color: var(--fx-muted);
  border-radius: var(--fx-radius-sm); cursor: pointer;
}
.mv-reset:hover { background: var(--fx-brand-tint); color: var(--fx-ink); }

/* Editable reference date on the Gehaltsrechner card: highlighted so it reads as
   the input that drives the days-until-next-match count. The date field needs
   more room than the numeric market-value field (5rem) and reads left-aligned. */
.ref-cell {
  background: var(--fx-brand-tint);
  border-color: var(--fx-brand); box-shadow: none;
}
/* Date field on its own row (full cell width) with the −/+/reset buttons grouped
   beneath it. `order:-1` floats the date above the buttons without reordering the
   markup; the 100% basis forces the buttons to wrap under it. This avoids both the
   awkward [−][date]/[+][↺] split and a clipped year in the narrow desktop cell. */
.ref-cell .ref-input {
  order: -1; flex: 1 1 100%; width: auto !important; text-align: left;
}

/* --- Charts ----------------------------------------------------------- */
/* Per-round trends are time series (one tick per Spieltag), so give each the
   full width and stack them — three-across crams the x-axis on desktop. */
.chartgrid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.chart {
  border: 1px solid var(--fx-line); border-radius: var(--fx-radius);
  padding: .5rem; background: var(--fx-surface); box-shadow: var(--fx-shadow);
}

/* ==========================================================================
   Scrollable table wrapper
   The data tables are wider than a phone screen. Without this, a wide table
   widens the whole page, forcing page-level horizontal scroll — which is also
   what let the page pinch-zoom out and break the layout. Wrapping every
   `table.players` in `.table-wrap` confines the overflow to its own box so the
   page itself never exceeds the viewport width. The table keeps its own card
   styling; the wrapper only scrolls.
   ========================================================================== */
.table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 1rem 0;
  /* Card styling moved here from table.players so the table has no clip of its
     own — the wrapper is the sticky scroll container and rounds/clips the card. */
  border: 1px solid var(--fx-line); border-radius: var(--fx-radius);
  box-shadow: var(--fx-shadow); background: var(--fx-surface);
}
.table-wrap > table.players { margin: 0; }

/* Pin the first column (Spieler / Datum / Position) so it stays visible while
   the rest of the table scrolls horizontally on narrow screens. A sticky cell
   must be opaque or scrolled columns show through, so the pinned cell repeats
   every row-state background used elsewhere: header, zebra, hover and the
   squad added/left tints. The right border + soft shadow mark the split edge. */
.table-wrap table.players th:first-child,
.table-wrap table.players td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--fx-surface);
  border-right: 1px solid var(--fx-line);
  box-shadow: 2px 0 4px -2px rgba(16, 24, 16, .12);
}
.table-wrap table.players thead th:first-child {
  z-index: 3;
  background: var(--fx-brand-tint);
}
.table-wrap table.players tbody tr:nth-child(even) td:first-child { background: var(--fx-brand-tint-2); }
.table-wrap table.players tbody tr:hover td:first-child { background: var(--fx-brand-tint); }
.table-wrap table.players tbody tr.squad-row-added td:first-child { background: var(--fx-added-bg); }
.table-wrap table.players tbody tr.squad-row-added:hover td:first-child { background: var(--fx-added-bg-strong); }
.table-wrap table.players tbody tr.squad-row-left td:first-child { background: var(--fx-removed-bg); }
.table-wrap table.players tbody tr.squad-row-left:hover td:first-child { background: var(--fx-removed-bg-strong); }

/* ==========================================================================
   Mobile / narrow-viewport layout
   Desktop grids reflow on their own (auto-fit/minmax), but three things need
   explicit help on phones: the brand nav overflowed off-screen, the feature
   tiles filled the whole width as giant squares, and the filter controls were
   wider than needed. Fix all three below.
   ========================================================================== */
@media (max-width: 640px) {
  /* Top bar stays a single row (hamburger + brand); the full nav now lives in
     the off-canvas drawer, so there are no inline links to wrap here. */

  /* Feature tiles: two per row, free-height (not full-width squares). Equal
     grid-auto-rows keeps every row the same height so tiles don't vary in size
     when descriptions differ in length. */
  .tilegrid { grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; gap: .5rem; margin: 1rem 0; }
  .tile { aspect-ratio: auto; min-height: 8.5rem; padding: .8rem .85rem; }
  .tile-icon { font-size: 2rem; }
  .tile h3 { font-size: 1.05rem; }
  .tile p { font-size: .72rem; }

  /* Filters: let each control fill its row so nothing forces page overflow. */
  .filters { gap: .6rem; }
  .filters > label, .filters > .field { width: 100%; }
  .filters select, .filters input { min-width: 0; width: 100%; }
  .filters .seg { align-self: stretch; }
  .filter-apply { width: 100% !important; }
  /* Give the editable Kadermarktwert the full row so −/input/+/↺ stay one line. */
  .mv-cell { grid-column: 1 / -1; }
}
