:root {
  color-scheme: dark;
  font-family: Arial, Helvetica, sans-serif;
  --bg: #0c1117;
  --panel: #151b23;
  --panel-2: #10161d;
  --panel-3: #1b2430;
  --ink: #e7edf5;
  --muted: #a3adbc;
  --line: #2a3442;
  --accent: #5ca8ff;
  --danger: #ff6f7a;
  --ok: #48d185;
  --warn: #f2b84b;
  --vantor-exposure: 100%;
  --vantor-contrast: 100%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: minmax(64px, auto) auto minmax(0, 1fr);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.load-progress {
  border-bottom: 1px solid var(--line);
  padding: 6px 16px 7px;
  background: rgba(12, 17, 23, 0.96);
}

.load-progress[hidden] {
  display: none;
}

.load-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.load-progress-row span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.load-progress-track {
  height: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
}

.load-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--ok));
  transition: width 0.18s ease;
}

.load-progress.is-indeterminate .load-progress-bar {
  width: 38%;
  animation: load-progress-slide 1s ease-in-out infinite;
}

@keyframes load-progress-slide {
  0% {
    transform: translateX(-110%);
  }

  100% {
    transform: translateX(280%);
  }
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.connection-status,
.role-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.connection-status::before {
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--warn);
  content: "";
}

.connection-status.is-online::before,
.connection-status.is-live::before {
  background: var(--ok);
}

.connection-status.is-syncing::before,
.connection-status.is-connecting::before {
  background: var(--warn);
}

.connection-status.is-offline::before {
  background: var(--danger);
}

.connection-status.is-paused::before {
  background: var(--muted);
}

main {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
}

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

aside {
  min-height: 0;
  overflow: auto;
  padding: 12px;
  border-left: 1px solid var(--line);
  background: var(--panel);
}

.panel-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.panel-section:first-child {
  padding-top: 0;
}

h2 {
  margin: 0 0 10px;
  font-size: 14px;
}

.section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin: 0 0 10px;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  text-align: left;
}

.section-toggle:hover {
  color: var(--accent);
}

.section-toggle::after {
  content: "▾";
  color: var(--muted);
  font-size: 12px;
}

.panel-section.collapsed .section-toggle {
  margin-bottom: 0;
}

.panel-section.collapsed .section-toggle::after {
  content: "▸";
}

.panel-section.collapsed .section-body {
  display: none;
}

label {
  display: block;
  margin: 10px 0 4px;
  font-size: 12px;
  color: var(--muted);
}

select,
input,
textarea,
button {
  width: 100%;
  font: inherit;
  border-radius: 6px;
}

select,
input,
textarea {
  border: 1px solid var(--line);
  padding: 8px;
  background: var(--panel-2);
  color: var(--ink);
}

select:focus,
input:focus,
textarea:focus,
button:focus,
a:focus {
  outline: 2px solid rgba(92, 168, 255, 0.45);
  outline-offset: 1px;
}

::placeholder {
  color: #7f8b9b;
}

textarea {
  resize: vertical;
}

button,
.header-actions a {
  border: 1px solid var(--line);
  background: var(--panel-3);
  color: var(--ink);
  padding: 8px 10px;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.header-actions a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button:disabled {
  cursor: default;
  opacity: 0.45;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.area-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
}

.fall-direction-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.provider-info {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.provider-description {
  margin-top: 6px;
  padding: 7px 8px;
  border-left: 3px solid var(--accent);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 8px;
}

.upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.upload-row input {
  min-width: 0;
}

.search-results {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.search-result {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 8px;
  background: var(--panel-2);
  text-align: left;
}

.search-result strong,
.search-result span {
  display: block;
  overflow-wrap: anywhere;
}

.search-result span {
  color: var(--muted);
  font-size: 11px;
}

.compare-controls {
  display: none;
  margin-top: 8px;
}

.compare-controls.active {
  display: block;
}

.inline-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--ink);
}

.inline-toggle input {
  width: auto;
}

input[type="range"] {
  padding: 0;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.tab-button {
  border-radius: 6px;
}

.tab-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #06121f;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.statistics-intro {
  margin: 0 0 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--panel-2);
}

.statistics-universe {
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
}

.statistics-load-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}

