html, body {
  height: 100%;
  margin: 0;
  font: 14px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: #1f2933;
  background: #f8fafc;
}

#layout {
  display: flex;
  height: 100%;
}

#control-panel {
  width: 340px;
  min-width: 300px;
  max-width: 380px;
  box-sizing: border-box;
  padding: 18px;
  background: #ffffff;
  border-right: 1px solid #e2e8f0;
  overflow-y: auto;
}

#control-panel h1 {
  margin: 0 0 10px;
  font-size: 20px;
  color: #0f172a;
}

.panel-section {
  margin-bottom: 20px;
}

.panel-section h2 {
  margin: 0 0 10px;
  font-size: 15px;
  color: #1e293b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.summary-card {
  background: #f1f5f9;
  border-radius: 8px;
  padding: 12px;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.04);
}

.summary-card.warning {
  background: #fff1f2;
  color: #b91c1c;
}

.summary-card .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(15, 23, 42, 0.6);
}

.summary-card.warning .label {
  color: #991b1b;
}

.summary-card .value {
  font-size: 26px;
  font-weight: 600;
  margin-top: 2px;
}

.summary-card .meta {
  font-size: 12px;
  color: rgba(15, 23, 42, 0.7);
  margin-top: 6px;
}

.status-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}

.status-filters label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

button[type="button"] {
  appearance: none;
  border: 1px solid #cbd5f5;
  background: #e2e8f0;
  color: #0f172a;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

button[type="button"]:hover {
  background: #d1dce8;
  border-color: #94a3b8;
}

button[type="button"]:active {
  background: #cbd5f5;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.file-upload {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: rgba(15, 23, 42, 0.7);
}

.file-upload input[type="file"] {
  font-size: 12px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  background: #e0f2f1;
  border: 1px solid #80cbc4;
  color: #00695c;
}

.icon-button:hover {
  background: #b2dfdb;
  border-color: #4db6ac;
}

.icon-button.danger {
  background: #fdecea;
  border-color: #f5aba1;
  color: #c62828;
}

.icon-button.danger:hover {
  background: #fbd0c9;
  border-color: #ef8f82;
}

.planner-section {
  border-top: 1px solid #e2e8f0;
  padding-top: 12px;
}

.planner-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.planner-form {
  border: 1px solid #cbd5f5;
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
  margin-bottom: 12px;
}

.planner-form.hidden {
  display: none;
}

.planner-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.planner-field label {
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(15, 23, 42, 0.6);
}

.planner-field input[type="text"],
.planner-field input[type="number"],
.planner-field select {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
}

.planner-field input[type="text"]:focus,
.planner-field input[type="number"]:focus,
.planner-field select:focus {
  outline: 2px solid #94a3b8;
}

.planner-help {
  font-size: 12px;
  color: rgba(15, 23, 42, 0.6);
}

.core-grid .planner-help {
  grid-column: 1 / -1;
  font-style: italic;
}

.core-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 6px;
}

.core-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 12px;
  background: #ffffff;
  cursor: pointer;
}

.core-chip input {
  cursor: pointer;
}

.core-chip .swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.1);
}

.core-chip.free {
  border-color: #81c784;
  background: #e8f5e9;
}

.core-chip.reserved {
  border-color: #ffb74d;
  background: #fff3e0;
}

.core-chip.planned {
  border-color: #64b5f6;
  background: #e3f2fd;
}

.core-chip.used {
  border-color: #ef9a9a;
  background: #ffebee;
  text-decoration: line-through;
}

.core-chip.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.planner-routes-empty {
  font-size: 13px;
  color: rgba(15, 23, 42, 0.6);
}

.planner-routes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.planner-route-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.02);
}

.planner-route-card.editing {
  border-color: #ffe082;
  background: #fff8e1;
}

.planner-route-card.editing .planner-route-header span:last-child {
  color: #ef6c00;
}

.planner-route-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: #0f172a;
}

.planner-route-meta {
  font-size: 12px;
  margin-top: 4px;
  color: rgba(15, 23, 42, 0.7);
}

.planner-route-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.planner-route-actions button {
  font-size: 12px;
  padding: 4px 8px;
}

.secondary {
  background: #f1f5f9;
  border-color: #cbd5f5;
  color: #1e293b;
}

.secondary:hover {
  background: #e2e8f0;
}

.status-section {
  background: #f8fafc;
  border-radius: 6px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
}

#status-message {
  font-size: 13px;
  color: #334155;
}

#map {
  flex: 1;
  height: 100%;
}

.legend {
  background: white;
  padding: 8px 10px;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  line-height: 1.4;
  font: 12px/1.2 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
.legend .title {
  font-weight: 600;
  margin-bottom: 4px;
}
.legend .row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend .swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  display: inline-block;
}

@media (max-width: 960px) {
  #layout {
    flex-direction: column;
  }

  #control-panel {
    width: 100%;
    max-width: none;
    border-right: none;
    border-bottom: 1px solid #e2e8f0;
  }

  #map {
    height: calc(100% - 300px);
    min-height: 320px;
  }
}
