/* Haus-Alarm – Granit, Enzianblau, Giebel. */
@font-face {
  font-family: "Schibsted Grotesk";
  src: url("/static/fonts/schibsted-grotesk-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 900; font-display: swap;
}

:root {
  --bg: #E9ECE6;        /* Granit */
  --surface: #FBFCFA;
  --surface-2: #F2F4EF;
  --ink: #1E2A24;       /* Tannen-Tinte */
  --muted: #56625B;
  --line: #CDD3CA;
  --line-soft: #E1E5DE;
  --accent: #2A4A9B;    /* Enzian */
  --accent-ink: #FFFFFF;
  --accent-soft: #DCE3F4;
  --warn: #8A5A0F;
  --warn-soft: #F3E6CC;
  --good: #2E6B3F;
  --good-soft: #DCEBDD;
  --bad: #9B2C2C;
  --bad-soft: #F4DCDA;
  --c1: #2A4A9B; --c2: #B8741A; --c3: #1F8A70;   /* Portale im Preisverlauf (validiert) */
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131915; --surface: #1B221E; --surface-2: #222A25; --ink: #E3E8E2; --muted: #9AA59D;
    --line: #34403A; --line-soft: #2A332E; --accent: #8EA6EE; --accent-ink: #10172B; --accent-soft: #24304F;
    --warn: #E0B163; --warn-soft: #3A2F1B; --good: #7CC08E; --good-soft: #1F3326; --bad: #E38D8D; --bad-soft: #3D2222;
    --c1: #7F98E6; --c2: #C98F3A; --c3: #4DB394;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 15px/1.5 "Schibsted Grotesk", system-ui, sans-serif;
}
a { color: var(--accent); text-underline-offset: 2px; }
h1, h2 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(24px, 3.2vw, 32px); font-weight: 750; }
h2 { font-size: 17px; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.warntext { color: var(--warn); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Kopf */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px max(16px, calc((100vw - 1120px) / 2)); background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.mark { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 18px; }
.mark-roof { fill: var(--accent); }
.mark-door { fill: none; stroke: var(--surface); stroke-width: 2; }
.top nav { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.top nav a { color: var(--muted); text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
.top nav a[aria-current="page"] { color: var(--ink); border-color: var(--accent); }
form.inline { display: inline; }
.linklike { background: none; border: 0; color: var(--muted); font: inherit; padding: 0; cursor: pointer; }
.linklike:hover { color: var(--ink); }

main { max-width: 1120px; margin: 0 auto; padding: 24px 16px 64px; }
.lead { margin: 8px 0 18px; }
.lead p { margin-top: 6px; }

/* ---------- Formulare */
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; min-height: 40px; width: 100%;
}
textarea { resize: vertical; min-height: 80px; }
input.short { width: 9ch; }
.suffix { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); }
.suffix input { width: 12ch; }
.suffix input.short { width: 9ch; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
label.check input { width: 18px; min-height: 18px; accent-color: var(--accent); }
button, .button {
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; min-height: 40px; border-radius: 8px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
}
button:hover, .button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover { filter: brightness(1.08); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.actions { display: flex; align-items: center; gap: 16px; }
.alert { padding: 10px 14px; border-radius: 8px; margin: 0 0 16px; font-size: 14px; }
.alert.good { background: var(--good-soft); color: var(--good); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Anmeldung */
main.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 32px 28px; }
.login-box h1 { margin: 12px 0 4px; }
.login-box p { margin-bottom: 18px; }
.login-mark .mark-door { stroke: var(--surface); }
input.code { font-size: 26px; letter-spacing: 0.3em; text-align: center; font-weight: 700; }

/* ---------- Filter */
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
.filters summary { padding: 12px 16px; cursor: pointer; font-weight: 600; font-size: 14px; list-style-position: inside; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px 16px; padding: 4px 16px 16px; }
.filter-grid .wide { grid-column: span 2; }
.filter-grid .checks { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px 22px; border: 0; padding: 0; margin: 0; }
.filter-grid .actions { grid-column: 1 / -1; }
.pill {
  display: inline-block; font-size: 12px; font-weight: 600; line-height: 1; padding: 5px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line-soft); vertical-align: middle;
}
.pill.new { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 6px 2px 10px; }
.exports { font-size: 13px; color: var(--muted); display: inline-flex; gap: 12px; align-items: center; }
.exports a { font-weight: 600; }

/* ---------- Giebel-Wertung: das Markenzeichen */
.gables { display: inline-flex; gap: 3px; vertical-align: -2px; }
.gables path.on { fill: var(--accent); }
.gables path.off { fill: none; stroke: var(--line); stroke-width: 1.4; }
.pts { font-size: 12px; color: var(--muted); margin-left: 4px; }

/* ---------- Hausliste */
.houses { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.house {
  display: grid; grid-template-columns: 200px 1fr 220px; gap: 18px; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
}
.house.top { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.house-photo { display: block; }
.photo { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 7px; background: var(--surface-2); }
.photo.placeholder { display: grid; place-items: center; }
.photo.placeholder svg { width: 52%; fill: none; stroke: var(--line); stroke-width: 2.2; stroke-linejoin: round; }
.house-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; min-height: 22px; }
.house h2 { font-size: 18px; margin: 6px 0 2px; }
.house h2 a { color: var(--ink); text-decoration: none; }
.house h2 a:hover { text-decoration: underline; }
.place { color: var(--muted); font-size: 13px; }
.reason { color: var(--warn); font-size: 13px; margin-top: 6px; }
.facts { display: grid; grid-template-columns: repeat(4, auto); justify-content: start; gap: 4px 22px; margin: 12px 0 0; }
.facts div { display: flex; flex-direction: column; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; font-size: 14px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tags:empty { display: none; }
.tags span { font-size: 12px; padding: 3px 8px; border-radius: 6px; background: var(--good-soft); color: var(--good); font-weight: 600; }
.warnline { font-size: 13px; color: var(--warn); margin-top: 6px; padding-left: 14px; position: relative; }
.warnline::before { content: ""; position: absolute; left: 0; top: 0.55em; width: 7px; height: 7px; background: var(--warn); transform: rotate(45deg); }
.house-money { text-align: right; display: flex; flex-direction: column; gap: 2px; }
.price { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.reno { font-size: 13px; color: var(--muted); }
.total { font-size: 14px; font-weight: 600; }
.total.over, .big.over { color: var(--warn); }
.portals { display: flex; flex-wrap: wrap; gap: 6px 12px; justify-content: flex-end; margin-top: 10px; font-size: 13px; font-weight: 600; }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 40px 24px; text-align: center; }
.empty h2 { margin-bottom: 8px; }

/* ---------- Detail */
.back { margin-bottom: 12px; font-size: 14px; }
.back a::before { content: "‹ "; }
.detail-head { display: grid; grid-template-columns: minmax(260px, 420px) 1fr; gap: 24px; margin-bottom: 18px; }
.detail-head h1 { margin: 8px 0 4px; }
.summary { margin-top: 10px; max-width: 62ch; }
.verdict { margin-top: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; gap: 6px; max-width: 62ch; }
.verdict .label { font-size: 12px; color: var(--muted); margin-right: 6px; }
.money-row { display: grid; grid-template-columns: repeat(3, auto); justify-content: start; gap: 8px 28px; margin: 16px 0 6px; }
.money-row .label { display: block; font-size: 12px; color: var(--muted); }
.big { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.detail-head .portals { justify-content: flex-start; margin-top: 14px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.panel.wide { grid-column: 1 / -1; }
.score { width: 100%; border-collapse: collapse; font-size: 14px; }
.score th { text-align: left; font-weight: 600; padding: 8px 12px 8px 0; vertical-align: top; width: 34%; }
.score td { padding: 8px 0; vertical-align: top; border-top: 1px solid var(--line-soft); }
.score th { border-top: 1px solid var(--line-soft); }
.score tr:first-child th, .score tr:first-child td { border-top: 0; }
.bar-cell { display: flex; flex-direction: column; gap: 4px; padding-right: 12px !important; }
.bar { width: 100%; height: 8px; display: block; }
.bar-bg { fill: var(--line-soft); }
.bar-fg { fill: var(--accent); }
.num { text-align: right; white-space: nowrap; font-weight: 600; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.votes { display: flex; gap: 8px; flex-wrap: wrap; }

.chart { width: 100%; height: auto; max-height: 260px; }
.chart .grid { stroke: var(--line-soft); stroke-width: 1; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .direct { fill: var(--ink); font-size: 12px; font-weight: 600; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .line.s1 { stroke: var(--c1); } .chart .dot.s1 { fill: var(--c1); }
.chart .line.s2 { stroke: var(--c2); } .chart .dot.s2 { fill: var(--c2); }
.chart .line.s3 { stroke: var(--c3); } .chart .dot.s3 { fill: var(--c3); }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.sw.s1 { background: var(--c1); } .sw.s2 { background: var(--c2); } .sw.s3 { background: var(--c3); }
.history { width: 100%; border-collapse: collapse; font-size: 13px; }
.history th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); }
.history td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line-soft); }

/* ---------- Einstellungen */
.settings { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
main > .panel { margin-bottom: 14px; }
.actions.sticky { padding: 4px 0; }
.jobbuttons { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Schmal */
@media (max-width: 860px) {
  .house { grid-template-columns: 120px 1fr; }
  .house-money { grid-column: 1 / -1; text-align: left; flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; border-top: 1px solid var(--line-soft); padding-top: 10px; }
  .house-money .portals { justify-content: flex-start; margin: 0; width: 100%; }
  .facts { grid-template-columns: repeat(2, auto); }
  .detail-head, .detail-grid { grid-template-columns: 1fr; }
  .money-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .top { padding: 10px 16px; }
  .top nav { gap: 12px; font-size: 13px; }
  .mark span { display: none; }
  .house { grid-template-columns: 96px 1fr; gap: 12px; }
  .house h2 { font-size: 16px; }
  .facts { gap: 4px 16px; }
  .filter-grid .wide { grid-column: auto; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
@media (forced-colors: active) { .gables path.on { fill: CanvasText; } }
