:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-strong: #eef4f3;
  --text: #172322;
  --muted: #66736f;
  --line: #dbe4e2;
  --primary: #0c766c;
  --primary-strong: #075e56;
  --blue: #1769aa;
  --done: #22a06b;
  --problem: #d93025;
  --selected: #f59e0b;
  --shadow: 0 8px 24px rgba(23, 35, 34, 0.1);
  font-family: Arial, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  color: var(--text);
  background: var(--bg);
}

#app {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  height: 100%;
}

#sidebar {
  overflow-y: auto;
  padding: 16px;
  background: #f7f9fa;
  border-right: 1px solid var(--line);
}

#map {
  position: relative;
  min-height: 100%;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.brand-logo {
  display: block;
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(23, 35, 34, 0.18);
}

.brand p {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 1.35rem;
}

.panel {
  margin: 12px 0;
  padding: 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(23, 35, 34, 0.05);
}

label,
.panel strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 800;
}

label {
  margin-top: 10px;
}

input,
select,
button {
  width: 100%;
  min-height: 40px;
  margin-top: 7px;
  padding: 8px 10px;
  border: 1px solid #cdd8d6;
  border-radius: 8px;
  font: inherit;
}

button {
  background: var(--primary);
  color: #fff;
  border: 0;
  cursor: pointer;
  font-weight: 800;
}

button:hover {
  filter: brightness(0.97);
}

.button-secondary {
  background: var(--surface-strong);
  color: #203432;
  border: 1px solid var(--line);
}

.button-danger {
  background: var(--problem);
}

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

.ok {
  color: #067647;
}

.error {
  color: #b42318;
}

.message,
.panel p {
  margin: 8px 0 0;
  font-size: 0.83rem;
  line-height: 1.45;
}

.small-text {
  margin-top: 8px;
  font-size: 0.82rem;
  line-height: 1.4;
}

.edit-block {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.edit-block b {
  display: block;
  font-size: 0.92rem;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat {
  padding: 10px;
  background: var(--surface-strong);
  border-radius: 8px;
}

.stat strong,
.stat span {
  display: block;
}

.stat strong {
  font-size: 1.25rem;
}

.stat span {
  color: var(--muted);
  font-size: 0.83rem;
}

.legend {
  display: grid;
  gap: 9px;
  margin-top: 11px;
  font-size: 0.86rem;
}

.legend div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.line {
  display: inline-block;
  width: 30px;
  height: 5px;
  border-radius: 999px;
  background: var(--blue);
}

.line.done {
  background: var(--done);
}

.line.problem {
  background: var(--problem);
}

.line.selected {
  background: var(--selected);
}

.details {
  margin-top: 10px;
  font-size: 0.9rem;
  line-height: 1.55;
}

.details b {
  display: inline-block;
  min-width: 112px;
}

.street-list {
  max-height: 190px;
  overflow-y: auto;
  margin-top: 10px;
  font-size: 0.86rem;
}

.street-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid #edf1f0;
}

.topbar {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 800;
  display: flex;
  gap: 8px;
}

.map-button {
  width: auto;
  margin-top: 0;
  background: #fff;
  color: #1f2937;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

@media (max-width: 860px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(360px, 48vh) minmax(420px, 1fr);
  }

  #sidebar {
    order: 2;
    border-right: 0;
    border-top: 1px solid var(--line);
  }

  #map {
    order: 1;
  }
}


