/* ISMS-Tool – Stylesheet v2 (minimalistisch, hell, Trade-Republic-inspiriert)
   Keine externen Fonts/CDNs – System-Schriften. */

:root {
  --c-bg: #f6f7f8;
  --c-surface: #ffffff;
  --c-border: #e9eaee;
  --c-border-strong: #d9dbe2;
  --c-text: #101114;
  --c-muted: #6b7078;
  --c-faint: #9aa0a8;
  --c-ink: #111214;
  --c-ink-hover: #2a2b30;
  --c-accent: #2b62e3;
  --c-green: #0e8a4d;
  --c-green-bg: #e8f6ee;
  --c-yellow: #9a6b00;
  --c-yellow-bg: #fbf2da;
  --c-red: #c43d3d;
  --c-red-bg: #fceaea;
  --c-blue: #2b62e3;
  --c-blue-bg: #eaf0fd;
  --c-gray: #6b7078;
  --c-gray-bg: #f0f1f4;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 17, 20, .04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: -apple-system, "SF Pro Text", system-ui, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--c-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -.015em; margin: 0 0 .5rem; }
h2 { font-size: 1.05rem; font-weight: 650; letter-spacing: -.01em; margin: 0 0 .8rem; }
h3 { font-size: .95rem; font-weight: 650; margin: 0 0 .5rem; }

:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--c-ink); color: #fff; padding: .5rem 1rem; z-index: 100;
  border-radius: 0 0 10px 0;
}
.skip-link:focus { left: 0; }

