/* ================================================================
   EnerGreen — Spirulina Surveillance
   Complete CSS — Professional dashboard theme
   ================================================================ */

/* -------- Reset & Variables -------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Brand */
  --primary: #1b4332;
  --primary-light: #2d6a4f;
  --secondary: #52b788;
  --accent: #74c69d;
  --accent-light: #b7e4c7;

  /* Sensor */
  --temp: #ef5350;
  --temp-glow: rgba(239, 83, 80, 0.15);
  --ph: #26c6da;
  --ph-glow: rgba(38, 198, 218, 0.15);
  --turb: #66bb6a;
  --turb-glow: rgba(102, 187, 106, 0.15);
  --waterlevel: #42a5f5;
  --waterlevel-glow: rgba(66, 165, 245, 0.15);
  --light: #ffa726;
  --light-glow: rgba(255, 167, 38, 0.15);

  /* Semantic */
  --danger: #d32f2f;
  --warning: #f57c00;
  --success: #2e7d32;
  --info: #1565c0;

  /* Neutrals */
  --bg: #f0f4f3;
  --card: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #5a6872;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);

  /* Radii */
  --radius: 14px;
  --radius-lg: 22px;

  /* Font */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html {
  scroll-behavior: smooth;
}

/* -------- Utility -------- */
.hidden {
  display: none !important;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ================================================================
   HEADER — White background so green logo pops
   ================================================================ */
.header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  color: var(--text);
  padding: 0.75rem 0;
  box-shadow: 0 1px 20px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 200;
  border-bottom: 1px solid rgba(226, 232, 240, 0.6);
  transition: all 0.3s;
}
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.header-left {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.header-center {
  flex: 1;
  text-align: center;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.logo-link {
  display: inline-flex;
  text-decoration: none;
}
.logo-img {
  height: 52px;
  width: auto;
  object-fit: contain;
  transition: transform 0.3s;
}
.logo-img:hover {
  transform: scale(1.05);
}

.header-tagline {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.3px;
}
.header-tagline i {
  color: var(--secondary);
  font-size: 0.85rem;
}

/* Spirulina accent bar */
.spirulina-bar {
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--primary),
    var(--secondary) 40%,
    var(--accent) 70%,
    var(--accent-light)
  );
  background-size: 200% 100%;
  animation: shimmerBar 3s ease infinite;
}
@keyframes shimmerBar {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Connection badge */
.connection-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  background: rgba(240, 244, 243, 0.8);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  transition: all 0.3s;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  transition: all 0.4s;
}
.status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 8px rgba(46, 125, 50, 0.6);
  animation: dotPulse 2s infinite;
}
@keyframes dotPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 currentColor;
  }
  50% {
    box-shadow: 0 0 0 4px transparent;
  }
}

/* Buttons */
.btn-connect {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 16px;
  border: none;
  border-radius: 10px;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(27, 67, 50, 0.2);
}
.btn-connect:hover {
  background: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(27, 67, 50, 0.3);
}
.btn-connect.active {
  background: var(--danger);
  color: #fff;
}
.btn-connect.active:hover {
  background: #c62828;
}

/* ================================================================
   COMPAT BANNER
   ================================================================ */
.compat-banner {
  display: none;
  background: linear-gradient(135deg, #fff3e0, #ffe0b2);
  color: #e65100;
  padding: 12px 0;
  font-size: 0.9rem;
  font-weight: 500;
}
.compat-banner.show {
  display: block;
}
.compat-banner .container {
  display: flex;
  align-items: center;
  gap: 10px;
}
.compat-banner a {
  color: #bf360c;
  font-weight: 600;
}

/* ================================================================
   ALERT BANNER
   ================================================================ */
.alert-banner {
  background: linear-gradient(135deg, #d32f2f, #f44336);
  color: #fff;
  text-align: center;
  font-weight: 600;
  font-size: 0.95rem;
  max-height: 0;
  overflow: hidden;
  transition: all 0.35s ease;
}
.alert-banner.show {
  padding: 14px;
  max-height: 120px;
}

/* ================================================================
   HERO SECTION (before connection)
   ================================================================ */
.hero-section {
  padding: 3rem 0;
  flex: 1;
  display: flex;
  align-items: center;
}
.hero-section.hidden {
  display: none;
}

.hero-card {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  padding: 3rem 3rem 2.5rem;
  text-align: center;
  max-width: 820px;
  margin: 0 auto;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(255, 255, 255, 0.5) inset;
  border: 1px solid rgba(226, 232, 240, 0.5);
  position: relative;
  overflow: hidden;
  animation: heroCardIn 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes heroCardIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.hero-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(
    90deg,
    var(--primary),
    var(--secondary),
    var(--accent)
  );
}

.hero-logo-wrap {
  margin: 0 auto 1.25rem;
  display: flex;
  justify-content: center;
  align-items: center;
}
.hero-logo-img {
  height: 90px;
  width: auto;
  object-fit: contain;
}

.spirulina-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 1.25rem;
}
.spirulina-badge i {
  font-size: 0.8rem;
  opacity: 0.85;
}

.hero-card h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--primary);
}
.hero-card > p {
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto 2rem;
  line-height: 1.7;
  font-size: 0.95rem;
}

/* Steps */
.hero-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 1rem;
  background: var(--bg);
  border-radius: var(--radius);
  min-width: 120px;
  transition: all 0.3s;
}
.step:hover {
  background: rgba(82, 183, 136, 0.1);
  transform: translateY(-3px);
}
.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--secondary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
}
.step-text {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
}
.step-arrow {
  color: var(--accent);
  font-size: 1rem;
}

/* Hero buttons */
.hero-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.btn-hero-connect {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  box-shadow: 0 4px 15px rgba(27, 67, 50, 0.3);
  position: relative;
  overflow: hidden;
}
.btn-hero-connect::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 40%,
    rgba(255, 255, 255, 0.15) 50%,
    transparent 60%
  );
  animation: btnShimmer 3s ease-in-out infinite;
}
@keyframes btnShimmer {
  0% {
    transform: translateX(-100%) rotate(25deg);
  }
  100% {
    transform: translateX(100%) rotate(25deg);
  }
}
.btn-hero-connect:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(27, 67, 50, 0.4);
}

.hero-note {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.hero-note code {
  background: var(--bg);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--primary-light);
}

/* ================================================================
   DASHBOARD
   ================================================================ */
.dashboard {
  display: none;
  padding: 2.5rem 0;
  flex: 1;
  animation: dashFadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.dashboard.show {
  display: block;
}

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

.section-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title i {
  color: var(--secondary);
  font-size: 1.1rem;
}

/* ================================================================
   GAUGE CARDS
   ================================================================ */
.gauges-section {
  margin-bottom: 2.5rem;
}

/* ── Device Status Bar ── */
.device-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.device-status-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.device-status-indicator {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}
.device-status-indicator.online {
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}
.device-status-indicator.online .device-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid #22c55e;
  animation: devicePulse 2s ease-out infinite;
}
.device-status-indicator.offline {
  background: #94a3b8;
}
.device-status-indicator.offline .device-pulse {
  display: none;
}
@keyframes devicePulse {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.8);
  }
}
.device-status-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.device-status-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}
.device-status-detail {
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.device-status-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.device-status-meta {
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* ── Gauges Grid — 5 cards in one row ── */
.gauges-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
}

.gauge-card {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(226, 232, 240, 0.6);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}
.gauge-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--border);
  transition: background 0.3s;
}
#tempCard::before {
  background: var(--temp);
}
#phCard::before {
  background: var(--ph);
}
#turbidityCard::before {
  background: var(--turb);
}
#waterLevelCard::before {
  background: var(--waterlevel);
}
#lightCard::before {
  background: var(--light);
}

.gauge-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.1);
  border-color: rgba(82, 183, 136, 0.2);
}
.gauge-card.warning {
  border-color: var(--danger);
  animation: cardPulse 1.5s infinite;
  box-shadow: 0 4px 20px rgba(211, 47, 47, 0.1);
}

@keyframes cardPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.3);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(211, 47, 47, 0);
  }
}

