:root {
  --ink: #1f2328;
  --muted: #59636e;
  --line: #d1d9e0;
  --bar: #f6f8fa;
  --accent: #0969da;
  --green: #1a7f37;
  --orange: #bc4c00;
  --red: #cf222e;
  --red-bg: #ffebe9;
  /* The candidates of the selected row on the map (spec 004, D4): never the colour of a status. */
  --candidate: #0969da;
  --selected-bg: #ddf4ff;
  /* Spec 008: the point placed by hand, the violet of the mock-up. */
  --new: #8250df;
  --new-bg: #f6efff;
  --results-height: max(70vh, 360px);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
}

body {
  margin: 0;
  background: #fff;
}

.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--bar);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 600;
}

.user:not([hidden]) {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--muted);
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* The results screen, table and map, uses the whole width of the window. */
main:has(> #results:not([hidden])) {
  max-width: none;
}

h1 {
  font-size: 1.4rem;
  margin: 0 0 16px;
}

h2 {
  font-size: 1rem;
  margin: 32px 0 8px;
  color: var(--muted);
}

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

.status {
  display: block;
  margin: 16px 0;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  overflow-wrap: anywhere;
}

button {
  font: inherit;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bar);
  color: var(--ink);
  cursor: pointer;
}

button[type="submit"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

button.link {
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
}

input[type="email"],
input[type="password"],
textarea {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

textarea {
  display: block;
  box-sizing: border-box;
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
  resize: vertical;
}

textarea.dragging {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
}

.input-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.buttons {
  display: flex;
  gap: 8px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 20px;
}

.narrow {
  max-width: 360px;
  margin: 48px auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.narrow button {
  margin-top: 8px;
}

.error {
  color: var(--red);
  margin: 8px 0 0;
}

.alert {
  border-color: var(--red);
  background: var(--red-bg);
}

.alert-title {
  font-weight: 600;
  margin-top: 0;
}

.alert p:last-child {
  margin-bottom: 0;
  overflow-wrap: anywhere;
}

.actions {
  text-align: right;
}

.format {
  padding-left: 20px;
  line-height: 1.6;
}

.results-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.counters {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 12px;
  margin: 8px 0 16px;
}

.counter {
  display: grid;
  grid-template-columns: auto auto;
  column-gap: 16px;
  min-width: 140px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.counter strong {
  text-align: right;
  font-size: 1.2rem;
}

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

.downloads {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.VERT {
  color: var(--green);
}

.ORANGE {
  color: var(--orange);
}

.ROUGE {
  color: var(--red);
}

.filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  border: none;
  padding: 0;
  margin: 0 0 8px;
}

.filter legend {
  float: left;
  margin-right: 4px;
}

/* Spec 004: the table on the left, the map on the right, same height; the table alone when there
   is no map (D8). The table scrolls inside its half, both ways; no column is removed (D1). */
.results-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.results-body.no-map {
  grid-template-columns: minmax(0, 1fr);
}

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

/* Spec 006: the decision panel above the map, both in the right half. */
.side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: var(--results-height);
  min-width: 0;
}

.side[hidden] {
  display: none;
}

.map {
  flex: 1 1 auto;
  min-height: 240px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

#map-status {
  margin: 8px 0 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  background: var(--bar);
  position: sticky;
  top: 0;
}

tbody tr:last-child td {
  border-bottom: none;
}

/* Spec 004, D5: a row is selected by a click on it or on its point; brought into view below the
   sticky header. Marked by its background only: an arrow reads as a toggle. */
tbody tr {
  cursor: pointer;
  scroll-margin-top: 36px;
}

tbody tr.selected td {
  background: var(--selected-bg);
}

.num {
  text-align: right;
  color: var(--muted);
}

td.clip {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

td.reason {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Spec 006, D1: the « Revue » column, apart from the colour of the engine. */
td.review {
  color: var(--muted);
}

.st-acceptee {
  color: var(--green);
}

.st-corrigee {
  color: var(--accent);
}

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

.counter.review {
  min-width: 200px;
}

.counter.review small {
  grid-column: 1 / -1;
}

/* Spec 006, D5: the decision panel of the selected non VERT row. */
.panel {
  flex: 0 1 auto;
  max-height: 60%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.9rem;
}

.side:has(> .map[hidden]) .panel {
  max-height: none;
}

.panel header {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 6px;
}

.panel p {
  margin: 0 0 8px;
  line-height: 1.45;
}

.panel .reason,
.panel .note {
  color: var(--muted);
}

.panel .spread {
  font-weight: 600;
}

.proposals {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.proposals li {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
}

.proposals li.engine {
  border-color: var(--orange);
}

.proposals li.weak {
  border-style: dashed;
}

.proposals li.chosen {
  background: #e9f6ec;
}

.pname {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.pdetail {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

/* D12: the same badges in the panel and on the map: engine in the colour of the row, other
   credible in blue, not credible as an empty blue circle. */
.badge {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--candidate);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge.engine.ORANGE {
  background: var(--orange);
  color: #fff;
}

.badge.weak {
  background: #fff;
  color: var(--candidate);
  border: 2px solid var(--candidate);
}

.map-badge {
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.map-badge.weak {
  border-color: var(--candidate);
}

.panel-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.panel .primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Spec 008, D1: the block « Placer le point à la main », dashed violet as in the mock-up. */
.place {
  border: 2px dashed var(--new);
  border-radius: 8px;
  background: var(--new-bg);
  padding: 10px 12px;
  margin: 0 0 10px;
}

.place h4 {
  margin: 0 0 4px;
  font-size: 0.92rem;
  color: var(--new);
}

.place .coords {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.panel .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 10px;
}

.place .actions {
  margin: 0;
}

button.new-btn {
  border: 1px dashed var(--new);
  background: var(--new-bg);
  color: var(--new);
}

/* Spec 008, D5: placing: dashed violet border (outline, the size of the map does not change),
   crosshair, banner. */
.map.placing {
  border-color: var(--new);
  border-style: dashed;
  outline: 1px dashed var(--new);
}

.map.placing .mapboxgl-canvas-container {
  cursor: crosshair;
}

.map-hint {
  background: #fff;
  border: 1px solid var(--new);
  border-radius: 6px;
  padding: 3px 8px;
  color: var(--new);
  font-size: 0.8rem;
  font-weight: 600;
}

.mapboxgl-ctrl-group button.map-reframe {
  width: auto;
  padding: 0 8px;
  font: inherit;
  font-size: 0.78rem;
}

/* Spec 008, D6: where the map opened, under it. */
.map-cap {
  flex: none;
  margin: -6px 0 0;
  font-size: 0.78rem;
}

kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8em;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

/* Filter ROUGE: nothing is retained, the two columns are empty. */
.only-red .found {
  display: none;
}

/* Narrow screen: the map under the table. */
@media (max-width: 900px) {
  .results-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .side {
    height: auto;
  }

  .map {
    flex: none;
    height: 50vh;
  }
}

@media (max-width: 640px) {
  main {
    padding: 16px;
  }

  .bar {
    padding: 12px 16px;
  }

  .downloads {
    margin-left: 0;
  }
}
