:root {
  --bg-dark: #070b14;
  --bg-panel: rgba(15, 23, 42, 0.86);
  --bg-card: rgba(30, 41, 59, 0.65);
  --bg-card-hover: rgba(30, 41, 59, 0.92);
  --border-subtle: rgba(148, 163, 184, 0.16);
  --border-highlight: rgba(16, 185, 129, 0.45);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);
  --accent-cyan: #38bdf8;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-lg: 0 20px 45px -15px rgba(0, 0, 0, 0.65);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: radial-gradient(circle at 15% 15%, #0f2027 0%, #070b14 55%, #050811 100%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.75rem;
  background: rgba(7, 11, 20, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 1000;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-main);
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(56, 189, 248, 0.2));
  border: 1px solid rgba(16, 185, 129, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.brand-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.75);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.18s ease;
}

.btn-secondary:hover {
  background: rgba(51, 65, 85, 0.85);
  border-color: rgba(56, 189, 248, 0.45);
}

/* Search Hero Section */
.search-section {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1.75rem 0.5rem;
}

.search-container {
  position: relative;
  display: flex;
  gap: 0.65rem;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: var(--radius-lg);
  padding: 0.45rem;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(16, 185, 129, 0.08);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-container:focus-within {
  border-color: var(--accent-emerald);
  box-shadow: var(--shadow-lg), 0 0 0 3px var(--accent-emerald-glow);
}

.search-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding-left: 0.85rem;
  position: relative;
}

.search-icon {
  color: var(--accent-emerald);
  flex-shrink: 0;
}

#address-input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 1.02rem;
  padding: 0.65rem 0.25rem;
  outline: none;
}

#address-input::placeholder {
  color: var(--text-dim);
}

.clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  font-size: 1.1rem;
  display: none;
}

.clear-btn:hover {
  color: var(--text-main);
}

.btn-primary {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #04130d;
  font-weight: 700;
  font-size: 0.92rem;
  border: none;
  padding: 0.7rem 1.35rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  white-space: nowrap;
}

.btn-primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

.btn-primary:active {
  transform: translateY(1px);
}

/* Autocomplete Dropdown */
.suggestions-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #0f172a;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.75);
  z-index: 1200;
  max-height: 310px;
  overflow-y: auto;
  display: none;
}

.suggestion-item {
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  transition: background 0.12s;
  font-size: 0.92rem;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.active {
  background: rgba(16, 185, 129, 0.14);
}

.suggestion-pin {
  color: var(--accent-cyan);
  flex-shrink: 0;
}

/* Quick Preset Chips */
.presets-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.7rem;
  flex-wrap: wrap;
}

.presets-label {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 0.2rem;
}

.preset-chip {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--border-subtle);
  color: #cbd5e1;
  font-size: 0.78rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.preset-chip:hover {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.45);
  color: #fff;
}

.preset-chip span.chip-tag {
  color: var(--accent-emerald);
  font-weight: 600;
}

/* Main Workspace Grid */
.workspace-grid {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 0.75rem 1.75rem 2rem;
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 1.25rem;
  flex: 1;
}

@media (max-width: 1080px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

/* Left Column: Results & Telemetry */
.results-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
}

/* Primary Hero Compass Result */
.hero-result-card {
  border-color: rgba(16, 185, 129, 0.32);
  background: linear-gradient(165deg, rgba(15, 23, 42, 0.95) 0%, rgba(11, 29, 34, 0.88) 100%);
  position: relative;
  overflow: hidden;
}

.matched-address-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.matched-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent-emerald);
  font-weight: 700;
}

.matched-address-text {
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--text-main);
  margin-top: 0.15rem;
}

.confidence-pill {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

/* Compass & Primary Readout */
.compass-hero-layout {
  display: grid;
  grid-template-columns: 168px 1fr;
  align-items: center;
  gap: 1.15rem;
}

@media (max-width: 480px) {
  .compass-hero-layout {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
}

.compass-dial-wrap {
  width: 164px;
  height: 164px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.compass-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.5));
}

#compass-needle-group {
  transition: transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
  transform-origin: 100px 100px;
}

.direction-readout {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.facing-eyebrow {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}

.direction-big {
  font-size: 2.15rem;
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.03em;
  background: linear-gradient(90deg, #ffffff 0%, #6ee7b7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.direction-sub-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-top: 0.15rem;
}

.azimuth-badge {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 0.18rem 0.6rem;
  border-radius: 6px;
}

.intercardinal-badge {
  font-size: 0.84rem;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
}

.facing-summary-sentence {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.45rem;
  line-height: 1.45;
}

/* Telemetry Signals Breakdown */
.signals-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  margin-top: 1.1rem;
  padding-top: 0.95rem;
  border-top: 1px solid var(--border-subtle);
}

.signal-box {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.65rem;
}

.signal-box.active-signal {
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.08);
}

.signal-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.signal-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 0.2rem;
}

.signal-desc {
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-top: 0.1rem;
}

/* 4-Sides Orientation Matrix */
.section-heading {
  font-size: 0.84rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sides-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.side-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.side-card.front-highlight {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.09);
}

.side-label {
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.side-dir {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.side-deg {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--accent-cyan);
}

.side-sun {
  font-size: 0.75rem;
  color: #cbd5e1;
  margin-top: 0.15rem;
}

/* Insights Tabs / Cards */
.insights-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.insight-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.8rem 0.95rem;
}

.insight-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.insight-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.insight-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
}

.insight-body {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Right Column: Map & Visual Sightline */
.map-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  min-height: 640px;
  position: relative;
}

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.1rem;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid var(--border-subtle);
  gap: 0.75rem;
  flex-wrap: wrap;
}

.map-legend {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: #cbd5e1;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.legend-line {
  width: 16px;
  height: 4px;
  border-radius: 2px;
  display: inline-block;
}

.map-controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.btn-chip {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid var(--border-subtle);
  color: #cbd5e1;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-chip.active,
.btn-chip:hover {
  background: rgba(16, 185, 129, 0.18);
  border-color: var(--accent-emerald);
  color: #fff;
}

#map {
  flex: 1;
  width: 100%;
  min-height: 540px;
  background: #060a12;
  z-index: 1;
}

.map-footer-bar {
  padding: 0.65rem 1.1rem;
  background: rgba(15, 23, 42, 0.95);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  gap: 0.75rem;
  flex-wrap: wrap;
}

.coords-mono {
  font-family: 'JetBrains Mono', monospace;
  color: #cbd5e1;
  font-size: 0.76rem;
}

/* Custom Map Markers */
.house-pin-marker {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #10b981;
  border: 3px solid #ffffff;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #04130d;
  font-weight: 800;
  font-size: 13px;
  cursor: grab;
}

.street-pin-marker {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #38bdf8;
  border: 2.5px solid #ffffff;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #04130d;
  font-weight: 800;
  font-size: 11px;
  cursor: grab;
}

/* Loading Overlay */
.loading-banner {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid var(--accent-emerald);
  color: var(--text-main);
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  display: none;
  align-items: center;
  gap: 0.6rem;
  z-index: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.spinner {
  width: 15px;
  height: 15px;
  border: 2.5px solid rgba(16, 185, 129, 0.3);
  border-top-color: var(--accent-emerald);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.toast-notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  border: 1px solid var(--accent-emerald);
  color: var(--text-main);
  padding: 0.75rem 1.15rem;
  border-radius: var(--radius-md);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 2000;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: all 0.22s ease;
}

.toast-notification.show {
  opacity: 1;
  transform: translateY(0);
}