.gauge-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0.75rem;
}
.gauge-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.9rem;
  transition:
    transform 0.3s,
    box-shadow 0.3s;
}
.gauge-card:hover .gauge-icon {
  transform: scale(1.1) rotate(-5deg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.temp-bg {
  background: linear-gradient(135deg, var(--temp), #ef9a9a);
}
.ph-bg {
  background: linear-gradient(135deg, var(--ph), #80deea);
}
.turbidity-bg {
  background: linear-gradient(135deg, var(--turb), #a5d6a7);
}
.waterlevel-bg {
  background: linear-gradient(135deg, var(--waterlevel), #90caf9);
}
.light-bg {
  background: linear-gradient(135deg, var(--light), #ffcc80);
}

.gauge-header h3 {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 600;
}

.gauge-badge {
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: rgba(46, 125, 50, 0.1);
  color: var(--success);
  white-space: nowrap;
  flex-shrink: 0;
}
.gauge-badge.warning {
  background: rgba(211, 47, 47, 0.1);
  color: var(--danger);
  animation: badgePulse 1s infinite;
}
.gauge-badge.critical {
  background: rgba(211, 47, 47, 0.15);
  color: var(--danger);
  animation: badgePulse 0.7s infinite;
}
@keyframes badgePulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* Gauge canvas */
.gauge-body {
  display: flex;
  justify-content: center;
  padding: 0.5rem 0;
}
.gauge-canvas-wrap {
  position: relative;
  width: 170px;
  height: 105px;
}
.gauge-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}
.gauge-center-label {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}
.gauge-center-label .value {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--primary);
}
.gauge-center-label .unit {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-left: 2px;
}

/* Threshold bar */
.gauge-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 0.75rem;
}
.range-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  white-space: nowrap;
}
.threshold-bar {
  flex: 1;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  position: relative;
  overflow: visible;
}
.threshold-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
  width: 0;
}
.temp-fill {
  background: linear-gradient(90deg, #ffcc02, var(--temp));
}
.ph-fill {
  background: linear-gradient(90deg, var(--danger), var(--ph), var(--info));
}
.turbidity-fill {
  background: linear-gradient(90deg, var(--turb), #2e7d32);
}
.waterlevel-fill {
  background: linear-gradient(90deg, var(--danger), var(--waterlevel));
}
.light-fill {
  background: linear-gradient(90deg, #37474f, var(--light));
}

.threshold-marker {
  position: absolute;
  top: -4px;
  transform: translateX(-50%);
}
.marker-line {
  width: 2px;
  height: 14px;
  background: var(--danger);
  border-radius: 1px;
}

/* ================================================================
   CHARTS
   ================================================================ */
.charts-section {
  margin-bottom: 2.5rem;
}

/* ---- Time Range Bar ---- */
.time-range-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.time-range-pills {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.time-pill {
  padding: 0.45rem 1rem;
  border: 1.5px solid var(--border);
  background: var(--card);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.time-pill:hover {
  border-color: var(--secondary);
  color: var(--primary);
  background: var(--accent-light);
}
.time-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(27, 67, 50, 0.25);
}
.time-range-actions {
  display: flex;
  gap: 0.4rem;
}
.export-btn {
  padding: 0.45rem 0.85rem;
  border: 1.5px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s;
}
.export-btn:hover {
  border-color: var(--secondary);
  color: var(--primary);
  background: var(--accent-light);
}
.export-btn:active {
  transform: scale(0.97);
}

/* ---- History Loading ---- */
.history-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.history-loading i {
  color: var(--secondary);
  font-size: 1.1rem;
}

/* ---- Date Range Modal ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  z-index: 900;
}
.date-range-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 0;
  width: 380px;
  max-width: 92vw;
  z-index: 950;
  overflow: hidden;
}
.date-range-modal .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.date-range-modal .modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.date-range-modal .modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.date-range-modal .modal-close:hover {
  color: var(--danger);
}
.date-range-modal .modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.date-field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}
.date-field input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  font-size: 0.9rem;
  font-family: var(--font);
  background: var(--bg);
  transition: border-color 0.2s;
}
.date-field input:focus {
  border-color: var(--secondary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(82, 183, 136, 0.15);
}
.date-range-modal .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}
.modal-btn {
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--border);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.modal-btn.cancel {
  background: var(--card);
  color: var(--text-secondary);
}
.modal-btn.cancel:hover {
  background: var(--bg);
}
.modal-btn.apply {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.modal-btn.apply:hover {
  background: var(--primary-light);
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}
.chart-card {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(226, 232, 240, 0.6);
  transition: all 0.3s;
}
.chart-card:hover {
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}
/* removed full-width rule since all charts now occupy equal grid cells */
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.chart-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chart-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}
.chart-card canvas {
  height: 220px !important;
}

/* ================================================================
   STATS
   ================================================================ */
.stats-section {
  margin-bottom: 2rem;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(226, 232, 240, 0.5);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.stat-card:hover {
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
  transform: translateY(-3px);
  border-color: rgba(82, 183, 136, 0.2);
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  color: #fff;
  flex-shrink: 0;
  transition: transform 0.3s;
}
.stat-card:hover .stat-icon {
  transform: scale(1.1) rotate(-5deg);
}
.temp-icon {
  background: linear-gradient(135deg, var(--temp), #ef9a9a);
}
.ph-icon {
  background: linear-gradient(135deg, var(--ph), #80deea);
}
.turbidity-icon {
  background: linear-gradient(135deg, var(--turb), #a5d6a7);
}
.waterlevel-icon {
  background: linear-gradient(135deg, var(--waterlevel), #90caf9);
}
.light-icon {
  background: linear-gradient(135deg, var(--light), #ffcc80);
}
.readings-icon {
  background: linear-gradient(135deg, #7e57c2, #b39ddb);
}
.alert-icon {
  background: linear-gradient(135deg, var(--warning), #ffb74d);
}
.time-icon {
  background: linear-gradient(135deg, #42a5f5, #90caf9);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 2px;
}
.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}
.stat-value-sm {
  font-size: 0.95rem;
}

/* ================================================================
   FOOTER
   ================================================================ */
.footer {
  background: linear-gradient(135deg, var(--primary) 0%, #0d2818 100%);
  color: #fff;
  padding: 1.75rem 0;
  text-align: center;
  margin-top: auto;
  position: relative;
}
.footer::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--accent),
    var(--secondary),
    var(--primary)
  );
  background-size: 200% 100%;
  animation: shimmerBar 3s ease infinite;
}
.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}
.footer-logo {
  height: 36px;
  width: auto;
  filter: brightness(0) invert(1);
  opacity: 0.9;
}
.footer-text p {
  margin: 2px 0;
  font-size: 0.82rem;
  opacity: 0.85;
}
.footer-tech {
  font-size: 0.72rem !important;
  opacity: 0.55 !important;
}

/* ================================================================
   TOAST NOTIFICATIONS
   ================================================================ */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  border-left: 4px solid var(--info);
  font-size: 0.85rem;
  font-weight: 500;
  animation: toastIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 400px;
}
.toast.success {
  border-left-color: var(--success);
}
.toast.error {
  border-left-color: var(--danger);
}
.toast.warning {
  border-left-color: var(--warning);
}
.toast i {
  font-size: 1.1rem;
}
.toast.success i {
  color: var(--success);
}
.toast.error i {
  color: var(--danger);
}
.toast.warning i {
  color: var(--warning);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 1100px) {
  .gauges-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .charts-grid {
    grid-template-columns: 1fr;
  }
  .chart-card.full-width {
    grid-column: auto;
  }
}
@media (max-width: 860px) {
  .header-center {
    display: none;
  }
  .header-inner {
    gap: 0.5rem;
  }
  .logo-img {
    height: 42px;
  }
  .gauges-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .hero-steps {
    gap: 0.5rem;
  }
  .step {
    min-width: 100px;
    padding: 0.75rem;
  }
}
@media (max-width: 640px) {
  .header-inner {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
  }
  .header-left {
    width: 100%;
    justify-content: center;
  }
  .header-right {
    width: 100%;
    justify-content: center;
    gap: 0.4rem;
  }
  .btn-connect span {
    display: none;
  }
  .btn-connect {
    padding: 8px 12px;
  }
  .connection-badge {
    font-size: 0.72rem;
    padding: 4px 10px;
  }
  .hero-section {
    padding: 2rem 0;
  }
  .hero-card {
    padding: 2rem 1.5rem 1.75rem;
  }
  .hero-logo-img {
    height: 70px;
  }
  .hero-card h2 {
    font-size: 1.3rem;
  }
  .hero-steps {
    flex-direction: column;
    gap: 0.4rem;
  }
  .step-arrow {
    transform: rotate(90deg);
    font-size: 0.75rem;
  }
  .step {
    flex-direction: row;
    min-width: auto;
    width: 100%;
    justify-content: flex-start;
    gap: 10px;
    padding: 0.6rem 0.8rem;
  }
  .hero-actions {
    flex-direction: column;
  }
  .btn-hero-connect {
    width: 100%;
    justify-content: center;
  }
  .gauges-grid {
    grid-template-columns: 1fr;
  }
  .device-status-bar {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
  }
  .device-status-left {
    justify-content: center;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .section-title {
    font-size: 1.1rem;
  }
  .gauge-card {
    padding: 1.25rem;
  }
  .time-range-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .time-range-pills {
    justify-content: center;
  }
  .time-range-actions {
    justify-content: center;
  }
  .time-pill {
    padding: 0.4rem 0.7rem;
    font-size: 0.75rem;
  }
}
@media (max-width: 400px) {
  .container {
    padding: 0 0.75rem;
  }
  .hero-card {
    padding: 1.5rem 1rem 1.25rem;
  }
  .hero-logo-img {
    height: 56px;
  }
  .spirulina-badge {
    font-size: 0.65rem;
    padding: 5px 12px;
  }
  .gauge-center-label .value {
    font-size: 1.5rem;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .stat-card {
    padding: 1rem;
  }
  .chart-card {
    padding: 1rem;
  }
  .chart-card canvas {
    height: 170px !important;
  }
  .footer-logo {
    height: 28px;
  }
}

/* Print */
@media print {
  .header,
  .footer,
  .hero-section,
  .toast-container,
  .compat-banner,
  .alert-banner,
  .spirulina-bar,
  .login-overlay {
    display: none !important;
  }
  .dashboard {
    display: block !important;
  }
}

/* ================================================================
   LOGIN OVERLAY
   ================================================================ */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    #0d2818 50%,
    #1b4332 100%
  );
  background-size: 300% 300%;
  animation: loginGradient 8s ease infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
@keyframes loginGradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}
.login-overlay.hidden {
  display: none;
}

/* Auth loading screen — shown while Firebase checks session */
.auth-loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9500;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease;
}
.auth-loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}
.auth-loading-spinner {
  width: 38px;
  height: 38px;
  border: 4px solid rgba(82, 183, 136, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.login-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
  text-align: center;
  position: relative;
  overflow: hidden;
  animation: loginCardIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes loginCardIn {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.login-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(
    90deg,
    var(--primary),
    var(--secondary),
    var(--accent)
  );
}
.login-logo-wrap {
  margin-bottom: 1rem;
}
.login-logo {
  height: 72px;
  width: auto;
  object-fit: contain;
}
.login-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  padding: 5px 16px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}
.login-badge i {
  font-size: 0.75rem;
  opacity: 0.85;
}

/* Tabs */
.login-tabs {
  display: flex;
  background: var(--bg);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 1.5rem;
}
.login-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
}
.login-tab.active {
  background: var(--card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Forms */
.login-form {
  text-align: left;
}
.login-form.hidden {
  display: none;
}
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.form-group label i {
  color: var(--secondary);
  margin-right: 4px;
  font-size: 0.75rem;
}
.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  transition: all 0.2s;
  outline: none;
}
.form-group input:focus {
  border-color: var(--secondary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(82, 183, 136, 0.15);
}
.form-group input::placeholder {
  color: #aab4bd;
}
.form-error {
  color: var(--danger);
  font-size: 0.8rem;
  font-weight: 500;
  min-height: 1.2rem;
  margin-bottom: 0.5rem;
}
.btn-login {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 10px;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
}
.btn-login::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 40%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 60%
  );
  animation: btnShimmer 3s ease-in-out infinite;
}
.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(27, 67, 50, 0.35);
}
.btn-login:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Divider */
.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 1.25rem 0;
  color: var(--text-secondary);
  font-size: 0.78rem;
}
.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Google button */
.btn-google {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  background: #fff;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn-google:hover {
  background: #f8f9fa;
  border-color: #dadce0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.btn-google svg {
  flex-shrink: 0;
}

.login-footer-text {
  margin-top: 1.25rem;
  font-size: 0.72rem;
  color: var(--text-secondary);
  opacity: 0.7;
}

/* ================================================================
   USER BADGE & LOGOUT (Header)
   ================================================================ */
.user-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(82, 183, 136, 0.1);
  border: 1px solid rgba(82, 183, 136, 0.25);
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--primary);
}
.user-badge i {
  color: var(--secondary);
  font-size: 0.9rem;
}
.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg);
  color: var(--text-secondary);
}
.btn-logout:hover {
  background: #fee2e2;
  color: var(--danger);
  border-color: #fca5a5;
}

/* Phone mode info box */
.phone-mode-info {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: linear-gradient(
    135deg,
    rgba(82, 183, 136, 0.08),
    rgba(116, 198, 157, 0.08)
  );
  border: 1px solid rgba(82, 183, 136, 0.2);
  border-radius: var(--radius);
}
.phone-mode-info.hidden {
  display: none;
}
.phone-mode-icon {
  font-size: 2rem;
  color: var(--secondary);
  margin-bottom: 0.5rem;
}
.phone-mode-info h3 {
  font-size: 1.1rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}
.phone-mode-info > p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  line-height: 1.6;
}

