/* ==========================================================================
   Club Voleibol Encamp · tauler de gestió
   Paleta presa de l'escut del club: blau #186090, daurat #f0d800,
   blau marí #091f5a de la web. Sense dependències ni pas de compilació.
   ========================================================================== */

:root {
    /* Marca */
    --navy-900: #061634;
    --navy-800: #091f5a;
    --navy-700: #0e2f6b;
    --brand-700: #124e78;
    --brand-600: #186090;
    --brand-500: #1e78b0;
    --brand-100: #e2eef6;
    --brand-050: #f2f8fc;
    --gold-600: #c9a300;
    --gold-500: #f0c81e;
    --gold-400: #ffde59;
    --gold-100: #fff6d9;

    /* Neutres */
    --ink-900: #10151f;
    --ink-700: #313c4f;
    --ink-500: #5c6a80;
    --ink-400: #8494a8;
    --ink-300: #b9c4d1;
    --ink-200: #dde3ea;
    --ink-100: #eef1f5;
    --ink-050: #f6f8fa;
    --white: #fff;

    /* Estats */
    --ok-600: #17794a;
    --ok-100: #dcf5e7;
    --warn-700: #8a5300;
    --warn-100: #fdefd2;
    --bad-600: #c02a2a;
    --bad-100: #fbe3e3;
    --info-600: #1b6ba8;
    --info-100: #e0eefb;

    --radius: 10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(16, 21, 31, .06), 0 1px 3px rgba(16, 21, 31, .04);
    --shadow-md: 0 4px 12px rgba(16, 21, 31, .08);
    --shadow-lg: 0 12px 32px rgba(16, 21, 31, .14);
    --sidebar-w: 250px;
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink-900);
    background: var(--ink-050);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; letter-spacing: -.011em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 1rem; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.visually-hidden {
    position: absolute; width: 1px; height: 1px;
    margin: -1px; padding: 0; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Estructura ---------------------------------------------------------- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: linear-gradient(180deg, var(--navy-800) 0%, var(--navy-900) 100%);
    color: #cfd9ea;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: 1.15rem 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.sidebar__brand img { width: 40px; height: 40px; flex: 0 0 40px; }

.sidebar__brand-text { min-width: 0; }
.sidebar__brand-name {
    display: block; color: var(--white); font-weight: 650;
    font-size: .93rem; line-height: 1.2;
}
.sidebar__brand-sub {
    display: block; font-size: .72rem; color: #8fa3c4;
    text-transform: uppercase; letter-spacing: .06em; margin-top: .15rem;
}

.sidebar__nav { padding: .85rem .65rem; flex: 1; }

.sidebar__group + .sidebar__group { margin-top: 1.1rem; }

.sidebar__group-title {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: #7c8fb0;
    font-weight: 650;
    padding: 0 .5rem .35rem;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .55rem;
    border-radius: var(--radius-sm);
    color: #cfd9ea;
    font-size: .89rem;
    font-weight: 500;
    margin-bottom: 1px;
}
.sidebar__link:hover { background: rgba(255, 255, 255, .08); color: var(--white); text-decoration: none; }
.sidebar__link.is-active {
    background: rgba(255, 255, 255, .13);
    color: var(--white);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--gold-400);
}
.sidebar__link svg { width: 17px; height: 17px; flex: 0 0 17px; opacity: .85; }
.sidebar__link.is-active svg { opacity: 1; }

.sidebar__footer {
    padding: .8rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, .1);
    font-size: .78rem;
    color: #8fa3c4;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .7rem 1.5rem;
    background: var(--white);
    border-bottom: 1px solid var(--ink-200);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar__title { font-size: 1rem; font-weight: 650; margin: 0; }
.topbar__spacer { flex: 1; }

.topbar__season {
    font-size: .78rem;
    color: var(--ink-500);
    background: var(--ink-100);
    padding: .25rem .6rem;
    border-radius: 100px;
    font-weight: 600;
    white-space: nowrap;
}

.content { padding: 1.5rem; max-width: 1400px; width: 100%; }

.page-head {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.15rem;
}
.page-head__text { flex: 1; min-width: 240px; }
.page-head p { color: var(--ink-500); margin: .15rem 0 0; font-size: .89rem; }
.page-head__actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* --- Menú d'usuari ------------------------------------------------------- */

.menu { position: relative; }

