:root {
  --sap-blue: #0a6ed1;
  --sap-blue-dark: #0854a0;
  --sap-dark: #32363a;
  --sap-navy: #1c2b3a;
  --bg: #f5f6f7;
  --border: #d9d9d9;
  --hot: #bb0000;
  --high: #e9730c;
  --med: #e9730c;
  --low: #6a6d70;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,0.06), 0 1px 6px rgba(0,0,0,0.04);
  --surface: #ffffff;
  --surface-alt: #fafcff;
  --surface-hover: #f0f2f4;
  --table-header-bg: #f7f8f9;
  --text: #1a1a1a;
  --text-muted: #6a6d70;
}

[data-theme="dark"] {
  --sap-dark: #e4e7ea;
  --bg: #14171a;
  --border: #3a4048;
  --surface: #20242a;
  --surface-alt: #262b32;
  --surface-hover: #2b313a;
  --table-header-bg: #262b32;
  --text: #e4e7ea;
  --text-muted: #9aa3ad;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 1px 6px rgba(0,0,0,0.25);
}
[data-theme="dark"] details summary:hover { background: var(--surface-hover); }
[data-theme="dark"] tr:hover td { background: var(--surface-hover); }
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea {
  background: var(--surface-alt);
  color: var(--text);
  border-color: var(--border);
}
[data-theme="dark"] .btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: "72", "Segoe UI", Arial, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main { flex: 1 0 auto; }
footer.site-footer { flex-shrink: 0; }

.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 32px;
}

/* ---------------- Header (Fiori Shell Bar Style) ---------------- */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 32px;
}
header .logo { height: 40px; width: auto; display: block; }
header .header-text { border-left: 1px solid var(--border); padding-left: 20px; }
header h1 { margin: 0; font-size: 19px; font-weight: 700; color: var(--sap-dark); }
.subtitle { margin: 2px 0 0; opacity: 0.65; font-size: 12.5px; }

.header-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
  color: var(--text-muted);
  white-space: nowrap;
}
.header-user .btn-secondary { padding: 6px 12px; font-size: 13px; }

/* ---------------- Tab Navigation ---------------- */
nav.tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.tabs-inner {
  display: flex;
  padding: 0;
}
.tab-btn {
  border: none;
  background: none;
  padding: 14px 22px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--sap-dark);
  border-bottom: 3px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
nav.tabs .tab-btn:hover { background: transparent; color: var(--sap-blue); }
nav.tabs .tab-btn.active {
  background: transparent;
  border-bottom-color: var(--sap-blue);
  color: var(--sap-blue);
  font-weight: 700;
}
.tab-btn:focus { outline: none; }
.tab-btn:focus-visible {
  outline: 2px solid var(--sap-blue);
  outline-offset: -3px;
  border-radius: 2px;
}

main { padding: 32px 0 48px; }
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

h2 {
  color: var(--sap-dark);
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 16px;
}

/* ---------------- Forms / Panels ---------------- */
.inline-form, .grid-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  background: var(--surface);
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.grid-form fieldset {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  width: 100%;
}

/* Fiori-style collapsible panels */
details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
details summary {
  cursor: pointer;
  padding: 14px 18px;
  font-weight: 600;
  color: var(--sap-dark);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  transition: background 0.15s ease;
}
details summary::-webkit-details-marker { display: none; }
details summary::before {
  content: "▶";
  font-size: 10px;
  color: var(--sap-blue);
  transition: transform 0.15s ease;
  display: inline-block;
}
details[open] summary::before { transform: rotate(90deg); }
details summary:hover { background: var(--surface-hover); }
details > *:not(summary) { padding-left: 18px; padding-right: 18px; }
details > p.hint:last-child, details > form:last-child, details > .grid-form:last-child { padding-bottom: 18px; }
details .inline-form, details .grid-form {
  box-shadow: none;
  border: none;
  margin-bottom: 8px;
  padding: 0 0 4px;
}
details p.hint { margin: 8px 0; }

input, select, button, textarea {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--sap-blue);
  box-shadow: 0 0 0 2px rgba(10,110,209,0.15);
}
/* Checkboxen von der appearance:none-Regel oben ausnehmen — sonst ist ihr
   Häkchen unsichtbar (betraf u.a. "Mit NVD anreichern" und die neuen
   Administrator-/Aktiv-Haken im Admin-Tab: das Kästchen war da, zeigte aber
   nie an, ob es angehakt ist). */