/* Responsive additions for login */
@media (max-width: 480px) {
  .login-card {
    padding: 2rem 1.5rem 1.5rem;
  }
  .login-logo {
    height: 56px;
  }
  .login-badge {
    font-size: 0.62rem;
    padding: 4px 12px;
  }
}
@media (max-width: 640px) {
  .user-badge span {
    display: none;
  }
  .btn-logout span {
    display: none;
  }
  .btn-logout {
    padding: 8px 10px;
  }
}

/* ───────────────────── LANG SWITCH ───────────────────── */
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0;
  background: var(--bg);
  cursor: pointer;
  overflow: hidden;
  font-family: var(--font);
  transition: border-color 0.2s;
}
.lang-switch:hover {
  border-color: var(--secondary);
}
.lang-switch span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  transition: all 0.2s;
}
.lang-switch span.active {
  background: var(--primary);
  color: #fff;
}

/* ================================================================
   PRICING OVERLAY (post-login plan selection)
   ================================================================ */
.pricing-overlay {
  position: fixed;
  inset: 0;
  z-index: 8500;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    #0d2818 50%,
    #1b4332 100%
  );
  background-size: 300% 300%;
  animation: loginGradient 8s ease infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}
.pricing-overlay.hidden {
  display: none;
}

.pricing-overlay-inner {
  width: 100%;
  max-width: 1000px;
  text-align: center;
  animation: loginCardIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.pricing-logo {
  height: 60px;
  margin-bottom: 0.75rem;
  filter: brightness(0) invert(1);
}
.pricing-overlay-header h2 {
  color: #fff;
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
}
.pricing-overlay-header h2 i {
  color: var(--accent);
}
.pricing-overlay-header p {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
  max-width: 520px;
  margin: 0 auto 2rem;
  line-height: 1.6;
}

.pricing-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.po-card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  text-align: center;
  position: relative;
  border: 2px solid transparent;
  transition: all 0.3s;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}
.po-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.2);
}
.po-card.popular {
  border-color: var(--secondary);
  transform: scale(1.04);
  box-shadow: 0 12px 40px rgba(82, 183, 136, 0.25);
}
.po-card.popular:hover {
  transform: scale(1.04) translateY(-6px);
}
.po-popular-tag {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--secondary), var(--accent));
  color: #fff;
  padding: 4px 20px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.po-card-header h3 {
  font-size: 1.1rem;
  color: var(--primary);
  margin-bottom: 0.75rem;
}
.po-price {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.25rem;
}
.po-price span {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.po-price-note {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.po-features {
  list-style: none;
  text-align: left;
  margin-bottom: 1.5rem;
}
.po-features li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 0.82rem;
  color: var(--text);
}
.po-features li i.fa-check {
  color: var(--success);
}
.po-features li i.fa-times {
  color: #ccc;
}
.po-features li.disabled {
  color: #bbb;
  text-decoration: line-through;
}

.po-btn {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  background: #fff;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.po-btn:hover {
  background: var(--accent-light);
  border-color: var(--secondary);
}
.po-btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  border-color: transparent;
}
.po-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(27, 67, 50, 0.3);
}

.po-logout-link {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-family: var(--font);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 8px 16px;
  transition: color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.po-logout-link:hover {
  color: #fff;
}

@media (max-width: 860px) {
  .pricing-cards-grid {
    grid-template-columns: 1fr;
    max-width: 400px;
    margin: 0 auto 1.5rem;
  }
  .po-card.popular {
    transform: none;
  }
  .po-card.popular:hover {
    transform: translateY(-6px);
  }
}

/* ================================================================
   PAYMENT OVERLAY
   ================================================================ */
.payment-overlay {
  position: fixed;
  inset: 0;
  z-index: 8500;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    #0d2818 50%,
    #1b4332 100%
  );
  background-size: 300% 300%;
  animation: loginGradient 8s ease infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}
