:root {
  --bg: #10110f;
  --card: #191d1b;
  --surface-2: #232924;
  --hover: #2d352f;
  --ink: #f3f0e8;
  --muted: #aeb8b0;
  --line: #343d37;
  --line-2: #4b574f;
  --accent: #66c8bc;
  --accent-d: #a6e0d8;
  --accent-soft: rgba(102,200,188,.14);
  --accent-soft-line: rgba(102,200,188,.38);
  --wood: #d2a15f;
  --steel: #83b7d9;
  --earth: #91a36a;
  --warn: #e0a84f;
  --danger: #ff6f66;
  --danger-soft: rgba(255,111,102,.15);
  --danger-line: rgba(255,111,102,.38);
  --good: #4cc568;
  --radius: 14px;
  --shadow: 0 18px 58px rgba(0,0,0,.38);
  color-scheme: dark;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
/* Blød baggrund bag den centrerede app-kolonne */
body { background: linear-gradient(180deg, #1b1d18 0%, #111310 44%, #0c0d0c 100%); }

/* Diskrete mørke scrollbars */
* { scrollbar-width: thin; scrollbar-color: #39424f transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #39424f; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #4a5563; background-clip: content-box; }

#app { display: flex; flex-direction: column; min-height: 100vh; width: 100%; max-width: 1600px; margin: 0 auto; padding: 0 18px 8px; }

/* ---- Header ---- */
#hd {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 20px; background: var(--card);
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand strong { font-size: 17px; }
.brand .sub { margin-left: 8px; color: var(--muted); font-size: 13px; }

.filebar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.name-inp { font: inherit; padding: 4px 8px; background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-2); border-radius: 8px; font-size: 13px; width: 150px; }
.name-inp:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.lang { display: flex; align-items: center; gap: 6px; }
.lang-l { color: var(--muted); font-size: 12px; }
.lang-b, .tab, .utog-b, .btn-sm {
  font: inherit; cursor: pointer; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); border-radius: 8px; padding: 4px 10px; font-size: 13px;
}
.lang-b:hover, .utog-b:hover, .btn-sm:hover { background: var(--hover); }
.lang-b.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---- Tab bar ---- */
#tabbar { display: flex; gap: 6px; padding: 10px 20px 0; flex-wrap: wrap; }
.tab { padding: 8px 16px; border-radius: 10px 10px 0 0; border-bottom: none; }
.tab:hover { background: var(--hover); }
.tab.on { background: var(--card); color: var(--accent); font-weight: 600; box-shadow: var(--shadow); }

/* ---- Content ---- */
#content {
  flex: 1; margin: 0 20px 16px; padding: 20px 22px; background: var(--card);
  border-radius: 0 var(--radius) var(--radius) var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
#content h2 { margin: 0 0 4px; font-size: 19px; }
#content h3 { margin: 0 0 8px; font-size: 14px; color: var(--accent-d); }
.intro { margin: 0 0 16px; color: var(--muted); font-size: 13.5px; max-width: 56ch; }

.twocol { display: grid; grid-template-columns: minmax(260px, 320px) 1fr; gap: 24px; align-items: start; }
@media (max-width: 720px) { .twocol { grid-template-columns: 1fr; } }

/* ---- Inputs ---- */
.panel { display: flex; flex-direction: column; gap: 12px; }
.fld { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.fld-l { color: var(--muted); font-size: 12px; font-weight: 600; }
.fld-h { color: var(--muted); font-size: 11px; }
.fld input, .panel select {
  font: inherit; padding: 6px 8px; background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-2); border-radius: 8px; font-size: 14px; width: 100%;
}
.fld input:focus, .panel select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
/* Smalle talfelter i analyse-faner (ikke abnormt brede) */
.panel .fld input[type=number] { width: 120px; max-width: 120px; }
/* Kort top-indstillinger: smalle talfelter */
.site-settings .fld.inline input[type=number] { width: 78px; flex: 0 0 auto; }

.unit-row { display: flex; gap: 14px; flex-wrap: wrap; padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
.utog { display: flex; align-items: center; gap: 6px; }
.utog-l { color: var(--muted); font-size: 11px; }
.utog-bs { display: inline-flex; }
.utog-b { border-radius: 0; padding: 3px 9px; }
.utog-b:first-child { border-radius: 7px 0 0 7px; }
.utog-b:last-child { border-radius: 0 7px 7px 0; border-left: none; }
.utog-b.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---- Material control ---- */
.mat-block { display: flex; flex-direction: column; gap: 4px; }
.matctl-row { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.matctl-row select { flex: 1; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-sm.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-sm.primary:hover { background: var(--accent-d); }
.btn-sm.danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
/* ---- Results ---- */
.results { background: var(--accent-soft); border: 1px solid var(--accent-soft-line); border-radius: var(--radius); padding: 14px 16px; max-width: 340px; }
.res { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.res:last-child { border-bottom: none; }
.res-l { color: var(--muted); }
.res-v { font-weight: 600; font-variant-numeric: tabular-nums; }
.res.big .res-v { font-size: 18px; color: var(--danger); }
.res-note { margin-top: 8px; font-size: 11px; line-height: 1.45; color: var(--muted); }

/* ---- Chart ---- */
.charthost { margin-top: 16px; }
.chart-title { font-size: 13px; font-weight: 600; color: var(--accent-d); margin-bottom: 4px; }
.chart { width: 100%; max-width: 460px; height: auto; background: #141c27; border: 1px solid var(--line); border-radius: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.leg-item { display: inline-flex; align-items: center; gap: 5px; }
.leg-sw { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }

/* ---- Site map editor ---- */
.site-settings { display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: flex-end; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px dashed var(--line); }
.fld.inline { flex-direction: row; align-items: center; gap: 8px; }
.fld.inline .fld-l { margin: 0; }

.map-wrap { display: flex; gap: 12px; align-items: flex-start; }
.toolpalette { display: flex; flex-direction: column; gap: 6px; flex: 0 0 96px; }
.toolbtn { display: flex; align-items: center; gap: 7px; padding: 7px 9px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); border-radius: 9px; cursor: pointer; font: inherit; font-size: 12.5px; text-align: left; }
.toolbtn:hover { background: var(--hover); }
.toolbtn.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.toolbtn-i { font-size: 15px; width: 18px; text-align: center; }
.zoombar { display: flex; gap: 4px; margin-top: 6px; }
.zoombar .btn-sm { flex: 1; text-align: center; font-size: 15px; padding: 2px 0; }
.zoombar.map-actions { flex-direction: column; }
.zoombar.map-actions .btn-sm { width: 100%; font-size: 11px; line-height: 1.2; padding: 5px 3px; }

.map { flex: 1; min-width: 0; max-width: 500px; aspect-ratio: 520 / 440; display: block; background: #131c28; border: 1px solid var(--line); border-radius: 10px; touch-action: none; cursor: crosshair; overflow: hidden; }
.map svg { display: block; width: 100%; height: 100%; }
.map:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.map-help { margin-top: 8px; font-size: 12px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }

.sel-hint { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.conntable-area { margin-top: 16px; }
.conntable-area h3 { margin: 0 0 8px; font-size: 14px; color: var(--accent-d); }
/* Tabeller som højre kolonne ved siden af kortet */
.conntable-area.side { flex: 0 0 460px; min-width: 0; align-self: stretch; margin-top: 0; max-height: 560px; overflow: auto; container-type: inline-size; }
.conntable-area.side h3 { font-size: 13px; }
@media (max-width: 760px) { .conntable-area.side { flex: 1 1 100%; max-height: none; } }
.conntab.full { font-size: 13px; }
.conntab.full td, .conntab.full th { padding: 5px 8px; vertical-align: middle; }
.conntab.full .editc { padding: 3px 6px; }
.conntab.full td.numc { font-variant-numeric: tabular-nums; white-space: nowrap; }
.conntab.full select, .conntab.full input[type=number] { width: 100%; min-width: 64px; font: inherit; font-size: 13px; padding: 4px 6px; background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-2); border-radius: 6px; }
.conntab.full input[type=number] { max-width: 100px; }
.conntab.full select:focus, .conntab.full input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

/* Kompakt (dense) variant */
.conntab.full.dense { font-size: 11.5px; }
.conntab.full.dense th { font-size: 10px; padding: 2px 5px; }
.conntab.full.dense td { padding: 1px 5px; }
.conntab.full.dense td.conn-name { width: 46px; min-width: 46px; white-space: nowrap; line-height: 1; }
.conntab.full.dense .conn-name-text { display: inline-block; vertical-align: middle; white-space: nowrap; }
.conntab.full.dense .conn-name .cdot { margin-right: 4px; }
.conntab.full.dense .editc { padding: 1px 3px; }
.conntab.full.dense select, .conntab.full.dense input[type=number] { font-size: 11.5px; padding: 2px 3px; border-radius: 5px; }
.conntab.full.dense input[type=number] { width: 56px; min-width: 0; max-width: 64px; }
.conntab.full.dense select { width: 100%; min-width: 98px; max-width: 130px; }
.connections-tab { table-layout: fixed; width: 100%; }
.connections-tab .conn-name-col, .connections-tab td.conn-name { width: 44px; min-width: 44px; }
.connections-tab .conn-mat-col, .connections-tab td.conn-mat { width: 92px; }
.connections-tab .conn-wall-col, .connections-tab td.conn-wall { width: 46px; }
.connections-tab .conn-measure-col, .connections-tab td.conn-measure { width: 46px; }
.connections-tab .conn-result-col, .connections-tab td.conn-result { width: 42px; }
.connections-tab .conn-defl-col, .connections-tab td.conn-defl { width: 56px; }
.connections-tab select { min-width: 0 !important; max-width: none !important; padding-inline: 2px !important; }
.connections-tab input[type=number] { width: 100% !important; min-width: 0; max-width: none; padding-inline: 2px !important; }
.connections-tab th, .connections-tab td { overflow: hidden; text-overflow: ellipsis; }
.connections-tab .not-applicable { display: block; text-align: center; color: var(--muted); }
.posts-h { margin-top: 12px !important; }
.posts-tab { max-width: 100%; }
.posts-tab .post-mat-cell select { min-width: 88px; max-width: 120px; }
.posts-tab .post-sway-col, .posts-tab .post-sway { width: 64px; min-width: 64px; text-align: right; white-space: nowrap; }
.posts-tab .post-sway.ok-value { color: var(--good); }
.posts-tab .post-sway.warn-value { color: var(--warn); }
.posts-tab .post-sway.crit-value { color: var(--danger); font-weight: 700; }
.crow.warn { background: rgba(224,168,79,.12); }
.pdot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; background: #b6986a; border: 1px solid #6b4f2a; vertical-align: middle; margin-right: 4px; }
.adot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #8fa3c9; vertical-align: middle; margin-right: 4px; }
.persons-tab { max-width: 320px; }
.ladders-tab { min-width: 620px; }
.ladder-dot { display: inline-block; width: 9px; height: 9px; border: 1px solid #0e7490; background: #67d3e8; vertical-align: middle; margin-right: 4px; }
.conntab.full.dense th.delete-col, .conntab.full.dense td.delete-col { width: 30px; min-width: 30px; padding-inline: 2px; text-align: center; }
.row-delete { width: 26px; height: 26px; display: inline-grid; place-items: center; padding: 0; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); font: 700 18px/1 system-ui, sans-serif; cursor: pointer; }
.row-delete:hover, .row-delete:focus-visible { color: var(--danger); border-color: var(--danger-line); background: var(--danger-soft); outline: none; }
.conntab { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 4px; }
.conntab th { text-align: left; color: var(--muted); font-weight: 600; font-size: 10.5px; padding: 3px 4px; border-bottom: 1px solid var(--line); }
.conntab td { padding: 4px 4px; border-bottom: 1px solid var(--line); }
.crow { cursor: pointer; }
.crow:hover { background: var(--hover); }
.crow.on { background: var(--accent-soft); }
.crow.crit { background: var(--danger-soft); }
.crow.crit td { color: var(--danger); }
.cdot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; margin-right: 3px; }
.encnote { font-size: 11px; color: var(--muted); line-height: 1.4; margin: 6px 0 10px; }

@container (max-width: 540px) {
  .conntable-area.side .conntab { display: block; width: 100%; min-width: 0; max-width: none; }
  .conntable-area.side .conntab thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .conntable-area.side .conntab tbody { display: block; }
  .conntable-area.side .conntab tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; position: relative; padding: 10px 4px; border-bottom: 1px solid var(--line); }
  .conntable-area.side .conntab tbody td { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: auto; min-width: 0; padding: 0; border: 0; white-space: normal; overflow: visible; font-size: 13px; }
  .conntable-area.side .conntab tbody td:first-child { grid-column: 1 / -1; flex-direction: row; align-items: center; padding-right: 40px; font-weight: 700; min-height: 32px; }
  .conntable-area.side .conntab td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: 11px; font-weight: 400; overflow-wrap: anywhere; }
  .conntable-area.side .conntab td.delete-col { position: absolute; top: 8px; right: 4px; }
  .conntable-area.side .conntab .row-delete { width: 34px; height: 34px; border-color: var(--line); }
  .conntable-area.side .conntab input[type=number], .conntable-area.side .conntab select { width: 100% !important; min-width: 0 !important; max-width: none !important; min-height: 32px; font-size: 16px; }
}

/* ---- 3D view ---- */
.view3d-host { position: relative; width: 100%; max-width: none; aspect-ratio: 16 / 9; background: #131c28; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.view3d-status { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 13px; text-align: center; padding: 16px; }
.view3d-hint { margin-top: 8px; font-size: 12px; color: var(--muted); }

/* ---- Materials list + cut list ---- */
.mat-list { width: 100%; max-width: 640px; border-collapse: collapse; font-size: 13.5px; }
.mat-list td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.mat-list td.q { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); font-weight: 600; }
.mat-list tr.sub td { padding-top: 1px; padding-bottom: 6px; border-bottom: 1px solid var(--line); font-size: 11.5px; color: var(--muted); }
.mat-list tr.sub td:first-child { padding-left: 24px; }
.mat-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; vertical-align: baseline; box-shadow: 0 0 0 1px rgba(255,255,255,.14); }
.mat-note { margin: 8px 0 4px; font-size: 11.5px; color: var(--muted); line-height: 1.45; max-width: 640px; }
.pipe-specs { margin: 16px 0 22px; padding: 14px 16px; border-block: 1px solid var(--line); background: rgba(255,255,255,.018); }
.pipe-specs-head { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; }
.pipe-specs-head h3 { margin: 0; }
.pipe-specs-head .mat-note { margin: 0; text-align: right; }
.pipe-specs-scroll { overflow-x: auto; }
.pipe-spec-table { width: 100%; margin-top: 10px; border-collapse: collapse; }
.pipe-spec-table th, .pipe-spec-table td { padding: 7px 10px; border-top: 1px solid rgba(166,224,216,.1); text-align: left; white-space: nowrap; }
.pipe-spec-table th { color: var(--muted); font-size: 11px; font-weight: 700; }
.pipe-spec-name { font-weight: 700; }
.pipe-wall-cell .pipe-wall-input { margin-right: 6px; }
.pipe-wall-input { width: 76px; }
.pipe-standard-cell { color: var(--muted); }
.pipe-standard-cell .pipe-wall-reset { margin-left: 8px; }
.pipe-wall-reset { width: 30px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); color: var(--ink); cursor: pointer; }
.pipe-wall-reset:hover { border-color: var(--accent); color: var(--accent); }
.pipe-wall-custom { font-size: 11px; color: var(--muted); }
@media (max-width: 600px) {
  .pipe-specs { padding-inline: 0; }
  .pipe-spec-table th, .pipe-spec-table td { white-space: normal; padding: 7px 3px; }
  .pipe-spec-table small { display: block; }
  .pipe-wall-input { width: 64px; font-size: 16px; }
  .pipe-standard-cell .pipe-wall-reset { display: block; margin: 4px 0 0; }
  .view3d-host { aspect-ratio: 1; }
}
.cut-h { margin-top: 22px; }
.cutlist { max-width: 720px; }
.cl-grp { margin-bottom: 14px; padding: 10px 12px 8px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; background: var(--surface-2); }
.cl-grp-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.cl-grp-h b { font-size: 13px; color: var(--ink); display: inline-flex; align-items: center; }
.cl-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; box-shadow: 0 0 0 1px rgba(255,255,255,.14); }
.cl-stock { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.cl-stock-inp { width: 72px; font: inherit; font-size: 13px; padding: 3px 6px; background: var(--bg); color: var(--ink); border: 1px solid var(--line-2); border-radius: 6px; }
.cl-stock-inp:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.cl-warn { font-size: 12px; color: var(--danger); margin-top: 4px; }
.cl-bar { display: flex; height: 26px; margin: 6px 0 2px; border: 1px solid var(--line-2); border-radius: 5px; overflow: hidden; background: var(--bg); }
.cl-seg { display: flex; align-items: center; justify-content: center; gap: 5px; color: #fff; font-size: 11px; font-weight: 600; overflow: hidden; white-space: nowrap; border-right: 1px solid rgba(255,255,255,.5); }
.cl-seg-lbl { font-weight: 700; opacity: .85; font-size: 10px; padding: 0 3px; border-radius: 3px; background: rgba(0,0,0,.28); }
.cl-waste { display: flex; align-items: center; justify-content: center; background: repeating-linear-gradient(45deg, #232a34, #232a34 5px, #1a2029 5px, #1a2029 10px); color: var(--muted); font-size: 11px; }
.cl-kerf { flex: 0 0 auto; min-width: 1px; background: #e2e8f0; border-right: 1px solid #94a3b8; }
.cl-list { font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.cut-settings { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: -8px 0 10px; padding: 8px 10px; max-width: 700px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.cut-settings .fld { margin: 0; }
.cut-settings .fld input { width: 70px; }
.cut-settings-hint { color: var(--muted); font-size: 11.5px; }

.classic-link { color: var(--accent); font-weight: 600; text-decoration: none; }
.classic-link:hover { text-decoration: underline; }

/* ---- Refreshed layout pass ---- */
#hd {
  margin: 14px 20px 0;
  border: 1px solid rgba(166,224,216,.16);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(32,37,32,.94), rgba(21,26,24,.96));
  box-shadow: 0 12px 44px rgba(0,0,0,.28);
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 220px; }
.brand strong { font-size: 18px; letter-spacing: 0; }
.brand .sub { margin-left: 0; color: var(--wood); font-weight: 600; }
.filebar { margin-left: auto; padding: 3px; background: rgba(255,255,255,.035); border: 1px solid rgba(255,255,255,.06); border-radius: 12px; }
.name-inp { width: 170px; border-radius: 10px; background: rgba(16,17,15,.72); }
.lang { padding: 3px; background: rgba(255,255,255,.035); border: 1px solid rgba(255,255,255,.06); border-radius: 12px; }
.lang-l { padding-left: 4px; }
.lang-b, .tab, .utog-b, .btn-sm { border-color: rgba(166,224,216,.16); }
.lang-b.on, .utog-b.on, .btn-sm.primary {
  background: linear-gradient(180deg, #76d6ca, #42b8aa);
  color: #08100f;
  border-color: rgba(166,224,216,.72);
  font-weight: 700;
}

#tabbar {
  gap: 4px;
  margin: 12px 20px 0;
  padding: 5px;
  width: auto;
  background: rgba(10,12,11,.48);
  border: 1px solid rgba(166,224,216,.11);
  border-radius: 14px;
}
/* Hver gruppe = en lille søjle: sektions-overskrift ØVERST, fane-række under */
.tab-group {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-width: 0;
}
.tab-row { display: inline-flex; align-items: center; gap: 4px; }
.tab-group-labeled {
  margin-left: 10px;
  padding-left: 12px;
  border-left: 1px solid rgba(166,224,216,.14);
}
/* Første gruppe: ingen indledende skillelinje */
.tab-group-labeled:first-child { margin-left: 0; padding-left: 0; border-left: none; }
/* Overskriften skal IKKE ligne en fane: lille, dæmpet, ikke-klikbar caption */
.tab-group-label {
  padding: 0 6px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em;
  white-space: nowrap;
  opacity: .75;
  pointer-events: none;
  user-select: none;
}
.tab {
  border: 1px solid rgba(166,224,216,.18);
  border-radius: 10px;
  background: rgba(255,255,255,.05);
  color: var(--muted);
  padding: 7px 15px;
  font-weight: 600;
}
.tab:hover { background: rgba(255,255,255,.1); color: var(--ink); border-color: rgba(166,224,216,.34); }
.tab.on {
  background: linear-gradient(180deg, rgba(102,200,188,.26), rgba(102,200,188,.13));
  color: var(--accent-d);
  border-color: rgba(166,224,216,.45);
  box-shadow: inset 0 0 0 1px rgba(166,224,216,.22), 0 1px 4px rgba(0,0,0,.25);
}

#content {
  margin: 10px 20px 18px;
  padding: 22px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(25,29,27,.98), rgba(18,22,20,.98));
  border-color: rgba(166,224,216,.14);
}
#content h2 { font-size: 22px; letter-spacing: 0; }
#content h3 { color: var(--accent-d); }
.intro { color: #c7cec7; line-height: 1.45; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.page-head .intro { margin-bottom: 0; }

.twocol.analysis-layout { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 20px; align-items: stretch; }
.panel {
  padding: 15px;
  background: rgba(255,255,255,.035);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 14px;
}
.fld input, .panel select {
  background: rgba(16,17,15,.70);
  border-color: rgba(174,184,176,.25);
}
.unit-row { gap: 12px; border-bottom-color: rgba(166,224,216,.14); }

.analysis-output { display: grid; grid-template-columns: repeat(2, minmax(320px, 1fr)); gap: 16px; align-items: stretch; min-width: 0; }
.analysis-output-bar { display: grid; grid-template-columns: 1fr; }
.analysis-top { display: grid; grid-template-columns: repeat(2, minmax(320px, 1fr)); gap: 16px; align-items: stretch; }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(300px, 1fr)); gap: 16px; align-items: stretch; }
.analysis-card { height: 100%; min-height: 292px; }
.analysis-output .charthost {
  min-width: 0;
  margin-top: 0;
  padding: 12px;
  background: rgba(255,255,255,.028);
  border: 1px solid rgba(255,255,255,.065);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
}
.analysis-output .chart { max-width: none; background: #111713; border-color: rgba(166,224,216,.13); flex: 1 1 auto; }
.analysis-output-bar > .legend {
  margin: 0;
  padding: 8px 12px;
  background: rgba(255,255,255,.026);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 12px;
}

.results {
  position: relative;
  overflow: hidden;
  max-width: none;
  padding: 16px;
  background: linear-gradient(180deg, rgba(102,200,188,.13), rgba(255,255,255,.035));
  border-color: rgba(166,224,216,.28);
}
.results::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--accent); }
.result-ok::before { background: var(--good); }
.result-warn::before { background: var(--warn); }
.result-bad::before { background: var(--danger); }
.result-ok .res.big .res-v { color: var(--good); }
.result-warn .res.big .res-v { color: var(--warn); }
.result-bad .res.big .res-v { color: var(--danger); }
.res { border-bottom-color: rgba(255,255,255,.08); }
.res-v { color: var(--ink); }

#content.view-site { padding: 18px; }
.site-summary { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.summary-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(210,161,95,.12);
  border: 1px solid rgba(210,161,95,.26);
  color: #efd1a4;
  font-size: 12px;
  font-weight: 700;
}
.site-shell { display: grid; gap: 14px; }
.site-controls-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(520px, 540px); gap: 14px; align-items: stretch; }
.site-analysis-settings { display: grid; grid-template-columns: 1fr; gap: 7px; padding: 10px; background: rgba(78,166,255,.07); border: 1px solid rgba(78,166,255,.22); border-radius: 14px; }
.site-analysis-title { color: var(--accent); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.site-testload-title { color: var(--ink); font-size: 11px; font-weight: 750; }
.site-testload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.site-analysis-settings .fld.inline { min-width: 0; }
.site-analysis-settings input[type=number] { width: 88px; }
.site-analysis-settings select { width: 100%; }
.site-soil-setting { padding-top: 7px; border-top: 1px dashed rgba(255,255,255,.12); }
.site-control-group { display: flex; flex-direction: column; gap: 3px; }
.site-zoom-actions, .site-grid-actions { display: flex; gap: 6px; align-items: flex-end; }
.site-settings {
  margin-bottom: 0;
  padding: 10px;
  background: rgba(255,255,255,.035);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 14px;
}
.map-wrap {
  display: grid;
  grid-template-columns: 108px minmax(440px, 1fr) minmax(520px, 540px);
  gap: 14px;
  align-items: start;
}
.toolpalette {
  display: grid;
  gap: 8px;
  flex: initial;
  position: sticky;
  top: 12px;
}
.toolbtn {
  min-height: 40px;
  border-radius: 11px;
  background: rgba(255,255,255,.045);
}
.toolbtn.on {
  background: linear-gradient(180deg, rgba(102,200,188,.95), rgba(65,180,168,.95));
  color: #07100f;
  border-color: rgba(166,224,216,.72);
  font-weight: 800;
}
.toolbtn.on svg * { stroke: currentColor; }
.zoombar { margin-top: 0; }
.map {
  width: 100%;
  max-width: none;
  border-radius: 16px;
  background: #111713;
  border-color: rgba(166,224,216,.16);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.03), 0 18px 45px rgba(0,0,0,.20);
}
.map-help {
  margin-top: 0;
  background: rgba(255,255,255,.035);
  border-color: rgba(255,255,255,.07);
}
.conntable-area.side {
  flex: initial;
  width: auto;
  max-height: calc(100vh - 270px);
  padding: 12px;
  background: rgba(255,255,255,.035);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 14px;
}
.conntab th { color: #c5cfc8; }
.crow:hover { background: rgba(102,200,188,.08); }
.crow.on { background: rgba(102,200,188,.14); }

.empty-state {
  min-height: 340px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 14px;
  padding: 30px;
  text-align: center;
  color: var(--muted);
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.018)),
    repeating-linear-gradient(90deg, rgba(166,224,216,.035) 0 1px, transparent 1px 34px);
  border: 1px dashed rgba(166,224,216,.25);
  border-radius: 18px;
}
.empty-state p { margin: 0; max-width: 46ch; line-height: 1.45; }
.rig-ghost {
  position: relative;
  width: min(440px, 86vw);
  height: 190px;
  transform: perspective(680px) rotateX(54deg) rotateZ(-13deg);
}
.rig-ghost::before {
  content: "";
  position: absolute;
  left: 12%;
  right: 10%;
  bottom: 18px;
  height: 18px;
  background: rgba(145,163,106,.22);
  border-radius: 999px;
  filter: blur(.2px);
}
.ghost-post, .ghost-bar, .ghost-ladder { position: absolute; display: block; border-radius: 999px; }
.ghost-post {
  bottom: 34px;
  width: 12px;
  height: 122px;
  background: linear-gradient(180deg, #d4ac73, #8a6035);
  box-shadow: 0 0 0 2px rgba(43,30,18,.38);
}
.ghost-post-a { left: 20%; }
.ghost-post-b { left: 76%; height: 132px; }
.ghost-post-c { left: 34%; bottom: 18px; height: 110px; opacity: .78; }
.ghost-post-d { left: 88%; bottom: 20px; height: 116px; opacity: .78; }
.ghost-bar {
  height: 10px;
  background: linear-gradient(90deg, #b8c8d1, #536d78);
  box-shadow: 0 2px 0 rgba(0,0,0,.22);
}
.ghost-bar-top { left: 20%; right: 12%; top: 42px; }
.ghost-bar-mid { left: 34%; right: 5%; top: 78px; opacity: .72; }
.ghost-ladder {
  right: 20%;
  top: 68px;
  width: 52px;
  height: 70px;
  border-left: 7px solid var(--steel);
  border-right: 7px solid var(--steel);
  background: repeating-linear-gradient(180deg, transparent 0 13px, rgba(131,183,217,.92) 13px 18px);
  opacity: .85;
}
.material-ghost {
  position: relative;
  width: min(420px, 86vw);
  height: 170px;
}
.mat-stack, .mat-bag, .mat-crate { position: absolute; display: block; }
.mat-stack {
  left: 16%;
  right: 18%;
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(90deg, #b7c6cf, #526b78);
  box-shadow: 0 12px 30px rgba(0,0,0,.22);
}
.mat-stack-a { top: 52px; transform: rotate(-3deg); }
.mat-stack-b { top: 82px; background: linear-gradient(90deg, #d5aa6a, #8e5d2f); transform: rotate(2deg); }
.mat-stack-c { top: 112px; left: 22%; right: 12%; transform: rotate(-1deg); }
.mat-bag {
  right: 22%;
  top: 32px;
  width: 58px;
  height: 78px;
  border-radius: 8px;
  background: linear-gradient(180deg, #b8b19e, #777061);
  transform: rotate(8deg);
}
.mat-crate {
  left: 16%;
  bottom: 28px;
  width: 58px;
  height: 40px;
  border-radius: 7px;
  background: linear-gradient(180deg, #b9975e, #755331);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.10);
}

@media (max-width: 1180px) {
  .analysis-output, .analysis-top, .chart-grid { grid-template-columns: 1fr; }
  .analysis-card { min-height: 0; }
  .map-wrap { grid-template-columns: 96px minmax(0, 1fr); }
  .site-controls-row { grid-template-columns: 1fr; }
  .conntable-area.side { grid-column: 1 / -1; max-height: none; }
}

@media (max-width: 720px) {
  #app { padding: 0 10px 8px; }
  #hd { margin: 8px 0 0; padding: 12px; display: grid; grid-template-columns: 1fr; gap: 10px; }
  .brand { min-width: 0; display: block; }
  .brand .sub { display: block; margin-top: 2px; }
  /* filbjælken har mange knapper: behold flex + wrap; navnefeltet fylder egen række */
  .filebar { width: 100%; }
  .name-inp { width: 100%; min-width: 0; flex: 1 1 100%; }
  .lang { justify-content: flex-start; width: 100%; }
  #tabbar { margin: 10px 0 0; overflow-x: auto; flex-wrap: nowrap; }
  .tab-group { flex: 0 0 auto; }
  .tab-group-labeled { margin-left: 4px; padding-left: 8px; }
  .tab-group-label { font-size: 10px; padding: 0 4px; }
  .tab { white-space: nowrap; flex: 0 0 auto; }
  #content { margin: 8px 0 12px; padding: 14px; border-radius: 16px; }
  .page-head { display: grid; gap: 10px; }
  .site-summary { justify-content: flex-start; }
  .twocol.analysis-layout, .twocol { grid-template-columns: 1fr; }
  .site-settings { display: grid; grid-template-columns: 1fr; align-items: stretch; gap: 10px; }
  .site-testload-grid { grid-template-columns: 1fr; }
  .fld.inline { justify-content: space-between; }
  .map-wrap { grid-template-columns: 1fr; }
  .toolpalette { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .zoombar { grid-column: span 2; }
  /* BEMÆRK: .map skal beholde aspect-ratio 520/440 (= SVG-viewBox), ellers
     letterboxer preserveAspectRatio og touch-koordinaterne rammer skævt. */
  .empty-state { min-height: 300px; padding: 22px; }
  .rig-ghost { width: min(300px, 70vw); height: 160px; transform: perspective(560px) rotateX(54deg) rotateZ(-10deg); }
  .material-ghost { width: min(300px, 70vw); }
}

/* ---- Footer ---- */
#ft { padding: 10px 20px 16px; color: #c08a82; font-size: 11px; line-height: 1.4; }

/* ---- Gem/Åbn-menu i filbjælken ---- */
.filebar { position: relative; }
.filebar-sep { width: 1px; align-self: stretch; margin: 2px 3px; background: rgba(255,255,255,.14); }
.save-menu { position: absolute; z-index: 50; min-width: 240px; max-height: 300px; overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.45); padding: 6px; }
.save-menu-empty { padding: 10px 12px; color: var(--muted); font-size: 12.5px; }
.save-menu-row { display: flex; align-items: stretch; gap: 4px; }
.save-menu-name { flex: 1; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; text-align: left; font: inherit; font-size: 13px; color: var(--ink); background: none; border: 0; border-radius: 7px; padding: 7px 9px; cursor: pointer; }
.save-menu-name:hover { background: rgba(255,255,255,.07); }
.save-menu-date { color: var(--muted); font-size: 11px; }
.save-menu-del { font: inherit; font-size: 15px; line-height: 1; color: var(--muted); background: none; border: 0; border-radius: 7px; padding: 0 9px; cursor: pointer; }
.save-menu-del:hover { color: #ff6b6b; background: rgba(225,29,29,.12); }
.startup-warning { margin: 10px 0 0; padding: 9px 12px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid var(--danger-line); border-left: 4px solid var(--danger); border-radius: 7px; background: var(--danger-soft); color: var(--ink); font-size: 12.5px; line-height: 1.4; }
.startup-warning button { flex: 0 0 28px; width: 28px; height: 28px; padding: 0; border: 0; background: transparent; color: var(--muted); font: 700 18px/1 system-ui, sans-serif; cursor: pointer; }
.startup-warning button:hover { color: var(--danger); }

/* ---- Print: byggevejledningen (#print-root) ---- */
#print-root { display: none; }
@media print {
  @page { size: A4 portrait; margin: 10mm; }
  body { background: #fff !important; }
  #app { display: none !important; }
  #print-root { display: block; color: #111; background: #fff; font: 12px/1.5 system-ui, sans-serif; padding: 0; }
  #print-root h1 { font-size: 22px; margin: 0 0 2px; }
  #print-root h2 { font-size: 15px; margin: 14px 0 6px; border-bottom: 1.5px solid #333; padding-bottom: 3px; break-after: avoid; }
  #print-root .pr-sub { color: #444; margin: 0 0 10px; }
  #print-root .pr-visuals { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 5mm; align-items: start; break-inside: avoid; }
  #print-root .pr-visual { min-width: 0; }
  #print-root .pr-visual h2 { margin-top: 0; }
  #print-root .pr-map svg, #print-root .pr-3d-img { display: block; width: 100%; height: auto; max-height: 78mm; object-fit: contain; object-position: top left; border: 1px solid #999; border-radius: 4px; box-sizing: border-box; }
  #print-root .pr-map svg { border: 0; }
  #print-root .pr-tab { width: 100%; border-collapse: collapse; break-inside: avoid; }
  #print-root .pr-tab th, #print-root .pr-tab td { border: 1px solid #999; padding: 4px 8px; text-align: left; font-size: 12px; }
  #print-root .pr-tab th { background: #eee; }
  #print-root .pr-q { text-align: right; white-space: nowrap; }
  #print-root .pr-cut-h { margin: 8px 0 2px; font-weight: 700; }
  #print-root .pr-cut-overview { margin: 0 0 7px; }
  #print-root .pr-cut-item { display: grid; grid-template-columns: 20px minmax(0, 1fr); column-gap: 5px; margin: 4px 0 6px; break-inside: avoid; }
  #print-root .pr-cut-no { grid-row: span 2; padding-top: 3px; color: #475569; font-weight: 700; }
  #print-root .pr-cut-bar { display: flex; height: 14px; overflow: hidden; border: 1px solid #64748b; border-radius: 2px; box-sizing: border-box; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  #print-root .pr-cut-seg { display: flex; flex: 0 0 auto; min-width: 0; align-items: center; justify-content: center; gap: 2px; overflow: hidden; color: #fff; font-size: 8px; line-height: 1; white-space: nowrap; border-right: .25px solid rgba(255,255,255,.8); }
  #print-root .pr-cut-seg b { font-size: 8px; }
  #print-root .pr-cut-kerf { flex: 0 0 auto; min-width: .45mm; background: #e2e8f0; border-right: .25px solid #94a3b8; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  #print-root .pr-cut-waste { display: flex; flex: 0 0 auto; align-items: center; justify-content: center; overflow: hidden; color: #475569; font-size: 8px; white-space: nowrap; background: repeating-linear-gradient(45deg, #f1f5f9, #f1f5f9 2px, #dbe3ec 2px, #dbe3ec 4px); print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  #print-root .pr-cut-list { grid-column: 2; margin-top: 1px; color: #555; font-size: 9px; line-height: 1.25; }
  #print-root .pr-steps li { margin: 3px 0; }
  #print-root .pr-note { color: #555; font-size: 11px; margin-top: 10px; }
  #print-root .pr-elevations { break-before: page; }
  #print-root .pr-elev-note { margin: 0 0 5mm; }
  #print-root .pr-elev-grid { display: block; }
  #print-root .pr-elev { width: 190mm; height: 250mm; break-inside: avoid; overflow: hidden; }
  #print-root .pr-elev + .pr-elev { break-before: page; }
  #print-root .pr-elev svg { display: block; width: 190mm; height: 250mm; max-height: none; }
  #print-root svg { max-height: 105mm; }
}
