:root {
  --teal: #0f6e56;
  --teal-bright: #1d9e75;
  --teal-soft: #e1f5ee;
  --ink: #14201c;
  --ink-soft: #4a5a54;
  --line: #e2e8e4;
  --bg: #f6f8f7;
  --surface: #ffffff;
  --via: #1d9e75;
  --shaping: #d8873a;
  --poi: #3b73c4;
  --danger: #b4402d;
  --radius: 10px;
  --shadow: 0 6px 24px rgba(20, 32, 28, 0.10);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; height: 60px;
  background: var(--ink); color: #fff;
  flex: 0 0 auto;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand .mark {
  width: 14px; height: 14px; border-radius: 3px;
  background: var(--teal-bright);
  transform: skewX(-12deg);
  display: inline-block; align-self: center;
}
.brand .name { font-size: 19px; font-weight: 600; letter-spacing: 0.3px; }
.brand .tag { font-size: 13px; color: #9fb8ae; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.layout { flex: 1 1 auto; display: flex; min-height: 0; }
.sidebar {
  width: 340px; flex: 0 0 340px;
  background: var(--surface); border-right: 1px solid var(--line);
  overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 16px;
}
.panel { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: var(--surface); }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.panel-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--ink-soft); margin: 0; }
.head-actions { display: flex; gap: 6px; }
.etappes-panel { flex: 0 0 auto; }

.muted { color: var(--ink-soft); font-size: 13px; }
.hint { color: var(--ink-soft); font-size: 12px; line-height: 1.5; margin: 0 0 10px; }
.hint b { color: var(--ink); font-weight: 600; }

.map-wrap { flex: 1 1 auto; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; }

