/* BM Office – ulkoasu. Biomitan värit kuten BM Maastossa. */

:root {
  --brand: #285836;
  --brand-dark: #1c3f27;
  --brand-soft: #e6efe8;
  --blue: #0e427e;
  --red: #b23a2e;
  --bg: #eef1ee;
  --surface: #ffffff;
  --text: #17201a;
  --muted: #5d685f;
  --line: #d5dbd6;
  --sel: rgba(14, 66, 126, .14);
  --shadow: 0 1px 6px rgba(0, 0, 0, .18);
  --radius: 8px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #2c6a40;
    --brand-dark: #23573a;
    --brand-soft: #1f3326;
    --blue: #7fb0ea;
    --bg: #111613;
    --surface: #1b221d;
    --text: #e9efea;
    --muted: #9eaaa1;
    --line: #2f3a32;
    --sel: rgba(127, 176, 234, .22);
    --shadow: 0 1px 8px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text);
}
button, select, input, textarea { font: inherit; color: inherit; }
button, select {
  min-height: 32px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); cursor: pointer; white-space: nowrap;
}
button:hover { border-color: var(--brand); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-dark); }
button.on { background: var(--brand-soft); border-color: var(--brand); font-weight: 600; }
input[type="search"], input:not([type]), .pageno {
  min-height: 32px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface);
}
.muted { color: var(--muted); }
.grow { flex: 1; }
.right { margin-left: auto; }

