:root {
  --bg: #f6f5f3;
  --card: #ffffff;
  --text: #201c1b;
  --muted: #6b6560;
  --border: #e7e2dd;
  --shadow: 0 8px 24px rgba(32, 28, 27, 0.06);
  --radius: 16px;

  --accent: #7d2248;
  --accent-tint: #fbeef2;

  --success: #1f9d55;
  --success-tint: #e6f6ea;
  --warning: #c06a12;
  --warning-tint: #fdeee0;
  --danger: #d64545;
  --danger-tint: #fbe9e9;
  --info: #3b82c4;
  --info-tint: #e8f1fa;
  --secondary: #6b7280;
  --secondary-tint: #eef0f2;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-top: 4.5rem;
}

h2, h3, h4 { font-weight: 800; letter-spacing: -0.01em; }

a { color: var(--accent); }

/* Navbar */
.navbar {
  background: var(--card) !important;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(32, 28, 27, 0.03);
}

.navbar-brand {
  color: var(--text) !important;
  font-weight: 800;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.navbar-brand .brand-mark { color: var(--accent); }

.nav-link {
  color: var(--muted) !important;
  font-weight: 600;
  padding: 0.5rem 0.9rem !important;
  border-radius: 8px;
  transition: background-color 0.15s, color 0.15s;
}

.nav-link:hover { color: var(--text) !important; background: var(--bg); }

.nav-link.active {
  color: var(--accent) !important;
  background: var(--accent-tint);
  text-decoration: none;
  font-weight: 700;
}

/* Latest capture banner */
.latest-time {
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 0.9rem 1.25rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

/* Online/offline status indicator */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.7rem 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-indicator.is-online { background: var(--success-tint); color: var(--success); }
.status-indicator.is-offline { background: var(--danger-tint); color: var(--danger); }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.status-indicator.is-online .status-dot {
  animation: status-pulse 1.8s ease-in-out infinite;
}

@keyframes status-pulse {
  0% { box-shadow: 0 0 0 0 rgba(31, 157, 85, 0.45); }
  70% { box-shadow: 0 0 0 6px rgba(31, 157, 85, 0); }
  100% { box-shadow: 0 0 0 0 rgba(31, 157, 85, 0); }
}

.section-title {
  margin: 2.5rem 0 1.25rem;
  font-size: 1.35rem;
  font-weight: 800;
}

/* Stat cards (readings) */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--status-color, var(--border));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
}

.stat-card .stat-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

.stat-card .stat-value {
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.stat-card .stat-diff {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  margin-left: 0.35rem;
}

.status-success { --status-color: var(--success); }
.status-warning { --status-color: var(--warning); }
.status-danger { --status-color: var(--danger); }
.status-info { --status-color: var(--info); }
.status-secondary { --status-color: var(--secondary); }

/* Status pill badges */
.badge-pill {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-optimal { background: var(--success-tint); color: var(--success); }
.badge-low { background: var(--secondary-tint); color: var(--secondary); }
.badge-high { background: var(--warning-tint); color: var(--warning); }

/* Charts */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.chart-card h5 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.chart-card .chart-canvas-wrap {
  position: relative;
  height: 200px;
}

/* Summary blocks */
.summary-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--status-color, var(--border));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
}

.summary-block h4 {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.05rem;
  margin-bottom: 0.4rem;
}

.summary-block p { color: var(--muted); margin: 0; }

/* Table */
.table-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-card .table { margin-bottom: 0; }

.table thead th {
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
  border-bottom: 2px solid var(--border);
  text-align: center;
  vertical-align: middle;
}

.table tbody td {
  text-align: center;
  vertical-align: middle;
  color: var(--text);
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: rgba(32, 28, 27, 0.02);
}

/* Content sections (storage / about) */
.section, .content-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}

.content-section { max-width: 800px; margin-left: auto; margin-right: auto; }

.section p, .content-section p { color: var(--muted); line-height: 1.65; }
.section p:last-child, .content-section p:last-child { margin-bottom: 0; }

.sensor-img {
  max-width: 100%;
  height: auto;
  margin: 1rem 0;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

/* Footer */
footer {
  margin-top: 3rem;
  padding: 1.5rem 0;
  text-align: center;
  color: var(--muted);
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}
