:root {
  --navy: #10151f;
  --navy-2: #1a222e;
  --ink: #1a1f26;
  --muted: #5b6672;
  --line: #dbe2ec;
  --line-soft: #e8ecf2;
  --surface: #ffffff;
  --bg: #eef1f6;
  --blue: var(--acc-d,#2f5f8a);
  --blue-dark: var(--acc-dd,#24496b);
  --blue-soft: var(--acc-bd,#e3ebf2);
  --amber: #e08a4a;
  --amber-soft: #faeade;
  --red: #d34242;
  --red-soft: #fff0f0;
  --green: #178755;
  --green-soft: #e9f8f0;
  --shadow: 0 1px 3px rgba(20, 24, 32, .08), 0 10px 30px rgba(20, 24, 32, .04);
  --shadow-lg: 0 2px 6px rgba(20, 24, 32, .05), 0 12px 32px rgba(20, 24, 32, .08);
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
}

/* Pimeätila (design system kohta 11): navy-paletti. Muuttujia käyttävät tyylit vaihtuvat tästä;
   kovakoodatut värit muunnetaan buildissa tiedostoon dark.css (scripts/dark-css.mjs). */
html[data-theme="dark"] {
  color-scheme: dark;
  --navy: #0d1119;
  --navy-2: #182644;
  --ink: #f4f6fa;
  --muted: #98a3ba;
  --line: rgba(255, 255, 255, .12);
  --line-soft: rgba(255, 255, 255, .07);
  --surface: #141a26;
  --bg: #0d1119;
  --blue: var(--acc,#3b6fd1);
  --blue-dark: #8fb4e8;
  --blue-soft: rgba(var(--acc-d-rgb,47,95,168), .18);
  --amber: #f0a468;
  --amber-soft: rgba(224, 138, 74, .16);
  --red: #ff8a7e;
  --red-soft: rgba(224, 69, 60, .16);
  --green: #6fcf8e;
  --green-soft: rgba(46, 155, 92, .15);
  --shadow: 0 1px 3px rgba(0, 0, 0, .35), 0 10px 30px rgba(0, 0, 0, .25);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .35), 0 12px 32px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
html { font-family: var(--font-body); color: var(--ink); background: var(--bg); }
body { margin: 0; min-width: 320px; background: var(--bg); font-family: inherit; color: inherit; font-size: 16px; line-height: 1.45; }
h1, h2, h3 { font-family: var(--font-heading); letter-spacing: -.02em; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(47, 95, 138, .3); outline-offset: 2px; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; color: #dbe6ee; background: var(--navy); border-right: 1px solid #24344a; z-index: 20; }

.brand { height: 74px; padding: 0 22px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid #24344a; }

.brand small { display: block; margin-top: 3px; color: #90a5b8; font-size: 11px; letter-spacing: .035em; }
.main-nav { padding: 18px 12px; display: grid; gap: 5px; }
.nav-item { width: 100%; height: 44px; border: 0; border-radius: 12px; display: flex; align-items: center; gap: 12px; padding: 0 14px; color: #9fb4c7; background: transparent; cursor: pointer; text-align: left; }
.nav-item:hover { color: #fff; background: #1a222e; }
.nav-item.active { color: #fff; background: #24374d; box-shadow: inset 3px 0 #6fa8d6; }
.nav-item svg { width: 18px; height: 18px; }
.nav-group-toggle { width: 100%; height: 44px; border: 0; border-radius: 12px; display: flex; align-items: center; gap: 12px; padding: 0 14px; color: #9fb4c7; background: transparent; cursor: pointer; text-align: left; font: inherit; }
.nav-group-toggle:hover { color: #fff; background: #1a222e; }
.nav-group-toggle svg:first-child { width: 18px; height: 18px; flex-shrink: 0; }
.nav-group-chevron { width: 14px !important; height: 14px !important; margin-left: auto; flex-shrink: 0; transition: transform .18s ease; }
.nav-group.open .nav-group-chevron { transform: rotate(90deg); }
.nav-group-items { display: grid; gap: 3px; padding-left: 16px; overflow: hidden; max-height: 0; transition: max-height .22s ease; }
.nav-group.open .nav-group-items { max-height: 260px; margin-top: 2px; }
.nav-group-items .nav-item { height: 40px; }

.side-label { margin: 4px 10px 11px; color: #6e8299; font-size: 11px; font-weight: 700; letter-spacing: .1em; }
.recent-project { width: 100%; border: 0; border-radius: 8px; display: flex; align-items: center; gap: 10px; padding: 10px; color: #aec0d1; background: transparent; text-align: left; cursor: pointer; }
.recent-project:hover, .recent-project.active { background: #1c2c3d; color: #fff; }
.project-code { width: 32px; height: 32px; flex: 0 0 32px; display: grid; place-items: center; border-radius: 8px; color: #cfe0ee; background: #2a4560; font-size: 11px; font-weight: 800; }
.project-code.muted { background: #263447; color: #9db2c4; }
.recent-project strong, .company-switcher strong { display: block; font-size: 13px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-project small, .company-switcher small { display: block; margin-top: 2px; color: #7c8fa1; font-size: 11px; }
.side-footer { margin-top: auto; padding: 12px; border-top: 1px solid #24344a; }

.company-switcher { width: 100%; display: grid; grid-template-columns: 34px 1fr 18px; gap: 9px; align-items: center; padding: 9px 7px; margin-bottom: 7px; border: 0; background: transparent; color: #dbe4ec; text-align: left; cursor: pointer; }
.company-switcher > span:nth-child(2) { min-width: 0; }
.company-switcher svg { width: 17px; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: #2f5f8a; font-size: 11px; font-weight: 800; }

.workspace { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; height: 58px; padding: 0 30px; display: flex; justify-content: space-between; align-items: center; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.breadcrumb span { color: var(--muted); }
.breadcrumb svg { width: 14px; height: 14px; color: #a5afba; }
.breadcrumb strong { font-weight: 650; }
.top-actions { display: flex; align-items: center; gap: 13px; }
.theme-toggle { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); cursor: pointer; }
.theme-toggle:hover { background: var(--blue-soft); color: var(--blue); }
.theme-toggle svg { width: 17px; height: 17px; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 7px; background: transparent; cursor: pointer; }
.icon-btn:hover { border-color: var(--line); background: #eaeef4; }
.mobile-menu { display: none; }
.content-wrap { width: min(1540px, 100%); margin: 0 auto; padding: 40px 40px 64px; }
.project-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.eyebrow-row { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.status-pill { display: inline-flex; align-items: center; height: 22px; padding: 0 10px; border-radius: 999px; color: #556476; background: #e9edf2; font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.status-pill.success { color: var(--green); background: var(--green-soft); }
.project-heading h1 { margin: 7px 0 4px; font-size: clamp(25px, 2.2vw, 34px); line-height: 1.18; letter-spacing: -.035em; }
.project-heading p, .section-intro p, .analysis-header p { margin: 0; color: var(--muted); }
.primary-btn, .secondary-btn { min-height: 42px; padding: 0 18px; border-radius: var(--r-md); display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 650; font-size: 14px; cursor: pointer; transition: background .15s ease, transform .1s ease; }
.primary-btn:active, .secondary-btn:active { transform: translateY(1px); }
.primary-btn { border: 1px solid var(--blue); color: #fff; background: var(--blue); box-shadow: 0 3px 8px rgba(47, 95, 138, .22); }
.primary-btn:hover { border-color: var(--blue-dark); background: var(--blue-dark); }
.secondary-btn { border: 1px solid var(--line); color: var(--ink); background: #fff; }
.secondary-btn:hover { background: #eaeef4; border-color: #c3ccd8; }
.primary-btn svg, .secondary-btn svg { width: 16px; height: 16px; }
.process-steps { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); margin: 28px 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-lg); }
.process-steps li { position: relative; min-height: 70px; display: flex; align-items: center; gap: 11px; padding: 13px 18px; border-right: 1px solid var(--line-soft); color: #6c7a8b; }
.process-steps li:last-child { border: 0; }
.process-steps li > span { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid #cdd6e0; border-radius: 50%; font-size: 12px; font-weight: 800; }
.process-steps strong, .process-steps small { display: block; }
.process-steps strong { color: #405064; font-size: 13px; }
.process-steps small { margin-top: 2px; font-size: 11px; }
.process-steps li.active { background: #f7fbff; }
.process-steps li.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--blue); }
.process-steps li.active > span, .process-steps li.complete > span { color: #fff; border-color: var(--blue); background: var(--blue); }
.process-steps li.complete > span { font-size: 0; }
.process-steps li.complete > span::before { content: "✓"; font-size: 13px; }

.view { display: none; }

.section-intro, .analysis-header { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 17px; }
.section-intro h2, .analysis-header h2 { margin: 0 0 3px; font-size: 20px; letter-spacing: -.015em; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); }

.file-panel { min-height: 508px; overflow: hidden; }
.file-group { border-bottom: 1px solid var(--line-soft); }

.file-row { width: 100%; min-height: 58px; padding: 8px 10px 8px 13px; display: grid; grid-template-columns: 34px minmax(0, 1fr) 20px; gap: 9px; align-items: center; border: 0; border-left: 3px solid transparent; background: #fff; text-align: left; cursor: pointer; }
.file-row:hover, .file-row.selected { background: var(--blue-soft); border-left-color: var(--blue); }
.file-row strong, .file-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row strong { font-size: 11px; font-weight: 650; }
.file-row small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.file-row > svg { width: 16px; color: #92a0af; }
.file-type { width: 31px; height: 28px; display: grid; place-items: center; border-radius: 4px; font-size: 8px; font-weight: 850; letter-spacing: .04em; }
.file-type.pdf { color: #d24444; background: #feeaea; }

.file-type.xls { color: #21835a; background: #e7f7ef; }
.file-type.doc { color: #4f65b8; background: #e9edfb; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--blue); }
.project-facts { overflow: hidden; }
.auto-badge { padding: 3px 6px; border-radius: 4px; color: var(--blue) !important; background: var(--blue-soft); font-weight: 700; }
.project-facts dl { margin: 0; padding: 5px 15px; }
.project-facts dl div { padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.project-facts dt { color: var(--muted); font-size: 10px; }
.project-facts dd { margin: 3px 0 0; font-size: 12px; font-weight: 650; }
.text-btn { border: 0; color: var(--blue); background: transparent; font-size: 12px; font-weight: 650; cursor: pointer; }
.text-btn:hover { color: var(--blue-dark); text-decoration: underline; }
.project-facts > .text-btn { margin: 12px 15px; padding: 0; }
.analysis-cta { margin-top: 16px; padding: 17px 18px; display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 14px; color: #fff; background: var(--navy-2); border: 1px solid #273e58; border-radius: 9px; box-shadow: var(--shadow); }
.cta-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 7px; color: #83bcff; background: #1a3c60; }
.cta-icon svg { width: 22px; }
.analysis-cta strong { font-size: 14px; }
.analysis-cta p { margin: 3px 0 0; color: #9fb1c5; font-size: 12px; }

.analysis-header { align-items: end; }
.analysis-header h2 { margin-top: 8px; font-size: 28px; }
.analysis-actions { display: flex; gap: 9px; }
.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.metric-card { padding: 22px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.metric-card > span, .metric-card em { display: block; }
.metric-card > span { color: var(--muted); font-size: 11px; font-weight: 650; }
.metric-card strong { display: block; margin: 7px 0 2px; font-size: 26px; letter-spacing: -.03em; }
.metric-card strong small { color: #8794a4; font-size: 12px; letter-spacing: 0; }
.metric-card em { color: var(--muted); font-size: 10px; font-style: normal; }

.metric-card.warning { border-left: 3px solid var(--amber); }
.metric-card.warning strong, .metric-card.warning em { color: #a66500; }
.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { position: relative; flex: 0 0 auto; height: 45px; padding: 0 14px; border: 0; background: transparent; color: var(--muted); font-weight: 650; font-size: 12px; cursor: pointer; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--blue); }
.tab.active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; background: var(--blue); }
.tab > span { margin-left: 5px; padding: 2px 6px; border-radius: 9px; color: #59687a; background: #e8edf2; font-size: 9px; }

.tab-pane { display: none; padding-top: 16px; }
.tab-pane.active { display: block; }

.severity { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; }
.severity svg { width: 15px; }
.severity.high { color: var(--red); background: var(--red-soft); }
.severity.medium { color: var(--amber); background: var(--amber-soft); }

.symbol { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 5px; color: #52708b; background: #edf2f6; font: normal 9px ui-monospace, monospace; }
.source-link { padding: 0; display: inline-flex; align-items: center; gap: 5px; border: 0; color: var(--blue); background: transparent; font-size: 10px; cursor: pointer; text-align: left; }
.source-link:hover { text-decoration: underline; }
.source-link svg { width: 12px; }

.data-panel { overflow: hidden; }
.data-toolbar { min-height: 58px; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.data-toolbar > span { margin-left: auto; color: var(--muted); font-size: 10px; }
.search-field { width: min(340px, 100%); height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.search-field svg { width: 15px; color: #8593a2; }
.search-field input { width: 100%; border: 0; outline: 0; font-size: 12px; }
.search-field:focus-within { border-color: #2f5fa8; box-shadow: 0 0 0 3px rgba(47,95,168,.25); }
.data-toolbar select { height: 36px; padding: 0 28px 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 11px; }

.risk-note { margin: 18px 0; padding: 11px; display: flex; gap: 8px; text-align: left; color: #8a5909; background: var(--amber-soft); border-radius: 8px; font-size: 10px; }
.risk-note svg { flex: 0 0 15px; width: 15px; }

.estimate-panel { overflow: hidden; }
.estimate-top { padding: 17px; display: flex; align-items: end; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.estimate-top > div:last-child { display: flex; align-items: end; gap: 10px; }
.estimate-status { color: var(--blue); background: var(--blue-soft); }
.estimate-top h3 { margin: 7px 0 2px; font-size: 20px; }
.estimate-top p { margin: 0; color: var(--muted); font-size: 11px; }
.estimate-top label { color: var(--muted); font-size: 10px; }

.e-row { min-height: 61px; display: grid; grid-template-columns: 1.45fr repeat(4, .65fr); gap: 12px; align-items: center; padding: 9px 17px; border-bottom: 1px solid var(--line-soft); font-size: 11px; }
.e-row.e-head { min-height: 36px; color: var(--muted); background: #e9edf3; font-size: 9px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.e-row > span:first-child strong, .e-row > span:first-child small { display: block; }
.e-row > span:first-child small { color: var(--muted); margin-top: 2px; font-size: 9px; }

.estimate-summary { padding: 15px 17px; display: grid; justify-content: end; gap: 7px; background: #e9edf3; }
.estimate-summary > div { width: 330px; display: flex; justify-content: space-between; font-size: 11px; }
.estimate-summary > div span { color: var(--muted); }
.estimate-summary em { font-style: normal; }
.estimate-summary .total { margin-top: 5px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; }
.estimate-summary .total strong { font-size: 18px; }
.estimate-footer { min-height: 68px; padding: 12px 17px; display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.estimate-footer > span { display: flex; align-items: center; gap: 7px; color: #94620c; font-size: 10px; }
.estimate-footer > span svg { width: 15px; }
.source-audit { overflow: hidden; }
.source-list > div { min-height: 66px; padding: 10px 15px; display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; border-bottom: 1px solid var(--line-soft); }
.source-list strong, .source-list small { display: block; }
.source-list strong { font-size: 11px; }
.source-list small { margin-top: 3px; color: var(--muted); font-size: 9px; }

.analysis-overlay { position: fixed; inset: 0; z-index: 100; display: none; place-items: center; padding: 20px; background: rgba(5, 15, 27, .78); backdrop-filter: blur(5px); }
.analysis-overlay.open { display: grid; }
.analysis-modal { width: min(460px, 100%); padding: 34px; color: #fff; background: #121821; border: 1px solid #24374d; border-radius: 12px; box-shadow: 0 30px 90px rgba(0,0,0,.35); }


.analysis-modal h2 { margin: 8px 0 5px; font-size: 22px; text-align: center; }
.analysis-modal > p { margin: 0 0 22px; color: #a9b8c9; text-align: center; font-size: 12px; }

.analysis-log { display: grid; gap: 9px; margin-top: 22px; padding-top: 18px; border-top: 1px solid #223347; color: #7c8fa1; font-size: 11px; }
.analysis-log span::before { content: "○"; display: inline-block; width: 19px; }
.analysis-log span.done { color: #d7e2ea; }
.analysis-log span.done::before { content: "✓"; color: #53d193; }
.analysis-log span.current { color: #8fbfe0; }
.analysis-log span.current::before { content: "●"; color: #6fa8d6; }

.dialog-backdrop{ position: fixed; inset: 0; z-index: 49; visibility: hidden; opacity: 0; background: rgba(8, 20, 35, .28); transition: .2s ease; }
.dialog-backdrop.open{ visibility: visible; opacity: 1; }

.dialog-head{ min-height: 74px; padding: 16px 19px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.dialog-head h3{ margin: 3px 0 0; font-size: 17px; }

dialog { width: min(690px, calc(100% - 30px)); padding: 0; border: 0; border-radius: 10px; color: var(--ink); box-shadow: 0 25px 90px rgba(0,0,0,.24); }
dialog::backdrop { background: transparent; }
.dialog-body { padding: 20px; }

.dialog-actions { padding: 13px 20px; display: flex; justify-content: end; gap: 9px; border-top: 1px solid var(--line); background: #e9edf3; }
.toast { position: fixed; z-index: 200; left: 50%; bottom: 26px; min-height: 44px; max-width: calc(100% - 30px); display: flex; align-items: center; gap: 9px; padding: 0 15px; color: #fff; background: #121821; border: 1px solid #24374d; border-radius: 8px; box-shadow: 0 15px 45px rgba(0,0,0,.2); font-size: 12px; transform: translate(-50%, 100px); opacity: 0; pointer-events: none; transition: .25s ease; }
/* Piilossa oleva ilmoitus ei saa ottaa kosketuksia: puhelimella se peitti alareunan nappien keskikohdan (2.10.2026). */
.toast.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.toast svg { width: 16px; color: #66d99d; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 210px 1fr; }
  
  .project-facts { grid-column: 1 / -1; }
  .project-facts dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 18px; }
  .company-switcher strong { max-width: 105px; }
}

@media (max-width: 880px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-105%); width: 244px; transition: transform .22s ease; box-shadow: 20px 0 50px rgba(0,0,0,.22); }
  .sidebar.open { transform: translateX(0); }

  .mobile-menu { width: 34px; height: 34px; padding: 8px; display: grid; gap: 4px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
  .mobile-menu span { height: 2px; background: #445467; }
  .topbar { padding: 0 16px; }
  .breadcrumb span, .breadcrumb svg { display: none; }
  .content-wrap { padding: 23px 18px 45px; }

  .project-facts { grid-column: auto; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }

  .e-row{ grid-template-columns: 1.2fr .55fr .75fr .45fr; }
  .e-row > *:nth-child(4){ display: none; }
}

@media (max-width: 600px) {
  .content-wrap { padding-left: 13px; padding-right: 13px; }
  .project-heading, .section-intro, .analysis-header { align-items: flex-start; }
  .project-heading, .analysis-header { flex-direction: column; }
  .project-heading h1 { font-size: 25px; }
  .process-steps { grid-template-columns: 1fr 1fr; }
  .process-steps li:nth-child(2) { border-right: 0; }
  .process-steps li:nth-child(-n+2) { border-bottom: 1px solid var(--line-soft); }
  .project-facts dl { grid-template-columns: 1fr 1fr; }
  
  .analysis-cta { grid-template-columns: 38px 1fr; }
  .analysis-cta .primary-btn { grid-column: 1 / -1; width: 100%; }
  .metrics-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric-card { padding: 13px; }
  .metric-card strong { font-size: 22px; }
  .analysis-actions { width: 100%; }
  .analysis-actions button { flex: 1; }
  
  .data-toolbar { align-items: stretch; flex-direction: column; }
  .data-toolbar > span { margin-left: 0; }
  .search-field { width: 100%; }

  .estimate-top { align-items: stretch; flex-direction: column; }
  .estimate-top > div:last-child { justify-content: space-between; }
  .estimate-table { overflow-x: auto; }
  .e-row { min-width: 600px; }
  .estimate-summary > div { width: min(330px, 100%); }
  .estimate-footer { align-items: stretch; flex-direction: column; }
  
}

@media print {
  .sidebar, .topbar, .analysis-actions, .tabs, .process-steps { display: none !important; }
  .app-shell { display: block; }
  .content-wrap { padding: 0; }
  .tab-pane { display: block !important; break-inside: avoid; }
  .tab-pane:not(#tab-summary) { display: none !important; }
  .panel, .metric-card { box-shadow: none; }
}
[hidden] { display: none !important; }

.upload-layout { display:grid; grid-template-columns:minmax(0, 1.6fr) minmax(250px, 1fr); gap:20px; }
.upload-panel,.upload-help,.live-panel { padding:24px; }
.upload-help h3,.live-panel h3 { font-size:18px; margin:0 0 14px; }
.upload-help li { margin-bottom:12px; }
.upload-help p,.live-panel p,.privacy-note { color:var(--muted); line-height:1.6; font-size:14px; }
.drop-zone { text-align:center; border:2px dashed #b8cce1; padding:32px 16px; background:#f6faff; border-radius:8px; }
.drop-zone.dragging { background:#dfedff; border-color:var(--blue); }
.drop-zone>svg { width:36px; height:36px; color:var(--blue); }
.drop-zone h3 { font-size:21px; margin:12px 0; }
.drop-zone p { font-size:16px; }
.drop-zone button { margin:18px auto 0; }
.uploaded-file { display:flex; gap:12px; align-items:center; padding:15px 0; border-bottom:1px solid var(--line); overflow-wrap:anywhere; }
.uploaded-file>span:nth-child(2) { flex:1; min-width:0; }
.uploaded-file strong,.uploaded-file small { display:block; }
.uploaded-file small { color:var(--muted); }
.error-message { background:#fff0ef; color:#9b2720; border:1px solid #efbeb9; padding:18px; margin-top:20px; border-radius:8px; }
.running-panel { padding:24px; display:flex; gap:20px; align-items:center; margin-top:20px; }
.running-panel p { margin:6px 0; }
.spinner { width:28px; height:28px; flex:none; border:3px solid #c9d8e9; border-top-color:var(--blue); border-radius:50%; animation:spin 1s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }
.live-panel { margin-bottom:20px; }
.facts-grid>div { display:grid; grid-template-columns:180px 1fr; gap:16px; padding:16px 0; border-bottom:1px solid var(--line); }
.facts-grid dt { color:var(--muted); }.facts-grid dd { margin:0; }.facts-grid button { margin-top:8px; }
.table-scroll { overflow-x:auto; }table { width:100%; border-collapse:collapse; font-size:14px; }th,td { padding:15px 10px; text-align:left; vertical-align:top; border-bottom:1px solid var(--line); }th { background:#e9edf3; font-weight:650; }td small { display:block; margin-top:6px; color:var(--muted); font-size:13px; }td input[type=number] { width:110px; }input[type=number] { padding:9px; border:1px solid #bac9d8; border-radius:5px; font-size:16px; }input[type=checkbox] { width:20px; height:20px; accent-color:var(--blue); }
.live-issue { padding:20px 0; border-bottom:1px solid var(--line); }.live-issue label { display:flex; align-items:center; gap:12px; }.risk-label { display:block; margin:8px 0 0 32px; color:#9a5622; font-size:14px; }.live-issue p { margin:10px 0; }
.source-link { font-size:14px!important; display:block; text-align:left; white-space:normal; overflow-wrap:anywhere; margin:5px 0; }
.price-controls { margin-top:25px; display:flex; flex-wrap:wrap; gap:25px; align-items:center; }.price-controls label { display:flex; align-items:center; gap:12px; }.price-controls input { width:85px; }.price-controls strong { display:block; margin-top:8px; font-size:20px; }
#sourceDialog { width:min(1050px,calc(100% - 24px)); }#sourceFrame { display:block; width:100%; height:60vh; border:1px solid var(--line); margin-top:16px; }dialog::backdrop { background:rgba(8,20,35,.55); }
button:disabled { opacity:.5; cursor:not-allowed; }button:focus-visible,a:focus-visible,input:focus-visible { outline:3px solid #338aff; outline-offset:3px; }
.primary-btn,.secondary-btn,.tab,.process-steps small,.process-steps strong,.section-intro p,.analysis-cta p,.analysis-cta strong,.metric-card>span,.breadcrumb,.nav-item,.status-pill { font-size:14px; }
.analysis-header p { font-size:16px; max-width:850px; line-height:1.6; }.tabs { overflow-x:auto; }.tab { flex-shrink:0; }.analysis-actions { flex-wrap:wrap; }
@media(max-width:880px){.upload-layout{grid-template-columns:1fr}.facts-grid>div{grid-template-columns:1fr;gap:6px}.upload-panel,.upload-help,.live-panel{padding:16px}.analysis-header{align-items:flex-start;flex-direction:column}table{min-width:650px}.project-heading h1{overflow-wrap:anywhere}.section-intro{flex-wrap:wrap}}
/* Palaute (dist/nav.js navFeedback) */
.nav-fb{border:1px solid var(--line);border-radius:var(--r-lg,16px);padding:0;width:min(480px,calc(100vw - 32px));background:var(--surface,#fff);color:var(--ink);box-shadow:0 20px 60px rgba(10,20,40,.25)}
.nav-fb::backdrop{background:rgba(10,16,28,.45)}
.nav-fb-f{padding:22px;display:flex;flex-direction:column;gap:12px}
.nav-fb-f h2{margin:0;font-size:20px}
.nav-fb-f p{margin:0;color:var(--muted);font-size:14px;line-height:1.5}
.nav-fb-k{display:flex;gap:8px;flex-wrap:wrap}
.nav-fb-k label{cursor:pointer}
.nav-fb-k input{position:absolute;opacity:0;pointer-events:none}
.nav-fb-k span{display:inline-block;padding:7px 14px;border:1px solid var(--line);border-radius:999px;font-size:13.5px;font-weight:600}
.nav-fb-k input:checked+span{background:var(--blue);border-color:var(--blue);color:#fff}
.nav-fb-k input:focus-visible+span{outline:2px solid var(--blue);outline-offset:2px}
.nav-fb textarea{width:100%;box-sizing:border-box;border:1px solid var(--line);border-radius:var(--r-md,10px);padding:10px 12px;font:inherit;font-size:14px;resize:vertical;background:var(--surface,#fff);color:var(--ink)}
.nav-fb-f .nav-fb-n{font-size:12.5px}
.nav-fb-f .nav-fb-s{min-height:1em;color:var(--ink)}
.nav-fb-a{display:flex;justify-content:flex-end;gap:10px}