.payment-overlay.hidden {
  display: none;
}

.payment-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 580px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
  text-align: center;
  position: relative;
  overflow: hidden;
  animation: loginCardIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.payment-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(
    90deg,
    var(--primary),
    var(--secondary),
    var(--accent)
  );
}
.payment-logo {
  height: 56px;
  margin-bottom: 0.75rem;
}
.payment-header h2 {
  font-size: 1.4rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}
.payment-header h2 i {
  color: var(--secondary);
}
.payment-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.bank-info-box {
  background: linear-gradient(135deg, #f0f4f3, #e8f5e9);
  border: 1px solid rgba(82, 183, 136, 0.3);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: left;
  margin-bottom: 1.5rem;
}
.bank-info-box h3 {
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.bank-info-box h3 i {
  color: var(--secondary);
}

.bank-details {
  display: grid;
  gap: 8px;
  margin-bottom: 1rem;
}
.bank-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 8px;
}
.bank-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.bank-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary);
  font-family: "Courier New", monospace;
}
.ccp-number {
  font-size: 1.05rem;
  color: var(--success);
}
.bank-note {
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.5;
}
.bank-note i {
  color: var(--info);
  margin-top: 2px;
}

.payment-form {
  text-align: left;
  margin-bottom: 1rem;
}
.field-hint {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.5;
}
.payment-contact {
  margin-top: 1rem;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
}
.payment-contact p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.payment-contact i {
  color: var(--secondary);
}

/* ── File Upload Area ── */
.file-upload-area {
  border: 2px dashed rgba(82, 183, 136, 0.35);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  background: rgba(82, 183, 136, 0.04);
  position: relative;
}
.file-upload-area:hover {
  border-color: var(--primary);
  background: rgba(82, 183, 136, 0.08);
}
.file-upload-placeholder i {
  font-size: 2rem;
  color: var(--primary);
  opacity: 0.5;
  display: block;
  margin-bottom: 0.5rem;
}
.file-upload-placeholder p {
  font-size: 0.9rem;
  color: var(--text);
  margin: 0 0 0.25rem;
}
.file-upload-placeholder span {
  font-size: 0.72rem;
  color: var(--text-secondary);
}
.file-upload-preview {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-align: left;
}
.file-upload-preview.hidden {
  display: none;
}
.file-upload-preview img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid rgba(82, 183, 136, 0.25);
}
.file-upload-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.file-upload-info span:first-child {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  word-break: break-all;
}
.file-upload-info span:last-child {
  font-size: 0.72rem;
  color: var(--text-secondary);
}
.file-remove-btn {
  background: rgba(211, 47, 47, 0.1);
  color: #d32f2f;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.file-remove-btn:hover {
  background: #d32f2f;
  color: white;
}
.proof-or-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
}
.proof-or-divider hr {
  flex: 1;
  border: none;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
}

/* ================================================================
   PENDING REVIEW OVERLAY
   ================================================================ */
.pending-review-overlay {
  position: fixed;
  inset: 0;
  z-index: 8500;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    #0d2818 50%,
    #1b4332 100%
  );
  background-size: 300% 300%;
  animation: loginGradient 8s ease infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.pending-review-overlay.hidden {
  display: none;
}

.pending-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
  text-align: center;
  animation: loginCardIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
  position: relative;
  overflow: hidden;
}
.pending-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--warning), #ffb74d, var(--warning));
  background-size: 200% 100%;
  animation: shimmerBar 2s ease infinite;
}
.pending-logo {
  height: 56px;
  margin-bottom: 1rem;
}
.pending-icon {
  font-size: 3rem;
  color: var(--warning);
  margin-bottom: 1rem;
  animation: pendingPulse 2s ease infinite;
}
@keyframes pendingPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}
.pending-card h2 {
  font-size: 1.4rem;
  color: var(--primary);
  margin-bottom: 0.75rem;
}
.pending-card > p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 1.5rem;
}
.pending-status-box {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  background: rgba(245, 124, 0, 0.08);
  border: 1px solid rgba(245, 124, 0, 0.25);
  border-radius: 24px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--warning);
  margin-bottom: 1rem;
}
.pending-dot {
  width: 10px;
  height: 10px;
  background: var(--warning);
  border-radius: 50%;
  animation: dotPulse 2s infinite;
}
.pending-note {
  font-size: 0.78rem;
  color: var(--text-secondary);
  opacity: 0.7;
  margin-bottom: 1.5rem;
}

/* ================================================================
   PROFILE PANEL (slide-in from right)
   ================================================================ */
.profile-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 9998;
  opacity: 1;
  transition: opacity 0.3s;
}
.profile-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}
.profile-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 370px;
  max-width: 92vw;
  height: 100vh;
  background: var(--bg);
  box-shadow: -6px 0 32px rgba(0, 0, 0, 0.12);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}
.profile-panel.hidden {
  transform: translateX(110%);
}

/* Header */
.profile-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
}
.profile-panel-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.profile-close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}
.profile-close-btn:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* Body */
.profile-panel-body {
  padding: 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Avatar section */
.profile-avatar-section {
  text-align: center;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 1.8rem;
  color: #fff;
  box-shadow: 0 4px 16px rgba(82, 183, 136, 0.3);
}
.profile-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.profile-email {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* Sections */
.profile-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.profile-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.profile-section-label i {
  color: var(--primary);
  font-size: 0.8rem;
}

/* Plan card */
.profile-plan-card {
  background: linear-gradient(
    135deg,
    rgba(82, 183, 136, 0.08),
    rgba(116, 198, 157, 0.06)
  );
  border: 1px solid rgba(82, 183, 136, 0.25);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.profile-plan-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}
.profile-plan-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 500;
}
.profile-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
}
.profile-plan-status.active .profile-status-dot {
  background: var(--success);
  box-shadow: 0 0 6px rgba(82, 183, 136, 0.5);
}
.profile-plan-status.pending .profile-status-dot {
  background: var(--warning);
  animation: dotPulse 2s infinite;
}
.profile-plan-status.inactive .profile-status-dot {
  background: var(--danger);
}

/* Detail rows */
.profile-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: 8px;
  font-size: 0.84rem;
}
.profile-detail-label {
  color: var(--text-secondary);
  font-weight: 500;
}
.profile-detail-value {
  font-weight: 600;
  color: var(--text-primary);
}

/* Actions */
.profile-actions {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.profile-btn-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border: 1px solid #fca5a5;
  border-radius: 10px;
  background: #fef2f2;
  color: var(--danger);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.profile-btn-logout:hover {
  background: #fee2e2;
  border-color: var(--danger);
}

/* Mobile */
@media (max-width: 480px) {
  .profile-panel {
    width: 100vw;
    max-width: 100vw;
  }
}

/* ================================================================
   LAB DASHBOARD — clean, minimalist, scientific
   ================================================================ */

/* ── Layout shell ── */
.lab-dashboard {
  padding: 1.75rem 0 3rem;
  background: #f4f6f5;
}

.lab-shell {
  display: grid;
  gap: 1rem;
}

/* ── Base card ── */
.lab-card {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 16px;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.05),
    0 4px 16px rgba(0, 0, 0, 0.04);
  padding: 1.1rem 1.15rem;
}

/* ── Status pill ── */
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.32rem 0.8rem;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border: 1px solid transparent;
}

.status-pill.safe {
  background: rgba(46, 125, 50, 0.09);
  color: #2e7d32;
  border-color: rgba(46, 125, 50, 0.18);
}

.status-pill.warning {
  background: rgba(230, 120, 0, 0.09);
  color: #c46a00;
  border-color: rgba(230, 120, 0, 0.2);
}

.status-pill.critical {
  background: rgba(198, 40, 40, 0.09);
  color: #c62828;
  border-color: rgba(198, 40, 40, 0.2);
}

.status-pill.status-pill--muted {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-secondary);
  border-color: rgba(0, 0, 0, 0.06);
}

/* keep backwards-compat aliases used by JS setToneClass */
.hero-status-pill {
  /* maps to status-pill, kept for JS compat */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.32rem 0.8rem;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border: 1px solid transparent;
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-secondary);
}

.hero-status-pill.safe {
  background: rgba(46, 125, 50, 0.09);
  color: #2e7d32;
  border-color: rgba(46, 125, 50, 0.18);
}

.hero-status-pill.warning {
  background: rgba(230, 120, 0, 0.09);
  color: #c46a00;
  border-color: rgba(230, 120, 0, 0.2);
}

