:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --panel-2: #f8fafc;
    --text: #122033;
    --muted: #627084;
    --border: #d9e1ea;
    --shadow: 0 12px 35px rgba(15, 31, 56, 0.10);
    --accent: #0b6b48;
    --button: #122033;
    --button-text: #fff;
    --sticky: #ffffff;
    --highlight: rgba(255, 209, 102, .32);
    --fd-very-easy: #006837;
    --fd-easy: #1a9850;
    --fd-kind: #66bd63;
    --fd-slight-kind: #c2e699;
    --fd-neutral: #fff2a8;
    --fd-slight-hard: #fdd49e;
    --fd-hard: #fdae61;
    --fd-very-hard: #f46d43;
    --fd-brutal: #a50026;
    --fd-dark-text: #ffffff;
    --fd-light-text: #162033;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f141c;
        --panel: #171e29;
        --panel-2: #111823;
        --text: #e8eef7;
        --muted: #aab4c4;
        --border: #2a3545;
        --shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
        --accent: #61d394;
        --button: #e8eef7;
        --button-text: #111823;
        --sticky: #171e29;
        --highlight: rgba(255, 209, 102, .20);
    }
}

body.theme-light {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --panel-2: #f8fafc;
    --text: #122033;
    --muted: #627084;
    --border: #d9e1ea;
    --shadow: 0 12px 35px rgba(15, 31, 56, 0.10);
    --accent: #0b6b48;
    --button: #122033;
    --button-text: #fff;
    --sticky: #ffffff;
    --highlight: rgba(255, 209, 102, .32);
}