.statistics-state {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.statistics-state.is-loading {
  color: var(--accent);
}

.statistics-state.is-error {
  color: var(--danger);
}

.statistics-state.is-ready {
  color: var(--ok);
}

.statistics-retry {
  flex: 0 0 auto;
  width: auto;
  padding: 5px 8px;
  font-size: 11px;
}

.statistics-content[aria-busy="true"] {
  opacity: 0.68;
}

.statistics-section:last-child {
  border-bottom: 0;
}

.statistics-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.statistics-kpi {
  min-width: 0;
  min-height: 88px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
}

.statistics-kpi:last-child:nth-child(odd) {
  grid-column: span 2;
}

.statistics-kpi dt {
  min-height: 27px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.statistics-kpi dd {
  margin: 4px 0 0;
  color: var(--accent);
  font-size: 23px;
  font-weight: 800;
  line-height: 1;
}

.statistics-kpi small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
}

.statistics-chart-grid,
.statistics-direction-grid,
.statistics-distribution-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.statistics-chart-card,
.statistics-distribution-card {
  min-width: 0;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
}

.statistics-chart-card + .statistics-chart-card {
  margin-top: 10px;
}

.statistics-chart-grid .statistics-chart-card + .statistics-chart-card,
.statistics-direction-grid .statistics-chart-card + .statistics-chart-card {
  margin-top: 0;
}

.statistics-chart-card figcaption,
.statistics-distribution-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.statistics-chart-card figcaption strong,
.statistics-chart-card figcaption span,
.statistics-distribution-card header h3,
.statistics-distribution-card header span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.statistics-chart-card figcaption strong,
.statistics-distribution-card header h3 {
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.3;
}

.statistics-chart-card figcaption span,
.statistics-distribution-card header span {
  max-width: 52%;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
  text-align: right;
}

.statistics-empty {
  margin: 8px 0;
  color: var(--muted);
  font-size: 11px;
}

.statistics-bar-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.statistics-bar-row {
  min-width: 0;
}

.statistics-bar-label {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 10px;
  line-height: 1.25;
}

.statistics-bar-label span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
}

.statistics-bar-label strong {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  text-align: right;
}

.statistics-bar-track {
  height: 9px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel-3);
}

.statistics-bar-fill {
  display: block;
  width: var(--statistics-bar-width);
  height: 100%;
  border-right: 2px solid #d9eaff;
  background: var(--accent);
}

.activity-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 9px;
}

.activity-legend span::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border: 1px solid currentColor;
  vertical-align: -1px;
}

.activity-legend .is-create::before,
.activity-segment.is-create {
  background: #5ca8ff;
}

.activity-legend .is-update::before,
.activity-segment.is-update {
  background: #f2b84b;
}

.activity-legend .is-delete::before,
.activity-segment.is-delete {
  background: #df5ccc;
}

.activity-chart {
  display: grid;
  gap: 9px;
}

.activity-row-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
  font-size: 9px;
}

.activity-row-heading strong {
  color: var(--ink);
  font-size: 10px;
}

.activity-row-heading span,
.activity-row-meta {
  color: var(--muted);
  text-align: right;
}

.activity-scale {
  height: 17px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel-3);
}

.activity-stack {
  display: flex;
  width: var(--activity-stack-width);
  min-width: 2px;
  height: 100%;
}

.activity-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--activity-segment-width);
  min-width: 1px;
  border-right: 1px solid rgba(6, 18, 31, 0.72);
  color: #06121f;
  font-size: 8px;
  font-weight: 800;
}

.activity-row-meta {
  margin-top: 2px;
  font-size: 9px;
}

.statistics-table-details {
  margin-top: 10px;
  color: var(--muted);
  font-size: 10px;
}

.statistics-table-details summary {
  cursor: pointer;
  color: var(--accent);
}

.statistics-table-scroll {
  overflow-x: auto;
  margin-top: 7px;
}

.statistics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 9px;
  white-space: nowrap;
}

.statistics-table th,
.statistics-table td {
  padding: 4px 5px;
  border: 1px solid var(--line);
  text-align: right;
}

.statistics-table th:first-child,
.statistics-table td:first-child {
  text-align: left;
}

.direction-rose-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  align-items: center;
  gap: 6px;
}

.direction-rose {
  display: block;
  width: 100%;
  max-height: 236px;
}

.direction-rose text {
  fill: var(--ink);
  font-size: 10px;
  font-weight: 700;
}

.direction-rose-grid,
.direction-rose-axis {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
}

.direction-rose-sector {
  fill: #df5ccc;
  fill-opacity: 0.68;
  stroke: #ffd5f6;
  stroke-width: 1.2;
}

.direction-bin-labels {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 9px;
}

.direction-bin-labels li {
  display: flex;
  justify-content: space-between;
  gap: 5px;
  padding-bottom: 2px;
  border-bottom: 1px dotted var(--line);
}