.hero-status-pill.critical {
  background: rgba(198, 40, 40, 0.09);
  color: #c62828;
  border-color: rgba(198, 40, 40, 0.2);
}

.hero-status-pill.secondary {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-secondary);
  border-color: rgba(0, 0, 0, 0.06);
}

/* ── GHI band ── */
.ghi-band {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
  padding: 1.1rem 1.5rem;
}

.ghi-score-cluster {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-shrink: 0;
}

.ghi-numeral-wrap {
  display: flex;
  align-items: flex-end;
  gap: 0.2rem;
}

.ghi-numeral {
  font-size: clamp(3rem, 4.5vw, 4rem);
  line-height: 0.9;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.ghi-numeral-unit {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.ghi-text {
  max-width: 28rem;
}

.ghi-eyebrow {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--secondary);
  font-weight: 700;
  margin-bottom: 0.3rem;
}

.ghi-meta {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.4;
}

.ghi-stats {
  display: flex;
  gap: 2rem;
  margin-left: auto;
  flex-wrap: wrap;
}

.ghi-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.ghi-stat-k {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 0.2rem;
}

.ghi-stat strong {
  font-size: 0.97rem;
  font-weight: 700;
  color: var(--text);
}

/* ── Toolbar band ── */
.toolbar-band {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  padding: 0.85rem 1.25rem;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}

.toolbar-band .history-loading {
  margin-left: auto;
  font-size: 0.82rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Telemetry grid ── */
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1rem;
  align-items: stretch;
}

.metric-card {
  grid-column: span 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ── Binary water level indicator ── */
.wl-state {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.35rem 0;
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
}

.wl-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.12);
  transition:
    background 0.35s,
    box-shadow 0.35s;
}

.wl-dot--on {
  background: #1e88e5;
  box-shadow: 0 0 0 5px rgba(30, 136, 229, 0.14);
}

.wl-dot--off {
  background: #c62828;
  box-shadow: 0 0 0 5px rgba(198, 40, 40, 0.14);
}

/* ── Metric card internals ── */
.metric-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
  min-width: 0;
  overflow: hidden;
}

.metric-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.metric-value-row {
  display: flex;
  align-items: flex-end;
  gap: 0.25rem;
  margin-bottom: 0.35rem;
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
}