body.theme-dark {
    --bg: #0f141c;
    --panel: #171e29;
    --panel-2: #111823;
    --text: #e8eef7;
    --muted: #aab4c4;
    --border: #2a3545;
    --shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
    --accent: #61d394;
    --button: #e8eef7;
    --button-text: #111823;
    --sticky: #171e29;
    --highlight: rgba(255, 209, 102, .20);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
.fiso-fdr-app { max-width: 1400px; margin: 0 auto; padding: 24px; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(210px, auto); gap: 24px; align-items: stretch; margin-bottom: 20px; }
.hero__copy { min-width: 0; }
.eyebrow { margin: 0 0 8px; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; font-size: 13px; font-weight: 800; }
.eyebrow a { color: inherit; text-decoration: none; }
.eyebrow a:hover { text-decoration: underline; }
h1 { margin: 0; font-size: clamp(28px, 4vw, 48px); line-height: 1.05; letter-spacing: -0.03em; }
.intro { max-width: 790px; color: var(--muted); font-size: 17px; line-height: 1.55; }
.hero-logo { align-self: center; display: flex; align-items: center; justify-content: center; background: var(--panel); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 8px; max-width: 260px; }
.hero-logo img { display: block; width: min(240px, 28vw); height: auto; border-radius: 10px; }
.hero-card { min-width: 210px; background: linear-gradient(145deg, var(--panel), var(--panel-2)); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 22px; text-align: right; }
.hero-card__label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
.hero-card__value { font-size: 34px; font-weight: 850; }
.hero-card__small { color: var(--muted); }
.controls { display: grid; grid-template-columns: minmax(260px, 1.3fr) minmax(230px, .95fr) minmax(230px, .95fr) minmax(280px, 1fr); gap: 14px; margin-bottom: 14px; }
.control-block, .sort-panel, .legend, .notes { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }
.control-block { padding: 16px; }
label, .label-like { display: block; font-weight: 800; margin-bottom: 8px; }
.slider-row { display: flex; gap: 12px; align-items: center; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
output { min-width: 38px; padding: 6px 10px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--border); text-align: center; font-weight: 800; }
select, input[type="number"] { border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2); color: var(--text); padding: 9px 10px; }
select { width: 100%; }
.hint { margin: 8px 0 0; min-height: 20px; color: var(--muted); font-size: 13px; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
button { border: 1px solid var(--border); background: var(--button); color: var(--button-text); border-radius: 999px; padding: 9px 14px; cursor: pointer; font-weight: 750; }
button:hover, button.is-active { outline: 3px solid rgba(97, 211, 148, .28); }
.sort-panel { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 14px; margin-bottom: 14px; }
.sort-panel > span { color: var(--muted); font-weight: 800; margin-right: 4px; }
.autosort-toggle { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 0 auto; font-weight: 800; color: var(--muted); }
.autosort-toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; margin-bottom: 14px; }
.legend__item { font-size: 12px; font-weight: 800; padding: 7px 9px; border-radius: 8px; color: var(--fd-light-text); }
.table-shell { overflow: auto; border: 1px solid var(--border); border-radius: 18px; background: var(--panel); box-shadow: var(--shadow); max-height: 76vh; }
.fdr-table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 1120px; }
th, td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 9px; text-align: center; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 5; background: var(--panel-2); font-size: 13px; text-transform: uppercase; letter-spacing: .03em; }
th small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; text-transform: none; letter-spacing: normal; }
tr:last-child td { border-bottom: 0; }
.row-highlight td { box-shadow: inset 0 0 0 9999px var(--highlight); }
.team-col, td.team-cell { text-align: left; min-width: 180px; }
.strength-col, td.strength-cell { min-width: 110px; }
.sticky-col { position: sticky; left: 0; z-index: 4; background: var(--sticky); }
th.sticky-col { z-index: 7; background: var(--panel-2); }
.sticky-col-2 { position: sticky; left: 180px; z-index: 4; background: var(--sticky); }
th.sticky-col-2 { z-index: 7; background: var(--panel-2); }
.team-name { font-weight: 850; display: block; }
.team-code { color: var(--muted); font-size: 12px; }
.strength-input { width: 76px; text-align: center; font-weight: 800; }
.avg-cell { font-weight: 850; }
.fixture-cell { min-width: 74px; height: 58px; }
.fixture-inner { display: grid; gap: 2px; justify-items: center; }
.opp { font-weight: 900; font-size: 15px; }
.meta { font-size: 11px; opacity: .82; }
.score { font-size: 12px; font-weight: 900; }
.fd-very-easy { background: var(--fd-very-easy); color: var(--fd-dark-text); }
.fd-easy { background: var(--fd-easy); color: var(--fd-dark-text); }
.fd-kind { background: var(--fd-kind); color: var(--fd-light-text); }
.fd-slight-kind { background: var(--fd-slight-kind); color: var(--fd-light-text); }
.fd-neutral { background: var(--fd-neutral); color: var(--fd-light-text); }
.fd-slight-hard { background: var(--fd-slight-hard); color: var(--fd-light-text); }
.fd-hard { background: var(--fd-hard); color: var(--fd-light-text); }
.fd-very-hard { background: var(--fd-very-hard); color: var(--fd-light-text); }
.fd-brutal { background: var(--fd-brutal); color: var(--fd-dark-text); }
.notes { margin-top: 18px; padding: 18px; line-height: 1.55; color: var(--muted); }
.notes h2 { color: var(--text); margin: 0 0 8px; }
.notes p { margin: 8px 0; }
@media (max-width: 1100px) { .controls { grid-template-columns: 1fr 1fr; } .hero { grid-template-columns: 1fr; } .hero-logo { justify-content: flex-start; } .hero-logo img { width: min(260px, 70vw); } .hero-card { text-align: left; } }
@media (max-width: 850px) {
    .fiso-fdr-app { padding: 14px; }
    .hero, .controls { grid-template-columns: 1fr; display: grid; }
    .hero-logo { justify-content: flex-start; }
    .hero-card { text-align: left; }
    .autosort-toggle { width: 100%; margin-left: 0; padding-top: 4px; }
    .table-shell { max-height: 72vh; }
    .team-col, td.team-cell { min-width: 135px; }
    .sticky-col-2 { left: 135px; }
    .strength-col, td.strength-cell { min-width: 96px; }
    .fdr-table { min-width: 1040px; }
    th, td { padding: 7px; }
}
