:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef2ed;
  --line: #d9dfd7;
  --text: #20251f;
  --muted: #657063;
  --accent: #1f7a5a;
  --accent-strong: #12583f;
  --blue: #2563eb;
  --red: #dc2626;
  --orange: #d97706;
  --yellow: #f59e0b;
  --shadow: 0 12px 30px rgba(28, 38, 28, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #1f2a22;
  color: #f7fbf6;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  color: #f7fbf6;
  margin-bottom: 28px;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #e6b84f;
  color: #20251f;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: #c8d4c6;
  margin-top: 2px;
}

.sidebar nav {
  display: grid;
  gap: 6px;
}

.sidebar nav a {
  color: #dfe8dc;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  text-decoration: none;
}

.content {
  padding: 28px;
  min-width: 0;
}

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

.page-header h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
}

.page-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.header-actions,
.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.button,
button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 13px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  min-height: 40px;
}

.button:hover,
button:hover {
  border-color: #b7c4b5;
  text-decoration: none;
}

.button.primary,
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.button.danger,
button.danger {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}

.button.compact {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.icon-button {
  width: 32px;
  min-height: 32px;
  padding: 0;
  text-align: center;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.metrics article,
.panel,
.map-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metrics article {
  padding: 16px;
}

.metrics span,
.summary-band span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.metrics strong {
  display: block;
  font-size: 28px;
  line-height: 1.1;
  margin: 8px 0 2px;
}

.metrics small {
  color: var(--muted);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin: 0 0 10px;
}

.section-title h2 {
  margin: 0;
  font-size: 18px;
}

.panel {
  padding: 16px;
  margin-bottom: 18px;
}

.error-panel {
  border-color: #fecaca;
  background: #fff1f2;
  color: #991b1b;
}

.info-panel {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1e40af;
}

.uploaded-preview {
  max-height: 460px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
}

.uploaded-preview img {
  display: block;
  width: 100%;
  height: auto;
}

.table-wrap {
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  vertical-align: top;
}

th {
  background: var(--surface-2);
  color: #3c4639;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

tr:last-child td {
  border-bottom: 0;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 28px;
}

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  background: #e8ece7;
  color: #344034;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.status.sobreposicao_detectada,
.status.critical {
  background: #fee2e2;
  color: #991b1b;
}

.status.proximidade,
.status.warning,
.status.completed_with_errors {
  background: #fef3c7;
  color: #92400e;
}

.status.possivel_conflito {
  background: #ffedd5;
  color: #9a3412;
}

.status.sem_conflito,
.status.completed {
  background: #dcfce7;
  color: #166534;
}

.status.point-no-polygon,
.status.polygon-no-area,
.status.polygon-invalid,
.status.line {
  background: #fef3c7;
  color: #92400e;
}

.status.point-linked-polygon,
.status.polygon-delimited {
  background: #dcfce7;
  color: #166534;
}

.status.deleted {
  background: #e5e7eb;
  color: #374151;
}

.upload-form,
.filters {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.bulk-actions {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.quick-filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.filter-chip {
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  background: var(--surface);
}

.filter-chip.is-active,
.filter-chip.active {
  border-color: var(--accent);
  background: #e4f3ec;
  color: var(--accent-strong);
}

.bulk-actions label {
  min-width: 180px;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 360px;
}

.is-deleted {
  opacity: 0.62;
}

label {
  display: grid;
  gap: 6px;
  color: #364036;
  font-size: 13px;
  font-weight: 650;
}

.inline-check {
  display: flex;
  align-items: center;
  grid-template-columns: none;
  min-height: 40px;
}

.inline-check input,
th input[type="checkbox"],
td input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cfd8cc;
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  padding: 8px 10px;
}

textarea {
  resize: vertical;
  min-height: 140px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.analysis-form {
  display: grid;
  gap: 16px;
}

.vertices-panel {
  padding: 0;
}

.vertices-panel .section-title {
  padding: 16px 16px 0;
}

.vertices-table input,
.vertices-table select {
  min-width: 80px;
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.summary-band > div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
}

.summary-band strong {
  display: block;
  margin-top: 8px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
}

.details {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 10px;
  margin: 0;
}

.details dt {
  color: var(--muted);
  font-weight: 750;
}

.details dd {
  margin: 0;
}

.compact-details {
  margin-top: 12px;
  font-size: 13px;
}

.technical-details {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.technical-details summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 750;
}

.technical-details pre {
  white-space: pre-wrap;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 12px;
  overflow: auto;
}

.map {
  width: 100%;
  height: 420px;
  border-radius: 8px;
  overflow: hidden;
}

.map-panel .legend {
  margin: 12px;
  box-shadow: none;
}

.map-large {
  height: min(68vh, 680px);
  min-height: 460px;
}

.map-toolbar {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.map-toolbar label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
}

.map-toolbar input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
}

.map-toolbar input[type="search"] {
  max-width: 320px;
}

.map-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.map-side-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
  min-height: 680px;
}

.map-toolbar.stacked {
  display: grid;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.legend {
  display: grid;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.legend h2 {
  margin: 0 0 4px;
  font-size: 15px;
}

.legend-group {
  display: grid;
  gap: 6px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.legend-group:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.legend-group strong {
  font-size: 12px;
  color: #3c4639;
  text-transform: uppercase;
  letter-spacing: 0;
}

.legend-group small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.legend-dot,
.legend-line {
  width: 14px;
  height: 14px;
  display: inline-block;
  border-radius: 999px;
  background: var(--accent);
}

.legend-line {
  border-radius: 3px;
  height: 4px;
}

.legend-line.polygon {
  background: var(--blue);
}

.legend-line.polygon-delimited {
  background: var(--blue);
}

.legend-line.analysis {
  background: var(--red);
}

.legend-line.line {
  background: var(--accent);
}

.legend-dot.point-no-polygon {
  background: var(--accent);
}

.legend-dot.point-linked-polygon {
  background: var(--yellow);
}

.legend-dot.overlap {
  background: var(--orange);
}

.legend-dot.nearby {
  background: var(--yellow);
}

.map-marker {
  background: transparent;
  border: 0;
}

.map-marker span {
  display: block;
  width: 18px;
  height: 18px;
  border: 3px solid #ffffff;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(20, 30, 20, 0.32);
}

.map-marker-green span {
  background: var(--accent);
}

.map-marker-orange span {
  background: var(--yellow);
}

.map-marker-red span {
  background: var(--red);
}

.popup-warning {
  display: inline-block;
  margin-top: 4px;
  color: #9a3412;
  font-weight: 750;
}

.popup-muted-action {
  display: inline-flex;
  margin-top: 5px;
  margin-right: 4px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
}

.map-list {
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.map-list article {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.map-list article:last-child {
  border-bottom: 0;
}

.map-list button {
  border: 0;
  background: transparent;
  min-height: 0;
  padding: 0;
  text-align: left;
  color: var(--accent-strong);
}

.map-list small {
  color: var(--muted);
}

.map-list-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  color: var(--muted);
  font-size: 12px;
}

.map-list-icons {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.layer-icon {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--accent);
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px var(--line);
}

.layer-icon.area {
  border-radius: 3px;
  background: var(--blue);
}

.layer-icon.point-linked {
  background: var(--yellow);
}

.layer-icon.warning {
  background: var(--orange);
}

.warning-note {
  color: #9a3412;
  font-weight: 750;
}

.warning-panel {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  margin-top: 14px;
  padding: 12px;
}

.edit-form {
  display: grid;
  gap: 14px;
  max-width: 760px;
}

.form-actions.spaced {
  margin-top: 18px;
}

.muted-action {
  display: inline-flex;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  margin: 0 4px 4px 0;
}

.selected-file {
  color: var(--muted);
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}

@media (max-width: 1200px) {
  .metrics,
  .summary-band {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .sidebar nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content {
    padding: 18px;
  }

  .page-header,
  .split,
  .detail-grid,
  .map-workspace {
    grid-template-columns: 1fr;
    display: grid;
  }

  .map-side-panel {
    min-height: auto;
  }

  .metrics,
  .summary-band,
  .form-grid {
    grid-template-columns: 1fr;
  }
}
