*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --sidebar-width: 320px;
  --detail-width: 360px;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #d8dce3;
  --text: #1a1d23;
  --muted: #5c6573;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --log-bg: #0f172a;
  --log-text: #e2e8f0;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.25s ease, min-width 0.25s ease, max-height 0.25s ease;
}

#app.sidebar-collapsed #sidebar {
  width: 0;
  min-width: 0;
  border-right: none;
  overflow: hidden;
}

.sidebar-toggle {
  flex-shrink: 0;
  width: 1.35rem;
  margin: 0;
  padding: 0;
  border: none;
  border-right: 1px solid var(--border);
  background: #eef1f6;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-toggle:hover {
  background: #e2e8f0;
  color: var(--text);
}

.sidebar-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 2;
}

.sidebar-toggle-icon {
  font-size: 1.1rem;
  line-height: 1;
  font-weight: 700;
}

.sidebar-toggle-icon::before {
  content: '‹';
}

#app.sidebar-collapsed .sidebar-toggle-icon::before {
  content: '›';
}

#sidebar header {
  padding: 1rem 1rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

#sidebar h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.btn-help {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border-radius: 50%;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  border-color: var(--accent);
  background: var(--surface);
}

.btn-help:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
}

#sidebar .subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem 1rem;
}

.section {
  margin-bottom: 1.25rem;
}

.section h2 {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}

label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
  color: var(--muted);
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="file"] {
  width: 100%;
  font-size: 0.875rem;
}

input[type="text"],
input[type="number"],
input[type="password"] {
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

input[type="text"]:disabled,
input[type="number"]:disabled,
input[type="password"]:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  background: var(--bg);
}

input[type="file"] {
  font-size: 0.8rem;
}

.btn-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

button {
  font: inherit;
  font-size: 0.875rem;
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  color: var(--text);
}

button:hover:not(:disabled) {
  background: var(--bg);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

button.danger {
  color: var(--danger);
  border-color: var(--danger);
}

#stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

#stats .stat-value {
  font-weight: 600;
  text-align: right;
}

#progress-wrap {
  margin-top: 0.5rem;
}

#progress-wrap.hidden {
  display: none;
}

#progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s ease;
}

#progress-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

#status-log {
  background: var(--log-bg);
  color: var(--log-text);
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 0.7rem;
  line-height: 1.45;
  padding: 0.5rem;
  border-radius: 6px;
  height: 180px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-entry {
  margin-bottom: 0.15rem;
}

.log-entry.error { color: #fca5a5; }
.log-entry.success { color: #86efac; }
.log-entry.info { color: #93c5fd; }
.log-entry.muted { color: #94a3b8; }

#workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

#main {
  flex: 1;
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
}

#table-resizer {
  height: 6px;
  cursor: row-resize;
  background: var(--border);
  flex-shrink: 0;
}

#table-resizer:hover {
  background: var(--text);
}

body.resizing {
  cursor: row-resize;
  user-select: none;
}

#table-panel {
  height: 260px;
  min-height: 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-top: 1px solid var(--border);
  overflow: hidden;
}

#table-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  flex-shrink: 0;
}

#table-toolbar .btn-row {
  margin-top: 0;
}

#btn-show-selection-only.active {
  background: #dbeafe;
  border-color: #93c5fd;
  color: var(--accent);
  font-weight: 600;
}

.column-header-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  min-width: 0;
  max-width: 100%;
}

.column-header-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.column-sort {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
}

.column-sort-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.2rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
}

.column-sort-btn:hover {
  background: #e2e8f0;
  color: var(--text);
}

.column-sort-btn.active {
  background: #dbeafe;
  border-color: #93c5fd;
  color: var(--accent);
  font-weight: 700;
}

.column-sort-order {
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
}

.status-filter-wrap {
  position: relative;
  min-width: 5.5rem;
}

