html, body { margin: 0; height: 100%; font-family: system-ui, sans-serif; }
#map { position: absolute; inset: 0 320px 0 0; }

#panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: 320px;
  box-sizing: border-box; padding: 12px 16px; overflow-y: auto;
  background: #fafafa; border-left: 1px solid #ddd; font-size: 14px;
}
#panel h1 { font-size: 18px; margin: 0 0 12px; }
#panel h2 { font-size: 14px; margin: 16px 0 6px; }
#panel section { margin-bottom: 12px; }
#panel select { margin-left: 6px; max-width: 200px; }

.buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.buttons button { padding: 6px; cursor: pointer; }

#log { padding-left: 18px; margin: 0; }
#log li { margin-bottom: 4px; }
#clicked { white-space: pre-wrap; font-size: 12px; background: #fff; border: 1px solid #ddd; padding: 6px; margin: 0; }

.popup h3 { margin: 0 0 4px; font-size: 14px; }
.popup dl { margin: 4px 0; font-size: 12px; display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; }
.popup dt { color: #666; }
.popup dd { margin: 0; word-break: break-all; }
.popup button { margin-top: 6px; }
#legend { font-size: 13px; }
.legend-group { font-weight: 600; margin: 8px 0 2px; }
.legend-row { display: flex; align-items: center; gap: 6px; padding: 1px 0; cursor: pointer; }
.legend-row img { width: 20px; height: 20px; }
.legend-row.empty { color: #999; }
#status { font-size: 12px; color: #666; margin-top: 4px; }
#status.ok { color: #1e7d32; }

@media (max-width: 700px) {
  #map { inset: 0 0 45% 0; }
  #panel { top: 55%; width: 100%; border-left: 0; border-top: 1px solid #ddd; }
}

/* Lägen och historik */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 12px; }
.modes button { padding: 6px; cursor: pointer; border: 1px solid #ccc; background: #fff; border-radius: 4px; }
.modes button.active { background: #1e6fd9; color: #fff; border-color: #1e6fd9; }
#history-status { font-size: 12px; color: #666; margin-bottom: 6px; }
.trip-group { font-weight: 600; margin: 10px 0 4px; }
.trip { display: block; width: 100%; text-align: left; padding: 6px 8px; margin-bottom: 4px; cursor: pointer;
        border: 1px solid #ddd; border-radius: 4px; background: #fff; }
.trip:hover { border-color: #1e6fd9; }
.trip .title { font-weight: 600; }
.trip .meta { font-size: 12px; color: #555; }
button.link { border: 0; background: none; color: #1e6fd9; cursor: pointer; padding: 0; margin-bottom: 6px; }
#trip-title { margin: 4px 0; font-size: 16px; }
#trip-facts { font-size: 12px; color: #555; margin-bottom: 8px; }
#trip-detail details { margin-bottom: 8px; font-size: 13px; }
#trip-detail input, #trip-detail textarea { width: 100%; box-sizing: border-box; margin: 4px 0; font: inherit; }
#trip-days { list-style: none; padding: 0; margin: 6px 0; }
.day { display: grid; grid-template-columns: 82px 1fr auto; gap: 6px; align-items: baseline; width: 100%;
       text-align: left; padding: 3px 6px; border: 0; border-radius: 3px; background: none; cursor: pointer; font: inherit; font-size: 13px; }
.day:hover { background: #eef1f5; }
.day.active { background: #dde9fb; }
.day-date { color: #555; white-space: nowrap; }
.day-where { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-night { color: #888; }
.day-km { color: #555; font-size: 12px; white-space: nowrap; }
#btn-whole-trip { display: block; font-weight: 600; margin-bottom: 2px; }
.trip-year { font-weight: 700; font-size: 13px; color: #444; margin: 14px 0 4px; padding-bottom: 2px; border-bottom: 1px solid #ccc; }
.trip-legend { font-size: 12px; color: #666; margin-bottom: 4px; white-space: pre; }
.trip-symbol { margin-right: 6px; }
.day-week { font-size: 11px; color: #888; text-transform: uppercase; letter-spacing: 0.04em;
            margin: 8px 0 2px; padding: 0 6px 2px; border-bottom: 1px solid #e3e3e3; }
.day-stops { list-style: none; margin: 0 0 6px; padding: 0; font-size: 12px; color: #555; }
.day-stops li { display: grid; grid-template-columns: 82px 1fr auto; gap: 6px; align-items: baseline;
                padding: 1px 6px; border-radius: 3px; cursor: pointer; }
.day-stops .day-date, .day-stops .day-km { font-size: 11px; color: #777; }
.day-stops li:hover { background: #eef1f5; }
