:root {
  color-scheme: dark;
  --ink: #f0efe7;
  --muted: #a7aba2;
  --panel: #171918;
  --panel-2: #20231f;
  --line: #3a3f37;
  --field: #101210;
  --accent: #e8c84a;
  --accent-2: #40c7b5;
  --danger: #f0735f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #0e100f;
  color: var(--ink);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

button,
input {
  font: inherit;
}

input[type="checkbox"] {
  width: auto;
}

.admin-screen,
.upload-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    linear-gradient(rgba(232, 200, 74, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(64, 199, 181, 0.06) 1px, transparent 1px),
    #080909;
  background-size: 36px 36px;
}

.geocloud-portal {
  align-items: stretch;
  place-items: stretch;
}

.portal-shell {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(420px, 1.25fr);
  gap: 22px;
  width: min(100%, 1280px);
  margin: auto;
}

.agent-hero,
.portal-console {
  min-height: min(760px, calc(100vh - 48px));
}

.agent-hero {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(420px, 1fr) auto;
  gap: 18px;
  overflow: hidden;
  border: 1px solid rgba(64, 199, 181, 0.34);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 42%, rgba(64, 199, 181, 0.18), transparent 38%),
    linear-gradient(135deg, rgba(232, 200, 74, 0.08), transparent 28%),
    linear-gradient(180deg, #101616, #0b0d0d);
  padding: 22px;
}

.agent-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(64, 199, 181, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(240, 239, 231, 0.04) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at center, black 0 56%, transparent 80%);
}

.portal-brand,
.portal-metrics,
.agent-network {
  position: relative;
  z-index: 1;
}

.agent-network {
  min-height: 430px;
  overflow: hidden;
}

.neural-map-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.agent-node {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 138px;
  height: 74px;
  border: 1px solid rgba(240, 239, 231, 0.2);
  border-radius: 8px;
  background: rgba(14, 16, 15, 0.78);
  box-shadow: 0 0 30px rgba(64, 199, 181, 0.12);
  text-align: center;
}

.agent-node b,
.agent-node small {
  display: block;
}

.agent-node small {
  color: var(--muted);
  font-size: 10px;
}

.core-node {
  left: 50%;
  top: 50%;
  width: 160px;
  height: 92px;
  border-color: rgba(232, 200, 74, 0.75);
  transform: translate(-50%, -50%);
  background: rgba(28, 29, 22, 0.92);
}

.node-field { left: 2%; top: 18%; }
.node-drone { right: 4%; top: 14%; }
.node-photo { right: 0; bottom: 20%; }
.node-gis { left: 7%; bottom: 16%; }
.node-report { left: 50%; bottom: 4%; transform: translateX(-50%); }

.network-link {
  display: none;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 168px;
  transform-origin: top center;
  background: linear-gradient(rgba(64, 199, 181, 0.9), rgba(232, 200, 74, 0.15));
}

.link-field { transform: rotate(238deg); }
.link-drone { transform: rotate(308deg); }
.link-photo { transform: rotate(58deg); }
.link-gis { transform: rotate(128deg); }
.link-report { height: 150px; transform: rotate(180deg); }

.portal-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.portal-metrics span {
  border: 1px solid rgba(240, 239, 231, 0.14);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.025);
  padding: 12px;
}

.portal-metrics b,
.portal-metrics small {
  display: block;
}

.portal-metrics small {
  color: var(--muted);
  font-size: 10px;
  margin-top: 4px;
}

.admin-panel,
.upload-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: min(100%, 560px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--panel), #111311);
  padding: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand strong {
  display: block;
  font-size: 20px;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 10px;
  background: url("assets/geocloud-logo.svg") center / contain no-repeat;
  box-shadow: 0 0 0 1px rgba(240, 239, 231, 0.18);
}

.upload-box {
  display: grid;
  gap: 10px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.025);
  padding: 10px 12px;
  text-transform: none;
}

.terrain-products {
  display: grid;
  gap: 10px;
  margin: 4px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  padding: 12px;
}

.terrain-products legend {
  padding: 0 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.terrain-products > small {
  color: var(--muted);
  line-height: 1.45;
  text-transform: none;
}

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

.terrain-grid .check-row {
  margin: 0;
}

.terrain-grid input {
  width: auto;
}

label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--ink);
  padding: 11px 12px;
}

button {
  min-height: 40px;
  border: 1px solid #d3b63f;
  border-radius: 6px;
  background: var(--accent);
  color: #15140b;
  cursor: pointer;
  font-weight: 700;
}

