/* =====================================================================
   VV De Spuyt members portal: one design system for every page (D18).

   Brand from the club logo: purple #6d2f92 (disc), red #e41e2e (lettering),
   white ball, near-black outline. Purple is the working colour; red is
   reserved for "no" states (absent, error). The logo itself carries the brand.
   Light is the default palette; [data-theme="dark"] swaps the tokens.
   Type is the system stack on purpose: the site never loads third-party
   fonts (see README, CSP font-src 'self').
   ===================================================================== */

:root {
    --brand: #6d2f92;
    --brand-strong: #562373;
    --brand-soft: #f0e8f6;
    --brand-softer: #f8f4fb;
    --brand-ink: #ffffff;
    --brand-text: #5a2779;
    --red: #e41e2e;
    --red-soft: #fdeaec;
    --red-text: #b3111f;
    --green: #1e8a4a;
    --green-soft: #e6f5ec;
    --green-text: #176b3a;
    --amber: #b7791f;
    --amber-soft: #fcf1dc;

    --bg: #f6f3f8;
    --surface: #ffffff;
    --surface-2: #f2eef5;
    --surface-3: #e9e3ee;
    --border: #e2dbe8;
    --border-strong: #cfc4d8;
    --text: #221b28;
    --text-2: #5e5468;
    --text-3: #8d8297;

    --shadow-sm: 0 1px 2px rgba(45, 20, 60, 0.06), 0 1px 6px rgba(45, 20, 60, 0.05);
    --shadow-md: 0 4px 14px rgba(45, 20, 60, 0.10), 0 1px 3px rgba(45, 20, 60, 0.06);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* legacy names still used by older rules/scripts */
    --bg-primary: var(--bg);
    --bg-secondary: var(--surface-2);
    --bg-card: var(--surface);
    --bg-card-hover: var(--surface-2);
    --accent-primary: var(--brand);
    --accent-secondary: var(--brand-strong);
    --accent-gradient: var(--brand);
    --text-primary: var(--text);
    --text-secondary: var(--text-2);
    --text-muted: var(--text-3);
    --border-color: var(--border);
    color-scheme: light;
}

:root[data-theme="dark"] {
    --brand: #9a5cc4;
    --brand-strong: #7d44a8;
    --brand-soft: #33233f;
    --brand-softer: #281c31;
    --brand-ink: #ffffff;
    --brand-text: #c9a6e6;
    --red: #f04452;
    --red-soft: #3d1f24;
    --red-text: #ff9aa2;
    --green: #34b46a;
    --green-soft: #1c3328;
    --green-text: #8fe0b0;
    --amber: #d99a36;
    --amber-soft: #3a2e18;

    --bg: #15101a;
    --surface: #1f1826;
    --surface-2: #281f31;
    --surface-3: #33293d;
    --border: #3a2f45;
    --border-strong: #4d3f5a;
    --text: #f1ecf5;
    --text-2: #b9aec4;
    --text-3: #877b93;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

::selection { background: var(--brand-soft); color: var(--brand-text); }
:root[data-theme="dark"] ::selection { background: var(--brand-strong); color: #fff; }

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* The hidden attribute must win from any class display (.btn, .board-form-row, ...). */
[hidden] { display: none !important; }

input, button, select, textarea { font: inherit; color: inherit; caret-color: var(--brand); }
button { cursor: pointer; }
a { color: var(--brand-text); text-decoration: none; text-underline-offset: 0.18em; }
a:hover { text-decoration: underline; }
img, svg { display: inline-block; vertical-align: middle; }
table { border-collapse: collapse; width: 100%; }
h1, h2, h3, h4 { line-height: 1.2; text-wrap: balance; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
code { font-family: var(--mono); font-size: 0.88em; background: var(--surface-2); padding: 0.1em 0.4em; border-radius: 4px; }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 3px solid var(--bg); }

.icon {
    width: 1.1em;
    height: 1.1em;
    flex: none;
    vertical-align: -0.18em;
}
.icon.icon-lg { width: 1.5em; height: 1.5em; }

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.25rem 1.25rem 3rem;
}

/* ---------- header ---------- */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.25rem;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    min-width: 0;
}

.brand-logo {
    width: 52px;
    height: 46px;
    flex: none;
}

