:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-soft: #f8f9fb;
  --ink: #14161a;
  --muted: #6b7280;
  --muted-2: #9aa0a6;
  --line: #e1e4e8;
  --line-strong: #cfd5dd;
  --accent: #ff7a00;
  --accent-soft: #fff0df;
  --accent-blue: #4267d8;
  --danger: #b73535;
  --shadow-soft: 0 8px 24px rgba(18, 24, 38, 0.08);
  --shadow-card: 0 2px 10px rgba(18, 24, 38, 0.05);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-width: 350px;
}

* { box-sizing: border-box; }

html, body, #root { min-height: 100%; }

body {
  margin: 0;
  font-family: Inter, "Source Sans 3", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
  background: linear-gradient(180deg, #fafafa 0%, var(--bg) 100%);
}

button,
select,
input { font: inherit; }

button { color: inherit; }

.app {
  min-height: 100vh;
  display: flex;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 auto;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 5;
  overflow: auto;
  background: rgba(255, 255, 255, 0.96);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  transition: width 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.sidebar.closed {
  width: 0;
  min-width: 0;
  overflow: visible;
  background: transparent;
  border-right-color: transparent;
  box-shadow: none;
}

.sidebar.closed .sidebar-content,
.sidebar.closed .brand,
.sidebar.closed .brand-text {
  display: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 18px 16px;
}

.sidebar.closed .sidebar-header {
  position: fixed;
  left: 10px;
  top: 50vh;
  z-index: 50;
  display: block;
  padding: 0;
  transform: translateY(-50%);
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo { display: none; }

.brand h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: none;
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.icon-btn {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.icon-btn:hover {
  background: var(--surface-soft);
  border-color: var(--muted-2);
}

.sidebar.closed .icon-btn {
  width: 24px;
  height: 32px;
  border-radius: 999px;
  border-color: rgba(207, 213, 221, 0.9);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 6px 18px rgba(18, 24, 38, 0.16);
  color: var(--ink);
  font-size: 0;
}

.sidebar.closed .icon-btn::before {
  content: "›";
  font-size: 17px;
  font-weight: 600;
  line-height: 1;
}

.sidebar.closed .icon-btn:hover {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 8px 22px rgba(18, 24, 38, 0.2);
}

.sidebar.closed + .content {
  padding-left: 22px;
}

.sidebar-content {
  padding: 0 12px 22px;
}

/* Accordion sections */
.control-section {
  margin: 0 0 10px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.section-title {
  width: 100%;
  border: 0;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
}

.section-title:hover {
  background: var(--surface-soft);
}

.chev {
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  display: inline-block;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.section-body {
  padding: 2px 16px 16px;
  border-top: 1px solid var(--line);
}

.field {
  margin: 14px 0 0;
}

.field label,
.range-field label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.field label b,
.range-field b {
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
}

select,
input[type="text"],
input[type="number"] {
  width: 100%;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 450;
}

select:focus,
input[type="text"]:focus,
input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Pills */
.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.pill {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: #303846;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.15;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(18, 24, 38, 0.04);
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.pill:hover {
  background: var(--surface-soft);
  border-color: var(--muted-2);
}

.pill.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #9a4a00;
}

.mini-hint,
.hint {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
}

.mini-hint {
  margin: 7px 0 0;
}

.sidebar-note {
  margin: 15px 4px 0;
}

.primary { display: none; }

/* Range input */
input[type="range"] {
  width: 100%;
  height: 18px;
  margin: 1px 0 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: #e8ebef;
}

input[type="range"]::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: #e8ebef;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  margin-top: -6px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 2px 7px rgba(255, 122, 0, 0.35);
}

input[type="range"]::-moz-range-thumb {
  width: 17px;
  height: 17px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 2px 7px rgba(255, 122, 0, 0.35);
}

/* Main content */
.content {
  flex: 1;
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.topbar h1 {
  margin: 0 0 5px;
  font-size: 21px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.topbar p {
  max-width: 880px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status {
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 6px 10px;
  font-size: 12px;
}

/* Map grid + cards */
.map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(390px, 1fr));
  gap: 16px;
}

.map-card {
  min-height: 390px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
}

.map-card.working-map {
  border-color: rgba(255, 122, 0, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 122, 0, 0.12), var(--shadow-soft);
}

.map-card.working-map .map-head {
  background: linear-gradient(90deg, rgba(255, 122, 0, 0.08), rgba(255, 255, 255, 0));
}

.map-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 9px;
  border-bottom: 1px solid var(--line);
}

.map-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.25;
  font-weight: 700;
}

.map-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
}

.pin-map,
.close {
  flex: 0 0 auto;
  height: 27px;
  min-width: 27px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.pin-map {
  border: 1px solid rgba(255, 122, 0, 0.55);
  background: var(--accent-soft);
  color: #9a4a00;
  padding: 0 9px;
}

.pin-map:hover {
  background: #ffe2c2;
}

.pin-map:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.close {
  display: grid;
  place-items: center;
  border: 0;
  background: #fff1f1;
  color: var(--danger);
}

.close:hover {
  background: #ffe3e3;
}

.map-wrap {
  position: relative;
  flex: 1;
  min-height: 330px;
}

.map-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Compact floating legend */
.legend {
  position: absolute;
  left: 9px;
  bottom: 9px;
  /*width: 100%;*/
  /*padding: 6px 7px;*/
  /*border: 1px solid rgba(225, 228, 232, 0.92);*/
  /*border-radius: 9px;*/
  background: rgba(255, 255, 255, 0.9);
  /*box-shadow: 0 3px 10px rgba(18, 24, 38, 0.08);*/
  color: #343b45;
  font-size: 10px;
  line-height: 1.15;
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: row;
  gap: 4px;
  flex-wrap: wrap;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 2px 0;
  white-space: nowrap;
}

.swatch {
  width: 12px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 2px;
}

.empty {
  min-height: 420px;
  display: grid;
  place-items: center;
  padding: 40px;
  border: 1px dashed var(--line-strong);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
}

.tooltip {
  position: fixed;
  z-index: 20;
  display: none;
  max-width: 260px;
  pointer-events: none;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(20, 24, 30, 0.94);
  color: #fff;
  font-size: 12px;
  line-height: 1.35;
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
  }

  .content {
    padding-left: 72px;
  }

  .sidebar.closed + .content {
    padding-left: 22px;
  }

  .topbar {
    flex-direction: column;
  }

  .map-grid {
    grid-template-columns: 1fr;
  }
}