.secondary-button,
.danger-button,
.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 6px;
  padding: 8px 10px;
  text-decoration: none;
  white-space: nowrap;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
}

.danger-button {
  border: 1px solid rgba(240, 115, 95, 0.65);
  background: rgba(240, 115, 95, 0.12);
  color: #ffb2a7;
}

.action-button {
  border: 1px solid rgba(64, 199, 181, 0.75);
  background: rgba(64, 199, 181, 0.1);
  color: var(--accent-2);
}

button:disabled {
  cursor: progress;
  opacity: 0.6;
}

.status-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  padding: 14px;
}

.admin-panel {
  width: min(100%, 1100px);
}

.portal-console {
  width: 100%;
}

.projects-section {
  display: grid;
  gap: 14px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 16px;
  text-transform: uppercase;
}

.static-portal {
  width: min(100%, 760px);
}

.project-list {
  display: grid;
  gap: 12px;
}

.project-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  padding: 14px;
}

.project-card[data-status="ready"] {
  border-color: rgba(64, 199, 181, 0.35);
}

.project-card[data-status="failed"] {
  border-color: rgba(240, 115, 95, 0.45);
}

.project-main {
  min-width: 0;
}

.project-card strong,
.project-card small {
  display: block;
}

.project-card strong {
  overflow-wrap: anywhere;
}

.project-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 10px;
  white-space: nowrap;
}

.project-card small,
.empty-state {
  color: var(--muted);
}

.project-error {
  color: #ffb2a7;
  margin-top: 4px;
}

a {
  color: var(--accent-2);
  font-weight: 700;
}

.viewer-page {
  overflow: hidden;
}

#potree_render_area {
  position: absolute;
  inset: 0;
}

.viewer-toolbar {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 28px);
  border: 1px solid rgba(240, 239, 231, 0.18);
  border-radius: 8px;
  background: rgba(14, 16, 15, 0.78);
  padding: 10px 12px;
  backdrop-filter: blur(12px);
}

.inspection-toolbar {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 40;
  display: flex;
  gap: 8px;
  border: 1px solid rgba(240, 239, 231, 0.18);
  border-radius: 8px;
  background: rgba(14, 16, 15, 0.82);
  padding: 8px;
  backdrop-filter: blur(12px);
}

.inspection-toolbar button {
  min-height: 32px;
  border-color: rgba(64, 199, 181, 0.65);
  background: rgba(64, 199, 181, 0.14);
  color: var(--ink);
  padding: 6px 10px;
}

body.viewer-page #potree_sidebar_container {
  z-index: 20;
}

body.viewer-page .potree_menu_toggle {
  display: none !important;
}

body.viewer-page #potree_sidebar_container .geovisor-tool-icon {
  width: 34px !important;
  height: 34px !important;
  box-sizing: border-box;
  margin: 4px 5px 5px 0;
  border: 1px solid rgba(240, 239, 231, 0.22);
  border-radius: 7px;
  background: rgba(14, 16, 15, 0.58);
  padding: 5px;
}

body.viewer-page #potree_sidebar_container .geovisor-tools-panel .divider,
body.viewer-page #potree_sidebar_container .geovisor-filters-panel .divider {
  margin-top: 16px;
}

body.viewer-page #potree_sidebar_container #geoPointSizeControl {
  margin-top: 18px;
}

body.viewer-page #potree_sidebar_container .geovisor-about {
  line-height: 1.45;
}

.layer-panel {
  position: fixed;
  right: 14px;
  top: 76px;
  z-index: 40;
  display: grid;
  gap: 10px;
  width: 260px;
  max-height: calc(100vh - 110px);
  overflow: auto;
  border: 1px solid rgba(240, 239, 231, 0.18);
  border-radius: 8px;
  background: rgba(14, 16, 15, 0.82);
  padding: 12px;
  backdrop-filter: blur(12px);
}

.layer-panel h2 {
  margin: 0;
  font-size: 14px;
  text-transform: uppercase;
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 13px;
  text-transform: none;
}

.layer-item[aria-disabled="true"] {
  color: var(--muted);
  opacity: 0.65;
}

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

  .agent-hero,
  .portal-console {
    min-height: auto;
  }

  .agent-network {
    min-height: 360px;
  }

  .agent-node {
    width: 118px;
    height: 66px;
  }

  .core-node {
    width: 140px;
  }

  .portal-metrics {
    grid-template-columns: 1fr;
  }

  .layer-panel {
    left: 14px;
    right: 14px;
    top: 82px;
    width: auto;
  }

  .project-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .project-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}
