/* ── MALT Conservation Lands — ESV Dashboard ── */
/* Matches SoilScope spy-movie green aesthetic */

:root {
  --bg-deep: #070b10;
  --bg-panel: rgba(10, 20, 10, 0.5);
  --bg-panel-hover: rgba(10, 20, 10, 0.55);
  --border: rgba(76, 175, 80, 0.08);
  --border-hover: rgba(76, 175, 80, 0.2);
  --accent: #3a7d5e;
  --accent-dim: #388e3c;
  --text: #e6eef8;
  --text-dim: #9aaa9a;
  --text-label: #6a8399;
  --font-mono: "SF Mono", "JetBrains Mono", "Fira Code", monospace;
  --font-sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#cesiumContainer {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.hidden { display: none !important; }

/* ── Top Bar ── */
#topBar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: rgba(10, 18, 10, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(76, 175, 80, 0.15);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 100;
}

.top-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.top-brand img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.top-brand h1 {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: #c8d8c8;
}

.top-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}

.layer-groups {
  display: flex;
  gap: 6px;
}

.layer-pill {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.layer-pill:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.layer-pill.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(76, 175, 80, 0.08);
}

/* ── Easement Sidebar ── */
#easementSidebar {
  position: fixed;
  top: 60px;
  left: 12px;
  bottom: 92px;
  width: 300px;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 12px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background 0.3s;
}

#easementSidebar:hover {
  background: var(--bg-panel-hover);
  border-color: var(--border-hover);
}

.sidebar-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-header h2 {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: #c8d8c8;
  margin-bottom: 8px;
}

#easementSearch {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

#easementSearch:focus {
  border-color: var(--accent);
}

#easementSearch::placeholder {
  color: var(--text-label);
}

#easementList {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.easement-item {
  padding: 10px 16px;
  border-bottom: 1px solid rgba(76, 175, 80, 0.06);
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.easement-item:hover {
  background: rgba(76, 175, 80, 0.06);
}

.easement-item.active {
  background: rgba(76, 175, 80, 0.12);
  border-left: 3px solid var(--accent);
}

.easement-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.easement-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
}

.easement-esv {
  color: var(--text);
  font-weight: 600;
}

.easement-bar-track {
  height: 3px;
  background: rgba(76, 175, 80, 0.1);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 2px;
}

.easement-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ── Detail Card (overlay) ── */
.pipeline-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  border-radius: 8px;
  margin-bottom: 5px;
  font-size: 0.82rem;
}
.pipeline-row .pipeline-label { font-weight: 500; }
.pipeline-row .pipeline-value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.82rem;
}

