:root {
  --bg:    #f7f7f7;
  --fg:    #333;
  --light: #e0e0e0;
  --dark:  #555;
  --border:#ccc;
  --radius:8px;

  /* Buttons */
  --btn-blue: #0d6efd;
  --btn-blue-hover:#0a58ca;
  --btn-red:  #e57373;      /* softer red */
  --btn-red-hover:#f28b82;

  --container-p: 2rem;
  --gap: 1rem;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  padding: 2rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.5;
}

.container {
  max-width: 95%;
  margin: 2rem auto;
  padding: var(--container-p);
  background: #fff;
  border: 1px solid var(--light);
  border-radius: var(--radius);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

h1 {
  margin: 0 0 1rem 0;
  font-size: 1.6rem;
  color: var(--dark);
}

label { display: block; margin-bottom: 0.5rem; font-weight: 500; }

input[type="text"],
textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 0.25rem;
  font-size: 1rem;
  background: #fff;
}

textarea { resize: vertical; }

button {
  padding: 0.6rem 0.9rem;
  font-size: 0.95rem;
  color: #fff;
  background: var(--dark);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}
button:hover { background: var(--fg); }

.btn-secondary {
  background: #888;
}
.btn-secondary:hover {
  background: #666;
}

.error { color: #b00; margin-bottom: 1rem; }

/* ---------- 2-column layout (list left, map right) ---------- */
.result-grid {
  display: flex;
  gap: var(--gap);
  align-items: flex-start;
}

.result-left { flex: 1 1 33%; min-width: 260px; }
.result-right { flex: 2 1 67%; min-width: 320px; }

/* Stack vertically on small screens */
@media (max-width: 900px) {
  .result-grid { display: block; }
  .result-left, .result-right { width: 100%; }
}

/* -------- Editable Results UI -------- */

.rows { margin-bottom: 1rem; }

.row {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin: .15rem 0;
}

/* A/B/C label */
.wp-label {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #eee;
  color: #444;
  font-weight: 700;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 22px;
}

.row input[type="text"] {
  flex: 1;
  padding: .45rem .6rem;
}

/* icon buttons */
.btn-icon {
  width: 32px;
  height: 32px;
  line-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  cursor: pointer;
  user-select: none;
}

/* minus: red, round */
.btn-del  { background: var(--btn-red); }
.btn-del:hover  { background: var(--btn-red-hover); }

/* plus: blue “+” only (no background), subtle by default */
.btn-add  {
  width: auto;
  height: auto;
  line-height: 1;
  background: transparent;
  color: #aaa;           /* subtle default */
  border: none;
  font-size: 18px;
  padding: 0;
  cursor: pointer;
}
.btn-add:hover  { color: var(--btn-blue); }

/* plus between rows */
.between {
  display: flex;
  justify-content: center;
  margin: 0; /* minimal spacing */
}

.muted { color:#666; font-size:.9em; }

/* Toolbar under the list */
.toolbar {
  display:flex;
  gap:.5rem;
  flex-wrap:wrap;
  margin:.5rem 0 1rem;
}

#reverse-btn {
  background: var(--light);
  color: var(--dark);
}
#reverse-btn:hover { background: var(--border); }

/* Map box */
#map {
  width: 100%;
  height: 520px;
  border: 1px solid var(--light);
  border-radius: var(--radius);
  margin-top: 0;
}

/* Totals panel under the map */
.route-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  margin-top: .75rem;
  padding: .75rem;
  border: 1px solid var(--light);
  border-radius: var(--radius);
  background: #fafafa;
}
.route-stats .stat { display:flex; flex-direction: column; }
.route-stats .stat-label { color:#666; font-size:.9rem; }
.route-stats .stat-value { font-weight: 600; font-size: 1.05rem; }

/* Modal (save dialog) */
.modal-backdrop[hidden] { display: none !important; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: grid;
  place-items: center;
  z-index: 9999;
}
.modal {
  width: 100%;
  max-width: 520px;
  background: #fff;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.modal h2 { margin-top: 0; }
.modal label { margin: .5rem 0; }
.modal input[type="text"] { margin-top: .25rem; }
.modal-actions {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
  margin-top: .75rem;
}

.topnav {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--light);
  padding-bottom: 0.5rem;
}

.topnav a {
  text-decoration: none;
  color: var(--dark);
  font-weight: 500;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
}

.topnav a:hover {
  background: var(--light);
}

.topnav a.active {
  background: var(--btn-blue);
  color: #fff;
}


/* Optional: add spacing above map when stacked */
@media (max-width: 900px) {
  #map { margin-top: 1rem; }
}

/* ----- Routes table styles ----- */
.routes-table { width: 100%; border-collapse: collapse; }
.routes-table th, .routes-table td {
  border: 1px solid var(--light);
  padding: .55rem .6rem;
  vertical-align: top;
}
.routes-table th { background: #fafafa; text-align: left; }
.routes-actions { display:flex; gap:.5rem; align-items:center; }
.routes-topbar { display:flex; justify-content:space-between; align-items:center; margin-bottom: 1rem; }
.routes-topbar a.button {
  text-decoration:none;
  background: var(--dark);
  color:#fff;
  padding:.5rem .8rem;
  border-radius:6px;
}
.routes-topbar a.button:hover { background: var(--fg); }
.wrap { word-break: break-word; }

/* inline button styles for per-route actions */
.inline-btn {
  text-decoration: none;
  background: var(--btn-blue);
  color: #fff;
  padding: .35rem .6rem;
  border-radius: 6px;
  display: inline-block;
}
.inline-btn:hover { background: var(--btn-blue-hover); }

.inline-btn.secondary {
  background: #888;
}
.inline-btn.secondary:hover {
  background: #666;
}

.inline-btn.danger {
  background: var(--btn-red);
}
.inline-btn.danger:hover {
  background: var(--btn-red-hover);
}

/* simple notice style for flash messages */
.notice { color: #0a7; margin-bottom: 1rem; }
