/* Meadowridge Bowling Club - competition manager
   Palette follows the club badge: navy blue with gold. */

:root {
    --navy: #16306b;
    --navy-dark: #0e2049;
    --navy-light: #23458f;
    --gold: #d4a72c;
    --gold-light: #f0c94a;

    --ink: #1c2333;
    --ink-soft: #4a556b;
    --ink-faint: #7b869c;

    --surface: #ffffff;
    --canvas: #f2f4f8;
    --line: #dde2ec;
    --line-soft: #eaeef5;

    --green: #1d7a4c;
    --green-soft: #e6f4ec;
    --red: #b3261e;
    --red-soft: #fdecea;
    --amber: #9a6700;
    --amber-soft: #fff5d6;

    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 2px rgba(16, 27, 56, .06), 0 4px 12px rgba(16, 27, 56, .06);

    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--canvas);
}

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }

a { color: var(--navy-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- shell ---- */

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

.sidebar {
    width: 250px;
    flex: 0 0 250px;
    background: var(--navy-dark);
    color: #dfe6f5;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.sidebar-brand .club {
    display: block;
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    letter-spacing: -.01em;
}

.sidebar-brand .tagline {
    display: block;
    font-size: .78rem;
    color: var(--gold-light);
    text-transform: uppercase;
    letter-spacing: .07em;
    margin-top: .15rem;
}

.sidebar nav { padding: .75rem 0; flex: 1; overflow-y: auto; }

.nav-heading {
    padding: .9rem 1.25rem .35rem;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: #8fa2ca;
    font-weight: 600;
}

.sidebar nav a {
    display: block;
    padding: .45rem 1.25rem;
    color: #dfe6f5;
    font-size: .9rem;
    border-left: 3px solid transparent;
}

.sidebar nav a:hover { background: rgba(255, 255, 255, .07); text-decoration: none; }

.sidebar nav a.active {
    background: rgba(255, 255, 255, .1);
    border-left-color: var(--gold);
    color: #fff;
    font-weight: 600;
}

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

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: .85rem 1.75rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.topbar h1 { margin: 0; font-size: 1.25rem; }
.topbar .spacer { flex: 1; }

.content { padding: 1.5rem 1.75rem 3rem; flex: 1; }

/* ---- cards & panels ---- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
    overflow: hidden;
}

.card-header {
    padding: .85rem 1.15rem;
    border-bottom: 1px solid var(--line-soft);
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}

.card-header h2, .card-header h3 { margin: 0; }
.card-header .spacer { flex: 1; }
.card-body { padding: 1.15rem; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 1.25rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* ---- stats ---- */

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: .9rem 1.1rem;
    box-shadow: var(--shadow);
}

.stat .label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--ink-faint);
    font-weight: 600;
}

.stat .value { font-size: 1.6rem; font-weight: 680; letter-spacing: -.02em; margin-top: .15rem; }
.stat .note { font-size: .8rem; color: var(--ink-soft); }

/* ---- tables ---- */

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

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

table.data th {
    text-align: left;
    padding: .55rem .7rem;
    background: var(--canvas);
    border-bottom: 1px solid var(--line);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ink-soft);
    font-weight: 650;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

table.data td {
    padding: .5rem .7rem;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}

