:root {
  --bg: #121711;
  --bg-accent: radial-gradient(circle at 12% 18%, #25412f 0%, transparent 35%),
    radial-gradient(circle at 80% 12%, #6f451f 0%, transparent 28%),
    linear-gradient(180deg, #131913 0%, #161f18 100%);
  --surface: #1b241d;
  --surface-soft: #202b23;
  --text: #ebf3ea;
  --muted: #aebcae;
  --brand: #72d28f;
  --brand-2: #f0b16f;
  --border: #2f3c32;
  --shadow: 0 14px 32px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg-accent);
  min-height: 100%;
}

body {
  min-height: 100vh;
}

h1,
h2,
h3,
.brand {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.layout {
  width: min(1200px, 92vw);
  margin: 0 auto;
}

.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0;
}

.brand {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-links a,
button {
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.48rem 0.9rem;
  text-decoration: none;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.nav-links a.active {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, var(--surface));
}

.nav-links a:hover,
button:hover {
  transform: translateY(-1px);
}

.hero {
  margin-top: 1.5rem;
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
}

.hero p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.section {
  margin: 1rem 0 1.5rem;
}

.grid {
  display: grid;
  gap: 1rem;
}

.cards {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.card {
  padding: 1rem;
}

.card h3 {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0;
  font-weight: 600;
}

.value {
  margin-top: 0.4rem;
  font-size: 1.6rem;
  font-weight: 700;
}

.value small {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
}

.panel {
  padding: 1rem;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.panel-header p {
  margin: 0.3rem 0 0;
}

.panel h2 {
  margin: 0 0 0.8rem;
  font-size: 1.02rem;
}

.chart-card {
  padding: 1rem;
}

.chart-card h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
}

.charts {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.sensor-cards {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.sensor-charts {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.chart-wrap {
  height: 320px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: end;
}

label {
  display: grid;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.88rem;
}

input[type="date"] {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  border-radius: 10px;
  padding: 0.48rem 0.6rem;
}

input[type="time"] {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  border-radius: 10px;
  padding: 0.48rem 0.6rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 0.6rem;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
}

.footer-note {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  margin: 1.5rem 0;
}

.fade-in {
  opacity: 0;
  transform: translateY(10px);
  animation: fadeInUp 0.5s ease forwards;
}

.fade-in:nth-child(2) {
  animation-delay: 0.08s;
}

.fade-in:nth-child(3) {
  animation-delay: 0.16s;
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.pagination button {
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, opacity 0.2s ease;
}

.pagination button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: color-mix(in srgb, var(--brand) 12%, var(--surface));
  border-color: var(--brand);
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination #pageInfo {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

@media (max-width: 700px) {
  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .chart-wrap {
    height: 280px;
  }

  .pagination {
    flex-direction: column;
    gap: 0.5rem;
  }

  .pagination button {
    width: 100%;
  }
}

/* ── Export page styles ─────────────────────────────────────────── */

.btn-accent {
  background: linear-gradient(135deg, var(--brand), #4eb872) !important;
  color: #121711 !important;
  border-color: var(--brand) !important;
  font-weight: 600;
}

.btn-accent:hover {
  filter: brightness(1.1);
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.chart-card-header h3 {
  margin: 0;
  font-size: 0.95rem;
}

.btn-export-single,
.btn-export-group {
  font-size: 0.8rem;
  padding: 0.3rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-export-single:hover,
.btn-export-group:hover {
  background: color-mix(in srgb, var(--brand) 15%, var(--surface));
  border-color: var(--brand);
  color: var(--text);
  transform: translateY(-1px);
}

.export-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.side-by-side {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 900px) {
  .side-by-side {
    grid-template-columns: 1fr;
  }
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.3rem;
}

.dot-moss {
  background: #2d7a4b;
}

.dot-nonmoss {
  background: #d4732f;
}

/* ── Analysis page styles ──────────────────────────────────────────── */

.section-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--brand), #4eb872);
  color: #121711;
  margin-right: 0.5rem;
  vertical-align: middle;
}

.analysis-note {
  border-radius: 12px;
  padding: 0.8rem 1rem;
  font-size: 0.88rem;
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.note-warning {
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.25);
  color: #fbbf24;
}

.note-info {
  background: rgba(90, 200, 224, 0.08);
  border: 1px solid rgba(90, 200, 224, 0.25);
  color: #5ac8e0;
}

.sig-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(114, 210, 143, 0.15);
  color: #72d28f;
  border: 1px solid rgba(114, 210, 143, 0.3);
}

.diff-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  background: rgba(240, 177, 111, 0.15);
  color: #f0b16f;
  border: 1px solid rgba(240, 177, 111, 0.3);
}

.cooling-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.cooling-card {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cooling-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.cooling-label {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.cooling-value {
  font-size: 1.8rem;
  font-weight: 700;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.findings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.finding-card {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.2rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.finding-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent);
  border-radius: 4px 0 0 4px;
}

.finding-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.finding-icon {
  font-size: 1.5rem;
  margin-bottom: 0.4rem;
}

.finding-card h3 {
  font-size: 0.92rem;
  color: var(--text);
  margin: 0 0 0.3rem;
  font-weight: 600;
}

.finding-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  margin-bottom: 0.4rem;
}

.finding-detail {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.45;
}

.panel-filter {
  border-color: rgba(114, 210, 143, 0.25);
  background: linear-gradient(135deg, rgba(114, 210, 143, 0.04), var(--surface));
}

.filter-status {
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.filter-active {
  color: #72d28f;
  font-weight: 500;
}

.filter-inactive {
  color: var(--muted);
  font-style: italic;
}

.row-dimmed {
  opacity: 0.35;
}

input[type="number"] {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  border-radius: 10px;
  padding: 0.48rem 0.6rem;
  width: 90px;
}

input[type="number"]:focus,
input[type="date"]:focus,
input[type="time"]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(114, 210, 143, 0.15);
}

.panel-findings {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.04), var(--surface));
  border-color: rgba(167, 139, 250, 0.2);
}

@keyframes filterPulse {
  0% { box-shadow: 0 0 0 0 rgba(114, 210, 143, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(114, 210, 143, 0); }
  100% { box-shadow: 0 0 0 0 rgba(114, 210, 143, 0); }
}

.filter-applied {
  animation: filterPulse 0.6s ease;
}

/* ── Moss Effect page styles ───────────────────────────────────────── */

.me-humidity-filter {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.me-filter-title {
  font-size: 0.92rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--text);
}

.me-entries-section {
  margin-top: 0.5rem;
}

.me-entries-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.me-entry-row {
  display: flex;
  align-items: end;
  gap: 0.65rem;
  padding: 0.75rem 0.9rem;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s ease, transform 0.35s ease, box-shadow 0.2s ease;
}

.me-entry-row.me-entry-visible {
  opacity: 1;
  transform: translateY(0);
}

.me-entry-row:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.me-entry-label {
  display: grid;
  gap: 0.2rem;
  color: var(--muted);
  font-size: 0.82rem;
  flex: 1;
  min-width: 0;
}

.me-input-pct {
  width: 80px !important;
}

.me-btn-remove {
  width: 34px;
  height: 34px;
  border-radius: 10px !important;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: #f87171 !important;
  border-color: rgba(248, 113, 113, 0.3) !important;
  background: rgba(248, 113, 113, 0.08) !important;
  transition: background 0.2s ease, transform 0.2s ease;
  flex-shrink: 0;
}

.me-btn-remove:hover {
  background: rgba(248, 113, 113, 0.2) !important;
  transform: translateY(-1px) scale(1.05);
}

.me-entries-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}

.me-btn-add {
  border-style: dashed !important;
  border-color: rgba(114, 210, 143, 0.4) !important;
  color: #72d28f !important;
  background: rgba(114, 210, 143, 0.06) !important;
  font-weight: 500;
}

.me-btn-add:hover {
  background: rgba(114, 210, 143, 0.14) !important;
  border-color: var(--brand) !important;
}

.me-btn-generate {
  font-size: 0.92rem;
  padding: 0.55rem 1.2rem !important;
}

.me-pct-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dot-color);
  margin-right: 0.4rem;
  vertical-align: middle;
}

.me-dl-btn {
  font-size: 0.78rem;
  padding: 0.3rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.me-dl-btn:hover {
  background: color-mix(in srgb, var(--brand) 15%, var(--surface));
  border-color: var(--brand);
  color: var(--text);
  transform: translateY(-1px);
}

@media (max-width: 700px) {
  .me-entry-row {
    flex-direction: column;
    align-items: stretch;
  }

  .me-entry-label {
    flex: none;
  }

  .me-input-pct {
    width: 100% !important;
  }

  .me-btn-remove {
    align-self: flex-end;
  }
}

/* ── Correlation Matrix Table ──────────────────────────────────────── */

.correlation-matrix-wrap {
  overflow-x: auto;
  margin-bottom: 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.correlation-matrix {
  width: auto;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
}

.correlation-matrix th,
.correlation-matrix td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 0.55rem 0.65rem;
  text-align: center;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.correlation-matrix th {
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  position: sticky;
  top: 0;
  z-index: 2;
}

.correlation-matrix th:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--surface-soft);
}

.correlation-matrix td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-align: left;
}

.correlation-matrix td:last-child,
.correlation-matrix th:last-child {
  border-right: none;
}

.correlation-matrix tr:last-child td {
  border-bottom: none;
}

.correlation-matrix tbody tr:hover td {
  background: rgba(114, 210, 143, 0.06);
}

.correlation-matrix tbody tr:hover td:first-child {
  background: color-mix(in srgb, var(--brand) 10%, var(--surface-soft));
}

.corr-cell {
  font-weight: 600;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  border-radius: 6px;
  min-width: 52px;
}

.corr-cell.corr-self {
  background: rgba(114, 210, 143, 0.25);
  color: #72d28f;
}

.corr-cell.corr-strong-pos {
  background: rgba(114, 210, 143, 0.22);
  color: #8be0a5;
}

.corr-cell.corr-mod-pos {
  background: rgba(114, 210, 143, 0.12);
  color: #72d28f;
}

.corr-cell.corr-weak {
  background: rgba(150, 150, 150, 0.1);
  color: #999;
}

.corr-cell.corr-mod-neg {
  background: rgba(248, 113, 113, 0.12);
  color: #f87171;
}

.corr-cell.corr-strong-neg {
  background: rgba(248, 113, 113, 0.22);
  color: #ff8a8a;
}

.corr-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding: 0.6rem 0.8rem;
  background: var(--surface-soft);
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--muted);
}

.corr-legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.corr-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
}

/* ── Pearson Correlation Value Card ──────────────────────────────── */

.pearson-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.pearson-card {
  flex: 1;
  min-width: 140px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.25rem;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pearson-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.pearson-r-value {
  font-size: 2rem;
  font-weight: 700;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: #5ac8e0;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.pearson-r-value.r-negative {
  color: #f87171;
}

.pearson-r-value.r-weak {
  color: #aebcae;
}

.pearson-r-label {
  margin-top: 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
}

.pearson-r-sublabel {
  margin-top: 0.25rem;
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.7;
}