.menu__toggle {
    display: flex; align-items: center; gap: .5rem;
    background: none; border: 1px solid var(--ink-200);
    border-radius: 100px; padding: .28rem .7rem .28rem .3rem;
    cursor: pointer; font: inherit; font-size: .85rem; color: var(--ink-700);
}
.menu__toggle:hover { background: var(--ink-050); }

.avatar {
    width: 27px; height: 27px; border-radius: 50%;
    background: var(--brand-600); color: var(--white);
    display: grid; place-items: center;
    font-size: .72rem; font-weight: 700; letter-spacing: .02em;
}

.menu__panel {
    position: absolute; right: 0; top: calc(100% + .4rem);
    background: var(--white); border: 1px solid var(--ink-200);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    min-width: 210px; padding: .35rem; z-index: 40;
}

.menu__header {
    padding: .5rem .6rem; border-bottom: 1px solid var(--ink-100);
    margin-bottom: .3rem;
}
.menu__name { font-weight: 600; font-size: .87rem; }
.menu__email { font-size: .76rem; color: var(--ink-500); word-break: break-all; }

.menu__item {
    display: flex; align-items: center; gap: .5rem;
    width: 100%; text-align: left;
    padding: .45rem .6rem; border-radius: var(--radius-sm);
    color: var(--ink-700); font-size: .87rem;
    background: none; border: 0; cursor: pointer; font-family: inherit;
}
.menu__item:hover { background: var(--ink-050); text-decoration: none; }
.menu__item--danger { color: var(--bad-600); }

.menu__sep { height: 1px; background: var(--ink-100); margin: .3rem 0; }

.menu__lang { display: flex; gap: .2rem; padding: .35rem .3rem; }
.menu__lang a {
    flex: 1; text-align: center; padding: .28rem 0;
    border-radius: var(--radius-sm); font-size: .76rem;
    font-weight: 600; color: var(--ink-500); text-transform: uppercase;
}
.menu__lang a:hover { background: var(--ink-050); text-decoration: none; }
.menu__lang a.is-active { background: var(--brand-600); color: var(--white); }

/* --- Targetes ------------------------------------------------------------ */

.card {
    background: var(--white);
    border: 1px solid var(--ink-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.15rem;
}

.card__head {
    display: flex; align-items: center; gap: .75rem;
    padding: .85rem 1.1rem;
    border-bottom: 1px solid var(--ink-100);
}
.card__head h2, .card__head h3 { margin: 0; }
.card__head-actions { margin-left: auto; display: flex; gap: .45rem; }
.card__body { padding: 1.1rem; }
.card__body--flush { padding: 0; }
.card__foot {
    padding: .7rem 1.1rem; border-top: 1px solid var(--ink-100);
    background: var(--ink-050);
    border-radius: 0 0 var(--radius) var(--radius);
}

/* --- Indicadors ---------------------------------------------------------- */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
    gap: .85rem;
    margin-bottom: 1.3rem;
}

.stat {
    background: var(--white);
    border: 1px solid var(--ink-200);
    border-radius: var(--radius);
    padding: .95rem 1.05rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.stat::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: var(--brand-600);
}
.stat--gold::before { background: var(--gold-500); }
.stat--ok::before { background: var(--ok-600); }
.stat--warn::before { background: var(--warn-700); }
.stat--bad::before { background: var(--bad-600); }

.stat__label {
    font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--ink-500); font-weight: 650;
}
.stat__value {
    font-size: 1.75rem; font-weight: 700; line-height: 1.15;
    margin-top: .2rem; letter-spacing: -.02em;
}
.stat__hint { font-size: .78rem; color: var(--ink-500); margin-top: .1rem; }

/* --- Taules -------------------------------------------------------------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: .87rem;
}

table.data th {
    text-align: left;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ink-500);
    font-weight: 650;
    padding: .6rem .8rem;
    border-bottom: 1px solid var(--ink-200);
    background: var(--ink-050);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

table.data td {
    padding: .6rem .8rem;
    border-bottom: 1px solid var(--ink-100);
    vertical-align: middle;
}

table.data tbody tr:hover { background: var(--brand-050); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .actions { text-align: right; white-space: nowrap; }
table.data .shrink { width: 1%; white-space: nowrap; }

/* Capçaleres que ordenen. La fletxa només es veu del tot a la columna
   activa; a la resta apareix en passar-hi per sobre, per no omplir la
   capçalera de símbols. */
table.data th.is-sortable {
    cursor: pointer;
    user-select: none;
    padding-right: 1rem;
}

table.data th.is-sortable:hover { color: var(--brand-600); }

