/* SchutzWerk – Stylesheet. Systemschriften (kein externes Font-Hosting). */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #F5F4F8;
  --surface: #FFFFFF;
  --surface-2: #FBFAFD;
  --border: #E3E0EC;
  --border-strong: #CFC9DE;
  --ink: #201C2E;
  --ink-soft: #55506A;
  --muted: #837D99;

  --accent: #7B3FE4;
  --accent-ink: #FFFFFF;
  --accent-soft: #F1EBFD;

  --good: #178F55;
  --good-soft: #E4F5EC;
  --warning: #B5790E;
  --warning-soft: #FBF0DA;
  --critical: #D1352B;
  --critical-soft: #FCE7E5;
  --info: #2864C7;
  --info-soft: #E8EFFC;
  --neutral: #6A6480;
  --neutral-soft: #ECEAF3;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 2px rgba(32, 28, 46, 0.06), 0 1px 1px rgba(32, 28, 46, 0.04);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-weight: 650; letter-spacing: -0.01em; margin: 0 0 6px; color: var(--ink); }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.05rem; margin-bottom: 12px; }
p { margin: 0 0 10px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }

/* ---------- Layout ---------- */
.shell {
  display: grid;
  grid-template-columns: 258px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 20px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; flex: none;
}
.brand-name { font-weight: 700; font-size: 1rem; }
.brand-sub { font-size: 0.72rem; color: var(--muted); text-transform: capitalize; }
.nav-group-label {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); padding: 14px 10px 6px;
}
.nav-item {
  display: block; padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--ink-soft); font-size: 0.9rem; font-weight: 500;
}
.nav-item:hover { background: var(--surface-2); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.who { display: flex; flex-direction: column; padding: 4px 10px 10px; }
.who span { font-size: 0.78rem; color: var(--muted); }

.main { padding: 28px 34px 60px; min-width: 0; }
.view { max-width: 1080px; }
.crumb { font-size: 0.78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 2px; }
.view-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.view-scroll { overflow-x: auto; }

.center-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}

/* ---------- Surfaces ---------- */
.card-surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.panel-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 900px) { .panel-row { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
thead th { color: var(--muted); font-weight: 600; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.03em; background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
table.nested-table { margin-top: 10px; font-size: 0.85rem; }
table.nested-table thead th { background: transparent; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--ink); font-size: 0.88rem; font-weight: 600; cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #6A2FD1; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 11px; font-size: 0.8rem; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
.form-card { max-width: 900px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.span-2 { grid-column: span 2; }
@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: span 1; }
}
label { font-size: 0.8rem; font-weight: 600; color: var(--ink-soft); }
input, select, textarea {
  font-family: inherit; font-size: 0.9rem; color: var(--ink);
  padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; font-family: inherit; }
.error-text { color: var(--critical); font-size: 0.85rem; margin: 0 0 10px; }

/* ---------- Login ---------- */
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-card); padding: 32px 30px; width: 100%; max-width: 380px;
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.login-brand .brand-name { font-size: 1.2rem; font-weight: 700; }
.login-sub { color: var(--muted); font-size: 0.85rem; margin-bottom: 18px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Flash ---------- */
.flash {
  padding: 11px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 0.88rem; font-weight: 500;
}
.flash-good { background: var(--good-soft); color: var(--good); }
.flash-critical { background: var(--critical-soft); color: var(--critical); }
.flash-info, .flash-warning { background: var(--warning-soft); color: var(--warning); }

/* ---------- Pills / Badges ---------- */
.pill {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  font-size: 0.74rem; font-weight: 650; white-space: nowrap;
}
.pill-good { background: var(--good-soft); color: var(--good); }
.pill-warning { background: var(--warning-soft); color: var(--warning); }
.pill-critical { background: var(--critical-soft); color: var(--critical); }
.pill-neutral { background: var(--neutral-soft); color: var(--neutral); }

/* ---------- Filter chips ---------- */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  padding: 6px 13px; border-radius: 999px; border: 1px solid var(--border-strong);
  font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); background: var(--surface);
}
.chip:hover { background: var(--surface-2); text-decoration: none; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- Stats ---------- */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 900px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.stat-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-tile .label { font-size: 0.78rem; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.stat-tile .value { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; }
.stat-tile.tone-critical .value { color: var(--critical); }
.stat-tile.tone-warning .value { color: var(--warning); }

/* ---------- Distribution bar ---------- */
.dist-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--neutral-soft); margin-bottom: 12px; }
.dist-seg { height: 100%; }
.dist-seg.dist-aktuell, .dist-swatch.dist-aktuell { background: var(--good); }
.dist-seg.dist-faellig_bald, .dist-swatch.dist-faellig_bald { background: var(--warning); }
.dist-seg.dist-ueberfaellig, .dist-swatch.dist-ueberfaellig { background: var(--critical); }
.dist-seg.dist-neutral, .dist-swatch.dist-neutral { background: var(--neutral); }
.dist-legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 0.84rem; color: var(--ink-soft); }
.dist-legend-item { display: flex; align-items: center; gap: 6px; }
.dist-swatch { width: 9px; height: 9px; border-radius: 999px; display: inline-block; }