.pipe-carbon  { background: rgba(76,175,80,0.08); }
.pipe-carbon .pipeline-label { color: #81c784; }
.pipe-carbon .pipeline-value { color: #66bb6a; }

.pipe-water   { background: rgba(66,165,245,0.08); }
.pipe-water .pipeline-label { color: #64b5f6; }
.pipe-water .pipeline-value { color: #42a5f5; }

.pipe-cooling { background: rgba(0,188,212,0.08); }
.pipe-cooling .pipeline-label { color: #4dd0e1; }
.pipe-cooling .pipeline-value { color: #26c6da; }

.pipe-soil    { background: rgba(141,110,99,0.12); }
.pipe-soil .pipeline-label { color: #bcaaa4; }
.pipe-soil .pipeline-value { color: #8d6e63; }

.pipe-biodiversity { background: rgba(171,71,188,0.08); }
.pipe-biodiversity .pipeline-label { color: #ba68c8; }
.pipe-biodiversity .pipeline-value { color: #ab47bc; }

.pipe-pollination { background: rgba(255,167,38,0.08); }
.pipe-pollination .pipeline-label { color: #ffcc80; }
.pipe-pollination .pipeline-value { color: #ffa726; }

.pipe-health  { background: rgba(239,83,80,0.07); }
.pipe-health .pipeline-label { color: #f48fb1; }
.pipe-health .pipeline-value { color: #ef5350; }

/* Total box */
.detail-total-box {
  margin: 0 0 18px;
  padding: 18px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(76, 175, 80, 0.2);
  border-radius: 10px;
  text-align: center;
}
.detail-total-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #5a7a5a;
  margin-bottom: 4px;
}

/* ── Bottom Dashboard Bar ── */
#dashboardBar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 24px;
  background: rgba(10, 18, 10, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(76, 175, 80, 0.15);
  z-index: 100;
}

.dash-hero {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-shrink: 0;
}

.dash-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--text-label);
  text-transform: uppercase;
  position: absolute;
  top: 10px;
  left: 24px;
}

.dash-value {
  font-size: 32px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  margin-top: 8px;
}

.dash-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

.dash-divider {
  width: 1px;
  height: 48px;
  background: var(--border);
  flex-shrink: 0;
}

.dash-stats {
  display: flex;
  gap: 24px;
  flex-shrink: 0;
}

.dash-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.dash-stat-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.dash-stat-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--text-label);
  text-transform: uppercase;
}

.dash-pipelines {
  display: flex;
  gap: 12px;
  flex: 1;
  justify-content: flex-end;
  overflow: hidden;
}

.dash-pipe {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 60px;
}

.dash-pipe-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.dash-pipe-label {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.08em;
  color: var(--text-label);
  text-transform: uppercase;
}

.dash-pipe-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-bottom: 2px;
}

/* ── Telescope HUD (from main app) ── */
.telescope-hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.hud-crosshair-h, .hud-crosshair-v {
  position: absolute;
  background: rgba(76, 175, 80, 0.08);
}

.hud-crosshair-h {
  top: 50%; left: 0; right: 0;
  height: 1px;
}

.hud-crosshair-v {
  left: 50%; top: 0; bottom: 0;
  width: 1px;
}

.hud-ring {
  position: absolute;
  border: 1px solid rgba(76, 175, 80, 0.06);
  border-radius: 50%;
}

.hud-ring-1 {
  width: 200px; height: 200px;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

.hud-ring-2 {
  width: 400px; height: 400px;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

.hud-corner {
  position: absolute;
  width: 30px; height: 30px;
  border-color: rgba(76, 175, 80, 0.15);
  border-style: solid;
  border-width: 0;
}

.hud-corner-tl { top: 12px; left: 12px; border-top-width: 1px; border-left-width: 1px; }
.hud-corner-tr { top: 12px; right: 12px; border-top-width: 1px; border-right-width: 1px; }
.hud-corner-bl { bottom: 12px; left: 12px; border-bottom-width: 1px; border-left-width: 1px; }
.hud-corner-br { bottom: 12px; right: 12px; border-bottom-width: 1px; border-right-width: 1px; }

.hud-scanline {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(76, 175, 80, 0.04), transparent);
  animation: scanDown 8s linear infinite;
}

@keyframes scanDown {
  0% { top: 0; }
  100% { top: 100%; }
}

.hud-coords {
  position: absolute;
  bottom: 90px;
  right: 20px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  text-align: right;
}

/* ── Cell popup ── */
#cellPopup {
  position: fixed;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  z-index: 70;
  font-family: var(--font-mono);
  font-size: 14px;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.cell-popup-esv {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.cell-popup-name {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 2px;
}

/* ── Sweep Badge ── */
.sweep-badge {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.03);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.chat-toggle {
  background: rgba(255, 255, 255, 0.04);
}

/* ── AI Chat Panel ── */
.ai-chat-panel {
  position: fixed;
  bottom: 90px;
  right: 16px;
  z-index: 80;
  width: 380px;
  height: 60vh;
  max-height: calc(100vh - 160px);
  display: flex;
  flex-direction: column;
  background: rgba(10, 18, 10, 0.92);
  border: 1px solid rgba(76, 175, 80, 0.2);
  border-radius: 14px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  overflow: hidden;
}

.ai-chat-panel.hidden { display: none; }

.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.ai-chat-header h3 {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: #c8d8c8;
}

.ai-chat-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  transition: color 0.2s;
}

.ai-chat-close:hover { color: var(--text); }

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.ai-msg {
  max-width: 92%;
  font-size: 15px;
  line-height: 1.55;
  padding: 10px 14px;
  border-radius: 12px;
  word-wrap: break-word;
}

.ai-msg p { margin: 0 0 6px; }
.ai-msg p:last-child { margin-bottom: 0; }
.ai-msg strong { color: #c8dce8; }
.ai-msg a { color: #64b5f6; }

.ai-msg-bot {
  align-self: flex-start;
  background: rgba(27, 94, 32, 0.2);
  border: 1px solid rgba(102, 187, 106, 0.2);
  color: #c8dce8;
}

.ai-msg-user {
  align-self: flex-end;
  background: rgba(30, 60, 100, 0.35);
  border: 1px solid rgba(76, 175, 80, 0.2);
  color: var(--text);
}

.ai-msg-typing {
  align-self: flex-start;
  color: #6a8399;
  font-style: italic;
  background: none;
  border: none;
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  background: var(--accent-dim);
  border-radius: 50%;
  animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.ai-chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.ai-chat-input-row input {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 15px;
  font-family: var(--font-sans);
  transition: border-color 0.3s;
}

.ai-chat-input-row input:focus {
  border-color: rgba(76, 175, 80, 0.4);
  outline: none;
}

.ai-chat-input-row button {
  flex-shrink: 0;
  background: var(--accent);
  color: #0a0f0a;
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 500;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s;
}

.ai-chat-input-row button:hover {
  background: #81c784;
}

/* ── Breakdown Panel ── */
.breakdown-formulas {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.formula-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(76, 175, 80, 0.06);
}

.formula-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}

.formula-content {
  flex: 1;
  min-width: 0;
}

.formula-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.formula-calc {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  word-break: break-all;
}

.formula-result {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
  text-align: right;
  min-width: 60px;
}

.breakdown-inputs {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(76, 175, 80, 0.03);
}

.breakdown-inputs h4 {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--text-label);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
}

.input-item {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  padding: 2px 0;
}

.input-label {
  color: var(--text-dim);
}

.input-value {
  font-family: var(--font-mono);
  color: var(--text);
  font-weight: 500;
}

.breakdown-sources {
  margin-top: 14px;
  padding: 12px 14px;
  background: rgba(76,175,80,0.04);
  border-radius: 8px;
  border: 1px solid rgba(76,175,80,0.08);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: #5a7a5a;
  line-height: 1.6;
}


/* ══ Unified Easement Detail Slide-Out ══ */
#easementDetail {
  position: fixed;
  top: 60px;
  left: 324px;
  width: 500px;
  bottom: 92px;
  background: rgba(8, 16, 8, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 12px 12px 0;
  z-index: 55;
  box-shadow: 8px 0 32px rgba(0,0,0,0.3);
  transform: translateX(0);
  transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  opacity: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#easementDetail.detail-closed {
  transform: translateX(-840px);
  opacity: 0;
  pointer-events: none;
}

.detail-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#easementDetail #detailClose {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
  z-index: 10;
  transition: color 0.2s;
  line-height: 1;
}
#easementDetail #detailClose:hover { color: var(--text); }

#easementDetail h3 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 6px;
  padding-right: 30px;
  color: var(--text);
}

.detail-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  margin-bottom: 14px;
}



.detail-total {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  color: #81c784;
  line-height: 1;
}

.detail-rate {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #5a7a5a;
  margin-top: 4px;
}

.detail-pipelines {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 6px;
}

.detail-divider {
  height: 1px;
  background: var(--border);
  margin: 18px 0;
}

.detail-section-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-label);
  margin-bottom: 12px;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  #easementSidebar { width: 240px; }
  #easementDetail { width: 340px; left: 254px; }

      .ai-chat-panel { width: 320px; }
}

@media (max-width: 600px) {
  #easementSidebar { display: none; }
      .dash-pipelines { display: none; }
  .ai-chat-panel { left: 10px; right: 10px; width: auto; }
}