/* AM RibX Viewer 2.0: riooltype, lengte en filters */
.line.sewer-foul { background: #d93025; }
.line.sewer-storm { background: #1769aa; }
.line.sewer-combined { background: #7c3aed; }
.line.sewer-drainage { background: #0c766c; }
.line.sewer-unknown { background: #6b7280; }

.type-badge,
.status-badge {
  display: inline-block;
  min-width: auto !important;
  padding: 3px 7px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.25;
}

.type-vuil { background: #d93025; }
.type-hemel { background: #1769aa; }
.type-gemengd { background: #7c3aed; }
.type-drainage { background: #0c766c; }
.type-onbekend { background: #6b7280; }

.status-todo { background: #6b7280; }
.status-done { background: #22a06b; }
.status-problem { background: #d93025; }

.length-highlight {
  display: inline-block;
  min-width: auto !important;
  padding: 4px 8px;
  border-radius: 7px;
  background: var(--surface-strong);
  font-weight: 900;
}

.summary-title {
  margin: 10px 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.leaflet-tooltip b {
  font-weight: 900;
}

/* AM RibX Viewer 2.1: werkkaart */
.progress-bar{width:100%;height:13px;margin-top:10px;overflow:hidden;background:var(--surface-strong);border:1px solid var(--line);border-radius:999px}
.progress-bar-fill{width:0%;height:100%;background:var(--done);border-radius:999px;transition:width 160ms ease-out}
.progress-grid{display:grid;grid-template-columns:1fr 1fr 1fr;gap:7px;margin-top:9px;font-size:.82rem}
.progress-grid div{padding:7px;background:var(--surface-strong);border-radius:8px}
.progress-grid span,.progress-grid b{display:block}
.manhole-marker{width:18px;height:18px;background:#fff;border:3px solid #172322;border-radius:50%;box-shadow:0 2px 6px rgba(23,35,34,.28)}
.manhole-marker.selected{border-color:#f59e0b;box-shadow:0 0 0 4px rgba(245,158,11,.28),0 2px 6px rgba(23,35,34,.28)}
.manhole-label{color:#172322;font-size:11px;font-weight:900;line-height:1;text-align:center;text-shadow:-1px -1px 0 #fff,1px -1px 0 #fff,-1px 1px 0 #fff,1px 1px 0 #fff,0 2px 4px rgba(255,255,255,.75);pointer-events:none}
.direction-arrow{color:#172322;font-size:18px;font-weight:900;line-height:1;text-shadow:-1px -1px 0 #fff,1px -1px 0 #fff,-1px 1px 0 #fff,1px 1px 0 #fff,0 2px 4px rgba(255,255,255,.8);pointer-events:none}
.leaflet-interactive{-webkit-tap-highlight-color:transparent}

/* AM RibX Viewer 2.2: kaartlagen en gestreepte gereinigde strengen */
.map-layer-button {
  min-width: 44px;
  padding-left: 10px;
  padding-right: 10px;
  font-size: 1.05rem;
}

.map-layer-button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.direction-arrow {
  color: #111827;
  -webkit-text-stroke: 1px #ffffff;
}

/* AM RibX Viewer 2.3: verbeterde pijlen en labels */
.direction-arrow {
  font-size: 14px;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.manhole-label {
  transform: translate(10px, -3px);
}

/* AM RibX Viewer 2.4: duidelijke gereinigde lijnen en SVG-pijlen */
.direction-arrow {
  width: 22px;
  height: 22px;
}

.direction-arrow svg {
  display: block;
  width: 22px;
  height: 22px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.45));
}

.direction-arrow path {
  stroke: #ffffff;
  stroke-width: 2.2;
  stroke-linejoin: round;
}


/* AM RibX Viewer QA/QC */
.validation-panel button {
  margin-top: 10px;
}

.validation-summary {
  margin-top: 8px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-strong);
  font-size: 0.86rem;
  line-height: 1.45;
}

.validation-summary.ok {
  color: #067647;
  background: #ecfdf3;
  border: 1px solid #abefc6;
}

.validation-summary.warning {
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
}

.validation-summary.error {
  color: #b42318;
  background: #fef3f2;
  border: 1px solid #fecdca;
}

.validation-details {
  margin-top: 9px;
  font-size: 0.84rem;
}

.validation-details summary {
  cursor: pointer;
  font-weight: 900;
}

.validation-report {
  max-height: 260px;
  overflow-y: auto;
  margin-top: 9px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  line-height: 1.45;
}

.validation-item {
  padding: 8px 0;
  border-bottom: 1px solid #edf1f0;
}

.validation-item:last-child {
  border-bottom: 0;
}

.validation-item b {
  display: inline;
  min-width: auto;
}

.validation-tag {
  display: inline-block;
  min-width: auto !important;
  padding: 2px 6px;
  margin-right: 5px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 900;
}

.validation-tag.error { background: #d93025; color: #fff; }
.validation-tag.warning { background: #f59e0b; color: #172322; }
.validation-tag.info { background: #1769aa; color: #fff; }


/* AM RibX Viewer 2.5: uitgebreide RIBX-validatie */
.validation-summary {
  margin-top: 8px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-strong);
  font-size: 0.84rem;
  line-height: 1.45;
}
.validation-summary.ok { color:#067647; background:#ecfdf3; border:1px solid #abefc6; }
.validation-summary.warn { color:#93370d; background:#fffaeb; border:1px solid #fedf89; }
.validation-summary.error { color:#b42318; background:#fef3f2; border:1px solid #fecdca; }
.validation-details { margin-top: 8px; font-size: 0.84rem; }
.validation-details summary { cursor: pointer; font-weight: 800; color: var(--primary); }
.validation-report {
  margin-top: 8px;
  max-height: 260px;
  overflow-y: auto;
  padding: 8px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  line-height: 1.45;
}
.validation-item { padding: 8px 0; border-bottom: 1px solid #edf1f0; }
.validation-item:last-child { border-bottom: 0; }
.validation-item b { display: block; }
.validation-pill {
  display:inline-block;
  min-width:auto!important;
  margin-right:5px;
  padding:2px 6px;
  border-radius:999px;
  color:#fff;
  font-size:.72rem;
  font-weight:900;
}
.validation-pill.error { background:#d93025; }
.validation-pill.warn { background:#f59e0b; }
.validation-pill.ok { background:#22a06b; }


/* AM RibX Viewer stability update: kaartdiagnose en parallelle strengen */
.diagnostic-line {
  margin-top: 6px;
}
.validation-small {
  color: var(--muted);
  font-size: .78rem;
}