.title {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--text);
}

.subtitle {
    color: var(--text-2);
    font-size: 0.9rem;
    margin-top: 0.1rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.me-nav { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 0.92rem;
    line-height: 1.2;
    text-decoration: none;
    transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out), color 160ms var(--ease-out), box-shadow 160ms var(--ease-out), transform 160ms var(--ease-out);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }

.btn-primary {
    background: var(--brand);
    color: var(--brand-ink);
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--brand-strong); }

.btn-secondary,
.back-btn,
.cache-refresh-btn {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-secondary:hover,
.back-btn:hover,
.cache-refresh-btn:hover { border-color: var(--brand); color: var(--brand-text); background: var(--brand-softer); }

.theme-toggle,
.lang-toggle {
    padding: 0.5rem 0.7rem;
    min-width: 2.5rem;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.theme-toggle .icon { width: 1.15rem; height: 1.15rem; vertical-align: -0.25em; }

.admin-toggle.is-on {
    background: var(--brand-soft);
    border-color: var(--brand);
    color: var(--brand-text);
}

.back-btn { margin-bottom: 1.25rem; }

/* ---------- tabs ---------- */
.tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0.3rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 1.25rem;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
    flex: 0 0 auto;
    padding: 0.6rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-2);
    font-weight: 600;
    font-size: 0.92rem;
    white-space: nowrap;
    transition: background-color 160ms var(--ease-out), color 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}
.tab-btn.tab-right { margin-left: auto; }
.tab-btn:hover { color: var(--text); background: var(--surface-3); }
.tab-btn.active {
    background: var(--brand);
    color: var(--brand-ink);
    box-shadow: var(--shadow-sm);
}

.tab-content { display: none; }
.tab-content.active {
    display: block;
    animation: tab-enter 260ms var(--ease-out);
}
@keyframes tab-enter {
    /* already readable at frame 0; the motion is the settle, not a reveal */
    from { opacity: 0.75; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
    .tab-content.active { animation: none; }
    .btn, .tab-btn { transition: none; }
}

/* ---------- panels ---------- */
.panel,
.team-section,
.controls-bar,
.cache-info-bar,
.detail-header,
.detail-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.panel {
    padding: 1.25rem 1.35rem;
    margin-bottom: 1.1rem;
}
.panel > h2 { margin-bottom: 0.35rem; }
.panel > h2 + p { margin-bottom: 0.9rem; }
.panel > p { color: var(--text-2); }

.team-section { padding: 1.25rem 1.35rem; margin-bottom: 1.1rem; }
.team-section > h2 { margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; }
.team-section > h2 .icon { color: var(--brand); }

.me-muted { color: var(--text-2); }
.me-footer { margin-top: 1.5rem; font-size: 0.85rem; text-align: center; color: var(--text-3); }
.me-team-name { font-size: 1.4rem; font-weight: 650; letter-spacing: -0.01em; margin: 0.25rem 0; }

/* own profile row: ClubCollect photo + name + rugnummer */
.me-profile { display: flex; align-items: center; gap: 0.75rem; margin: 0.25rem 0 0; }
.me-profile-form { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; align-items: center; margin-top: 0.5rem; }
.me-profile-form input[type="file"] { max-width: 280px; }
.me-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); flex-shrink: 0; cursor: zoom-in; }
.me-avatar.lg { width: 48px; height: 48px; }
.member-avatar { display: inline-flex; }
.detail-avatar { display: inline-flex; }
.detail-avatar .me-avatar { width: 48px; height: 48px; }

/* Teams overview rows: photo + name + jersey number + badges
   Photo 28px, name stretches, number + badges right; badges wrap down */
.overview-team .me-list li { justify-content: flex-start; flex-wrap: wrap; row-gap: 0.3rem; }
.overview-team .ov-name { flex: 1 1 auto; min-width: 5em; }