.direction-bin-labels span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
}

.direction-bin-labels strong {
  color: var(--ink);
}

.statistics-histogram {
  display: block;
  width: 100%;
  max-height: 190px;
}

.statistics-histogram-bar {
  fill: var(--accent);
  stroke: #d9eaff;
  stroke-width: 0.8;
}

.statistics-histogram-axis {
  stroke: var(--muted);
  stroke-width: 1;
}

.statistics-histogram-label,
.statistics-histogram-max {
  fill: var(--muted);
  font-size: 7px;
}

.statistics-distribution-card header {
  margin-bottom: 7px;
}

.distribution-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  margin: 0 0 4px;
}

.distribution-summary div {
  min-width: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel-3);
}

.distribution-summary dt {
  color: var(--muted);
  font-size: 9px;
}

.distribution-summary dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
}

#saveLabelBtn {
  grid-column: span 2;
  background: var(--accent);
  color: #06121f;
  border-color: var(--accent);
}

#deleteLabelBtn {
  grid-column: span 2;
  color: var(--danger);
}

.save-status {
  grid-column: span 2;
  min-height: 20px;
  border-radius: 6px;
  padding: 6px 8px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
}

.save-status.active {
  background: rgba(92, 168, 255, 0.13);
  color: #9dccff;
}

.save-status.ok {
  background: rgba(72, 209, 133, 0.12);
  color: var(--ok);
}

.save-status.warn {
  background: rgba(242, 184, 75, 0.14);
  color: var(--warn);
}

.save-status.error {
  background: rgba(255, 111, 122, 0.12);
  color: var(--danger);
}

.conflict-notice {
  grid-column: span 2;
  display: grid;
  gap: 7px;
  border: 1px solid rgba(242, 184, 75, 0.55);
  border-radius: 6px;
  padding: 9px;
  background: rgba(242, 184, 75, 0.13);
  color: var(--warn);
  font-size: 12px;
}

.conflict-notice[hidden] {
  display: none;
}

.conflict-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.conflict-actions button {
  padding: 6px 8px;
  font-size: 11px;
}

dl {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 6px 10px;
  margin: 0;
  font-size: 12px;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.image-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.image-links a {
  display: block;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  text-align: center;
  color: var(--accent);
  text-decoration: none;
  background: var(--panel-2);
}

.image-preview {
  grid-column: span 2;
  display: block;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
}

.image-preview img {
  display: block;
  width: 100%;
  max-height: 240px;
  object-fit: contain;
}

#imageStatus {
  font-size: 12px;
  color: var(--muted);
}

.database-links {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.database-links a {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  text-align: center;
  color: var(--accent);
  text-decoration: none;
  background: var(--panel-2);
}

.database-info {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.database-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.summary-card,
.summary-action {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: var(--panel-2);
  color: var(--ink);
}

.summary-card {
  min-height: 58px;
}

.summary-total {
  grid-column: span 2;
}

.summary-card span {
  display: block;
  color: var(--accent);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.summary-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

.summary-button {
  text-align: left;
}

.summary-button.active,
.summary-button:hover {
  border-color: var(--warn);
  color: var(--warn);
}

.summary-button.active span,
.summary-button:hover span {
  color: var(--warn);
}

.summary-action {
  min-height: 44px;
  line-height: 1.25;
}

.result-toggle {
  margin: 10px 0 2px;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.filter-grid button {
  align-self: end;
}

.results-wrap {
  overflow: auto;
  max-height: 58vh;
}

.load-more-results {
  position: sticky;
  bottom: 0;
  width: 100%;
  margin-top: 8px;
  background: var(--panel-3);
}

#resultsTable {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 11px;
}

#resultsTable th,
#resultsTable td {
  border-bottom: 1px solid var(--line);
  padding: 6px 4px;
  text-align: left;
  vertical-align: top;
}

#resultsTable th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
  color: var(--muted);
  font-weight: 600;
}

.sort-btn {
  width: auto;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  text-align: left;
}

.sort-btn.active {
  color: var(--accent);
}

.result-detail-row td {
  background: var(--panel-2);
  color: var(--muted);
}

.result-detail {
  display: grid;
  gap: 4px;
  font-size: 11px;
}

#resultsTable .result-row {
  cursor: pointer;
}

#resultsTable .result-row.is-missing-fall td {
  background: rgba(242, 184, 75, 0.08);
}

#resultsTable .result-row:hover,
#resultsTable .result-row:focus {
  background: rgba(92, 168, 255, 0.12);
  outline: none;
}

