/* ═══════════════════════════════════════════════════════════════════════════
   NABHYA NDVI FRONTEND — Design System & Styles
   Satellite-grade crop health analyzer UI
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ───────────────────────────────────────────────────────── */
/* System font stack — no CDN, no latency */
:root {
  --bg-primary:    hsl(222, 47%, 5%);
  --bg-secondary:  hsl(224, 39%, 10%);
  --bg-tertiary:   hsl(222, 30%, 14%);
  --bg-hover:      hsl(222, 30%, 17%);

  --border-subtle: hsla(0, 0%, 100%, 0.06);
  --border-default:hsla(0, 0%, 100%, 0.10);
  --border-accent: hsla(160, 84%, 39%, 0.30);

  --accent:        hsl(160, 84%, 39%);
  --accent-light:  hsl(160, 67%, 52%);
  --accent-dim:    hsla(160, 84%, 39%, 0.12);
  --accent-glow:   hsla(160, 84%, 39%, 0.25);

  --healthy:       #10B981;
  --stressed:      #F59E0B;
  --barren:        #EF4444;

  --text-primary:  hsl(210, 40%, 96%);
  --text-secondary:hsl(215, 16%, 47%);
  --text-tertiary: hsl(215, 19%, 35%);

  --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     16px;
  --radius-xl:     24px;
  --transition:    200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Ambient Background ──────────────────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(16,185,129,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16,185,129,0.025) 1px, transparent 1px);
  background-size: 64px 64px;
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  top: -300px;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 600px;
  background: radial-gradient(ellipse, rgba(16,185,129,0.06), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

#particles-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.app {
  position: relative;
  z-index: 1;
  max-width: 920px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.header {
  text-align: center;
  margin-bottom: 2.5rem;
  animation: fadeInDown 0.6s ease-out;
}

.header-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.header-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-logo svg {
  width: 20px;
  height: 20px;
  fill: white;
}

.header h1 {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #10B981, #34D399, #6EE7B7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.header-tagline {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-top: 0.35rem;
}

/* ── Server Status ───────────────────────────────────────────────────────── */
.server-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.4rem 0.9rem;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  transition: all var(--transition);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-tertiary);
  transition: background var(--transition);
}

.server-status.online .status-dot {
  background: var(--healthy);
  box-shadow: 0 0 6px var(--healthy);
  animation: pulse-dot 2s ease-in-out infinite;
}

.server-status.waking .status-dot {
  background: var(--stressed);
  animation: pulse-dot 1s ease-in-out infinite;
}

.server-status.offline .status-dot {
  background: var(--barren);
}

/* ── Card ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  transition: border-color var(--transition);
}

.card + .card {
  margin-top: 1.25rem;
}

.card-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.try-sample-section {
  margin-top: 1.5rem;
  z-index: 10;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

.sample-buttons {
  display: flex;
  gap: 0.75rem;
}

.btn-sample {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.35rem 0.85rem;
  border-radius: 12px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-sample:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

/* ── Upload Zone ─────────────────────────────────────────────────────────── */
.upload-section {
  animation: fadeInUp 0.5s ease-out 0.15s both;
}

.dropzone {
  border: 2px dashed var(--border-accent);
  border-radius: var(--radius-md);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  animation: pulse-border 3s infinite;
}

@keyframes pulse-border {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.1); }
  50% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
  animation: none;
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  border-radius: var(--radius-md);
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition);
}

.dropzone:hover .dropzone-icon { transform: translateY(-2px); }

.dropzone-icon svg {
  width: 26px;
  height: 26px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 1.5;
}

.dropzone-title {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.3rem;
}

.dropzone-subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* Preview */
.upload-preview {
  display: none;
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
}

.upload-preview.visible { display: flex; align-items: center; gap: 1rem; }

.upload-preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.upload-preview-info { flex: 1; }
.upload-preview-name {
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}
.upload-preview-meta {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}

.upload-preview-remove {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  font-size: 1.2rem;
  line-height: 1;
}
.upload-preview-remove:hover { color: var(--barren); background: hsla(0,84%,60%,0.1); }

/* Analyze Button */
.btn-analyze {
  width: 100%;
  padding: 0.9rem;
  margin-top: 1rem;
  background: linear-gradient(135deg, var(--accent), hsl(160, 70%, 32%));
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.btn-analyze::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, rgba(255,255,255,0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.5s;
}

.btn-analyze:hover:not(:disabled)::before { transform: translateX(100%); }
.btn-analyze:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 20px var(--accent-glow); }
.btn-analyze:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* Button Ripple Effect */
.ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  animation: ripple 600ms linear;
  background-color: rgba(255, 255, 255, 0.3);
  pointer-events: none;
}
@keyframes ripple {
  to { transform: scale(4); opacity: 0; }
}

/* Result Actions */
.result-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  justify-content: center;
}

