:root {
  color-scheme: light;
  --bg: #f4f6f4;
  --ink: #17201a;
  --muted: #5e6a62;
  --line: #cbd5cd;
  --panel: #ffffff;
  --rail: #19251d;
  --accent: #2d7f5e;
  --accent-2: #b65c2e;
  --warn: #b42318;
  --gold: #b78b1f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

.is-loading .app-shell {
  display: none;
}

.loading-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 24px;
  background: #ffffff;
}

.loading-screen[hidden] {
  display: none;
}

.loading-text {
  color: #ff0000;
  font-size: clamp(42px, 9vw, 118px);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  animation: loading-blink 0.72s steps(2, start) infinite;
}

.loading-bar {
  width: min(72vw, 620px);
  height: 18px;
  border: 3px solid #ff0000;
  background: #fff4f4;
  overflow: hidden;
}

.loading-bar span {
  display: block;
  width: 0%;
  height: 100%;
  background: #ff0000;
  transition: width 0.18s ease;
}

.loading-detail {
  min-height: 20px;
  color: #9a0000;
  font-weight: 700;
  text-align: center;
}

@keyframes loading-blink {
  50% {
    opacity: 0.08;
  }
}

.app-shell {
  display: grid;
  grid-template-columns: 174px minmax(0, 1fr);
  min-height: 100vh;
}

.app-shell.rail-collapsed {
  grid-template-columns: 56px minmax(0, 1fr);
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--rail);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 8px;
}

.rail-toggle {
  width: 38px;
  height: 32px;
  border: 1px solid #86a891;
  background: transparent;
  color: #f4fff7;
  cursor: pointer;
  font-weight: 700;
}

.brand {
  width: 100%;
  height: 38px;
  border: 1px solid #86a891;
  color: #f4fff7;
  display: grid;
  place-items: center;
  font-weight: 700;
  margin-bottom: 10px;
  padding: 0 6px;
}

.app-shell.rail-collapsed .brand {
  font-size: 0;
}

.app-shell.rail-collapsed .brand::after {
  content: attr(data-short);
  font-size: 12px;
}

.tab {
  width: 100%;
  min-height: 38px;
  border: 1px solid transparent;
  background: transparent;
  color: #d7e5dc;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  padding: 8px 10px;
  white-space: normal;
}

.app-shell.rail-collapsed .tab {
  text-align: center;
  padding: 8px 3px;
  font-size: 0;
}

.app-shell.rail-collapsed .tab::after {
  content: attr(data-short);
  font-size: 13px;
}

.tab:hover,
.tab.active {
  border-color: #9fc5ab;
  background: #26372b;
}

main {
  min-width: 0;
  padding: 22px;
}

.legal-page {
  max-width: 980px;
  margin: 0 auto;
}

.legal-page h1 {
  margin-bottom: 8px;
}

.legal-page h2 {
  margin-top: 20px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 18px;
}

.top-actions {
  display: flex;
  justify-content: flex-end;
}

h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
}

h2 {
  margin: 0 0 12px;
  font-size: 17px;
}

p {
  margin: 6px 0 0;
  color: var(--muted);
}

.intro {
  max-width: 1180px;
  background: #ffffff;
  border: 1px solid var(--line);
  padding: 14px 16px;
  margin-bottom: 14px;
}

.intro summary,
.timeline summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 17px;
}

.intro p:first-of-type {
  margin-top: 10px;
}

.intro a {
  color: var(--accent);
  font-weight: 700;
}

.metrics {
  display: flex;
  gap: 10px;
}

.metrics div {
  min-width: 126px;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 10px 12px;
}

.metrics span {
  display: block;
  font-size: 22px;
  font-weight: 700;
}

.metrics small {
  color: var(--muted);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.compact-toolbar {
  margin-top: 6px;
}

.filter-hint {
  color: #b00000;
  font-weight: 700;
  align-self: center;
  max-width: 420px;
}

label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

select,
input[type="search"],
input[type="number"] {
  min-width: 180px;
  height: 34px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 0 8px;
}

input[type="number"] {
  min-width: 120px;
}

input[type="range"] {
  width: 100%;
  appearance: none;
  background: transparent;
  height: 18px;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: #d8e0da;
  border-radius: 999px;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px #6b8774;
  margin-top: -6px;
}

input[type="range"]::-moz-range-track {
  height: 4px;
  background: #d8e0da;
  border-radius: 999px;
}

input[type="range"]::-moz-range-progress {
  height: 4px;
  background: #d8e0da;
  border-radius: 999px;
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px #6b8774;
}

.timeline {
  max-width: 1180px;
}

.timeline .block-head span {
  color: var(--muted);
  font-weight: 600;
}

.head-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.range-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr);
  gap: 16px;
}