#resultsTable .result-row.is-missing-fall:hover td,
#resultsTable .result-row.is-missing-fall:focus td {
  background: rgba(242, 184, 75, 0.16);
}

.missing-fall-badge {
  display: inline-block;
  border: 1px solid rgba(242, 184, 75, 0.48);
  border-radius: 999px;
  padding: 2px 6px;
  background: rgba(242, 184, 75, 0.12);
  color: var(--warn);
  font-weight: 700;
}

.fall-clarity-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.fall-clarity-badge.is-pending {
  border-color: rgba(242, 184, 75, 0.48);
  background: rgba(242, 184, 75, 0.12);
  color: var(--warn);
}

.fall-clarity-badge.is-clear {
  border-color: rgba(72, 209, 133, 0.48);
  background: rgba(72, 209, 133, 0.12);
  color: var(--ok);
}

.fall-clarity-badge.is-unclear {
  border-color: rgba(163, 173, 188, 0.48);
  background: rgba(163, 173, 188, 0.1);
  color: var(--ink);
}

.rupture-arrow-icon {
  color: #e23b3b;
  font-size: 18px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  transform-origin: center;
  text-shadow: 0 0 2px #ffffff;
}

.drawing-fall-direction,
.drawing-fall-direction *,
.adding-poi,
.adding-poi * {
  cursor: crosshair !important;
}

.zone-label-icon span {
  display: inline-block;
  max-width: 160px;
  padding: 3px 6px;
  border: 1px solid rgba(92, 168, 255, 0.85);
  border-radius: 4px;
  background: rgba(11, 17, 24, 0.88);
  color: #dbeafe;
  font-size: 11px;
  font-weight: 700;
  line-height: 14px;
  white-space: nowrap;
}

.event-star-icon {
  color: #df5ccc;
  font-size: 26px;
  font-weight: 800;
  line-height: 26px;
  text-align: center;
  text-shadow: 0 0 2px #000000, 0 0 6px #ffffff;
}

.event-star-icon.event-slip {
  color: #ffb347;
}

.point-star-icon {
  font-size: 28px;
  font-weight: 900;
  line-height: 28px;
  text-align: center;
  text-shadow: 0 0 2px #000000, 0 0 6px #ffffff;
}

.point-star-icon.poi-red {
  color: #ff2f3f;
}

.severe-damage-marker {
  filter: drop-shadow(0 0 2px #ffffff);
}

.vantor-post-tile,
.vantor-pre-tile {
  filter: brightness(var(--vantor-exposure)) contrast(var(--vantor-contrast));
}

.dem-surface-tile {
  image-rendering: auto;
}

.total-damage-marker {
  filter: drop-shadow(0 0 2px #ffffff);
}

.collab-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.collab-grid div {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  background: rgba(8, 13, 21, 0.34);
}

.collab-grid span {
  display: block;
  color: var(--accent);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.collab-grid small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.editor-roster {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.editor-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(15, 23, 42, 0.76);
  color: var(--ink);
  font-size: 12px;
}

.editor-chip.is-online::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.18);
}

.editor-chip:not(.is-online)::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #64748b;
}

.input-required-error {
  border-color: #f43f5e !important;
  box-shadow: 0 0 0 2px rgba(244, 63, 94, 0.22);
}

.map-legend {
  width: 245px;
  padding: 9px 10px;
  border: 1px solid rgba(147, 164, 184, 0.24);
  border-radius: 6px;
  background: rgba(18, 24, 32, 0.94);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.2;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.36);
}

.legend-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
}

.legend-toggle::after {
  content: "▾";
  color: var(--muted);
}

.map-legend.collapsed {
  width: auto;
}

.map-legend.collapsed .legend-toggle::after {
  content: "▸";
}

.map-legend.collapsed .legend-content {
  display: none;
}

.legend-content {
  margin-top: 7px;
}

.legend-section {
  padding: 7px 0;
  border-top: 1px solid rgba(147, 164, 184, 0.18);
}