.btn-download {
  padding: 0.65rem 1.5rem;
  background: linear-gradient(135deg, var(--accent), hsl(160, 70%, 32%));
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-download:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-new-analysis {
  padding: 0.65rem 1.5rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-new-analysis:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: var(--bg-hover);
}

.btn-analyze .spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── How It Works Section ────────────────────────────────────────────────── */
.how-it-works {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-subtle);
}

.hiw-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75rem;
}

.hiw-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.hiw-icon svg {
  width: 20px;
  height: 20px;
}

.hiw-text h4 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--text-primary);
}

.hiw-text p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ── Progress Indicator ──────────────────────────────────────────────────── */
.progress-section {
  display: none;
  animation: fadeInUp 0.3s ease-out;
}

.progress-section.visible { display: block; }

.progress-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 1.25rem;
}

.progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  position: relative;
}

.progress-step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: all 0.4s ease;
}

.progress-step-dot svg {
  width: 14px;
  height: 14px;
  stroke: var(--text-tertiary);
  fill: none;
  stroke-width: 2;
  transition: stroke 0.4s ease;
}

.progress-step.active .progress-step-dot {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.progress-step.active .progress-step-dot svg { stroke: var(--accent); }

.progress-step.done .progress-step-dot {
  border-color: var(--accent);
  background: var(--accent);
}
.progress-step.done .progress-step-dot svg { stroke: white; }

.progress-step-label {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  font-weight: 500;
  transition: color 0.4s ease;
}
.progress-step.active .progress-step-label,
.progress-step.done .progress-step-label { color: var(--text-secondary); }

.progress-line {
  width: 48px;
  height: 2px;
  background: var(--border-default);
  margin: 0 0.25rem;
  margin-bottom: 1.6rem;
  transition: background 0.4s ease;
}
.progress-line.filled { background: var(--accent); }

.progress-bar-wrap {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 2px;
  width: 0%;
  transition: width 0.5s ease;
}

.progress-status {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 0.75rem;
}

/* ── Results ─────────────────────────────────────────────────────────────── */
.results-section {
  display: none;
}

.results-section.visible {
  display: block;
  animation: fadeInUp 0.5s ease-out;
}

/* View Tabs */
.view-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
}

.view-tab {
  flex: 1;
  padding: 0.55rem 0.75rem;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.view-tab:hover { color: var(--text-primary); }
.view-tab.active {
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Image Display */
.image-display {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  max-width: 512px;
  margin: 0 auto;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
}

.image-display img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
  transition: transform 0.3s ease, filter 0.3s ease;
}

.image-display:hover img.visible:not(.is-fullscreen) {
  transform: scale(1.03);
}

.image-display img.visible { 
  display: block; 
  filter: drop-shadow(0 0 15px rgba(16, 185, 129, 0.15));
}

.btn-fullscreen {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  padding: 8px;
  cursor: pointer;
  z-index: 20;
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-display:hover .btn-fullscreen {
  opacity: 1;
}

.btn-fullscreen:hover {
  background: rgba(0, 0, 0, 0.8);
}

.btn-fullscreen svg {
  width: 18px;
  height: 18px;
}

.image-display.is-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  z-index: 1000;
  border-radius: 0;
  background: rgba(10, 15, 26, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-display.is-fullscreen img.visible {
  max-width: 90vw;
  max-height: 90vh;
  filter: none;
}

.image-display.is-fullscreen .compare-container {
  width: 90vw;
  height: 90vh;
}

/* Comparison Slider */
.compare-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: none;
  user-select: none;
  touch-action: none;
}

.compare-container.visible { display: block; }

.compare-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.compare-layer img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block !important;
}

.compare-after {
  clip-path: inset(0 0 0 50%);
}

.compare-label {
  position: absolute;
  top: 12px;
  padding: 0.3rem 0.65rem;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.85);
}

.compare-before .compare-label { left: 12px; }
.compare-after .compare-label { right: 12px; }

.compare-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  background: white;
  cursor: ew-resize;
  z-index: 10;
  transform: translateX(-50%);
  box-shadow: 0 0 8px rgba(0,0,0,0.4);
}

.compare-grip {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.compare-grip svg {
  width: 18px;
  height: 18px;
  fill: var(--bg-primary);
}

/* Thumbnails */
.image-thumbs {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  justify-content: center;
}

.thumb {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--transition);
  opacity: 0.6;
}

.thumb:hover { opacity: 0.85; }
.thumb.active { border-color: var(--accent); opacity: 1; }

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Health Gauges ───────────────────────────────────────────────────────── */
.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.card-title-row .card-title {
  margin-bottom: 0;
}

.verdict-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 100px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.verdict-badge.healthy {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
  color: #6EE7B7;
}

.verdict-badge.stressed {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.3);
  color: #FCD34D;
}

.verdict-badge.barren {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #FCA5A5;
}

.gauges-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.gauge-card {
  text-align: center;
  padding: 1.25rem 0.5rem;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
}

.gauge-svg {
  width: 100px;
  height: 100px;
  transform: rotate(-90deg);
  margin-bottom: 0.5rem;
}

.gauge-bg {
  fill: none;
  stroke: var(--border-subtle);
  stroke-width: 7;
}