.range-label {
  position: relative;
}

.range-archive-marker {
  position: absolute;
  left: var(--archive-left, -999px);
  top: 23px;
  width: 0;
  height: 18px;
  border-left: 2px dashed #8a5a2d;
  pointer-events: auto;
}

.range-archive-marker::after {
  content: "";
  position: absolute;
  left: -4px;
  top: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8a5a2d;
}

.mini-timeline {
  position: relative;
  height: 28px;
  margin-top: 12px;
  border: 1px solid var(--line);
  background: #eef3ef;
  cursor: crosshair;
}

.mini-timeline::before {
  content: "";
  position: absolute;
  inset: 9px 8px;
  background: #d8e0da;
}

.mini-window {
  position: absolute;
  top: 6px;
  bottom: 6px;
  background: rgba(45, 127, 94, 0.16);
  border-left: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
}

.archive-marker {
  position: absolute;
  top: 3px;
  bottom: 3px;
  width: 0;
  border-left: 3px dashed #8a5a2d;
  z-index: 3;
}

.archive-marker::after {
  content: "Archivmarke";
  position: absolute;
  top: -20px;
  left: 6px;
  white-space: nowrap;
  color: #8a5a2d;
  font-size: 11px;
  font-weight: 700;
}

.action {
  height: 34px;
  border: 1px solid #8aa994;
  background: #ffffff;
  color: var(--ink);
  padding: 0 8px;
  cursor: pointer;
  font-weight: 600;
}

.action:hover {
  background: #eaf2ed;
}

.action.active {
  background: #173d2a;
  border-color: #173d2a;
  color: #ffffff;
}

.grid.two {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(360px, 0.8fr);
  gap: 14px;
}

.grid.two.coverage-hidden {
  grid-template-columns: minmax(0, 1fr);
}

.grid.two.coverage-hidden #coverageBlock {
  display: none;
}

.block {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 14px;
  margin-bottom: 14px;
}

.block-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
  margin-bottom: 12px;
}

.block-head h2 {
  margin-bottom: 0;
}

.export-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 5px;
}

.picker-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  margin: 0 0 14px;
  padding: 10px 12px;
}

.picker-panel summary {
  cursor: pointer;
  font-weight: 700;
}

.directory-table {
  margin-bottom: 14px;
}

.hint {
  color: var(--muted);
  margin: 8px 0 0;
  max-width: 980px;
}

.button-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 10px;
}

.chip {
  min-height: 30px;
  border: 1px solid #9fb0a4;
  background: #ffffff;
  color: var(--ink);
  padding: 5px 9px;
  cursor: pointer;
  font-weight: 600;
}

.chip.active {
  background: #173d2a;
  border-color: #173d2a;
  color: #ffffff;
}

.chip.utility {
  border-style: dashed;
  color: var(--ink);
}

.chip.utility.active {
  background: #173d2a;
  border-color: #173d2a;
  color: #ffffff;
}

.chip.dim {
  color: #8b938d;
  border-color: #d0d6d1;
}

.chip.dim.active {
  background: #e8ece9;
  border-color: #c8d0ca;
  color: #7d8780;
}

.chip.utility.dim,
.chip.utility.active.dim {
  color: var(--muted);
  border-color: #9fb0a4;
  background: #ffffff;
}

.chip.blocked {
  border-color: #b68f89;
  color: #8f332a;
}

.chip.blocked.active {
  background: #7d2d26;
  border-color: #7d2d26;
  color: #ffffff;
}

.sortable {
  cursor: pointer;
}

.draggable-column {
  cursor: grab;
  user-select: none;
  position: sticky;
}

.draggable-column:active {
  cursor: grabbing;
}

.column-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  z-index: 3;
}

.column-resizer::after {
  content: "";
  position: absolute;
  top: 7px;
  bottom: 7px;
  left: 3px;
  border-left: 1px solid #a8b7ad;
}

.is-resizing-column,
.is-resizing-column * {
  cursor: col-resize !important;
  user-select: none;
}

.column-tools {
  border: 1px solid var(--line);
  background: #ffffff;
  padding: 8px 10px;
  margin: 8px 0 6px;
}

.column-tools summary {
  cursor: pointer;
  font-weight: 700;
}

.column-tools-body {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.column-profile-buttons,
.column-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.column-view-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: end;
}

.column-view-tools label {
  max-width: 220px;
}

.column-view-tools input {
  height: 32px;
  border: 1px solid #cbd7ce;
  padding: 0 8px;
}

