:root {
  --bg: linear-gradient(135deg, #2d3748 0%, #1a202c 50%, #0f1419 100%);
  --bg-alt: #ffffff;
  --text: #2d3748;
  --text-light: #ffffff;
  --muted: #718096;
  --primary: #38a169;
  --primary-light: #48bb78;
  --secondary: #68d391;
  --accent: #9ae6b4;
  --card: #ffffff;
  --border: #e2e8f0;
  --shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --netl-green: #7cb342;
  --netl-dark: #2d3748;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body.page {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  min-height: 100vh;
}

.container { max-width: 1200px; margin: 0 auto; padding: 20px 24px; }

.hero { 
  text-align: center; 
  padding: 30px 0 20px; 
  color: var(--text-light);
}
.hero-content { max-width: 800px; margin: 0 auto; }

.pipeline-logo {
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
}

.logo-container {
  position: relative;
  width: 120px;
  height: 80px;
}

.pipeline-icon {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pipe-segment {
  width: 30px;
  height: 12px;
  background: linear-gradient(90deg, var(--netl-green), var(--primary-light));
  border-radius: 6px;
  margin: 0 2px;
  box-shadow: 0 2px 8px rgba(56, 161, 105, 0.3);
  position: relative;
}

.pipe-segment::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 4px;
  height: 4px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
}

.monitoring-waves {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
}

.wave {
  width: 2px;
  height: 20px;
  background: linear-gradient(180deg, var(--secondary), var(--accent));
  border-radius: 1px;
  animation: pulse-wave 2s ease-in-out infinite;
}

.wave:nth-child(2) {
  animation-delay: 0.3s;
  height: 16px;
}

.wave:nth-child(3) {
  animation-delay: 0.6s;
  height: 24px;
}

.sensor-dot {
  position: absolute;
  top: -8px;
  right: 10px;
  width: 8px;
  height: 8px;
  background: var(--netl-green);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--netl-green);
  animation: sensor-blink 1.5s ease-in-out infinite;
}

@keyframes pulse-wave {
  0%, 100% { opacity: 0.4; transform: scaleY(0.8); }
  50% { opacity: 1; transform: scaleY(1.2); }
}

@keyframes sensor-blink {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; box-shadow: 0 0 16px var(--netl-green); }
}
.hero h1 { 
  margin: 0 0 12px; 
  font-size: 36px; 
  font-weight: 800; 
  letter-spacing: -0.02em;
  text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.subtitle { 
  margin: 0; 
  font-size: 18px; 
  font-weight: 300; 
  opacity: 0.9;
  line-height: 1.4;
}

.main-content { margin-top: -10px; }
.welcome-card {
  background: var(--card);
  border-radius: 20px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
}

.card-header { 
  text-align: center; 
  margin-bottom: 24px; 
}
.card-header h2 { 
  margin: 0 0 6px; 
  font-size: 28px; 
  font-weight: 700; 
  background: linear-gradient(135deg, var(--netl-green), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.card-header p { 
  margin: 0; 
  color: var(--muted); 
  font-size: 18px; 
}

.features-grid { 
  display: grid; 
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); 
  gap: 16px; 
  margin-bottom: 24px; 
}
.feature { 
  text-align: center; 
  padding: 16px; 
  border-radius: 12px; 
  background: linear-gradient(135deg, #f8fafc, #f0fff4);
  border: 1px solid var(--border);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.feature:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}
.feature-icon { 
  font-size: 28px; 
  margin-bottom: 8px; 
}
.feature h3 { 
  margin: 0 0 6px; 
  font-size: 16px; 
  font-weight: 600; 
}
.feature p { 
  margin: 0; 
  color: var(--muted); 
  font-size: 13px; 
}

.tech-specs { 
  margin-bottom: 24px; 
}
.tech-specs h3 { 
  margin: 0 0 12px; 
  font-size: 18px; 
  font-weight: 600; 
  text-align: center; 
}
.specs-grid { 
  display: grid; 
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); 
  gap: 12px; 
}
.spec { 
  padding: 12px; 
  border-radius: 8px; 
  background: #f8fafc; 
  border: 1px solid var(--border);
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
}
.spec-label { 
  color: var(--muted); 
  font-size: 14px; 
}
.spec-value { 
  font-weight: 600; 
  color: var(--primary); 
}

.action-section { 
  text-align: center; 
}
.connect-btn {
  background: linear-gradient(135deg, var(--netl-green), var(--primary-light));
  color: white;
  border: none;
  padding: 16px 32px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px 0 rgba(124, 179, 66, 0.3);
}
.connect-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px 0 rgba(124, 179, 66, 0.4);
}
.btn-icon { 
  font-size: 20px; 
}
.action-note { 
  margin: 16px 0 0; 
  color: var(--muted); 
  font-size: 14px; 
}

.loading-container {
  margin: 20px 0;
  text-align: center;
}

.loading-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 12px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 16px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--netl-green), var(--primary-light));
  width: 0%;
  border-radius: 4px;
  transition: width 0.3s ease;
  animation: progress-fill 3s ease-in-out forwards;
}

.loading-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  max-width: 300px;
  margin: 0 auto;
}

.step {
  font-size: 14px;
  color: var(--muted);
  opacity: 0.5;
  transition: all 0.3s ease;
}

.step.active {
  opacity: 1;
  color: var(--primary);
  transform: translateX(4px);
}

@keyframes progress-fill {
  0% { width: 0%; }
  100% { width: 100%; }
}

.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}
.btn.secondary { background: #6c757d; }
.btn:disabled { opacity: .7; cursor: not-allowed; }
.btn:hover { transform: translateY(-1px); }

.footer { 
  text-align: center; 
  color: rgba(255, 255, 255, 0.7); 
  margin-top: 20px; 
  font-size: 12px;
}

.dash-header { 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  margin-bottom: 12px; 
  color: var(--text-light);
}
.dash-header h1 {
  color: var(--text-light);
  margin: 0;
}
.dash-header .subtitle {
  color: rgba(255, 255, 255, 0.8);
}

.grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 16px; }
.panel h2 { margin: 0 0 12px; }
.updated { color: var(--muted); margin-top: 8px; font-size: 14px; }

.mel-spectrogram-container {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mel-spectrogram-container img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.mel-spectrogram-container p {
  color: var(--muted);
  font-style: italic;
}

.event-card { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px dashed var(--border); border-radius: 12px; background: #fff; }
.event-card .icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 10px; font-size: 26px; }
.event-card .info .label { font-weight: 700; }
.event-card .info .prob { color: var(--muted); font-size: 14px; }
.event-card .info .audio-file { color: var(--muted); font-size: 12px; margin-top: 4px; }

.legend { list-style: none; padding: 0; margin: 16px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.legend li { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.legend-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-size: 16px; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #28a745; margin-left: 6px; }
.pulse { animation: pulse 0.6s ease; }
@keyframes pulse { from { transform: scale(1); } 50% { transform: scale(1.3); } to { transform: scale(1); } }

.audio-analysis-section {
  margin-top: 20px;
}

.audio-analysis {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
}

.analysis-content {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  align-items: start;
}

.audio-plot {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.audio-plot img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.analysis-details {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.analysis-details h3 {
  margin: 0 0 16px 0;
  color: var(--primary);
  font-size: 16px;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

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

.detail-label {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.detail-value {
  color: var(--muted);
  font-size: 14px;
  text-align: right;
  max-width: 60%;
  word-break: break-word;
}

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .analysis-content { 
    grid-template-columns: 1fr; 
    gap: 16px;
  }
}
