/* hidden-attribuutti piilottaa aina, vaikka elementille olisi annettu display-arvo. */
[hidden] {
  display: none !important;
}

/* Asiallinen perustyyli. Fontit ovat laitteen omia, ei ulkoisia fonttipalveluja. */

:root {
  --text: #1c1f23;
  --muted: #5b6470;
  --background: #ffffff;
  --surface: #f4f5f7;
  --border: #d5d9de;
  --accent: #1f4e79;
  --accent-text: #ffffff;
  --accent-soft: #e8eff6;
  --success: #1e6b3a;
  --success-soft: #e6f2ea;
  --danger: #a4262c;
  --danger-soft: #f8e7e8;
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

html {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 100%;
  line-height: 1.5;
  color: var(--text);
  background: var(--background);
}

body {
  margin: 0;
}

/* --- Ylä- ja alaosa --- */

.nowrap {
  white-space: nowrap;
}

.break-anywhere {
  overflow-wrap: anywhere;
}

/* Luettelon haku (Äänestäjät-välilehti). */
.list-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1rem;
  margin-bottom: 0.6rem;
}

.list-filter input[type="search"] {
  flex: 1 1 14rem;
  max-width: 24rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
}

.list-filter p {
  margin: 0;
}

.table tr[hidden] {
  display: none;
}

/* Ajastimen laskuri (äänilippu, odotustila, iso näyttö, ylläpito). */
.timer {
  display: inline-block;
  margin: 0.4rem 0;
  padding: 0.3rem 0.8rem;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  font-variant-numeric: tabular-nums;
}

.timer strong {
  font-size: 1.3em;
}

.timer.timer-done {
  border-color: var(--danger);
  color: var(--danger);
}

.screen .timer {
  font-size: 2rem;
}

.timer-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0.6rem 0;
}

.timer-custom input[type="number"] {
  width: 4.2rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
}

.timer-form .small-button {
  padding: 0.3rem 0.7rem;
  font-size: 0.9rem;
}

/* Yhteyskatkoksen ilmoitus ylälaidassa (static/js/app.js). */
.connection-lost {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 0.6rem 1rem;
  background: var(--danger);
  color: #ffffff;
  text-align: center;
}

.connection-lost[hidden] {
  display: none;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.site-header-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  font-size: 0.9rem;
}

