@import url('https://fonts.googleapis.com/css2?family=Unbounded:wght@500;700;800&family=Manrope:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  --bg-base: #060a12;
  --panel-bg: rgba(9, 14, 24, 0.9);
  --panel-bg-soft: rgba(9, 14, 24, 0.85);
  --panel-border: rgba(255, 255, 255, 0.07);
  --hairline: rgba(255, 255, 255, 0.07);
  --text-primary: #eef1f6;
  --text-secondary: #90a0b7;
  --text-muted: #566078;
  --text-faint: #4a5468;

  --accent: #31d0c9;
  --accent-ink: #05141a;
  --gold: #d4af37;
  --gold-soft: #e3c467;

  --gas: #f2a93c;
  --oil: #ef6b4d;
  --water: #4fa8f0;
  --methane: #ff8a3d;
  --spill: #ff3860;
  --well: #c3cede;

  --font-display: 'Unbounded', 'Segoe UI', sans-serif;
  --font-body: 'Manrope', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  overflow: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: #5fe3dc; }
button { font: inherit; }

.mono { font-family: var(--font-mono); }
.display { font-family: var(--font-display); }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== keyframes ===== */
@keyframes flowDash { to { stroke-dashoffset: -200; } }
@keyframes pingRing { 0% { transform: scale(0.6); opacity: 0.9; } 70% { opacity: 0; } 100% { transform: scale(2.2); opacity: 0; } }
@keyframes livePulse { 0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(49, 208, 201, 0.55); } 50% { opacity: 0.55; box-shadow: 0 0 0 6px rgba(49, 208, 201, 0); } }
@keyframes methaneBreathe { 0%, 100% { opacity: 0.55; } 50% { opacity: 0.85; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ===== app shell ===== */
#app {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ===== top bar ===== */
#topbar {
  height: 68px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  background: rgba(9, 14, 24, 0.92);
  border-bottom: 1px solid var(--hairline);
  position: relative;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: 0.02em; color: #f5f8fc; }
.brand-tag { font-size: 10.5px; color: var(--text-muted); letter-spacing: 0.06em; margin-top: 2px; }

.search-wrap { flex: 1; max-width: 420px; margin: 0 40px; position: relative; }
.search-wrap svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); opacity: 0.4; }
.search-input {
  width: 100%; height: 36px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: var(--text-primary);
  padding-left: 38px;
  font-size: 13px;
  font-family: var(--font-body);
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { outline: none; border-color: rgba(49, 208, 201, 0.4); }

.topbar-right { display: flex; align-items: center; gap: 16px; }
.live-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: rgba(49, 208, 201, 0.08);
  border: 1px solid rgba(49, 208, 201, 0.25);
  border-radius: 999px;
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display: block; animation: livePulse 2.2s ease-in-out infinite; }
.live-chip .mono:first-of-type { font-size: 11px; font-weight: 600; color: var(--accent); letter-spacing: 0.05em; }
.live-chip .mono:last-of-type { font-size: 11px; color: var(--text-muted); border-left: 1px solid rgba(255, 255, 255, 0.1); padding-left: 8px; }

.btn-pro {
  display: flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 14px;
  background: rgba(212, 175, 55, 0.08);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 8px;
  cursor: pointer;
  color: var(--gold-soft);
}
.btn-pro:hover { background: rgba(212, 175, 55, 0.15); }
.btn-pro span { font-size: 12.5px; font-weight: 700; font-family: var(--font-body); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text-secondary);
}

/* ===== body layout ===== */
#body { flex: 1; display: flex; position: relative; overflow: hidden; }

/* ===== layers panel ===== */
#layers-panel {
  width: 292px; flex-shrink: 0;
  background: var(--panel-bg-soft);
  border-right: 1px solid var(--hairline);
  overflow-y: auto;
  padding: 20px 16px;
  position: relative;
  z-index: 20;
}
.panel-title { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; color: var(--text-muted); margin-bottom: 4px; }
.panel-subtitle { font-size: 12px; color: var(--text-secondary); margin-bottom: 16px; }