table.data th.is-sortable::after {
    content: '\25BE';
    display: inline-block;
    margin-left: .35rem;
    font-size: .7rem;
    opacity: 0;
    transition: opacity .12s ease;
}

table.data th.is-sortable:hover::after,
table.data th.is-sortable:focus-visible::after { opacity: .4; }

table.data th[aria-sort]::after {
    opacity: 1;
    color: var(--brand-600);
}

table.data th[aria-sort="ascending"]::after { content: '\25B4'; }

/* Tirador per amidar la columna, a la vora dreta de la capçalera. */
.col-resize {
    position: absolute;
    top: 0;
    right: 0;
    width: 12px;
    height: 100%;
    cursor: col-resize;
    touch-action: none;
    z-index: 2;
}

/* La vora es veu sempre, fluixa: és el que fa endevinar que es pot
   arrossegar. En passar-hi per sobre es marca, i mentre s'arrossega
   s'encén del color de la marca. */
.col-resize::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 22%;
    height: 56%;
    width: 2px;
    border-radius: 2px;
    background: var(--ink-200);
    transition: background .12s;
}

table.data th:hover .col-resize::after { background: var(--ink-400); }
.col-resize:hover::after,
body.is-resizing-column .col-resize::after { background: var(--brand-600); }

body.is-resizing-column,
body.is-resizing-column * {
    cursor: col-resize !important;
    user-select: none;
}

/* Un cop s'amida una columna, l'amplada mana sobre el càlcul automàtic.
   La taula pot passar de l'ample disponible: per això el contenidor
   es pot desplaçar de costat. */
table.data.is-resized {
    table-layout: fixed;
    width: auto;
    min-width: 100%;
}

table.data.is-resized th {
    overflow: hidden;
    text-overflow: ellipsis;
}

table.data.is-resized td { overflow-wrap: anywhere; }

/* Amplades mínimes de les columnes que més pateixen quan la taula té
   moltes columnes. Sense això, el navegador escanya el nom fins a partir-lo
   en tres línies i la fila creix el triple; val més que la taula es pugui
   desplaçar de costat, o que qui vulgui una altra repartició eixampli les
   columnes ell mateix. */
table.data td:first-child,
table.data th:first-child { min-width: 190px; }

table.data .col-teams { min-width: 150px; }

/* Un cop s'han amidat les columnes a mà, mana el que s'hagi triat. */
table.data.is-resized td:first-child,
table.data.is-resized th:first-child,
table.data.is-resized .col-teams { min-width: 0; }

.table-name { font-weight: 600; color: var(--ink-900); }
.table-sub { font-size: .78rem; color: var(--ink-500); }


/* Seccions d'un departament, dins de la graella de permisos. */
.section-row td { background: var(--ink-050); padding-top: .5rem; padding-bottom: .6rem; }

.section-picker {
    display: flex; align-items: center; gap: .15rem 1rem; flex-wrap: wrap;
}

.section-picker__label {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--ink-500); font-weight: 650; margin-right: .3rem;
}

.section-picker .check { font-size: .82rem; }

.section-row.is-muted { opacity: .45; }

/* --- Calendari de partits ------------------------------------------------ */

.calendar-bar {
    display: flex; align-items: center; gap: .9rem; flex-wrap: wrap;
    padding: .7rem 1.15rem;
    border-top: 1px solid var(--ink-100);
}

.calendar-bar__spacer { flex: 1 1 auto; }

.calendar-legend {
    display: flex; align-items: center; gap: .4rem;
    margin: 0; font-size: .8rem; color: var(--ink-500);
}

.calendar-legend__key {
    width: 11px; height: 11px; border-radius: 3px; display: inline-block;
}

.calendar-legend__key--home { background: var(--navy-800); }
.calendar-legend__key--away { background: var(--white); border: 1.5px solid var(--ink-300); }
.calendar-legend__key--away + span { margin-left: .2rem; }

/* Commutador de vista: dues pestanyes petites, com les de quotes però
   dins de la barra d'eines. */
.view-switch {
    display: flex; gap: .15rem;
    background: var(--ink-100); border-radius: var(--radius-sm); padding: .15rem;
}

.view-switch a {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .35rem .7rem; border-radius: calc(var(--radius-sm) - 2px);
    font-size: .82rem; font-weight: 600; color: var(--ink-500);
}

.view-switch a:hover { color: var(--ink-900); text-decoration: none; }

