/* Stammdaten-Check Design v2 – Marineblau-Palette + Inter */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

* { box-sizing: border-box; }

:root {
  --c-primary: #1a2d5b;       /* Marineblau (Brand) */
  --c-primary-dark: #0f1d3e;
  --c-primary-light: #2a4583;
  --c-accent: #00bcd4;        /* Cyan (Signal) */
  --c-accent-dark: #0097a7;
  --c-alert: #d81b60;         /* Magenta (Eingabefehler) */
  --c-bg: #f5f7fa;
  --c-bg-card: #ffffff;
  --c-text: #1a2d5b;
  --c-text-muted: #5a6478;
  --c-border: #d0d7de;
  --c-divider: #e1e5e9;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Header mit Logo + Markenname */
header {
  background: var(--c-primary);
  color: #fff;
  padding: 20px 28px;
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
}
header .brand {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 1200px;
  margin: 0 auto;
}
header .brand img { height: 56px; width: 56px; background: #ffffff; padding: 5px; border-radius: 12px; object-fit: contain; }
header .brand .name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
header .brand .name span { color: var(--c-accent); }
header .lead {
  margin: 6px 0 0;
  font-size: 14px;
  opacity: .85;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}
header .meta {
  margin: 6px 0 0;
  font-size: 12px;
  opacity: .65;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}
header a { color: var(--c-accent); text-decoration: none; }
header a:hover { text-decoration: underline; }

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px;
}

.card {
  background: var(--c-bg-card);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid var(--c-divider);
}
.card h2 {
  margin: 0 0 14px;
  font-size: 20px;
  font-weight: 700;
  color: var(--c-primary);
  letter-spacing: -0.3px;
}
.card p { margin: 0 0 12px; color: var(--c-text-muted); }
.row { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.row input { flex: 1 1 200px; min-width: 200px; }

input, textarea, select {
  font-family: inherit;
  font-size: 14px;
  padding: 11px 14px;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  width: 100%;
  color: var(--c-text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(0,188,212,.15);
}
textarea {
  font-family: ui-monospace, "SF Mono", "Consolas", monospace;
  font-size: 13px;
}

button {
  background: var(--c-primary);
  color: #fff;
  border: 0;
  padding: 11px 22px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
button:hover { background: var(--c-primary-light); }
button:active { transform: translateY(1px); }
button:disabled { background: #94a3b8; cursor: wait; }

.result-box {
  margin-top: 16px;
  padding: 18px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--c-divider);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.score-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
}
.score-0 { background: #d1fae5; color: #065f46; }
.score-low { background: #fef3c7; color: #92400e; }
.score-mid { background: #fed7aa; color: #9a3412; }
.score-high { background: #fee2e2; color: #991b1b; }

.finding {
  padding: 12px 14px;
  margin: 10px 0;
  border-left: 4px solid #94a3b8;
  background: #fafbfc;
  border-radius: 6px;
  font-size: 14px;
  overflow-wrap: anywhere;
}
.finding.kritisch { border-left-color: #dc2626; background: #fef2f2; }
.finding.warn { border-left-color: #f59e0b; background: #fffbeb; }
.finding.info { border-left-color: var(--c-accent); background: #ecfeff; }
.finding.eingabefehler { border-left-color: var(--c-alert); background: #fdf2f8; }

.finding .rule {
  font-family: ui-monospace, monospace;
  font-weight: 700;
  font-size: 11px;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.finding.eingabefehler .rule { color: var(--c-alert); }
.finding .msg { margin-top: 4px; font-weight: 500; color: var(--c-text); }
.finding .detail { margin-top: 6px; font-size: 12px; color: var(--c-text-muted); line-height: 1.6; }
.finding .detail b { color: var(--c-text); font-weight: 600; }

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 14px;
}
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--c-divider);
}
th {
  background: #f0f4f8;
  font-weight: 600;
  color: var(--c-primary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
tr:hover td { background: #fafbfc; cursor: pointer; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.metric {
  background: #f0f4f8;
  padding: 14px;
  border-radius: 8px;
  text-align: center;
}
.metric .v {
  font-size: 26px;
  font-weight: 700;
  color: var(--c-primary);
  line-height: 1.2;
}
.metric .l {
  font-size: 11px;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

footer {
  text-align: center;
  padding: 28px 16px;
  font-size: 13px;
  color: var(--c-text-muted);
  background: #fafbfc;
  border-top: 1px solid var(--c-divider);
  margin-top: 40px;
}
footer p { margin: 4px 0; }
footer .meta { font-size: 11px; opacity: .75; }
footer a { color: var(--c-primary); text-decoration: none; margin: 0 4px; font-weight: 500; }
footer a:hover { text-decoration: underline; }

small { font-size: 13px; opacity: .7; font-weight: normal; }
.error { color: #991b1b; padding: 12px; background: #fef2f2; border-radius: 8px; margin-top: 12px; border-left: 3px solid #dc2626; }
.success { color: #065f46; padding: 12px; background: #d1fae5; border-radius: 8px; margin-top: 12px; border-left: 3px solid #10b981; }
.pending { color: #92400e; padding: 12px; background: #fef3c7; border-radius: 8px; margin-top: 12px; border-left: 3px solid #f59e0b; }

/* Audit-Tabelle: klickbare Zeilen mit Akkordeon */
.audit-row { transition: background .1s; }
.audit-row:hover td { background: #eff4fa; }
.expand-chevron {
  display: inline-block;
  margin-left: 6px;
  color: #94a3b8;
  font-size: 11px;
  transition: transform .15s;
}
.audit-row:hover .expand-chevron { color: var(--c-primary); }
.audit-detail-row td { background: #f5f7fa !important; border-top: 0; }

/* Mobile-First Card-Layout für Tabellen unter 700px */
@media (max-width: 700px) {
  header { padding: 16px 18px; }
  header .brand img { height: 44px; width: 44px; padding: 4px; border-radius: 10px; }
  header .brand .name { font-size: 18px; }
  header .lead { font-size: 13px; }
  main { padding: 16px 14px; }
  .card { padding: 16px 14px; margin-bottom: 16px; }
  .card h2 { font-size: 17px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .metric { padding: 10px; }
  .metric .v { font-size: 20px; }
  .metric .l { font-size: 10px; }

  table thead { display: none; }
  table { border: 0; box-shadow: none; }
  table tr {
    display: block;
    margin-bottom: 12px;
    border: 1px solid var(--c-divider);
    border-radius: 8px;
    padding: 12px 14px;
    background: #fff;
  }
  table tr:hover td { background: transparent; }
  table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 0;
    padding: 5px 0;
    gap: 12px;
    font-size: 13px;
    line-height: 1.4;
  }
  table td:not([data-label=""]):before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--c-text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex: 0 0 110px;
  }
  table td > *:last-child { text-align: right; }
  table tr td:first-child {
    border-bottom: 1px solid var(--c-divider);
    padding-bottom: 8px;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--c-primary);
  }
  table tr td:first-child:before { display: none; }
  table tr td:first-child { justify-content: flex-start; }

  .finding { padding: 10px 12px; font-size: 13px; }
  .finding .detail { font-size: 11px; }

  .audit-detail-row { display: none; }
  .audit-detail-row td { padding: 0 !important; }
  .audit-detail-row td > div { padding: 10px 12px !important; }
  .audit-detail-row td:before { display: none !important; }
}


/* Rechtlicher Kontext bei Findings */
.regulation { margin-top: 8px; padding: 8px 10px; background: #ecfeff; border-left: 3px solid var(--c-accent); border-radius: 4px; font-size: 12px; line-height: 1.5; color: var(--c-text); }
.regulation a { color: var(--c-accent-dark); text-decoration: underline; font-weight: 500; }
.regulation em { color: var(--c-alert); font-style: normal; font-weight: 500; }

/* Historische Anlage (Endgültig stillgelegt) */
.historic-banner { margin: 0 0 14px; padding: 10px 12px; background: #f1f3f7; border-left: 4px solid #8a93a3; border-radius: 4px; font-size: 13px; line-height: 1.5; color: #4a5161; }
.historic-banner b { color: #1a2d5b; }
.result-box.historic .finding { opacity: 0.65; }
.result-box.historic .finding .rule { color: #5a6173 !important; }
.result-box.historic .score-badge { filter: grayscale(0.4); }

/* Regel-Übersicht (Dropdown unter Befunden) */
.rule-overview { margin-top: 14px; padding: 8px 12px; border: 1px solid #e0e4ec; border-radius: 6px; background: #fafbfd; }
.rule-overview summary { cursor: pointer; padding: 4px 0; user-select: none; }
.rule-overview ul { list-style: none; padding: 8px 0 0 0; margin: 0; }
.rule-row { display: grid; grid-template-columns: 28px 80px 1fr; gap: 8px; padding: 4px 0; font-size: 13px; align-items: baseline; }
.rule-row .ico { font-size: 14px; }
.rule-row b { color: #1a2d5b; font-weight: 600; }
.rule-row .t { color: #555; }
.rule-row.hit { background: #fff8e6; padding: 4px 6px; border-radius: 4px; }
.rule-row.hit .t { color: #1a2d5b; font-weight: 500; }

/* Payment-Banner nach Audit */
.pmt-banner { margin-top: 16px; padding: 16px; background: linear-gradient(135deg, #f0f6ff 0%, #e6ecf7 100%); border-left: 4px solid #00bcd4; border-radius: 6px; }
.pmt-buy-btn { padding: 10px 18px; background: #ffc439; color: #1a2d5b; border: 0; border-radius: 6px; font-weight: 700; cursor: pointer; font-size: 14px; }
.pmt-buy-btn:hover:not(:disabled) { background: #f0b62c; }
.pmt-buy-btn:disabled { background: #d4d4d4; cursor: wait; }
.pmt-msg { margin-top: 8px; font-size: 13px; }

/* Single-Check Paywall-Banner */
.paywall-banner { margin-top: 14px; padding: 18px; background: linear-gradient(135deg, #fff8e6 0%, #f0f6ff 100%); border-left: 5px solid #ffc439; border-radius: 8px; }
.pw-buy-btn { margin-top: 14px; padding: 12px 22px; background: #ffc439; color: #1a2d5b; border: 0; border-radius: 6px; font-weight: 700; cursor: pointer; font-size: 14px; box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
.pw-buy-btn:hover:not(:disabled) { background: #f0b62c; }
.pw-buy-btn:disabled { background: #d4d4d4; cursor: wait; }
.pw-msg { margin-top: 10px; font-size: 13px; color: #555; }

/* Status-Badge für Betriebs-Status */
.status-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; vertical-align: middle; margin-left: 6px; }
.status-badge.status-active { background: #e6f5e9; color: #1a5d28; }
.status-badge.status-plan { background: #fff4d6; color: #7a5a00; }
.status-badge.status-genehm { background: #ffe4cc; color: #8b3a00; }
.status-badge.status-stilllegt-final { background: #e7eaf0; color: #4a5161; }
.status-badge.status-stilllegt-temp { background: #d6ecff; color: #003a6b; }
.status-badge.status-other { background: #f3f5f9; color: #1a2d5b; }

/* Statistik: Tech-Karten Hover-Farben */
.metric.tech-pv { border-top: 4px solid #ffc439; }
.metric.tech-wind { border-top: 4px solid #00bcd4; }
.metric.tech-sp { border-top: 4px solid #a21caf; }
.metric.tech-all { border-top: 4px solid #1a2d5b; }

/* Statistik: Gruppen-Header in Regel-Tabelle */
.stats-group td { background: #1a2d5b; color: #fff; font-weight: 600; font-size: 12px; padding: 8px 10px; letter-spacing: 0.3px; text-transform: uppercase; }
.stats-group.stats-pv td { background: #b58900; }
.stats-group.stats-wind td { background: #0097a7; }
.stats-group.stats-sp td { background: #6b21a8; }
.stats-group.stats-all td { background: #1a2d5b; }
.stats-group.stats-eingabe td { background: #d81b60; }

/* Score-Badge in neuer Skala: 100=ok, 0=kritisch */
.score-badge.score-ok { background: #e6f5e9; color: #1a5d28; }
.score-badge.score-mid { background: #fff4d6; color: #7a5a00; }
.score-badge.score-low { background: #ffe4cc; color: #8b3a00; }
.score-badge.score-crit { background: #fdecf2; color: #a01545; }

/* Regel-Übersicht: Tech-Gruppierung */
.rules-cat.tech-cat { font-size: 18px; margin-top: 32px; padding-bottom: 8px; }
.rules-cat.tech-cat-solar { border-color: #ffc439; color: #7a5a00; }
.rules-cat.tech-cat-wind { border-color: #00bcd4; color: #003a6b; }
.rules-cat.tech-cat-speicher { border-color: #a21caf; color: #3a1d7a; }
.rules-cat.tech-cat-biomasse { border-color: #33691e; color: #33691e; }
.rules-cat.tech-cat-wasser { border-color: #0d47a1; color: #0d47a1; }
.rules-cat.tech-cat-geothermie { border-color: #bf360c; color: #bf360c; }
.rules-cat.tech-cat-verbrennung { border-color: #4a148c; color: #4a148c; }
.rules-cat.tech-cat-gas { border-color: #263238; color: #263238; }
.rules-cat.tech-cat-kernkraft { border-color: #b71c1c; color: #b71c1c; }
.rules-cat.tech-cat-all { border-color: #1a2d5b; color: #1a2d5b; }

/* Aktion-Buttons im Single-Check-Result */
.actions-row { padding-top: 12px; border-top: 1px solid #e7eaf0; margin-top: 14px; }
.ks-save-btn { padding: 8px 16px; background: #1a2d5b; color: #fff; border: 0; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 500; }
.ks-save-btn:hover:not(:disabled) { background: #0f1e44; }
.ks-save-btn:disabled { cursor: wait; opacity: 0.8; }