.route-badge {
  position: absolute; z-index: 500; left: 12px; bottom: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 12px; font-size: 13px; box-shadow: var(--shadow);
}
.route-badge b { color: var(--teal); }
.route-badge .stats { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.route-badge .sep { color: var(--line); }
.route-badge .spark { display: block; margin-top: 6px; }

/* Rit-instellingen */
.ride-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.ride-value { color: var(--teal); font-weight: 600; }
.slider { width: 100%; accent-color: var(--teal); margin: 2px 0; }
.ride-hint { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-soft); margin-bottom: 12px; }
.avoid-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; font-size: 13px; margin-bottom: 12px; }
.avoid-grid label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.avoid-grid input { accent-color: var(--teal); }
.roundtrip { border-top: 1px solid var(--line); padding-top: 10px; }
.rt-head { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.rt-controls { display: flex; align-items: center; gap: 8px; }
.rt-controls input { width: 74px; font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }

/* Buttons */
.btn {
  font: inherit; font-size: 13px; cursor: pointer;
  border-radius: 8px; border: 1px solid var(--line);
  padding: 8px 14px; background: var(--surface); color: var(--ink);
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: #c9d4cf; }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-bright); border-color: var(--teal-bright); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

select {
  font: inherit; font-size: 13px; padding: 7px 10px; border-radius: 8px;
  border: 1px solid #3a4a44; background: #22322c; color: #fff;
}

/* Etappes */
.etappe-list { display: flex; flex-direction: column; gap: 6px; }
.etappe-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
  font-size: 14px;
}
.etappe-item:hover { border-color: var(--teal-bright); }
.etappe-item.active { background: var(--teal-soft); border-color: var(--teal-bright); }
.etappe-item .day { font-size: 11px; color: var(--ink-soft); }
.etappe-name { display: flex; align-items: center; gap: 7px; min-width: 0; }

/* Drag & drop */
.drag-handle {
  flex: 0 0 auto; cursor: grab; color: #b7c4be; font-size: 13px; line-height: 1;
  user-select: none; letter-spacing: -1px;
}
.drag-handle:hover { color: var(--ink-soft); }
.drag-handle:active { cursor: grabbing; }
.dragging { opacity: 0.45; }
.drag-over { border-color: var(--teal-bright); box-shadow: inset 0 2px 0 var(--teal-bright); }

/* Waypoints */
.wp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.wp-item {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.wp-top { display: flex; align-items: center; gap: 8px; }
.wp-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.wp-dot.via { background: var(--via); }
.wp-dot.shaping { background: var(--shaping); }
.wp-dot.poi { background: var(--poi); }
.wp-name { font-size: 13px; flex: 1 1 auto; border: none; background: transparent; color: var(--ink); padding: 2px 0; }
.wp-name:focus { outline: none; border-bottom: 1px solid var(--teal-bright); }
.wp-actions { display: flex; gap: 4px; }
.type-toggle { display: flex; gap: 4px; }
.type-btn {
  font-size: 11px; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; color: var(--ink-soft);
}
.type-btn.active.via { background: var(--via); border-color: var(--via); color: #fff; }
.type-btn.active.shaping { background: var(--shaping); border-color: var(--shaping); color: #fff; }
.type-btn.active.poi { background: var(--poi); border-color: var(--poi); color: #fff; }
.icon-btn {
  border: none; background: transparent; cursor: pointer; color: var(--ink-soft);
  font-size: 15px; line-height: 1; padding: 2px 4px;
}
.icon-btn:hover { color: var(--danger); }

.range-row input { width: 60px; font: inherit; font-size: 13px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; text-align: right; }
.range-row { margin-top: 4px; }

/* Weer */
.weather-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.weather-day {
  flex: 0 0 auto; min-width: 62px; text-align: center; border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 6px; font-size: 12px; background: var(--surface);
}
.weather-day .wd-date { color: var(--ink-soft); font-size: 11px; }
.weather-day .wd-emoji { font-size: 18px; line-height: 1.4; }
.weather-day .wd-temp { font-weight: 600; }
.weather-day .wd-temp .lo { color: var(--ink-soft); font-weight: 400; }
.weather-day .wd-sub { color: var(--ink-soft); font-size: 10px; }
.weather-day.wet { border-color: var(--poi); }
.star-row { font-size: 12px; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.star-row select { background: var(--surface); color: var(--ink); border: 1px solid var(--line); padding: 4px 6px; }
.poi-result .dist { color: var(--teal); font-size: 11px; font-weight: 600; margin-left: 6px; }
.route-badge .warn-fuel { display: block; margin-top: 5px; color: var(--danger); font-size: 12px; }

/* POI zoeken */
.poi-toggle { font-size: 12px; color: var(--ink-soft); display: flex; align-items: center; gap: 5px; cursor: pointer; }
.poi-toggle input { accent-color: var(--poi); }
.poi-search { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.poi-results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; max-height: 220px; overflow-y: auto; }
.poi-result {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; font-size: 13px;
}
.poi-result:hover { border-color: var(--poi); }
.poi-result-main { cursor: pointer; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.poi-result-main .muted { font-size: 12px; }
.poi-result button { flex: 0 0 auto; }

/* Zoekkandidaat op de kaart (nog niet toegevoegd) */
.poi-candidate {
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 3px solid var(--poi);
  box-shadow: 0 1px 4px rgba(0,0,0,.35); cursor: pointer;
}

/* Export panel */
.export-panel {
  position: fixed; right: 20px; bottom: 20px; width: 380px; z-index: 1000;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.export-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.export-head h2 { font-size: 15px; margin: 0; }
.report { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; max-height: 260px; overflow-y: auto; }
.report-stat { font-size: 14px; font-weight: 600; color: var(--teal); padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.report-line { display: flex; gap: 8px; font-size: 13px; line-height: 1.4; align-items: flex-start; }
.report-line .mk { flex: 0 0 auto; font-weight: 700; }
.report-line.ok .mk { color: var(--teal-bright); }
.report-line.warn .mk { color: var(--shaping); }
.export-actions { display: flex; gap: 8px; }

/* Auth-paneel */
.auth-panel {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(400px, 92vw); z-index: 1600;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.auth-field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--ink-soft); margin-bottom: 12px; }
.auth-field input { font: inherit; font-size: 14px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); }
.auth-field input:focus { outline: none; border-color: var(--teal-bright); }
.auth-error { color: var(--danger); font-size: 13px; margin-bottom: 10px; }
.account-info { font-size: 14px; margin-bottom: 14px; }
.account-info .plan { display: inline-block; margin-top: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.account-info .plan.free { background: var(--line); color: var(--ink-soft); }
.account-info .plan.premium { background: var(--teal-soft); color: var(--teal); }
#accountBtn { color: #fff; border-color: #3a4a44; }
#accountBtn:hover { border-color: var(--teal-bright); }

/* Gratis GPX-dokter (tool.html) */
.tool-main { max-width: 720px; margin: 0 auto; padding: 40px 20px; }
.tool-hero h1 { font-size: 28px; line-height: 1.2; margin: 0 0 12px; }
.tool-hero p { color: var(--ink-soft); font-size: 15px; line-height: 1.6; margin: 0 0 24px; }
.tool-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; background: var(--surface);
  display: flex; flex-direction: column; gap: 14px; align-items: flex-start; box-shadow: var(--shadow); }
.tool-device { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.tool-device select { align-self: flex-start; background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.tool-result { margin-top: 28px; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; background: var(--surface); }
.tool-result .export-head { margin-bottom: 12px; }
.tool-upsell { margin: 16px 0 0; font-size: 13px; color: var(--ink-soft); }
.tool-upsell a { color: var(--teal); font-weight: 600; text-decoration: none; }

/* Tour-overzicht */
.summary-panel {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(560px, 92vw); max-height: 82vh; overflow-y: auto; z-index: 1500;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.summary-totals {
  display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 14px;
  padding: 12px 14px; background: var(--teal-soft); border-radius: 8px;
}
.summary-totals .tot b { display: block; font-size: 20px; color: var(--teal); }
.summary-totals .tot span { font-size: 12px; color: var(--ink-soft); }
.summary-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.summary-table th { text-align: left; color: var(--ink-soft); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.4px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.summary-table td { padding: 8px; border-bottom: 1px solid var(--line); }
.summary-table tbody tr:hover { background: var(--bg); }
.summary-table .num { color: var(--teal); font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 13px; z-index: 2000; box-shadow: var(--shadow);
}

/* Leaflet marker labels */
.wp-marker {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.3); display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 700;
}
.wp-marker.via { background: var(--via); }
.wp-marker.shaping { background: var(--shaping); }
.wp-marker.poi { background: var(--poi); }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: 0 0 auto; max-height: 45vh; }
  .export-panel { left: 12px; right: 12px; width: auto; }
}
