/* Two independent stacks: compact OK cards do not inherit row heights. */
.analysisPanel,.analysisHousingTools{font-family:var(--font,Arial,sans-serif)}
.analysisPanel.rightPanel,body.examineMode .analysisPanel.rightPanel{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);grid-template-rows:max-content;grid-auto-rows:max-content;align-items:start;gap:12px;overflow:auto}
.analysisPanel>.section:has(#info){grid-column:1/-1}
body.examineMode .analysisPanel>.section:has(#info){display:none}
.analysisColumn{display:flex;flex-direction:column;gap:10px;min-width:0;align-self:start}
.analysisPanel .analysisColumn>.section{display:block;margin:0;min-height:0;height:auto;border:1px solid #dce5df;border-radius:12px;background:#fff;overflow:hidden;box-shadow:0 2px 6px #23432c09}
.analysisCardHeader{width:100%;display:flex;align-items:center;justify-content:space-between;gap:8px;padding:11px 12px;border:0;background:#fff;text-align:left;font:600 13px var(--font);color:#234334;cursor:pointer;min-height:42px}
.analysisCardHeader::after{content:'⌄';color:#567766}
.analysisCardHeader[aria-expanded=true]::after{content:'⌃'}
.analysisCardHeader:focus-visible{outline:2px solid #397b57;outline-offset:-3px}
.analysisCardHeader .cardBadge{margin-left:auto;white-space:normal;text-align:right;font-size:11px;font-weight:600;border-radius:12px;padding:3px 7px;background:#edf0ee;color:#54665a}
.analysisCard[data-status=ok] .cardBadge{background:#e0f1e7;color:#226043}
.analysisCard[data-status=attention]{border-left:4px solid #df9a2d!important}
.analysisCard[data-status=attention] .cardBadge{background:#fff0d5;color:#825000}
.analysisCard[data-status=conflict]{border-left:4px solid #c94343!important}
.analysisCard[data-status=conflict] .cardBadge{background:#fce4e4;color:#963131}
.analysisPanel .analysisCard>.body,body.examineMode .analysisPanel .analysisCard>.body{display:none;padding:2px 12px 12px;max-height:360px;overflow:auto;font-size:12px}
.analysisPanel .analysisCard:has(.analysisCardHeader[aria-expanded=true])>.body{display:block}
.analysisPanel .housingInformation>.head{padding:12px;font-size:13px}
.analysisPanel .housingInformation>.body{padding:0 12px 12px;font-size:12px}
.housingInformation h4{font-size:12px;margin:16px 0 7px;color:#344e40}
.housingInformation .housingStat{width:100%;display:flex;justify-content:space-between;align-items:center;padding:8px 4px;border:0;background:transparent;font:inherit;color:#244837;cursor:pointer}
.housingInformation .housingStat strong{font-size:21px}
.significantDwelling{display:flex;flex-direction:column;gap:3px;border-top:1px solid #e8ede9;padding:9px 0;overflow-wrap:anywhere}
.significantDwelling strong{font-size:12px;color:#2b6345}.significantDwelling span{color:#506256}
.housingPreferences{margin-top:16px;border-top:1px solid #e0e7e2;padding-top:10px}
.housingPreferences label{display:flex;align-items:center;gap:6px;margin:8px 0}
.analysisHousingTools{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
.analysisHousingTools button{display:flex;align-items:center;gap:6px;border:1px solid #b5c7b9;border-radius:8px;padding:7px 9px;background:white;color:#26513b;font:600 12px var(--font);cursor:pointer}

.analysisHousingTools button:disabled{opacity:.55;cursor:default}
#edit-housing-hint{background:white;padding:6px;border-radius:6px;font-size:12px}
.analysisPanel .section[hidden],.analysisHousingTools [hidden]{display:none!important}
@media(max-width:1450px){body:not(.examineMode) .analysisPanel.rightPanel{grid-template-columns:1fr}}
@media(max-width:620px){body.examineMode .analysisPanel.rightPanel{grid-template-columns:1fr}.analysisCardHeader{font-size:12px}}

/* Tarkastelu has a narrow detail sidebar, not the wide Analysointi canvas.
   Keep each card full-width regardless of viewport resolution or pixel ratio. */
body:not(.examineMode) #view-map{
  grid-template-columns:clamp(240px,19vw,300px) minmax(320px,1fr) clamp(350px,28vw,460px);
  grid-template-rows:auto minmax(0,1fr);min-width:0;min-height:0;overflow:hidden;
}
body:not(.examineMode) #view-map>.leftPanel{grid-column:1;grid-row:2;min-width:0;min-height:0}
body:not(.examineMode) #view-map>.mapPanel{grid-column:2;grid-row:2;min-width:0;min-height:0}
body:not(.examineMode) #view-map>.analysisPanel.rightPanel{
  grid-column:3;grid-row:2;display:flex;flex-direction:column;align-items:stretch;gap:10px;
  min-width:0;min-height:0;padding:10px;box-sizing:border-box;overflow-x:hidden;overflow-y:auto;
  scrollbar-gutter:stable;
}
body:not(.examineMode) .analysisPanel>.analysisColumn{display:contents}
body:not(.examineMode) .analysisPanel .section{flex:0 0 auto;min-width:0;max-width:100%;box-sizing:border-box}
body:not(.examineMode) .analysisPanel>.section:has(#info){margin:0 0 2px;border:0;box-shadow:none}
body:not(.examineMode) .analysisPanel #info{padding:8px 2px 12px}
body:not(.examineMode) .analysisPanel .selectedRoadHeading{gap:10px;flex-wrap:wrap;align-items:flex-start!important}
body:not(.examineMode) .analysisPanel .selectedRoadHeading>div{flex:1 1 160px;min-width:0;overflow-wrap:anywhere}
body:not(.examineMode) .analysisPanel .selectedRoadHeading>button{flex:0 1 auto;max-width:100%;line-height:1.35}
body:not(.examineMode) .analysisPanel .analysisCardHeader{gap:8px;padding:10px 12px;font-size:13px}
body:not(.examineMode) .analysisPanel .analysisCardHeader>span:first-child{flex:1;min-width:0}
body:not(.examineMode) .analysisPanel .analysisCardHeader .cardBadge{flex:0 1 auto;max-width:55%;font-size:11px}
body:not(.examineMode) .analysisPanel .analysisCard>.body{max-height:none;overflow:visible;overflow-wrap:anywhere}
body:not(.examineMode) .analysisPanel .observationCard{box-sizing:border-box;max-width:100%;overflow-wrap:anywhere}
body:not(.examineMode) .analysisPanel .observationCard>div{min-width:0;max-width:100%}
body:not(.examineMode) .analysisPanel .observationCard input[type=text]{min-width:0;width:100%;box-sizing:border-box}
body:not(.examineMode) .analysisPanel .housingInformation>.head{padding:11px 12px;background:#f2f6f3;color:#254636}
body:not(.examineMode) .analysisPanel .housingInformation h4{margin:12px 0 6px;line-height:1.4}
body:not(.examineMode) .analysisPanel .housingStat{padding:6px 2px}
body:not(.examineMode) #view-map .kpiRow{align-items:stretch;min-width:0}
body:not(.examineMode) #view-map .kpiRow>.kpi{
  height:auto;min-height:112px;max-height:none;min-width:0;overflow:visible;box-sizing:border-box;
}
body:not(.examineMode) #view-map .kpiRow>.kpi .rows{max-height:none!important;overflow:visible!important}
body:not(.examineMode) #view-map .kpiRow>.kpi .combinedScroll{max-height:none;overflow:visible}
body:not(.examineMode) #view-map .kpiRow .row>span{min-width:0;overflow-wrap:anywhere}
body:not(.examineMode) #view-map .kpiRow .mutedText{white-space:normal;overflow-wrap:anywhere;line-height:1.35}
body:not(.examineMode) .mapToolbar{max-width:calc(100% - 28px);box-sizing:border-box}
body:not(.examineMode) .mapToolbar>*{max-width:100%;box-sizing:border-box}
body:not(.examineMode) .analysisHousingTools{min-width:0;max-width:100%}
body:not(.examineMode) .mapToolbar button{white-space:normal}

/* Below laptop width, retain map space instead of squeezing three columns. */
@media(max-width:1199px){
  body:not(.examineMode) #view-map{
    grid-template-columns:240px minmax(0,1fr);
    grid-template-rows:auto minmax(300px,45vh) max-content;overflow:auto;align-content:start;
  }
  body:not(.examineMode) #view-map>.kpiRow{grid-column:1/-1;grid-row:1;grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:auto auto}
  body:not(.examineMode) #view-map>.leftPanel{grid-column:1;grid-row:2}
  body:not(.examineMode) #view-map>.mapPanel{grid-column:2;grid-row:2}
  body:not(.examineMode) #view-map>.analysisPanel.rightPanel{grid-column:1/-1;grid-row:3;overflow:visible;scrollbar-gutter:auto}
}
@media(max-width:760px){
  body:not(.examineMode) .topbar{height:auto;min-height:52px;flex-wrap:wrap;gap:8px;padding:8px 10px}
  body:not(.examineMode) .topbar .viewSwitch{flex:1 1 100%;min-width:0}
  body:not(.examineMode) .topbar .viewSwitch button{width:50%;min-width:0}
  body:not(.examineMode) .topbar .title{display:flex;align-items:center;gap:8px;flex:1 1 180px;min-width:0}
  body:not(.examineMode) #kunta-select{min-width:0!important;max-width:100%;flex:1}
  body:not(.examineMode) .topbar .subtitleBlock{display:none}
  body:not(.examineMode) .topbar .attaTag{font-size:24px}
  body:not(.examineMode) .nav{height:auto;min-height:36px;flex-wrap:wrap;gap:8px;padding:6px 10px;box-sizing:border-box}
  body:not(.examineMode) #view-map{grid-template-columns:minmax(0,1fr);grid-template-rows:auto 220px minmax(340px,48vh) max-content}
  body:not(.examineMode) #view-map>.leftPanel{grid-column:1;grid-row:2}
  body:not(.examineMode) #view-map>.mapPanel{grid-column:1;grid-row:3}
  body:not(.examineMode) #view-map>.analysisPanel.rightPanel{grid-column:1;grid-row:4;padding:8px}
}
@media(max-width:440px){
  body:not(.examineMode) #view-map>.kpiRow{grid-template-columns:minmax(0,1fr);grid-template-rows:repeat(4,auto)}
}

/* Reserve the KPI row's normal height; an open card overlays the next row. */
body:not(.examineMode) #view-map>.kpiRow{
  position:relative;z-index:60;isolation:isolate;overflow:visible;
  height:112px;grid-template-rows:112px;align-items:start;gap:10px;
}
body:not(.examineMode) #view-map .kpiRow>.kpi{
  position:relative;z-index:1;height:112px;min-height:112px;max-height:112px;
  align-self:start;overflow:hidden;
}
body:not(.examineMode) #view-map .kpiRow>.kpi:hover,
body:not(.examineMode) #view-map .kpiRow>.kpi:focus-within{
  z-index:30;height:auto;max-height:none;overflow:visible;box-shadow:0 8px 24px #25352c40;
}
body:not(.examineMode) #view-map>.mapPanel,
body:not(.examineMode) #view-map>.leftPanel,
body:not(.examineMode) #view-map>.rightPanel{position:relative;z-index:1}
@media(min-width:1200px){body:not(.examineMode) #view-map{overflow:visible}}
@media(max-width:1199px){body:not(.examineMode) #view-map>.kpiRow{height:234px;grid-template-rows:112px 112px}}
@media(max-width:440px){body:not(.examineMode) #view-map>.kpiRow{height:478px;grid-template-rows:repeat(4,112px)}}

/* The editor control has the same 34px height as the map selects. */


.analysisPanel .housingInformation>.body,
body.examineMode .analysisPanel .housingInformation>.body{
  display:flow-root;padding:12px;box-sizing:border-box;
}
.analysisPanel .housingInformation .housingAssociationToggle{
  position:static;display:flex;align-items:center;width:fit-content;max-width:100%;
  margin:0 0 10px;transform:none;box-sizing:border-box;white-space:normal;
}

/* Shared final housing cards. */
.analysisPanel>.section:has(#info){position:sticky;top:0;z-index:8;background:#f3f5f7}
.examineIdentity{position:sticky;top:0;z-index:8;background:#f3f5f7;padding-bottom:8px}
.significantDwelling.dwellingLoss strong,.significantDwelling.dwellingLoss span{color:#b42328}
.significantEdit{margin:6px 0;padding:6px 9px;border:1px solid #bbcbbf;border-radius:7px;background:white;color:#26513b;cursor:pointer}
.housingAssociationToggle{font-size:11px!important;padding:4px 7px!important;margin-top:7px!important}

.analysisPanel .housingInformation.analysisCard:not(:has(.analysisCardHeader[aria-expanded=true]))>.body{display:none}

body:not(.examineMode) .analysisCard:has(#detail-rajoitus){order:1}
body:not(.examineMode) .analysisCard:has(#detail-length-change){order:2}
body:not(.examineMode) .analysisCard:has(#detail-significant-change){order:3}
body:not(.examineMode) .analysisCard:has(#detail-esteet){order:4}
body:not(.examineMode) .analysisCard:has(#detail-merkit){order:5}
body:not(.examineMode) .analysisCard:has(#detail-rakennukset){order:6}

/* Map tools share one height, palette and undistorted square icons. */
.mapToolbar{align-items:center}
.mapToolbar .mapLayerSelect,.mapToolbar .buildingControl{height:36px;min-height:36px;box-sizing:border-box}
.mapToolbar .buildingControl{display:flex;align-items:center}
.mapToolbar .buildingControl>#rakennukset-toggle,.mapToolbar .buildingControl>#rakennukset-menu-button{height:34px;min-height:34px;box-sizing:border-box}
.mapToolbar .analysisHousingTools{display:flex;flex:0 0 auto;flex-wrap:nowrap;gap:8px;max-width:100%;align-items:center}
.mapToolbar .analysisHousingTools .housingMapTool{--tool-fill:#b8bec4;display:inline-flex;align-items:center;justify-content:center;flex:0 0 40px;width:40px;min-width:40px;max-width:40px;height:36px;min-height:36px;padding:2px;border:1px solid #929ba3;border-radius:8px;background:#b8bec4;color:#505962;box-sizing:border-box}
.mapToolbar .analysisHousingTools .housingMapTool[aria-pressed=true]{--tool-fill:#78cf87;background:#78cf87;color:#173d20;border-color:#61ad70}
.mapToolbar .analysisHousingTools .housingMapTool svg{width:30px;height:30px;flex:0 0 30px;aspect-ratio:1;display:block}
.mapToolbar #reset-housing-map{height:36px;min-height:36px;box-sizing:border-box}
.mapToolbar #edit-housing-hint{font-size:11px;max-width:240px;line-height:1.3}
#app-user-municipality{color:#e3e9ed!important}
.buildingSignificanceChoice{display:flex;align-items:center;gap:6px;margin:12px 0 4px;line-height:1.4;cursor:pointer}

/* Compact housing information uses the same layout in both environments. */
body.examineMode .analysisPanel .housingInformation>.head{padding:7px 10px;font-size:12px}
body.examineMode .analysisPanel .housingInformation>.body{padding:6px 10px;font-size:11px;line-height:1.3}
body.examineMode .analysisPanel .housingInformation h4{margin:8px 0 3px;font-size:11px}
body.examineMode .analysisPanel .housingInformation .housingStat{padding:3px 2px;min-height:0}
body.examineMode .analysisPanel .housingInformation .housingStat strong{font-size:16px}
body.examineMode .analysisPanel .housingInformation .significantDwelling{padding:5px 0;gap:2px}
body.examineMode .analysisPanel .housingInformation .housingAssociationToggle{margin-bottom:4px;padding:4px 7px;font-size:11px}


.annualKpiFilter{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;border:0;background:transparent;font:inherit;text-align:left;cursor:pointer;padding:6px 4px}
.annualKpiFilter[aria-pressed=true]{background:#fff2a0;outline:2px solid #524815;border-radius:5px}
.annualKpiFilter:disabled{cursor:default;color:inherit;opacity:.65}
.kpiAccessNotice,.kpi[data-state=locked]>.mutedText,.kpi[data-state=unavailable]>.mutedText{font-size:12px;line-height:1.4;margin:12px 0 0;color:#394344}
.analysisCard[data-status=locked] .cardBadge{background:#edf0ee;color:#54665a}

/* All four KPI cards follow the same palette as the shared demonstration layout. */
.lengthChangeKpi,.housingChangeKpi{background:#ffcc00!important}
.lengthChangeKpi[data-state=locked],.housingChangeKpi[data-state=locked]{background:#f4e6ac!important}