.gauge-fill {
  fill: none;
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 282.743;
  stroke-dashoffset: 282.743;
  transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.gauge-card[data-type="healthy"] .gauge-fill { stroke: var(--healthy); }
.gauge-card[data-type="stressed"] .gauge-fill { stroke: var(--stressed); }
.gauge-card[data-type="barren"] .gauge-fill { stroke: var(--barren); }

.gauge-value {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
}

.gauge-card[data-type="healthy"] .gauge-value { color: var(--healthy); }
.gauge-card[data-type="stressed"] .gauge-value { color: var(--stressed); }
.gauge-card[data-type="barren"] .gauge-value { color: var(--barren); }

.gauge-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.3rem;
  font-weight: 500;
}

/* ── Stats Cards ─────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.stat-card {
  padding: 1rem;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-light);
  line-height: 1;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.35rem;
  font-weight: 500;
}

/* ── NDVI Legend Bar ─────────────────────────────────────────────────────── */
.legend-bar-section {
  margin-top: 1.5rem;
}

.legend-gradient {
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, #EF4444 0%, #F59E0B 30%, #EAB308 50%, #84CC16 70%, #10B981 100%);
  position: relative;
}

.legend-markers {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  position: relative;
}

.legend-marker {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

.legend-thresholds {
  display: flex;
  justify-content: space-between;
  margin-top: 0.15rem;
}

.legend-threshold {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.legend-threshold.low { color: var(--barren); }
.legend-threshold.mod { color: var(--stressed); }
.legend-threshold.high { color: var(--healthy); }

/* Histogram */
.histogram-section {
  margin-top: 1.5rem;
}

.histogram-bars {
  height: 80px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 8px 0 8px;
}

.hist-bar {
  flex: 1;
  border-radius: 4px 4px 0 0;
  transition: height 1.5s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 2px;
  opacity: 0.9;
}

.hist-bar:hover {
  opacity: 1;
  filter: brightness(1.2);
}

.histogram-labels {
  display: flex;
  justify-content: space-around;
  margin-top: 6px;
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px) scale(0.95);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
  max-width: 90%;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.toast.visible {
  transform: translateX(-50%) translateY(0) scale(1);
  opacity: 1;
}

.toast.error {
  background: hsla(0, 84%, 60%, 0.15);
  border: 1px solid hsla(0, 84%, 60%, 0.3);
  color: #fca5a5;
}

.toast.success {
  background: hsla(160, 84%, 39%, 0.12);
  border: 1px solid hsla(160, 84%, 39%, 0.25);
  color: #6EE7B7;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.footer {
  text-align: center;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.7;
}

.footer-content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.footer-sub {
  color: var(--text-tertiary);
  font-size: 0.75rem;
}

.footer a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition);
}
.footer a:hover { color: var(--accent); }

/* ── Animations ──────────────────────────────────────────────────────────── */
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

/* ── Intelligence & Zones (NEW) ─────────────────────────────────────────── */
.intelligence-card {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
}

.score-container {
  display: flex;
  align-items: center;
  gap: 2.5rem;
}

.score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 4px solid var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.score-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.score-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-top: 4px;
}

.score-details {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}

.score-grade-wrap {
  font-size: 1.2rem;
  color: var(--text-primary);
}

.score-grade {
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--accent);
}

.action-flag {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 1px;
}
.action-flag.HEALTHY { background: rgba(16, 185, 129, 0.2); color: #10B981; }
.action-flag.MONITOR { background: rgba(245, 158, 11, 0.2); color: #F59E0B; }
.action-flag.ALERT { background: rgba(239, 68, 68, 0.2); color: #EF4444; }

.dominant-condition {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.zone-summary {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.zones-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.zone-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.zone-id {
  font-weight: 600;
  color: var(--text-primary);
}

.zone-stats {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  gap: 1rem;
}

.zone-severity {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}
.zone-severity.CRITICAL { background: rgba(239, 68, 68, 0.2); color: #EF4444; }
.zone-severity.HIGH { background: rgba(245, 158, 11, 0.2); color: #F59E0B; }
.zone-severity.MODERATE { background: rgba(16, 185, 129, 0.2); color: #10B981; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .app { padding: 1.5rem 1rem 3rem; }
  .header h1 { font-size: 1.6rem; }
  .card { padding: 1.25rem; }
  .dropzone { padding: 2rem 1.25rem; }
  .gauges-grid { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
  .gauge-svg { width: 76px; height: 76px; }
  .gauge-value { font-size: 1.1rem; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
  .stat-value { font-size: 1.15rem; }
  .view-tabs { flex-wrap: wrap; }
  .view-tab { font-size: 0.75rem; padding: 0.45rem 0.5rem; }
  .progress-line { width: 24px; }
  .image-display { max-width: 100%; }
  
  .score-container { flex-direction: column; text-align: center; gap: 1.5rem; }
  .score-details { align-items: center; }
}

@media (max-width: 380px) {
  .gauges-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
}