/* Photo lightbox (shared dialog, opened from any .me-avatar) */
.photo-dialog {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    max-width: min(92vw, 540px);
}
.photo-dialog::backdrop { background: rgba(15, 23, 32, 0.6); }
.photo-dialog img { display: block; width: 100%; max-height: 78vh; object-fit: contain; background: var(--surface); }
.photo-dialog-name { margin: 0.6rem 0 0.4rem; text-align: center; color: var(--text-2); }
.photo-dialog form { margin: 0; }
.photo-dialog .btn { display: block; width: 100%; }
.me-rug { background: var(--brand-softer); color: var(--brand); white-space: nowrap; }
.me-season-heading { margin: 1.1rem 0 0.5rem; font-size: 1rem; }
.me-season-heading .me-muted { font-weight: 400; font-size: 0.9rem; }
.me-tags { margin-top: 0.75rem; }

/* lists of people / teams */
.me-list {
    list-style: none;
    margin: 0.6rem 0 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 0.45rem;
}
.me-list li {
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.me-list li.is-me { border-color: var(--brand); background: var(--brand-softer); }

/* ClubCollect memberships: name + meta stacked, not a pill grid */
.me-plans { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.5rem; }
.me-plans li {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.25rem 1rem;
    align-items: baseline;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.me-plans .plan-name { font-weight: 600; }
.me-plans .plan-state { font-size: 0.82rem; color: var(--text-2); white-space: nowrap; }
.me-plans .plan-state.is-started { color: var(--green-text); }
.me-plans .plan-state.is-cancelled { color: var(--text-3); }
.me-plans .plan-dates { grid-column: 1 / -1; font-size: 0.82rem; color: var(--text-3); }
.me-cc-number { margin-bottom: 0.25rem; }

/* badges */
.me-sub-badge,
.duty-badge,
.match-badge,
.role-badge,
.status-badge,
.match-level,
.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 650;
    line-height: 1.5;
    white-space: nowrap;
}
.me-sub-badge { background: var(--amber-soft); color: var(--amber); }
.duty-badge { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.duty-badge.own { background: var(--brand-soft); color: var(--brand-text); border-color: transparent; }
.match-badge { background: var(--brand-soft); color: var(--brand-text); padding: 0.35rem 0.8rem; font-size: 0.85rem; }
.role-badge { background: var(--brand-soft); color: var(--brand-text); }
.status-badge { background: var(--surface-2); color: var(--text-2); }
.status-badge.warning, .isWarning { background: var(--amber-soft); color: var(--amber); }
.match-level { background: var(--surface-2); color: var(--text-2); }
.match-level.is-concept { background: var(--amber-soft); color: var(--amber); }
.match-header > div { display: flex; gap: 0.35rem; }

/* messages */
.login-message {
    margin-top: 1rem;
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius-md);
    background: var(--brand-softer);
    border: 1px solid var(--brand-soft);
    color: var(--text);
}
.login-message.is-error {
    background: var(--red-soft);
    border-color: transparent;
    color: var(--red-text);
}

/* ---------- forms ---------- */
.controls-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.9rem;
    margin-bottom: 1.1rem;
}
.controls-bar .search-box { flex: 1 1 260px; }
.filters { display: flex; gap: 0.6rem; flex-wrap: wrap; flex: 1 1 100%; }
.filter-label { color: var(--text-2); font-size: 0.85rem; font-weight: 600; }

.search-box { position: relative; display: flex; align-items: center; }
.search-icon {
    position: absolute;
    left: 0.8rem;
    color: var(--text-3);
    pointer-events: none;
    display: inline-flex;
}
.search-box input[type="text"] { padding-left: 2.4rem; padding-right: 2.4rem; }
.search-clear {
    position: absolute;
    right: 0.4rem;
    width: 1.8rem;
    height: 1.8rem;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-3);
    font-size: 1.1rem;
    line-height: 1;
}
.search-clear:hover { background: var(--surface-2); color: var(--text); }

input[type="text"],
input[type="email"],
input[type="date"],
textarea,
.select-input {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font-size: 0.95rem;
    transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
    -webkit-appearance: none;
    appearance: none;
}
input::placeholder { color: var(--text-3); }
input[type="text"]:focus,
input[type="email"]:focus,
input[type="date"]:focus,
textarea:focus,
.select-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
.select-input {
    min-width: 200px;
    width: auto;
    padding-right: 2.4rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236d2f92' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: calc(100% - 0.7rem) center;
    cursor: pointer;
}
:root[data-theme="dark"] .select-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23c9a6e6' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

input[type="checkbox"] { accent-color: var(--brand); width: 1rem; height: 1rem; }

