/* Store Guardian PWA — Mobile-first dark industrial theme */
:root {
  --bg-base: #0a0a14;
  --bg-card: #1a1a2e;
  --bg-item: #2a2a3e;
  --bg-border: #35354a;
  --cyan: #00d2e6;
  --cyan2: #00eeff;
  --violet: #a78bfa;
  --green: #22d98a;
  --amber: #f5a623;
  --red: #f0405a;
  --text-primary: #e0e0ff;
  --text-muted: #6c7a9c;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

/* ── App shell ────────────────────────────────────────────────────────────── */
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--bg-border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 0.5px;
}
.app-header .back-btn {
  background: none;
  border: none;
  color: var(--cyan);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.app-header .back-btn:active {
  background: var(--bg-item);
}
.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.main-content {
  flex: 1;
  padding: 12px 12px 60px; /* extra bottom space so sync-pill doesn't overlap */
  overflow-y: auto;
}

/* ── Screens ──────────────────────────────────────────────────────────────── */
.screen {
  display: none;
}
.screen.active {
  display: block;
}
/* Login is full-screen fixed — needs flex not block */
#screen-login.active {
  display: flex;
}

/* ── Login ────────────────────────────────────────────────────────────────── */
#screen-login {
  /* Full-bleed — bypass the .main-content padding */
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  background: #05060f;
  overflow: hidden;
}
#screen-login.active {
  display: flex;
}

/* Ambient glow orbs matching presentation style */
#screen-login::before,
#screen-login::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
#screen-login::before {
  width: 420px;
  height: 420px;
  background: radial-gradient(
    circle,
    rgba(0, 210, 230, 0.1) 0%,
    transparent 70%
  );
  top: -120px;
  right: -80px;
}
#screen-login::after {
  width: 320px;
  height: 320px;
  background: radial-gradient(
    circle,
    rgba(167, 139, 250, 0.09) 0%,
    transparent 70%
  );
  bottom: -80px;
  left: -60px;
}

/* Cyan horizontal accent line (matches presentation .stripe) */
.login-stripe {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(0, 210, 230, 0.6),
    transparent
  );
}

.login-wrap {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 32px 28px 40px;
  gap: 0;
}

/* Logo area */
.login-logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 36px;
  gap: 8px;
}

.title-product-logo {
  height: auto;
  max-height: 175px;
  object-fit: contain;
  /* filter: drop-shadow(0 0 16px rgba(0, 210, 230, 0.25)); */
  /* drop-shadow(0 0 30px rgba(0, 210, 230, 0.4)) drop-shadow(0 0 60px rgba(0, 210, 230, 0.155)); */
}
.login-wordmark {
  font-family: "Barlow Condensed";
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #4161e1;
  text-align: center;
  line-height: 1;
  filter: drop-shadow(0 0 16px rgba(0, 210, 230, 0.25));
}
.login-sub-tag {
  font-size: 1rem;
  color: rgba(222, 228, 242, 0.6);
  text-align: center;
  margin-top: 2px;
  letter-spacing: 0.02em;
}

/* Divider */
.login-divider {
  width: 100%;
  max-width: 320px;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(0, 210, 230, 0.25),
    transparent
  );
  margin-bottom: 28px;
}

.login-form {
  width: 100%;
  max-width: 320px;
}
.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(184, 200, 232, 0.55);
  margin-bottom: 6px;
}
.form-group input {
  width: 100%;
  padding: 13px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(0, 210, 230, 0.18);
  border-radius: 10px;
  color: #e0e0ff;
  font-size: 1rem;
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  -webkit-appearance: none;
}
.form-group input::placeholder {
  color: rgba(184, 200, 232, 0.3);
}
.form-group input:focus {
  border-color: rgba(0, 210, 230, 0.55);
  box-shadow: 0 0 0 3px rgba(0, 210, 230, 0.08);
}
.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--cyan);
  color: #000;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  margin-top: 6px;
  transition:
    opacity 0.2s,
    box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(0, 210, 230, 0.25);
}
.btn-primary:active {
  opacity: 0.85;
}
.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}
.login-error {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(240, 64, 90, 0.12);
  border: 1px solid var(--red);
  border-radius: 8px;
  color: var(--red);
  font-size: 0.85rem;
  text-align: center;
  display: none;
}

/* ── Store list ───────────────────────────────────────────────────────────── */
.stores-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.store-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition:
    border-color 0.2s,
    background 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.store-card:active {
  background: var(--bg-item);
  border-color: var(--cyan);
}