table.data tbody tr:hover { background: #fafbfe; }
table.data tr.is-highlight { background: var(--gold-light); }
table.data tr.is-highlight:hover { background: var(--gold-light); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.mid, table.data th.mid { text-align: center; }
table.data tfoot td { font-weight: 650; border-top: 2px solid var(--line); background: var(--canvas); }

.label-chip {
    display: inline-block;
    min-width: 1.9rem;
    text-align: center;
    padding: .1rem .35rem;
    background: var(--navy);
    color: #fff;
    border-radius: 5px;
    font-weight: 700;
    font-size: .8rem;
    font-family: var(--mono);
}

.pos {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.pos-1 { color: var(--gold); }

/* ---- badges ---- */

.badge {
    display: inline-block;
    padding: .12rem .5rem;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge.bad { background: var(--red-soft); color: var(--red); }
.badge.neutral { background: var(--line-soft); color: var(--ink-soft); }
.badge.navy { background: #e5ebf8; color: var(--navy); }

/* ---- buttons ---- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .42rem .85rem;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font-size: .88rem;
    font-weight: 550;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.4;
}

.btn:hover { background: var(--canvas); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-light); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #3a2c00; }
.btn.gold:hover { background: var(--gold-light); }
.btn.danger { color: var(--red); border-color: #f0c4c0; }
.btn.danger:hover { background: var(--red-soft); }
.btn.small { padding: .25rem .55rem; font-size: .8rem; }

.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---- forms ---- */

.field { margin-bottom: .9rem; }

.field label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: .25rem;
}

input[type=text], input[type=number], input[type=date], input[type=email], select, textarea {
    width: 100%;
    padding: .42rem .6rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: .9rem;
    color: var(--ink);
    background: var(--surface);
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid rgba(35, 69, 143, .35);
    outline-offset: -1px;
    border-color: var(--navy-light);
}

textarea { min-height: 90px; resize: vertical; font-size: .85rem; }

input.score {
    width: 4.2rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
    padding: .3rem .35rem;
}

input.inline { padding: .28rem .45rem; font-size: .85rem; }

.checkline { display: flex; align-items: center; gap: .45rem; font-size: .88rem; }
.checkline input { width: auto; }

.hint { font-size: .78rem; color: var(--ink-faint); margin-top: .2rem; }

/* ---- messages ---- */

.alert {
    padding: .7rem .95rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .88rem;
    border: 1px solid transparent;
}

.alert.info { background: #eaf0fb; border-color: #c9d8f5; color: var(--navy); }
.alert.ok { background: var(--green-soft); border-color: #b9e0c9; color: #14603a; }
.alert.warn { background: var(--amber-soft); border-color: #f0dfa8; color: var(--amber); }
.alert.bad { background: var(--red-soft); border-color: #f3c6c2; color: var(--red); }
.alert ul { margin: .35rem 0 0; padding-left: 1.1rem; }

.empty {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--ink-faint);
    font-size: .92rem;
}

/* ---- misc ---- */

.muted { color: var(--ink-faint); }
.soft { color: var(--ink-soft); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.mt { margin-top: 1rem; }
.mb0 { margin-bottom: 0; }

.tabs {
    display: flex;
    gap: .25rem;
    border-bottom: 1px solid var(--line);
    margin-bottom: 1.25rem;
    overflow-x: auto;
}

.tabs a {
    padding: .5rem .85rem;
    font-size: .88rem;
    font-weight: 550;
    color: var(--ink-soft);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}

.tabs a:hover { color: var(--navy); text-decoration: none; }
.tabs a.active { color: var(--navy); border-bottom-color: var(--gold); font-weight: 650; }

@media (max-width: 820px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; flex: none; }
    .sidebar nav { display: flex; flex-wrap: wrap; padding: .5rem; }
    .sidebar nav a { border-left: none; border-bottom: 3px solid transparent; }
    .nav-heading { width: 100%; padding: .5rem .75rem .1rem; }
    .content { padding: 1rem; }
}

/* ---- print ---- */

@media print {
    .sidebar, .topbar, .no-print, .tabs { display: none !important; }
    body, html { background: #fff; font-size: 11pt; }
    .content { padding: 0; }
    .card { border: none; box-shadow: none; margin: 0; }
    .card-body { padding: 0; }
    a { color: inherit; text-decoration: none; }
    .page-break { break-after: page; page-break-after: always; }
    .page-break:last-child { break-after: auto; page-break-after: auto; }
}

/* ---- printable sheets ---- */

.print-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem 1.25rem 3rem;
    background: #fff;
    min-height: 100vh;
}

.print-toolbar {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem 0 1rem;
    border-bottom: 1px solid var(--line);
    margin-bottom: 1.25rem;
}

.print-toolbar .spacer { flex: 1; }

.sheet-head {
    text-align: center;
    margin-bottom: 1rem;
}

.sheet-head .club-line {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: .01em;
}

.sheet-head .title-line {
    font-size: 1.15rem;
    font-weight: 700;
    margin-top: .2rem;
}

.sheet-head .sub-line {
    font-size: .85rem;
    color: var(--ink-soft);
    margin-top: .15rem;
}

.sheet-head .sponsor {
    font-size: .8rem;
    color: var(--ink-soft);
    margin-top: .2rem;
}

table.sheet {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}

table.sheet th, table.sheet td {
    border: 1px solid #333;
    padding: .28rem .4rem;
}

table.sheet th {
    background: #eef1f7;
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    text-align: center;
}

table.sheet td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.sheet td.mid, table.sheet th.mid { text-align: center; }
table.sheet tr.is-highlight { background: #fdf3d0; }

/* score cards, four to a page as the club prints them */

.card-sheet {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6mm;
    margin-bottom: 6mm;
}

.score-card {
    border: 1px solid #333;
    padding: 3mm 3.5mm;
    font-size: .78rem;
    break-inside: avoid;
    page-break-inside: avoid;
}

.score-card .sc-title {
    text-align: center;
    font-weight: 700;
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .02em;
    border-bottom: 1px solid #333;
    padding-bottom: 1.5mm;
    margin-bottom: 1.5mm;
}

.score-card .sc-team {
    display: flex;
    gap: .5rem;
    align-items: baseline;
    margin-bottom: 1.5mm;
}

.score-card .sc-team .letter {
    font-weight: 700;
    font-size: 1.05rem;
}

.score-card .sc-names { flex: 1; font-size: .76rem; line-height: 1.35; }
.score-card .sc-names .row { display: flex; gap: .3rem; }
.score-card .sc-names .k { color: #555; min-width: 2.6rem; }
.score-card .sc-names .v { font-weight: 600; }

.score-card table {
    width: 100%;
    border-collapse: collapse;
    font-size: .72rem;
}

.score-card th, .score-card td {
    border: 1px solid #555;
    padding: .18rem .2rem;
    text-align: center;
    height: 1.5rem;
}

.score-card th {
    background: #eef1f7;
    font-size: .62rem;
    text-transform: uppercase;
    line-height: 1.15;
}

.score-card .sc-notes {
    margin-top: 1.5mm;
    font-size: .62rem;
    color: #444;
    line-height: 1.3;
}

.score-card .sc-notes div { margin-bottom: .3mm; }

@media print {
    .print-page { padding: 0; max-width: none; }
    .print-toolbar { display: none !important; }
    .card-sheet { gap: 5mm; }
    table.sheet { font-size: 9pt; }
    .sheet-head { margin-bottom: .5rem; }
    @page { margin: 10mm; }
}

/* ---- rink ranking ---- */

.rink-greens {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    padding: .85rem 1.15rem;
    background: var(--canvas);
    border-bottom: 1px solid var(--line);
}

.rink-green .green-name {
    display: block;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--ink-faint);
    font-weight: 600;
}

.rink-green .green-order {
    font-family: var(--mono);
    font-size: .9rem;
    font-weight: 600;
    color: var(--navy);
    letter-spacing: .02em;
}

/* ---- sign in ---- */

.signin {
    max-width: 26rem;
    margin: 0 auto;
    padding: 4rem 1.25rem 3rem;
}

.signin-brand {
    text-align: center;
    margin-bottom: 1.5rem;
}

.signin-brand .club {
    display: block;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--navy);
}

.signin-brand .tagline {
    display: block;
    font-size: .78rem;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: .09em;
    margin-top: .15rem;
}

.signin .card-body { padding: 1.5rem; }
.signin h2 { margin-bottom: 1rem; }

.signin-foot {
    text-align: center;
    margin-top: 1.25rem;
    font-size: .85rem;
}

/* ---- signed-in identity in the sidebar ---- */

.who {
    padding: .75rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, .1);
    font-size: .82rem;
    color: #dfe6f5;
}

.who .name { display: block; font-weight: 600; color: #fff; }

.who .role {
    display: inline-block;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--gold-light);
    margin-top: .1rem;
}

.who form { margin-top: .5rem; }

.who button {
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .15);
    color: #dfe6f5;
    padding: .25rem .6rem;
    border-radius: 6px;
    font-size: .78rem;
    font-family: inherit;
    cursor: pointer;
}

.who button:hover { background: rgba(255, 255, 255, .18); }

.who a.signin-link {
    display: inline-block;
    color: var(--gold-light);
    font-weight: 600;
}

/* ---- calendar grid ---- */

.cal-month { margin-bottom: 1.5rem; break-inside: avoid; }

.cal-head {
    display: flex;
    align-items: baseline;
    gap: .6rem;
    margin-bottom: .4rem;
}

.cal-head h3 { margin: 0; color: var(--navy); }

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.cal-dow {
    background: var(--canvas);
    padding: .3rem .4rem;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--ink-faint);
    font-weight: 650;
    text-align: center;
}

.cal-day {
    background: var(--surface);
    min-height: 5.2rem;
    padding: .25rem .3rem;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.cal-day .num {
    font-size: .72rem;
    color: var(--ink-faint);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.cal-day.outside { background: #fbfcfe; }
.cal-day.outside .num { opacity: .4; }
.cal-day.has-events { background: #fdfefe; }

.cal-day.today { box-shadow: inset 0 0 0 2px var(--gold); }
.cal-day.today .num { color: var(--gold); font-weight: 700; }

.cal-event {
    display: block;
    font-size: .68rem;
    line-height: 1.25;
    padding: .12rem .3rem;
    border-radius: 4px;
    border-left: 3px solid transparent;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: default;
}

.cal-event.is-competition { background: #e5ebf8; color: var(--navy);  border-left-color: var(--navy); }
.cal-event.is-league      { background: var(--green-soft); color: #14603a; border-left-color: var(--green); }
.cal-event.is-fixture     { background: var(--amber-soft); color: var(--amber); border-left-color: var(--gold); }
.cal-event.is-social      { background: #fdf3d0; color: #7a5b00; border-left-color: var(--gold-light); }
.cal-event.is-meeting     { background: var(--line-soft); color: var(--ink-soft); border-left-color: var(--ink-faint); }
.cal-event.is-external    { background: #f4f6fa; color: var(--ink-faint); border-left-color: var(--line); }

.cal-legend {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: .78rem;
    color: var(--ink-soft);
    margin-bottom: 1rem;
}

.cal-legend span::before {
    content: "";
    display: inline-block;
    width: .7rem;
    height: .7rem;
    border-radius: 3px;
    margin-right: .35rem;
    vertical-align: -1px;
}

.cal-legend .k-competition::before { background: var(--navy); }
.cal-legend .k-league::before      { background: var(--green); }
.cal-legend .k-fixture::before     { background: var(--gold); }
.cal-legend .k-social::before      { background: var(--gold-light); }
.cal-legend .k-meeting::before     { background: var(--ink-faint); }
.cal-legend .k-external::before    { background: var(--line); }

@media (max-width: 720px) {
    .cal-day { min-height: 3.6rem; }
    .cal-event { font-size: .6rem; }
}

@media print {
    .cal-grid { border-color: #999; background: #999; }
    .cal-day { min-height: 4.2rem; }
    .cal-event {
        border: 1px solid #bbb;
        border-left-width: 3px;
        /* Backgrounds are dropped by default when printing; keep the colour coding. */
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .cal-dow, .cal-day.outside { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .cal-month { break-inside: avoid; page-break-inside: avoid; }
}

/* Facility hire — what the club calls an Event. */
.cal-event.is-hire { background: var(--red-soft); color: var(--red); border-left-color: var(--red); }
.cal-legend .k-hire::before { background: var(--red); }