.panel form { display: flex; flex-direction: column; gap: 0.75rem; }
.panel form .btn { align-self: flex-start; }

.me-teams-fixed {
    /* Both dt/dd pairs on one row (M31); the 720px block below stacks them again */
    display: grid;
    grid-template-columns: max-content 1fr max-content 1fr;
    gap: 0.35rem 1rem;
    margin: 0.5rem 0 0.75rem;
}
.me-teams-fixed dt { color: var(--text-2); }
.me-teams-fixed dd { font-weight: 600; }
.me-checks {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}
.me-team-role {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.35rem 0.35rem 0.35rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
}
.me-team-role.is-set { border-color: var(--brand); background: var(--brand-softer); }
.me-team-role .select-input { min-width: 0; width: auto; padding: 0.3rem 2rem 0.3rem 0.6rem; font-size: 0.85rem; }
.me-source-badge { background: var(--brand-soft); color: var(--brand-text); }
.me-checks { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.me-caps {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}



#me-teams-form > div:last-child { display: flex; align-items: center; gap: 0.75rem; }
#me-teams-status { font-size: 0.88rem; }

/* ---------- tables ---------- */
.table-container { overflow-x: auto; }
.detail-table,
.standings-table,
.zaaldienst-table { font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.detail-table th,
.standings-table th,
.zaaldienst-table th {
    text-align: left;
    padding: 0.5rem 0.65rem;
    color: var(--text-2);
    font-weight: 650;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-strong);
    white-space: nowrap;
}
.detail-table td,
.standings-table td,
.zaaldienst-table td {
    padding: 0.55rem 0.65rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.detail-table tbody tr:hover td,
.standings-table tbody tr:hover td,
.zaaldienst-table tbody tr:hover td { background: var(--surface-2); }
.me-sub-row td { background: var(--amber-soft); }
.highlight-row td { background: var(--brand-softer); }
.de-spuyt-team { color: var(--brand-text); font-weight: 650; }
.duty-past td { color: var(--text-3); }
.duty-next {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 0.85rem;
    margin-bottom: 0.85rem;
    border-radius: var(--radius-md);
    background: var(--brand-soft);
    color: var(--brand-text);
    font-weight: 600;
}
.zaaldienst-venue { font-size: 0.9rem; font-weight: 400; color: var(--text-2); }

/* ---------- stats strip (Players tab) ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.1rem;
}
.stat-card {
    padding: 0.9rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--brand-text);
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}
.stat-label { font-size: 0.8rem; color: var(--text-2); margin-top: 0.15rem; }

.results-info { color: var(--text-2); font-size: 0.88rem; margin: 0.25rem 0 0.75rem; }

/* ---------- member cards (Players tab) ---------- */
.members-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.9rem;
}
.member-card {
    position: relative;
    padding: 1rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out), transform 200ms var(--ease-out);
}
.member-card:hover { border-color: var(--brand); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.member-card h3 { font-size: 1.02rem; }
.member-code { font-family: var(--mono); font-size: 0.78rem; color: var(--text-3); margin-top: 0.15rem; }
.member-team { color: var(--text-2); font-size: 0.88rem; margin-top: 0.35rem; display: flex; align-items: center; gap: 0.35rem; }
.member-team .icon { color: var(--brand); }
.member-sub-flag {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: var(--amber-soft);
    color: var(--amber);
    font-size: 0.75rem;
    font-weight: 650;
}
.card-stats { display: flex; gap: 0.4rem; margin-top: 0.85rem; flex-wrap: wrap; }
.stat-badge { background: var(--surface-2); color: var(--text-2); font-weight: 500; }
.stat-badge strong { color: var(--text); font-variant-numeric: tabular-nums; }
.stat-badge.is-sub { background: var(--amber-soft); color: var(--amber); }
.card-hint { margin-top: 0.8rem; color: var(--text-3); font-size: 0.82rem; }

/* member detail */
.member-detail-view { display: none; }
.detail-header {
    padding: 1.25rem 1.35rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}
.detail-info h2 { font-size: 1.35rem; margin-bottom: 0.4rem; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; color: var(--text-2); font-size: 0.9rem; }
.detail-meta .icon { color: var(--brand); }
.detail-meta code, .detail-code { font-family: var(--mono); background: none; padding: 0; }
.detail-content { display: flex; flex-direction: column; gap: 1rem; }
.detail-section { padding: 1.1rem 1.25rem; }
.detail-section h3 { margin-bottom: 0.75rem; }
.detail-table .matchup { font-weight: 500; }
.detail-table .vs { color: var(--text-3); margin: 0 0.4rem; }

/* ---------- programme (Upcoming games) ---------- */
.teams-loading,
.teams-error,
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.5rem;
    padding: 3rem 1.5rem;
    color: var(--text-2);
    grid-column: 1 / -1;
}
.teams-error { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.empty-state h2, .teams-error h3 { color: var(--text); }
.empty-icon, .error-icon { color: var(--brand); display: inline-flex; }
.empty-icon .icon, .error-icon .icon { width: 2.2rem; height: 2.2rem; }
.teams-error .error-icon { color: var(--red); }

.loading-spinner {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    border: 3px solid var(--brand-soft);
    border-top-color: var(--brand);
    animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.cache-info { margin-bottom: 1.1rem; }
.cache-info-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 0.6rem 0.55rem 1rem;
    font-size: 0.88rem;
    color: var(--text-2);
}
.cache-info-text { display: inline-flex; align-items: center; gap: 0.4rem; }
.cache-info-text .icon.ok { color: var(--green); }
.cache-info-text .icon.warn { color: var(--amber); }
.cache-refresh-btn { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

.date-group { margin-bottom: 1.5rem; }
.date-heading {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-3);
    background: var(--brand-softer);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    margin: 0 0 0.6rem;
}
/* Mijn wedstrijden: the date bar carries the tab-btn.active colors (user
   request); the Programma tab keeps the muted bar above. */
#mymatches-view .date-heading {
    background: var(--brand);
    color: var(--brand-ink);
    border-color: transparent;
    box-shadow: var(--shadow-sm);
}
.matches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.9rem;
}
.match-card {
    padding: 1rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.match-card.highlight { border-color: var(--border-strong); }
.match-header { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.match-time { font-weight: 650; color: var(--brand-text); font-variant-numeric: tabular-nums; }
.match-teams {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}
.match-teams .team { min-width: 0; }
.match-teams .team:last-child { text-align: right; }
.match-teams .team.de-spuyt { color: var(--brand-text); font-weight: 700; }
.match-vs { color: var(--text-3); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; }
.match-score { font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.match-sets { color: var(--text-2); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.match-location {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
    color: var(--text-2);
    font-size: 0.88rem;
}
.match-location .icon { color: var(--brand); margin-top: 0.15rem; }
.match-location-link { color: inherit; text-decoration: underline; text-decoration-color: var(--border-strong); }
.match-location-link:hover { color: var(--brand-text); text-decoration-color: currentColor; }
.match-link { font-size: 0.88rem; font-weight: 600; display: inline-flex; align-items: center; gap: 0.3rem; }

.mymatches-note { margin: -0.5rem 0 1rem; font-size: 0.9rem; }

/* presence inside a match card */
.presence {
    margin-top: 0.25rem;
    padding-top: 0.7rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.presence.is-mine { border-top-color: var(--brand-soft); }
.presence-label {
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--brand-text);
}
/* Present/absent: one capsule in two halves (M28), the segmented-pill language
   of the tabs and reaction chips. Green only for yes, red only for no (DESIGN.md). */
.presence-buttons { display: inline-flex; }
.presence-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.45rem 0.9rem;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.2;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    color: var(--text-2);
    transition: border-color 160ms var(--ease-out), background 160ms var(--ease-out), color 160ms var(--ease-out);
}
.presence-btn[data-presence="present"] { border-radius: 999px 0 0 999px; }
.presence-btn[data-presence="absent"] { border-radius: 0 999px 999px 0; margin-left: -1px; }
.presence-btn:hover, .presence-btn.is-active { z-index: 1; }
.presence-btn[data-presence="present"]:hover { border-color: var(--green); color: var(--green-text); }
.presence-btn[data-presence="absent"]:hover { border-color: var(--red); color: var(--red-text); }
.presence-btn.is-active.is-present { background: var(--green-soft); border-color: var(--green); color: var(--green-text); }
.presence-btn.is-active.is-absent { background: var(--red-soft); border-color: var(--red); color: var(--red-text); }
.presence-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-2);
    font-variant-numeric: tabular-nums;
}
.presence-who {
    background: none;
    border: none;
    color: var(--brand-text);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.15rem 0;
    text-decoration: underline;
    text-decoration-color: var(--border-strong);
}
.presence-who:hover { text-decoration-color: currentColor; }
.presence-panel h4 { font-size: 0.8rem; color: var(--text-2); margin: 0.5rem 0 0.3rem; text-transform: uppercase; letter-spacing: 0.04em; }
.presence-panel .me-list { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-top: 0; }
.presence-panel li.presence-present { border-color: var(--green); }
.presence-panel li.presence-absent { border-color: var(--red); color: var(--text-2); }
.presence-panel li .me-muted { font-size: 0.8rem; }

/* ---------- teams overview ---------- */
.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.9rem;
}
.overview-team { margin: 0; }
.overview-team .me-list { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
/* The name may take two lines (long full names, admin view); the role/jij
   badges sit beside it and, if too wide, wrap as a unit onto the next line
   instead of squeezing it. */
.overview-team .me-list li { flex-wrap: wrap; }
.overview-team .me-list li .ov-badges { display: inline-flex; gap: 0.4rem; white-space: nowrap; flex-shrink: 0; }
.overview-team h2 { display: flex; align-items: baseline; gap: 0.5rem; }
/* TC contact (D37): apart from the roster, bottom right of the team panel */
.overview-team .ov-tc { display: flex; justify-content: flex-end; align-items: center; gap: 0.4rem; margin: 0.6rem 0 0; font-size: 0.9rem; }
/* ClubCollect linking issue (D38, admins): warning icon, reason in the title */
.cc-warning { display: inline-flex; align-items: center; color: var(--amber); }
.cc-warning .icon { width: 1rem; height: 1rem; }
/* Divider between the women's (DS) and men's (HS) team cards (C43) */
.overview-grid .overview-sep { grid-column: 1 / -1; border: none; border-top: 1px solid var(--border); margin: 0.35rem 0; }
.overview-count { font-size: 0.85rem; font-weight: 500; margin-left: auto; }
#overview-note { margin: -0.25rem 0 1rem; font-size: 0.88rem; }

/* ---------- announcements (M23) ---------- */
.board-controls { margin-bottom: 1rem; }
.board-deleted-badge { background: var(--red-soft); color: var(--red-text); }
.board-post { margin-bottom: 0.9rem; }
.board-post h2 { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.board-meta { font-size: 0.85rem; margin: 0.15rem 0 0.6rem; }
.board-body { white-space: pre-line; overflow-wrap: anywhere; }
.board-actions { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.75rem; }
.board-reactions { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.board-buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.reaction-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.55rem;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    transition: border-color 160ms var(--ease-out), background 160ms var(--ease-out), color 160ms var(--ease-out);
}
.reaction-btn .icon { width: 1.05rem; height: 1.05rem; }
.reaction-btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-text); }
.reaction-btn.is-active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-text); }
.reaction-btn:disabled { cursor: default; opacity: 0.7; }
.board-form-row { display: flex; flex-direction: column; gap: 0.3rem; }
.board-form-row .me-muted { font-size: 0.82rem; }
#board-expires { width: auto; align-self: flex-start; }
.board-form-buttons { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.board-reply-form { margin-top: 0.75rem; border-top: 1px solid var(--border); padding-top: 0.75rem; }
#board-archive { margin-top: 1.25rem; }
#board-archive summary { cursor: pointer; font-weight: 650; padding: 0.25rem 0; }
#board-archive .board-post { opacity: 0.85; }

/* ---------- login ---------- */
.login-panel { max-width: 520px; margin: 2rem auto; }
.login-panel h2 { font-size: 1.4rem; }
.login-device {
    border: none;
    padding: 0;
    margin: 0 0 0.75rem;
}
.login-device legend { padding: 0; margin-bottom: 0.4rem; }
.login-device-option {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    margin-bottom: 0.4rem;
    cursor: pointer;
}
.login-device-option:has(input:checked) { border-color: var(--brand); background: var(--brand-softer); }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
    .container { padding: 0.75rem 0.75rem 2.5rem; }
    .header { flex-direction: column; align-items: stretch; padding: 0.85rem 1rem; }
    .header-actions { justify-content: flex-start; }
    .title { font-size: 1.25rem; }
    .brand-logo { width: 44px; height: 39px; }
    .tab-btn { padding: 0.55rem 0.8rem; font-size: 0.88rem; }
    /* Mobile: wrap instead of scroll, so every tab (incl. the right-aligned
       Instellingen and the admin Spelers) is visible and tappable; the buttons
       stretch to fill each line. */
    .tabs { flex-wrap: wrap; }
    .tab-btn { flex: 1 1 auto; }
    .panel, .team-section { padding: 1rem; }
    .match-teams { grid-template-columns: 1fr; text-align: left; }
    .match-teams .team:last-child { text-align: left; }
    .match-vs { display: none; }
    .me-teams-fixed { grid-template-columns: 1fr; gap: 0.15rem; }
    .me-teams-fixed dt { margin-top: 0.4rem; }
    .detail-header { flex-direction: column; }
    .select-input { width: 100%; min-width: 0; }
}