.store-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.store-card-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}
.chevron {
  color: var(--text-muted);
  font-size: 1rem;
}

.store-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.store-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ambient-strip {
  display: flex;
  gap: 12px;
  padding: 8px 10px;
  background: var(--bg-item);
  border-radius: 8px;
  font-size: 0.82rem;
}
.ambient-val {
  font-weight: 600;
  color: var(--cyan);
}

/* Grain type badge in store card header */
.sc-grain-badge {
  font-size: 1.2rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(0, 210, 230, 0.1);
  color: var(--cyan);
  border: 1px solid rgba(0, 210, 230, 0.25);
  white-space: nowrap;
  margin-left: auto;
  margin-right: 6px;
}

/* ── Store card overview sections ────────────────────────────────────────── */
/* Compact ambient strip on store list card */
.sc-ambient {
  display: flex;
  gap: 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding: 6px 10px;
  background: var(--bg-item);
  border-radius: 7px;
}
.sc-ambient span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Temperature statistics mini grid */
.sc-temp-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}
.sc-temp-stat {
  background: linear-gradient(135deg, #35354a 0%, #2a2a3e 100%);
  border-radius: 10px;
  padding: 15px;
  border: 1px solid #4a4a5e;
  transition: all 0.3s;
}

.sc-temp-stat-fan {
  background: linear-gradient(135deg, #35354a 0%, #2a2a3e 100%);
  border-radius: 10px;
  padding: 15px;
  border: 1px solid #4a4a5e;
  transition: all 0.3s;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}

.sc-stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 10px;
}
.sc-stat-icon.avg {
  background: linear-gradient(135deg, #0d6efd 0%, #0dcaf0 100%);
  color: white;
}

.sc-stat-icon.high {
  background: linear-gradient(135deg, #f44336 0%, #e91e63 100%);
  color: white;
}

.sc-stat-icon.low {
  background: linear-gradient(135deg, #00c853 0%, #00e676 100%);
  color: white;
}
/* .temp-stat-card {
    background: linear-gradient(135deg, #35354a 0%, #2a2a3e 100%);
    border-radius: 10px;
    padding: 15px;
    border: 1px solid #4a4a5e;
    transition: all 0.3s;
  } */

.individual-temps-header {
  font-size: 0.75rem;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.sc-temp-stat {
  text-align: center;
}
.sc-temp-val {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-primary);
}
.sc-temp-val.hot {
  color: var(--red);
}
.sc-temp-val.warm {
  color: var(--amber);
}
.sc-temp-val.cool {
  color: var(--cyan);
}
.sc-temp-val.cold {
  color: #7ecfff;
}
.sc-temp-lbl {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: 1px;
}

/* Fan summary row */
.sc-fan-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.sc-fan-stat {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--bg-item);
  color: var(--text-muted);
  border: 1px solid var(--bg-border);
}
.sc-fan-stat.running {
  color: var(--green);
  background: rgba(34, 217, 138, 0.08);
  border-color: rgba(34, 217, 138, 0.25);
}
.sc-fan-stat.manual {
  color: var(--amber);
  background: rgba(245, 166, 35, 0.08);
  border-color: rgba(245, 166, 35, 0.25);
}
.sc-fan-stat.fault {
  color: var(--red);
  background: rgba(240, 64, 90, 0.08);
  border-color: rgba(240, 64, 90, 0.25);
}

/* Active alarms strip */
.sc-alarms {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: rgba(240, 64, 90, 0.08);
  border: 1px solid rgba(240, 64, 90, 0.3);
  border-radius: 7px;
  margin-bottom: 8px;
}
.sc-alarms-msg {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.sc-alarms-ack {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 9px;
  background: rgba(245, 166, 35, 0.15);
  border: 1px solid rgba(245, 166, 35, 0.55);
  color: var(--amber);
  border-radius: 5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.sc-alarms-ack:hover {
  background: rgba(245, 166, 35, 0.28);
}
.sc-alarms-ack.sent {
  background: rgba(34, 217, 138, 0.15);
  border-color: rgba(34, 217, 138, 0.5);
  color: var(--green);
  cursor: default;
}
.sc-alarms-ack:disabled {
  opacity: 0.85;
}

/* Slow spin for running fan icon on store card */
@keyframes fan-rotate-slow {
  to {
    transform: rotate(360deg);
  }
}
.fan-spin-slow {
  display: inline-block;
  animation: fan-rotate-slow 2.5s linear infinite;
}

/* ── Fan chips — store-list view ─────────────────────────────────────────── */
.fan-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.fan-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.fan-chip.running {
  background: rgba(34, 217, 138, 0.12);
  color: var(--green);
  border-color: rgba(34, 217, 138, 0.3);
}
.fan-chip.stopped {
  background: rgba(108, 118, 156, 0.12);
  color: var(--text-muted);
  border-color: var(--bg-border);
}
.fan-chip.fault {
  background: rgba(240, 64, 90, 0.12);
  color: var(--red);
  border-color: rgba(240, 64, 90, 0.3);
}
.fan-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.fan-dot.running {
  background: var(--green);
}
.fan-dot.stopped {
  background: var(--text-muted);
}
.fan-dot.fault {
  background: var(--red);
  animation: pulse 1.2s infinite;
}

/* ── Fan cards — detail view ─────────────────────────────────────────────── */
.fans-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.fan-card {
  background: linear-gradient(135deg, #35354a 0%, #2a2a3e 100%);
  border-radius: 10px;
  padding: 14px;
  border: 1px solid #4a4a5e;
  transition: all 0.25s;
}
.fan-card.running {
  border-color: rgba(34, 217, 138, 0.45);
  background: linear-gradient(135deg, #1a3530 0%, #1e2e2a 100%);
}
.fan-card.fault {
  border-color: rgba(240, 64, 90, 0.5);
  background: linear-gradient(135deg, #351a1a 0%, #2a1e1e 100%);
}
.fan-card.stopped {
  border-color: #4a4a5e;
}

.fan-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.fan-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.fan-card-icon.running {
  background: linear-gradient(135deg, #22d98a 0%, #00b377 100%);
  color: #000;
}
.fan-card-icon.stopped {
  background: rgba(108, 118, 156, 0.2);
  color: var(--text-muted);
}
.fan-card-icon.fault {
  background: linear-gradient(135deg, #f0405a 0%, #c0192e 100%);
  color: #fff;
}

.fan-card-info {
  flex: 1;
  min-width: 0;
}
.fan-card-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fan-card-state {
  font-size: 0.78rem;
  font-weight: 700;
  margin-top: 2px;
}
.fan-card-state.running {
  color: var(--green);
}
.fan-card-state.stopped {
  color: var(--text-muted);
}
.fan-card-state.fault {
  color: var(--red);
}

/* Mode badges */
.fan-mode-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}
.fan-mode-badge.auto {
  background: rgba(0, 210, 230, 0.12);
  color: var(--cyan);
  border: 1px solid rgba(0, 210, 230, 0.3);
}
.fan-mode-badge.manual {
  background: rgba(245, 166, 35, 0.15);
  color: var(--amber);
  border: 1px solid rgba(245, 166, 35, 0.4);
  animation: manual-pulse 2s ease-in-out infinite;
}
@keyframes manual-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(245, 166, 35, 0);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(245, 166, 35, 0.15);
  }
}

/* Fan control buttons */
.fan-controls {
  display: flex;
  flex-direction: column;
  padding: 10px 0;
  gap: 8px;
}
.fan-btn {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--bg-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition:
    background 0.2s,
    color 0.2s,
    border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.fan-btn:active {
  opacity: 0.75;
}
.fan-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.fan-btn-on {
  border-color: rgba(34, 217, 138, 0.3);
}
.fan-btn-on:active,
.fan-btn-on.active {
  background: rgba(34, 217, 138, 0.18);
  color: var(--green);
  border-color: rgba(34, 217, 138, 0.55);
}
.fan-btn-off {
  border-color: rgba(108, 118, 156, 0.3);
}
.fan-btn-off:active,
.fan-btn-off.active {
  background: rgba(108, 118, 156, 0.18);
  color: var(--text-primary);
  border-color: rgba(108, 118, 156, 0.55);
}
.fan-btn-auto {
  border-color: rgba(0, 210, 230, 0.3);
  color: var(--cyan);
}
.fan-btn-auto:active,
.fan-btn-auto.active {
  background: rgba(0, 210, 230, 0.12);
}
.fan-btn-mode {
  border-color: rgba(245, 166, 35, 0.3);
  color: var(--amber);
}
.fan-btn-mode:active {
  background: rgba(245, 166, 35, 0.12);
}

/* Spinning fan icon when running */
@keyframes fan-rotate {
  to {
    transform: rotate(360deg);
  }
}
.fan-spin {
  display: inline-block;
  animation: fan-rotate 1.2s linear infinite;
}

/* ── Probe grid — matches dashboard temp-stat-card ───────────────────────── */
.probes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

/* temp-stat-card: exact match to dashboard */
.temp-stat-card {
  background: linear-gradient(135deg, #35354a 0%, #2a2a3e 100%);
  border-radius: 10px;
  padding: 15px;
  border: 1px solid #4a4a5e;
  transition: all 0.3s;
}
.temp-stat-card:active {
  transform: translateY(-1px);
  border-color: #0d6efd;
  box-shadow: 0 4px 12px rgba(13, 110, 253, 0.2);
}
.temp-stat-card.probe-offline {
  opacity: 0.55;
}
.temp-stat-content {
  text-align: left;
}

.temp-stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.temp-stat-icon.avg {
  background: linear-gradient(135deg, #0d6efd 0%, #0dcaf0 100%);
  color: #fff;
}

.temp-stat-label {
  font-size: 0.75rem;
  color: #adb5bd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}

.temp-stat-value {
  font-size: 1.6rem;
  font-weight: bold;
  color: #fff;
  line-height: 1.2;
}
/* temperature colour classes — match dashboard */
.temp-stat-value.hot {
  color: var(--red);
}
.temp-stat-value.warm {
  color: var(--amber);
}
.temp-stat-value.cool {
  color: var(--cyan);
}
.temp-stat-value.cold {
  color: #7ecfff;
}

/* SVG battery — matches dashboard base.html */
.battery-container {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  vertical-align: middle;
}
.batteryIcon {
  width: 35px;
  height: auto;
  flex-shrink: 0;
}
.batteryLevel {
  transition:
    width 0.8s ease-in-out,
    fill 0.4s ease;
}
.batteryText {
  font-size: 0.82rem;
  min-width: 32px;
  color: var(--text-primary);
}

.probe-updated {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── PWA 3D store visualisation ──────────────────────────────────────────── */
.pwa-3d-wrap {
  margin-bottom: 14px;
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
  border-radius: 12px;
  overflow: hidden;
}
.pwa-3d-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 0;
}
.pwa-3d-controls {
  display: flex;
  gap: 6px;
}
.pwa-3d-btn {
  background: none;
  border: 1px solid var(--bg-border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}
.pwa-3d-btn:active {
  background: var(--bg-item);
}
.pwa-3d-canvas {
  width: 100%;
  height: 280px;
  display: block;
  background: #080d24;
  border-radius: 0 0 12px 12px;
  /* Prevent the canvas from hijacking page scroll on mobile */
  touch-action: pan-y;
}
.pwa-3d-canvas canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  border-radius: 0 0 12px 12px;
  /* Allow vertical scroll to pass through on mobile */
  touch-action: pan-y;
}
/* On desktop/laptop show a hint that mouse controls work */
@media (hover: hover) and (pointer: fine) {
  .pwa-3d-canvas canvas {
    touch-action: none;
    cursor: grab;
  }
  .pwa-3d-canvas canvas:active {
    cursor: grabbing;
  }
}

/* Mobile-only caption under 3D canvas */
.pwa-3d-mobile-hint {
  display: none;
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: center;
  padding: 4px 0 8px;
}
@media (hover: none) and (pointer: coarse) {
  /* Touch device — show hint, hide desktop grab cursor */
  .pwa-3d-mobile-hint {
    display: block;
  }
}

/* ── Store detail header ──────────────────────────────────────────────────── */
.detail-ambient {
  display: flex;
  gap: 16px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
  border-radius: 10px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, #ff9800 0%, #ff6f00 100%);
}
.detail-ambient-item {
  text-align: center;
}
.detail-ambient-val {
  font-size: 1.4rem;
  font-weight: 700;
  color: #ffffff;
}
.detail-ambient-lbl {
  font-size: 0.72rem;
  color: #ffffff;
  text-transform: uppercase;
}
.ambient-icon {
  width: 60px;
  height: 60px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: #ffffff;
  flex-shrink: 0;
}
.ambient-icon {
  width: 50px;
  height: 50px;
  font-size: 1.5rem;
}

.section-header {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 14px 0 8px;
}

/* ── Offline banner ───────────────────────────────────────────────────────── */
.offline-banner {
  background: rgba(245, 166, 35, 0.15);
  border: 1px solid var(--amber);
  color: var(--amber);
  padding: 8px 14px;
  font-size: 0.82rem;
  text-align: center;
  display: none;
}
.offline-banner.show {
  display: block;
}

/* ── Loading spinner ──────────────────────────────────────────────────────── */
.spinner-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--bg-border);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Logout button ────────────────────────────────────────────────────────── */
.btn-logout {
  background: none;
  border: 1px solid var(--bg-border);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
}
.btn-logout:active {
  background: var(--bg-item);
}

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.4;
}
.empty-state h3 {
  font-size: 1rem;
  margin-bottom: 6px;
  color: var(--text-primary);
}

/* ── Alarm cards (store detail) ──────────────────────────────────────────── */
.alarm-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.alarm-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
}
.alarm-card.alarm-critical {
  background: rgba(240, 64, 90, 0.06);
  border-color: rgba(240, 64, 90, 0.35);
}
.alarm-card.alarm-warning {
  background: rgba(245, 166, 35, 0.06);
  border-color: rgba(245, 166, 35, 0.35);
}
.alarm-card.alarm-info {
  background: rgba(0, 210, 230, 0.04);
  border-color: rgba(0, 210, 230, 0.25);
}
.alarm-card-body {
  flex: 1;
  min-width: 0;
}
.alarm-card-type {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.alarm-card-msg {
  font-size: 0.85rem;
  color: var(--text-primary);
  line-height: 1.4;
}
.alarm-card-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── Swipe-to-acknowledge ───────────────────────────────────────────────── */
/*
 * Each alarm sits inside .alarm-row which has the amber ACK action absolutely
 * positioned on the right edge. The .alarm-card itself is the foreground;
 * dragging it leftwards exposes the action underneath. A slow swipe rests at
 * the action's width (~20% of the card) so the button can be tapped to confirm;
 * a fast left flick (>800px/s) commits immediately.
 */
.alarm-row {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  /* Match alarm-list gap by sitting in the same flex column */
}
.alarm-row-action {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 20%;            /* one-fifth of the card */
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--amber);
  color: #1a1a2e;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  cursor: pointer;
  border: none;
  user-select: none;
  -webkit-user-select: none;
  /* Sit BEHIND the card foreground until revealed */
  z-index: 0;
}
.alarm-row-action i { font-size: 1.2rem; margin-bottom: 2px; }
.alarm-row-action-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;  /* tap target is the parent button */
}
.alarm-row .alarm-card {
  position: relative;
  z-index: 1;            /* above the action layer */
  margin-bottom: 0;      /* row provides spacing */
  background: var(--bg-card);  /* must be opaque so the action stays hidden when not swiped */
  transition: transform 0.18s ease;
  touch-action: pan-y;   /* let vertical scroll through, capture horizontal */
  will-change: transform;
}
/* Severity-tinted backgrounds need to remain opaque — preserve the existing
 * tint by re-stating it with non-alpha base so transforms show no bleed. */
.alarm-row .alarm-card.alarm-critical { background: #2a1822; }
.alarm-row .alarm-card.alarm-warning  { background: #2a221a; }
.alarm-row .alarm-card.alarm-info     { background: #1a2228; }
.alarm-row.swiping .alarm-card { transition: none; }
.alarm-row.committing .alarm-card { transition: transform 0.22s ease; }

/* ── Last updated ─────────────────────────────────────────────────────────── */
.last-updated {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 12px;
}

/* ── Animations ───────────────────────────────────────────────────────────── */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* ── Safe area (notch/home-bar) ───────────────────────────────────────────── */
.main-content {
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}
.app-header {
  padding-top: max(12px, env(safe-area-inset-top));
}

/* ── Farm name banner (dashboard / stores list) ───────────────────────────── */
.farm-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(
    135deg,
    rgba(0, 210, 230, 0.12) 0%,
    rgba(167, 139, 250, 0.08) 100%
  );
  border: 1px solid rgba(0, 210, 230, 0.25);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 4px 0 14px;
}
.farm-banner-icon {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(0, 210, 230, 0.18);
  color: var(--cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.farm-banner-text {
  flex: 1;
  min-width: 0;
}
.farm-banner-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.farm-banner-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Notifications menu (header bell) ─────────────────────────────────────── */
.notif-menu-wrap {
  position: relative;
  margin-right: 4px;
}
#header-notif .bi-bell-slash,
#header-notif .bi-bell-slash-fill {
  color: var(--amber);
}
.notif-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  padding: 6px;
  display: none;
  z-index: 1000;
}
.notif-menu.open {
  display: block;
}
.notif-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--bg-border);
  margin-bottom: 4px;
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.notif-status {
  font-weight: 700;
  color: var(--green);
}
.notif-status.muted {
  color: var(--amber);
}
.notif-status.off {
  color: var(--red);
}
.notif-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 10px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.88rem;
  text-align: left;
  border-radius: 6px;
  cursor: pointer;
}
.notif-menu-item:hover,
.notif-menu-item:focus-visible {
  background: var(--bg-item);
  outline: none;
}
.notif-menu-item .notif-item-label {
  flex: 1;
}
.notif-menu-item .notif-item-check {
  opacity: 0;
  color: var(--cyan);
}
.notif-menu-item.active .notif-item-check {
  opacity: 1;
}
.notif-menu-divider {
  height: 1px;
  background: var(--bg-border);
  margin: 6px 0;
}
.notif-menu-foot {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 8px 10px 6px;
  border-top: 1px solid var(--bg-border);
  margin-top: 4px;
  min-height: 1em;
}
/* Version label at the foot of the header hamburger menu */
.notif-menu-version {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 4px;
  font-size: 0.7rem;
  color: var(--text-muted);
  border-top: 1px solid var(--bg-border);
  margin-top: 4px;
}

/* ── Per-store-card hamburger menu ─────────────────────────────────────── */
.store-card-menu-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  padding: 2px 8px;
  margin-left: auto;
  margin-right: 6px;
  border-radius: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.store-card-menu-btn:active {
  background: var(--bg-item);
  color: var(--cyan);
}
.store-card-menu-btn[aria-expanded="true"] {
  color: var(--cyan);
}
.store-card-menu {
  display: none;
  background: var(--bg-item);
  border: 1px solid var(--bg-border);
  border-radius: 8px;
  padding: 6px;
  margin-bottom: 10px;
}
.store-card-menu.open {
  display: block;
}
.store-card-menu .notif-menu-header {
  padding: 6px 8px 8px;
}
.store-card-menu .notif-menu-item {
  padding: 8px 8px;
  font-size: 0.85rem;
}
.notif-menu-foot:empty {
  display: none;
}

/* Per-store mute section inside the menu */
.notif-menu {
  max-height: 75vh;
  overflow-y: auto;
}
.notif-per-store:empty {
  display: none;
}
.notif-per-store {
  border-top: 1px solid var(--bg-border);
  margin-top: 4px;
  padding-top: 4px;
}
.notif-section-title {
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 10px 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.notif-store-row {
  padding: 6px 10px 8px;
  border-radius: 6px;
}
.notif-store-row:hover {
  background: var(--bg-item);
}
.notif-store-row-main {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  margin-bottom: 4px;
}
.notif-store-name {
  flex: 1;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notif-store-state {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.notif-store-actions {
  display: flex;
  gap: 4px;
}
.notif-store-btn {
  flex: 1;
  padding: 5px 0;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg-base);
  border: 1px solid var(--bg-border);
  color: var(--text-primary);
  border-radius: 5px;
  cursor: pointer;
}
.notif-store-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}
.notif-store-btn:focus-visible {
  outline: 1px solid var(--cyan);
  outline-offset: 1px;
}

/* ── Pull-to-refresh + last-sync pill ─────────────────────────────────────── */
.ptr-indicator {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translate(-50%, -100%);
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 14px;
  padding: 8px 14px;
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 900;
  pointer-events: none;
  transition: transform 0.18s ease;
}
.ptr-indicator.visible {
  transform: translate(-50%, 0);
}
.ptr-indicator.refreshing #ptr-icon {
  animation: spin 0.8s linear infinite;
}
.ptr-indicator.refreshing #ptr-text::after {
  content: "Refreshing…";
}
.ptr-indicator.refreshing #ptr-text {
  font-size: 0;
}
.ptr-indicator #ptr-text {
  font-size: 0.78rem;
}

.sync-pill {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(26, 26, 46, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--bg-border);
  border-radius: 999px;
  padding: 5px 6px 5px 12px;
  font-size: 0.72rem;
  color: var(--text-muted);
  z-index: 850;
  user-select: none;
}
.sync-pill .sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}
.sync-pill.stale .sync-dot {
  background: var(--amber);
  box-shadow: 0 0 6px var(--amber);
}
.sync-pill.offline .sync-dot {
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
}
#sync-pill-refresh {
  background: transparent;
  border: 1px solid var(--bg-border);
  color: var(--cyan);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font-size: 0.85rem;
}
#sync-pill-refresh:hover {
  border-color: var(--cyan);
}
#sync-pill-refresh.spinning i {
  animation: spin 0.8s linear infinite;
}