.site-name {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.content {
  max-width: 48rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.site-footer {
  max-width: 48rem;
  margin: 0 auto;
  padding: 0 1.25rem 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

/* --- Teksti --- */

h1 {
  font-size: 1.75rem;
  line-height: 1.25;
  margin: 0 0 1rem;
}

h2 {
  font-size: 1.2rem;
  line-height: 1.3;
  margin: 0 0 0.5rem;
}

a {
  color: var(--accent);
}

.muted {
  color: var(--muted);
}

/* --- Painikkeet --- */

button,
.button {
  display: inline-block;
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

button.secondary,
.button.secondary {
  background: var(--background);
  color: var(--accent);
}

button.button-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: normal;
  text-decoration: underline;
}

.inline-form {
  display: inline;
  margin: 0;
}

/* --- Lomakkeet --- */

.form {
  display: grid;
  gap: 0.4rem;
  justify-items: start;
}

.form.narrow {
  max-width: 22rem;
}

.form label {
  margin-top: 0.4rem;
  font-weight: 600;
}

/* :where() pitää tarkkuuden pienenä, jotta yksittäiset kentät voi kaventaa. */
.form :where(input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"])),
.form :where(select, textarea) {
  width: 100%;
  max-width: 28rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
}

/*
 * iPhonen Safari piirtää päivämääräkentän omalla harmaalla tyylillään ja vähimmäisleveydellä,
 * jolloin kenttä venyy kortin reunan yli. Kenttä näyttää nyt muiden kenttien kaltaiselta.
 */
.form input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  min-width: 0;
  min-height: calc(1.5em + 1rem + 2px);
  background: var(--background);
  color: var(--text);
  text-align: left;
}

.form input[type="date"]::-webkit-date-and-time-value {
  margin: 0;
  text-align: left;
}

.form button {
  margin-top: 0.8rem;
}

.form-error {
  color: var(--danger);
}

/* --- Ilmoitukset --- */

.messages {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}

.message {
  margin-bottom: 0.5rem;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.message-success {
  background: var(--success-soft);
  color: var(--success);
}

.message-error {
  background: var(--danger-soft);
  color: var(--danger);
}

/* --- Oman tilin poisto --- */

a.danger-link {
  color: var(--danger);
}

/* Vain varsinainen painike. Tekstilinkin näköiset poistopainikkeet (button-link danger) pysyvät linkkeinä. */
button.danger:not(.button-link) {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

.card-danger {
  border-color: var(--danger);
}

/* --- Ylläpitosivu --- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.toolbar h1 {
  margin: 0;
}

.card {
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card-open {
  border-color: var(--accent);
  border-left-width: 4px;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.status {
  margin: 0;
  color: var(--muted);
}

.card-open .status {
  color: var(--success);
  font-weight: 600;
}

.pin {
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius);
  background: var(--accent-soft);
  font-size: 1.1rem;
}

.pin strong {
  letter-spacing: 0.08em;
}

.poll-list {
  margin: 0.75rem 0;
  padding-left: 1.2rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.status-ok {
  color: var(--success);
  font-weight: 600;
}

.small {
  font-size: 0.85rem;
}

button.button-link.danger {
  color: var(--danger);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Taulukot */

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.table th {
  font-size: 0.85rem;
  color: var(--muted);
}

.row-actions {
  text-align: right;
  white-space: nowrap;
}

.row-actions form + form {
  margin-left: 0.8rem;
}

/*
 * Kapealla näytöllä (puhelin) taulukon rivit pinotaan allekkain, jottei sivu leviä näytön yli.
 * Solun data-label näytetään otsikkona, koska taulukon otsikkorivi piilotetaan.
 */
@media (max-width: 40rem) {
  .table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .table,
  .table tbody {
    display: block;
    width: 100%;
  }

  /* Solut rivittyvät: lyhyet (nimi ja tila) mahtuvat samalle riville, pitkät jatkuvat seuraavalle. */
  .table tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.8rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
  }

  .table td {
    padding: 0;
    border-bottom: 0;
  }

  .table td[data-label],
  .table td.cell-wide {
    width: 100%;
  }

  .table td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
  }

  .table .row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    width: 100%;
    text-align: left;
    white-space: normal;
  }

  .row-actions form + form {
    margin-left: 0;
  }
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.badge-ok {
  background: var(--success-soft);
  color: var(--success);
}

/* Nimien esikatselu */

.preview {
  width: 100%;
  max-width: 28rem;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  background: var(--surface);
}

.preview p {
  margin: 0.3rem 0;
}

.name-preview {
  max-height: 16rem;
  margin: 0.3rem 0;
  overflow-y: auto;
}

/* Äänestäjän odotustila */

.waiting {
  text-align: center;
  padding: 2rem 1rem;
}

/* Organisaatiovalikko */

.menu {
  position: relative;
}

.menu summary {
  cursor: pointer;
  color: var(--accent);
}

.menu ul {
  position: absolute;
  left: 0;
  /* Välilehtien (z-index 40) päällä, kun valikko avataan sivun ylälaidassa. */
  z-index: 45;
  min-width: 14rem;
  max-width: calc(100vw - 2.5rem);
  margin: 0.4rem 0 0;
  padding: 0.4rem 0;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.menu li a {
  display: block;
  padding: 0.35rem 0.9rem;
  text-decoration: none;
}

.menu li a[aria-current="page"] {
  font-weight: 600;
}

/* --- Äänestykset --- */

.h2 {
  font-size: 1.2rem;
}

.center {
  text-align: center;
}

.notice {
  margin: 0.8rem 0;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  background: #fff6e0;
}

.proposal-list {
  margin: 0;
  padding-left: 1.4rem;
}

.proposal-list li {
  margin: 0.2rem 0;
}

.card-decision {
  border-color: var(--success);
  background: var(--success-soft);
}

.decision {
  margin: 0.6rem 0 0;
  font-size: 1.1rem;
}

.live-count {
  font-size: 1.2rem;
  margin: 0.4rem 0;
}

.radio-group {
  margin: 0.6rem 0 0;
  padding: 0;
  border: 0;
}

.radio-group legend {
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.checkbox-group {
  margin: 0.4rem 0 0.4rem 1.6rem;
  padding: 0;
  border: 0;
}

.checkbox-group legend {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
}

label.radio,
label.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: normal;
  margin: 0.2rem 0;
}

.form label.radio,
.form label.checkbox {
  margin-top: 0.2rem;
}

.checkbox-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 0 1rem;
  width: 100%;
}

.name-columns {
  columns: 14rem;
  margin: 0;
  padding-left: 1.2rem;
}

.fraction {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.form .fraction input {
  width: 5rem;
}

/* Määräenemmistö: lisäkysymykset näkyvät vain, kun niitä tarvitaan. */
.current-setting {
  margin: 0 0 0.6rem;
}

.qualified-details {
  display: none;
  gap: 0.4rem;
  justify-items: start;
  width: 100%;
  padding: 0.2rem 0 0.2rem 1rem;
  border-left: 3px solid var(--border);
}

.qualified:has(input[name="mode"][value="qualified"]:checked) .qualified-details {
  display: grid;
}

.custom-fraction {
  display: none;
}

.qualified:has(option[value="custom"]:checked) .custom-fraction {
  display: flex;
}

.round-details {
  margin: 0.5rem 0;
}

.round-details summary {
  cursor: pointer;
}

/* Tulos */

.result {
  margin: 0.6rem 0;
}

.result-row {
  margin-bottom: 0.8rem;
}

.result-label {
  font-weight: 600;
}

/* Tulospalkki on SVG, jotta leveys voidaan antaa ilman style-attribuuttia (sisällön suojauskäytäntö). */
.result-bar {
  display: block;
  width: 100%;
  height: 0.75rem;
  margin: 0.25rem 0;
  border-radius: 999px;
  background: var(--surface);
  overflow: hidden;
}

.result-bar rect {
  fill: var(--muted);
}

.result-row.winner .result-bar rect {
  fill: var(--accent);
}

.result-number {
  font-size: 0.9rem;
}

.result-meta {
  font-size: 0.9rem;
  color: var(--muted);
}

/* Äänilippu */

.ballot fieldset {
  margin: 0 0 1rem;
  padding: 0;
  border: 0;
}

.ballot-option {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.6rem;
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1.1rem;
  cursor: pointer;
}

.ballot-option input {
  width: 1.3rem;
  height: 1.3rem;
  flex: none;
}

.ballot-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.ballot-blank {
  color: var(--muted);
}

.ballot-submit {
  width: 100%;
  padding: 0.9rem;
  font-size: 1.1rem;
}

.ballot-submit:disabled {
  opacity: 0.6;
}

/* Henkilövaalin äänilippu */

.ballot-instructions {
  margin: 0.4rem 0 1rem;
}

.ballot-submit + .ballot-submit {
  margin-top: 0.6rem;
}

.ballot .ranks {
  display: grid;
  gap: 0.3rem;
  width: 100%;
}

.ballot .ranks select {
  max-width: none;
  padding: 0.7rem;
  font-size: 1.1rem;
}

.ballot-option:has(input:disabled) {
  opacity: 0.5;
  cursor: default;
}

/* Arvonta */

.draw-group {
  display: grid;
  gap: 0.4rem;
  justify-items: start;
  width: 100%;
  margin: 0.6rem 0;
}

.draw-group p {
  margin: 0 0 0.2rem;
}

/* --- Iso näyttö --- */

/* Kaikki mitat ovat rem-yksiköissä, joten koko sivu skaalautuu näytön leveyden mukaan. */
html.screen-page {
  font-size: clamp(16px, 1.6vw, 40px);
}

.screen {
  min-height: 100vh;
}

.screen-content {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1.5rem 2rem 3rem;
}

.screen-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}

.screen-main {
  padding-top: 1.5rem;
}

.screen-main h1 {
  font-size: 2.4rem;
  line-height: 1.2;
  margin: 0 0 1rem;
}

.screen-choices,
.screen-status {
  font-size: 1.6rem;
}

.screen-candidates {
  columns: 2;
  font-size: 1.4rem;
  padding-left: 1.4rem;
}

.screen-count {
  margin: 1rem 0 0;
  font-size: 4rem;
  line-height: 1;
}

.screen-address {
  font-size: 2rem;
  font-weight: 600;
  margin: 0.5rem 0;
}

.screen-pin {
  font-size: 3rem;
  margin: 0.5rem 0;
}

.screen-pin strong {
  letter-spacing: 0.15em;
}

/* Tulos tiiviisti yhdelle riville per vaihtoehto, jotta se mahtuu näytölle ilman vieritystä. */
.screen .result-row {
  display: grid;
  grid-template-columns: minmax(10rem, 1.2fr) 2fr minmax(7rem, auto);
  align-items: center;
  gap: 0.3rem 1rem;
  margin-bottom: 0.7rem;
}

.screen .result-row > .small {
  grid-column: 1 / -1;
}

/* Kirjautumisen QR-koodi isolla näytöllä. Valkoinen tausta, jotta kamera tunnistaa sen. */
.screen-login {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2rem 3rem;
}

.screen-qr {
  background: #ffffff;
  line-height: 0;
}

.screen-qr .qr-code {
  display: block;
  width: 100%;
  height: auto;
  shape-rendering: crispEdges;
}

.screen-qr-large {
  width: min(22rem, 40vw);
}

.screen-qr-small {
  float: right;
  width: 9rem;
  margin: 0 0 1rem 1.5rem;
  line-height: 1.3;
  text-align: center;
}

/* Nimellisessä asiavaalissa nimet luetaan seinältä. */
.screen .result-voters {
  font-size: 1.15rem;
  color: var(--text);
}

.screen .result-label,
.screen .decision {
  font-size: 1.4rem;
}

.screen .result-number {
  font-size: 1.2rem;
  text-align: right;
}

.screen .result-bar {
  height: 1.1rem;
  margin: 0;
}

.screen-fullscreen {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  font-size: 0.8rem;
  opacity: 0.5;
}

.screen-fullscreen:hover,
.screen-fullscreen:focus {
  opacity: 1;
}

:fullscreen .screen-fullscreen {
  display: none;
}

.password {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 1.05rem;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* Uuden tunnuksen tiedot: otsikko ja arvo omilla riveillään, pitkä osoite rivittyy ruudun sisällä. */
.credentials {
  margin: 0.5rem 0;
}

.credentials dt {
  margin-top: 0.4rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.credentials dd {
  margin: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.rename-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.rename-form input {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
}

/* Organisaatiot-taulukko: nimikenttä joustaa, jotta taulukko mahtuu kortin sisään. */
.organization-table .rename-form input {
  width: 100%;
  min-width: 8rem;
}

/* Tilamerkki ja sen vaihtolinkki samalla rivillä; linkki rivittyy merkin alle, jos tila loppuu. */
.state-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem 0.5rem;
}

.state-line + .state-line {
  margin-top: 0.35rem;
}

/* --- Esikatselu ja odotustila --- */

.preview-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.preview-choices {
  padding-left: 1.4rem;
  font-size: 1.1rem;
}

.preview-choices li {
  margin: 0.2rem 0;
}

.queued {
  margin-top: 1rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

.queued-list {
  padding-left: 1.4rem;
  margin: 0.3rem 0;
}

.screen .queued-list {
  font-size: 1.3rem;
}

.decision-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.decision-list li {
  padding: 0.6rem 0;
  border-top: 1px solid var(--border);
}

.decision-list li:first-child {
  border-top: 0;
}

.decision-text {
  display: block;
  color: var(--muted);
}

.screen .preview-label {
  font-size: 1.1rem;
}

.screen .preview-choices {
  columns: 2;
  font-size: 1.5rem;
}

.screen-main h2 {
  font-size: 1.6rem;
  margin-top: 2rem;
}

.screen .decision-list {
  font-size: 1.3rem;
}

/* --- Valintaikkuna ja tukitila --- */

.dialog {
  max-width: 32rem;
  width: calc(100% - 2rem);
  padding: 1.2rem 1.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.dialog h2 {
  margin-top: 0;
}

.support-mode {
  border-left: 4px solid var(--accent);
}

/* --- Esityslistan PDF sovelluksen sisällä --- */

dialog.pdf-viewer {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  display: none;
  flex-direction: column;
  background: var(--surface);
}

dialog.pdf-viewer[open] {
  display: flex;
}

.pdf-viewer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--background);
}

.pdf-viewer-bar strong {
  flex: 1;
}

.pdf-viewer-pages {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  -webkit-overflow-scrolling: touch;
}

.pdf-viewer-pages canvas {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto 0.5rem;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.pdf-viewer-message {
  padding: 1rem;
}

/* Ylläpitäjän tietojen muokkaus Käyttäjät-sivulla */

.row-edit {
  margin-top: 0.3rem;
}

.row-edit summary {
  cursor: pointer;
  color: var(--accent);
}

.row-edit .form {
  margin-top: 0.4rem;
}

/* Ääntenlaskijan näkymä: tulokset latauspainikkeen alla. */
.teller-results {
  margin-top: 1rem;
}

/* Toissijainen vaihtoehto avattavana osana (esim. erillinen ääntenlaskijan tunnus). */
.secondary-option {
  margin-top: 1.2rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
}

.secondary-option summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}

.secondary-option .form {
  margin-top: 0.4rem;
}

/*
 * --- Välilehdet (kokous, äänestys, testimateriaalit) ---
 * Välilehdet pysyvät näkymän ylälaidassa, kun sivua vieritetään alas, jotta osiota voi vaihtaa aina.
 * Tausta on peittävä, jottei sisältö näy välilehtien läpi. Yhteyskatkoksen ilmoitus (z-index 50) jää päälle.
 */

.tabs {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  gap: 0.2rem;
  margin: 0.6rem 0 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--background);
  overflow-x: auto;
}

/* Ankkurilinkki (esim. käyttöohjeen sisällysluettelo) ei jätä otsikkoa välilehtien alle. */
html:has(.tabs) {
  scroll-padding-top: 3.5rem;
}

.tabs a {
  padding: 0.55rem 0.8rem;
  margin-bottom: -1px;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.tabs a:hover {
  color: var(--text);
}

.tabs a[aria-current="page"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.support-request {
  margin-top: 1rem;
}

.setup-list {
  margin: 0;
  padding-left: 1.2rem;
}

.setup-list li {
  margin: 0.25rem 0;
}

/* Vastaesitysten järjestyksen nuolipainikkeet */

.proposal-list li {
  padding: 0.25rem 0;
}

.move-buttons {
  display: inline-flex;
  gap: 0.25rem;
  vertical-align: middle;
}

button.move-button {
  min-width: 2.4rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--background);
  color: var(--accent);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

button.move-button:disabled {
  border-color: var(--border);
  color: var(--border);
  cursor: default;
}

.proposal-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-top: 0.25rem;
}

/* --- Testimateriaalit --- */

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.document-edit {
  margin: 0 0 1rem;
}

/* Markdown-tiedostosta tehty sisältö: käyttöohje, tehtävälista ja versiohistoria. */
.document {
  max-width: 46rem;
  overflow-wrap: anywhere;
}

.document h1 {
  font-size: 1.6rem;
}

.document h2 {
  margin-top: 2rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.3rem;
}

.document h3 {
  margin-top: 1.4rem;
  font-size: 1.1rem;
}

.document li {
  margin: 0.25rem 0;
}

.document table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.document th,
.document td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  /* Sarake on vähintään pisimmän sanan levyinen ("Äänest äjä" katkesi kesken sanan). Leveä taulukko vierii sivusuunnassa. */
  overflow-wrap: break-word;
}

.document code {
  padding: 0.05rem 0.25rem;
  border-radius: 4px;
  background: var(--surface);
  font-size: 0.9em;
}

.document .toc {
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.document .toc .toctitle {
  font-weight: 600;
}

.document .toc ul {
  margin: 0.2rem 0;
  padding-left: 1.2rem;
}

.feedback-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.feedback-item {
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border);
}

.feedback-item:last-child {
  border-bottom: 0;
}

.feedback-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.feedback-text,
.feedback-response {
  margin: 0.4rem 0;
  overflow-wrap: anywhere;
}

.feedback-response {
  padding-left: 0.7rem;
  border-left: 3px solid var(--accent-soft);
}

.feedback-update {
  margin: 0.4rem 0;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  background: var(--surface);
}

.feedback-update button {
  margin-top: 0.4rem;
}