.column-saved-views {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.saved-view {
  display: inline-flex;
  gap: 2px;
}

.compact-action {
  min-width: 30px;
  padding-left: 8px;
  padding-right: 8px;
}

.column-check {
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid #d2ddd5;
  padding: 4px 7px;
  background: #f8fbf9;
  color: var(--ink);
}

.sort-indicator {
  color: var(--muted);
  margin-left: 4px;
}

.source-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.source-link:hover {
  text-decoration: underline;
}

.table-wrap {
  overflow: auto;
  max-height: 66vh;
  border: 1px solid var(--line);
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 680px;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid #e3e8e4;
  padding: 7px 8px;
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: #edf2ee;
  z-index: 1;
  font-size: 12px;
  overflow: hidden;
}

.header-label,
.cell-content {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alias-manager {
  display: grid;
  gap: 8px;
}

.alias-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(180px, 240px) auto auto auto;
  gap: 8px;
  align-items: end;
  border: 1px solid var(--line);
  background: #ffffff;
  padding: 8px;
}

.alias-row strong,
.alias-row span,
.alias-row p {
  min-width: 0;
}

.alias-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.alias-row p {
  margin: 4px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alias-row label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.alias-row input {
  min-width: 0;
  height: 34px;
  border: 1px solid #cbd7ce;
  padding: 0 8px;
  color: var(--ink);
  background: #ffffff;
}

@media (max-width: 980px) {
  .alias-row {
    grid-template-columns: 1fr;
  }
}

td.num,
th.num {
  text-align: right;
}

td.trend-cell {
  transition: background-color 120ms ease;
}

td.parliament-cell {
  box-shadow: inset 0 0 0 999px rgba(101, 111, 105, 0.12);
}

canvas {
  width: 100%;
  max-height: 720px;
  border: 1px solid var(--line);
  background: #fbfcfb;
}

.chart-tooltip {
  position: fixed;
  display: none;
  max-width: 280px;
  z-index: 20;
  pointer-events: none;
  background: #17201a;
  color: #ffffff;
  border: 1px solid #3f5748;
  padding: 7px 9px;
  font-size: 12px;
  line-height: 1.35;
  box-shadow: 0 6px 18px rgba(23, 32, 26, 0.22);
}

.chart-tooltip strong {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}

.point-detail {
  border: 1px solid var(--line);
  background: #f8faf8;
  padding: 10px 12px;
  margin-top: 10px;
}

.point-detail dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 5px 12px;
  margin: 0;
}

.point-detail dt {
  color: var(--muted);
  font-weight: 700;
}

.point-detail dd {
  margin: 0;
}

.rules-editor {
  width: 100%;
  min-height: 180px;
  margin-top: 10px;
  border: 1px solid var(--line);
  padding: 10px;
  font: 12px Consolas, "Courier New", monospace;
  color: var(--ink);
  background: #fbfcfb;
}

.rules-button-editor {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.rules-button-editor h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.rules-button-editor .rule-row {
  border: 1px solid var(--line);
  background: #fbfcfb;
  padding: 10px;
}

.chip.rule-excluded {
  border-style: solid;
  border-color: #9c3f2f;
}

.chip.rule-ever {
  border-style: solid;
  border-color: #2d7f5e;
}

.quality-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.quality-summary div {
  min-width: 180px;
  border: 1px solid var(--line);
  background: #f8faf8;
  padding: 10px 12px;
}

.quality-summary strong,
.quality-summary span {
  display: block;
}

.quality-summary span {
  color: var(--muted);
  font-size: 12px;
}

.change-list {
  display: grid;
  gap: 10px;
}

.change-item {
  border-left: 4px solid var(--accent);
  background: #f8faf8;
  padding: 10px 12px;
}

.change-item.error {
  border-left-color: var(--warn);
}

.change-item.baseline {
  border-left-color: var(--gold);
}

.change-item strong {
  display: block;
}

.change-item span {
  display: block;
  margin-top: 3px;
}

.change-item a {
  color: var(--accent);
  word-break: break-all;
}

.page-footer {
  color: var(--muted);
  font-size: 12px;
  padding: 4px 0 12px;
}

.page-footer a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.page-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 112px minmax(0, 1fr);
  }

  .app-shell.rail-collapsed {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  main {
    padding: 14px;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .metrics {
    width: 100%;
    overflow-x: auto;
  }

  .grid.two {
    grid-template-columns: 1fr;
  }

  select,
  input[type="search"],
  input[type="number"] {
    min-width: 150px;
  }

  .range-grid {
    grid-template-columns: 1fr;
  }
}