.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 20px; }
.stat-tile { background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.06); border-radius: 10px; padding: 10px 12px; }
.stat-tile.alert { background: rgba(255, 56, 96, 0.06); border-color: rgba(255, 56, 96, 0.2); }
.stat-value { font-family: var(--font-mono); font-size: 18px; font-weight: 700; color: #f5f8fc; }
.stat-tile.alert .stat-value { color: #ff5878; }
.stat-label { font-size: 10.5px; color: #7a879c; margin-top: 2px; }
.stat-tile.alert .stat-label { color: #c68a97; }

.hr { height: 1px; background: var(--hairline); margin: 14px 0; }

.layer-row {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 8px; border-radius: 9px; cursor: pointer;
  margin-bottom: 2px; border: none; background: transparent;
  width: 100%; text-align: left;
}
.layer-row:hover { background: rgba(255, 255, 255, 0.035); }
.swatch { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.layer-row-text { flex: 1; min-width: 0; }
.layer-row-label { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.layer-row-desc { font-family: var(--font-mono); font-size: 10px; color: #5b6678; margin-top: 1px; }

.switch { width: 34px; height: 19px; border-radius: 999px; position: relative; flex-shrink: 0; transition: background 0.15s; background: rgba(255, 255, 255, 0.12); }
.switch.on { background: var(--accent); }
.switch-knob { position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: #fff; transition: left 0.15s; }
.switch.on .switch-knob { left: 17px; }

.pro-heading { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.pro-heading span { font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; color: var(--gold); }

.locked-row {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 8px; border-radius: 9px; cursor: pointer;
  margin-bottom: 2px; opacity: 0.75; border: none; background: transparent; width: 100%; text-align: left;
}
.locked-row:hover { background: rgba(212, 175, 55, 0.07); }
.locked-row-label { font-size: 13px; font-weight: 600; color: #b7c1d1; }
.locked-row-desc { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); margin-top: 1px; }

.disclaimer { font-size: 10.5px; color: var(--text-faint); line-height: 1.5; margin-top: 16px; padding: 10px; background: rgba(255, 255, 255, 0.02); border-radius: 8px; }

/* ===== map ===== */
#map-stage {
  flex: 1; position: relative; overflow: hidden;
  background: radial-gradient(ellipse 900px 700px at 42% 45%, #0d1728 0%, #070c16 62%, #05080f 100%);
}
#map-svg { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; }
#markers-layer { position: absolute; inset: 0; z-index: 5; pointer-events: none; }

.pipe-group[hidden], [data-layer].layer-hidden { display: none !important; }

.marker-well {
  position: absolute; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px;
  border-radius: 50%; background: var(--well); opacity: 0.85; cursor: pointer; pointer-events: auto;
}
.marker-methane {
  position: absolute; border-radius: 50%; cursor: pointer; pointer-events: auto;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle, rgba(255, 138, 61, 0.55) 0%, rgba(255, 90, 61, 0.22) 55%, rgba(255, 59, 59, 0) 100%);
  animation: methaneBreathe 3.4s ease-in-out infinite;
}
.marker-methane .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--methane); }
.marker-spill {
  position: absolute; width: 32px; height: 32px; margin: -16px 0 0 -16px;
  cursor: pointer; pointer-events: auto; display: flex; align-items: center; justify-content: center;
}
.marker-spill .ring { position: absolute; width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--spill); animation: pingRing 2.2s ease-out infinite; }
.marker-spill .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--spill); }

.zoom-controls {
  position: absolute; top: 18px; right: 18px;
  display: flex; flex-direction: column;
  background: var(--panel-bg-soft); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 9px; overflow: hidden;
  z-index: 8;
}
.zoom-controls button {
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: #b7c1d1; font-size: 16px; cursor: pointer;
}
.zoom-controls button:first-child { border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.zoom-controls button:hover { background: rgba(255, 255, 255, 0.06); }

.basemap-chip {
  position: absolute; top: 18px; left: 18px;
  padding: 6px 11px; background: var(--panel-bg-soft); border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px; font-size: 10px; letter-spacing: 0.07em; color: #7a879c; z-index: 8;
}

.compass-scale { position: absolute; bottom: 16px; left: 18px; display: flex; align-items: center; gap: 14px; z-index: 8; }
.scale-bar { width: 70px; height: 2px; background: #5b6678; position: relative; }
.scale-bar::before, .scale-bar::after { content: ''; position: absolute; top: -3px; width: 1px; height: 8px; background: #5b6678; }
.scale-bar::before { left: 0; }
.scale-bar::after { right: 0; }
.scale-label { font-size: 9.5px; color: #5b6678; margin-top: 3px; }

.legend {
  position: absolute; bottom: 16px; right: 18px;
  background: var(--panel-bg-soft); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 10px;
  padding: 10px 13px; display: flex; gap: 16px; z-index: 8;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 2px; display: block; }
.legend-item .mono { font-size: 10px; color: #8b98ab; }

/* ===== detail popup ===== */
#detail-popup {
  position: absolute; right: 20px; bottom: 78px; width: 300px;
  background: rgba(11, 17, 29, 0.97); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 14px;
  padding: 16px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5); z-index: 25;
}
#detail-popup[hidden] { display: none; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 8px; }
.detail-type { display: flex; align-items: center; gap: 8px; }
.detail-type .swatch { border-radius: 3px; }
.detail-type span { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; }
.icon-btn {
  width: 22px; height: 22px; border-radius: 6px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #7a879c; border: none; background: transparent; font-size: 14px; line-height: 1;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.12); }
.detail-title { font-size: 14.5px; font-weight: 700; color: #f5f8fc; margin-bottom: 6px; }
.detail-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 10px; }
.detail-meta { display: flex; gap: 14px; margin-bottom: 12px; }
.detail-meta-label { font-family: var(--font-mono); font-size: 9.5px; color: var(--text-muted); }
.detail-meta-value { font-family: var(--font-mono); font-size: 12px; color: #c3cede; }
.detail-note { font-size: 10.5px; color: var(--text-faint); background: rgba(255, 255, 255, 0.03); border-radius: 7px; padding: 7px 9px; margin-bottom: 12px; }

.btn-primary {
  width: 100%; height: 36px; border-radius: 9px; border: none; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  font-family: var(--font-body); font-size: 12.5px; font-weight: 700;
}
.btn-primary:hover { background: #3ee0d8; }
.btn-primary.added { background: rgba(49, 208, 201, 0.14); color: var(--accent); }
.btn-primary.disabled { background: rgba(255, 255, 255, 0.06); color: var(--text-muted); cursor: default; }

/* ===== report drawer ===== */
#report-drawer {
  width: 54px; flex-shrink: 0;
  background: var(--panel-bg);
  border-left: 1px solid var(--hairline);
  position: relative; z-index: 20;
  transition: width 0.22s ease;
  overflow: hidden;
}
#report-drawer.open { width: 332px; }

.drawer-collapsed {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; cursor: pointer; border: none; background: transparent; width: 100%; color: inherit;
}
.drawer-collapsed .mono { font-size: 10.5px; letter-spacing: 0.1em; color: #7a879c; writing-mode: vertical-rl; transform: rotate(180deg); }
#report-drawer.open .drawer-collapsed { display: none; }
#report-drawer:not(.open) .drawer-open { display: none; }

.drawer-open { display: flex; flex-direction: column; height: 100%; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 14px; border-bottom: 1px solid var(--hairline); }
.drawer-head-title { font-size: 13.5px; font-weight: 700; color: #f5f8fc; margin-top: 2px; }

.drawer-body { flex: 1; overflow-y: auto; padding: 14px 16px; }
.report-item {
  background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.06); border-radius: 10px;
  padding: 11px 12px; margin-bottom: 8px;
}
.report-item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.report-item-type { display: flex; align-items: center; gap: 7px; }
.report-item-type .swatch { border-radius: 2px; width: 7px; height: 7px; }
.report-item-type span { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.06em; }
.report-item-title { font-size: 12.5px; font-weight: 600; color: var(--text-primary); margin-top: 5px; }
.report-item-time { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); margin-top: 3px; }

.empty-state { text-align: center; padding: 30px 10px; }
.empty-state svg { margin: 0 auto 12px; opacity: 0.35; display: block; }
.empty-state p { font-size: 12.5px; color: #7a879c; line-height: 1.5; margin: 0; }

.drawer-footer { padding: 14px 16px 18px; border-top: 1px solid var(--hairline); }
.generated-banner {
  background: rgba(49, 208, 201, 0.08); border: 1px solid rgba(49, 208, 201, 0.3); border-radius: 9px;
  padding: 10px 11px; margin-bottom: 10px; animation: toastIn 0.2s ease;
}
.generated-banner .title { font-size: 12px; font-weight: 700; color: var(--accent); }
.generated-banner .file { font-family: var(--font-mono); font-size: 10px; color: #7a879c; margin-top: 3px; }

/* ===== status bar ===== */
#statusbar {
  height: 30px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; background: #070b13; border-top: 1px solid var(--hairline);
}
#statusbar .mono { font-size: 10px; color: var(--text-faint); }

/* ===== PRO modal ===== */
#pro-modal {
  position: absolute; inset: 0; background: rgba(3, 5, 10, 0.72); z-index: 40;
  display: flex; align-items: center; justify-content: center;
}
#pro-modal[hidden] { display: none; }
.pro-card {
  width: 460px; background: #0b1220; border: 1px solid rgba(212, 175, 55, 0.3); border-radius: 18px;
  padding: 30px 28px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.pro-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.pro-head-title { display: flex; align-items: center; gap: 9px; }
.pro-head-title span { font-family: var(--font-display); font-size: 15px; font-weight: 700; color: var(--gold-soft); }
.pro-intro { font-size: 13px; color: var(--text-secondary); line-height: 1.55; margin-bottom: 20px; }
.pro-feature { display: flex; gap: 11px; align-items: flex-start; margin-bottom: 12px; }
.pro-feature svg { margin-top: 2px; flex-shrink: 0; }
.pro-feature-title { font-size: 12.5px; font-weight: 700; color: #eef1f6; }
.pro-feature-desc { font-size: 11.5px; color: #7a879c; }
.btn-gold {
  width: 100%; height: 42px; border-radius: 10px; border: none; cursor: pointer;
  background: var(--gold-soft); color: #241b04; font-family: var(--font-body); font-size: 13px; font-weight: 700; margin-top: 8px;
}
.btn-gold:hover { background: #eccf7c; }

/* ===== responsive note ===== */
@media (max-width: 1180px) {
  #layers-panel { width: 240px; }
  #report-drawer.open { width: 280px; }
}