/* ---- Grundgeruest ---- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 244px;
  flex: 0 0 244px;
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex; align-items: center; gap: .65rem;
  padding: 1.15rem 1.2rem .95rem;
}
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--c-ink); color: #fff;
  font-weight: 700; font-size: 1.1rem;
}
.brand-text { font-weight: 650; line-height: 1.2; letter-spacing: -.01em; }
.brand-text small { display: block; font-weight: 400; color: var(--c-faint); font-size: .7rem; letter-spacing: 0; }

.nav-section {
  padding: .95rem 1.25rem .3rem;
  font-size: .64rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--c-faint);
  font-weight: 600;
}
.nav-link {
  display: block;
  margin: 0 .6rem .15rem;
  padding: .42rem .7rem;
  color: #3d4046;
  font-size: .88rem;
  border-radius: var(--radius-sm);
}
.nav-link:hover { background: var(--c-bg); text-decoration: none; color: var(--c-text); }
.nav-link.active { background: var(--c-gray-bg); color: var(--c-text); font-weight: 600; }

.sidebar-foot {
  margin-top: auto;
  padding: 1rem 1.2rem 1.1rem;
  border-top: 1px solid var(--c-border);
  font-size: .85rem;
}
.userbox a { color: var(--c-text); font-weight: 600; }
.userbox small { display: block; color: var(--c-faint); margin-bottom: .55rem; }
.version { display: block; color: var(--c-faint); margin-top: .7rem; font-size: .7rem; }

.content {
  flex: 1;
  padding: 1.7rem 2rem 3.5rem;
  max-width: 1280px;
  min-width: 0;
}

/* ---- Seitenkopf ---- */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap;
}
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---- Karten & Kacheln ---- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.2rem;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .9rem;
  margin-bottom: 1.2rem;
}
.tile {
  position: relative;
  display: block;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.05rem 1.15rem;
  color: var(--c-text);
  transition: border-color .15s ease;
}
a.tile:hover { border-color: var(--c-border-strong); text-decoration: none; }
.tile-value { font-size: 1.85rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.tile-label { color: var(--c-muted); font-size: .8rem; margin-top: .3rem; }
.tile-sub { color: var(--c-faint); font-size: .75rem; margin-top: .3rem; }
.tile-light { position: absolute; top: 1rem; right: 1rem; }

/* ---- Ampeln ---- */
.light {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  vertical-align: 0;
  margin-right: .45rem;
}
.light-green { background: #1fac62; }
.light-yellow { background: #e3a51e; }
.light-red { background: #e05252; }
.light-gray { background: #c3c7ce; }

/* ---- Reifegrad ---- */
.maturity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .9rem;
  margin-bottom: 1.2rem;
}
.maturity-card { margin-bottom: 0; }
.maturity-head { display: flex; justify-content: space-between; align-items: center; }
.maturity-head .light { width: 12px; height: 12px; margin: 0; }
.meter {
  height: 6px;
  background: var(--c-gray-bg);
  border-radius: 999px;
  overflow: hidden;
  margin: .7rem 0 .45rem;
}
.meter-fill { height: 100%; border-radius: 999px; }
.meter-green { background: #1fac62; }
.meter-yellow { background: #e3a51e; }
.meter-red { background: #e05252; }
.maturity-score { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }

/* ---- Risiko-Heatmap (5x5) ---- */
table.riskmatrix {
  border-collapse: separate;
  border-spacing: 4px;
  width: 100%;
  max-width: 640px;
  font-size: .85rem;
  table-layout: fixed;
  margin-left: -4px;
}
.riskmatrix th, .riskmatrix td {
  text-align: center;
  padding: .45rem .2rem;
  border-radius: 8px;
}
.riskmatrix thead th, .riskmatrix tbody th {
  background: transparent;
  color: var(--c-faint);
  font-size: .7rem;
  font-weight: 600;
}
.riskmatrix th small {
  display: block;
  font-weight: 400;
  font-size: .62rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.riskmatrix .rm-axis span { font-size: .66rem; }
.riskmatrix td {
  font-weight: 700;
  color: rgba(16, 17, 20, .3);
  height: 44px;
}
.riskmatrix td a { display: block; color: inherit; font-weight: 700; }
.riskmatrix td a:hover { text-decoration: underline; }
.riskmatrix td.rm-green { background: #e4f3ea; }
.riskmatrix td.rm-yellow { background: #faf0d4; }
.riskmatrix td.rm-red { background: #f9e3e3; }
.riskmatrix td.rm-hit { color: var(--c-text); }
.riskmatrix td.rm-red.rm-hit { color: var(--c-red); }
.riskmatrix td.rm-yellow.rm-hit { color: var(--c-yellow); }
.riskmatrix td.rm-green.rm-hit { color: var(--c-green); }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- Verlaufsdiagramm ---- */
svg.linechart {
  width: 100%;
  height: auto;
  display: block;
}
.filter-chip {
  display: inline-flex;
  gap: .4rem;
  align-items: center;
  background: var(--c-gray-bg);
  color: var(--c-text);
  border-radius: 999px;
  padding: .28rem .8rem;
  font-size: .8rem;
}
.filter-chip a { color: var(--c-muted); font-weight: 700; }

/* ---- Verknüpfungslisten / Kapitel / Matrizen ---- */
.linklist { list-style: none; margin: 0; padding: 0; }
.linklist li { padding: .45rem 0; border-bottom: 1px solid var(--c-border); font-size: .9rem; }
.linklist li:last-child { border-bottom: 0; }

.prewrap { white-space: pre-wrap; word-break: break-word; }

.empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--c-muted);
}
.empty p { margin: .4rem 0; }

.chapter {
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: .95rem 1.05rem;
  margin-bottom: .8rem;
  background: #fafbfc;
}
.chapter-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: .55rem; gap: .5rem; flex-wrap: wrap;
}
.chapter label { margin-bottom: .5rem; }

.mitre-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: .7rem;
}
.mitre-col {
  display: block;
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: .7rem .8rem;
  background: var(--c-surface);
  color: var(--c-text);
  transition: border-color .15s ease;
}
.mitre-col:hover { border-color: var(--c-border-strong); text-decoration: none; }
.mitre-col-head { font-size: .8rem; font-weight: 600; display: flex; gap: .35rem; align-items: baseline; margin-bottom: .4rem; }

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: .14rem .6rem;
  border-radius: 999px;
  font-size: .73rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green { background: var(--c-green-bg); color: var(--c-green); }
.badge-yellow { background: var(--c-yellow-bg); color: var(--c-yellow); }
.badge-red { background: var(--c-red-bg); color: var(--c-red); }
.badge-blue { background: var(--c-blue-bg); color: var(--c-blue); }
.badge-gray { background: var(--c-gray-bg); color: var(--c-gray); }

/* ---- Tabellen ---- */
.tbl-wrap { overflow-x: auto; }
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
  background: var(--c-surface);
}
.tbl th, .tbl td {
  text-align: left;
  padding: .6rem .6rem;
  border-bottom: 1px solid var(--c-border);
  vertical-align: top;
}
.tbl thead th {
  background: transparent;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--c-faint);
  font-weight: 600;
  border-bottom: 1px solid var(--c-border-strong);
  white-space: nowrap;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #fafbfc; }
.tbl td form { display: inline; }
.tbl .num { text-align: right; }

/* ---- Toolbar (Suche/Filter) ---- */
.toolbar {
  display: flex; gap: .6rem; align-items: end; flex-wrap: wrap;
  margin-bottom: 1rem;
}
.toolbar label { display: flex; flex-direction: column; gap: .25rem; font-size: .75rem; color: var(--c-muted); font-weight: 500; }
.toolbar input[type="search"], .toolbar input[type="text"], .toolbar select {
  min-width: 170px;
}

/* ---- Formulare ---- */
input[type="text"], input[type="search"], input[type="email"], input[type="password"],
input[type="date"], input[type="datetime-local"], input[type="url"], input[type="number"],
input[type="file"], select, textarea {
  width: 100%;
  padding: .52rem .7rem;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  background: #fff;
  color: var(--c-text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(43, 98, 227, .14);
}
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] {
  border-color: var(--c-red);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: .8rem 1rem;
  margin-top: .6rem;
}
.form-grid label, .form-col label {
  display: flex; flex-direction: column; gap: .3rem;
  font-size: .78rem; font-weight: 550; color: var(--c-muted);
}
.form-grid .span2 { grid-column: 1 / -1; }
.form-actions { grid-column: 1 / -1; display: flex; gap: .5rem; margin-top: .4rem; flex-wrap: wrap; }
.form-hint { font-weight: 400; font-size: .73rem; color: var(--c-faint); }

fieldset {
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: .85rem 1rem;
  margin: 0 0 .9rem;
}
legend { font-size: .78rem; font-weight: 600; color: var(--c-muted); padding: 0 .4rem; }

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  padding: .5rem .95rem;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  color: var(--c-text);
  font: inherit;
  font-size: .86rem;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease;
}
.btn:hover { border-color: #b9bdc7; background: #fafbfc; text-decoration: none; }
.btn-primary { background: var(--c-ink); border-color: var(--c-ink); color: #fff; }
.btn-primary:hover { background: var(--c-ink-hover); border-color: var(--c-ink-hover); }
.btn-danger { background: var(--c-surface); border-color: #eccaca; color: var(--c-red); }
.btn-danger:hover { background: var(--c-red-bg); border-color: #e0b3b3; }
.btn-sm { padding: .25rem .65rem; font-size: .76rem; border-radius: 8px; }
.btn-ghost { background: transparent; border-color: var(--c-border-strong); color: var(--c-text); }
.btn-ghost:hover { background: var(--c-bg); }

/* ---- Meldungen ---- */
.flash {
  padding: .7rem 1rem;
  border-radius: 12px;
  margin-bottom: 1.1rem;
  border: 1px solid;
  font-size: .9rem;
}
.flash-success { background: var(--c-green-bg); color: var(--c-green); border-color: #cfe9db; }
.flash-error { background: var(--c-red-bg); color: var(--c-red); border-color: #f0d2d2; }
.flash-info { background: var(--c-blue-bg); color: var(--c-blue); border-color: #d4e0f7; }

.err-summary {
  background: var(--c-red-bg);
  border: 1px solid #f0d2d2;
  color: var(--c-red);
  border-radius: 12px;
  padding: .8rem 1.05rem;
  margin-bottom: 1.1rem;
}
.err-summary ul { margin: .4rem 0 0 1.1rem; padding: 0; }

/* ---- Sonstiges ---- */
.muted { color: var(--c-muted); }
.small { font-size: .82rem; }
.mt { margin-top: 1rem; }
.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.1rem;
  align-items: start;
}
.two-col > .card { margin-bottom: 0; }

details.reveal { margin-top: .8rem; }
details.reveal > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: .86rem;
  color: var(--c-accent);
  padding: .3rem 0;
  list-style: revert;
}

.kv { display: grid; grid-template-columns: minmax(150px, 220px) 1fr; gap: .4rem .9rem; font-size: .9rem; }
.kv dt { color: var(--c-faint); }
.kv dd { margin: 0; }

.deflist { margin: 0; font-size: .86rem; }
.deflist dt { font-weight: 600; margin-top: .55rem; }
.deflist dd { margin: 0 0 .2rem; color: var(--c-muted); }

/* ---- Login ---- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--c-bg);
  padding: 1rem;
}
.login-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 20px;
  box-shadow: 0 12px 40px rgba(16, 17, 20, .07);
  padding: 2.4rem 2.2rem;
  width: 100%;
  max-width: 400px;
}
.login-card h1 { text-align: center; font-size: 1.5rem; }
.login-card .sub { text-align: center; color: var(--c-muted); font-size: .88rem; margin-bottom: 1.5rem; }
.login-card label { display: block; font-size: .78rem; font-weight: 550; color: var(--c-muted); margin-bottom: .8rem; }
.login-card input { margin-top: .3rem; }
.login-card .btn { width: 100%; margin-top: .6rem; padding: .65rem; }

/* ---- Druck (Bericht) ---- */
@media print {
  .sidebar, .page-actions, .no-print, .flash, .skip-link { display: none !important; }
  .shell { display: block; }
  .content { max-width: none; padding: 0; }
  body { background: #fff; font-size: 12px; }
  .card, .tile { box-shadow: none; break-inside: avoid; }
  a { color: inherit; }
}

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--c-border); }
  .content { padding: 1rem; }
}
