/* Pinpoint Engineering Portal — stylesheet
   Aesthetic: dark instrumentation; mono for numerics; restrained terracotta accent. */

:root {
  --bg-0: #0a0c0d;
  --bg-1: #111416;
  --bg-2: #181c1f;
  --bg-3: #21262a;
  --line: #2a3035;
  --line-bright: #3a4248;
  --text-0: #e8ebed;
  --text-1: #aab2b8;
  --text-2: #6e7880;
  --accent: #d97757;
  --accent-dim: #8a4d38;
  --accent-bg: #2a1810;
  --signal: #5db98f;
  --warning: #d4a64d;
  --danger: #e2574c;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  --sans: 'IBM Plex Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-0);
  color: var(--text-0);
  font-family: var(--sans);
  font-weight: 300;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ============ LOGIN ============ */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-0);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  /* subtle grid texture to feel like instrumentation */
  background-image:
    linear-gradient(rgba(42, 48, 53, 0.4) 1px, transparent 1px),
    linear-gradient(90deg, rgba(42, 48, 53, 0.4) 1px, transparent 1px);
  background-size: 40px 40px;
}
.login-card {
  width: 360px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  padding: 32px;
  position: relative;
}
.login-card::before {
  content: '';
  position: absolute;
  top: -1px; left: -1px;
  width: 24px; height: 24px;
  border-top: 1px solid var(--accent);
  border-left: 1px solid var(--accent);
}
.login-card::after {
  content: '';
  position: absolute;
  bottom: -1px; right: -1px;
  width: 24px; height: 24px;
  border-bottom: 1px solid var(--accent);
  border-right: 1px solid var(--accent);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
}
.login-logo {
  width: 36px;
  height: 36px;
  background: var(--accent);
  position: relative;
}
.login-logo::after {
  content: '';
  position: absolute;
  inset: 14px;
  background: var(--bg-1);
}
.login-title {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--text-0);
}
.login-sub {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.25em;
  color: var(--text-2);
  margin-top: 2px;
}
.login-form { display: flex; flex-direction: column; gap: 4px; }
.login-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--text-2);
  margin-top: 12px;
  margin-bottom: 6px;
}
.login-form input {
  background: var(--bg-0);
  border: 1px solid var(--line);
  color: var(--text-0);
  font-family: var(--mono);
  font-size: 13px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 100ms ease;
}
.login-form input:focus { border-color: var(--accent); }
.login-btn {
  margin-top: 24px;
  background: var(--accent);
  color: var(--bg-0);
  border: 0;
  padding: 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  font-weight: 500;
  cursor: pointer;
  transition: background 100ms ease;
}
.login-btn:hover { background: #e88a6e; }
.login-btn:disabled { opacity: 0.5; cursor: wait; }
.login-error {
  color: var(--danger);
  font-family: var(--mono);
  font-size: 11px;
  margin-top: 12px;
  min-height: 16px;
}
.login-foot {
  position: absolute;
  bottom: 12px;
  right: 16px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--text-2);
}

/* ============ APP SHELL ============ */
#app {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 48px 1fr;
  height: 100vh;
}

/* ============ TOP BAR ============ */
.topbar {
  grid-column: 1 / -1;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 24px;
}
.brand {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--text-0);
  font-weight: 500;
}
.brand .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--accent);
  margin-right: 10px;
  vertical-align: 1px;
}
.breadcrumb {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.breadcrumb .sep { margin: 0 8px; color: var(--line-bright); }
.breadcrumb .current { color: var(--text-0); }
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-2);
  letter-spacing: 0.05em;
}
.topbar-right .user {
  color: var(--text-1);
  border-left: 1px solid var(--line);
  padding-left: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logout-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-2);
  width: 22px;
  height: 22px;
  font-size: 12px;
  cursor: pointer;
  transition: all 100ms ease;
}
.logout-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ============ SIDEBAR ============ */
.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.sidebar-section {
  border-bottom: 1px solid var(--line);
  padding: 16px;
}
.sidebar-meta { margin-top: auto; }
.sidebar-section-title {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-2);
  margin-bottom: 12px;
}

.project {
  padding: 10px 12px;
  margin: 0 -12px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 80ms ease;
}
.project:hover { background: var(--bg-2); }
.project.active { background: var(--bg-2); border-left-color: var(--accent); }
.project-name {
  font-size: 13px;
  color: var(--text-0);
  font-weight: 400;
  margin-bottom: 2px;
}
.project-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-2);
  letter-spacing: 0.05em;
}

.capture {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  cursor: pointer;
  position: relative;
}
.capture-marker {
  width: 8px;
  height: 8px;
  border: 1px solid var(--line-bright);
  background: var(--bg-1);
  flex-shrink: 0;
  transition: all 100ms ease;
}
.capture.active .capture-marker {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.capture-date {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-1);
  letter-spacing: 0.03em;
}
.capture.active .capture-date { color: var(--text-0); }
.capture-line {
  position: absolute;
  left: 3px;
  top: 24px;
  width: 1px;
  height: 16px;
  background: var(--line);
}
.capture:last-child .capture-line { display: none; }

