:root {
  --brand: #ed8022;
  --brand-dark: #d16a12;
  --ink: #2b2a32;
  --muted: #6f7380;
  --line: #e4e6ec;
  --bg: #f8f9fd;
  --card: #ffffff;
  --ok: #2f9e6b;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); }
body { font-size: 14px; line-height: 1.4; }
button, input, textarea, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.app { max-width: 1180px; margin: 0 auto; padding: 12px; }

/* Überschrift */
.hero { text-align: center; margin: 4px auto 14px; max-width: 760px; }
.eyebrow { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-dark); background: #fff1e3; padding: 3px 10px; border-radius: 99px; }
.hero h2 { margin: 8px 0 4px; font-size: clamp(22px, 3.2vw, 30px); line-height: 1.2; letter-spacing: -.015em; }
.hero p { margin: 0; color: var(--muted); font-size: 14.5px; }

/* Suche */
.search { position: relative; margin-bottom: 10px; }
.search-box { position: relative; background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 6px 12px 4px; transition: border-color .15s; }
.search-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(237,128,34,.12); }
.search-box label { display: block; font-size: 12px; color: var(--muted); }
.search-box input { width: 100%; border: 0; outline: 0; font-size: 15.5px; padding: 1px 0 3px; background: transparent; }
.search-hint { margin: 6px 4px 0; font-size: 12px; color: var(--muted); }
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30; margin: 0; padding: 5px; list-style: none; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 30px rgba(20,22,30,.12); }
.suggest li { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.suggest li:hover, .suggest li.active { background: #fff4ea; }
.suggest li small { color: var(--muted); margin-left: auto; }

/* Zustimmung */
.consent { position: fixed; inset: 0; z-index: 50; background: rgba(43,42,50,.45); display: grid; place-items: center; padding: 16px; }
.consent[hidden] { display: none; }
/* Eingebettet: iframe ist so hoch wie der Inhalt – Hinweis oben statt mittig zeigen */
.embedded .consent { position: absolute; place-items: start center; padding-top: 120px; }
.embedded body { background: transparent; }
.consent-card { background: var(--card); border-radius: 16px; padding: 22px; max-width: 500px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.consent-card h2 { margin: 0 0 8px; font-size: 20px; }
.consent-card p { color: #4a4d57; margin: 0 0 16px; }
.consent-card .small { display: inline-block; margin-left: 12px; color: var(--muted); }

/* Raster */
.layout { display: grid; grid-template-columns: 290px 1fr; grid-template-areas: "panel viewer" "results results"; gap: 10px; }
.panel { grid-area: panel; display: flex; flex-direction: column; gap: 8px; align-self: start; }
.viewer { grid-area: viewer; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; min-height: clamp(400px, 66vh, 520px); align-self: stretch; }
.results { grid-area: results; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.card h3 { margin: 0 0 6px; font-size: 14.5px; display: flex; align-items: baseline; gap: 8px; }
.card h3 .sub { font-weight: 500; font-size: 12px; color: var(--muted); }
.card p { margin: 0; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 0; }
.row + .row { border-top: 1px dashed var(--line); }
.row > label { font-size: 13.5px; display: flex; align-items: center; gap: 7px; }
.unit { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; flex: none; }
.unit input { width: 74px; border: 0; padding: 4px 7px; text-align: right; outline: 0; background: transparent; }
.unit select { width: 74px; border: 0; padding: 4px 7px; text-align: right; outline: 0; background: transparent; }
.unit span { padding: 4px 7px; background: #f3f4f8; color: var(--muted); font-size: 12px; white-space: nowrap; }
.unit:focus-within { border-color: var(--brand); }
.toggle-row .unit.off { opacity: .4; pointer-events: none; }
input[type=checkbox] { accent-color: var(--brand); width: 16px; height: 16px; }
.info { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: #eceef3; color: var(--muted); font-size: 11px; cursor: help; }

.seg { display: inline-flex; background: #f0f1f5; border-radius: 9px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 3px 8px; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }
.seg.small button { padding: 3px 9px; font-size: 12.5px; }

/* Dachflächen */
.face { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.face:first-child { border-top: 0; }
.face b { display: block; font-size: 13.5px; }
.face small { color: var(--muted); font-size: 12px; }
.switch { position: relative; width: 36px; height: 21px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: #d5d8df; transition: .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 15px; height: 15px; border-radius: 50%; background: #fff; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(15px); }
.face-actions { display: flex; align-items: center; gap: 8px; }
.reset { border: 0; background: none; color: var(--brand-dark); font-size: 12px; cursor: pointer; padding: 0; }
.more-faces { display: block; width: 100%; margin-top: 2px; padding: 6px 0 2px; border: 0; border-top: 1px solid var(--line); background: none; color: var(--brand-dark); font-size: 12.5px; text-align: left; cursor: pointer; }

/* Viewer */
.viewer-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.where { display: flex; gap: 8px; align-items: center; min-width: 0; }
.where b { font-size: 13.5px; }
.where .pin { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: #fff4ea; color: var(--brand); font-size: 15px; flex: none; }
.where small { display: block; color: var(--muted); font-size: 12px; }
.view-tools { display: flex; gap: 5px; align-items: center; }
.icon { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 16px; }
.canvas-wrap { position: relative; flex: 1; min-height: 320px; background: #e9edf3; }
.canvas-wrap canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; touch-action: none; }
.compass, .hint-overlay, .loading, .zoom-hint { z-index: 2; }
.zoom-hint { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 16px; background: rgba(43,42,50,.45); color: #fff; font-size: 14px; pointer-events: none; }
.hint-overlay { pointer-events: none; }
.placeholder { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted); }
.ph-icon { font-size: 38px; color: var(--brand); }
.compass { position: absolute; right: 10px; top: 10px; width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.9); box-shadow: 0 2px 6px rgba(0,0,0,.15); display: grid; place-items: center; }
.compass span { font-weight: 700; font-size: 12px; color: #c0392b; display: block; transform-origin: center; }
.compass span::before { content: "▲"; display: block; font-size: 8px; line-height: 1; text-align: center; }
.hint-overlay { position: absolute; left: 10px; bottom: 10px; background: rgba(43,42,50,.82); color: #fff; padding: 5px 9px; border-radius: 8px; font-size: 12px; max-width: calc(100% - 20px); }
.loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; background: rgba(233,237,243,.75); color: var(--muted); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid #d6dae2; border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.attrib { font-size: 10.5px; color: var(--muted); padding: 5px 10px; border-top: 1px solid var(--line); }

/* Ergebnisse */
.kpis { display: grid; grid-template-columns: 1.3fr repeat(4, 1fr); gap: 8px; }
.kpi { background: #f7f8fb; border-radius: 10px; padding: 9px 11px; display: flex; flex-direction: column; gap: 1px; }
.kpi small { color: var(--muted); font-size: 12px; }
.kpi b { font-size: 18.5px; letter-spacing: -.01em; }
.kpi.main { background: linear-gradient(135deg, #fff1e3, #fff9f3); border: 1px solid #f7d3b0; }
.kpi.main b { font-size: 25px; color: var(--brand-dark); }
.details { margin-top: 8px; }
.details summary { cursor: pointer; color: var(--brand-dark); font-weight: 600; padding: 3px 0; font-size: 13.5px; }
.chart { margin: 8px 0; }
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; margin: 6px 0 10px; }
.tbl td { padding: 5px 4px; border-bottom: 1px solid var(--line); }
.tbl td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.cta { margin-top: 10px; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 14px; background: var(--ink); color: #fff; border-radius: 10px; flex-wrap: wrap; }
.cta b { display: block; font-size: 15px; }
.cta .muted { color: #c9cad2; font-size: 13px; }

.btn { border: 1px solid var(--line); background: #fff; padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Dialog */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(500px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(43,42,50,.5); }
dialog form { padding: 20px; display: flex; flex-direction: column; gap: 9px; }
dialog h2 { margin: 0; font-size: 20px; }
dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #4a4d57; }
dialog input:not([type=checkbox]), dialog textarea { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; outline: 0; }
dialog input:focus, dialog textarea:focus { border-color: var(--brand); }
dialog label.check { flex-direction: row; align-items: flex-start; gap: 8px; font-size: 12px; }
dialog a { color: var(--brand-dark); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; grid-template-areas: "viewer" "panel" "results"; }
  .viewer { min-height: 0; }
  .canvas-wrap { min-height: 320px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi.main { grid-column: 1 / -1; }
}
@media (max-width: 480px) {
  .app { padding: 10px; }
  .grid2 { grid-template-columns: 1fr; }
  .search-box input { font-size: 16px; } /* verhindert automatisches Zoomen auf dem iPhone */
  .hero h2 { font-size: 22px; }
  .hero p { font-size: 13.5px; }
  .canvas-wrap { min-height: 290px; }
}