.view-switch a.is-active {
    background: var(--white); color: var(--navy-800);
    box-shadow: var(--shadow-sm);
}

/* Dues graelles de mes de costat, que és com es mira un calendari: el mes
   que ve importa tant com aquest. */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
    gap: 1.15rem;
    margin-bottom: 1.15rem;
}

.calendar-month__body { padding: .6rem .75rem 1rem; }

.calendar-week,
.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-week { margin-bottom: .3rem; }

.calendar-week__day {
    text-align: center;
    font-size: .7rem; text-transform: lowercase; letter-spacing: .04em;
    color: var(--ink-400); font-weight: 650;
    text-decoration: none; border: 0;
}

.calendar-days { gap: 2px; }

.calendar-day {
    min-height: 68px;
    padding: .3rem .3rem .35rem;
    border-radius: var(--radius-sm);
    background: var(--white);
    border: 1px solid var(--ink-100);
    display: flex; flex-direction: column; gap: .2rem;
}

.calendar-day--outside { background: var(--ink-050); border-color: transparent; }
.calendar-day--outside .calendar-day__number { color: var(--ink-300); }

.calendar-day--today {
    border-color: var(--brand-500);
    box-shadow: 0 0 0 1px var(--brand-500);
}

.calendar-day__number {
    font-size: .72rem; font-weight: 650; color: var(--ink-500);
    line-height: 1;
}

.calendar-day--today .calendar-day__number { color: var(--brand-600); }

/* Un partit dins d'una casella. A casa, ple; a fora, buit amb la vora
   marcada: es distingeixen sense haver de llegir res. */
.calendar-chip {
    display: block;
    padding: .2rem .35rem;
    border-radius: 4px;
    font-size: .68rem; line-height: 1.25;
    border: 1px solid transparent;
    overflow: hidden;
}

.calendar-chip:hover { text-decoration: none; filter: brightness(1.08); }

.calendar-chip__name {
    display: block;
    font-weight: 650;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.calendar-chip__time { display: block; opacity: .85; font-variant-numeric: tabular-nums; }

.calendar-chip--home {
    background: var(--navy-800); color: var(--white);
}

.calendar-chip--away {
    background: var(--white); color: var(--navy-800);
    border-color: var(--ink-300);
}

/* --- Fitxes de partit ---------------------------------------------------- */

.match-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
    gap: 1.15rem;
    align-items: start;
}

.match-month__title {
    font-size: .74rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--ink-500); margin: 0 0 .6rem;
}

.match-card {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: .6rem;
    padding: .8rem .9rem;
    margin-bottom: .6rem;
    background: var(--white);
    border: 1px solid var(--ink-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.match-card--cancelled { opacity: .6; }
.match-card--postponed { border-style: dashed; }

.match-card__side {
    display: flex; align-items: center; gap: .5rem;
    min-width: 0;
}

.match-card__side--right { justify-content: flex-end; }

.match-card__team {
    font-size: .84rem; font-weight: 600; color: var(--ink-900);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.match-card__crest { width: 26px; height: 26px; object-fit: contain; flex: none; }

.match-card__crest--rival {
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--ink-100); color: var(--ink-500);
    font-size: .62rem; font-weight: 700; letter-spacing: .02em;
}

.match-card__middle {
    display: flex; flex-direction: column; align-items: center; gap: .15rem;
    text-align: center; white-space: nowrap;
}

.match-card__vs {
    font-size: .72rem; font-weight: 700; color: var(--ink-400);
    text-transform: uppercase; letter-spacing: .06em;
}

.match-card--played .match-card__vs { color: var(--ink-900); font-size: .95rem; }

.match-card__when {
    font-size: .74rem; color: var(--ink-500); font-variant-numeric: tabular-nums;
}

.match-card__meta {
    grid-column: 1 / -1;
    display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
    padding-top: .55rem; margin-top: .15rem;
    border-top: 1px solid var(--ink-100);
}

.match-card__meta .btn { margin-left: auto; }

table.data tr.is-today td { background: var(--brand-050); }

@media (max-width: 620px) {
    .calendar-day { min-height: 58px; }
    .calendar-chip__time { display: none; }
    .match-card { grid-template-columns: 1fr; text-align: left; }
    .match-card__side--right { justify-content: flex-start; }
    .match-card__middle { flex-direction: row; gap: .5rem; align-self: flex-start; }
}

/* --- Distintius ---------------------------------------------------------- */

.badge {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .16rem .5rem;
    border-radius: 100px;
    font-size: .74rem;
    font-weight: 650;
    line-height: 1.5;
    white-space: nowrap;
    background: var(--ink-100);
    color: var(--ink-700);
}
.badge--ok { background: var(--ok-100); color: var(--ok-600); }
.badge--warn { background: var(--warn-100); color: var(--warn-700); }
.badge--bad { background: var(--bad-100); color: var(--bad-600); }
.badge--info { background: var(--info-100); color: var(--info-600); }
.badge--gold { background: var(--gold-100); color: var(--gold-600); }
.badge--muted { background: var(--ink-100); color: var(--ink-500); }
.badge--navy { background: var(--navy-800); color: var(--white); }

.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* --- Botons -------------------------------------------------------------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .45rem .85rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--ink-200);
    background: var(--white);
    color: var(--ink-700);
    font: inherit; font-size: .86rem; font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--ink-050); border-color: var(--ink-300); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