.status-filter-toggle {
  width: 100%;
  min-width: 0;
  font-size: 0.72rem;
  font-weight: 400;
  padding: 0.2rem 1.2rem 0.2rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-filter-toggle::after {
  content: '▾';
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.65rem;
  pointer-events: none;
}

.status-filter-toggle:hover {
  background: #f4f5f7;
}

.status-filter-panel {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  z-index: 12;
  min-width: 100%;
  width: max-content;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.status-filter-panel[hidden] {
  display: none !important;
}

.status-filter-option {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.status-filter-option input {
  margin: 0;
  cursor: pointer;
}

.status-filter-option:not(:has(input:checked)) {
  opacity: 0.5;
}

.legend-item,
.status-filter-option.legend-ok,
.status-filter-option.legend-failed,
.status-filter-option.legend-pending,
.status-filter-option.legend-no-address {
  font-size: 0.72rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.legend-item {
  display: inline-block;
}

.legend-ok { background: #dcfce7; border-color: #86efac; }
.legend-failed { background: #fee2e2; border-color: #fca5a5; }
.legend-pending { background: #fef9c3; border-color: #fde047; }
.legend-no-address { background: #f1f5f9; border-color: #cbd5e1; }

#table-container {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: auto;
}

.table-empty {
  padding: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}

.member-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.member-table th,
.member-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
}

.member-table th.col-data,
.member-table td[data-col-key] {
  width: 200px;
  min-width: 72px;
  max-width: 200px;
}

.member-table th.col-data {
  position: relative;
  padding-right: 0.65rem;
}

.col-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 3;
}

.col-resize-handle::after {
  content: '';
  position: absolute;
  top: 15%;
  bottom: 15%;
  left: 2px;
  width: 2px;
  border-radius: 1px;
  background: transparent;
  transition: background 0.15s ease;
}

.member-table th.col-data:hover .col-resize-handle::after,
.col-resize-handle.col-resize-active::after {
  background: var(--text);
}

body.col-resizing {
  cursor: col-resize;
  user-select: none;
}

.member-table th {
  background: #eef1f6;
  font-weight: 600;
}

.member-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #eef1f6;
}

.member-table thead tr:first-child th {
  border-bottom: none;
  padding-bottom: 0.15rem;
}

.member-table thead tr.column-filter-row th {
  font-weight: 400;
  padding: 0.15rem 0.35rem 0.3rem;
  vertical-align: middle;
  border-top: none;
}

.column-filter-wrap {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  min-width: 0;
  max-width: 100%;
}

.column-filter-negate {
  flex-shrink: 0;
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.column-filter-negate:hover:not(:disabled) {
  background: #e2e8f0;
  color: var(--text);
}

.column-filter-negate:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.column-filter-negate.active {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.column-filter-input {
  width: 100%;
  min-width: 0;
  font-size: 0.72rem;
  font-weight: 400;
  padding: 0.2rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
}

.column-filter-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

.column-filter-clear {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.column-filter-clear:hover {
  background: #e2e8f0;
  color: var(--text);
}

.table-empty-row td.table-empty-cell {
  text-align: center;
  color: var(--muted);
  font-style: italic;
  padding: 1rem;
  white-space: normal;
}

.member-table tbody {
  user-select: none;
  -webkit-user-select: none;
}

.member-table tbody tr {
  cursor: pointer;
}

.member-table tr.vtable-spacer td {
  padding: 0;
  border: none;
  line-height: 0;
  pointer-events: none;
  background: transparent;
}

.member-table td.cell-copyable {
  position: relative;
  padding-right: 1.65rem;
}

.member-table td.cell-copyable .cell-value {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-copy-float {
  position: absolute;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.cell-copy-float:hover {
  color: var(--text);
  background: #f4f5f7;
}

.cell-copy-float.copied {
  color: var(--success);
  border-color: #86efac;
  background: #f0fdf4;
}

.cell-copy-float[hidden] {
  display: none !important;
}

.member-table tbody tr.status-ok td {
  background: #f0fdf4;
}

.member-table tbody tr.status-failed td {
  background: #fef2f2;
}

.member-table tbody tr.status-failed td.col-status {
  color: var(--danger);
  font-weight: 600;
}

.member-table tbody tr.status-pending td {
  background: #fffbeb;
}

.member-table tbody tr.status-no-address td {
  background: #f8fafc;
  color: var(--muted);
}

.member-table tbody tr.selected td {
  background: #dbeafe !important;
  color: var(--text);
}

.member-table tbody tr.selected td.col-select {
  box-shadow: inset 4px 0 0 var(--accent);
}

.member-table .col-select {
  width: 2rem;
  text-align: center;
  position: sticky;
  left: 0;
  z-index: 1;
}

.member-table .col-status {
  position: sticky;
  left: 2rem;
  font-weight: 500;
  min-width: 8.5rem;
  z-index: 1;
}

.col-status-wrap {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.col-status-text {
  flex: 1;
  min-width: 0;
}

.col-status-map-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.col-status-map-btn:hover {
  color: var(--text);
  border-color: #93c5fd;
  background: #eff6ff;
}

.member-table thead .col-select,
.member-table thead .col-status {
  position: sticky;
  z-index: 4;
  background: #eef1f6;
}

.member-table thead .col-select {
  left: 0;
}

.member-table thead .col-status {
  left: 2rem;
}

.member-table thead .col-status-filter {
  overflow: visible;
  vertical-align: middle;
}

.member-marker-wrap {
  background: transparent;
  border: none;
}

.member-pin {
  width: 26px;
  height: 26px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: #fca5a5;
  border: 2px solid #f87171;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  position: relative;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.member-pin-selected {
  background: #991b1b;
  border-color: #7f1d1d;
}

.member-pin-hovered {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.5), 0 3px 10px rgba(0, 0, 0, 0.35);
}

.member-pin-selected.member-pin-hovered {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85), 0 0 0 6px rgba(37, 99, 235, 0.55), 0 3px 10px rgba(0, 0, 0, 0.35);
}

.member-pin-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(45deg);
  font-size: 0.7rem;
  font-weight: 700;
  color: #7f1d1d;
  line-height: 1;
}

.member-pin-selected .member-pin-badge {
  color: #fff;
}

.detail-member-block {
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.detail-member-block:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.detail-member-name {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.detail-group h4 {
  margin: 0 0 0.35rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}

.map-selection-box {
  position: absolute;
  border: 2px dashed var(--accent);
  background: rgba(37, 99, 235, 0.12);
  pointer-events: none;
  z-index: 1000;
  box-sizing: border-box;
}


#detail-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--detail-width);
  max-width: 90%;
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.08);
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#detail-panel.open {
  transform: translateX(0);
}

#detail-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#detail-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  padding-right: 0.5rem;
}

#detail-close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
}

#detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem 1rem;
}

.detail-group {
  margin-bottom: 1rem;
}

.detail-group h3 {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.detail-group dl {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.85rem;
}

.detail-field {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 0.35rem 0.75rem;
  align-items: start;
}

.detail-group dt {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.detail-group dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.35rem;
  line-height: 1.4;
}

.geocode-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.875rem;
  cursor: pointer;
  user-select: none;
}

.geocode-option input {
  margin: 0;
  cursor: pointer;
}

.geocode-option:has(input:disabled) {
  opacity: 0.55;
  cursor: not-allowed;
}

.geocode-option:has(input:disabled) input {
  cursor: not-allowed;
}

#nominatim-settings.nominatim-disabled {
  opacity: 0.55;
}

.mapping-field {
  margin-bottom: 0.5rem;
}

.mapping-field label {
  font-size: 0.8rem;
  margin-bottom: 0.2rem;
}

.mapping-field select {
  width: 100%;
  font-size: 0.875rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.mapping-field select.mapping-from-meta {
  background: #dcfce7;
  border-color: #86efac;
}

.mapping-land-extra {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}

.mapping-land-extra label {
  font-size: 0.8rem;
  margin-bottom: 0.2rem;
}

.mapping-land-extra input[type="text"] {
  width: 100%;
  font-size: 0.875rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.mapping-land-extra input[type="text"]:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.mapping-land-extra input[type="text"].mapping-from-meta {
  background: #dcfce7;
  border-color: #86efac;
}

.address-preview {
  font-size: 0.8rem;
  margin: 0.5rem 0;
  padding: 0.45rem 0.5rem;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
  word-break: break-word;
}

.address-preview.preview-invalid {
  border-color: #f87171;
  color: var(--danger);
}

body.help-open {
  overflow: hidden;
}

.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.55);
}

.help-overlay.hidden {
  display: none;
}

.help-dialog {
  width: min(36rem, 100%);
  max-height: min(90vh, 42rem);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.help-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.help-close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
}

.help-close:hover {
  background: var(--bg);
  color: var(--text);
}

.help-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  font-size: 0.875rem;
  line-height: 1.55;
}

.help-body section {
  margin-bottom: 1.25rem;
}

.help-body section:last-child {
  margin-bottom: 0;
}

.help-body h3 {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.help-body p {
  margin: 0 0 0.65rem;
}

.help-body p:last-child {
  margin-bottom: 0;
}

.help-body ol,
.help-body ul {
  margin: 0;
  padding-left: 1.25rem;
}

.help-body li {
  margin-bottom: 0.4rem;
}

.help-body li:last-child {
  margin-bottom: 0;
}

.help-body a {
  color: var(--accent);
}

.help-warning {
  padding: 0.65rem 0.75rem;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  color: #78350f;
}

.help-note {
  padding: 0.65rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.help-demo {
  margin-top: 0.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.help-linke-tools {
  margin-top: 0.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.help-linke-tools-brand {
  display: inline-block;
  text-decoration: none;
  color: var(--text);
}

.help-linke-tools-brand:hover {
  opacity: 0.88;
}

.help-linke-tools-logo {
  display: block;
  margin: 0 auto;
  height: 12em;
  max-height: 10rem;
  width: auto;
  object-fit: contain;
}

.help-demo-links {
  list-style: none;
  padding-left: 0;
}

.help-demo-links li {
  margin-bottom: 0.4rem;
}

.help-demo-links a {
  display: inline-block;
}

.help-footer {
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.geocode-warn-dialog {
  max-height: min(90vh, 28rem);
}

.geocode-warn-footer {
  gap: 0.5rem;
}

.export-filename-dialog {
  max-height: min(90vh, 16rem);
}

.export-filename-input {
  width: 100%;
  margin-top: 0.35rem;
  font: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.export-filename-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

@media (max-width: 768px) {
  #app {
    flex-direction: column;
  }

  .sidebar-toggle {
    width: 100%;
    height: 1.5rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-toggle-icon::before {
    content: '▲';
  }

  #app.sidebar-collapsed .sidebar-toggle-icon::before {
    content: '▼';
  }

  #sidebar {
    width: 100%;
    min-width: 0;
    max-height: 40vh;
  }

  #app.sidebar-collapsed #sidebar {
    max-height: 0;
    width: 100%;
    min-width: 0;
  }

  #workspace {
    min-height: 50vh;
  }

  #table-panel {
    height: 200px;
  }

  #detail-panel {
    width: 100%;
    max-width: 100%;
  }
}
