/* Küttekava eelvaate tööriist */
.kk-page { background: var(--bg-soft); }
.kk-page .site-header { position: sticky; }
.kk-app {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 330px;
  grid-template-rows: auto auto minmax(0, 1fr);
  grid-template-areas: "bar bar bar" "left steps right" "left stage right";
  height: calc(100vh - var(--header-h));
  height: calc(100dvh - var(--header-h));
  min-height: 560px;
}

/* Tööriistariba */
.kk-toolbar {
  grid-area: bar; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 14px; background: #fff; border-bottom: 1px solid var(--line);
}
.kk-group { display: flex; align-items: center; gap: 4px; }
.kk-group + .kk-group { padding-left: 8px; border-left: 1px solid var(--line); }
.kk-group-end { margin-left: auto; border-left: 0 !important; gap: 8px; }
.kk-btn, .kk-tool, .kk-icon {
  display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 9px;
  border-radius: 7px; font-size: 13.5px; font-weight: 500; color: var(--ink); white-space: nowrap;
  border: 1px solid transparent; transition: background-color .15s, border-color .15s, color .15s;
}
.kk-btn { border-color: #d3dbe6; background: #fff; }
.kk-btn:hover, .kk-tool:hover, .kk-icon:hover { background: var(--bg-soft); }
.kk-btn-open { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
.kk-btn-open:hover { background: var(--navy-700); }
.kk-icon { width: 36px; padding: 0; justify-content: center; }
.kk-icon:disabled { opacity: .35; cursor: default; background: none; }
.kk-tool[aria-pressed="true"] { background: var(--orange-50); border-color: #f6c49c; color: var(--orange-600); }
.kk-tool .ic, .kk-btn .ic, .kk-icon .ic { width: 18px; height: 18px; }
.kk-send-btn { min-height: 36px; height: 36px; padding: 0 14px; font-size: 14px; }
.kk-menu { position: relative; }
.kk-menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 290px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px;
}
.kk-menu-list button { display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: 7px; }
.kk-menu-list button:hover { background: var(--bg-soft); }
.kk-menu-list strong { display: block; font-size: 14px; color: var(--ink); font-weight: 600; }
.kk-menu-list span { display: block; font-size: 12.5px; color: var(--muted); }
.kk-menu-list .danger strong { color: #c03a3a; }

/* Sammuriba */
.kk-stepper {
  grid-area: steps; display: flex; align-items: center; gap: 4px; padding: 8px 12px;
  background: #fff; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin;
}
.kk-step {
  display: inline-flex; align-items: center; gap: 7px; flex: none; padding: 4px 11px 4px 4px; border-radius: 20px;
  font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; border: 1px solid transparent;
  transition: background-color .15s, color .15s, border-color .15s;
}
.kk-step-no { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--bg-soft); color: var(--muted); font-size: 12px; font-weight: 700; }
.kk-step:not(:disabled):hover { background: var(--bg-soft); }
.kk-step.done { color: var(--ink); }
.kk-step.done .kk-step-no { background: #e8f5ea; color: var(--green); }
.kk-step.active { background: var(--orange-50); border-color: #f6c49c; color: var(--orange-600); }
.kk-step.active .kk-step-no { background: var(--orange); color: #fff; }
.kk-step:disabled { opacity: .45; cursor: not-allowed; }
.kk-step-sep { flex: 1 1 10px; min-width: 10px; max-width: 28px; height: 2px; background: var(--line); }

/* Mida teha nüüd */
.kk-guide { background: linear-gradient(180deg, var(--orange-50), #fff 75%); }
.kk-guide-step { font-size: 11.5px !important; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--orange-600) !important; margin-bottom: 4px !important; }
.kk-guide h3 { font-size: 17px; margin-bottom: 8px; }
.kk-guide p { font-size: 13.5px; color: var(--text); margin-bottom: 10px; line-height: 1.45; }
.kk-guide .kk-guide-sub { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.kk-guide .kk-guide-lock { background: #fff; border: 1px dashed #f0b37e; border-radius: 8px; padding: 8px 10px; color: #8a4f00; font-size: 12.5px; }
.kk-guide .kk-guide-progress { font-size: 13px; color: var(--muted); }
.kk-guide .kk-guide-progress strong { color: var(--ink); }
.kk-guide .kk-guide-ok { color: #2f7d3d; font-weight: 600; }
.kk-guide .kk-guide-warn { color: #9a5b00; font-weight: 600; }
.kk-guide .kk-guide-bad { color: #c03a3a; font-weight: 600; }
.kk-guide .kk-actions { margin: 0 0 10px; }
.kk-guide .kk-actions:last-child { margin-bottom: 0; }
.kk-guide .btn { min-height: 38px; padding: 0 14px; font-size: 14px; white-space: normal; text-align: center; }
.kk-guide .btn:disabled { opacity: .45; box-shadow: none; cursor: not-allowed; }
.kk-actions-col { flex-direction: column; align-items: stretch; }
.kk-actions-col .kk-btn { justify-content: center; }
.kk-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.kk-chip { padding: 6px 14px; border-radius: 18px; border: 1px solid #d3dbe6; background: #fff; font-weight: 600; font-size: 14px; color: var(--ink); }
.kk-chip:hover { border-color: var(--navy-800); }
.kk-chip.on { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
.kk-btn.on { background: var(--orange-50); border-color: #f6c49c; color: var(--orange-600); }
.kk-btn-wide { width: 100%; justify-content: center; }
.kk-copy-from { display: grid; gap: 6px; padding: 10px; margin-bottom: 10px; border-radius: 8px; background: #fff; border: 1px solid var(--line); font-size: 13px; color: var(--ink); }
.kk-copy-from select {
  min-height: 36px; padding: 6px 28px 6px 8px; font: inherit; font-size: 13px; color: var(--ink); border: 1px solid #d3dbe6; border-radius: 6px; appearance: none; -webkit-appearance: none;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2312223b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center / 14px;
}
.kk-tool[aria-disabled="true"] { opacity: .38; cursor: not-allowed; }
.kk-tool[aria-disabled="true"]:hover { background: none; }
.kk-price { font-style: normal; font-size: 11.5px; font-weight: 700; color: var(--orange-600); background: var(--orange-50); border-radius: 10px; padding: 1px 7px; margin-left: 4px; }
.kk-price.paid { color: #2f7d3d; background: #e8f5ea; }

/* Dialoogid: kopeerimine ja makse */
.kk-copy-dialog, .kk-pay-dialog { width: min(560px, calc(100vw - 32px)); }
.kk-copy-list { display: grid; gap: 8px; max-height: 300px; overflow: auto; margin: 12px 0 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.kk-copy-list legend { padding: 0 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.kk-copy-list .kk-check span { display: flex; flex-direction: column; }
.kk-copy-list em { font-style: normal; font-size: 12.5px; color: var(--muted); }
.kk-copy-dialog .kk-check { margin: 10px 0; }
.kk-pay-error { color: #c03a3a; font-size: 13.5px; margin: 6px 0; }
.kk-pay-error:empty { display: none; }
.kk-pay-dialog .checklist { margin: 12px 0 16px; }
.kk-pay-dialog .kk-pop-actions, .kk-copy-dialog .kk-pop-actions { flex-wrap: wrap; margin-top: 12px; }
.kk-pay-foot { margin-top: 14px !important; text-align: center; }
.kk-center { justify-content: center !important; }

/* Külgpaneelid */
.kk-left, .kk-right { overflow-y: auto; background: #fff; padding: 6px 0 16px; }
.kk-left { grid-area: left; border-right: 1px solid var(--line); }
.kk-right { grid-area: right; border-left: 1px solid var(--line); }
.kk-panel { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.kk-panel:last-child { border-bottom: 0; }
.kk-panel h2 { font-family: var(--font-body); font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.kk-panel h3 { font-size: 16px; margin-bottom: 10px; }
.kk-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.kk-panel-head h2 { margin: 0; }
.kk-link-btn { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--navy-800); }
.kk-link-btn:hover { color: var(--orange-600); }
.kk-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px; background: var(--bg-soft); color: var(--ink); font-size: 11.5px; letter-spacing: 0; }
.kk-count.has-error { background: #fdecec; color: #c03a3a; }
.kk-count.has-warn { background: #fff4e0; color: #9a5b00; }

.kk-floors { display: grid; gap: 4px; }
.kk-floor {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; text-align: left;
  border-radius: 8px; border: 1px solid transparent; font-size: 14px; color: var(--ink);
}
.kk-floor:hover { background: var(--bg-soft); }
.kk-floor[aria-current="true"] { background: var(--orange-50); border-color: #f6c49c; }
.kk-floor-no { display: inline-grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: 6px; background: var(--navy-800); color: #fff; font-size: 12px; font-weight: 700; }
.kk-floor-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.kk-floor-meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
.kk-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.kk-dot.error { background: #d64545; }
.kk-dot.warn { background: #e8a33a; }
.kk-empty-list { font-size: 13px; color: var(--muted); }

.kk-fields { display: grid; gap: 10px; }
.kk-fields .field > span { font-size: 12.5px; }
.kk-fields .field input, .kk-fields .field select, .kk-fields .field textarea { min-height: 36px; padding: 7px 10px; font-size: 14px; }
.kk-fields .field select { padding-right: 32px; background-position: right 10px center; }
.kk-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kk-check { display: flex; align-items: flex-start; gap: 8px; font-size: 13.5px; color: var(--ink); cursor: pointer; line-height: 1.35; }
.kk-check input { width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--orange); flex: none; }
.kk-check-sm { font-size: 12.5px; color: var(--muted); align-items: center; }
.kk-note { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.kk-note.warn { color: #9a5b00; }
.kk-kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 13.5px; margin: 4px 0 0; }
.kk-kv dt { color: var(--muted); }
.kk-kv dd { margin: 0; font-weight: 600; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
.kk-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.kk-danger { color: #c03a3a !important; }
.kk-danger:hover { background: #fdecec !important; }
.kk-license { padding: 12px 16px 0; font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.kk-license a { color: var(--navy-700); }
.kk-rad-list { display: grid; gap: 6px; margin-top: 8px; }
.kk-rad-item { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; padding: 6px 8px; background: var(--bg-tint); border-radius: 6px; }
.kk-rad-item strong { color: var(--ink); font-weight: 600; }

.kk-summary { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; margin: 0; font-size: 13.5px; }
.kk-summary dt { color: var(--muted); }
.kk-summary dd { margin: 0; font-weight: 600; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
.kk-summary .total { padding-top: 6px; border-top: 1px solid var(--line); }

.kk-remarks { display: grid; gap: 6px; counter-reset: rem; }
.kk-remark {
  display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start; width: 100%; text-align: left;
  padding: 8px; border-radius: 8px; font-size: 13px; line-height: 1.4; color: var(--ink); background: var(--bg-tint); border: 1px solid transparent;
}
.kk-remark:hover { border-color: var(--line); background: #fff; }
.kk-remark .no { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 700; }
.kk-remark.error .no { background: #d64545; }
.kk-remark.warn .no { background: #e8a33a; }
.kk-remark.info .no { background: #3b74c2; }
.kk-remark.error { background: #fdf3f3; }
.kk-remark.warn { background: #fff8ec; }
.kk-ok { display: flex; gap: 8px; align-items: center; font-size: 13.5px; color: #2f7d3d; }

/* Joonis */
.kk-stage { grid-area: stage; position: relative; overflow: hidden; background: #e9edf3; outline: none; touch-action: none; }
.kk-stage:focus-visible { box-shadow: inset 0 0 0 3px rgba(244, 123, 32, .5); }
#kk-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; user-select: none; -webkit-user-select: none; }
.kk-stage.tool-select #kk-svg { cursor: default; }
.kk-stage.panning #kk-svg, .kk-stage.space #kk-svg { cursor: grab; }
.kk-stage.tool-rect #kk-svg, .kk-stage.tool-poly #kk-svg, .kk-stage.tool-scale #kk-svg, .kk-stage.tool-align #kk-svg { cursor: crosshair; }
.kk-stage.tool-window #kk-svg, .kk-stage.tool-radiator #kk-svg, .kk-stage.tool-riser #kk-svg { cursor: copy; }

#kk-svg .bg-page { filter: drop-shadow(0 2px 10px rgba(15, 42, 74, .18)); }
#kk-svg .room { fill: rgba(244, 123, 32, .08); stroke: #f47b20; stroke-width: 1.5px; vector-effect: non-scaling-stroke; cursor: pointer; }
#kk-svg .room.nored { fill: rgba(59, 116, 194, .08); stroke: #3b74c2; stroke-dasharray: 5 3; }
#kk-svg .room.sel { fill: rgba(244, 123, 32, .16); stroke-width: 2.5px; }
#kk-svg .room-label { fill: #12223b; font-family: Inter, sans-serif; text-anchor: middle; pointer-events: none; paint-order: stroke; stroke: rgba(255, 255, 255, .85); stroke-linejoin: round; }
#kk-svg .room-label .sub { fill: #5b6b82; font-weight: 400; }
#kk-svg .room-label .load { fill: #c45a09; font-weight: 600; }
#kk-svg .win { stroke: #0ea5e9; stroke-width: 7px; vector-effect: non-scaling-stroke; cursor: pointer; }
#kk-svg .win.off { stroke-dasharray: 4 3; stroke: #7dd3fc; }
#kk-svg .win.sel, #kk-svg .rad.sel, #kk-svg .riser.sel circle { filter: drop-shadow(0 0 3px #f47b20) drop-shadow(0 0 2px #f47b20); }
#kk-svg .rad { fill: #f47b20; stroke: #8c4005; stroke-width: 1px; vector-effect: non-scaling-stroke; cursor: pointer; }
#kk-svg .rad.manual { fill: #fb923c; }
#kk-svg .rad-label { fill: #8c4005; font-family: Inter, sans-serif; text-anchor: middle; dominant-baseline: middle; pointer-events: none; paint-order: stroke; stroke: rgba(255, 255, 255, .9); stroke-linejoin: round; }
#kk-svg .link { stroke: #64748b; stroke-width: 1px; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; pointer-events: none; opacity: .8; }
#kk-svg .riser { cursor: move; }
#kk-svg .riser .sup { fill: #d32f2f; stroke: #fff; stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
#kk-svg .riser .ret { fill: #1e63d6; stroke: #fff; stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
#kk-svg .riser text { fill: #12223b; font-family: Inter, sans-serif; font-weight: 700; text-anchor: middle; paint-order: stroke; stroke: #fff; stroke-linejoin: round; pointer-events: none; }
#kk-svg .ghost-riser { opacity: .35; pointer-events: none; }
#kk-svg .handle { fill: #fff; stroke: #f47b20; stroke-width: 2px; vector-effect: non-scaling-stroke; cursor: move; }
#kk-svg .marker circle { stroke: #fff; stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
#kk-svg .marker.error circle { fill: #d64545; }
#kk-svg .marker.warn circle { fill: #e8a33a; }
#kk-svg .marker.info circle { fill: #3b74c2; }
#kk-svg .marker text { fill: #fff; font-family: Inter, sans-serif; font-weight: 700; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
#kk-svg .marker { cursor: pointer; }
#kk-svg .align-mark { stroke: #7c3aed; stroke-width: 1.5px; vector-effect: non-scaling-stroke; fill: none; pointer-events: none; }
#kk-svg .temp { fill: rgba(14, 165, 233, .1); stroke: #0ea5e9; stroke-width: 1.5px; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; pointer-events: none; }
#kk-svg .temp-line { stroke: #7c3aed; stroke-width: 2px; vector-effect: non-scaling-stroke; pointer-events: none; }
#kk-svg .temp-dot { fill: #7c3aed; pointer-events: none; }
#kk-svg .snap { fill: none; stroke: #16a34a; stroke-width: 2px; vector-effect: non-scaling-stroke; pointer-events: none; }
#kk-svg .ghost { stroke: #0ea5e9; stroke-width: 7px; vector-effect: non-scaling-stroke; opacity: .55; pointer-events: none; }
#kk-svg .ghost.rad-ghost { stroke: #f47b20; }

.kk-hint {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 3; max-width: calc(100% - 24px);
  padding: 7px 14px; border-radius: 20px; background: rgba(15, 42, 74, .9); color: #fff; font-size: 13px; text-align: center; pointer-events: none;
}
.kk-hint:empty { display: none; }
.kk-statusbar {
  position: absolute; left: 12px; bottom: 12px; z-index: 3; padding: 5px 10px; border-radius: 6px;
  background: rgba(255, 255, 255, .92); border: 1px solid var(--line); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.kk-statusbar:empty { display: none; }
.kk-scale-pop {
  position: absolute; right: 16px; top: 56px; z-index: 5; width: 280px; display: grid; gap: 12px;
  padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); font-size: 13.5px; color: var(--ink);
}
.kk-scale-pop > label { display: grid; gap: 6px; font-weight: 500; }
.kk-scale-pop input[type="text"] { width: 100%; min-height: 40px; padding: 8px 34px 8px 10px; font: inherit; border: 1px solid #d3dbe6; border-radius: 7px; }
.kk-pop-actions { display: flex; justify-content: flex-end; gap: 8px; }
.kk-pop-actions .btn { min-height: 36px; padding: 0 16px; }
.kk-loading { position: absolute; inset: 0; z-index: 6; display: grid; place-content: center; justify-items: center; gap: 12px; background: rgba(233, 237, 243, .8); font-size: 14px; color: var(--ink); }
.kk-spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #cbd5e1; border-top-color: var(--orange); animation: spin .8s linear infinite; }

.kk-empty { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; padding: 24px; overflow-y: auto; background: var(--bg-soft); }
.kk-empty.drag { background: var(--orange-50); }
.kk-empty-card { max-width: 620px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 30px 32px; text-align: center; }
.kk-empty-card h1 { font-size: 26px; margin-bottom: 10px; }
.kk-empty-card > p { color: var(--muted); font-size: 15px; margin-bottom: 18px; }
.kk-formats { font-size: 12.5px !important; margin: 10px 0 18px !important; }
.kk-steps { counter-reset: s; display: grid; gap: 8px; text-align: left; margin: 0 auto 16px; max-width: 480px; }
.kk-steps li { counter-increment: s; position: relative; padding-left: 32px; font-size: 14px; color: var(--text); }
.kk-steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--orange-50); color: var(--orange-600); font-weight: 700; font-size: 12px; }
.kk-steps strong { color: var(--ink); }

.kk-send-dialog { width: min(600px, calc(100vw - 32px)); }
.kk-send-dialog > p { color: var(--muted); }
.kk-send-done { text-align: center; padding: 16px 0 4px; }
.kk-send-done h3 { font-size: 19px; margin-bottom: 6px; }
.kk-send-done p { color: var(--muted); margin: 0; }

@media (max-width: 1280px) {
  .kk-app { grid-template-columns: 240px minmax(0, 1fr) 300px; }
  .kk-step:not(.active) .kk-step-label { display: none; }
  .kk-step:not(.active) { padding-right: 4px; }
  .kk-tool span { display: none; }
  .kk-tool { width: 38px; padding: 0; justify-content: center; }
}

@media (max-width: 960px) {
  .kk-app {
    height: auto; min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 64vh auto auto;
    grid-template-areas: "bar" "steps" "stage" "right" "left";
  }
  .kk-toolbar { position: sticky; top: var(--header-h); z-index: 10; overflow-x: auto; flex-wrap: nowrap; }
  .kk-group-end { margin-left: 0; }
  .kk-left, .kk-right { overflow: visible; border: 0; border-top: 1px solid var(--line); }
  .kk-btn span { display: none; }
  .kk-btn-open span { display: inline; }
  /* telefonis vihje joonise kohal eraldi ribana, mitte joonise peal */
  .kk-stage { display: flex; flex-direction: column; }
  #kk-svg { position: relative; inset: auto; flex: 1 1 auto; min-height: 0; height: auto; }
  .kk-hint {
    position: static; transform: none; flex: none; order: -1; max-width: none; width: 100%;
    border-radius: 0; padding: 7px 14px; font-size: 12.5px; line-height: 1.4; text-align: left; background: var(--navy-800);
  }
  .kk-stage.tool-select .kk-hint { display: none; }
}
