:root {
  /* SSA Brand Book */
  --kuusikko: #17403a;
  --okra: #af6327;
  --topaasi: #8b9585;
  --kaura: #d4b371;
  --bg: #f2f1ec;
  --panel: #ffffff;
  --border: #e2ddd2;
  --text: #1c1f1c;
  --muted: #6f6a5f;
  --accent-soft: #e6ece9;
  --green: #1f6b4c;
  --red: #b3401f;
  font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Work Sans", system-ui, sans-serif; color: var(--text); background: var(--bg); display: flex; min-height: 100vh; }
h1, h2, .logo-nimi, .kortti-luku { font-family: "Playfair Display", Georgia, serif; font-weight: 600; }
h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 10px; }
a { color: var(--kuusikko); }

.sivupalkki { width: 220px; flex: none; background: var(--kuusikko); color: #ece8de; display: flex; flex-direction: column; padding: 22px 0; position: sticky; top: 0; height: 100vh; }
.logo { display: flex; flex-direction: column; padding: 0 22px 22px; }
.logo-ssa { font-weight: 600; letter-spacing: .3em; font-size: 12px; opacity: .8; }
.logo-nimi { font-size: 20px; }
.sivupalkki a { color: inherit; text-decoration: none; padding: 10px 22px; opacity: .85; border-left: 3px solid transparent; }
.sivupalkki a:hover { opacity: 1; background: rgba(255,255,255,.06); }
.sivupalkki a.aktiivinen { opacity: 1; border-left-color: var(--kaura); background: rgba(255,255,255,.1); }
.uloskirjaus { margin-top: auto; padding: 0 22px; }
.uloskirjaus .kayttaja { font-size: 12px; opacity: .8; margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uloskirjaus button { background: none; border: 1px solid rgba(255,255,255,.3); color: inherit; padding: 6px 12px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 12px; }

main { flex: 1; min-width: 0; padding: 30px 34px 60px; }
.sivun-otsikko { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 20px; flex-wrap: wrap; }
.selite { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; line-height: 1.45; }
.paneeli { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-bottom: 20px; }
.paneelin-otsikko { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.tyhja { color: var(--muted); }
.kaksi-saraketta { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 1250px) { .kaksi-saraketta { grid-template-columns: 1fr; } }

.viesti { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.viesti.ok { background: #eaf3ee; border-color: #bcd8c8; color: var(--green); }
.viesti.virhe { background: #f8ebe6; border-color: #e6c3b6; color: var(--red); }

button, .nappi { font: inherit; font-size: 13px; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--border); background: #fff; color: var(--text); cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .nappi:hover { border-color: var(--kuusikko); }
button.ensisijainen { background: var(--kuusikko); color: #fff; border-color: var(--kuusikko); }
button.pieni { padding: 3px 8px; font-size: 12px; }
button.vaara { color: var(--red); }
button.vaara:hover { border-color: var(--red); }
input, select { font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
label { font-size: 13px; color: var(--muted); }
label.rivi { display: block; margin: 14px 0 4px; }
label.rivi input { margin-left: 8px; }
.jakso { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.jakso label { display: flex; flex-direction: column; gap: 4px; }
.jakso a { font-size: 13px; padding: 7px 0; }
.tuonti { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 12px 0 18px; }
.toiminnot { display: flex; gap: 12px; margin-top: 16px; }

/* Kortit */
.kortit { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.kortti { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; display: flex; flex-direction: column; gap: 4px; border-left: 4px solid var(--topaasi); }
.kortti.plus { border-left-color: var(--okra); }
.kortti.miinus { border-left-color: var(--green); }
.kortti-nimi { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kortti-luku { font-size: 24px; }
.kortti-apu { font-size: 12px; color: var(--muted); }
@media (max-width: 1250px) { .kortit { grid-template-columns: repeat(2, 1fr); } }

/* Taulukot */
table { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; background: #fff; }
th:first-child, td:first-child { text-align: left; }
thead th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; border-bottom: 2px solid var(--border); vertical-align: bottom; }
.vieritys { overflow-x: auto; }
td.neg { color: var(--red); }
td.nolla { color: #b8b3a8; }
.yhteensa { background: #faf8f3; font-weight: 600; border-left: 2px solid var(--border); }

/* Yhteiset lukutaulukoiden säännöt: vuororivit, kiinnitetty nimisarake, ryhmäviivat */
.kiinnitetty tbody tr:nth-child(even) th, .kiinnitetty tbody tr:nth-child(even) td { background: #f8f7f3; }
.kiinnitetty tbody tr:nth-child(even) td.yhteensa { background: #f3f0e8; }
.kiinnitetty tbody tr:hover th, .kiinnitetty tbody tr:hover td { background: #eef2ef; }
.kiinnitetty .nimi-sarake { position: sticky; left: 0; z-index: 1; min-width: 260px; max-width: 300px; overflow: hidden; text-overflow: ellipsis; border-right: 1px solid var(--border); }
.kiinnitetty thead .nimi-sarake { z-index: 2; }
.kiinnitetty .ryhma-alku { border-left: 2px solid var(--border); }
.kiinnitetty thead th.ryhma { text-align: center; border-left: 2px solid var(--border); font-size: 11.5px; color: var(--kuusikko); background: var(--accent-soft); }
.kiinnitetty thead .alaotsikko { display: block; font-size: 10px; letter-spacing: 0; text-transform: none; font-weight: 400; margin-top: 2px; }
.kiinnitetty tfoot th, .kiinnitetty tfoot td { font-weight: 600; border-top: 2px solid #c9c4b8; border-bottom: 0; background: #faf8f3; }

.vertailu th, .vertailu td { padding: 5px 8px; font-size: 12.5px; }
.vertailu tbody th { font-weight: 400; }
.vertailu tr.osio th { text-align: left; background: var(--accent-soft); color: var(--kuusikko); font-family: "Playfair Display", serif; font-size: 14px; font-weight: 600; padding: 9px 8px; text-transform: none; letter-spacing: 0; white-space: normal; position: static; max-width: none; }
.vertailu tr.osio .selite { font-family: "Work Sans", sans-serif; font-weight: 400; font-size: 12px; margin-left: 8px; }
.vertailu tr.summa th, .vertailu tr.summa td { font-weight: 600; border-top: 1px solid #c9c4b8; }
.vertailu tr.prosentti td, .vertailu tr.apu td, .vertailu tr.apu th, .vertailu tr.prosentti th { color: var(--muted); font-style: italic; }
.vertailu tbody tr.summa th, .vertailu tbody tr.summa td { background: #fff; }

.tyomaataulu th, .tyomaataulu td { font-size: 12.5px; padding: 6px 10px; line-height: 1.3; }
.tyomaataulu tbody th { font-weight: 400; }
.tyomaataulu .tnro { font-weight: 600; display: inline-block; min-width: 58px; margin-right: 6px; }
.tyomaataulu td.summa { font-weight: 600; }
.tyomaataulu td.prosentti { color: var(--muted); font-size: 11.5px; }
.tyomaataulu .ero-sarake { font-weight: 600; background: #faf8f3; position: sticky; right: 0; z-index: 1; box-shadow: -1px 0 0 var(--border); }
.tyomaataulu thead .ero-sarake { z-index: 2; }
.tyomaataulu tbody tr:nth-child(even) .ero-sarake { background: #f3f0e8; }
.tyomaataulu tbody tr.sivukulutyomaa th, .tyomaataulu tbody tr.sivukulutyomaa td { background: #fbf6ee; color: var(--muted); font-style: italic; }
.tyomaataulu tbody tr.sivukulutyomaa .tnro { color: var(--okra); }
.tyomaataulu tr.vali td { height: 18px; padding: 0; border: 0; background: transparent; }
.tyomaataulu tr.summa-apu th, .tyomaataulu tr.summa-apu td { font-weight: 500; color: var(--muted); border-top: 0; border-bottom: 1px solid var(--border); background: #faf8f3; }
.tyomaataulu tr.summa-apu .alaotsikko { font-weight: 400; font-size: 11px; margin-left: 6px; }
.tyomaataulu tr.yksikko-otsikko th, .tyomaataulu tr.yksikko-otsikko td { background: var(--accent-soft); color: var(--kuusikko); font-family: "Playfair Display", serif; font-size: 14px; font-weight: 600; padding: 9px 10px; border-top: 2px solid var(--border); }
.tyomaataulu tr.yksikko-otsikko .alaotsikko { font-family: "Work Sans", sans-serif; font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 8px; }
.tyomaataulu tr.yksikko-otsikko .alaotsikko a { color: var(--okra); }
.tyomaataulu tr.yksikko-summa th, .tyomaataulu tr.yksikko-summa td { font-weight: 600; background: #f3f0e8; border-top: 1px solid #c9c4b8; border-bottom: 2px solid var(--border); }
.tyomaataulu tbody.ei-mukana th, .tyomaataulu tbody.ei-mukana td { color: var(--muted); }
.tyomaataulu tbody.ei-mukana tr.yksikko-otsikko th { background: #f3f2ee; color: var(--muted); }
.tyomaataulu tbody.koko-yhtio tr.summa th, .tyomaataulu tbody.koko-yhtio tr.summa td { font-weight: 600; border-top: 3px double #c9c4b8; border-bottom: 1px solid #c9c4b8; background: #faf8f3; }
.tyomaataulu tbody.koko-yhtio .alaotsikko { font-weight: 400; font-size: 11px; color: var(--muted); margin-left: 6px; }
.valintaruudut { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin: 14px 0 4px; display: flex; gap: 18px; flex-wrap: wrap; }
.valintaruudut legend { font-size: 12px; color: var(--muted); padding: 0 6px; }
.valintaruudut label { color: var(--text); display: flex; align-items: center; gap: 6px; }
.tyomaat-lista tr.luokittelematon th, .tyomaat-lista tr.luokittelematon td { background: #fbeee5; }
.merkki { font-size: 10px; background: var(--accent-soft); color: var(--kuusikko); border-radius: 4px; padding: 1px 6px; margin-left: 6px; vertical-align: middle; }
.merkki.varoitus { background: #fbeee5; color: var(--okra); }

.lista th, .lista td { text-align: left; font-size: 13px; }
.lista td.luku, .lista th.luku { text-align: right; }
.lista.kapea { width: auto; min-width: 420px; }
.lista td.tiedosto { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.lista th form { margin-top: 4px; }
.esikatselu tr.th-lohko th, .esikatselu tr.th-lohko td { border-top: 2px solid var(--kuusikko); }
.esikatselu tr.tuotu-jo td { color: var(--muted); }
.tilit tr.luokka-ohita th, .tilit tr.luokka-ohita td { color: var(--muted); }
.tilit tr.luokka-sivukulu th { color: var(--okra); }
details summary { cursor: pointer; margin: 12px 0; color: var(--muted); }

/* Kirjautuminen */
body.login-sivu { align-items: center; justify-content: center; }
.login { width: 340px; display: flex; flex-direction: column; gap: 14px; }
.login .logo { padding: 0 0 6px; color: var(--kuusikko); }
.login label { display: flex; flex-direction: column; gap: 4px; }
.login form { display: flex; flex-direction: column; gap: 14px; }
.login .nappi.microsoft { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px; font-weight: 500; }
.login .vaihtoehto summary { font-size: 13px; color: var(--muted); cursor: pointer; margin: 4px 0 10px; }