.btn--primary {
    background: var(--brand-600); border-color: var(--brand-600); color: var(--white);
}
.btn--primary:hover { background: var(--brand-700); border-color: var(--brand-700); }

.btn--gold {
    background: var(--gold-400); border-color: var(--gold-500); color: #3d3000;
}
.btn--gold:hover { background: var(--gold-500); }

.btn--danger { color: var(--bad-600); border-color: #f0c4c4; background: var(--white); }
.btn--danger:hover { background: var(--bad-100); border-color: var(--bad-600); }

.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--ink-100); }

.btn--sm { padding: .27rem .6rem; font-size: .79rem; }
.btn--icon { padding: .35rem; }
.btn--block { width: 100%; }

.btn-group { display: inline-flex; gap: .35rem; }

/* --- Formularis ---------------------------------------------------------- */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
}
.form-grid--full { grid-template-columns: 1fr; }
.span-2 { grid-column: span 2; }
@media (max-width: 620px) { .span-2 { grid-column: span 1; } }

.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }

.field label, .label {
    font-size: .81rem;
    font-weight: 600;
    color: var(--ink-700);
}
.field .hint { font-size: .77rem; color: var(--ink-500); }
.field .error { font-size: .77rem; color: var(--bad-600); font-weight: 550; }
.field .optional { font-weight: 400; color: var(--ink-400); }

input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="number"], input[type="search"], input[type="tel"], input[type="file"],
select, textarea {
    width: 100%;
    padding: .48rem .65rem;
    border: 1px solid var(--ink-300);
    border-radius: var(--radius-sm);
    background: var(--white);
    font: inherit;
    font-size: .88rem;
    color: var(--ink-900);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(30, 120, 176, .15);
}
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] {
    border-color: var(--bad-600);
}
input:disabled, select:disabled, textarea:disabled {
    background: var(--ink-050); color: var(--ink-500); cursor: not-allowed;
}
textarea { min-height: 84px; resize: vertical; }
input[type="file"] { padding: .35rem; font-size: .83rem; }

.check {
    display: flex; align-items: flex-start; gap: .5rem;
    font-size: .87rem; cursor: pointer; font-weight: 500;
}
.check input { width: 16px; height: 16px; margin: .16rem 0 0; flex: 0 0 16px; accent-color: var(--brand-600); cursor: pointer; }

.form-actions {
    display: flex; gap: .5rem; flex-wrap: wrap;
    padding-top: 1.05rem; margin-top: 1.05rem;
    border-top: 1px solid var(--ink-100);
}
.form-actions--right { justify-content: flex-end; }

fieldset {
    border: 1px solid var(--ink-200);
    border-radius: var(--radius);
    padding: 1rem;
    margin: 0 0 1.15rem;
}
legend {
    font-size: .81rem; font-weight: 650; padding: 0 .4rem;
    color: var(--ink-700); text-transform: uppercase; letter-spacing: .04em;
}

/* --- Etiquetes seleccionables (assistents) -------------------------------- */

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-top: .45rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .55rem;
    border: 1px solid var(--ink-300);
    border-radius: 100px;
    font-size: .79rem;
    font-weight: 550;
    color: var(--ink-700);
    background: var(--white);
    cursor: pointer;
    user-select: none;
    transition: background .12s, border-color .12s, color .12s;
}
.chip:hover { background: var(--ink-050); border-color: var(--ink-400); }

/* Distintius dins d'una cel·la: sense el marge de sobre ni el subratllat
   de l'enllaç, que en una taula fan nosa.

   Cadascun ocupa una línia i el que no hi cap es retalla amb punts
   suspensius, en comptes de partir el nom en dos i fer créixer la fila.
   Qui vulgui llegir-los sencers eixampla la columna. */