/* ===== Mijn wedstrijden: one row per match ===== */
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.82rem; }
.mm-rows { display: flex; flex-direction: column; gap: 0.4rem; }
.mm-row {
    display: grid;
    grid-template-columns: 7rem minmax(0, 1fr) minmax(0, 12rem) auto auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.92rem;
}
.mm-when { font-weight: 650; color: var(--brand-text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mm-teams { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mm-teams .is-own { font-weight: 700; color: var(--brand-text); }
.mm-dash { color: var(--text-3); margin: 0 0.15rem; }
.mm-coach-badge,
.mm-tc-badge {
    display: inline-block;
    margin-right: 0.3rem;
    padding: 0.05rem 0.4rem;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.2;
    vertical-align: middle;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand-text);
    white-space: nowrap;
}
.mm-loc { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.85rem; color: var(--text-2); }
.mm-loc .icon { color: var(--brand); }
.mm-presence { display: inline-flex; align-items: center; gap: 0.4rem; justify-self: end; min-width: 6.5rem; justify-content: flex-end; }
.presence-inline { display: inline-flex; align-items: center; }
.presence-inline .presence-counts { font-size: 0.8rem; color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 2.2rem; text-align: right; margin-left: 0.45rem; }
.presence-btn-sm { padding: 0.3rem 0.6rem; }
.presence-btn-sm .icon { width: 1rem; height: 1rem; }
.mm-detail-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: 0.75rem; }
.mm-detail-head h2 { font-size: 1.3rem; }
.mm-detail-presence .presence { margin: 0; padding: 0; border: none; }
#mm-roster h4 { font-size: 0.8rem; color: var(--text-2); margin: 0.75rem 0 0.35rem; text-transform: uppercase; letter-spacing: 0.04em; }
#mm-roster .me-list { margin-top: 0; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
#mm-roster .me-list li .me-muted { white-space: nowrap; font-size: 0.8rem; }
#mm-roster li.presence-present { border-color: var(--green); }
#mm-roster li.presence-absent { border-color: var(--red); color: var(--text-2); }
@media (max-width: 860px) {
    .mm-row { grid-template-columns: 6rem minmax(0, 1fr) auto; grid-template-areas: "when teams presence" "loc loc details"; row-gap: 0.35rem; }
    .mm-when { grid-area: when; }
    .mm-teams { grid-area: teams; white-space: normal; }
    .mm-loc { grid-area: loc; }
    .mm-presence { grid-area: presence; }
    .mm-details-btn { grid-area: details; justify-self: end; }
}

/* invitations */
.match-level.is-invited { background: var(--brand-soft); color: var(--brand-text); }
.mm-invite-search { margin: 0.5rem 0 0.6rem; max-width: 420px; }
/* Position filter chips (C42): checkboxes that narrow the candidate list */
.mm-cap-filters { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0 0 0.75rem; }
.mm-cap-filter {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.mm-cap-filter.is-on { background: var(--brand-soft); color: var(--brand-text); border-color: transparent; }
.mm-cap-filter input { accent-color: var(--brand); margin: 0; }
.mm-candidates { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.mm-candidates li { justify-content: space-between; }
#mm-invite h4 { margin-top: 1.25rem; }