input[type="checkbox"] {
  appearance: auto;
  -webkit-appearance: auto;
  -moz-appearance: auto;
  width: 16px;
  height: 16px;
  padding: 0;
  accent-color: var(--sap-blue);
  cursor: pointer;
}
button {
  background: var(--sap-blue);
  color: white;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s ease, transform 0.05s ease;
}
button:hover { background: var(--sap-blue-dark); }
button:active { transform: translateY(1px); }
button:focus { outline: none; }
button:focus-visible {
  outline: 2px solid var(--sap-blue-dark);
  outline-offset: 2px;
}
button.btn-secondary {
  background: var(--surface);
  color: var(--sap-dark);
  border: 1px solid var(--border);
}
button.btn-secondary:hover { background: var(--surface-hover); }
button.btn-danger {
  background: var(--surface);
  color: var(--hot);
  border: 1px solid var(--hot);
}
button.btn-danger:hover { background: #fdeaea; }
button.btn-row-delete {
  background: transparent;
  color: var(--hot);
  border: none;
  padding: 6px 10px;
  font-weight: 500;
  font-size: 12.5px;
}
button.btn-row-delete:hover { background: #fdeaea; border-radius: 6px; }

/* ---------------- Filter inputs ---------------- */
.filter-input {
  width: 320px;
  max-width: 100%;
  background: var(--surface);
}

/* ---------------- Tables (Fiori-style) ---------------- */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
th, td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
th {
  background: var(--surface-hover);
  color: var(--sap-dark);
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  user-select: none;
}
th.sortable { cursor: pointer; }
th.sortable:hover { background: #eef2f6; }
th.sort-asc::after { content: " ▲"; font-size: 9px; color: var(--sap-blue); }
th.sort-desc::after { content: " ▼"; font-size: 9px; color: var(--sap-blue); }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 0;
}
.pagination .pg-info { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.pagination button {
  background: var(--surface);
  color: var(--sap-dark);
  border: 1px solid var(--border);
  padding: 6px 14px;
  font-size: 13px;
}
.pagination button:hover:not(:disabled) { background: var(--surface-hover); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
tr:hover td { background: var(--surface-alt); }
tr[style*="display: none"] { display: none !important; }

.field-row { margin-bottom: 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.actions-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.hint { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

.prio-badge {
  padding: 3px 9px;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 700;
  color: white;
  white-space: nowrap;
}
.prio-hot { background: var(--hot); }
.prio-sehr-hoch { background: var(--high); }
.prio-hoch { background: #e9730c; }
.prio-mittel { background: #e9a800; color: #1a1a1a; }
.prio-niedrig { background: var(--low); }

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--sap-blue);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.result-card.prio-Hot-News { border-left-color: var(--hot); }
.result-card.prio-Sehr-hoch { border-left-color: var(--high); }
.result-card.prio-Hoch { border-left-color: #e9730c; }
.result-card.prio-Mittel { border-left-color: #e9a800; }
.result-card.prio-Niedrig { border-left-color: var(--low); }

.result-card .top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.empty-state { color: var(--text-muted); padding: 24px; text-align: center; }

#table-notes td a {
  color: var(--sap-blue);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}
#table-notes td a:hover { text-decoration: underline; }

.range-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.range-block h4 { margin: 0 0 10px; color: var(--sap-dark); font-size: 14px; }

table.range-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}
table.range-table th, table.range-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
}
table.range-table th { color: var(--sap-dark); font-weight: 600; background: var(--table-header-bg); }
table.range-table tbody tr:last-child td { border-bottom: 1px solid var(--border); }
table.range-table tfoot td {
  border-bottom: none;
  border-top: 2px solid var(--border);
  padding-top: 10px;
  vertical-align: middle;
}
table.range-table tfoot input,
table.range-table tfoot select {
  width: 100%;
  box-sizing: border-box;
}
table.range-table tfoot button { white-space: nowrap; }
.range-empty-row td {
  color: var(--text-muted);
  font-style: italic;
  padding: 6px 8px;
}

/* ---------------- Footer ---------------- */
.site-footer {
  background: var(--sap-navy);
  color: rgba(255,255,255,0.85);
  margin-top: 40px;
}
.footer-inner {
  display: grid;
  grid-template-columns: 2fr 1fr;
  align-items: center;
  gap: 32px;
  padding: 36px 32px;
}
.footer-inner .footer-col:last-child { text-align: center; }
.footer-col h3 { margin: 0 0 10px; font-size: 18px; color: white; }
.footer-col h4 {
  margin: 0 0 10px;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.6);
}
.footer-col p { margin: 0 0 8px; font-size: 13.5px; line-height: 1.6; }
.footer-col a { color: white; text-decoration: none; }
.footer-col a:hover { text-decoration: underline; }
.footer-copyright { margin-top: 16px; font-size: 12px; color: rgba(255,255,255,0.55); }

@media (max-width: 720px) {
  .footer-inner { grid-template-columns: 1fr; }
  .header-inner { flex-wrap: wrap; }
}