.layer-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  cursor: pointer;
  user-select: none;
}
.layer-toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-1);
}
.layer-toggle-label .icon {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
}
.layer-toggle.on .layer-toggle-label { color: var(--text-0); }
.layer-toggle.on .layer-toggle-label .icon { color: var(--accent); }
.switch {
  width: 28px;
  height: 14px;
  border: 1px solid var(--line-bright);
  background: var(--bg-2);
  position: relative;
  transition: all 100ms ease;
}
.switch::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  width: 10px;
  height: 10px;
  background: var(--text-2);
  transition: all 100ms ease;
}
.layer-toggle.on .switch { background: var(--accent-bg); border-color: var(--accent); }
.layer-toggle.on .switch::after { left: 15px; background: var(--accent); }

.dataset-info {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-1);
  line-height: 1.8;
}
.ds-row { display: flex; justify-content: space-between; }
.ds-row > span:first-child { color: var(--text-2); }

/* ============ STAGE ============ */
.stage { position: relative; background: var(--bg-0); overflow: hidden; }

.mode-tabs {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  display: flex;
  background: var(--bg-1);
  border: 1px solid var(--line);
}
.mode-tab {
  padding: 8px 16px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-2);
  cursor: pointer;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  transition: all 100ms ease;
}
.mode-tab:last-child { border-right: none; }
.mode-tab:hover { color: var(--text-1); }
.mode-tab.active {
  color: var(--text-0);
  background: var(--bg-2);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.stage-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  display: flex;
  gap: 8px;
}
.ctrl-btn {
  background: var(--bg-1);
  border: 1px solid var(--line);
  color: var(--text-1);
  padding: 7px 12px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ctrl-btn:hover { color: var(--text-0); border-color: var(--line-bright); }
.ctrl-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-bg); }
.ctrl-btn svg { width: 12px; height: 12px; }

.compare-bar {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: none;
  background: var(--bg-1);
  border: 1px solid var(--line);
  padding: 8px 12px;
  align-items: center;
  gap: 14px;
  font-family: var(--mono);
  font-size: 11px;
}
.compare-bar.active { display: flex; }
.compare-pick {
  color: var(--text-1);
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 4px 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.05em;
}
.compare-pick.left { border-left: 2px solid var(--accent); }
.compare-pick.right { border-left: 2px solid var(--signal); }
.compare-bar select {
  background: transparent;
  border: none;
  color: var(--text-0);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  outline: none;
}
.compare-bar option { background: var(--bg-2); }
.compare-bar .vs {
  color: var(--text-2);
  letter-spacing: 0.15em;
  font-size: 10px;
}

#map-2d, #compare-container { position: absolute; inset: 0; background: var(--bg-0); }
#compare-before, #compare-after { position: absolute; inset: 0; }
#pointcloud-frame { position: absolute; inset: 0; border: 0; background: var(--bg-0); width: 100%; height: 100%; }

.status-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 28px;
  background: var(--bg-1);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 20px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-2);
  z-index: 5;
}
.status-bar .stat { display: flex; gap: 6px; }
.status-bar .stat-label { color: var(--text-2); text-transform: uppercase; }
.status-bar .stat-value { color: var(--text-0); }
.status-bar .live {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--signal);
  margin-left: auto;
}
.status-bar .live::before {
  content: '';
  width: 5px; height: 5px;
  background: var(--signal);
  border-radius: 50%;
  animation: pulse 2s infinite;
}
.status-bar .live.error { color: var(--danger); }
.status-bar .live.error::before { background: var(--danger); }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.tools {
  position: absolute;
  left: 12px;
  top: 56px;
  z-index: 10;
  background: var(--bg-1);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.tool {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-2);
  border-bottom: 1px solid var(--line);
  transition: all 100ms ease;
}
.tool:last-child { border-bottom: none; }
.tool:hover { color: var(--text-0); background: var(--bg-2); }
.tool.active { color: var(--accent); background: var(--accent-bg); }
.tool svg { width: 16px; height: 16px; }

.measure-panel {
  position: absolute;
  right: 12px;
  bottom: 40px;
  z-index: 10;
  width: 240px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  display: none;
}
.measure-panel.active { display: block; }
.measure-panel-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-2);
}
.measure-panel-header .clear { color: var(--text-2); cursor: pointer; font-size: 10px; }
.measure-panel-header .clear:hover { color: var(--accent); }
.measure-list { max-height: 220px; overflow-y: auto; }
.measure-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
}
.measure-item:last-child { border-bottom: none; }
.measure-item-label {
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
}
.measure-item-value { color: var(--text-0); }
.measure-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.maplibregl-ctrl-attrib, .maplibregl-ctrl-bottom-right { display: none !important; }
.maplibregl-canvas:focus { outline: none; }
.mapboxgl-ctrl-group, .maplibregl-ctrl-group { display: none !important; }

.mode-view { display: none; position: absolute; inset: 0; }
.mode-view.active { display: block; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb { background: var(--line-bright); }
::-webkit-scrollbar-thumb:hover { background: var(--text-2); }
