/* ═══════════════════════════════════════════════════
   Food Safety Dashboard — Design System
   ═══════════════════════════════════════════════════ */

/* ── Tokens ─────────────────────────────────────── */
:root {
  --bg: #f0ede6;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --text: #1c2822;
  --muted: #55645a;
  --line: rgba(28, 40, 34, 0.12);
  --line-strong: rgba(28, 40, 34, 0.2);
  --primary: #0e785f;
  --primary-dark: #0a5f4b;
  --primary-light: rgba(14, 120, 95, 0.1);
  --secondary: #bc6231;
  --cold-bg: rgba(223, 243, 251, 0.9);
  --hot-bg: rgba(255, 228, 210, 0.9);
  --danger: #b83a1a;
  --danger-light: rgba(184, 58, 26, 0.08);
  --ok: #136948;
  --ok-light: rgba(19, 105, 72, 0.08);
  --sidebar-w: 256px;
  --bottom-nav-h: 64px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-xl: 30px;
  --shadow-sm: 0 2px 8px rgba(28, 40, 34, 0.07);
  --shadow-md: 0 6px 20px rgba(28, 40, 34, 0.1);
  --shadow-lg: 0 16px 48px rgba(28, 40, 34, 0.13);
}

/* ── Reset ──────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Source Sans 3", sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}

/* ── Background decoration ──────────────────────── */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 12% 8%, rgba(188, 98, 49, 0.09), transparent 28%),
    radial-gradient(circle at 88% 5%, rgba(14, 120, 95, 0.08), transparent 26%);
  pointer-events: none;
  z-index: 0;
}

.sidebar,
.page-content {
  position: relative;
  z-index: 1;
}

/* ── Typography ─────────────────────────────────── */
h1,
h2,
h3,
h4,
.brand-text,
.metric-value {
  font-family: "Space Grotesk", sans-serif;
  margin: 0;
  line-height: 1.15;
}

h1 { font-size: clamp(1.7rem, 3.5vw, 2.6rem); }
h2 { font-size: clamp(1.2rem, 2.5vw, 1.7rem); }
h3 { font-size: 1.05rem; }

p { margin: 0; }

a { color: inherit; text-decoration: none; }

label,
input,
textarea,
select,
button {
  font: inherit;
}

.eyebrow {
  margin: 0 0 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--secondary);
}

/* ── Sidebar ────────────────────────────────────── */
.sidebar {
  grid-column: 1;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--surface-solid);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 100;
  scrollbar-width: none;
}

.sidebar::-webkit-scrollbar {
  display: none;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.5rem 1rem 1.25rem;
}

.sidebar-header {
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.1rem;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--primary);
  font-weight: 700;
  font-size: 1.05rem;
  font-family: "Space Grotesk", sans-serif;
}

.sidebar-nav {
  flex: 1;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-md);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 130ms ease, color 130ms ease;
}

.nav-link:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.nav-active {
  background: var(--primary-light);
  color: var(--primary);
}

.sidebar-status {
  margin-top: auto;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.conn-indicator {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.conn-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line-strong);
  flex-shrink: 0;
  transition: background 300ms ease, box-shadow 300ms ease;
}

.dot-on {
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-light);
  animation: pulse-dot 2.2s ease infinite;
}

.dot-off {
  background: var(--danger);
}

.dot-warn {
  background: var(--secondary);
}

.dot-checking {
  background: var(--muted);
  animation: pulse-dot 1s ease infinite;
}

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

/* ── Mobile sidebar overlay ─────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(28, 40, 34, 0.38);
  z-index: 99;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.overlay-visible {
  display: block;
}

/* ── Mobile menu button ─────────────────────────── */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 101;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  color: var(--text);
  align-items: center;
  justify-content: center;
}

/* ── Bottom nav (mobile) ────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--surface-solid);
  border-top: 1px solid var(--line);
  height: var(--bottom-nav-h);
  align-items: stretch;
  box-shadow: 0 -4px 24px rgba(28, 40, 34, 0.08);
}

.bottom-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.22rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.4rem;
  transition: color 130ms ease;
}

.bottom-active {
  color: var(--primary);
}

/* ── Page content ───────────────────────────────── */
.page-content {
  grid-column: 2;
  padding: 2.25rem 2.5rem 3.5rem;
  min-width: 0;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.page-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ── Live badge ─────────────────────────────────── */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: var(--ok-light);
  color: var(--ok);
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid rgba(19, 105, 72, 0.15);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  animation: pulse-dot 1.8s ease infinite;
}

/* ── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 40px;
  padding: 0.65rem 1.2rem;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.88rem;
  text-decoration: none;
  transition: background 130ms ease, transform 130ms ease, box-shadow 130ms ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:not(:disabled):hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(14, 120, 95, 0.28);
}

.btn-secondary {
  background: var(--surface-solid);
  color: var(--text);
  border-color: var(--line-strong);
}

.btn-secondary:not(:disabled):hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.btn-ghost:not(:disabled):hover {
  background: var(--primary-light);
  color: var(--primary);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border-color: rgba(184, 58, 26, 0.25);
}

.btn-danger-ghost:not(:disabled):hover {
  background: var(--danger-light);
}

.btn-sm {
  min-height: 32px;
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
}

/* ── Cards ──────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  font-family: "Space Grotesk", sans-serif;
}

/* ── Metrics row ────────────────────────────────── */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  padding: 1.3rem 1.5rem 1.5rem;
  min-height: 136px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.5rem;
}

.metric-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.metric-value {
  font-size: clamp(1.9rem, 3.5vw, 2.8rem);
  line-height: 1;
  font-weight: 700;
}

.metric-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.metric-safe {
  background: linear-gradient(145deg, rgba(19, 105, 72, 0.1), rgba(255, 255, 255, 0.85));
}

.metric-safe .metric-value {
  color: var(--ok);
}

.metric-alert {
  background: linear-gradient(145deg, rgba(184, 58, 26, 0.09), rgba(255, 255, 255, 0.85));
}

.metric-alert .metric-value {
  color: var(--danger);
}

.metric-cold {
  background: var(--cold-bg);
}

.metric-hot {
  background: var(--hot-bg);
}

/* ── Dashboard 2-column grid ─────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

/* ── Alerts ─────────────────────────────────────── */
.alert-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.alert-item {
  padding: 0.85rem 1rem 0.85rem 1.1rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line);
  border-left: 3px solid var(--danger);
  display: grid;
  gap: 0.12rem;
}

.alert-location {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--danger);
}

.alert-label {
  font-weight: 700;
  font-size: 0.92rem;
}

.alert-msg {
  color: var(--muted);
  font-size: 0.87rem;
}

/* ── Action list ────────────────────────────────── */
.action-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.action-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line);
  font-size: 0.88rem;
  color: var(--muted);
}

.action-bullet {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--secondary);
  margin-top: 0.38rem;
  flex-shrink: 0;
}

/* ── Badges ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-safe {
  background: var(--ok-light);
  color: var(--ok);
  border: 1px solid rgba(19, 105, 72, 0.18);
}

.badge-alert {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid rgba(184, 58, 26, 0.18);
}

.badge-warn {
  background: rgba(188, 98, 49, 0.1);
  color: var(--secondary);
}

.badge-type {
  background: rgba(28, 40, 34, 0.06);
  color: var(--muted);
}

/* ── Sensor table ───────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
}

.sensor-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.sensor-table th {
  padding: 0.8rem 1.1rem;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.sensor-table td {
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.sensor-table tr:last-child td {
  border-bottom: none;
}

.sensor-table tbody tr {
  transition: background 120ms ease;
}

.sensor-table tbody tr:hover td {
  background: rgba(14, 120, 95, 0.03);
}

/* ── Sensor card grid (sensors.html) ─────────────── */
.sensors-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.sensor-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.sensor-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.sensor-card-alert {
  border-color: rgba(184, 58, 26, 0.28);
  background: linear-gradient(160deg, rgba(184, 58, 26, 0.04), var(--surface));
}

.sensor-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.sensor-reading {
  font-size: clamp(2rem, 4.5vw, 3rem);
  font-weight: 700;
  font-family: "Space Grotesk", sans-serif;
  line-height: 1;
}

.reading-ok {
  color: var(--ok);
}

.reading-alert {
  color: var(--danger);
}

.reading-neutral {
  color: var(--text);
}

.sensor-card-label {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.3;
}

.sensor-card-location {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.sensor-card-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.sensor-threshold {
  font-size: 0.8rem;
  color: var(--muted);
  margin-left: auto;
}

/* ── Sensor inline edit form ────────────────────── */
.sensor-edit-wrap {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  margin-top: 0.25rem;
}

.sensor-edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sensor-edit-form .form-input,
.sensor-edit-form .form-select {
  font-size: 0.85rem;
  padding: 0.6rem 0.8rem;
}

.sensor-edit-form .form-label {
  font-size: 0.78rem;
}

/* ── Filters row ────────────────────────────────── */
.filters-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.filter-btn {
  padding: 0.38rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-solid);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 130ms ease;
}