/* Yläpalkki */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 6px 16px;
  background: var(--brand); color: #fff; flex: none;
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; font-size: 16px; }
.brand img { border-radius: 6px; background: #fff; }
.apps { display: flex; gap: 4px; }
.apps a { color: #fff; text-decoration: none; padding: 5px 10px; border-radius: 6px; opacity: .85; display: inline-flex; align-items: center; gap: 6px; }
.apps a img { border-radius: 4px; }
.apps a:hover { background: rgba(255,255,255,.12); opacity: 1; }
.apps a.on { background: rgba(255,255,255,.2); opacity: 1; font-weight: 600; }
.docname { margin-left: auto; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }

.view { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* Koti */
.home { max-width: 960px; margin: 0 auto; padding: 32px 16px; overflow: auto; width: 100%; }
.home h1 { margin: 0 0 8px; color: var(--brand); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .home h1 { color: #6cc189; } }
.lead { font-size: 16px; color: var(--muted); max-width: 640px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin: 24px 0 8px; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left;
  padding: 16px; min-height: 96px; border-radius: 10px; white-space: normal; box-shadow: var(--shadow);
}
.tile b { font-size: 16px; }
.tile img { border-radius: 9px; margin-bottom: 4px; }
.tile span { color: var(--muted); }
.hint { color: var(--muted); }
.recent { list-style: none; padding: 0; margin: 0; }
.recent li { display: flex; gap: 12px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.recent button { border: none; background: none; padding: 0; color: var(--blue); text-decoration: underline; min-height: 0; }
.recent .kind { font-size: 12px; padding: 2px 6px; border-radius: 4px; background: var(--brand-soft); }
body.dragging::after {
  content: "Pudota tiedosto avataksesi"; position: fixed; inset: 12px; border: 3px dashed var(--brand);
  border-radius: 16px; background: rgba(40,88,54,.12); display: grid; place-items: center;
  font-size: 22px; font-weight: 700; color: var(--brand); pointer-events: none; z-index: 100;
}

/* Työkalurivit */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 6px 12px; padding: 6px 12px; align-items: center;
  background: var(--surface); border-bottom: 1px solid var(--line); flex: none;
}
.toolbar .group { display: flex; gap: 4px; align-items: center; }
.toolbar .group.grow { flex: 1; min-width: 180px; }
.toolbar .group.grow input { flex: 1; min-width: 0; }
.mini { display: inline-flex; align-items: center; }
.mini input[type="color"] { width: 34px; height: 32px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.pageno { width: 52px; text-align: center; }
.statusbar {
  display: flex; gap: 12px; padding: 4px 12px; font-size: 12px; color: var(--muted);
  background: var(--surface); border-top: 1px solid var(--line); flex: none;
}

/* PDF */
.pdf-body { flex: 1; display: flex; min-height: 0; }
.thumbs { width: 190px; flex: none; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); }
.thumbbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border-bottom: 1px solid var(--line); }
.thumbbar button { min-height: 28px; padding: 2px 6px; font-size: 12px; }
.thumblist { list-style: none; margin: 0; padding: 8px; overflow: auto; flex: 1; }
.thumblist li {
  position: relative; margin: 0 auto 10px; padding: 4px; border: 2px solid transparent; border-radius: 6px;
  cursor: pointer; text-align: center; font-size: 12px; color: var(--muted); width: fit-content;
}
.thumblist li.sel { border-color: var(--blue); background: var(--sel); }
.thumblist li.cur .num { color: var(--text); font-weight: 700; }
.thumblist li.dropbefore { box-shadow: 0 -4px 0 var(--brand); }
.thumblist li.dropafter { box-shadow: 0 4px 0 var(--brand); }
.thumblist canvas { display: block; background: #fff; box-shadow: var(--shadow); max-width: 150px; }
.pdf-scroll { flex: 1; overflow: auto; position: relative; outline: none; background: var(--bg); }
.pdf-pages { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 16px; min-width: fit-content; }
.page { position: relative; background: #fff; box-shadow: var(--shadow); flex: none; }
.page canvas.render { position: absolute; inset: 0; width: 100%; height: 100%; }
.page .textLayer { z-index: 1; }
.page .anns { position: absolute; inset: 0; z-index: 2; }
.page .hits { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.page .hits div { position: absolute; background: rgba(255, 170, 0, .35); outline: 1px solid rgba(200, 120, 0, .7); }
.page .hits div.cur { background: rgba(255, 90, 0, .45); }
.pdf-pages[data-tool="select"] .anns { pointer-events: none; }
.pdf-pages[data-tool="select"] .ann { pointer-events: auto; }
.pdf-pages:not([data-tool="select"]) .anns { cursor: crosshair; }
.pdf-pages[data-tool="text"] .anns { cursor: text; }
.ann { position: absolute; transform-origin: 0 100%; }
.ann.sel { outline: 2px dashed var(--blue); outline-offset: 2px; }
.pdf-pages[data-tool="select"] .ann { cursor: move; }
.ann.text { white-space: pre; line-height: 1.2; font-family: Helvetica, Arial, sans-serif; padding: 0; min-width: 4px; }
.ann.text[contenteditable="true"] { outline: 1px solid var(--blue); background: rgba(255,255,255,.6); cursor: text; }
.ann.img img { width: 100%; height: 100%; display: block; pointer-events: none; }
.ann .handle {
  position: absolute; right: -6px; bottom: -6px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--blue); border: 2px solid #fff; cursor: nwse-resize; display: none;
}
.ann.sel .handle { display: block; }
.anns svg.ink { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.anns svg.ink path { pointer-events: stroke; }
.pdf-pages[data-tool="select"] svg.ink path { cursor: move; }
.anns svg.ink path.sel { stroke-dasharray: 6 3; }
.drawbox { position: absolute; border: 1px dashed var(--blue); pointer-events: none; }
.empty { position: absolute; inset: 0; display: grid; place-content: center; gap: 12px; text-align: center; color: var(--muted); }
.side { width: 280px; flex: none; overflow: auto; padding: 12px; background: var(--surface); border-left: 1px solid var(--line); }
.side h3 { margin: 0 0 12px; font-size: 15px; }
.side label.field { display: block; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.side label.field input, .side label.field select, .side label.field textarea {
  display: block; width: 100%; margin-top: 2px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); font-size: 14px;
}
.check { display: flex; gap: 6px; align-items: center; }

/* Asiakirja */
@font-face { font-family: "Poppins"; font-weight: 400; font-style: normal; font-display: swap; src: local("Poppins"), local("Poppins-Regular"), url("vendor/fonts/poppins-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 400; font-style: italic; font-display: swap; src: local("Poppins Italic"), local("Poppins-Italic"), url("vendor/fonts/poppins-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 700; font-style: normal; font-display: swap; src: local("Poppins Bold"), local("Poppins-Bold"), url("vendor/fonts/poppins-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 700; font-style: italic; font-display: swap; src: local("Poppins Bold Italic"), local("Poppins-BoldItalic"), url("vendor/fonts/poppins-latin-700-italic.woff2") format("woff2"); }

/* Nauhavalikko (Wordin tapaan) */
.ribbon { background: var(--surface); border-bottom: 1px solid var(--line); flex: none; }
.rtabs { display: flex; gap: 2px; padding: 0 8px; overflow-x: auto; }
.rtab { border: none; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: 6px 12px; min-height: 34px; }
.rtab:hover { background: var(--bg); border-color: transparent; }
.rtab.on { border-bottom-color: var(--brand); font-weight: 600; color: var(--brand); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .rtab.on { color: #6cc189; border-bottom-color: #6cc189; } }
.rtab.file { background: var(--brand); color: #fff; border-radius: 6px 6px 0 0; margin-right: 6px; }
.rtab.file:hover, .rtab.file.on { background: var(--brand-dark); color: #fff; border-bottom-color: var(--brand-dark); }
.rtab.ctx { color: var(--blue); }
.rpanel { display: flex; gap: 0; padding: 4px 6px 0; overflow-x: auto; border-top: 1px solid var(--line); min-height: 98px; }
.ribbon.collapsed .rpanel { display: none; }
.rgroup { display: flex; flex-direction: column; padding: 2px 8px 0; border-right: 1px solid var(--line); flex: none; }
.rgroup:last-child { border-right: none; }
.rbody { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 3px; }
.rrow { display: flex; gap: 2px; align-items: center; flex-wrap: nowrap; }
.rname { text-align: center; font-size: 11px; color: var(--muted); padding: 2px 0 3px; white-space: nowrap; }
.rb { min-height: 28px; padding: 2px 7px; border-color: transparent; background: none; display: inline-flex; align-items: center; gap: 4px; }
.rb:hover { background: var(--bg); border-color: var(--line); }
.rb.on { background: var(--brand-soft); border-color: var(--brand); }
.rb.big { flex-direction: column; min-width: 58px; min-height: 66px; padding: 4px 6px; justify-content: flex-start; white-space: normal; text-align: center; line-height: 1.15; font-size: 12px; max-width: 92px; }
.rb.big .ic { font-size: 22px; line-height: 28px; }
.rb .ic.sm { font-size: 14px; }
.rb.b .lb { font-weight: 800; } .rb.i .lb { font-style: italic; font-family: Georgia, serif; } .rb.u .lb { text-decoration: underline; } .rb.s .lb { text-decoration: line-through; }
.ribbon select, .ribbon input.num { min-height: 28px; padding: 2px 4px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.ribbon input.num { width: 58px; }
.rlabel { font-size: 12px; color: var(--muted); min-width: 78px; }
.unit { font-size: 12px; color: var(--muted); margin-right: 8px; }
.split { display: inline-flex; align-items: stretch; }
.split .rb { flex-direction: column; gap: 0; padding: 2px 5px 1px; }
.split .swatch { display: block; width: 18px; height: 4px; border-radius: 1px; }
.split.fc .lb { font-weight: 700; }
.split .drop { display: inline-flex; align-items: center; padding: 0 3px; cursor: pointer; font-size: 10px; border-radius: 4px; position: relative; }
.split .drop:hover { background: var(--bg); }
.split .drop input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.menuwrap { position: relative; display: inline-flex; }
.menu { position: absolute; top: 100%; left: 0; z-index: 50; min-width: 190px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.menu .mi { border: none; background: none; text-align: left; border-radius: 4px; min-height: 30px; white-space: nowrap; }
.menu .mi:hover { background: var(--brand-soft); }
.menu hr { border: none; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
.menu.symgrid { display: grid; grid-template-columns: repeat(8, 1fr); min-width: 300px; }
.menu.symgrid .mi { text-align: center; padding: 2px; font-size: 15px; }
.tgrid { display: grid; grid-template-columns: repeat(8, 18px); gap: 2px; padding: 4px; }
.tgrid i { width: 18px; height: 18px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.tgrid i.on { background: var(--brand-soft); border-color: var(--brand); }
.tgrid-info { font-size: 12px; color: var(--muted); padding: 0 4px 4px; }
.stylegal { display: grid; grid-template-columns: repeat(6, 96px); grid-auto-rows: 30px; gap: 3px; max-height: 66px; overflow-y: auto; padding-right: 4px; }
.sty { min-height: 0; height: 30px; padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: #111; text-align: left; overflow: hidden; font-family: Poppins, Calibri, sans-serif; font-size: 11px; }
.sty.on { outline: 2px solid var(--brand); }
.sty-otsikko1 span, .sty-otsikko2 span { color: #285836; font-size: 13px; } .sty-otsikko3 span { color: #0e427e; }
.sty-otsikko span { color: #380c00; font-size: 14px; } .sty-alaotsikko span { color: #285836; }
.sty-kuvateksti span, .sty-taulukkootsikko span { color: #285836; font-style: italic; font-size: 10px; } .sty-lahde span { font-style: italic; font-size: 10px; } .sty-lainaus span { font-style: italic; color: #444; }

/* Asiakirjan sivu: Biomitan raportin mitat */
.doc-body { flex: 1; display: flex; min-height: 0; position: relative; }
.doc-scroll { flex: 1; overflow: auto; padding: 24px 16px 64px; background: var(--bg); }
.sheet {
  --pw: 210mm; --ph: 297mm; --mt: 30mm; --mr: 28.8mm; --mb: 38mm; --ml: 28.8mm;
  width: var(--pw); min-height: var(--ph); margin: 0 auto; color: #000; position: relative;
}
/* Sivut piirretään tekstin taakse: valkoinen paperi, ylä- ja alatunniste joka sivulla */
.pglayer { position: absolute; inset: 0; z-index: 0; }
.pg { position: absolute; left: 0; right: 0; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.pg-head, .pg-foot { position: absolute; left: var(--ml); right: var(--mr); font: 9pt/1.45 Poppins, sans-serif; color: #285836; }
.pg-head { top: 14mm; }
.pg-foot { bottom: 4mm; }
.pg-head .hf-empty, .pg-foot .hf-empty { color: transparent; font-size: 8pt; }
.sheet:hover .hf-empty { color: #b7c2b9; }
.hfrow { position: relative; padding-right: 90px; width: 100%; }
.hfrow .pn { position: absolute; right: 0; top: 0; }
.hfrow.foot { padding-right: 0; display: flex; align-items: flex-end; gap: 16px; }
.hfrow.foot .pn { position: static; margin-left: auto; }
.hf-logo { width: 26mm; height: auto; display: block; }
.hf-editing .paper { opacity: .45; pointer-events: none; }
.hf-editing .pglayer { z-index: 3; }
.pg-head.editing, .pg-foot.editing { outline: 1px dashed #285836; outline-offset: 4px; background: #fff; z-index: 4; }
.hf-editor { min-height: 1.5em; outline: none; white-space: pre-wrap; color: #285836; cursor: text; }
.hf-bar { position: absolute; left: 0; top: 100%; margin-top: 8px; display: flex; gap: 4px; align-items: center; flex-wrap: wrap; font: 12px system-ui, sans-serif; color: #444; background: #f0f4f1; border: 1px solid #c8d4cb; border-radius: 6px; padding: 4px 6px; white-space: nowrap; }
.pg-foot .hf-bar { top: auto; bottom: 100%; margin: 0 0 8px; }
.hf-bar button { min-height: 24px; padding: 1px 8px; font-size: 12px; }
.paper {
  position: relative; z-index: 1; padding: var(--mt) var(--mr) var(--mb) var(--ml); outline: none; color: #000; background: transparent; min-height: var(--ph);
  font: 12pt/1.75 Poppins, Calibri, Arial, sans-serif; text-align: justify; hyphens: manual;
  counter-reset: h1;
}
.paper > :first-child { margin-top: 0; }
.paper h1, .paper h2, .paper h3, .paper h4 { font-weight: 400; line-height: 1.3; text-align: left; break-after: avoid; }
.paper h1 { font-size: 18pt; color: #285836; margin: 24pt 0 12pt; counter-increment: h1; counter-reset: h2; }
.paper h2 { font-size: 14pt; color: #285836; margin: 12pt 0 8pt; counter-increment: h2; counter-reset: h3; }
.paper h3 { font-size: 12pt; color: #0e427e; margin: 10pt 0 6pt; counter-increment: h3; }
.paper h4 { font-size: 12pt; color: #0e427e; margin: 8pt 0 4pt; font-style: italic; }
.paper h1:not(.nonum)::before { content: counter(h1) "."; display: inline-block; min-width: 1cm; }
.paper h2:not(.nonum)::before { content: counter(h1) "." counter(h2); display: inline-block; min-width: 1cm; }
.paper h3:not(.nonum)::before { content: counter(h1) "." counter(h2) "." counter(h3); display: inline-block; min-width: 1.4cm; }
.paper h1[data-num=""]::before, .paper h2[data-num=""]::before, .paper h3[data-num=""]::before { content: none; }
.paper h1[data-num=""] { counter-increment: none; }
.paper p { margin: 0 0 4pt; }
.paper p.title { font-size: 22pt; line-height: 1.6; color: #380c00; text-align: left; margin: 0 0 6pt; }
.paper p.subtitle { font-size: 14pt; color: #285836; text-align: left; margin: 0 0 12pt; }
.paper p.kuvateksti, .paper p.taulukkootsikko { font-size: 10pt; font-style: italic; color: #285836; line-height: 1.4; text-align: left; margin: 6pt 0 4pt; }
.paper p.taulukkootsikko { break-after: avoid; }
.paper p.lahde { font-size: 10pt; font-style: italic; text-align: left; line-height: 1.5; }
.paper p.eivalia { margin: 0; line-height: 1.5; text-align: left; }
.paper p.cover-logo { text-align: left; margin: 0 0 12pt; }
.paper blockquote { margin: 6pt 1cm; font-style: italic; color: #404040; }
.paper ul, .paper ol { margin: 0 0 4pt; padding-left: 1.27cm; text-align: left; }
.paper li { margin: 0 0 2pt; }
.paper table { border-collapse: collapse; width: 100%; margin: 4pt 0 12pt; text-align: left; line-height: 1.5; }
.paper td, .paper th { border: none; border-top: 1px solid #000; border-bottom: 1px solid #000; padding: 0 4pt; vertical-align: top; min-width: 30px; }
.paper th { background: #0e427e; color: #fff; font-weight: 700; }
.paper img { max-width: 100%; height: auto; }
.paper img.sel-img { outline: 3px solid var(--blue); outline-offset: 2px; }
.paper a { color: #0e427e; }
.paper hr { border: none; border-top: 1px solid #999; margin: 8pt 0; }
.paper hr.pagebreak { border: none; height: 0; margin: 0; break-after: page; page-break-after: always; position: relative; overflow: visible; }
.marks .paper hr.pagebreak { border-top: 1px dotted #7aa6d6; margin: 6pt 0; }
.marks .paper hr.pagebreak.section::after { content: "Osanvaihto (seuraava sivu)"; }
.paper p.kuva-paikka { border: 1px dashed #9aa79c; color: #5d685f; text-align: center; padding: 48pt 0; font-size: 9pt; }
.marks .paper hr.pagebreak::after { content: "Sivunvaihto"; position: absolute; left: 50%; top: -8px; transform: translateX(-50%); font: 10px system-ui, sans-serif; color: #7aa6d6; background: #fff; padding: 0 6px; }
.paper sup.fn { color: #0e427e; cursor: pointer; font-size: 70%; }
.paper aside.fn-list { margin-top: 24pt; border-top: 1px solid #999; padding-top: 4pt; font-size: 9pt; line-height: 1.4; text-align: left; }
.paper aside.fn-list ol { margin: 0; padding-left: 1.2em; }
.paper nav.toc { display: block; margin: 0 0 12pt; padding: 6pt 0; user-select: none; text-align: left; line-height: 1.9; }
.paper nav.toc .toc-title { display: none; }
.paper nav.toc a { display: flex; color: #000; text-decoration: none; }
.paper nav.toc a b { font-weight: 400; min-width: 1cm; }
.paper nav.toc a.l2 { padding-left: 1cm; }
.paper nav.toc a.l2 b { min-width: 1.2cm; }
.paper nav.toc a:hover { color: #0e427e; }
.marks .paper p::after, .marks .paper h1::after, .marks .paper h2::after, .marks .paper h3::after, .marks .paper li::after { content: "¶"; color: #7aa6d6; margin-left: 2px; }
.web .sheet { width: auto; max-width: none; min-height: 100% !important; background: #fff; }
.web .pglayer { display: none; }
.web .paper { padding: 16px 32px; text-align: left; min-height: 0; }
/* Kommentit ja muutokset */
.paper span.cmt { background: #fff1a8; border-bottom: 2px solid #e5b800; border-radius: 2px; }
.paper span.cmt[data-done] { background: #f3f3e6; border-bottom-color: #c9c9a8; }
.paper span.cmt.rv-active, .paper .rv-active { outline: 2px solid #e5b800; }
.paper ins.trk { color: #0b62c4; text-decoration: underline; text-decoration-color: #0b62c4; background: #e8f1fc; }
.paper del.trk { color: #b3261e; text-decoration: line-through; background: #fdeceb; }
.paper.final-view del.trk { display: none; }
.paper.final-view ins.trk { color: inherit; text-decoration: none; background: none; }
.paper.final-view span.cmt { background: none; border: 0; }
.doc-review { width: 290px; flex: none; overflow: auto; padding: 10px; background: var(--surface); border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.doc-review[hidden] { display: none; }
.doc-review .rv-top { display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.doc-review .rv-top h3 { margin: 0; font-size: 14px; flex: 1; }
.doc-review .rv-top button { min-height: 0; padding: 2px 8px; }
.rv-card { border: 1px solid var(--line); border-left: 4px solid #e5b800; border-radius: 8px; padding: 8px; background: var(--bg); font-size: 13px; cursor: pointer; }
.rv-card.on { box-shadow: 0 0 0 2px #e5b80088; }
.rv-card.done { opacity: .6; }
.rv-card.chg.ins { border-left-color: #0b62c4; } .rv-card.chg.del { border-left-color: #b3261e; }
.rv-head { display: flex; justify-content: space-between; gap: 6px; font-size: 12px; }
.rv-head span { color: var(--muted); }
.rv-quote { color: var(--muted); font-style: italic; margin: 4px 0; overflow-wrap: anywhere; }
.rv-card textarea { width: 100%; box-sizing: border-box; font: inherit; resize: vertical; }
.rv-acts { display: flex; gap: 4px; margin-top: 4px; }
.rv-acts button { min-height: 0; padding: 2px 8px; font-size: 12px; }
/* Palstat, tavutus, kentät, kaavat, ristiviittaukset, luettelot */
.paper div.cols { column-gap: 1cm; }
.paper div.cols-2 { column-count: 2; } .paper div.cols-3 { column-count: 3; }
.paper.marks div.cols { outline: 1px dashed #9ab; }
.paper.hyphenate { hyphens: auto; -webkit-hyphens: auto; }
.paper span.field { background: #e9e9e9; border-radius: 2px; }
.paper a.xref { color: inherit; text-decoration: none; background: #e9e9e9; border-radius: 2px; }
.paper span.eq { display: inline-block; padding: 0 2px; cursor: pointer; font-size: 1.05em; }
.paper span.eq.block { display: block; text-align: center; margin: 6pt 0; }
.paper span.eq:hover { outline: 1px dashed #7ab648; }
.paper p.eqline { text-align: center; }
.paper ol.paren { list-style: none; counter-reset: li; }
.paper ol.paren > li { counter-increment: li; }
.paper ol.paren > li::before { content: counter(li) ") "; margin-left: -0.8cm; display: inline-block; width: 0.8cm; }
.paper ol.ml, .paper ol.ml ol { list-style: none; counter-reset: ml; }
.paper ol.ml li { counter-increment: ml; }
.paper ol.ml li::before { content: counters(ml, ".") ". "; margin-left: -1.1cm; display: inline-block; width: 1.1cm; }
.charpick { max-height: 300px; overflow: auto; margin-bottom: 8px; }
.charpick .sub { font-size: 12px; color: var(--muted); margin: 6px 0 2px; }
.chargrid { display: flex; flex-wrap: wrap; gap: 2px; }
.chargrid .ch { min-width: 32px; min-height: 30px; padding: 2px 4px; font-size: 16px; }
@media print { .paper span.cmt { background: none; border: 0; } .paper span.field, .paper a.xref { background: none; } .doc-review { display: none !important; } }
.doc-outline { width: 240px; flex: none; overflow: auto; padding: 12px; background: var(--surface); border-right: 1px solid var(--line); }
.doc-outline h3 { margin: 0 0 8px; font-size: 14px; }
.doc-outline ol { list-style: none; margin: 0; padding: 0; }
.doc-outline li button { border: none; background: none; text-align: left; padding: 3px 4px; min-height: 0; white-space: normal; width: 100%; font-size: 13px; }
.doc-outline li button:hover { background: var(--brand-soft); }
.doc-outline li.l2 { padding-left: 14px; } .doc-outline li.l3 { padding-left: 28px; }
.doc-find { position: absolute; right: 16px; top: 8px; z-index: 20; width: 300px; padding: 10px; display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.doc-find .row { display: flex; gap: 4px; }
.doc-find input:not([type]) { flex: 1; min-width: 0; }
.doc-find .replace { display: none; }
.doc-find.with-replace .replace { display: flex; }
.doc-find.with-replace button.replace { display: inline-flex; }
::highlight(bm-find) { background: #ffe08a; }
::highlight(bm-find-cur) { background: #ff9d3d; }
.zoombar { display: inline-flex; align-items: center; gap: 4px; }
.zoombar button { min-height: 20px; padding: 0 6px; }
.zoombar input { width: 110px; }
.dialog label.field { display: block; margin: 10px 0; font-size: 13px; color: var(--muted); }
.dialog label.field input, .dialog label.field select, .dialog label.field textarea { display: block; width: 100%; min-width: 280px; margin-top: 3px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); font-size: 14px; }
.dialog table.stats td { padding: 4px 12px 4px 0; }
.dialog table.stats td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* Taulukko */
.formulabar { display: flex; gap: 6px; padding: 4px 8px; background: var(--surface); border-bottom: 1px solid var(--line); flex: none; }
.formulabar .addr { flex: none; width: 96px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; text-align: center; font-variant-numeric: tabular-nums; background: var(--surface); }
.formulabar .fxbtn { font-style: italic; font-family: Georgia, serif; min-width: 34px; }
.formulabar input { flex: 1; font-family: ui-monospace, Consolas, monospace; }
.grid-wrap { flex: 1; overflow: auto; position: relative; outline: none; background: var(--surface); }
.grid-sizer { position: absolute; top: 0; left: 0; width: 1px; height: 1px; pointer-events: none; }
.grid { position: sticky; top: 0; left: 0; width: 0; height: 0; overflow: visible; }
.grid .c {
  position: absolute; padding: 0 4px; line-height: 1.25; overflow: hidden; white-space: nowrap; display: flex; align-items: flex-end;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 13px; background: var(--surface); color: var(--text);
  font-family: Calibri, Carlito, 'Segoe UI', Arial, sans-serif; padding-bottom: 2px;
}
.grid .c > span { overflow: hidden; text-overflow: clip; flex: 0 1 auto; min-width: 0; }
.grid .c.num { justify-content: flex-end; font-variant-numeric: tabular-nums; }
.grid .c.wrap { white-space: pre-wrap; word-break: break-word; }
.grid .c.wrap > span { white-space: pre-wrap; }
.grid .c.err { color: var(--red); }
.grid .h { background: var(--bg); color: var(--muted); justify-content: center; align-items: center; font-size: 12px; z-index: 5; user-select: none; padding: 0; position: absolute; }
.grid .h.on { background: var(--brand-soft); color: var(--text); font-weight: 600; }
.grid .corner { z-index: 7; }
.grid .h .rsz { position: absolute; z-index: 2; }
.grid .h.col .rsz { right: -3px; top: 0; bottom: 0; width: 7px; cursor: col-resize; }
.grid .h.row .rsz { bottom: -3px; left: 0; right: 0; height: 7px; cursor: row-resize; }
.grid .selbox { position: absolute; border: 1px solid var(--blue); background: var(--sel); pointer-events: none; z-index: 8; }
.grid .activebox { position: absolute; border: 2px solid var(--blue); pointer-events: none; z-index: 8; }
.grid .fillhandle { position: absolute; width: 8px; height: 8px; background: var(--blue); border: 1px solid #fff; z-index: 9; cursor: crosshair; }
.grid .fillbox { position: absolute; border: 2px dashed var(--blue); pointer-events: none; z-index: 8; }
.grid .refbox { position: absolute; border: 2px solid; pointer-events: none; z-index: 8; }
.grid .copybox { position: absolute; border: 2px dashed #2e8b57; pointer-events: none; z-index: 8; animation: march 1s linear infinite; }
@keyframes march { 50% { border-color: #9fd4ad; } }
.grid .freezeline { position: absolute; background: #9aa59c; z-index: 7; pointer-events: none; }
.grid .freezeline.h { left: 0; right: -9999px; height: 1px; } .grid .freezeline.v { top: 0; bottom: -9999px; width: 1px; }
.grid .fbtn { position: absolute; right: 2px; bottom: 2px; min-height: 0; height: 17px; width: 17px; padding: 0; font-size: 10px; line-height: 1; border-radius: 3px; background: var(--surface); color: var(--text); z-index: 2; }
.grid .fbtn.on { background: var(--blue); color: #fff; }
.nogrid .grid .c:not(.h) { border-color: transparent; }
.rsztip { position: absolute; z-index: 20; background: #222; color: #fff; font-size: 12px; padding: 2px 6px; border-radius: 4px; pointer-events: none; }
.cell-editor {
  position: absolute; z-index: 5; resize: none; border: 2px solid var(--blue); padding: 1px 3px; margin: 0;
  font: 13px/20px system-ui, sans-serif; background: var(--surface); color: var(--text); outline: none; overflow: hidden;
}
.sheettabs { display: flex; align-items: center; gap: 4px; padding: 4px 8px; background: var(--surface); border-top: 1px solid var(--line); flex: none; }
.tabs { display: flex; gap: 2px; overflow-x: auto; }
.tabs button { border-radius: 0 0 6px 6px; border-top: none; min-height: 28px; }
.tabs button.on { background: var(--brand-soft); border-color: var(--brand); font-weight: 600; }

/* Ikkunat ja ilmoitukset */
.dialog { border: none; border-radius: 12px; padding: 20px; box-shadow: var(--shadow); background: var(--surface); color: var(--text); max-width: calc(100vw - 32px); }
.dialog h3 { margin: 0 0 4px; }
.dialog canvas { display: block; width: 100%; max-width: 600px; aspect-ratio: 3 / 1; border: 1px solid var(--line); border-radius: 8px; background: #fff; touch-action: none; margin: 12px 0; }
.dialog .row { display: flex; gap: 8px; }
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 200;
  background: #222; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}
.toast.err { background: var(--red); }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px; }
  .docname { display: none; }
  .thumbs { display: none; }
  .side { position: absolute; right: 0; top: 0; bottom: 0; z-index: 10; }
  .sheet { width: 100% !important; }
  .paper { --ml: 6mm; --mr: 6mm; text-align: left; }
  .hf { --ml: 6mm; --mr: 6mm; }
}

@media print {
  body:not(.printing-slides):not(.printing-sheet) > *:not(#view-asiakirja) { display: none !important; }
  body.printing-slides > #view-asiakirja { display: none !important; }
  #view-asiakirja > *:not(.doc-body), .doc-outline, .doc-find, .hf { display: none !important; }
  .doc-body, .doc-scroll { display: block; padding: 0; overflow: visible; background: none; }
  .sheet { box-shadow: none; width: auto !important; min-height: 0; zoom: 1 !important; background-image: none; }
  .paper { padding: 0; }
  .paper hr.pagebreak { border: none; margin: 0; }
  .paper hr.pagebreak::after { content: none; }
}


/* Pikatyökalurivi, tilarivin painikkeet */
.qat { display: inline-flex; gap: 0; align-items: center; margin-right: 8px; padding-right: 8px; border-right: 1px solid var(--line); }
.qat .rb { min-height: 28px; padding: 0 6px; }
.sbtn { border: none; background: none; min-height: 0; padding: 0 4px; font-size: 12px; color: inherit; }
.sbtn:hover { background: var(--bg); }

/* Hiiren oikean painikkeen valikko */
.ctxmenu { position: fixed; z-index: 300; min-width: 230px; max-width: 320px; padding: 4px; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 18px rgba(0,0,0,.25); display: flex; flex-direction: column; }
.ctxmenu .mi { display: flex; justify-content: space-between; gap: 16px; border: none; background: none; text-align: left; min-height: 28px; padding: 3px 10px; border-radius: 4px; }
.ctxmenu .mi:hover:not(:disabled) { background: var(--brand-soft); }
.ctxmenu kbd { font: 11px system-ui, sans-serif; color: var(--muted); }
.ctxmenu hr { border: none; border-top: 1px solid var(--line); margin: 4px 0; }
.ctxmenu .sub { font-size: 11px; color: var(--muted); padding: 2px 10px; }
.ctxmenu .stylerow { display: flex; flex-wrap: wrap; gap: 2px; padding: 0 6px; }
.ctxmenu .stylerow .mi { flex: none; min-height: 24px; padding: 1px 6px; font-size: 12px; border: 1px solid var(--line); }
.ctxmenu .hint { font-size: 11px; color: var(--muted); padding: 4px 10px 2px; }

/* Pikatyökalurivi valinnan yläpuolella */
.doc-scroll { position: relative; }
.minibar { position: absolute; z-index: 30; display: flex; gap: 2px; align-items: center; padding: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 3px 12px rgba(0,0,0,.2); }
.minibar button { min-height: 26px; padding: 0 7px; border-color: transparent; background: none; }
.minibar button:hover { background: var(--bg); }
.minibar .b { font-weight: 800; } .minibar .i { font-style: italic; font-family: Georgia, serif; } .minibar .u { text-decoration: underline; } .minibar .fc { color: #c00000; font-weight: 700; }
.minibar select { min-height: 26px; padding: 0 4px; max-width: 130px; }

/* Kuvan koonmuutoskahva */
.img-handle { position: absolute; z-index: 5; width: 14px; height: 14px; border-radius: 3px; background: var(--blue); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--blue); cursor: nwse-resize; touch-action: none; }

@media print {
  .pglayer, .minibar, .img-handle, .ctxmenu { display: none !important; }
  .paper [data-pg] { margin-top: var(--pgorig, 0) !important; }
}

/* ---------- Esitys ---------- */
.sl-body { flex: 1; display: flex; min-height: 0; }
.sl-thumbs { width: 196px; flex: none; overflow: auto; background: var(--surface); border-right: 1px solid var(--line); outline: none; }
.sl-thumbs ol { list-style: none; margin: 0; padding: 10px 8px 10px 4px; }
.sl-thumbs li { display: flex; gap: 6px; align-items: flex-start; padding: 4px; margin-bottom: 8px; border-radius: 6px; cursor: pointer; }
.sl-thumbs li .num { width: 18px; text-align: right; font-size: 12px; color: var(--muted); padding-top: 2px; }
.sl-thumbs li .thumb { position: relative; overflow: hidden; box-shadow: 0 0 0 1px var(--line); pointer-events: none; flex: none; }
.sl-thumbs li.on .thumb { box-shadow: 0 0 0 3px var(--brand); }
.sl-thumbs li.hid .thumb { opacity: .4; }
.sl-thumbs li.hid .num { text-decoration: line-through; }
.sl-thumbs li.dropbefore { box-shadow: 0 -3px 0 var(--brand); }
.sl-thumbs li.dropafter { box-shadow: 0 3px 0 var(--brand); }
.sl-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.sl-stagewrap { flex: 1; overflow: auto; position: relative; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.sl-stage { box-shadow: var(--shadow); }
.sl-stage.hiddenslide { opacity: .55; }
.sl-notes { flex: none; border-top: 1px solid var(--line); background: var(--surface); }
.sl-notes textarea { width: 100%; height: 72px; border: none; resize: vertical; padding: 8px 12px; background: var(--surface); color: var(--text); font: 13px/1.4 system-ui, sans-serif; outline: none; }
.sl-slide { position: relative; overflow: hidden; flex: none; color: #17201a; }
.sl-el { position: absolute; transform-origin: 50% 50%; }
.sl-stage .sl-el { cursor: move; }
.sl-stage .sl-el.selected { outline: 1px solid rgba(14, 66, 126, .6); }
.sl-text { display: flex; flex-direction: column; overflow: visible; }
.sl-text.v-middle { justify-content: center; } .sl-text.v-bottom { justify-content: flex-end; }
.sl-el .tx { outline: none; padding: 4px; word-wrap: break-word; overflow-wrap: anywhere; }
.sl-el .tx ul, .sl-el .tx ol { margin: 0; padding-left: 1.3em; }
.sl-el .tx li { margin: 0 0 .25em; }
.sl-el .tx li::marker { color: #7ab648; }
.sl-el .tx div, .sl-el .tx p { margin: 0; }
.sl-el.editing { cursor: text; outline: 1px dashed #0e427e; }
.sl-el.editing .tx { cursor: text; min-height: 1em; }
.sl-el .tx[data-ph]:empty::before, .sl-el .tx[data-ph] > ul:only-child > li:only-child:has(> br:only-child)::after { color: #9aa59c; }
.sl-stage .sl-el .tx[data-ph]:not(:focus)::before { content: attr(data-ph); color: #9aa59c; pointer-events: none; }
.sl-stage .sl-el .tx[data-ph]:not(:focus) > * { display: none; }
.sl-stage .sl-text:has(.tx[data-ph]) { outline: 1px dashed #c4ccc6; }
.sl-shape svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.sl-shape .tx { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; }
.sl-img img { width: 100%; height: 100%; display: block; object-fit: fill; user-select: none; pointer-events: none; }
.sl-ph { border: 2px dashed #c4ccc6; display: grid; place-items: center; }
.sl-ph button { background: rgba(255,255,255,.8); border: 1px solid #c4ccc6; color: #5d685f; font-size: 15px; line-height: 1.5; padding: 10px 16px; }
.sl-table table { width: 100%; height: 100%; border-collapse: collapse; font-family: Poppins, sans-serif; }
.sl-table th, .sl-table td { border: 1px solid #444; padding: .2em .45em; text-align: left; vertical-align: middle; }
.sl-table th { background: #0e427e; color: #fff; font-weight: 700; }
.sl-table td { background: #fff; color: #17201a; }
.sl-table [contenteditable="true"] { outline: none; box-shadow: inset 0 0 0 1px rgba(14,66,126,.35); }
.sl-chart svg { display: block; }
.showgrid .sl-stage { background-image: linear-gradient(rgba(14,66,126,.12) 1px, transparent 1px), linear-gradient(90deg, rgba(14,66,126,.12) 1px, transparent 1px) !important; background-size: 5% 8.88%; }
.theme-bmgreen .ic { color: #285836; } .theme-dark .ic { color: #17201a; }
/* Moveable Biomitan väreillä */
.sl-stagewrap .moveable-line { background: #0e427e !important; }
.sl-stagewrap .moveable-control { border-color: #fff !important; background: #0e427e !important; }
.sl-stagewrap .moveable-guideline { background: #c4721f !important; }

/* Esitystila */
.sl-show { position: fixed; inset: 0; z-index: 500; background: #000; display: grid; place-items: center; cursor: none; }
.sl-show .sl-slide { box-shadow: none; }
.sl-show .sl-end { color: #ccc; font: 20px system-ui, sans-serif; display: grid; place-items: center; width: 100%; height: 100%; }
.sl-show #sl-show-cur:has(.sl-end) { width: 100vw !important; height: 100vh !important; }
.sl-blank { position: absolute; inset: 0; }
.sl-show.presenter { cursor: default; grid-template-columns: 66vw 1fr; place-items: start; background: #111; color: #eee; }
.sl-show.presenter .pv-main { padding: 20px; }
.sl-show.presenter .pv-side { padding: 20px 20px 20px 0; display: flex; flex-direction: column; gap: 10px; height: 100vh; font-family: system-ui, sans-serif; }
.pv-next-l, .pv-help { color: #999; font-size: 13px; }
.pv-timer { font-size: 40px; font-variant-numeric: tabular-nums; color: #b9e08f; }
.pv-pos { font-size: 15px; color: #ccc; }
.pv-notes { flex: 1; overflow: auto; font-size: 20px; line-height: 1.45; white-space: pre-wrap; background: #1c1c1c; border-radius: 8px; padding: 12px; }

/* Diojen tulostus PDF:ksi */
#sl-print { display: none; }
@media print {
  body.printing-slides > *:not(#sl-print) { display: none !important; }
  body.printing-slides #sl-print { display: block !important; }
  .sl-printpage { break-after: page; page-break-after: always; overflow: hidden; position: relative; }
  .sl-printpage:last-child { break-after: auto; }
  body.printing-slides { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Taulukon kaava-apu, suodatin, ikkunat */
.cell-editor { font: 13px/20px Calibri, Carlito, 'Segoe UI', Arial, sans-serif; z-index: 12; box-shadow: 0 2px 8px rgba(0,0,0,.15); white-space: pre; }
#view-taulukko { position: relative; }
.sheet-assist { position: absolute; z-index: 60; max-width: 520px; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); font-size: 13px; }
.sheet-assist .aclist { max-height: 300px; overflow: auto; padding: 4px; }
.sheet-assist .aci { padding: 4px 8px; border-radius: 5px; cursor: pointer; }
.sheet-assist .aci.on, .sheet-assist .aci:hover { background: var(--brand-soft); }
.sheet-assist .aci .fi { color: var(--muted); font-size: 12px; }
.sheet-assist .d { color: var(--muted); font-size: 12px; }
.sheet-assist .ahint { padding: 6px 10px; font-family: ui-monospace, Consolas, monospace; }
.sheet-assist .ahint u { font-weight: 700; text-decoration: none; background: var(--brand-soft); }
.sheet-assist .ahint .d { font-family: system-ui, sans-serif; }
.filterpop { position: absolute; z-index: 70; width: 250px; padding: 8px; display: flex; flex-direction: column; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.filterpop > button { text-align: left; border: none; background: none; min-height: 28px; }
.filterpop > button:hover { background: var(--brand-soft); }
.filterpop hr { border: none; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
.filterpop .fvals { max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }
.filterpop .fvals label { font-size: 13px; padding: 1px 0; }
.filterpop .row { display: flex; gap: 6px; margin-top: 4px; }
#sheet-find { top: 140px; }
.fxlist { width: 100%; min-width: 460px; margin: 8px 0; font-family: ui-monospace, Consolas, monospace; }
.fxinfo { min-height: 64px; font-size: 13px; margin-bottom: 8px; max-width: 520px; }
.dialog .row { display: flex; gap: 8px; align-items: center; }
.chartprev { width: 640px; max-width: 80vw; height: 380px; margin: 10px 0; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
#sh-print { display: none; }
@media print {
  body.printing-sheet > *:not(#sh-print) { display: none !important; }
  body.printing-sheet #sh-print { display: block !important; font: 10pt Calibri, Arial, sans-serif; }
  #sh-print table { border-collapse: collapse; }
  #sh-print td { border: 1px solid #bbb; padding: 2px 5px; }
}

/* ---------- BM Elinpiirimallinnus ---------- */
.view.rp { display: flex; flex-direction: column; min-height: 0; }
.view.rp[hidden] { display: none; }
.rp-toolbar { flex-wrap: wrap; }
.rp-toolbar .sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 4px; }
.rp-banner { background: #fdecea; color: #7a0019; font-size: 12.5px; padding: 4px 12px; border-bottom: 1px solid #f3c5c0; }
.rp-body { flex: 1; display: flex; min-height: 0; }
.rp-side { width: 430px; flex: none; overflow: auto; padding: 8px 12px 24px; background: var(--surface); border-right: 1px solid var(--line); }
.rp-side details { border-bottom: 1px solid var(--line); padding: 6px 0; }
.rp-side summary { font-weight: 600; cursor: pointer; padding: 4px 0; color: #285836; }
.rp-side fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 6px 0; padding: 4px 8px 8px; }
.rp-side .field { display: flex; flex-direction: column; gap: 2px; font-size: 13px; margin: 4px 0; }
.rp-params .field input.src { font-size: 12px; color: var(--muted); }
.rp-side input.missing { border-color: #d62728; background: #fff5f5; }
.rp-side .small, .rp-results .small { font-size: 12px; }
.rp-side .row { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0; }
.rp-tdef { display: flex; flex-wrap: wrap; gap: 4px; align-items: end; font-size: 12px; margin-bottom: 6px; }
.rp-tdef label { display: flex; flex-direction: column; width: 74px; }
.rp-tablewrap { overflow: auto; max-height: 260px; }
.rp-table { border-collapse: collapse; font-size: 12px; }
.rp-table th { background: #0e427e; color: #fff; font-weight: 500; padding: 3px 4px; position: sticky; top: 0; white-space: nowrap; }
.rp-table td { padding: 0; border: 1px solid var(--line); }
.rp-table input { width: 74px; border: 0; padding: 3px 4px; font: inherit; background: transparent; }
.rp-table td:first-child input { width: 64px; }
.rp-table button { min-height: 0; padding: 1px 6px; border: 0; background: none; }
.rp-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.rp-mapwrap { flex: 1 1 55%; position: relative; min-height: 260px; }
#rp-map { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.rp-mapbtns { position: absolute; right: 10px; top: 60px; display: flex; flex-direction: column; gap: 4px; }
.rp-mapbtns button { min-height: 0; width: 32px; height: 32px; padding: 0; }
.rp-legend { position: absolute; left: 10px; top: 28px; background: rgba(255,255,255,.88); border-radius: 8px; padding: 6px 8px; font-size: 12px; display: flex; flex-direction: column; gap: 2px; }
.rp-legend i.lg { display: inline-block; width: 14px; height: 10px; margin-right: 6px; vertical-align: middle; }
.lg.nest { background: #ffd400; border: 1px solid #5a2800; } .lg.turb { background: #c83020; border-radius: 50%; } .lg.obs { border-top: 2px solid rgba(14,66,126,.7); height: 0 !important; }
.lg.iso50 { border: 2px solid #7a0019; } .lg.iso75 { border: 1.5px solid #b34700; } .lg.iso95 { border: 1.5px dashed #5a5a5a; }
.lg.heat { background: linear-gradient(90deg, #ffffcc, #fd8d3c, #bd0026); }
.rp-results { flex: 1 1 45%; overflow: auto; padding: 8px 14px 20px; border-top: 1px solid var(--line); background: var(--surface); }
.rp-results h3 { margin: 10px 0 4px; font-size: 15px; color: #285836; }
.rp-res { border-collapse: collapse; font-size: 12.5px; }
.rp-res th { background: #0e427e; color: #fff; font-weight: 500; padding: 4px 6px; text-align: left; }
.rp-res td { border-bottom: 1px solid var(--line); padding: 3px 6px; white-space: nowrap; }
.rp-res .sig-vähäinen { color: #285836; } .rp-res .sig-kohtalainen { color: #b36b00; font-weight: 600; } .rp-res .sig-merkittävä { color: #b3261e; font-weight: 700; }
.rp-warn { background: #fff4e0; border: 1px solid #f0c36d; border-radius: 6px; padding: 6px 10px; margin: 4px 0; font-size: 13px; }
@media (max-width: 900px) { .rp-body { flex-direction: column; } .rp-side { width: auto; max-height: 45vh; } }

/* ---------- BM Suunnittelu ---------- */
.view.ds { display: flex; flex-direction: column; min-height: 0; }
.view.ds[hidden] { display: none; }
.ds-toolbar { flex-wrap: wrap; gap: 3px; }
.ds-toolbar button { padding: 4px 8px; }
.ds-toolbar button.on, .ds-status button.on { background: var(--brand-soft, #e6efe8); border-color: #285836; color: #285836; }
.ds-toolbar .sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 3px; }
.ds-body { flex: 1; display: flex; min-height: 0; }
.ds-left, .ds-right { width: 230px; flex: none; overflow: auto; padding: 8px 10px; background: var(--surface); font-size: 13px; }
.ds-left { border-right: 1px solid var(--line); } .ds-right { border-left: 1px solid var(--line); width: 250px; }
.ds-left h3, .ds-right h3 { font-size: 13px; margin: 8px 0 4px; color: #285836; }
.ds-layer { display: flex; align-items: center; gap: 4px; padding: 2px 0; }
.ds-layer.cur .nm { font-weight: 700; color: #285836; }
.ds-layer button { min-height: 0; padding: 1px 4px; border: 0; background: none; }
.ds-layer .nm { flex: 1; text-align: left; }
.ds-layer input[type=color] { width: 22px; height: 18px; padding: 0; border: 0; }
.ds-objects { display: flex; flex-direction: column; max-height: 50vh; overflow: auto; }
.ds-objects button { text-align: left; min-height: 0; padding: 2px 4px; border: 0; background: none; font-size: 12.5px; }
.ds-objects button.on { background: #dfe9f6; }
.ds-right .field { display: flex; flex-direction: column; gap: 2px; margin: 4px 0; }
.ds-meas { margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.ds-view { flex: 1; position: relative; min-width: 0; }
#ds-canvas { position: absolute; inset: 0; }
#ds-canvas canvas { display: block; cursor: crosshair; }
.ds-viewlabel { position: absolute; left: 10px; top: 8px; font-size: 12px; background: rgba(255,255,255,.8); padding: 2px 8px; border-radius: 6px; pointer-events: none; }
.ds-cmd { border-top: 1px solid var(--line); background: var(--surface); font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.ds-history { height: 74px; overflow: auto; padding: 2px 10px; color: #444; }
.ds-history .cmd { font-weight: 700; color: #0e427e; } .ds-history .warn { color: #b3261e; } .ds-history .res { color: #285836; }
.ds-cmdline { display: flex; align-items: center; gap: 6px; padding: 2px 10px; border-top: 1px solid var(--line); }
.ds-cmdline input { flex: 1; font: inherit; border: 0; outline: none; background: transparent; padding: 4px 0; }
#ds-prompt { color: #0e427e; white-space: nowrap; }
.ds-status { display: flex; align-items: center; gap: 4px; padding: 2px 10px 4px; }
.ds-status #ds-coords { flex: 1; color: var(--muted); }
.ds-status button { min-height: 0; padding: 1px 6px; font-size: 11px; }
@media (max-width: 1000px) { .ds-left { display: none; } .ds-right { width: 200px; } }

.ds-right { width: 300px; }
.ds-rtabs { display: flex; gap: 2px; margin-bottom: 6px; }
.ds-rtabs button { flex: 1; min-height: 0; padding: 4px; font-size: 12.5px; }
.ds-rtabs button.on { background: #e6efe8; border-color: #285836; color: #285836; font-weight: 600; }
.ds-analysis .field { display: flex; flex-direction: column; gap: 2px; margin: 4px 0; font-size: 12.5px; }
.ds-analysis textarea { font: 12px ui-monospace, Consolas, monospace; }
.ds-analysis .small { font-size: 12px; }
.ds-analysis .row { display: flex; gap: 4px; flex-wrap: wrap; margin: 6px 0; }
.an-progress { position: relative; height: 18px; background: #eef1ec; border-radius: 9px; overflow: hidden; margin: 6px 0; }
.an-progress div { position: absolute; inset: 0 auto 0 0; background: #7ab648; transition: width .3s; }
.an-progress span { position: relative; font-size: 11px; padding-left: 8px; line-height: 18px; }
.an-sum { font-size: 12px; border-collapse: collapse; width: 100%; }
.an-sum td { border-bottom: 1px solid var(--line); padding: 2px 4px; vertical-align: top; }
.an-layers { display: flex; flex-wrap: wrap; gap: 3px; margin: 6px 0; }
.an-layers button { min-height: 0; padding: 2px 6px; font-size: 11.5px; }
.an-layers button.on { background: #dfe9f6; border-color: #0e427e; }
.an-rec { font-size: 11.5px; border-collapse: collapse; }
.an-rec th { background: #0e427e; color: #fff; font-weight: 500; padding: 2px 4px; }
.an-rec td { border-bottom: 1px solid var(--line); padding: 2px 4px; white-space: nowrap; }
.ds-legend { position: absolute; right: 10px; bottom: 10px; background: rgba(255,255,255,.92); border-radius: 8px; padding: 6px 10px; font-size: 12px; min-width: 200px; max-width: 280px; }
.ds-legend i { display: inline-block; width: 14px; height: 10px; margin-right: 6px; vertical-align: middle; }
.ds-legend .ramp { height: 10px; margin-top: 4px; background: linear-gradient(90deg, #440154, #3b528b, #21918c, #5ec962, #fde725); border-radius: 3px; }
.ds-legend .ticks { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); }
/* Päästöpohjat */
.em-src { border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; margin: 6px 0; }
.em-src > summary { font-weight: 600; cursor: pointer; font-size: 12.5px; }
.em-row { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 12px; margin: 4px 0; }
.em-row button { min-height: 0; padding: 2px 6px; font-size: 11.5px; }
.em-params { display: flex; flex-wrap: wrap; gap: 4px; font-size: 11.5px; }
.em-params label { display: flex; flex-direction: column; width: 82px; }
.em-params input { width: 100%; box-sizing: border-box; }
.em-calc summary { font-size: 11.5px; cursor: pointer; color: #0e427e; }
.em-rates { border-collapse: collapse; font-size: 11px; width: 100%; margin: 4px 0; }
.em-rates th { background: #0e427e; color: #fff; font-weight: 500; padding: 2px 3px; text-align: left; }
.em-rates td { border-bottom: 1px solid var(--line); padding: 1px 2px; vertical-align: top; }
.em-rates select, .em-rates input { font-size: 11px; max-width: 100%; box-sizing: border-box; }
.em-rates td select { width: 92px; }
.em-in { display: flex; flex-direction: column; gap: 1px; }
.em-in input { width: 74px; }
.em-rates input.missing { border-color: #d62728; background: #fff5f5; }
