:root {
    /* --- Palette --- */
    --field-green: #16362B;
    --field-green-light: #1E4738;
    --chalk: #F7F6F2;
    --card: #FFFFFF;
    --ink: #1B211E;
    --slate: #6B7280;
    --slate-soft: #9CA3AF;
    --flag-yellow: #F5B700;
    --flag-yellow-ink: #4A3600; /* text on yellow, for contrast */
    --whistle-red: #C6362E;
    --turf-signal: #2E7D5B;
    --border: #E4E1D8;
    --line-dash: #D8D5CC;

    --radius: 10px;
    --radius-lg: 16px;

    --font-display: "Oswald", "Arial Narrow", sans-serif;
    --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "Roboto Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--chalk);
    color: var(--ink);
    padding-bottom: 84px;
    -webkit-tap-highlight-color: transparent;
}

a { color: inherit; }

/* Visible keyboard focus everywhere - accessibility floor */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
    outline: 3px solid var(--flag-yellow);
    outline-offset: 2px;
}

/* --- Top bar --- */
.topbar {
    background: var(--field-green);
    color: var(--chalk);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar .brand {
    color: white;
    text-decoration: none;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 9px;
}
.brand-flag {
    width: 11px; height: 11px;
    background: var(--flag-yellow);
    display: inline-block;
    transform: rotate(45deg);
    flex-shrink: 0;
}
.logout-form { margin: 0; }
.link-btn {
    background: none; border: none; color: #C9D6CD; font-size: 0.82rem;
    font-family: var(--font-body); cursor: pointer; padding: 8px; text-decoration: underline;
    text-underline-offset: 2px;
}

.content { max-width: 720px; margin: 0 auto; padding: 20px 16px 8px; }

/* --- Alerts --- */
.alert {
    padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px;
    font-size: 0.9rem; border-left: 4px solid transparent;
}
.alert-success { background: #E7F3ED; color: var(--turf-signal); border-color: var(--turf-signal); }
.alert-info { background: #EAF0EE; color: var(--field-green); border-color: var(--field-green); }
.alert-warning { background: #FDF3D9; color: #8A6116; border-color: var(--flag-yellow); }
.alert-danger { background: #FBEAE9; color: var(--whistle-red); border-color: var(--whistle-red); }

/* --- Type --- */
h1 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.5rem;
    letter-spacing: 0.01em;
    margin: 4px 0 20px;
    color: var(--ink);
}
h2.eyebrow {
    font-family: var(--font-display);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--slate);
    margin: 28px 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--line-dash);
}

.page-header {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px;
}
.page-header h1 { margin: 0; }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 12px 20px;
    border-radius: 999px;
    background: var(--flag-yellow);
    color: var(--flag-yellow-ink);
    text-decoration: none;
    font-family: var(--font-display);
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border: none;
    cursor: pointer;
}
.btn:active { background: #DBA400; }
.btn-secondary { background: var(--card); color: var(--field-green); border: 1.5px solid var(--field-green); }
.btn-danger { background: var(--card); color: var(--whistle-red); border: 1.5px solid var(--whistle-red); }
.btn-block { display: flex; width: 100%; }

.fab {
    position: fixed;
    bottom: 92px;
    right: 20px;
    width: 58px; height: 58px;
    border-radius: 50%;
    background: var(--flag-yellow);
    color: var(--flag-yellow-ink);
    font-size: 1.7rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    text-decoration: none;
    box-shadow: 0 6px 16px rgba(22, 54, 43, 0.28);
    z-index: 9;
    line-height: 1;
}

/* --- Dashboard scorecards --- */
.scorecard {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.scorecard .label {
    font-family: var(--font-display);
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--slate);
}
.scorecard .value {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    font-size: 1.55rem;
    color: var(--ink);
    white-space: nowrap;
}
.scorecard.net {
    border-left: 5px solid var(--flag-yellow);
    background: #FEFBF1;
}
.scorecard.net .value.positive { color: var(--turf-signal); }
.scorecard.net .value.negative { color: var(--whistle-red); }

.sport-row {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 13px 16px; margin-bottom: 8px;
}
.sport-row .sport-name {
    font-family: var(--font-display); font-weight: 600; font-size: 0.95rem;
    text-transform: uppercase; letter-spacing: 0.02em;
}
.sport-row .sport-stats { color: var(--slate); font-size: 0.78rem; margin-top: 2px; }
.sport-row .sport-amount { text-align: right; }
.sport-row .amount {
    font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 700;
    color: var(--field-green); font-size: 1.02rem; display: block;
}

/* --- Record cards (games / expenses lists) --- */
.record-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--field-green);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 10px;
    text-decoration: none;
    color: var(--ink);
    display: block;
}
.record-card .row1 {
    display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
    font-family: var(--font-body); font-weight: 600; font-size: 0.96rem; margin-bottom: 6px;
}
.record-card .row1 .title { flex: 1; }
.record-card .row2 { color: var(--slate); font-size: 0.82rem; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.record-card .amount {
    font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 700;
    color: var(--field-green); white-space: nowrap;
}
.badge {
    display: inline-block; font-size: 0.7rem; font-weight: 600; padding: 3px 9px; border-radius: 999px;
    background: #EDF2EF; color: var(--field-green); letter-spacing: 0.02em;
}

/* --- Forms --- */
form.styled-form {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 18px;
}
.form-field { margin-bottom: 20px; }
.form-field:last-of-type { margin-bottom: 0; }
.form-field label {
    display: block;
    font-family: var(--font-display);
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 8px;
    color: var(--slate);
}
.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 16px; /* keeps iOS Safari from auto-zooming on focus */
    font-family: var(--font-body);
    background: var(--chalk);
    color: var(--ink);
}
.form-field select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--slate) 50%), linear-gradient(135deg, var(--slate) 50%, transparent 50%);
    background-position: calc(100% - 20px) center, calc(100% - 15px) center;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 36px;
}
.form-field textarea { min-height: 88px; resize: vertical; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
    border-color: var(--flag-yellow);
    background: var(--card);
}

.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.form-actions .btn { flex: 1; min-width: 120px; }

.errorlist { color: var(--whistle-red); font-size: 0.82rem; list-style: none; padding: 0; margin: 6px 0 0; }

/* --- Auth pages --- */
.auth-wrap { max-width: 400px; margin: 48px auto; padding: 0 16px; }
.auth-wrap .brand-header {
    text-align: center; font-family: var(--font-display); font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.04em; font-size: 1.15rem; color: var(--field-green); margin-bottom: 24px;
    display: flex; align-items: center; justify-content: center; gap: 10px;
}

/* --- Bottom nav --- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--field-green);
    display: flex; z-index: 10;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.15);
}
.bottom-nav a {
    flex: 1; text-align: center; padding: 10px 4px 8px; text-decoration: none;
    color: #9DB3A8; font-family: var(--font-display); font-size: 0.68rem; font-weight: 600;
    letter-spacing: 0.03em; text-transform: uppercase;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    border-top: 3px solid transparent;
    min-height: 58px;
    justify-content: center;
}
.bottom-nav a .icon { font-size: 1.3rem; }
.bottom-nav a.active { color: var(--flag-yellow); border-top-color: var(--flag-yellow); }

.empty-state {
    text-align: center; color: var(--slate); padding: 48px 20px; font-size: 0.92rem;
    background: var(--card); border: 1px dashed var(--line-dash); border-radius: var(--radius-lg);
}

table.data-table { width: 100%; border-collapse: collapse; }

@media (max-width: 400px) {
    .scorecard .value { font-size: 1.3rem; }
}