.metric-value {
  font-size: clamp(1.45rem, 2.8vw, 2rem);
  line-height: 1;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.metric-value-xl .metric-value {
  font-size: clamp(2.5rem, 5.5vw, 3.8rem);
}

.metric-value-text {
  font-size: clamp(1.3rem, 2.5vw, 1.8rem);
}

.metric-unit {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.78rem;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.metric-note {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.35;
  margin: 0.2rem 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Sparkline ── */
.sparkline-shell {
  flex: 1;
  min-height: 70px;
  max-height: 90px;
  margin: 0.65rem 0;
}

.sparkline-shell canvas {
  width: 100%;
  height: 100%;
}

/* ── Progress bars ── */
.lab-bar-track,
.safe-zone-track {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.07);
  overflow: hidden;
  margin-top: 0.75rem;
}

.lab-bar-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  transition: width 0.4s ease;
}

.temp-fill {
  background: linear-gradient(90deg, #ffab91, #ef5350);
}
.ph-fill {
  background: linear-gradient(90deg, #80deea, #00acc1);
}
.turbidity-fill {
  background: linear-gradient(90deg, #a5d6a7, #43a047);
}
.waterlevel-fill {
  background: linear-gradient(90deg, #90caf9, #1e88e5);
}
.light-fill {
  background: linear-gradient(90deg, #ffe082, #ffb300);
}

.lab-threshold {
  position: absolute;
  top: -1px;
  bottom: -1px;
  width: 2px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 1px;
}

.bar-range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--text-secondary);
  margin-top: 0.35rem;
  white-space: nowrap;
  overflow: hidden;
  gap: 0.2rem;
}

.range-label-center {
  text-align: center;
}

/* ── pH safe-zone overlay ── */
.safe-zone-track {
  background: rgba(0, 0, 0, 0.06);
  overflow: visible;
}

.safe-zone-window {
  position: absolute;
  left: 33.33%;
  width: 26.66%;
  top: 0;
  bottom: 0;
  border-radius: 999px;
  background: rgba(46, 125, 50, 0.15);
  border: 1px solid rgba(46, 125, 50, 0.28);
}

.safe-zone-marker {
  position: absolute;
  top: -4px;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  transition: left 0.35s ease;
}

/* ── Dual metric (biomass) ── */
.dual-metric-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
}

.dual-divider {
  width: 1px;
  align-self: stretch;
  background: rgba(0, 0, 0, 0.08);
}

.submetric-label {
  display: block;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-top: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Analysis stack (single column) ── */
.analysis-stack {
  display: grid;
  gap: 1rem;
}

/* ── Light Penetration Depth Advisory card ── */
.lp-advisory-card {
  padding: 1.25rem 1.5rem;
}

.lp-adv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.lp-adv-title-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.lp-adv-icon {
  font-size: 1rem;
  color: var(--secondary);
}

.lp-adv-body {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.lp-adv-metrics {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex-shrink: 0;
}

.lp-adv-metric {
  padding: 0 1.25rem;
  min-width: 110px;
}

.lp-adv-metric:first-child {
  padding-left: 0;
}

.lp-adv-divider {
  width: 1px;
  background: var(--border);
  align-self: stretch;
  flex-shrink: 0;
}

.lp-adv-text {
  flex: 1;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin: 0;
  padding: 0.25rem 0;
  min-width: 200px;
}

/* Sub-metrics inside PAR card */
.lp-sub-row {
  display: flex;
  align-items: center;
  gap: 0;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

.lp-sub-item {
  display: flex;
  flex-direction: column;
  flex: 1;
  align-items: center;
  gap: 1px;
}

.lp-sub-divider {
  width: 1px;
  height: 32px;
  background: var(--border);
  flex-shrink: 0;
}

.lp-sub-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.lp-sub-unit {
  font-size: 0.65rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.lp-sub-label {
  font-size: 0.65rem;
  color: var(--text-secondary);
  text-align: center;
}

/* ════════════════════════════════════════════════════════
   GROWTH PHASE PIPELINE
══════════════════════════════════════════════════════════ */
.phase-pipeline-card {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Header row: title + New Batch button */
.pipeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.pipeline-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.pipeline-icon {
  font-size: 1.2rem;
  color: var(--secondary, #52b788);
}
.pipeline-day-badge {
  display: inline-block;
  padding: 0.18rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 20px;
  background: var(--secondary, #52b788);
  color: #fff;
}
.btn-new-batch {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: var(--primary, #1b4332);
  color: #fff;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.1s;
  white-space: nowrap;
}
.btn-new-batch:hover {
  background: var(--primary-light, #2d6a4f);
}
.btn-new-batch:active {
  transform: scale(0.97);
}

/* Progress track */
.pipeline-track {
  position: relative;
  height: 7px;
  border-radius: 4px;
  background: var(--border, #e2e8f0);
  margin-bottom: 0.35rem;
  overflow: hidden;
}
.pipeline-progress {
  height: 100%;
  border-radius: 4px;
  transition: width 0.9s ease;
  background: var(--secondary, #52b788);
}
.pipeline-fill-lag {
  background: var(--secondary, #52b788);
}
.pipeline-fill-log {
  background: var(--primary, #1b4332);
}
.pipeline-fill-stationary {
  background: var(--warning, #f6a623);
}
.pipeline-fill-decline {
  background: var(--danger, #e53e3e);
}

/* Phase nodes row */
.pipeline-phases {
  display: flex;
  justify-content: space-between;
  margin: 0.5rem 0 0.75rem;
}
.phase-node {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.phase-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--border, #cbd5e0);
  background: var(--card, #fff);
  transition:
    background 0.3s,
    border-color 0.3s,
    box-shadow 0.3s;
}
.phase-node.done .phase-dot {
  background: var(--secondary, #52b788);
  border-color: var(--secondary, #52b788);
}
.phase-node.active .phase-dot {
  background: var(--primary, #1b4332);
  border-color: var(--primary, #1b4332);
  box-shadow: 0 0 0 4px rgba(27, 67, 50, 0.18);
}
.phase-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-secondary, #718096);
  text-align: center;
  line-height: 1.2;
}
.phase-sublabel {
  font-size: 0.65rem;
  color: var(--text-secondary, #a0aec0);
  text-align: center;
  line-height: 1.2;
}
.phase-node.active .phase-label {
  color: var(--primary, #1b4332);
  font-weight: 700;
}
.phase-node.done .phase-label {
  color: var(--secondary, #52b788);
}

/* Phase advisory text */
.pipeline-advisory-text {
  margin: 0 0 0.6rem;
  font-size: 0.87rem;
  color: var(--text-secondary, #718096);
  line-height: 1.5;
}

/* Benchmarking row */
.pipeline-bench {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--text-secondary, #718096);
  background: var(--background, #f8fafc);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  margin-top: 0.25rem;
}
.pipeline-bench i {
  color: var(--secondary, #52b788);
  flex-shrink: 0;
  margin-top: 2px;
}

/* ════════════════════════════════════════════════════════
   CLICKABLE SENSOR CARDS
══════════════════════════════════════════════════════════ */
.clickable-card {
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
  position: relative;
}
.clickable-card::after {
  content: "\f35d";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  position: absolute;
  top: 0.7rem;
  right: 0.8rem;
  font-size: 0.65rem;
  color: var(--text-secondary, #a0aec0);
  opacity: 0;
  transition: opacity 0.15s;
}
.clickable-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
}
.clickable-card:hover::after {
  opacity: 1;
}
.clickable-card:active {
  transform: translateY(0);
}

/* ════════════════════════════════════════════════════════
   SENSOR DETAIL MODAL
══════════════════════════════════════════════════════════ */
.sm-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.sm-box {
  background: var(--card, #fff);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 780px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: sm-pop 0.22s ease;
}
@keyframes sm-pop {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Pipeline banner across top */
.sm-pipeline-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1.25rem;
  background: linear-gradient(
    90deg,
    var(--primary, #1b4332),
    var(--secondary, #52b788)
  );
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
}
.sm-pipeline-banner i {
  opacity: 0.85;
}

/* Header */
.sm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border, #e2e8f0);
  flex-shrink: 0;
}
.sm-title-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.sm-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.sm-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}
.sm-subtitle {
  font-size: 0.73rem;
  color: var(--text-secondary, #718096);
}
.sm-header-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}
.sm-badge {
  font-size: 0.72rem;
}
.sm-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border, #e2e8f0);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition:
    background 0.15s,
    color 0.15s;
}
.sm-close-btn:hover {
  background: #fee2e2;
  color: #e53e3e;
  border-color: #fca5a5;
}

/* Body */
.sm-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

/* Chart */
.sm-chart-wrap {
  height: 230px;
  position: relative;
}
.sm-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Compare row */
.sm-compare-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.sm-compare-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.sm-compare-select {
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  background: var(--background, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  outline: none;
}

/* Stats grid */
.sm-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}
.sm-stat {
  flex: 1;
  min-width: 110px;
  background: var(--background, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
}
.sm-stat-val {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.sm-stat-unit {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.sm-stat-lbl {
  font-size: 0.68rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Insight box */
.sm-insight {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  background: rgba(82, 183, 136, 0.07);
  border: 1px solid rgba(82, 183, 136, 0.2);
  border-radius: 10px;
  padding: 0.75rem 1rem;
}
.sm-insight-icon {
  font-size: 1rem;
  color: var(--secondary, #52b788);
  flex-shrink: 0;
  padding-top: 2px;
}
.sm-insight p {
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--text);
  margin: 0;
}

/* Footer */
.sm-footer {
  display: flex;
  gap: 0.65rem;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border, #e2e8f0);
  flex-wrap: wrap;
  flex-shrink: 0;
}
.sm-action-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  background: var(--background, #f8fafc);
  color: var(--text);
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
  white-space: nowrap;
}
.sm-action-btn:hover {
  background: rgba(27, 67, 50, 0.06);
  border-color: var(--primary, #1b4332);
  color: var(--primary, #1b4332);
}
.sm-action-btn--primary {
  background: var(--primary, #1b4332);
  color: #fff;
  border-color: var(--primary, #1b4332);
}
.sm-action-btn--primary:hover {
  background: var(--primary-light, #2d6a4f);
  color: #fff;
}

/* ── Camera section ── */
.camera-section {
  display: flex;
  justify-content: center;
}

.camera-section .camera-card {
  width: 100%;
  max-width: 720px;
  padding: 0;
  overflow: hidden;
}

/* ── Camera toggle header ── */
.camera-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.15rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  text-align: left;
}

.camera-toggle:hover {
  background: rgba(0, 0, 0, 0.025);
}

.camera-toggle-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  overflow: hidden;
}

.camera-icon {
  font-size: 0.85rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.camera-toggle .metric-title {
  margin: 0;
  white-space: nowrap;
}

.camera-toggle .status-pill {
  flex-shrink: 0;
}

.camera-chevron {
  font-size: 0.75rem;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: transform 0.28s ease;
}

.camera-chevron.collapsed {
  transform: rotate(180deg);
}

/* ── Camera body collapse animation ── */
.camera-body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.3s ease;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.camera-body.collapsed {
  grid-template-rows: 0fr;
  border-top-color: transparent;
}

.camera-body-inner {
  min-height: 0;
  overflow: hidden;
  padding: 0;
}

.camera-body-inner > * {
  padding: 1rem 1.15rem;
}

/* ── Correlation card ── */
.corr-select-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.corr-vs {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.corr-select-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--background, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 0.35rem 0.65rem;
  flex: 1;
  min-width: 160px;
}

.corr-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #aaa;
  transition: background 0.25s;
}

.corr-select-inner {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
}

.corr-select-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  user-select: none;
}

.corr-select {
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  cursor: pointer;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 0.25rem;
}

.corr-select option {
  font-weight: 500;
  color: var(--text);
  background: var(--card, #fff);
}

/* keep old toggle classes in case any old markup still refs them */
.correlation-toggle-row {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.correlation-toggle {
  display: none;
}

#correlationChart {
  height: 310px !important;
  width: 100%;
}

/* ── History charts ── */
.lab-charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
  margin-top: 0.75rem;
}

.lab-chart-card {
  background: #f8faf9;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 12px;
  padding: 0.85rem;
}

.lab-chart-card canvas {
  height: 200px !important;
  width: 100%;
}

/* ── Process logic grid ── */
.logic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.logic-card {
  display: grid;
  gap: 0.75rem;
  align-content: start;
}

.logic-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.logic-head i {
  color: var(--secondary);
  font-size: 0.95rem;
}

.logic-head h3 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
}

.logic-card p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 0;
}

.logic-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-secondary);
  width: fit-content;
}

.logic-pill.safe {
  background: rgba(46, 125, 50, 0.08);
  color: #2e7d32;
  border-color: rgba(46, 125, 50, 0.18);
}

.logic-pill.warning {
  background: rgba(230, 120, 0, 0.09);
  color: #c46a00;
  border-color: rgba(230, 120, 0, 0.2);
}

.logic-pill.critical {
  background: rgba(198, 40, 40, 0.09);
  color: #c62828;
  border-color: rgba(198, 40, 40, 0.2);
}

.logic-pill.secondary {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-secondary);
}

/* ── Sidebar cards ── */
.sidebar-card {
  align-content: start;
}

.sidebar-card .metric-head {
  margin-bottom: 1rem;
}

/* ── Maintenance log ── */
.maintenance-list {
  gap: 0;
}

.maintenance-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.maintenance-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.maintenance-item:first-child {
  padding-top: 0;
}

.maintenance-item strong {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.2rem;
}

.maintenance-item span {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.15rem;
}

.maintenance-item small {
  display: block;
  font-size: 0.74rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

.maintenance-dot {
  width: 7px;
  min-width: 7px;
  height: 7px;
  margin-top: 0.45rem;
  border-radius: 50%;
  background: var(--secondary);
  box-shadow: 0 0 0 3px rgba(82, 183, 136, 0.15);
}

/* ── System status / protocol rows ── */
.protocol-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  gap: 1rem;
}

.protocol-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.protocol-row:first-of-type {
  padding-top: 0;
}

.protocol-row span {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.protocol-row strong {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  text-align: right;
}

/* ── Camera placeholder ── */
.camera-placeholder {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 0.45rem;
  border: 1.5px dashed rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.02);
  aspect-ratio: 16 / 9;
  max-height: 340px;
  min-height: 0;
  width: 100%;
}

.camera-placeholder i {
  font-size: 2rem;
  color: var(--text-secondary);
  opacity: 0.5;
}

.camera-placeholder strong {
  font-size: 0.85rem;
  color: var(--text);
}

.camera-placeholder p {
  font-size: 0.78rem;
  color: var(--text-secondary);
  max-width: 18rem;
  line-height: 1.4;
}

/* ── Warning state on metric cards ── */
.metric-card.warning {
  border-color: rgba(220, 100, 0, 0.22);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.05),
    0 4px 16px rgba(220, 100, 0, 0.07);
}

/* ── Statistics section ── */
.lab-stats-section .section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.lab-stats-grid {
  gap: 0.85rem;
}

.lab-stats-grid .stat-card {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: none;
}

/* ── pH pulse animation when > 11.5 ── */
.ph-pulse {
  animation: phPulse 1.6s ease-in-out infinite;
}

@keyframes phPulse {
  0%,
  100% {
    box-shadow:
      0 1px 3px rgba(0, 0, 0, 0.05),
      0 4px 16px rgba(0, 0, 0, 0.04);
  }
  50% {
    box-shadow:
      0 1px 3px rgba(0, 0, 0, 0.05),
      0 6px 24px rgba(220, 100, 0, 0.18);
  }
}

/* ── Responsive — 1100px ── */
@media (max-width: 1100px) {
  .telemetry-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ghi-stats {
    margin-left: 0;
    justify-content: flex-start;
  }
}

/* ── Responsive — 760px ── */
@media (max-width: 760px) {
  .lab-dashboard {
    padding-top: 0.75rem;
  }

  .container {
    padding: 0 0.85rem;
  }

  .telemetry-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .lab-charts-grid {
    grid-template-columns: 1fr;
  }

  .ghi-band {
    gap: 1rem;
  }

  .ghi-score-cluster {
    gap: 0.75rem;
  }

  .toolbar-band {
    gap: 0.5rem;
  }

  .toolbar-divider {
    display: none;
  }

  .ghi-stats {
    gap: 1.25rem;
    margin-left: 0;
  }
}

/* ── Responsive — 480px ── */
@media (max-width: 480px) {
  .telemetry-grid {
    grid-template-columns: 1fr;
  }

  .lab-card {
    padding: 1rem;
  }

  .metric-value {
    font-size: 1.6rem;
  }
}

/* ================================================================
   SETTINGS PANEL — Language + Sensor Calibration
   ================================================================ */

/* Settings button in header */
.btn-settings {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 6px 14px;
  background: rgba(27, 67, 50, 0.07);
  border: 1px solid rgba(27, 67, 50, 0.18);
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-settings:hover {
  background: rgba(82, 183, 136, 0.15);
  border-color: var(--secondary);
  color: var(--primary-light);
}
.btn-settings i {
  font-size: 0.82rem;
}

/* Backdrop */
.settings-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 390;
}

/* Panel slide-in from right */
.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(500px, 100vw);
  background: var(--card);
  z-index: 400;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.18);
  animation: settingsSlideIn 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
.settings-panel.hidden {
  animation: none;
}

@keyframes settingsSlideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Panel header */
.settings-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--primary-light) 100%
  );
  color: #fff;
  flex-shrink: 0;
}
.settings-panel-header h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: 0;
  color: #fff;
}
.settings-panel-header h3 i {
  font-size: 1rem;
  opacity: 0.9;
}

.settings-close-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 0.82rem;
  transition: background 0.2s;
  padding: 0;
}
.settings-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Scrollable body */
.settings-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.settings-panel-body::-webkit-scrollbar {
  width: 4px;
}
.settings-panel-body::-webkit-scrollbar-track {
  background: transparent;
}
.settings-panel-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* Section block */
.settings-section {
  background: #f8faf9;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.settings-section-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--primary);
}
.settings-section-header i {
  color: var(--secondary);
  font-size: 0.85rem;
}

/* Sensor badge row */
.settings-sensor-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.77rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.settings-sensor-badge i {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Status badge */
.cal-status-badge {
  margin-left: auto;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 700;
  background: rgba(92, 107, 114, 0.1);
  color: var(--text-secondary);
  border: 1px solid rgba(92, 107, 114, 0.18);
  letter-spacing: 0.02em;
  transition: all 0.25s;
}
.cal-status-badge.active {
  background: rgba(82, 183, 136, 0.12);
  color: var(--primary);
  border-color: rgba(82, 183, 136, 0.35);
}

/* Live reading strip */
.cal-live-reading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(27, 67, 50, 0.05);
  border: 1px solid rgba(27, 67, 50, 0.1);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.cal-live-reading strong {
  font-size: 0.9rem;
  color: var(--primary);
  font-family: "Courier New", monospace;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* Language selector */
.settings-lang-row {
  display: flex;
  gap: 0.5rem;
}
.lang-option-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.lang-option-btn:hover {
  border-color: var(--secondary);
  color: var(--primary);
}
.lang-option-btn.active {
  border-color: var(--secondary);
  background: rgba(82, 183, 136, 0.1);
  color: var(--primary);
  box-shadow: 0 0 0 2px rgba(82, 183, 136, 0.15);
}
.lang-abbr {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: var(--primary);
  color: #fff;
  border-radius: 5px;
  padding: 1px 6px;
  line-height: 1.6;
}

/* Calibration card */
.cal-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.cal-card-secondary {
  background: #f8faf9;
  border-color: rgba(0, 0, 0, 0.08);
  border-style: dashed;
}

.cal-card-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.cal-card-title i {
  color: var(--secondary);
  font-size: 0.82rem;
}

.cal-card-desc {
  font-size: 0.74rem;
  color: var(--text-secondary);
  line-height: 1.5;
  background: rgba(82, 183, 136, 0.05);
  border-left: 2.5px solid var(--secondary);
  padding: 0.4rem 0.55rem;
  border-radius: 0 5px 5px 0;
  margin: 0;
}

/* Calibration point row */
.cal-point-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.55rem;
  background: rgba(0, 0, 0, 0.015);
  border-radius: 7px;
  border: 1px solid rgba(0, 0, 0, 0.05);
}
.cal-point-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Input grid */
.cal-inputs {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}
.cal-input-group {
  flex: 1;
  min-width: 100px;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.cal-input-group label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Input field */
.cal-input {
  width: 100%;
  padding: 0.42rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 0.84rem;
  font-family: "Courier New", monospace;
  color: var(--text);
  background: #fff;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
.cal-input:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 2.5px rgba(82, 183, 136, 0.18);
}
.cal-input-mono {
  font-family: "Courier New", monospace;
  letter-spacing: 0.05em;
}

/* Input + crosshair button group */
.cal-input-with-btn {
  display: flex;
  gap: 0.3rem;
  align-items: stretch;
}
.cal-input-with-btn .cal-input {
  flex: 1;
  min-width: 0;
}
.cal-use-live-btn {
  flex-shrink: 0;
  width: 30px;
  border: 1.5px solid var(--secondary);
  border-radius: 6px;
  background: rgba(82, 183, 136, 0.08);
  color: var(--secondary);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  transition: all 0.18s;
  padding: 0;
}
.cal-use-live-btn:hover {
  background: var(--secondary);
  color: #fff;
}

/* Action buttons */
.cal-apply-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.52rem 0.75rem;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--primary-light) 100%
  );
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.81rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    opacity 0.2s,
    transform 0.15s;
  letter-spacing: 0.02em;
}
.cal-apply-btn:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}
.cal-apply-secondary {
  background: linear-gradient(
    135deg,
    var(--primary-light) 0%,
    var(--secondary) 100%
  );
}

.cal-action-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}
.cal-action-row .cal-apply-btn {
  flex: 1;
}

.cal-reset-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.52rem 0.7rem;
  background: transparent;
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  font-size: 0.77rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.cal-reset-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(211, 47, 47, 0.04);
}

/* ================================================================
   Settings — Section description text
   ================================================================ */
.settings-section-desc {
  font-size: 0.74rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

/* ================================================================
   Settings — Threshold rows
   ================================================================ */
.thresh-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.6rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.thresh-row-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text);
}
.thresh-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.thresh-inputs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.thresh-input {
  width: 80px;
  text-align: center;
}
.thresh-status-badge {
  align-self: flex-start;
}

/* ================================================================
   Settings — Maintenance Mode
   ================================================================ */
.maint-status-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.maint-status-indicator {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.maint-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.3s;
}
.maint-dot--off {
  background: var(--success);
}
.maint-dot--on {
  background: var(--warning);
  box-shadow: 0 0 6px rgba(245, 124, 0, 0.55);
  animation: dotPulse 1.5s infinite;
}
.maint-timer {
  font-size: 0.74rem;
  color: var(--text-secondary);
  padding-left: 1.3rem;
}
.maint-timer strong {
  font-family: "Courier New", monospace;
  color: var(--warning);
}
.maint-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.6rem;
  border-radius: 9px;
  border: 2px solid var(--success);
  background: rgba(46, 125, 50, 0.06);
  color: var(--success);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.22s;
}
.maint-toggle-btn:hover {
  background: rgba(46, 125, 50, 0.12);
}
.maint-toggle-btn.active {
  border-color: var(--warning);
  background: rgba(245, 124, 0, 0.07);
  color: var(--warning);
}
.maint-toggle-btn.active:hover {
  background: rgba(245, 124, 0, 0.14);
}

/* ================================================================
   Maintenance Banner (above dashboard)
   ================================================================ */
.maintenance-banner {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 1.25rem;
  background: linear-gradient(90deg, #f57c00, #ff9800);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  flex-wrap: wrap;
}
.maintenance-banner.hidden {
  display: none !important;
}
.maint-banner-timer {
  font-family: "Courier New", monospace;
  background: rgba(0, 0, 0, 0.2);
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 0.78rem;
}
.maint-banner-stop {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}
.maint-banner-stop:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* ================================================================
   Settings — Wi-Fi Provisioning
   ================================================================ */
.wifi-device-status {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  background: #f8faf9;
  border: 1px solid var(--border);
}
.wifi-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--danger);
  transition: background 0.3s;
}
.wifi-status-dot.online {
  background: var(--success);
  box-shadow: 0 0 6px rgba(46, 125, 50, 0.5);
  animation: dotPulse 2s infinite;
}
.wifi-ap-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  padding: 0.4rem 0.7rem;
  background: rgba(27, 67, 50, 0.04);
  border: 1px dashed rgba(27, 67, 50, 0.18);
  border-radius: 8px;
}
.wifi-ap-badge i {
  color: var(--secondary);
}
.wifi-ap-name {
  font-family: "Courier New", monospace;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  background: rgba(82, 183, 136, 0.1);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(82, 183, 136, 0.25);
}
.wifi-steps {
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
}
.wifi-steps li {
  font-size: 0.76rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.wifi-steps li::marker {
  color: var(--secondary);
  font-weight: 700;
}

/* ================================================================
   Settings — Data Export section
   ================================================================ */
.export-info-row {
  font-size: 0.76rem;
  color: var(--text-secondary);
  padding: 0.4rem 0.65rem;
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid var(--border);
  border-radius: 7px;
}
.export-info-row strong {
  color: var(--primary);
}
.export-btn-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.export-settings-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text);
}
.export-settings-btn:hover {
  border-color: var(--secondary);
  background: rgba(82, 183, 136, 0.07);
  color: var(--primary);
}
.export-settings-btn.csv i {
  color: #2e7d32;
}
.export-settings-btn.json i {
  color: #1565c0;
}
.export-settings-btn.report i {
  color: #6a1b9a;
}

/* ══════════════════════════════════════
   SETTINGS PANEL — MOBILE RESPONSIVE
══════════════════════════════════════ */
@media (max-width: 640px) {
  /* Panel fills the full viewport width */
  .settings-panel {
    width: 100vw;
    box-shadow: none;
  }

  /* Reduce body padding */
  .settings-panel-body {
    padding: 0.75rem;
    gap: 0.65rem;
  }

  /* Section inner padding */
  .settings-section {
    padding: 0.85rem 0.75rem;
    gap: 0.65rem;
  }

  /* Close button — bigger touch target */
  .settings-close-btn {
    width: 40px;
    height: 40px;
    font-size: 0.9rem;
  }

  /* Section description text */
  .settings-section-desc {
    font-size: 0.78rem;
  }

  /* Language buttons — full height touch area */
  .settings-lang-row {
    gap: 0.5rem;
  }
  .lang-option-btn {
    padding: 0.8rem 0.5rem;
    font-size: 0.82rem;
    min-height: 48px;
  }

  /* Calibration input groups — stack vertically */
  .cal-inputs {
    flex-direction: column;
    gap: 0.55rem;
  }
  .cal-input-group {
    min-width: unset;
    width: 100%;
  }

  /* Input field — bigger touch area */
  .cal-input {
    padding: 0.55rem 0.7rem;
    font-size: 0.88rem;
  }

  /* Crosshair live-capture button */
  .cal-use-live-btn {
    width: 40px;
    min-height: 40px;
    font-size: 0.85rem;
  }

  /* Apply / Reset action row — stack vertically */
  .cal-action-row {
    flex-direction: column;
    gap: 0.45rem;
  }
  .cal-apply-btn,
  .cal-reset-btn {
    width: 100%;
    justify-content: center;
    padding: 0.7rem;
    font-size: 0.85rem;
  }

  /* Threshold rows — label above inputs */
  .thresh-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
  }
  .thresh-inputs {
    width: 100%;
  }
  .thresh-input {
    width: 100%;
  }

  /* Maintenance toggle — full width */
  .maint-toggle-btn {
    width: 100%;
    justify-content: center;
    padding: 0.75rem;
    font-size: 0.88rem;
  }

  /* WiFi step list */
  .wifi-steps {
    padding-left: 1.1rem;
  }
  .wifi-steps li {
    font-size: 0.8rem;
  }

  /* Export buttons — stack vertically */
  .export-btn-group {
    flex-direction: column;
    gap: 0.45rem;
  }
  .export-settings-btn {
    width: 100%;
    justify-content: center;
    padding: 0.72rem;
    font-size: 0.85rem;
  }

  /* Cal card inner padding */
  .cal-card {
    padding: 0.75rem;
  }

  /* Sensor badge wraps naturally — already flex-wrap */
  .cal-status-badge {
    margin-left: 0;
    margin-top: 0.2rem;
  }
}

/* ════════════════════════════════════════════════════════════════
   DEVICE CALIBRATION SECTION
   ════════════════════════════════════════════════════════════════ */

/* Live telemetry grid */
.devcal-live-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin: 1rem 0;
}
.devcal-live-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
  border-radius: 10px;
  padding: 0.75rem 0.5rem;
  gap: 0.25rem;
}
.devcal-live-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.65;
  font-weight: 500;
}
.devcal-live-value {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: "JetBrains Mono", "SF Mono", "Fira Code", monospace;
  color: var(--text, #1a1a2e);
}

/* Calibration status colors */
.devcal-cal-full {
  color: #2e7d32 !important;
}
.devcal-cal-partial {
  color: #e65100 !important;
}
.devcal-cal-none {
  color: #c62828 !important;
}

/* Action row */
.devcal-action-row {
  margin: 0.75rem 0 0.5rem;
}
.devcal-btn {
  width: 100%;
  font-size: 0.9rem;
  padding: 0.75rem 1.25rem;
}
.devcal-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Info note */
.devcal-note {
  font-size: 0.78rem;
  color: var(--text-muted, #6b7280);
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  margin-top: 0.3rem;
  padding: 0.5rem 0.6rem;
  background: rgba(59, 130, 246, 0.06);
  border-radius: 8px;
  border-left: 3px solid rgba(59, 130, 246, 0.3);
}
.devcal-note i {
  color: #3b82f6;
  margin-top: 0.15rem;
  flex-shrink: 0;
}

/* Status row */
.devcal-status-row {
  margin-bottom: 0.5rem;
}

/* Mode badge in settings */
.devcal-mode-uncal {
  background: #c62828 !important;
  color: #fff !important;
}
.devcal-mode-rti {
  background: #e65100 !important;
  color: #fff !important;
}
.devcal-mode-ntu {
  background: #2e7d32 !important;
  color: #fff !important;
}

/* Mode explainer */
.devcal-mode-explainer {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08));
}
.devcal-mode-explainer h4 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text, #1a1a2e);
}
.devcal-mode-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.devcal-mode-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-muted, #6b7280);
}
.devcal-mode-tag {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: "JetBrains Mono", "SF Mono", monospace;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  min-width: 3.5rem;
  text-align: center;
}
.devcal-mode-uncal {
  background: #ffcdd2;
  color: #b71c1c;
}
.devcal-mode-rti {
  background: #ffe0b2;
  color: #e65100;
}
.devcal-mode-ntu {
  background: #c8e6c9;
  color: #1b5e20;
}

/* ── Turbidity mode badge on dashboard card ── */
.turb-mode-badge {
  font-family: "JetBrains Mono", "SF Mono", monospace;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
}
.turb-mode-uncal {
  background: rgba(198, 40, 40, 0.12);
  color: #c62828;
}
.turb-mode-rti {
  background: rgba(230, 81, 0, 0.12);
  color: #e65100;
}
.turb-mode-ntu {
  background: rgba(46, 125, 50, 0.12);
  color: #2e7d32;
}

/* ── Responsive: device cal section ── */
@media (max-width: 600px) {
  .devcal-live-grid {
    grid-template-columns: 1fr;
  }
  .devcal-mode-grid {
    gap: 0.75rem;
  }
}