.legend-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.legend-section h3 {
  margin: 0 0 5px;
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.legend-row {
  display: grid;
  grid-template-columns: 16px 26px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  margin: 5px 0;
  color: var(--ink);
}

.legend-row input {
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: var(--accent);
}

.legend-marker {
  justify-self: center;
}

.legend-subrow {
  color: var(--muted);
}

.legend-swatch {
  display: inline-block;
  width: 22px;
  height: 14px;
}

.legend-swatch.polygon-provider {
  border: 2px solid #1d6fd1;
  background: rgba(29, 111, 209, 0.14);
}

.legend-swatch.polygon-compare {
  border: 2px dashed #ef8a00;
  background: rgba(239, 138, 0, 0.08);
}

.legend-swatch.polygon-label {
  border: 2px solid #7b5cc9;
  background: rgba(123, 92, 201, 0.32);
}

.legend-swatch.polygon-active {
  border: 2px solid #00a36c;
  background: rgba(0, 163, 108, 0.12);
}

.legend-swatch.polygon-zone {
  border: 2px dashed #5ca8ff;
  background: rgba(92, 168, 255, 0.12);
}

.legend-swatch.rupture-joint {
  border: 2px dashed #991b1b;
  background: rgba(226, 59, 59, 0.1);
}

.legend-swatch.dot {
  width: 12px;
  height: 12px;
  margin-left: 5px;
  border-radius: 50%;
}

.legend-dot {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22), 0 0 4px rgba(255, 255, 255, 0.55);
}

.legend-dot.total-damage-dot,
.legend-swatch.damage-total {
  border: 2px solid #b60000;
  background: #ff1f1f;
}

.legend-dot.severe-damage-dot,
.legend-swatch.severe-damage {
  border: 2px solid #b65a00;
  background: #ff9c1a;
}

.legend-swatch.event-slip {
  border: 2px solid #b65a00;
  background: #ff9c1a;
}

.legend-star {
  display: inline-block;
  width: 24px;
  color: #df5ccc;
  font-size: 18px;
  font-weight: 800;
  line-height: 14px;
  text-align: center;
  text-shadow: 0 0 2px #000000, 0 0 5px #ffffff;
}

.legend-star-marker {
  display: inline-block;
  width: 24px;
  color: #df5ccc;
  font-size: 18px;
  font-weight: 900;
  line-height: 14px;
  text-align: center;
  text-shadow: 0 0 2px #000000, 0 0 5px #ffffff;
}

.legend-star.event-slip,
.legend-star-marker.max-slip-star {
  color: #ffb347;
}

.legend-star.poi-star,
.legend-star-marker.poi-manual-star {
  color: #ff2f3f;
}

.legend-star::before,
.legend-star-marker::before {
  content: "★";
}

.legend-line {
  display: inline-block;
  width: 24px;
  height: 0;
  border-top-width: 4px;
  border-top-style: solid;
}

.legend-line.major-axis {
  border-color: #28d77d;
}

.legend-line.minor-axis {
  border-color: #ffda4d;
}

.legend-line.epicenter-radial {
  border-color: #b3269a;
  border-top-style: dashed;
}

.legend-line.slip-radial {
  border-color: #d07800;
  border-top-style: dashed;
}

.legend-line.fall-direction {
  border-color: #ff4f8b;
}

.leaflet-container {
  background: #0b1118;
}

.leaflet-bar a,
.leaflet-bar a:hover,
.leaflet-control-layers,
.leaflet-control-attribution {
  background: rgba(18, 24, 32, 0.94);
  border-color: var(--line);
  color: var(--ink);
}

.leaflet-control-layers label,
.leaflet-control-layers-list {
  color: var(--ink);
}

.leaflet-control-layers-separator {
  border-top-color: var(--line);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--panel);
  color: var(--ink);
}

.leaflet-popup-content {
  color: var(--ink);
}

.leaflet-draw-toolbar a {
  background-color: rgba(18, 24, 32, 0.94);
}

.leaflet-draw-actions a {
  background: var(--panel-3);
  color: var(--ink);
}

.leaflet-draw-actions a:hover {
  background: var(--accent);
  color: #06121f;
}

@media (max-width: 520px) {
  .database-summary {
    grid-template-columns: minmax(0, 1fr);
  }

  .summary-total {
    grid-column: auto;
  }

  .tabs {
    gap: 4px;
  }

  .tab-button {
    padding-inline: 5px;
    font-size: 12px;
  }

  .direction-rose-wrap {
    grid-template-columns: minmax(0, 1fr);
  }

  .direction-bin-labels {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .statistics-chart-card figcaption,
  .statistics-distribution-card header,
  .activity-row-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .statistics-chart-card figcaption span,
  .statistics-distribution-card header span,
  .activity-row-heading span {
    max-width: none;
    text-align: left;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-rows: minmax(72px, auto) auto minmax(0, 1fr);
  }

  main {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) 360px;
  }

  aside {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .map-legend {
    width: 190px;
    font-size: 11px;
  }
}
