/* ThermoPlan – light and dark theme (html[data-theme], set in index.html, switched in the header) */
:root {
  color-scheme: light;
  --bg: #E4E8EE; --surface: #F4F6F9; --surface2: #EAEEF3; --input: #FBFCFD; --border: #D3D9E2; --border2: #C3CAD5;
  --ink: #172033; --ink2: #2E3748; --muted: #4E5868;
  --primary: #2457C5; --primary-hover: #1D4AAB; --accent: #2457C5; --soft: #DCE5F8; --soft-ink: #1A449F;
  --warn-bg: #F5E7CC; --warn-ink: #6B3D05; --warn: #A15C07;
  --ok-bg: #D3EEDD; --ok-ink: #0F5428; --ok: #157F3D;
  --heat: #B44A16; --heat-bg: #F6E3D8; --heat-ink: #7A3A12;
  --cool: #1D6FB8; --cool-bg: #DCEAF7; --cool-ink: #134A7A;
  --danger: #B42318; --danger-bg: #FBE4E1; --danger-border: #EBC1BB;
  --hdr: #1C2536; --hdr-ink: #FFFFFF; --hdr-muted: #C3CBD8; --hdr-active: #2C3850;
  --track: #D3D9E2;
  /* floor plan */
  --plan-bg: #F2F4F7; --grid: #E1E6EC; --grid2: #EBEEF2; --wall: #1F2937; --inner: #A9B4C4; --unheated: #E07B39;
  --plan-ink: #3E4757; --plan-ink2: #4E5868; --win: #2A7FD0; --win-fill: #D6E8FA; --door: #8A5A2B; --fixture: #FFFFFF;
  --common: #E3E7ED; --other: #E9ECF0; --room: #E8EEFA; --room-unh: #FBE9DC;
  --terr: #E1F1E6; --terr-b: #3F8A5C; --terr-ink: #2D6B45;
  --sel: #2457C5; --sel-ink: #FFFFFF; --sel-fill: #C3D5F7; --bridge: #D92D20; --bridge-off: #B8C0CC;
  /* apartment colors: fill in the plan (--uN) and the swatch in lists (--uNs) */
  --u1: #E3EBFB; --u2: #E2F2E8; --u3: #FBEBCB; --u4: #F7E3EC; --u5: #ECE7FB; --u6: #DDF1F1; --u7: #FBE5D6; --u8: #EEF3D9;
  --u1s: #8CA9EE; --u2s: #7CC79C; --u3s: #E8B550; --u4s: #E296BA; --u5s: #B4A3EE; --u6s: #6CC5C5; --u7s: #EE9F6E; --u8s: #B5C96A; --ucs: #9AA3B2;
  --radius: 14px;
}
[data-theme=dark] {
  color-scheme: dark;
  --bg: #12161D; --surface: #1A2029; --surface2: #202734; --input: #151A22; --border: #2A323E; --border2: #3A4352;
  --ink: #E7EAF0; --ink2: #CDD3DD; --muted: #A0A9B8;
  --primary: #3A6FD8; --primary-hover: #4A7CE0; --accent: #7FA6F5; --soft: #22314D; --soft-ink: #A9C4FA;
  --warn-bg: #3A2C15; --warn-ink: #F2C27A; --warn: #E9A84A;
  --ok-bg: #173322; --ok-ink: #8BD9A8; --ok: #4CB874;
  --heat: #D9733F; --heat-bg: #3A2418; --heat-ink: #F3B48F;
  --cool: #5AA6E6; --cool-bg: #17283A; --cool-ink: #A9D0F2;
  --danger: #F28B82; --danger-bg: #3A1D1B; --danger-border: #5A2A27;
  --hdr: #0D1117; --hdr-ink: #E7EAF0; --hdr-muted: #B6BECB; --hdr-active: #22314D;
  --track: #2A323E;
  --plan-bg: #151A22; --grid: #1E2530; --grid2: #19202A; --wall: #D5DBE4; --inner: #4A5466; --unheated: #F08A4B;
  --plan-ink: #CDD3DD; --plan-ink2: #A0A9B8; --win: #6AAEF0; --win-fill: #1C3350; --door: #C99A6B; --fixture: #151A22;
  --common: #232A35; --other: #1C222C; --room: #1E2A44; --room-unh: #3A2418;
  --terr: #16301F; --terr-b: #4CB874; --terr-ink: #8BD9A8;
  --sel: #7FA6F5; --sel-ink: #0D1117; --sel-fill: #2B4675; --bridge: #F97066; --bridge-off: #4A5466;
  --u1: #1E2A44; --u2: #1B3326; --u3: #3A2E16; --u4: #3A2230; --u5: #2C2546; --u6: #173236; --u7: #3A2618; --u8: #2C3418;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 17px; font-weight: 600; margin: 0; }
h3 { font-size: 16px; font-weight: 600; margin: 0; }
h4 { margin: 0; }
svg.icon { flex: none; }

/* ------------------------------------------------------------------ header */
.topbar { background: var(--hdr); color: var(--hdr-ink); }
.topbar-in { max-width: 1240px; margin: 0 auto; padding: 0 24px; min-height: 64px; display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.topbar.full .topbar-in { max-width: none; padding: 0 20px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--hdr-ink); }
.logo:hover { text-decoration: none; }
.topnav { display: flex; gap: 4px; font-size: 14px; font-weight: 500; }
.topnav a { padding: 8px 12px; border-radius: 8px; color: var(--hdr-muted); }
.topnav a.active, .topnav a:hover { background: var(--hdr-active); color: var(--hdr-ink); text-decoration: none; }
.user { margin-left: auto; display: flex; align-items: center; gap: 16px; font-size: 14px; }
.who { text-align: right; line-height: 1.3; }
.who b { display: block; font-weight: 600; color: var(--hdr-ink); }
.who span { color: var(--hdr-muted); font-size: 12px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #3B6FE0; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; flex: none; }
.hbtn { height: 36px; padding: 0 12px; border-radius: 10px; border: 0; background: var(--hdr-active); color: var(--hdr-ink); display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 500; font-size: 13px; }
.hbtn:hover { filter: brightness(1.15); }

/* light / dark switch: the active button follows html[data-theme], so Blazor keeps no state */
.mode { display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--hdr-active); }
.mode button { height: 32px; padding: 0 12px; border: 0; border-radius: 999px; background: transparent; color: var(--hdr-muted); font-weight: 500; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
[data-theme=light] .mode .to-light, [data-theme=dark] .mode .to-dark { background: var(--hdr-ink); color: var(--hdr); font-weight: 600; }

/* ------------------------------------------------------------------ page */
.page { max-width: 1240px; margin: 0 auto; padding: 36px 24px 64px; display: flex; flex-direction: column; gap: 28px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p, .subtitle { margin: 6px 0 0; color: var(--muted); font-size: 15px; }
.crumbs { font-size: 13px; color: var(--muted); }
.band { background: var(--surface); border-bottom: 1px solid var(--border); }
.band-in { max-width: 1240px; margin: 0 auto; padding: 20px 24px 22px; display: flex; flex-direction: column; gap: 14px; }
.meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; color: var(--muted); margin-top: 6px; }
.cols { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.cols > .main { flex: 999 1 640px; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.cols > .side { flex: 1 1 300px; max-width: 380px; display: flex; flex-direction: column; gap: 18px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.count { color: var(--muted); font-weight: 500; }

/* ------------------------------------------------------------------ cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card > h2 + p, .card > h3 + p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.lbl { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.help { font-size: 12.5px; color: var(--muted); font-weight: 400; line-height: 1.45; }

/* building tiles */
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 16px; color: var(--ink); }
.tile:hover { text-decoration: none; border-color: var(--border2); box-shadow: 0 4px 16px #0f172a14; }
.tile-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.tile h3 { font-size: 17px; }
.figures { display: flex; gap: 22px; flex-wrap: wrap; }
.figures b { display: block; font-size: 18px; font-weight: 600; margin-top: 2px; }
.starts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.start { background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 10px; color: var(--ink); cursor: pointer; text-align: left; }
.start:hover { text-decoration: none; border-color: var(--accent); }
.start.featured { background: var(--soft); border: 2px solid var(--accent); padding: 17px; }
.start b { font-size: 15px; font-weight: 600; }
.start span { font-size: 13px; color: var(--muted); line-height: 1.45; }
.start.featured span { color: var(--ink2); }
.num { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 600; font-size: 13px; display: flex; align-items: center; justify-content: center; flex: none; }
.num.done { background: var(--ok-bg); color: var(--ok); }
.num.todo { background: transparent; border: 1.5px solid var(--border2); color: var(--muted); }
.search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border2); background: var(--input); border-radius: 10px; padding: 0 12px; height: 40px; width: 260px; max-width: 100%; }
.search input[type=search] { border: 0; outline: 0; width: 100%; height: 38px; background: transparent; padding: 0; }

/* floors on the building page */
.floor-card { padding: 0; overflow: hidden; }
.floor-head { padding: 18px 20px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.floor-head .grow { flex: 1; min-width: 200px; }
.floor-head .sub { margin-top: 4px; font-size: 13.5px; color: var(--muted); }
.floor-badge { width: 44px; height: 44px; border-radius: 10px; background: var(--surface2); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--ink2); flex: none; }
.floor-badge.ground { background: var(--primary); color: #fff; }
.floor-body { border-top: 1px solid var(--border); padding: 4px 20px 16px; overflow-x: auto; }
.floor-body form { padding-top: 14px; }
dl.summary { margin: 0; display: flex; flex-direction: column; gap: 10px; font-size: 13.5px; }
dl.summary div { display: flex; justify-content: space-between; gap: 12px; }
dl.summary dt { color: var(--muted); }
dl.summary dd { margin: 0; text-align: right; font-weight: 500; }

/* ------------------------------------------------------------------ forms */
.fields { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; font-weight: 500; color: var(--ink); }
.field.grow { flex: 1; min-width: 180px; }
.field .small { color: var(--muted); font-weight: 400; }
.field.check { flex-direction: row; align-items: center; gap: 8px; font-size: 13.5px; padding-bottom: 10px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select {
  border: 1px solid var(--border2); border-radius: 10px; padding: 0 12px; height: 40px; background: var(--input); color: var(--ink); min-width: 0; font-weight: 500;
}
input[type=number] { width: 110px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
input:focus, select:focus { outline: 2px solid var(--soft); border-color: var(--accent); }
input::placeholder { color: var(--muted); opacity: .8; font-weight: 400; }
select.wide { width: 100%; }
.unit-input { display: flex; align-items: center; gap: 6px; border: 1px solid var(--border2); border-radius: 10px; height: 40px; padding: 0 12px; background: var(--input); }
.unit-input input { border: 0; height: 38px; padding: 0; background: transparent; width: 100%; outline: 0; }
.unit-input:focus-within { outline: 2px solid var(--soft); border-color: var(--accent); }
.unit-input span { color: var(--muted); font-size: 14px; }
.actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* segmented choice and selectable chips */
.segmented { display: flex; border: 1px solid var(--border2); border-radius: 10px; padding: 3px; gap: 3px; background: var(--surface2); flex-wrap: wrap; }
.segmented button { flex: 1; min-height: 36px; border: 0; border-radius: 8px; background: transparent; font-weight: 500; font-size: 13px; color: var(--ink2); cursor: pointer; padding: 0 10px; }
.segmented button.on { background: var(--soft); color: var(--soft-ink); font-weight: 600; }
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.choice { border: 1px solid var(--border2); background: var(--surface2); border-radius: 999px; height: 34px; padding: 0 12px; font-weight: 500; font-size: 13px; color: var(--ink2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.choice:hover { border-color: var(--accent); }
.choice.on { border-color: var(--accent); background: var(--soft); color: var(--soft-ink); font-weight: 600; }
select.choice { padding-right: 8px; width: auto; max-width: 170px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border2); border-radius: 8px; overflow: hidden; background: var(--surface); flex: none; }
.stepper button { width: 30px; height: 30px; border: 0; background: var(--surface); color: var(--ink); cursor: pointer; font-weight: 600; font-size: 15px; }
.stepper button:hover { background: var(--surface2); }
.stepper span { min-width: 26px; text-align: center; font-weight: 600; }
.stepper.lg { height: 40px; width: 100%; border-radius: 10px; background: var(--input); }
.stepper.lg button { width: 46px; height: 40px; background: var(--surface2); font-size: 18px; }
.stepper.lg span { flex: 1; font-size: 16px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: var(--surface2); border-radius: 10px; }
.switch-row.on { background: var(--heat-bg); }
.switch-row b { display: block; font-weight: 600; }
.switch-row span { font-size: 12.5px; color: var(--muted); }
.switch-row.on span { color: var(--heat-ink); }
.toggle { width: 46px; height: 26px; border-radius: 999px; border: 0; background: var(--border2); position: relative; cursor: pointer; flex: none; padding: 0; }
.toggle::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; }
.toggle.on { background: var(--heat); }
.toggle.on::after { left: 23px; }

/* ------------------------------------------------------------------ buttons */
.btn { border: 1px solid var(--border2); background: var(--surface); color: var(--ink); border-radius: 10px; padding: 0 16px; height: 40px; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; font-size: 14px; line-height: 1; }
.btn:hover { background: var(--surface2); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn.active { background: var(--soft); border-color: var(--accent); color: var(--soft-ink); }
.btn.danger { color: var(--danger); border-color: var(--danger-border); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--soft); }
.btn.dashed { border-style: dashed; }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { height: 44px; padding: 0 18px; }
.btn.block { width: 100%; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 500; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ table */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .right { text-align: right; white-space: nowrap; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: middle; }

/* ------------------------------------------------------------------ messages */
.alert { border-radius: 10px; padding: 10px 14px; font-size: 13.5px; line-height: 1.5; display: flex; gap: 10px; align-items: flex-start; }
.alert > div { flex: 1; }
.alert.error { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.alert.warn { background: var(--warn-bg); color: var(--warn-ink); }
.alert.ok { background: var(--ok-bg); color: var(--ok-ink); }
.alert.info { background: var(--soft); color: var(--soft-ink); }
.alert ul { margin: 6px 0 0 18px; padding: 0; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface2); color: var(--ink2); white-space: nowrap; }
.chip.blue { background: var(--soft); color: var(--soft-ink); }
.chip.ok { background: var(--ok-bg); color: var(--ok-ink); }
.chip.warn { background: var(--warn-bg); color: var(--warn-ink); }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty h2 { color: var(--ink); }
.empty p { margin: 0; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.bad-text { color: var(--danger); font-weight: 600; }

/* ------------------------------------------------------------------ sign in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--hdr); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 30px; box-shadow: 0 20px 60px #0006; }
.auth-card .logo { color: var(--ink); font-size: 22px; margin-bottom: 10px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.auth-card .btn.primary { height: 44px; }
.auth-card .switch { margin-top: 18px; font-size: 13.5px; color: var(--muted); text-align: center; }
.auth-mode { position: fixed; top: 16px; right: 16px; }

/* ------------------------------------------------------------------ express build wizard */
.wizard { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.wizard-steps { flex: 1 1 220px; max-width: 260px; display: flex; flex-direction: column; gap: 4px; }
.wizard-steps button { display: flex; gap: 12px; padding: 12px; border-radius: 10px; border: 1px solid transparent; background: transparent; text-align: left; cursor: pointer; color: var(--ink); }
.wizard-steps button:hover { background: var(--surface); }
.wizard-steps button.on { background: var(--surface); border-color: var(--accent); }
.wizard-steps button.on b { color: var(--accent); }
.wizard-steps b { display: block; font-size: 14px; font-weight: 600; }
.wizard-steps small { font-size: 12.5px; color: var(--muted); }
.wizard-main { flex: 999 1 520px; min-width: 0; padding: 28px; display: flex; flex-direction: column; gap: 24px; }
.wizard-main h1 { font-size: 24px; }
.wizard-nav { display: flex; justify-content: space-between; gap: 12px; padding-top: 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.preview { flex: 1 1 300px; max-width: 360px; padding: 22px; display: flex; flex-direction: column; gap: 18px; }
.preview-box { background: var(--surface2); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.facts-grid { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.facts-grid div { background: var(--surface2); border-radius: 10px; padding: 12px; }
.facts-grid dd { margin: 4px 0 0; font-size: 18px; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.tbl.express th, .tbl.express td { text-align: center; padding: 6px; }
.tbl.express th:first-child, .tbl.express td:first-child { text-align: left; white-space: nowrap; }
.tbl.express td.terrace { white-space: nowrap; text-align: left; }
.tbl.express input[type=number] { height: 34px; padding: 0 8px; }
.tbl.express select { height: 34px; }
/* express build: one card per apartment */
.apt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 10px; }
.apt-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--surface2); }
.apt-head { display: flex; justify-content: space-between; align-items: center; }
.apt-sides { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.apt-sides th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 0 6px; }
.apt-sides td { padding: 3px 0; }
.apt-sides input { width: 64px; }
.apt-add { border: 1px dashed var(--border2); border-radius: 12px; background: transparent; color: var(--accent); font-weight: 600; cursor: pointer; min-height: 120px; }
.apt-add:hover { background: var(--surface2); }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }

/* ------------------------------------------------------------------ floor plan editor */
.editor-bar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 20px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 57px; }
.editor-bar .crumbs { font-size: 14px; flex: 1; min-width: 200px; }
.editor-bar .crumbs b { color: var(--ink); }
.saved { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ok); }
.dirty { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--warn); font-weight: 500; }
.editor-page { height: calc(100vh - 64px); display: flex; flex-direction: column; }
.editor { flex: 1; min-height: 0; display: grid; grid-template-columns: 270px minmax(0, 1fr) 360px; }
.editor-side, .editor-panel { background: var(--surface); overflow-y: auto; }
.editor-side { border-right: 1px solid var(--border); padding: 18px 14px; display: flex; flex-direction: column; gap: 18px; }
.editor-panel { border-left: 1px solid var(--border); padding: 18px 20px; display: flex; flex-direction: column; gap: 18px; }
.editor-main { min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.editor-main > .alert { margin: 12px 16px 0; }
.toolbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 6px 12px; display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.toolbar .sep { width: 1px; height: 32px; background: var(--border); margin: 0 6px; }
.toolbar .spacer { flex: 1; }
.toolbar .field.inline { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; }
.toolbar select { height: 36px; }
.tool { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 62px; height: 54px; border: 0; border-radius: 10px; background: transparent; font-weight: 500; font-size: 12px; color: var(--ink2); cursor: pointer; padding: 0 8px; }
.tool:hover { background: var(--surface2); }
.tool.on { background: var(--soft); color: var(--soft-ink); font-weight: 600; }
.canvas { flex: 1; min-height: 0; margin: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--plan-bg); overflow: auto; display: flex; }
svg.plan { width: 100%; height: 100%; min-height: 420px; display: block; touch-action: none; user-select: none; }
.legend { margin: 0 16px 14px; display: flex; gap: 18px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--ink2); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 22px; flex: none; }
.legend label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.legend label:first-of-type { margin-left: auto; }

/* left column: floors and units */
.floor-switch { display: flex; border: 1px solid var(--border2); border-radius: 10px; padding: 3px; gap: 3px; background: var(--surface2); flex-wrap: wrap; }
.floor-switch button { flex: 1; min-width: 60px; height: 34px; border: 0; border-radius: 8px; background: transparent; font-weight: 500; font-size: 13px; color: var(--ink2); cursor: pointer; white-space: nowrap; padding: 0 6px; }
.floor-switch button.on { background: var(--soft); color: var(--soft-ink); font-weight: 600; }
.side-sec { display: flex; flex-direction: column; gap: 4px; }
.side-sec > .lbl { padding: 0 4px 4px; }
.unit-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; font-size: 14px; color: var(--ink); cursor: pointer; border: 0; background: transparent; width: 100%; text-align: left; }
.unit-row:hover { background: var(--surface2); }
.unit-row.sel { background: var(--soft); }
.unit-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unit-row .note { font-size: 12px; color: var(--muted); white-space: nowrap; }
.unit-row .note.warn { color: var(--warn); }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; }
.unit-open { background: var(--surface2); border: 1px solid var(--border2); border-radius: 10px; padding: 2px 0 6px; }
.unit-open > .unit-row { font-weight: 600; }
.unit-open > .unit-row:hover { background: transparent; }
.rooms { display: flex; flex-direction: column; gap: 2px; padding: 0 8px 0 30px; font-size: 13.5px; }
.room-row { display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: 8px; color: var(--ink); cursor: pointer; border: 0; background: transparent; text-align: left; }
.room-row:hover { background: var(--surface); }
.room-row span:last-child { color: var(--muted); white-space: nowrap; }
.room-row.sel { background: var(--sel); color: var(--sel-ink); font-weight: 600; }
.room-row.sel span:last-child { color: var(--sel-ink); font-weight: 500; }
.rooms .link-btn { text-align: left; padding: 7px 10px; font-size: 13px; }
.side-box { background: var(--surface2); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.side-box b { font-size: 13.5px; }
.side-box .help { margin: 0; }
.side-box select { width: 100%; }
.side-foot { margin-top: auto; }

/* right panel */
.panel-head { display: flex; align-items: flex-start; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--border); margin: 0 -20px; padding: 0 20px 14px; }
.panel-head > div { flex: 1; min-width: 0; }
.panel-head .kicker { font-size: 12.5px; color: var(--muted); }
.panel-head h2 { font-size: 20px; font-weight: 700; margin-top: 2px; display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent; color: var(--ink2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--surface2); }
.psec { display: flex; flex-direction: column; gap: 12px; }
.psec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.panel-foot { margin: auto -20px -18px; padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: space-between; flex-wrap: wrap; align-items: center; }
.facts { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; margin: 0; font-size: 13.5px; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; }
.auto-badge { align-self: flex-start; display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; background: var(--ok-bg); color: var(--ok-ink); border-radius: 999px; padding: 3px 10px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface2); border-radius: 10px; padding: 10px 12px; }
.stat b { display: block; font-size: 18px; font-weight: 600; } .stat span { font-size: 12px; color: var(--muted); }
.stat-row { display: flex; gap: 10px; align-items: center; font-size: 13.5px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.stat-row:last-child { border-bottom: 0; }
.stat-row span:nth-child(2) { color: var(--muted); flex: 1; }
.stat-row .ok { color: var(--ok); } .stat-row .bad { color: var(--warn); }
.item-row { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--surface2); }
.item-row .name { flex: 1; font-size: 14px; font-weight: 500; min-width: 0; }
.item-row input[type=number] { width: 84px; height: 34px; }
.list-box { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 10px; font-size: 13.5px; }
.list-box li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.list-box li:last-child { border-bottom: 0; }
.layers { display: flex; flex-wrap: wrap; gap: 4px; }
.layers span { font-size: 11.5px; background: var(--surface2); color: var(--ink2); border-radius: 6px; padding: 2px 7px; }
.op-row { border: 1px solid var(--border); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 10px; background: var(--surface2); }
.op-row .fields { gap: 10px; }
.op-row input[type=number] { width: 78px; }
.apply-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); }
.quick { display: flex; flex-direction: column; gap: 8px; background: var(--soft); color: var(--soft-ink); border-radius: 12px; padding: 14px; }
.quick b { font-size: 14px; }
.quick .help { color: var(--soft-ink); }
.steps { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.steps li { margin-bottom: 6px; }
.steps b { color: var(--ink2); }
details.more summary { cursor: pointer; font-weight: 500; font-size: 13px; color: var(--ink2); }
details.more[open] summary { margin-bottom: 10px; }
details.more > div { display: flex; flex-direction: column; gap: 10px; }

/* plan drawing (SVG) */
svg.plan .room { cursor: pointer; }
svg.plan.draw, svg.plan.draw .room, svg.plan.draw .hit { cursor: crosshair; }
svg.plan.split .room { cursor: cell; }
svg.plan .seg.h .hit { cursor: ns-resize; }
svg.plan .seg.v .hit { cursor: ew-resize; }
svg.plan.draw .seg .hit { cursor: crosshair; }
svg.plan .tb { cursor: pointer; }
svg.plan .opening.h { cursor: ew-resize; } svg.plan .opening.v { cursor: ns-resize; }
.seg .vis { stroke-linecap: butt; }
.seg:hover .vis { filter: brightness(.8); }
.hit { stroke: transparent; stroke-width: 16; }
.w-ext { stroke: var(--wall); } .w-int { stroke: var(--inner); } .w-unh { stroke: var(--unheated); }
.rname { font-size: 15px; font-weight: 600; fill: var(--plan-ink); }
.rarea { font-size: 12.5px; fill: var(--plan-ink2); }
.uname { font-size: 19px; font-weight: 700; fill: var(--plan-ink); }
.plbl { font-size: 13px; font-weight: 500; fill: var(--plan-ink2); }
.ghost-label { font-size: 15px; font-weight: 600; fill: var(--sel); }

@media (max-width: 1100px) {
  .editor-page { height: auto; }
  .editor { grid-template-columns: 1fr; }
  .editor-side, .editor-panel { border: 0; border-bottom: 1px solid var(--border); overflow: visible; }
  .editor-main { order: -1; }
  svg.plan { min-height: 360px; }
}
@media (max-width: 640px) {
  .page { padding: 24px 16px 48px; }
  .topbar-in { padding: 8px 16px; gap: 12px; }
  .who { display: none; }
  .search { width: 100%; }
}

/* ------------------------------------------------------------------ Blazor */
#blazor-error-ui { background: var(--warn-bg); color: var(--warn-ink); bottom: 0; box-shadow: 0 -1px 2px #0003; display: none; left: 0; padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
.loading-progress { position: absolute; display: block; width: 8rem; height: 8rem; inset: 20vh 0 auto 0; margin: 0 auto; }
.loading-progress circle { fill: none; stroke: var(--border); stroke-width: .6rem; transform-origin: 50% 50%; transform: rotate(-90deg); }
.loading-progress circle:last-child { stroke: var(--primary); stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%; transition: stroke-dasharray .05s ease-in-out; }
.loading-progress-text { position: absolute; text-align: center; font-weight: bold; inset: calc(20vh + 3.25rem) 0 auto .2rem; color: var(--muted); }
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Loading"); }

/* fan coils of a room */
.fan-coils .fc-title { font-size: 13px; margin: 14px 0 6px; }
.fan-coils .fc-title:first-of-type { margin-top: 0; }
.tbl.fc td, .tbl.fc th, .tbl.fc-speeds td, .tbl.fc-speeds th { padding: 6px 8px; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent, var(--soft-ink)); cursor: pointer; text-decoration: underline; }
.tbl.fc tr.fc-open > td { background: var(--surface); }
.tbl.fc td.fc-detail { padding: 4px 12px 12px 24px; }
.tbl.fc-speeds { font-size: 13px; }
.fc-ok { color: var(--ok-ink); font-weight: 600; }
.fc-gate { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; border-radius: 10px; background: var(--surface); font-size: 13.5px; }
.fc-gate span { margin-right: auto; }

/* room loads: floor → apartment → room, floors and apartments open on click */
.tbl.loads tr.grp { cursor: pointer; }
.tbl.loads tr.grp td:first-child { white-space: nowrap; }
.tbl.loads td, .tbl.loads th { padding: 8px 10px; }
.tbl.loads .temps { display: flex; align-items: center; gap: 6px; }
.tbl.loads .temps input { width: 58px; height: 32px; padding: 0 8px; }
.tbl.loads .temps > span { width: 58px; text-align: center; }
.tbl.loads .temps > span:nth-child(2) { width: auto; }
.tbl.loads tr.grp:hover td { background: var(--surface2); }
.tbl.loads tr.grp.floor td { font-weight: 600; background: var(--surface); }
.tbl.loads tr.grp.unit td:first-child { padding-left: 28px; font-weight: 500; }
.tbl.loads tr.room td:first-child { padding-left: 52px; }
.tbl.loads .caret { display: inline-block; width: 16px; color: var(--muted); }