.filter-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.filter-active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* ── Forms ──────────────────────────────────────── */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 0.75rem 0.95rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  font-size: 0.92rem;
  transition: border-color 130ms ease, box-shadow 130ms ease;
  appearance: none;
  -webkit-appearance: none;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2355645a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-textarea {
  resize: vertical;
  min-height: 90px;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.form-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  padding-top: 0.25rem;
}

/* ── Status message ─────────────────────────────── */
.status-msg {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  margin-top: 0.5rem;
}

.msg-success {
  background: var(--ok-light);
  color: var(--ok);
  border: 1px solid rgba(19, 105, 72, 0.15);
}

.msg-error {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid rgba(184, 58, 26, 0.15);
}

.msg-neutral {
  background: rgba(28, 40, 34, 0.05);
  color: var(--muted);
  border: 1px solid var(--line);
}

/* ── Entity browser ─────────────────────────────── */
.search-wrap {
  position: relative;
  margin-bottom: 0.75rem;
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  line-height: 0;
}

.search-input {
  padding-left: 2.4rem !important;
}

.entity-list,
.mapped-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 390px;
  overflow-y: auto;
  padding-right: 2px;
}

.entity-list::-webkit-scrollbar,
.mapped-list::-webkit-scrollbar {
  width: 4px;
}

.entity-list::-webkit-scrollbar-track,
.mapped-list::-webkit-scrollbar-track {
  background: transparent;
}

.entity-list::-webkit-scrollbar-thumb,
.mapped-list::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 2px;
}

.entity-item,
.mapped-item {
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.65);
  display: grid;
  gap: 0.18rem;
}

.entity-item-top,
.mapped-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.entity-name,
.mapped-name {
  font-weight: 700;
  font-size: 0.88rem;
}

.entity-id,
.mapped-entity {
  font-size: 0.78rem;
  color: var(--muted);
  font-family: monospace;
  word-break: break-all;
}

.entity-value {
  font-size: 0.85rem;
}

.entity-actions,
.mapped-actions {
  margin-top: 0.45rem;
}

.mapped-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

/* ── Setup layout ───────────────────────────────── */
.setup-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.setup-wide {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

/* ── Section divider ────────────────────────────── */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.75rem 0 1.1rem;
  flex-wrap: wrap;
}

.section-head h2 {
  font-size: 1.2rem;
}

/* ── History charts ─────────────────────────────── */
.history-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.history-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.35rem;
}

.history-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.history-meta {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muted);
}

.history-meta strong {
  color: var(--text);
}

.history-chart-wrap {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: linear-gradient(180deg, rgba(14, 120, 95, 0.05), rgba(14, 120, 95, 0.01));
  border: 1px solid var(--line);
}

.history-svg {
  width: 100%;
  height: auto;
  display: block;
}

.history-axis {
  stroke: rgba(28, 40, 34, 0.1);
  stroke-width: 1;
}

.history-fill {
  fill: rgba(14, 120, 95, 0.07);
}

.history-line {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.history-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--muted);
}

.history-entity-id {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: monospace;
  word-break: break-all;
}

/* ── Empty & loading states ─────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2.5rem 1.5rem;
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
}

.empty-icon {
  opacity: 0.25;
  flex-shrink: 0;
}

.empty-inline {
  color: var(--muted);
  font-size: 0.88rem;
  padding: 0.75rem;
  text-align: center;
}

.link-accent {
  color: var(--primary);
  font-weight: 700;
}

/* ── Last updated ───────────────────────────────── */
.last-updated {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Step indicators ────────────────────────────── */
.step-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 800;
}

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 940px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 240ms ease;
    z-index: 100;
  }

  .sidebar-open {
    transform: translateX(0);
  }

  .mobile-menu-btn {
    display: flex;
  }

  .bottom-nav {
    display: flex;
  }

  .page-content {
    grid-column: 1;
    padding: 4.5rem 1.25rem calc(var(--bottom-nav-h) + 1.5rem);
  }

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

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

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

  .history-grid {
    grid-template-columns: 1fr;
  }

  .setup-cols,
  .setup-wide {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .metrics-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sensors-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .page-actions {
    width: 100%;
  }

  .filters-row {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.5rem;
  }
}
