:root {
  --accent: #0ea5e9;
  --accent-dark: #0369a1;
  --accent-soft: #e0f2fe;
  --ink: #1f2937;
  --muted: #64748b;
  --line: #d8e2ed;
  --surface: #ffffff;
  --page: #f4f8fb;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  overflow: hidden;
}

.app-header {
  height: 88px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(280px, 560px) minmax(220px, 1fr);
  align-items: center;
  gap: 18px;
  padding: 14px 10.5vw;
  background: rgba(255, 255, 255, 0.94);
  border-top: 4px solid #b7d4be;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
  position: relative;
  z-index: 3;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 800;
  min-width: 0;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 8px 22px rgba(14, 165, 233, 0.14);
}

.brand-mark img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.brand-text {
  font-size: 1.18rem;
  letter-spacing: 0;
}

.brand-text span:first-child {
  color: #0284c7;
}

.brand-text strong {
  color: #f97316;
}

.header-title {
  text-align: center;
}

.header-title h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
}

.header-title h1::before {
  content: none;
}

.header-title p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.dropdown {
  justify-self: end;
}

.btn-tools,
.icon-btn {
  border: 1px solid #bfdbfe;
  background: #fff;
  color: var(--ink);
  border-radius: 13px;
  font-weight: 700;
  padding: 10px 16px;
  box-shadow: 0 8px 20px rgba(3, 105, 161, 0.06);
}

.btn-tools i {
  margin-right: 8px;
  color: var(--accent-dark);
}

.studio-shell {
  height: calc(100vh - 88px);
  display: grid;
  grid-template-columns: minmax(270px, 320px) 1fr minmax(280px, 340px);
  gap: 14px;
  padding: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
  overflow: auto;
}

.layers-panel,
.feature-panel {
  padding: 16px;
}

.layers-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-hero {
  padding: 14px;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  background: linear-gradient(180deg, #f0f9ff 0%, #ffffff 100%);
  box-shadow: 0 10px 20px rgba(14, 165, 233, 0.08);
}

.sidebar-hero h2 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 900;
  color: var(--ink);
}

.sidebar-hero p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.sidebar-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.035);
}

.section-heading {
  margin-bottom: 12px;
}

.section-heading h3 {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 900;
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.add-data-group + .add-data-group {
  margin-top: 13px;
  padding-top: 13px;
  border-top: 1px solid #e2e8f0;
}

.group-label {
  display: grid;
  gap: 2px;
  margin-bottom: 8px;
}

.group-label span {
  font-size: 0.82rem;
  font-weight: 900;
  color: var(--ink);
}

.group-label small {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.3;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
}

.panel-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  color: var(--accent-dark);
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 0;
}

.data-action-btn,
.btn-primary-soft {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  background: #f0f9ff;
  color: var(--accent-dark);
  border: 1px solid #bae6fd;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.84rem;
  padding: 9px 10px;
  text-align: left;
  box-shadow: 0 5px 12px rgba(14, 165, 233, 0.05);
  transition: border-color 0.16s ease, background-color 0.16s ease, transform 0.16s ease;
}

.data-action-btn:hover,
.btn-primary-soft:hover {
  border-color: var(--accent);
  background: #e0f2fe;
  color: var(--accent-dark);
  transform: translateY(-1px);
}

.data-icon {
  width: 24px;
  min-width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  background: #ffffff;
  border: 1px solid #dbeafe;
  font-weight: 900;
}

.service-action {
  width: 100%;
  justify-content: center;
  min-height: 48px;
}

.btn-primary,
.btn-outline-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.btn-outline-primary {
  color: var(--accent-dark);
  border-color: #7dd3fc;
}

.map-stage {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #dde7ef;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

#map {
  width: 100%;
  height: 100%;
}

.map-toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.map-toolbar label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
}

.map-toolbar select {
  min-width: 180px;
}

.layer-list {
  display: grid;
  gap: 10px;
}

.layer-card {
  border: 1px solid #dbe7f2;
  border-radius: 8px;
  padding: 11px;
  background: #fff;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.035);
  cursor: pointer;
  transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

.layer-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 10px 20px rgba(14, 165, 233, 0.08);
}

.layer-card.is-selected {
  border-color: var(--accent);
  background: #f0f9ff;
  box-shadow: 0 10px 22px rgba(14, 165, 233, 0.12);
}

.layer-card.sortable-ghost {
  opacity: 0.55;
}

.layer-card.sortable-chosen {
  border-color: var(--accent);
}

.layer-main {
  display: grid;
  grid-template-columns: auto auto auto 1fr;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.layer-drag-handle {
  width: 24px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  color: #64748b;
  cursor: grab;
  font-weight: 900;
  line-height: 1;
  user-select: none;
}

.layer-drag-handle:hover {
  background: #e0f2fe;
  color: #0369a1;
}

.layer-drag-handle:active {
  cursor: grabbing;
}

.layer-type-icon {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: #e0f2fe;
  border: 1px solid #bae6fd;
  font-size: 0.98rem;
}

.layer-text {
  min-width: 0;
}

.layer-name {
  display: block;
  font-weight: 800;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.layer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 5px;
}

.layer-badge,
.layer-status,
.selected-badge {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #475569;
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
}

.kind-raster {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.kind-service {
  border-color: #bae6fd;
  background: #f0f9ff;
  color: #0369a1;
}

.layer-status {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #15803d;
}

.layer-status.is-hidden {
  border-color: #e2e8f0;
  background: #f8fafc;
  color: #64748b;
}

.selected-badge {
  border-color: #7dd3fc;
  background: #e0f2fe;
  color: #0369a1;
}

.layer-actions {
  display: grid;
  grid-template-columns: repeat(6, 30px);
  gap: 5px;
  margin-top: 10px;
}

.layer-actions button {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1;
}

.raster-opacity {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.raster-opacity .form-range {
  margin: 0;
}

.feature-info {
  border: 1px dashed #93c5fd;
  border-radius: 8px;
  min-height: 140px;
  padding: 12px;
  background: #fbfdff;
  overflow: auto;
}

.empty-state {
  color: var(--muted);
  margin: 0;
  font-size: 0.9rem;
}

.layer-empty-state {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px dashed #93c5fd;
  border-radius: 8px;
  background: #f8fcff;
}

.layer-empty-state strong {
  color: var(--ink);
  font-size: 0.9rem;
}

.layer-empty-state span,
.layer-empty-state small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.sidebar-help-strip {
  margin-top: auto;
  display: grid;
  gap: 3px;
  padding: 11px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.sidebar-help-strip strong {
  color: var(--accent-dark);
}

.selected-info-label {
  margin-bottom: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 0.78rem;
  font-weight: 800;
}

.modal-content {
  border: 0;
  border-radius: 8px;
}

#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.72);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
}

#custom-alert {
  z-index: 10000;
  min-width: 280px;
}

div.dt-buttons {
  margin-bottom: 10px;
}

@media (max-width: 1100px) {
  .app-header {
    padding: 12px 18px;
    grid-template-columns: 1fr auto;
  }

  .header-title {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .app-header {
    height: auto;
  }

  .studio-shell {
    height: calc(100vh - 126px);
    grid-template-columns: 270px 1fr;
  }

  .feature-panel {
    display: none;
  }
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .studio-shell {
    height: auto;
    grid-template-columns: 1fr;
  }

  .map-stage {
    height: 62vh;
    min-height: 420px;
  }

  .feature-panel {
    display: block;
  }

  .map-toolbar {
    left: 8px;
    right: 8px;
  }
}