.chips--inline { margin-top: 0; gap: .25rem; }

.chips--inline .chip {
    display: inline-block;
    max-width: 100%;
    padding: .08rem .45rem;
    font-size: .74rem;
    line-height: 1.55;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

a.chip, a.chip:hover { text-decoration: none; }
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip.is-on {
    background: var(--brand-600);
    border-color: var(--brand-600);
    color: var(--white);
}
.chip:focus-within { outline: 2px solid var(--brand-500); outline-offset: 2px; }

/* --- Filtres ------------------------------------------------------------- */

.filters {
    display: flex;
    gap: .6rem;
    flex-wrap: wrap;
    align-items: flex-end;
    padding: .85rem 1.1rem;
    border-bottom: 1px solid var(--ink-100);
    background: var(--ink-050);
    border-radius: var(--radius) var(--radius) 0 0;
}
.filters .field { min-width: 145px; }
.filters .field--grow { flex: 1; min-width: 210px; }
.filters .field label { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-500); }

/* --- Fotografies de persones --------------------------------------------- */

.photo { display: flex; flex-direction: column; align-items: flex-start; gap: .5rem; }

.photo__frame {
    display: block;
    width: 128px;
    height: 128px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--ink-200);
    background: var(--ink-050);
}
.photo__frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo__frame--empty { display: grid; place-items: center; color: var(--ink-300); }

.photo__warning {
    display: flex;
    align-items: flex-start;
    gap: .3rem;
    margin: 0;
    font-size: .75rem;
    line-height: 1.35;
    color: var(--warn-700);
    max-width: 190px;
}

.photo__actions { margin: 0; }
.photo .btn { cursor: pointer; }

/* Avatar petit per als llistats. */
.avatar-photo {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 34px;
    border: 1px solid var(--ink-200);
    background: var(--ink-050);
}
.avatar-photo--empty { display: grid; place-items: center; color: var(--ink-300); }

.name-cell { display: flex; align-items: center; gap: .55rem; }

/* --- Filtres de la llista d'atletes disponibles --------------------------- */

.roster-filters {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    padding-bottom: .7rem;
    margin-bottom: .7rem;
    border-bottom: 1px solid var(--ink-100);
}
.roster-filters input[type="search"] { font-size: .84rem; padding: .35rem .55rem; }
.roster-filters .btn { flex: 0 0 auto; }

/* Les que no encaixen amb la categoria es veuen, però apagades. */
.check.muted span { color: var(--ink-400); }

/* --- Biblioteca de documents --------------------------------------------- */

.doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 1rem;
}

.doc {
    border: 1px solid var(--ink-200);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--white);
    display: flex;
    flex-direction: column;
    transition: border-color .12s, box-shadow .12s;
}
.doc:hover { border-color: var(--ink-300); box-shadow: var(--shadow-md); }

.doc__preview {
    display: grid;
    place-items: center;
    height: 148px;
    background: var(--ink-050);
    border-bottom: 1px solid var(--ink-100);
    overflow: hidden;
}
.doc__preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.doc__preview:hover { text-decoration: none; }

.doc__icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .3rem;
    color: var(--ink-400);
}
.doc__ext {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .06em;
    color: var(--ink-500);
}

.doc__body {
    padding: .75rem .85rem .85rem;
    display: flex;
    flex-direction: column;
    gap: .45rem;
    flex: 1;
}

