/* FatTito read-only site.
   Colours from the logo: navy (text, header accents) and orange (active tab, leader). Light page, white cards,
   tabular numbers. Layout mirrors the live site's grids; narrow screens use the "..." mini detail (tables.js). */

:root {
    --navy: #1f2a44;
    --navy-soft: #3a4766;
    --orange: #e8681d;
    --orange-soft: #fdeee4;
    --page: #f1f2f5;
    --card: #ffffff;
    --line: #e1e4ea;
    --line-soft: #eef0f4;
    --text: #222b3a;
    --muted: #7a8396;
    --trend-up: #1f8a4c;
    --trend-up-bg: #dff2e6;
    --trend-down: #c0392b;
    --trend-down-bg: #fbe3e0;
    --gold: #e9b91f;
    --silver: #a9b0bc;
    --bronze: #c8854a;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(31, 42, 68, 0.06), 0 2px 8px rgba(31, 42, 68, 0.05);
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--page);
    color: var(--text);
    font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.4;
}

button {
    font: inherit;
}

/* ---------- Header: logo, then the three tabs ---------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 1.75rem;
    padding: 0.4rem 1.5rem;
    background: var(--card);
    border-bottom: 3px solid var(--orange);
    box-shadow: var(--shadow);
}

.site-header .logo img {
    display: block;
    width: 98px;
    height: 64px;
}

.site-nav {
    display: flex;
    gap: 0.35rem;
    padding: 0.25rem;
    background: var(--page);
    border-radius: 999px;
}

.site-nav a {
    padding: 0.45rem 1.1rem;
    border-radius: 999px;
    color: var(--navy-soft);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s, color 0.15s;
}

.site-nav a:hover {
    color: var(--navy);
    background: rgba(31, 42, 68, 0.06);
}

.site-nav a.active {
    background: var(--orange);
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(232, 104, 29, 0.35);
}

/* Signed-in user: name, Change password, Sign out (right side of the header) */

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--muted);
}

.user-menu form {
    margin: 0;
}

.user-menu .user-name {
    color: var(--navy);
    font-weight: 600;
}

.user-menu a,
.link-button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--navy-soft);
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

.user-menu a:hover,
.link-button:hover {
    color: var(--orange);
}

/* ---------- Sign in / password pages ---------- */

.auth-card {
    max-width: 380px;
    margin: 2.5rem auto;
    padding: 1.75rem 1.75rem 1.25rem;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border-top: 4px solid var(--orange);
}

.auth-card h1 {
    margin: 0 0 0.35rem;
    color: var(--navy);
    font-size: 1.6rem;
}

.auth-hint {
    margin: 0 0 1.1rem;
    color: var(--muted);
    font-size: 0.88rem;
}

.auth-card form + .auth-hint {
    margin: 1.25rem 0 0;
}

.field {
    display: block;
    margin-bottom: 0.95rem;
}

.field > span:first-child {
    display: block;
    margin-bottom: 0.3rem;
    color: var(--navy-soft);
    font-size: 0.85rem;
    font-weight: 600;
}

.field input {
    box-sizing: border-box;
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    font-size: 1rem;
    color: var(--text);
}

.field input:focus {
    outline: none;
    border-color: var(--orange);
    box-shadow: 0 0 0 3px var(--orange-soft);
}

.field-error,
.form-error {
    color: var(--trend-down);
    font-size: 0.85rem;
}

.field-error {
    display: block;
    margin-top: 0.25rem;
}

.form-error ul {
    margin: 0 0 0.9rem;
    padding: 0.6rem 0.8rem;
    list-style: none;
    background: var(--trend-down-bg);
    border-radius: 8px;
}

.form-error.validation-summary-valid {
    display: none;
}

.check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.1rem;
    font-size: 0.9rem;
    color: var(--text);
}

.button-primary {
    padding: 0.6rem 1.4rem;
    border: 0;
    border-radius: 999px;
    background: var(--orange);
    color: #ffffff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(232, 104, 29, 0.35);
}

.button-primary:hover {
    background: #d45b13;
}

.button-link {
    margin-left: 1rem;
    color: var(--navy-soft);
    text-decoration: none;
}

.flash {
    margin: 0 0 1rem;
    padding: 0.65rem 0.9rem;
    border-radius: 8px;
    background: var(--trend-up-bg);
    color: var(--trend-up);
    font-weight: 600;
}

/* ---------- Page ---------- */