/* ---------- Worklists ---------- */
.worklist-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 4px; border-bottom: 1px solid var(--border);
}
.worklist-item:last-child { border-bottom: none; }
.wl-link { display: flex; flex-direction: column; gap: 2px; color: var(--ink); flex: 1; min-width: 0; }
.wl-link:hover { text-decoration: none; }
.wl-link:hover .wl-title { text-decoration: underline; }
.wl-title { font-weight: 600; font-size: 0.92rem; }
.wl-meta { font-size: 0.78rem; color: var(--muted); }

/* ---------- Detail views ---------- */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin: 10px 0 20px; }
.detail-meta { display: flex; gap: 24px; flex-wrap: wrap; margin-top: 10px; }
.meta-block .k { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; }
.meta-block .v { font-size: 0.92rem; font-weight: 600; margin-top: 2px; }
.section-label {
  font-size: 0.76rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--muted); margin: 22px 0 10px;
}
.content-outline { margin: 0; padding-left: 20px; color: var(--ink-soft); }
.content-outline li { margin-bottom: 4px; }

.detail-gefahr {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 14px;
}
.detail-gefahr-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }

/* ---------- Wizard ---------- */
.wizard-steps { display: flex; gap: 8px; margin: 14px 0 20px; flex-wrap: wrap; }
.wizard-step-dot {
  padding: 7px 14px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border);
  font-size: 0.78rem; font-weight: 650; color: var(--muted);
}
.wizard-step-dot.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* ---------- Hazard / Gefährdung rows ---------- */
.hazard-row {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 14px;
}
.hazard-row-nested { background: var(--surface); margin: 10px 0 0; }
.hazard-row-head {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted);
}
.remove-row {
  background: none; border: none; color: var(--critical); font-weight: 600; font-size: 0.8rem;
  cursor: pointer; padding: 2px 6px; font-family: inherit;
}
.remove-row:hover { text-decoration: underline; }
.add-hazard-btn {
  margin-top: 4px; background: none; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  padding: 9px 14px; font-size: 0.85rem; font-weight: 600; color: var(--accent); cursor: pointer;
  font-family: inherit; width: 100%;
}
.add-hazard-btn:hover { background: var(--accent-soft); }

.risk-preview {
  display: inline-flex; align-items: center; padding: 8px 12px; border-radius: var(--radius-sm);
  font-weight: 700; font-size: 0.85rem; text-transform: capitalize; background: var(--neutral-soft); color: var(--neutral);
}
.risk-preview.risk-niedrig { background: var(--good-soft); color: var(--good); }
.risk-preview.risk-mittel { background: var(--warning-soft); color: var(--warning); }
.risk-preview.risk-hoch { background: var(--critical-soft); color: var(--critical); }

/* ---------- Misc ---------- */
code, .mono { font-family: var(--font-mono); }
template { display: none !important; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .main { padding: 18px; }
}