.doc__title {
    font-size: .92rem;
    margin: 0;
    line-height: 1.3;
    /* Dues línies com a màxim: els títols llargs no han de descolocar la graella. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.doc__meta {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .76rem;
    color: var(--ink-500);
}

.doc__desc {
    font-size: .8rem;
    color: var(--ink-500);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.doc__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .4rem;
    margin-top: auto;
    padding-top: .5rem;
    border-top: 1px solid var(--ink-100);
}

.doc__edit {
    border-top: 1px solid var(--ink-100);
    padding-top: .6rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

/* --- Avisos -------------------------------------------------------------- */

.flashes { margin-bottom: 1.15rem; display: flex; flex-direction: column; gap: .55rem; }

.alert {
    display: flex; align-items: flex-start; gap: .6rem;
    padding: .7rem .9rem;
    border-radius: var(--radius);
    font-size: .87rem;
    border: 1px solid transparent;
}
.alert svg { width: 17px; height: 17px; flex: 0 0 17px; margin-top: .1rem; }
.alert--success { background: var(--ok-100); color: var(--ok-600); border-color: #b6e6cd; }
.alert--error { background: var(--bad-100); color: var(--bad-600); border-color: #f3c8c8; }
.alert--warning { background: var(--warn-100); color: var(--warn-700); border-color: #f5dcac; }
.alert--info { background: var(--info-100); color: var(--info-600); border-color: #c3dff5; }

.empty {
    text-align: center;
    padding: 2.6rem 1.5rem;
    color: var(--ink-500);
}
.empty svg { width: 38px; height: 38px; color: var(--ink-300); margin-bottom: .6rem; }
.empty h3 { color: var(--ink-700); }
.empty p { max-width: 380px; margin: .25rem auto 1rem; font-size: .88rem; }

/* --- Fitxes de detall ---------------------------------------------------- */

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: .95rem 1.4rem;
}

.detail dt {
    font-size: .73rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--ink-500); font-weight: 650; margin-bottom: .1rem;
}
.detail dd { margin: 0; font-size: .9rem; word-break: break-word; }

.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 1.15rem; align-items: start; }
@media (max-width: 960px) { .two-col { grid-template-columns: 1fr; } }

/* --- Paginació ----------------------------------------------------------- */

.pagination {
    display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
    font-size: .84rem; color: var(--ink-500);
}
.pagination__spacer { flex: 1; }

/* --- Accés --------------------------------------------------------------- */

.login {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        radial-gradient(1100px 520px at 15% -10%, rgba(30, 120, 176, .35), transparent 60%),
        linear-gradient(160deg, var(--navy-800) 0%, var(--navy-900) 100%);
}

.login__card {
    width: 100%;
    max-width: 405px;
    background: var(--white);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    padding: 2rem 1.85rem;
}

.login__logo { display: block; width: 74px; height: 74px; margin: 0 auto .9rem; }
.login__title { text-align: center; font-size: 1.2rem; margin-bottom: .15rem; }
.login__sub { text-align: center; color: var(--ink-500); font-size: .86rem; margin-bottom: 1.35rem; }
.login__fields { display: flex; flex-direction: column; gap: .85rem; }
.login__foot {
    margin-top: 1.35rem; padding-top: 1rem;
    border-top: 1px solid var(--ink-100);
    text-align: center; font-size: .78rem; color: var(--ink-400);
}
.login__lang { display: flex; justify-content: center; gap: .3rem; margin-top: .6rem; }
.login__lang a {
    padding: .15rem .45rem; border-radius: 4px;
    font-size: .74rem; font-weight: 600; color: var(--ink-400); text-transform: uppercase;
}
.login__lang a.is-active { background: var(--brand-100); color: var(--brand-700); }

/* --- Pàgina d'error ------------------------------------------------------ */

.error-page { text-align: center; padding: 3.5rem 1.5rem; }
.error-page__code {
    font-size: 3.6rem; font-weight: 750; color: var(--ink-300);
    line-height: 1; letter-spacing: -.03em;
}
.error-page h1 { margin: .6rem 0 .35rem; }
.error-page p { color: var(--ink-500); max-width: 440px; margin: 0 auto 1.4rem; }

/* --- Utilitats ----------------------------------------------------------- */

.muted { color: var(--ink-500); }
.small { font-size: .81rem; }
.strong { font-weight: 650; }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.flex { display: flex; gap: .5rem; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.text-right { text-align: right; }
.hide { display: none !important; }

.tabs {
    display: flex; gap: .2rem; flex-wrap: wrap;
    border-bottom: 1px solid var(--ink-200);
    margin-bottom: 1.15rem;
}
.tabs a {
    padding: .5rem .85rem;
    font-size: .87rem; font-weight: 600; color: var(--ink-500);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tabs a:hover { color: var(--ink-900); text-decoration: none; }
.tabs a.is-active { color: var(--brand-600); border-bottom-color: var(--brand-600); }

.progress {
    height: 6px; border-radius: 100px; background: var(--ink-100);
    overflow: hidden; min-width: 70px;
}
.progress__bar { height: 100%; background: var(--ok-600); border-radius: 100px; }

/* --- Mòbil --------------------------------------------------------------- */

.sidebar__close, .nav-toggle { display: none; }

@media (max-width: 900px) {
    .sidebar {
        position: fixed; inset: 0 auto 0 0; z-index: 60;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: var(--shadow-lg);
    }
    body.nav-open .sidebar { transform: translateX(0); }

    .nav-toggle {
        display: inline-flex; align-items: center; justify-content: center;
        width: 36px; height: 36px; padding: 0;
        border: 1px solid var(--ink-200); border-radius: var(--radius-sm);
        background: var(--white); cursor: pointer; color: var(--ink-700);
    }
    .sidebar__close {
        display: inline-flex; margin-left: auto;
        background: none; border: 0; color: #cfd9ea;
        font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 0 .2rem;
    }

    .nav-backdrop {
        position: fixed; inset: 0; z-index: 50;
        background: rgba(6, 22, 52, .5);
    }

    .content { padding: 1.1rem; }
    .topbar { padding: .6rem 1.1rem; }
    .topbar__season { display: none; }
}

/* --- Taules com a fitxes al mòbil ---------------------------------------- */

@media (max-width: 760px) {
    /* Amb moltes columnes, el desplaçament lateral no serveix de res: cada
       fila passa a ser una fitxa amb l'etiqueta al davant de cada valor.
       Les etiquetes les posa el JS a partir de l'encapçalament. */
    table.data thead { display: none; }

    table.data,
    table.data tbody,
    table.data tr,
    table.data td { display: block; width: 100%; }

    table.data tr {
        border: 1px solid var(--ink-200);
        border-radius: var(--radius);
        padding: .6rem .75rem;
        margin-bottom: .6rem;
        background: var(--white);
    }
    table.data tbody tr:hover { background: var(--white); }

    table.data td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: .75rem;
        padding: .3rem 0;
        border: 0;
        text-align: right;
    }

    table.data td[data-label]::before {
        content: attr(data-label);
        flex: 0 0 auto;
        font-size: .7rem;
        font-weight: 650;
        text-transform: uppercase;
        letter-spacing: .04em;
        color: var(--ink-500);
        text-align: left;
    }

    /* La primera cel·la fa de títol de la fitxa. */
    table.data td:first-child {
        display: block;
        text-align: left;
        padding-bottom: .5rem;
        margin-bottom: .35rem;
        border-bottom: 1px solid var(--ink-100);
        font-size: .95rem;
    }
    /* El nom fa de títol de la fitxa: no li cal etiqueta, ni tan sols quan
       porta una segona línia i entra a la regla d'apilat. */
    table.data td:first-child::before,
    table.data td:first-child[data-stack]::before { display: none; }

    table.data td[data-empty] { display: none; }

    table.data td[data-stack] {
        display: block;
        text-align: left;
    }
    table.data td[data-stack]::before {
        display: block;
        margin-bottom: .15rem;
    }

    table.data td.actions,
    table.data td.num { text-align: right; }
    table.data td.actions .btn-group { justify-content: flex-end; }

    table.data input[type="text"],
    table.data input[type="number"],
    table.data select { max-width: 60%; }

    .table-wrap { overflow-x: visible; }
}

/* El botó de plegar filtres només té sentit en pantalla estreta. */
.filters__toggle { display: none; }

@media (max-width: 620px) {
    .filters { flex-direction: column; align-items: stretch; }

    .filters__toggle { display: block; order: -1; }

    /* Es deixa veure la cerca i els botons; la resta, plegada. */
    .filters .field:not(.field--grow) { display: none; }
    .filters .check { display: none; }
    .filters.is-open .field:not(.field--grow),
    .filters.is-open .check { display: flex; }
    .filters.is-open .field:not(.field--grow) { flex-direction: column; }
    .filters .field, .filters .field--grow { min-width: 0; }
    .stat__value { font-size: 1.5rem; }
    .page-head__actions { width: 100%; }
    .page-head__actions .btn { flex: 1; }

    /* Que hi càpiguen dos indicadors per fila en comptes d'un. */
    .stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; }
    .stat { padding: .7rem .8rem; }
    .stat__label { font-size: .68rem; }

    .card__head { flex-wrap: wrap; gap: .5rem; }
    .card__head-actions { margin-left: 0; }

    .doc-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem; }

    .form-actions .btn { flex: 1; }

    .photo__frame { width: 104px; height: 104px; }

    h1 { font-size: 1.35rem; }
}

@media print {
    .sidebar, .topbar, .filters, .page-head__actions, .form-actions, .pagination { display: none !important; }
    body { background: #fff; }
    .card { border: 0; box-shadow: none; }
    .content { padding: 0; max-width: none; }
}