.content {
    flex: 1;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 1rem 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.page-header h1 {
    margin: 0;
    color: var(--navy);
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.subtitle {
    color: var(--muted);
    font-weight: 600;
}

.site-footer {
    padding: 1.25rem;
    color: var(--muted);
    font-size: 0.8rem;
    text-align: center;
}

/* League / year pickers. */
.draft-picker {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.draft-picker select {
    appearance: none;
    min-width: 10rem;
    padding: 0.5rem 2.2rem 0.5rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%231f2a44' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 0.9rem center;
    color: var(--navy);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.draft-picker select:focus-visible {
    outline: 2px solid var(--orange);
    outline-offset: 1px;
}

.back-button {
    padding: 0.45rem 0.95rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--card);
    color: var(--navy);
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.back-button:hover {
    border-color: var(--navy-soft);
}

/* ---------- Tiles (Overall headline numbers, team page) ---------- */

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 0.9rem;
    margin-bottom: 1.25rem;
}

.tile {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.95rem 1.1rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.tile[data-href] {
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s;
}

.tile[data-href]:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(31, 42, 68, 0.1);
}

.tile-accent {
    border-top: 4px solid var(--orange);
    background: linear-gradient(180deg, var(--orange-soft), var(--card) 70%);
}

.tile-sacko {
    border-top: 4px solid var(--trend-down);
}

.tile-sacko .tile-value {
    color: var(--trend-down);
}

.tile-label {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.tile-value {
    color: var(--navy);
    font-size: 1.65rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.tile-value small {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.tile-team {
    color: var(--text);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trend-text-up {
    color: var(--trend-up);
}

.trend-text-down {
    color: var(--trend-down);
}

/* ---------- Tables ---------- */

.table-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

.grid {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

.grid th {
    padding: 0.75rem 0.8rem;
    background: #f8f9fb;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
    border-bottom: 1px solid var(--line);
}

.grid td {
    padding: 0.7rem 0.8rem;
    border-bottom: 1px solid var(--line-soft);
}

.grid tbody tr:last-child td {
    border-bottom: none;
}

.grid tbody tr:hover td {
    background: #fafbfd;
}

.grid .num {
    text-align: right;
    white-space: nowrap;
}

.grid .center {
    text-align: center;
}

.grid .nowrap {
    white-space: nowrap;
}

.grid .strong,
.grid .team-name {
    font-weight: 600;
}

.grid .team-name {
    color: var(--navy);
}

.grid .rank,
.grid .rank-col {
    width: 3.5rem;
    text-align: center;
}

/* Rank badges: gold / silver / bronze for the top three. */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.8rem;
    height: 1.8rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    color: var(--muted);
    font-weight: 700;
}

.rank-badge.rank-1,
.rank-badge.rank-2,
.rank-badge.rank-3 {
    color: #ffffff;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

.rank-badge.rank-1 {
    background: var(--gold);
}

.rank-badge.rank-2 {
    background: var(--silver);
}

.rank-badge.rank-3 {
    background: var(--bronze);
}

/* Trend pills (▲ up green, ▼ down red). */
.trend-badge {
    display: inline-block;
    min-width: 3.2rem;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    color: var(--muted);
    font-weight: 700;
    text-align: center;
}

.trend-badge.trend-up {
    background: var(--trend-up-bg);
    color: var(--trend-up);
}

.trend-badge.trend-down {
    background: var(--trend-down-bg);
    color: var(--trend-down);
}

/* Status badges (Paid / Unpaid, Final / Open). */
.status-badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
}

.status-paid {
    background: var(--trend-up-bg);
    color: var(--trend-up);
}

.status-unpaid {
    background: var(--line-soft);
    color: var(--muted);
}

/* Sortable headers: click to sort; an arrow shows the current order. */
.grid.sortable th[data-sortable] {
    cursor: pointer;
    user-select: none;
}

.grid.sortable th[data-sortable]:hover {
    color: var(--navy);
}

.grid.sortable th[aria-sort] {
    color: var(--navy);
}

.grid.sortable th[aria-sort]::after {
    margin-left: 0.35rem;
    color: var(--orange);
}

.grid.sortable th[aria-sort="ascending"]::after {
    content: "\2191";
}

.grid.sortable th[aria-sort="descending"]::after {
    content: "\2193";
}

/* Rows that open a page: clickable, no link styling. */
.grid tr[data-href] {
    cursor: pointer;
}

.grid tr[data-href]:hover td {
    background: var(--orange-soft);
}

.grid tr[data-href]:focus-visible td {
    outline: none;
    background: var(--orange-soft);
}

/* The signed-in user's team: the old site's #ffdbbb row colour, plus an orange edge. */
.grid tr.mine td {
    background: #ffdbbb;
}

.grid tr.mine td:first-child {
    box-shadow: inset 4px 0 0 var(--orange);
}

.grid tr.mine:hover td,
.grid tr.mine:focus-visible td {
    background: #ffcfa3;
}

.mine-badge {
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    background: #ffdbbb;
    color: #a6470f;
    font-size: 0.8rem;
    font-weight: 700;
}

/* Grouped tables (team page): a header row per league. */
.grid tr.group-row td {
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
    background: #f8f9fb;
    color: var(--navy);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.grid tbody tr.group-row:hover td {
    background: #f8f9fb;
}

.group-total {
    float: right;
    color: var(--muted);
    letter-spacing: 0;
    text-transform: none;
}

/* ---------- Team page ---------- */

.member-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: -0.5rem 0 1.25rem;
}

.chip {
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    background: var(--navy);
    color: #ffffff;
    font-size: 0.85rem;
    font-weight: 600;
}

.detail-card {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 3rem;
    padding: 1rem 1.25rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.detail-col {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.5rem 1.5rem;
    margin: 0;
    flex: 1 1 16rem;
}

.detail-col dt {
    color: var(--muted);
}

.detail-col dd {
    margin: 0;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.section-title {
    margin: 1.75rem 0 0.75rem;
    color: var(--navy);
    font-size: 1.2rem;
    font-weight: 700;
}

.total {
    margin-top: 0.6rem;
    color: var(--navy);
    font-weight: 700;
    text-align: right;
}

.empty,
.note {
    color: var(--muted);
}

.note {
    margin-top: 0.75rem;
    font-size: 0.85rem;
}

/* ---------- Adaptive columns ("..." mini detail) ----------
   col-wide hides at 768px and narrower, col-tablet at 600px and narrower; the "..." column then shows. */

.grid .col-more {
    display: none;
    width: 2.5rem;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
    text-align: center;
}

.more-button {
    padding: 0.2rem 0.45rem;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--muted);
    font-size: 1.1rem;
    line-height: 1;
    letter-spacing: 1px;
    cursor: pointer;
}

.more-button:hover {
    background: var(--line-soft);
    color: var(--navy);
}

.grid tr.expanded td {
    background: var(--orange-soft);
    border-bottom: none;
}

.grid tr.detail-row td {
    position: relative;
    padding: 0.85rem 2.75rem 0.95rem 1.25rem;
    background: var(--orange-soft);
    border-bottom: 1px solid var(--line);
    cursor: default;
}

.grid tbody tr.detail-row:hover td {
    background: var(--orange-soft);
}

.grid tr.detail-row dl {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.55rem 1rem;
    margin: 0;
}

.grid tr.detail-row dt {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    align-self: center;
}

.grid tr.detail-row dd {
    margin: 0;
    font-weight: 600;
}

.detail-close {
    position: absolute;
    top: 0.45rem;
    right: 0.55rem;
    border: none;
    background: none;
    color: var(--muted);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.detail-close:hover {
    color: var(--navy);
}

@media (max-width: 768px) {
    .grid .col-wide {
        display: none;
    }

    .grid .col-more {
        display: table-cell;
    }
}

@media (max-width: 600px) {
    .grid .col-tablet {
        display: none;
    }

    .site-header {
        gap: 0.75rem;
        padding: 0.35rem 0.75rem;
    }

    .site-header .logo img {
        width: 64px;
        height: 42px;
    }

    .site-nav a {
        padding: 0.4rem 0.75rem;
        font-size: 0.9rem;
    }

    .content {
        padding: 0.9rem 0.75rem;
    }

    .page-header h1 {
        font-size: 1.45rem;
    }

    .draft-picker select {
        min-width: 0;
    }

    .tiles {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.6rem;
    }

    /* Three tiles: the headline one takes the full first row. */
    .tile-accent {
        grid-column: 1 / -1;
    }

    .site-header {
        flex-wrap: wrap;
        row-gap: 0.2rem;
    }

    .user-menu {
        width: 100%;
        justify-content: flex-end;
        font-size: 0.8rem;
    }

    .auth-card {
        margin: 1rem auto;
        padding: 1.25rem 1.1rem 1rem;
    }

    .tile {
        padding: 0.75rem 0.85rem;
    }

    .tile-value {
        font-size: 1.3rem;
    }

    .grid th,
    .grid td {
        padding-left: 0.6rem;
        padding-right: 0.6rem;
    }
}

@media (max-width: 380px) {
    .site-nav a {
        padding: 0.35rem 0.55rem;
        font-size: 0.85rem;
    }
}
