:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e2e6ec;
  --text: #1a2230;
  --muted: #63708a;
  --primary: #1f6feb;
  --primary-dark: #1657c4;
  --good: #1f9d5b;
  --warn: #d98a1a;
  --bad: #d5432f;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(20, 30, 50, .06), 0 6px 20px rgba(20, 30, 50, .06);
  --maxw: 720px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* Header */
.app-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--primary); color: #fff; font-size: 18px;
}
.brand-text { font-size: 18px; font-weight: 500; }
.brand-text strong { font-weight: 800; }
.net-status { font-size: 12px; color: var(--muted); }
.net-status[data-src="api"]::before { content: "● "; color: var(--good); }
.net-status[data-src="cache"]::before,
.net-status[data-src="seed"]::before { content: "● "; color: var(--warn); }

/* Views */
#view { padding: 20px 16px 40px; }
.page-title { font-size: 22px; font-weight: 800; margin: 4px 0 2px; }
.page-sub { color: var(--muted); margin: 0 0 20px; }

/* Cards / calculator tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  transition: transform .08s ease, border-color .08s ease;
}
.tile:active { transform: scale(.99); }
.tile[aria-disabled="true"] { opacity: .5; }
.tile .tile-icon { font-size: 26px; }
.tile .tile-name { font-weight: 700; margin-top: 8px; }
.tile .tile-desc { font-size: 13px; color: var(--muted); margin-top: 2px; }
.tile .soon { font-size: 11px; color: var(--warn); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 28px 0 12px; }
.section-head h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0; }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 16px;
}
.card h3 { margin: 0 0 12px; font-size: 16px; }

/* Forms */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=number], select {
  width: 100%; padding: 11px 12px; font-size: 16px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--primary); border-color: var(--primary); }

.room-row { display: grid; grid-template-columns: 1fr 76px 76px 40px; gap: 8px; align-items: end; margin-bottom: 8px; }
.room-row .mini-label { font-size: 11px; color: var(--muted); }
.icon-btn {
  border: 1px solid var(--border); background: #fff; border-radius: 10px;
  height: 44px; font-size: 18px; cursor: pointer; color: var(--muted);
}
.icon-btn:active { background: var(--bg); }

.checks { display: grid; gap: 4px; }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.check input { width: 20px; height: 20px; }
.check label { font-size: 15px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 13px 16px; font-size: 16px; font-weight: 700;
  border: none; border-radius: 12px; background: var(--primary); color: #fff; cursor: pointer;
}
.btn:active { background: var(--primary-dark); }
.btn.secondary { background: #fff; color: var(--primary); border: 1px solid var(--border); }
.btn.ghost { background: transparent; color: var(--muted); font-weight: 600; }
.btn-row { display: flex; gap: 10px; }

/* Result */
.result-hero {
  background: linear-gradient(135deg, var(--primary), #3f86ff);
  color: #fff; border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.result-hero .label { font-size: 13px; opacity: .85; }
.result-hero .amount { font-size: 30px; font-weight: 800; margin-top: 2px; }
.result-hero .hint { font-size: 12px; opacity: .8; margin-top: 6px; }

.breakdown { list-style: none; margin: 0; padding: 0; }
.breakdown li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--border); }
.breakdown li:last-child { border-bottom: none; }
.breakdown .lbl { color: var(--text); }
.breakdown .lbl small { display: block; color: var(--muted); font-size: 12px; }
.breakdown .val { white-space: nowrap; font-variant-numeric: tabular-nums; }
.breakdown .cat-labor .lbl::before { content: "🔧 "; }
.breakdown .cat-material .lbl::before { content: "📦 "; }
.breakdown .cat-flat .lbl::before { content: "🚛 "; }

.subtotals { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 4px 0 16px; }
.subtotal { background: var(--bg); border-radius: 10px; padding: 10px; text-align: center; }
.subtotal .st-lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.subtotal .st-val { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; }

/* Offer check */
.verdict { border-radius: 12px; padding: 14px; margin-top: 12px; font-weight: 600; }
.verdict.guenstig { background: #e6f6ee; color: var(--good); }
.verdict.fair { background: #e6f6ee; color: var(--good); }
.verdict.hoch { background: #fdf3e2; color: var(--warn); }
.verdict.sehr_hoch { background: #fbe8e4; color: var(--bad); }

.project-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px; text-decoration: none; color: inherit;
}
.project-item .pi-meta { font-size: 12px; color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }

.info-note {
  font-size: 13px; color: var(--muted); background: var(--bg);
  border-radius: 10px; padding: 10px 12px; margin-top: 4px;
}
.back-link { display: inline-block; margin-bottom: 8px; color: var(--primary); text-decoration: none; font-weight: 600; }

.app-footer { padding: 20px 0 40px; }
.disclaimer { font-size: 12px; color: var(--muted); text-align: center; margin: 0; }

@media (max-width: 380px) {
  .subtotals { grid-template-columns: 1fr; }
  .room-row { grid-template-columns: 1fr 64px 64px 40px; }
}
