/* ═══════════════════════════════════════════
   AVONIC  –  styles.css  v5.0
   Fully restored structure, clean cards, & Modals
   ═══════════════════════════════════════════ */

/* ── Tokens ──────────────────────────────── */
:root {
  --bg:           #dedad2;   
  --card:         #fcfaf6;   
  --inner:        #ffffff;   
  --inner-bg:     #f9f7f3;   
  --border:       #dbd5c8;
  --border-inner: #ece8e0;
  
  --topbar:       #2e4f39;   
  --sidebar:      #4B644E;
  --green-mid:    #3d6b4c;
  --green-accent: #6aab7a;
  --green-pale:   #eef5ed;   
  --green-card-b: #b5d9be;   

  --yellow:       #f5c518;
  --yellow-hover: #d4a810;

  --warn:         #f59e0b;
  --danger:       #ef4444;

  --text:         #17211a;
  --text-sub:     #4a5c44;
  --text-muted:   #8a9c84;

  --f:            'Segoe UI', system-ui, sans-serif;
  --r:            24px;   
  --r-sm:         10px;   
  --r-xs:         6px;
  --sh:           0 4px 24px rgba(0,0,0,.04);
  --t:            .24s ease;

  --sb-w:         68px;   
  --tb-h:         52px;   
  --gap:          24px;   
}

/* Regular Weight */
@font-face {
    font-family: 'Quicksand';
    src: url('../assets/fonts/Quicksand-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* Light Weight */
@font-face {
    font-family: 'Quicksand';
    src: url('/assets/fonts/Quicksand-Light.ttf') format('truetype');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}

/* Medium Weight */
@font-face {
    font-family: 'Quicksand';
    src: url('/assets/fonts/Quicksand-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

/* SemiBold Weight */
@font-face {
    font-family: 'Quicksand';
    src: url('/assets/fonts/Quicksand-SemiBold.ttf') format('truetype');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

/* Bold Weight */
@font-face {
    font-family: 'Quicksand';
    src: url('/assets/fonts/Quicksand-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}


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

html {
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  ;
}

body {
  font-family: var(--f);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  font-family: 'Quicksand', sans-serif
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
}

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

img {
  display: block;
  max-width: 100%;
  object-fit: contain;
}

input, select {
  font: inherit;
}

::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* ── Utility Classes ─────────────────────── */
.mt-4 { margin-top: 16px; }
.w-100 { width: 100%; }

.ic-xs { width: 13px; height: 13px; flex-shrink: 0; }
.ic-sm { width: 20px; height: 20px; flex-shrink: 0; }
.ic-md { width: 26px; height: 26px; flex-shrink: 0; }

.nav-ic {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  opacity: .5;
  transition: opacity var(--t);
}

.bnav-ic {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  opacity: .45;
  transition: opacity var(--t);
}

/* ════════════════════════════════════════════
   TOPBAR
   ════════════════════════════════════════════ */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--tb-h);
  background: var(--topbar);
  display: flex;
  align-items: center;
  padding: 0 16px 0 20px;
  gap: 10px;
  z-index: 100;
  border-bottom: solid 1px;
}

.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 6px;
  min-width: 34px;
  min-height: 34px;
  border-radius: var(--r-xs);
  flex-shrink: 0;
}

/* --- TOPBAR ADDITIONS --- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between; /* Pushes left and right sides apart */
  padding: 0 20px;
  height: var(--tb-h);
  background: var(--topbar);
  z-index: 100;
  border-bottom: 1px solid rgba(0,0,0,0.2);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tb-conn-text {
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  opacity: 0.9;
  display: none; /* Hidden on mobile by default */
}

/* The White Pill Dropdown Container */
.tb-bin-selector {
  position: relative;
  display: flex;
  align-items: center;
  background: #ffffff;
  border-radius: 30px;
  padding: 4px 12px 4px 4px;
  height: 36px;
  min-width: 220px;
  cursor: pointer;
}

/* Dark circle icon background inside the pill */
.tb-bin-icon-bg {
  width: 28px;
  height: 28px;
  background: #2e4f39; /* Dark green */
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 8px;
}

.tb-bin-icon-bg img {
  width: 16px;
  height: 16px;
  filter: brightness(0) invert(1); /* Make it white */
}

/* The actual select element (invisible but clickable over the pill) */
.tb-bin-dropdown {
  appearance: none;
  background: transparent;
  border: none;
  color: #111;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  width: 100%;
  cursor: pointer;
  outline: none;
  z-index: 2; /* Sits above the chevron */
  padding-right: 20px; /* Space for chevron */
}

.tb-chevron {
  position: absolute;
  right: 12px;
  width: 12px;
  height: 12px;
  pointer-events: none; /* Let clicks pass through to the select */
}

/* Circular Edit Button */
.tb-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.4);
  background: transparent;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--t);
}

.tb-icon-btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: white;
}

.hamburger:hover {
  background: rgba(255, 255, 255, .1);
}

.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: var(--t);
}

.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.topbar-logo {
  display: flex;
  align-items: center;
  margin-right: auto;
}

.logo-img {
  height: 26px;
  width: auto;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.refresh-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--r-xs);
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, .72);
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(255, 255, 255, .08);
  transition: var(--t);
  white-space: nowrap;
}

.refresh-btn:hover {
  background: rgba(255, 255, 255, .16);
  color: #fff;
}

.refresh-btn.spinning .ic-xs {
  animation: spin .8s linear infinite;
}

.refresh-label {
  font-size: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ════════════════════════════════════════════
   SIDEBAR & EXPAND LOGIC
   ════════════════════════════════════════════ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .42);
  z-index: 150;
  backdrop-filter: blur(2px);
  border-right: 1px solid;
}

.sidebar-overlay.show {
  display: block;
}

.sidebar {
  position: fixed;
  top: var(--tb-h);
  left: 0;
  width: var(--sb-w);
  height: calc(100dvh - var(--tb-h));
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0 18px;
  z-index: 90;
  overflow: hidden;
  transition: width var(--t), padding var(--t), transform var(--t);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  width: 100%;
}

.sidebar-bottom {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--r-sm);
  position: relative;
  cursor: pointer;
  transition: background var(--t);
  -webkit-tap-highlight-color: transparent;
}

.nav-item:hover {
  background: rgba(255, 255, 255, .1);
}

.nav-item:hover .nav-ic {
  opacity: .9;
}

.nav-item.active {
  background: rgba(255, 255, 255, .16);
}

.nav-item.active .nav-ic {
  opacity: 1;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  background: var(--green-accent);
  border-radius: 0 3px 3px 0;
}

.nav-label {
  display: none;
}

.nav-logout {
  margin-top: auto;
}

.support-card {
  display: none;
  background: #4ca67f;
  border-radius: 20px;
  padding: 24px 20px;
  margin-bottom: 24px;
  color: #fff;
  flex-direction: column;
  gap: 8px;
}

.support-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}

.support-sub {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.9;
  line-height: 1.3;
}

/* Expanded Desktop Sidebar Triggers */
body.sidebar-expanded .sidebar {
  width: 240px;
  align-items: stretch;
  padding-left: 20px;
  padding-right: 20px;
}

body.sidebar-expanded .main {
  margin-left: 240px;
}

body.sidebar-expanded .nav-item {
  width: 100%;
  justify-content: flex-start;
  padding: 0 16px;
  gap: 14px;
}

body.sidebar-expanded .nav-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
}

body.sidebar-expanded .sidebar-bottom {
  align-items: stretch;
}

body.sidebar-expanded .support-card {
  display: flex;
  animation: tIn .3s ease forwards;
}

body.sidebar-expanded .nav-logout {
  border: 1px solid rgba(255, 255, 255, 0.8);
  justify-content: center;
  padding: 0;
}

/* ════════════════════════════════════════════
   MAIN SHELL
   ════════════════════════════════════════════ */
.main {
  margin-left: var(--sb-w);
  margin-top: var(--tb-h);
  /* Change height from calc to auto to allow the body to scroll */
  height: auto; 
  min-height: calc(100dvh - var(--tb-h));
  padding: var(--gap);
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Allow the main viewport to handle the scroll */
  overflow: visible; 
  transition: margin-left var(--t);
}
/* Update around line 355 */
.page {
  display: none;
  /* flex: 1;  <-- Remove or comment this out */
  flex-direction: column;
  width: 100%;
  max-width: 1060px;
  height: auto;
  min-height: 900px; /* Ensure this is auto */
  max-height: 900px; /* Limits height to 85% of the screen height */
  overflow: visible;
}

.page.active {
  display: flex;
}

/* Update around line 369 */
.page-card {
  background: var(--card);
  border-radius: var(--r);
  border: 1px solid;
  box-shadow: var(--sh);
  /* flex: 1; <-- Remove or comment this out */
  display: flex;
  flex-direction: column;
  overflow: hidden; 
  width: 100%;
  height: auto; /* Force height to fit content */
}

/* Update around line 382 */
.page-body {
  /* flex: 1; <-- Remove or comment this out */
  overflow-y: visible; 
  padding: 32px 22px;
  display: flex;
  flex-direction: column;
  height: auto; /* Force height to fit content */
}

/* ════════════════════════════════════════════
   HOME PAGE
   ════════════════════════════════════════════ */
.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 18px;
}

.home-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.status-pills {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.spill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: #ffffff;
  border: 1px solid #d1ccc1;
  border-radius: 8px; 
  font-size: 18px;
  font-weight: 400; 
  color: var(--text);
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(0,0,0,.08); 
}

.spill.spill-group {
  padding: 0;
}

.spill-half {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: 6px;
  transition: background 0.3s, color 0.3s;
}

@keyframes spill-half-pulse {
  0%, 100% { background: transparent; color: var(--text); }
  50%       { background: rgba(239, 68, 68, 0.13); color: #ef4444; }
}
.spill-half.spill-alert {
  animation: spill-half-pulse 1.4s ease-in-out infinite;
  /* override the default spill-alert which targets border */
  border-color: transparent !important;
  box-shadow: none !important;
}

.spill-divider {
  width: 1px;
  height: 26px;
  background: #d1ccc1;
}

/* Clickable status pills */
.spill-clickable {
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.spill-clickable:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,.13);
}
.spill-clickable:active {
  transform: scale(0.97);
}

/* Pulse animation for low-state pills */
@keyframes spill-pulse-low {
  0%, 100% {
    background: #ffffff;
    border-color: #d1ccc1;
    box-shadow: 0 3px 10px rgba(0,0,0,.08);
    color: var(--text);
  }
  50% {
    background: rgba(239, 68, 68, 0.09);
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18), 0 3px 10px rgba(239,68,68,.10);
    color: #ef4444;
  }
}
.spill-alert {
  animation: spill-pulse-low 1.4s ease-in-out infinite;
}
.spill-alert span { transition: color 0.3s; }

/* ── Dynamic Battery SVG Icon ── */
#bat-svg-icon { color: var(--text); transition: color 0.4s; }
#bat-svg-icon.bat-low      { color: #ef4444; }
#bat-svg-icon.bat-medium   { color: #f59e0b; }
#bat-svg-icon.bat-good     { color: #22c55e; }
#bat-svg-icon.bat-charging { color: #22c55e; }
/* When the pill is in alert state, SVG inherits the pill's animated color */
.spill-alert #bat-svg-icon { color: inherit; }

#bat-fill-bar { transition: width 0.5s cubic-bezier(.4,0,.2,1), fill 0.4s; }

@keyframes bat-charge-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}
#bat-svg-icon.bat-charging #bat-fill-bar {
  animation: bat-charge-pulse 1.1s ease-in-out infinite;
}

.home-divider {
  height: 1px;
  background: #d1ccc1;
  margin-bottom: 28px;
}

.section-label {
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 16px;
}

.bins-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px; 
}

.bin-card {
  background-color: var(--green-pale); 
  background-image: url("/img/photos/BinCards.png");
  background-size: cover;
  background-position: center bottom;
  background-repeat: no-repeat;
  border: 1px solid #a8c4b0;
  border-radius: 16px;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.03);
  transition: transform var(--t), box-shadow var(--t);
  -webkit-tap-highlight-color: transparent;
  aspect-ratio: 1.42; 
  justify-content: flex-start;
  position: relative;
  overflow: hidden;
}

.bin-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 16px rgba(0,0,0,.08);
}

.bin-card:active {
  transform: scale(.985);
}

.bin-name {
  font-size: 48px;
  font-weight: 400;
  color: var(--text);
  line-height: 1;
}

.bin-mode {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #6b7a67;
  margin-top: -2px;
}

.bin-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #6b7a67;
  flex-shrink: 0;
}

/* ════════════════════════════════════════════
   BIN MONITORING UI
   ════════════════════════════════════════════ */
.bin-body {
  gap: 16px;

}

.bin-crumb {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  background: #e2e2e2;
  border-bottom: 1px solid #111;
  margin: -36px -42px 24px -42px;
  padding: 16px 28px;
}
.back-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #ffc46b; /* Soft yellow-orange */
  border: 1px solid #111;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--t);
}

.back-btn:hover {
  transform: scale(0.95);
}

.back-btn img {
  filter: brightness(0); /* Forces pure black arrow */
  width: 18px; 
  height: 18px;
}

.crumb-path {
  font-size: 13px;
  font-weight: 500;
  color: #666;
  display: block;
  line-height: 1.2;
}

.crumb-name {
  font-size: 26px; /* Scaled up to match reference */
  font-weight: 700;
  color: #111;
  line-height: 1.2;
  margin-top: 4px;
}

/* Updated Banner */
.bin-banner {
  flex-shrink: 0;
  border-radius: 20px;
  background: linear-gradient(125deg, #6cc078 0%, #87db8c 100%);
  color: #fff;
  padding: 20px 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 120px;
  position: relative;
  height: 190px;
  border: 1px solid black;
}

.banner-left {
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 1;
}

.banner-title {
  font-size: 36px;
  font-weight: 400;
  line-height: 1;
}

.banner-sub {
  font-size: 12px;
  opacity: .8;
}

.banner-refresh {
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, .5);
  font-size: 12px;
  color: rgba(255, 255, 255, .9);
  background: rgba(255, 255, 255, .15);
  cursor: pointer;
  transition: var(--t);
  align-self: flex-start;
}

.banner-refresh:hover {
  background: rgba(255, 255, 255, .25);
}

 /* New Pill Mode Selector Wrapper */
.mode-selector-wrap {
  display: flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid #111; 
  border-radius: 30px;
  padding: 5px 6px 5px 16px; /* Extra padding on left for text, tight on right for button */
  gap: 10px;
  cursor: pointer;
  z-index: 1;
  box-shadow: 2px 3px 0px rgba(0, 0, 0, 0.08); /* Subtle shadow for depth */
  transition: transform var(--t);
}

.mode-selector-wrap:active {
  transform: scale(0.97);
}

.mode-lbl {
  font-size: 14px;
  font-weight: 500;
  color: #111;
}

/* Inner Mode Button */
.mode-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  transition: background var(--t), color var(--t);
  border: 1px solid #111; 
}

/* Auto State (Green) */
.mode-btn.auto {
  background: #4B644E; 
  color: #ffffff;
}

.mode-btn.auto .chevron-icon {
  filter: brightness(0) invert(1); /* Turns black icon to white */
}

/* Manual State (Orange) */
.mode-btn.manual {
  background: #F4A261; /* Soft orange/peach */
  color: #111111;
}

.mode-btn.manual .chevron-icon {
  filter: brightness(0); /* Forces icon to pure black */
}

/* Updated Clean Sensor Cards */
/* Neo-Brutalist Conditional Sensor Cards */
.sensor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  flex-shrink: 0;
  height: 60%;
}

 .sensor-card {
  background: #fdfdfd; 
  border: 1px solid #111; 
  border-radius: 20px; /* Slightly rounder like legacy */
  padding: 32px 36px; /* Maximize white space */
  min-height: 180px; /* Force taller cards */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: 0px 2px 0px rgba(0, 0, 0, 1); 
  transition: transform var(--t), box-shadow var(--t);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sensor-card:hover {
  transform: translateY(-2px);
  box-shadow: 6px 6px 0px rgba(0, 0, 0, 1);
}

.sensor-card:active {
  transform: translateY(2px);
  box-shadow: 2px 2px 0px rgba(0, 0, 0, 1);
}

/* Ensure background stays white regardless of condition */
.sensor-card.optimal, .sensor-card.warn, .sensor-card.danger { 
  background: #fdfdfd; 
}

.sc-info {
  display: flex;
  flex-direction: column;
  gap: 6px; /* Better spacing between text */
}

/* The neon green/yellow highlight behind the title */
.sc-name {
  font-size: 15px; /* Slightly larger */
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  background: #f1f8d4; 
  display: inline-block;

  border-radius: 8px;
  width: fit-content;
}

/* Status Text - Changes color based on condition */
.sc-status {
  font-size: 14px; /* Larger status text */
  font-weight: 600;
  margin-bottom: 12px; /* Pushes the big value down */
  transition: color var(--t);
}

.sensor-card.optimal .sc-status { color: #a0a0a0; } 
.sensor-card.warn .sc-status    { color: #f4a261; } 
.sensor-card.danger .sc-status  { color: #ef4444; } 

.sc-value {
  font-size: 48px; /* Massive value text */
  font-weight: 400;
  color: var(--text);
  line-height: 1;
}

.sc-unit {
  font-size: 22px; /* Massive unit text */
  color: #a0a0a0;
  margin-left: 6px;
}

/* Thicker Progress Rings with Flat Edges */
.ring-wrap {
  flex-shrink: 0;
  width: 96px; /* Scaled up heavily to match legacy */
  height: 96px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ring-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none; 
  stroke: #e8e8e8; 
  stroke-width: 10; /* Thicker track to match the scaled ring */
}

.ring-arc {
  fill: none;
  stroke-width: 10; /* Thicker arc */
  stroke-linecap: butt; 
  transition: stroke-dashoffset .5s ease, stroke .3s;
}

/* Ring Progress Color - Changes based on condition */
.sensor-card.optimal .ring-arc { stroke: #2a8b3d; } 
.sensor-card.warn .ring-arc    { stroke: #f4a261; } 
.sensor-card.danger .ring-arc  { stroke: #ef4444; } 

.ring-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.ring-icon img {
  width: 32px; /* Scaled up the inner icon */
  height: 32px;
  opacity: 1;
}
/* Switch Toggle (Reused in modals) */
.tog {
  position: relative;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.tog input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.tog-track {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 20px;
  cursor: pointer;
  transition: var(--t);
}

.tog-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  transition: transform var(--t);
}

.tog input:checked + .tog-track {
  background: var(--sidebar);
}

.tog input:checked + .tog-track::after {
  transform: translateX(22px);
}

.tog input:disabled + .tog-track {
  opacity: .4;
  cursor: not-allowed;
}

/* ════════════════════════════════════════════
   MODALS
   ════════════════════════════════════════════ */
.sys-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(3px);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.2s;
 
}

.sys-modal-overlay.show {
  display: block;
  opacity: 1;
  
}

.sys-modal{
  display:none;position:fixed;top:50%;left:50%;transform:translate(-50%,-45%);
  background:#fff;border-radius:24px;padding:28px 24px;z-index:210;
  width:92%;max-width:380px;box-shadow:0 10px 40px rgba(0,0,0,0.15);
  opacity:0;transition:opacity 0.2s, transform 0.2s;
   border: solid black 1px;
}

/* Wider variant for text-recommendation modals */
.sys-modal-wide {
  max-width: 460px;
}

.sys-modal.show {
  display: block;
  opacity: 1;
  transform: translate(-50%, -50%);
}

/* Lift sensor modal above Driver.js overlay during onboarding tour preview */
.sys-modal.tour-preview,
.sys-modal-overlay.tour-preview {
  z-index: 10001 !important;
  
}

/* ── While sensor-preview modal is open: suppress Driver.js popover + ring ──
   body.av-tour-sensor is added by avonicTourSensorPreview() and removed on close */
body.av-tour-sensor .driver-popover        { display: none !important; }
body.av-tour-sensor .driver-active-element { outline: none !important; box-shadow: none !important; z-index: auto !important; }

/* ── Tour context banner inside sensor modal ────────────────────────── */
.sm-tour-banner {
  border-radius: 10px;
  border: 2px solid black;
  padding: 12px 14px 10px;
  margin: 14px 0 4px;
  font-family: 'Quicksand', sans-serif;
}
.sm-tour-banner--auto   { background: #eef7f1; border-color: #2E6B47; }
.sm-tour-banner--manual { background: #fffbea; border-color: #c8970a; }

.sm-tour-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.sm-tour-badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #1E3A28;
}
.sm-tour-banner--manual .sm-tour-badge { color: #7a5800; }
.sm-tour-step-tag {
  font-size: 10px;
  font-weight: 700;
  color: #999;
  letter-spacing: 0.04em;
}
.sm-tour-banner p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.65;
  color: #444;
  font-weight: 600;
}

/* ── Tour nav buttons replacing Cancel in the modal footer ─────────── */
.sm-tour-nav {
  display: flex;
  gap: 10px;
  width: 100%;
}
.sm-tour-nav-back,
.sm-tour-nav-next {
  flex: 1;
  padding: 12px 0;
  border-radius: 12px;
  border: 2px solid black;
  font-family: 'Quicksand', sans-serif;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}
.sm-tour-nav-back {
  background: #fff;
  color: #444;
  box-shadow: 3px 3px 0 black;
}
.sm-tour-nav-next {
  background: #ECBD01;
  color: #1a1a1a;
  box-shadow: 3px 3px 0 black;
}
/* Back is display:none on auto step → Next stretches full width */
.sm-tour-nav-back[style*="display: none"] ~ .sm-tour-nav-next,
.sm-tour-nav-back[style*="display:none"]  ~ .sm-tour-nav-next {
  flex: unset;
  width: 100%;
}
.sm-tour-nav-back:hover,
.sm-tour-nav-next:hover  { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 black; }
.sm-tour-nav-back:active,
.sm-tour-nav-next:active { transform: translate(2px,2px);  box-shadow: 1px 1px 0 black; }

/* ════════════════════════════════════════════
   ACT-MODAL  —  Worm Recommendations modal
   ════════════════════════════════════════════ */
.act-modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -46%);
  background: #fff;
  border-radius: 22px;
  padding: 24px 22px 22px;
  z-index: 210;
  width: 92%;
  max-width: 420px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.16);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}
.act-modal.show {
  display: block;
  opacity: 1;
  transform: translate(-50%, -50%);
}

/* ✕ — minimal pill, top-right */
.act-modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--card);
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.act-modal-close:hover { background: var(--border); color: var(--text); }

/* Sensor name + icon row */
.act-modal-sensor {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding-right: 36px;
}
.act-modal-icon { width: 20px; height: 20px; opacity: .75; }
.act-modal-sensor span { font-size: 15px; font-weight: 700; color: var(--text); }

/* Scrollable content area */
.act-modal-body { max-height: 62vh; overflow-y: auto; }

/* ════════════════════════════════════════════
   WORM INSIGHT CARD
   ════════════════════════════════════════════ */
.wi-card {
  border-radius: 16px;
  border: 1.5px solid;
  padding: 14px 16px;
}

.wi-status-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.wi-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .9px;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 20px;
}
.wi-badge-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.65);
  flex-shrink: 0;
}

.wi-headline {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.45;
  margin-bottom: 12px;
}

.wi-steps {
  list-style: none;
  padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.wi-steps li {
  display: flex; align-items: flex-start;
  gap: 10px;
  font-size: 12.5px; color: var(--text-sub); line-height: 1.5;
}
.wi-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

.wi-single { font-size: 13px; color: var(--text-sub); line-height: 1.6; margin: 0; }
.wi-empty  { font-size: 13px; color: var(--text-muted); text-align: center; padding: 16px 0; }

/* Mode Switch UI */
/* ── Water Modal SVG ── */
@keyframes water-wave-sway {
  0%, 100% { rx: 60; transform: translateX(0px);  }
  50%       { rx: 52; transform: translateX(6px);  }
}
@keyframes water-fill-rise {
  from { y: 164; height: 0;   }
  /* 'to' set dynamically via JS */
}
#water-wave {
  animation: water-wave-sway 2.4s ease-in-out infinite;
  transform-origin: 80px 164px;
}

/* ── Battery Modal SVG Illustration ── */
@keyframes bat-modal-charge-sweep {
  0%   { width: 4px;  opacity: 0.55; }
  70%  { width: 88px; opacity: 1;   }
  71%  { width: 4px;  opacity: 0.55; }
  100% { width: 4px;  opacity: 0.55; }
}
@keyframes bat-modal-bolt-pulse {
  0%, 100% { opacity: 1;   }
  50%       { opacity: 0.5; }
}
#bat-modal-fill.charging {
  animation: bat-modal-charge-sweep 1.4s linear infinite;
}
#bat-modal-bolt.charging {
  display: block !important;
  filter: invert(1);
  
 
}

.mode-ill { width: 100%; text-align: center; margin-bottom: 24px; }

/* Water modal — tighter spacing since SVG has natural whitespace */
#status-modal-water .mode-ill { margin-bottom: 8px; }
#status-modal-water .sys-modal-title { margin-bottom: 4px; }
#status-modal-water .sys-modal-desc  { margin-bottom: 16px; }

/* Temp modal — same compact treatment */
#status-modal-temp .mode-ill { margin-bottom: 8px; }
#status-modal-temp .sys-modal-title { margin-bottom: 4px; }
#status-modal-temp .sys-modal-desc  { margin-bottom: 16px; }

/* Mercury tube fill rises on open */
@keyframes therm-rise {
  from { height: 0; y: 114; }
}
#therm-tube-fill {
  transition: height 0.6s cubic-bezier(.4,0,.2,1), y 0.6s cubic-bezier(.4,0,.2,1), fill 0.4s;
}
#therm-bulb-fill {
  transition: fill 0.4s;
}
.mode-ill img { 
  height: 180px; /* Significantly increased to match the reference */
  object-fit: contain; 
  margin: 0 auto; 
}

.sys-modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 8px;
}

.sys-modal-desc {
  font-size: 13px;
  color: var(--text-sub);
  text-align: center;
  line-height: 1.4;
  margin-bottom: 24px;
}

.sys-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-primary {
  background: #d5d4d0;
  color: var(--text);
  padding: 14px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  width: 100%;
  transition: var(--t);
  border: solid black 1px;
}

.btn-primary:hover {
  background: #c4c3bf;
}

.btn-secondary {
  background: transparent;
  border: 1px solid #d5d4d0;
  color: var(--text-sub);
  padding: 14px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  width: 100%;
  transition: var(--t);
}

.btn-secondary:hover {
  background: #f0f0f0;
}

/* Sensor Detail UI */

.sens-modal-header { display: flex; align-items: center; justify-content: space-between; }
.sm-head-left { display: flex; align-items: center; gap: 8px; }
.sm-title { font-size: 18px; font-weight: 700; color: var(--text); }
.sm-divider { 
  border: none; 
  border-bottom: 2px solid #c0c0c0; /* Distinct grey separator */
  margin-top: 16px; 
  margin-bottom: 20px; 
}

.sm-subtitle { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 10px; }

.sm-reading-card {
  border: 1px solid #111; /* Neo-brutalist */
  border-radius: 16px; padding: 16px 20px;
  display: flex; justify-content: space-between; align-items: center;
  background: #fff; margin-bottom: 24px;
}
.sm-rc-left { display: flex; flex-direction: column; gap: 8px; }
.sm-val-lrg { font-size: 42px; font-weight: 400; color: var(--text); line-height: 1; }
.sm-unit { font-size: 18px; color: #9aa3a0; margin-left: 4px; }
.sm-status-ind { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #9aa3a0; font-weight: 500; }
.sm-status-ind .dot { width: 8px; height: 8px; border-radius: 50%; background: #e0b25e; }
.sm-rc-right { width: 80px; height: 80px; display: flex; align-items: center; justify-content: center; }
.sm-worm-clipart { width: 100%; height: 100%; object-fit: contain; }

/* Pill Shaped Actuator Controls */
.sm-actuator-grid { display: flex; flex-direction: column; gap: 12px; }
.sm-act-box {
  background: #ffffff; border: 1.5px solid #eaeaea; border-radius: 30px; /* Full pill shape */
  padding: 8px 16px 8px 8px; display: flex; flex-direction: row; align-items: center; justify-content: space-between; width: 100%;
}
.sm-act-left { display: flex; align-items: center; gap: 12px; }

.sm-act-icon-bg img { 
  width: 30px; 
  height: 30px; 
  object-fit: contain; 
}
.sm-act-name { font-size: 14px; font-weight: 600; color: var(--text); }
 

.btn-cancel { background: #666666; color: #ffffff; padding: 14px; border-radius: 30px; font-weight: 600; font-size: 15px; width: 100%; transition: var(--t); border: none; }
.btn-cancel:hover { background: #555555; }
/* ════════════════════════════════════════════
   DASHBOARD
   ════════════════════════════════════════════ */
 /* ── Dashboard Landing Layout ── */
/* ── Dashboard Landing Layout ── */
.dash-layout {
  display: flex;
  flex-direction: row;
  gap: 0;
  align-items: center;
  flex: 1;
  height: 100%;
}

.dash-left {
  flex: 0 0 55%;
  width: 55%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  /* padding: 24px 0 24px 24px; */
}

.dash-welcome {
  font-size: 15px;
  color: var(--text);
  opacity: 0.75;
  text-align: center;
  align-self: center;
  padding-left: 12px;
}

.dash-main-clipart {
  width: 444px;
  height: 298px;
  object-fit: contain;
}

.dash-right {
  flex: 0 0 45%;
  width: 45%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 24px 24px 0;
  justify-content: center;
}

.dash-select-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  opacity: 0.55;
  text-align: center;
  margin-bottom: -4px;
  letter-spacing: 0.2px;
  width: 100%;
}

/* Horizontal card */
.dash-card-row {
  background: #B4ED83;
  border-radius: 16px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 20px;
  width: 427.91px;
  height: 159.51px;
  padding: 40px 48px;
  box-sizing: border-box;
  cursor: pointer;
  transition: transform var(--t), box-shadow var(--t), border var(--t);
  -webkit-tap-highlight-color: transparent;
  border: solid 1px;
}

.dash-card-row:hover {
  border: 1.53373px solid #000000;
  box-shadow: 3px 5px 0px #000000;
  transform: none;
}

.dash-card-row:active {
  transform: scale(.98);
}

.dash-row-icon {
  width: 80px;
  height: 80px;
  object-fit: contain;
  flex-shrink: 0;
}

.dash-row-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dash-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.dash-desc {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  opacity: 0.7;
  max-width: 220px;
}

.dash-row-text {
  display: flex;
  flex-direction: column;
  width: 200px;
}

/* ════════════════════════════════════════════
   SUB-PAGES (Quick Insights / Bin Fluctuation)
   ════════════════════════════════════════════ */
.sub-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  flex-shrink: 0;
}

/* Legacy – keep for safety */
.sub-layout { display: flex; gap: 16px; flex: 1; min-height: 0; align-items: flex-start; }
.sub-left   { width: 140px; flex-shrink: 0; display: flex; flex-direction: column; gap: 8px; }
.sub-right  { flex: 1; min-width: 0; overflow-y: auto; }

/* ════════════════════════════════════════════
   QUICK INSIGHTS — BF-mirrored layout
   ════════════════════════════════════════════ */
#page-quick-insights .qi-page-body {
  overflow: visible;
  padding: 0;
  gap: 0;
}

#page-quick-insights .bin-crumb {
  margin: 0;
  border-radius: var(--r) var(--r) 0 0;
  flex-shrink: 0;
  padding: 16px 28px;
  background: #e2e2e2;
  border-bottom: 1px solid #111;
}

.qi-layout {
  display: flex;
  gap: 14px;
  flex: 1;
  min-height: 0;
  align-items: stretch;
  padding: 20px 28px 20px;
  overflow: auto;
}

/* LEFT SIDEBAR */
.qi-sidebar {
  width: 130px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qi-sidebar-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
}

.qi-sens-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 8px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text-sub);
  cursor: pointer;
  transition: var(--t);
  flex: 1;
}
.qi-sens-btn:hover { border-color: var(--green-mid); color: var(--green-mid); }
.qi-sens-btn.active { background: var(--sidebar); border-color: var(--sidebar); color: #fff; }
.qi-sens-btn img { width: 28px; height: 28px; }
.qi-sens-btn.active img { filter: brightness(0) invert(1); }

/* RIGHT PANEL */
.qi-panel {
  flex: 1;
  min-width: 0;
  background: white;
  border-radius: 16px;
  border: 1px solid var(--border);
  overflow: auto;
  display: flex;
  flex-direction: column;
  min-height: 400px;
}

/* Top bar */
.qi-panel-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.qi-date-info {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  line-height: 1.7;
  white-space: pre-line;
}

/* Stats Container (Desktop 4-columns) */
.qi-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 16px; /* 🚨 Changed to 16px to perfectly match the table margin! */
  gap: 16px; 
  background: transparent;
  border-bottom: none;
  flex-shrink: 0;
}
/* Floating White Card for Insights */
.qi-insight-bottom {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  margin: 0 16px 24px 16px; /* Aligns perfectly with the table */
  padding: 16px 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  flex-shrink: 0;
}

/* Fix text size for the Insight box */
.qi-insight-bottom .qi-val {
  font-size: 13px !important;
  font-weight: 500;
  line-height: 1.5;
  margin-top: 4px;
}
.qi-insight-bottom .qi-ins-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.qi-stat-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  margin: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.qi-stat-box:last-child { border-right: none; }

.qi-ins-box-inline {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.qi-ins-box-inline .qi-val {
  font-size: 12px !important;
  line-height: 1.5;
  font-weight: 500;
}

.qi-ins-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: transparent;
  margin-left: 4px;
  vertical-align: middle;
  transition: background .3s;
}
.qi-ins-dot.warn   { background: var(--warn, #f59e0b); }
.qi-ins-dot.danger { background: var(--danger, #ef4444); }
.qi-ins-dot.ok     { background: var(--green-mid, #3a6b35); }

.bin-dd {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234a5c44' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.sens-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 10px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
  background: #fff;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--t);
  width: 100%;
}

.sens-btn:hover {
  border-color: var(--green-mid);
  color: var(--green-mid);
}

.sens-btn.active {
  background: var(--sidebar);
  border-color: var(--sidebar);
  color: #fff;
}

.qi-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .02);
}

.qi-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
  gap: 8px;
  flex-wrap: wrap;
}

.qi-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.qi-date {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  line-height: 1.7;
  white-space: pre-line;
}

.qi-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.qi-stat {
  background: var(--card);
  border-radius: var(--r-sm);
  padding: 14px 12px;
  border: 1px solid var(--border);
}

.qi-lbl {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 6px;
}

.qi-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.qi-val .u {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

.qi-ins .qi-val {
  font-size: 12px;
  line-height: 1.5;
  margin-top: 4px;
  font-weight: 500;
}

/* Insight stat box — header row with label + wrench */
.qi-ins-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.qi-action-btn {
  width: 30px !important;
  height: 30px !important;
  border-radius: 8px !important;
  flex-shrink: 0;
}

/* White Floating Card for the Table */
.qi-tbl-wrap {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  margin: 0 16px 16px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  /* 🚨 The magic below makes it stretch to fill space & pushes Insights to the bottom */
  flex: 1; 
  min-height: 240px;
  overflow-y: auto; 
}
.qi-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.qi-tbl thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.qi-tbl th {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: white;
  border-bottom: 1px solid var(--border);
  background: rgb(51, 51, 51);
  text-align: left;
  /* Sticky header shadow line */
  box-shadow: 0 1px 0 var(--border);
  text-align: center;
}

.qi-tbl td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-align: center;
}

.qi-tbl tr:last-child td {
  border-bottom: none;
}

.qi-tbl tr:nth-child(even) td {
  background: var(--card);
}

.s-ok { color: var(--green-mid); font-weight: 600; }
.s-hi { color: var(--danger); font-weight: 600; }
.s-lo { color: var(--warn); font-weight: 600; }

.qi-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 16px;
}

/* ════════════════════════════════════════════
   RECENT QUICK INSIGHTS CARD (home page)
   ════════════════════════════════════════════ */
.recent-qi-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0;
  overflow: hidden;
  margin-bottom: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.03);
}

.rqi-row {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  gap: 14px;
  flex-wrap: wrap;
}

.rqi-bin-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  min-width: 38px;
  flex-shrink: 0;
}

.rqi-sensors {
  display: flex;
  gap: 8px;
  flex: 1;
  flex-wrap: wrap;
}

.rqi-sensor-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--text);
}

.rqi-sensor-pill img { width: 14px; height: 14px; opacity: .75; }

.rqi-pill-val { font-weight: 700; }
.rqi-pill-unit { color: var(--text-muted); font-size: 11px; }

.rqi-pill-status {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 2px;
}
.rqi-pill-status.ok     { background: #e6f4e6; color: var(--green-mid, #3a6b35); }
.rqi-pill-status.warn   { background: #fef3cd; color: #92690a; }
.rqi-pill-status.danger { background: #fde8e8; color: #c0392b; }

.rqi-divider {
  height: 1px;
  background: var(--border);
  margin: 0 18px;
}

.rqi-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  background: var(--card);
  border-top: 1px solid var(--border);
}

.rqi-footer span {
  font-size: 11px;
  color: var(--text-muted);
}

.rqi-link {
  font-size: 11px;
  font-weight: 600;
  color: var(--green-mid, #3a6b35);
  text-decoration: none;
}
.rqi-link:hover { text-decoration: underline; }

#page-bin-fluctuation .page-body {
  overflow: visible;
  padding: 0;
  gap: 0;
  min-height: 0;
}

#page-bin-fluctuation .bin-crumb {
  margin: 0;
  border-radius: var(--r) var(--r) 0 0;
  flex-shrink: 0;
  padding: 16px 28px;
  background: #e2e2e2;
  border-bottom: 1px solid #111;
}

/* ════════════════════════════════════════════
   BIN FLUCTUATION — Layout
   ════════════════════════════════════════════ */
.bf-layout {
  display: flex;
  gap: 14px;
  flex: 1;
  min-height: 0;
  align-items: stretch;
  padding: 20px 28px 20px;
  overflow: auto;
}

/* LEFT SIDEBAR */
.bf-sidebar {
  width: 130px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bf-sidebar-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
}

/* Mobile date row inside sidebar — hidden on desktop */
.bf-sidebar-date {
  display: none;
}

.bf-sens-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 8px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text-sub);
  cursor: pointer;
  transition: var(--t);
  flex: 1;
}

.bf-sens-btn:hover {
  border-color: var(--green-mid);
  color: var(--green-mid);
}

.bf-sens-btn.active {
  background: var(--sidebar);
  border-color: var(--sidebar);
  color: #fff;
}

.bf-sens-btn img {
  width: 28px;
  height: 28px;
}

.bf-sens-btn.active img {
  filter: brightness(0) invert(1);
}

/* RIGHT PANEL */
.bf-panel {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border-radius: 16px;
  border: 1px solid var(--border);
  overflow: auto;
  display: flex;
  flex-direction: column;
  min-height: 400px;
}

/* Top bar */
.bf-panel-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: rgb(238, 238, 238);
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--bg);
 
}

.bf-sensor-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bf-sensor-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.date-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-right: 2px;
}

.date-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-sub);
}

.date-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 10px;
}

.date-in {
  border: none;
  background: transparent;
  font-size: 11px;
  color: var(--text);
  outline: none;
  width: 96px;
}

/* Mid section */
.bf-mid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--border-inner);
  flex-shrink: 0;
}

.bf-avg-box {
  padding: 18px 20px;
  border-right: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  background: white;
}

.bf-avg-lbl {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.bf-avg-valrow {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.bf-avg-num {
  font-size: 48px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.bf-avg-unit {
  font-size: 18px;
  color: var(--text-muted);
}

 
/* Worm image — large, right-aligned, comfortable spacing */
.bf-worm {
  position: absolute;
  right: 20px;  /* Pushed in from the right to match box padding */
  bottom: 12px; /* Lifted up from the bottom */
  width: 95px;  /* Slightly scaled to fit beautifully */
  height: 95px;
  object-fit: contain;
  pointer-events: none;
}

/* Insights box */
.bf-ins-box {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: white;
}

.bf-ins-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bf-ins-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.bf-ins-text {
  font-size: 12px;
  color: var(--text-sub);
  line-height: 1.6;
}

/* Action button (wrench) */
.bf-action-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--t);
  flex-shrink: 0;
}

.bf-action-btn:not(:disabled):hover {
  border-color: var(--danger);
  background: #fff0f0;
}

.bf-action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.bf-action-btn img {
  width: 18px;
  height: 18px;
}

.bf-wrench-fallback {
  font-size: 16px;
}

/* Red blinking dot — only visible when action needed */
.bf-action-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  display: none;
  animation: blink-dot 1.2s ease-in-out infinite;
}

.bf-action-dot.visible {
  display: block;
}

@keyframes blink-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.7); }
}

/* Scrollable chart — height set by JS via ResizeObserver */
.chart-scroll-wrap {
  flex: 1;
  min-height: 0;
  background: var(--card);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  position: relative;
  background: rgb(245, 245, 245);
}

.chart-scroll-inner {
  position: absolute;
  top: 12px;
  left: 16px;
  right: 0;
  bottom: 8px;
  min-width: calc(100% - 32px);
  width: max-content;
}

.chart-scroll-inner canvas {
  height: 100% !important;
  width: 100% !important;
  display: block;
}

/* ════════════════════════════════════════════
   AUTH SCREEN  — Split layout
   ════════════════════════════════════════════ */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: #3d7a4e;
  z-index: 10000;
  display: none;
  align-items: stretch;
  justify-content: center;
}

.auth-overlay.visible {
  display: flex;
}

/* ── LEFT ILLUSTRATION PANEL ── */
.auth-illus {
background: linear-gradient(180deg, #2A4633 0%, #67AC7D 100%);
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  position: relative;
  overflow: hidden;
}

.auth-illus-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  z-index: 1;
}

 
@keyframes blobMorph {
  0%, 100% { border-radius: 62% 38% 55% 45% / 48% 52% 48% 52%; }
  50%       { border-radius: 45% 55% 40% 60% / 55% 45% 60% 40%; }
}

.auth-illus-main {
  position: relative;
  width: min(680px, 85vh);
  height: min(640px, 80vh);
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-illus-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 8px 24px rgba(255, 255, 255, 0.25));
  animation: floatBob 4s ease-in-out infinite;
}

@keyframes floatBob {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-10px); }
}

.auth-illus-tag {
  font-size: 18px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  text-align: center;
  line-height: 1.5;
  text-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 1;
}

/* ── RIGHT FORM PANEL ── */
.auth-card {
  width: 100%;
  max-width: 420px;
  background: #f5f3ee;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 36px;
  gap: 0;
  overflow-y: auto;
  position: relative;
}

/* Language toggle in topbar */
.tb-lang-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted, #888);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  transition: color var(--t), background var(--t);
  flex-shrink: 0;
}

.tb-lang-btn:hover {
  color: var(--text, #1a1a1a);
  background: rgba(0,0,0,0.06);
}

.tb-lang-btn svg {
  flex-shrink: 0;
}
.auth-back-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  position: absolute;
  top: 28px;
  left: 32px;
}

.auth-back-label {
  font-size: 13px;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  transition: color 0.2s;
  user-select: none;
}

.auth-back-row:hover .auth-back-label {
  color: #1E3A28;
}

.auth-back-row:hover .back-btn {
  transform: scale(0.95);
}

.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
}

.auth-logo-img {
  height: 28px;
  width: auto;
  
}

/* Keyhole icon */
.auth-keyhole-wrap {
  display: flex;
  justify-content: center;
  margin: 16px 0 12px;
}

.auth-keyhole-placeholder {
  width: 72px;
  height: 72px;
  background: #f5c518;
  border: 2px solid #111;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  box-shadow: 3px 3px 0 #111;
}

/* Heading */
.auth-heading {
  text-align: center;
  margin-bottom: 20px;
}

/* ── Phase 3: Empty State ────────────────────────────────── */
#av-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 64px 24px 56px;
  margin: 0 auto;
  max-width: 400px;
}

.av-es-icon {
  width: 80px;
  height: 80px;
  border-radius: 18px;
  border: 2.5px solid black;
  box-shadow: 4px 4px 0 black;
  background: var(--green-pale);
  color: var(--topbar);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
}

.av-es-title {
  font-family: 'Quicksand', sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 12px;
}

.av-es-body {
  font-size: 14px;
  color: var(--text-sub);
  line-height: 1.7;
  margin: 0 0 28px;
}

.av-es-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 32px;
  background: var(--yellow);
  color: #1a1a1a;
  font-family: 'Quicksand', sans-serif;
  font-size: 14px;
  font-weight: 800;
  border: 2.5px solid black;
  border-radius: 10px;
  box-shadow: 4px 4px 0 black;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  margin-bottom: 14px;
  letter-spacing: 0.02em;
}

.av-es-cta:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 black;
}

.av-es-cta:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 black;
}

.av-es-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

/* ── Phase 1: Auth Tabs — removed, redundant with inline switch links ── */

.auth-title {
  font-size: 22px;
  font-weight: 700;
  color: #111;
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 13px;
  color: #777;
}

/* Tabs — removed (redundant with inline switch links) */

/* Banner */
.auth-banner {
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  width: 100%;
  margin-bottom: 10px;
}

.auth-banner--err {
  background: #fff4f4;
  border: 1px solid #fca5a5;
  color: var(--danger);
}

.auth-banner--ok {
  background: var(--green-pale);
  border: 1px solid var(--green-card-b);
  color: var(--green-mid);
}

/* Form */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.auth-desc {
  font-size: 13px;
  color: #666;
  line-height: 1.6;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.auth-hint { font-weight: 400; color: #aaa; }

/* Input with icon */
.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-icon {
  position: absolute;
  left: 12px;
  font-size: 14px;
  opacity: 0.5;
  pointer-events: none;
  z-index: 1;
}

.auth-input {
  width: 100%;
  padding: 11px 12px 11px 36px;
  border-radius: 10px;
  border: 1.5px solid #ddd;
  background: #fff;
  font-size: 14px;
  color: #111;
  outline: none;
  transition: var(--t);
  font-family: 'Quicksand', sans-serif;
}

.auth-input--padded { padding-right: 40px; }

.auth-input:focus {
  border-color: var(--green-accent);
  box-shadow: 0 0 0 3px rgba(106,171,122,0.15);
}

.auth-pw-eye {
  position: absolute;
  right: 10px;
  font-size: 14px;
  cursor: pointer;
  opacity: 0.4;
  padding: 4px;
  z-index: 1;
}
.auth-pw-eye:hover { opacity: 0.8; }

/* Forgot link — right aligned */
.auth-forgot-link {
  font-size: 12px;
  color: #888;
  text-align: right;
  cursor: pointer;
  padding: 2px 0;
  transition: var(--t);
  align-self: flex-end;
}
.auth-forgot-link:hover { color: var(--green-mid); }

/* Submit button */
.auth-submit {
  width: 100%;
  padding: 13px;
  border-radius: 10px;
  background: #2e4f39;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--t);
  margin-top: 4px;
  font-family: 'Quicksand', sans-serif;
  letter-spacing: 0.3px;
}

.auth-submit:hover  { background: var(--green-mid); }
.auth-submit:active { transform: scale(0.98); }
.auth-submit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Switch text */
.auth-switch-text {
  font-size: 13px;
  color: #888;
  text-align: center;
}

.auth-switch-link {
  font-weight: 700;
  color: #111;
  cursor: pointer;
  transition: var(--t);
}
.auth-switch-link:hover { color: var(--green-mid); }

.auth-link {
  font-size: 12px;
  color: #888;
  text-align: center;
  cursor: pointer;
  padding: 4px;
  transition: var(--t);
}
.auth-link:hover { color: var(--green-mid); }

/* Dev bypass */
.auth-dev-bypass {
  border-top: 1px dashed #ccc;
  padding-top: 12px;
  margin-top: 8px;
  display: flex;
  justify-content: center;
  width: 100%;
}

.auth-dev-bypass button {
  font-size: 11px;
  font-weight: 600;
  color: #aaa;
  background: none;
  border: 1px dashed #ccc;
  border-radius: 6px;
  padding: 5px 14px;
  cursor: pointer;
  transition: var(--t);
  font-family: 'Quicksand', sans-serif;
}

.auth-dev-bypass button:hover {
  background: #fff8f0;
  border-color: #F4A261;
  color: #c47a3a;
}

/* ── MOBILE: stack vertically, hide illustration ── */
@media (max-width: 768px) {

  .auth-overlay {
    flex-direction: column;
    background: #f5f3ee;
    overflow-y: auto;
  }

  .auth-illus {
    display: none;
  }

  .auth-card {
    max-width: 100%;
    padding: 72px 24px 40px;
    border-radius: 0;
    justify-content: flex-start;
  }
 .auth-back-row {
    position: fixed;
    top: 16px;
    left: 16px;
    width: auto;
    margin-bottom: 0;
    z-index: 10001;
  }

  .auth-back-label {
    display: none;
  }

  .auth-keyhole-wrap { margin: 12px 0 8px; }
  .auth-keyhole-placeholder { width: 56px; height: 56px; font-size: 22px; }
  .auth-title { font-size: 20px; }

.dash-main-clipart { width: 260px; height: auto; }
}

@media (max-width: 480px) {
  .auth-card { padding: 20px 18px 40px; }
}

/* ── Settings danger buttons ── */
.settings-danger-btn {
  padding: 5px 14px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--t);
  background: #fff3f3;
  border: 1px solid #fca5a5;
  color: var(--danger);
}

.settings-danger-btn:hover { background: #fee2e2; }

.settings-danger-btn--hard {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.settings-danger-btn--hard:hover { background: #dc2626; }
.settings-col {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ════════════════════════════════════════════
   SETTINGS
   ════════════════════════════════════════════ */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr; /* Mobile first: single column */
  gap: 24px;
  width: 100%;
  max-width: 1200px; /* Prevents it from getting absurdly wide on 4k screens */
  margin: 0 auto;
  align-items: start;
}

/* ── Resource Manual Buttons ── */
.resource-manual-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--green-pale, #eef5ed);
  border: 1px solid var(--green-card-b, #b5d9be);
  border-radius: 12px;
  padding: 13px 16px;
  text-decoration: none;
  color: var(--text, #1a1a1a);
  transition: background var(--t, .18s), border-color var(--t, .18s),
              box-shadow var(--t, .18s), transform var(--t, .18s);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
 
.resource-manual-btn:hover {
  background: #ddf0dc;
  border-color: var(--green-accent, #6aab7a);
  box-shadow: 0 2px 8px rgba(106,171,122,.18);
  transform: translateY(-1px);
}
 
.resource-manual-btn:active {
  transform: scale(.98);
  box-shadow: none;
}
 
.resource-manual-icon-wrap {
  width: 28px;
  height: 28px;
  background: transparent;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
 
.resource-manual-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
  opacity: 0.85;
}
 
.resource-manual-label {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text, #1a1a1a);
  line-height: 1.3;
}
 
.resource-manual-lang {
  font-weight: 400;
  color: var(--green-mid, #3d6b4c);
}
 
.resource-manual-chevron {
  color: var(--green-mid, #3d6b4c);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
 
/* ── Language Selector ── */
.resource-lang-select-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: #fff;
  border: 1.5px solid var(--border, #e0e0e0);
  border-radius: 12px;
  padding: 0 14px;
  height: 50px;
  cursor: pointer;
  transition: border-color var(--t, .18s), box-shadow var(--t, .18s);
}
 
.resource-lang-select-wrap:focus-within {
  border-color: var(--green-accent, #6aab7a);
  box-shadow: 0 0 0 3px rgba(106,171,122,.15);
}
 
.resource-lang-select-wrap:focus-within {
  border-color: var(--green-accent, #6aab7a);
  box-shadow: 0 0 0 3px rgba(106,171,122,.15);
}
 
.resource-lang-globe {
  color: var(--green-mid, #3d6b4c);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-right: 10px;
}
 
.resource-lang-select {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--text, #1a1a1a);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  outline: none;
  padding: 0;
  height: 100%;
}
 
.resource-lang-chevron {
  color: var(--text-muted, #888);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  cursor: pointer;
  padding: 4px;
  margin-right: -4px;
}


/* Desktop: Switch to 2 columns */
@media (min-width: 900px) {
  .settings-grid {
   grid-template-columns: minmax(min(400px, 100%), 630px) 1fr;
  }
}

.settings-sec {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
}

.settings-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
  transition: box-shadow var(--t);
}

.settings-sec-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-inner);
}


/* Hide the mobile logout card by default (on Desktop/Tablet) */
.mobile-logout-card {
  display: none;
}

.dev-row-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.dev-ic {
  width: 56px;
  height: 56px;
  border-radius: var(--r-sm);
  background: var(--green-pale);
  border: 1px solid var(--green-card-b);
  display: flex;
  align-items: center;
  justify-content: center;
}

.dev-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.dev-id {
  font-size: 12px;
  color: var(--text-muted);
  font-family: monospace;
  margin-top: 3px;
}

.dev-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-top: none;
  border-bottom: 1px solid var(--border-inner);
  font-size: 13px;
}

.dev-key {
  color: var(--text-muted);
}

.dev-val {
  color: var(--text);
  font-weight: 500;
}

.dev-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.dev-badge::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}

.dev-badge.online::before {
  background: var(--green-mid);
}


/* Remove bottom border on the last item to keep the card clean */
.dev-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.dev-row:first-of-type {
  padding-top: 0;
}
/* ════════════════════════════════════════════
   WIFI MANAGER
   ════════════════════════════════════════════ */
.wm-sec-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: none; 
  padding-bottom: 0;
}

.wm-scan-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 8px;
  background: var(--green-pale);
  border: 1px solid var(--green-card-b);
  color: var(--green-mid);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--t);
}

.wm-scan-btn:hover { background: var(--green-card-b); }
.wm-scan-btn:active { transform: scale(0.96); }

.wm-scan-icon {
  display: inline-block;
  font-size: 14px;
  transition: transform 0.5s ease;
}

.wm-scan-icon.spinning {
  animation: wmSpin 0.7s linear infinite;
}

@keyframes wmSpin {
  to { transform: rotate(360deg); }
}

/* ── Current status bar ── */
.wm-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--inner-bg);
  border: 1px solid var(--border-inner);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
}

.wm-status-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.wm-signal-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--green-pale);
  border: 1px solid var(--green-card-b);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--green-mid);
}

.wm-signal-icon svg {
  width: 18px;
  height: 18px;
}

.wm-ssid {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.wm-ip {
  font-size: 11px;
  color: var(--text-muted);
  font-family: monospace;
  margin-top: 2px;
}

.wm-status-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.wm-btn-disconnect {
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--t);
  background: #fff3f3;
  border: 1px solid #fca5a5;
  color: var(--danger);
}

.wm-btn-disconnect:hover { background: #fee2e2; }

.wm-btn-forget {
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--t);
  background: var(--inner-bg);
  border: 1px solid var(--border);
  color: var(--text-sub);
}

.wm-btn-forget:hover { background: var(--border); }

/* ── Network list ── */
.wm-net-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
}

.wm-placeholder {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 20px 0;
}

.wm-net-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--border-inner);
  background: var(--inner-bg);
  cursor: pointer;
  transition: var(--t);
  -webkit-tap-highlight-color: transparent;
}

.wm-net-item:hover { background: var(--green-pale); border-color: var(--green-card-b); }
.wm-net-item:active { transform: scale(0.98); }

.wm-net-item.is-connected {
  border-color: var(--green-card-b);
  background: var(--green-pale);
  cursor: default;
}

.wm-net-item.is-connected:hover { background: var(--green-pale); }

.wm-net-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.wm-net-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.wm-net-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.wm-net-enc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.wm-net-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.wm-rssi-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
}

.wm-rssi-bars span {
  width: 3px;
  border-radius: 1px;
  background: var(--border);
}

.wm-rssi-bars span.active { background: var(--green-mid); }

.wm-connected-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--green-mid);
  background: var(--green-card-b);
  padding: 2px 8px;
  border-radius: 20px;
}

/* ── Connect form ── */
.wm-connect-form {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--inner-bg);
  overflow: hidden;
}

.wm-cf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-inner);
  background: var(--card);
}

.wm-cf-ssid {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.wm-cf-close {
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 5px;
}

.wm-cf-close:hover { background: var(--border); }

.wm-cf-body {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
}

.wm-pw-input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: var(--t);
}

.wm-pw-input:focus { border-color: var(--green-accent); }

.wm-connect-submit {
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--sidebar);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--t);
  white-space: nowrap;
}

.wm-connect-submit:hover { background: var(--green-mid); }
.wm-connect-submit:active { transform: scale(0.96); }
.wm-connect-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* ════════════════════════════════════════════
   TOAST
   ════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}

.toast {
  padding: 10px 18px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  background: var(--text);
  color: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .15);
  animation: tIn .2s ease, tOut .3s ease 2.7s forwards;
  max-width: 280px;
}

.toast.ok { background: var(--sidebar); }
.toast.err { background: var(--danger); }

@keyframes tIn {
  from { transform: translateX(16px); opacity: 0; }
}

@keyframes tOut {
  to { transform: translateX(8px); opacity: 0; }
}

/* ════════════════════════════════════════════
   BOTTOM NAV  (mobile only)
   ════════════════════════════════════════════ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #282828;
  height: calc(56px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid rgba(255, 255, 255, .06);
  z-index: 100;
  align-items: center;
  justify-content: space-around;
}

.bnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
  cursor: pointer;
  border-top: 2px solid transparent;
  transition: var(--t);
  -webkit-tap-highlight-color: transparent;
}

.bnav-item.active .bnav-ic { opacity: 1; }
.bnav-item.active { border-top-color: var(--green-accent); }
.bnav-item:active { background: rgba(255, 255, 255, .04); }

/* ════════════════════════════════════════════
   RESPONSIVE  —  LARGE DESKTOP  ≥ 1440px
   ════════════════════════════════════════════ */
@media (min-width: 1440px) {
  :root { --sb-w: 76px; --tb-h: 60px; --gap: 32px; }
  .page { max-width: 1140px; }
  .page-body { padding: 48px 56px; }
  .home-title { font-size: 32px; }
  .bin-name { font-size: 54px; }
  .bins-grid { gap: 32px; }

}

@media (min-width: 1920px) {
  :root { --sb-w: 80px; --tb-h: 64px; --gap: 40px; }
  .page { max-width: 1240px; }
  .page-body { padding: 56px 64px; }
}

/* ════════════════════════════════════════════
   RESPONSIVE  —  TABLET  ≤ 1024px
   ════════════════════════════════════════════ */
@media (max-width: 1024px) {

  .bins-grid{
    height: 500px;
  }
  /* Old QI classes kept for compat */
  .qi-stats { grid-template-columns: 1fr 1fr; }
  .qi-ins { grid-column: span 2; }

  /* ── New QI Layout — mirrors BF mobile ── */
  .qi-layout { flex-direction: column; padding: 0; gap: 0; overflow-y: auto; }
  #page-quick-insights .qi-page-body { overflow: auto; padding: 0; }
  #page-quick-insights .bin-crumb { margin: 0; border-radius: 16px 16px 0 0; }

  .qi-sidebar {
    width: 100%;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px 16px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    border-radius: 0;
  }
  .qi-sidebar::before {
    content: 'Selection:';
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: .4px;
    display: block;
    margin-bottom: -2px;
  }
  .qi-sidebar .bin-dd { width: 100%; }

  .qi-sidebar-btns { flex-direction: row !important; gap: 8px; flex: none !important; }

  .qi-sens-btn {
    flex-direction: column;
    flex: 1;
    padding: 10px 4px;
    gap: 0;
    justify-content: center;
    align-items: center;
    min-width: 0;
    border-radius: 12px;
    font-size: 0;
  }
  .qi-sens-btn span { display: none; }
  .qi-sens-btn img { width: 22px; height: 22px; }

 .qi-panel {
    border-radius: 0;
    border: none;
    background: #ffffff; /* 1. pure white background */
    display: flex;
    flex-direction: column;
  }
  
  .qi-panel-top {
    padding: 12px 16px;
    background: #ffffff; /* pure white background */
 
    border-bottom: none; /* removes the line above the cards for a seamless look */
  }

 /* Base Stats Container */
/* Stats Container - Perfect 2x2 Grid */
  .qi-stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: transparent;
    padding: 0 16px 16px 16px;
    gap: 12px;
    border-bottom: none;
  }
  /* Individual White Stat Cards */
  .qi-stat-box {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    margin: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    
    /* 🚨 This kills any lingering row-spanning bugs 🚨 */
    order: unset !important;
    grid-column: span 1 !important;
    align-items: flex-start !important;
    text-align: left !important;
  }

  /* Remove any lingering nth-child order rules, they are no longer needed! */
  .qi-stat-box:nth-child(1), .qi-stat-box:nth-child(2), .qi-stat-box:nth-child(3), .qi-stat-box:nth-child(4) {
    order: unset;
    grid-column: span 1;
    align-items: flex-start;
    text-align: left;
  }


  /* Reorder boxes to fill empty space perfectly */
  .qi-stat-box:nth-child(1) { order: 1; } /* Min stays top left */
  .qi-stat-box:nth-child(3) { order: 2; } /* Max moves to top right */
  
  /* Average spans full width on the bottom row */
  .qi-stat-box:nth-child(2) { 
    order: 3; 
    grid-column: span 2; 
    align-items: center; 
    text-align: center;
  }
  
  /* Individual White Stat Cards */
  .qi-stat-box {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 14px;
    margin: 0; 
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
  }

  /* White Floating Card for the Table */
  .qi-tbl-wrap {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    flex: none;
    height: 240px; 
    margin: 0 16px 16px 16px; /* Exactly 16px left/right */
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  }

  /* Improved Insight Box at the Bottom */
  .qi-insight-bottom {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 14px;
    margin: 0 10px 24px 10px;
    padding: 18px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  /* Make the Insight text pop a bit more on mobile */
  .qi-insight-bottom .qi-ins-val {
    font-size: 14px !important;
    font-weight: 600;
    color: var(--text);
    margin-top: 6px;
  }
  
  .qi-stat-box {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 14px;
    margin: 0; /* 3. Removed the erratic margin causing the squishing */
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    margin: 5px;
  }
  
  .qi-stat-box:last-child { 
    border-right: 1px solid var(--border); /* Restores the missing border */
  }
  .qi-stats-row { border-bottom: none; display: grid; grid-template-columns: 1fr 1fr; padding: 4px 4px 0; gap: 0; }

 .qi-tbl-wrap {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    flex: none;
    max-height: 260px;
    overflow-y: auto;
    margin: 8px 10px 10px 10px; /* This creates the separation from the edges */
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  }

  /* ══ BF MOBILE — matches reference image ══ */
  .bf-layout { flex-direction: column; padding: 0; gap: 0; overflow-y: auto; }
  #page-bin-fluctuation .page-body { overflow: auto; padding: 0; }
  #page-bin-fluctuation .bin-crumb { margin: 0; border-radius: 16px 16px 0 0; }

  /* SELECTION CARD — white bg, "Selection:" pseudo-label */
  .bf-sidebar {
    width: 100%;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px 16px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    border-radius: 0;
  }

  .bf-sidebar::before {
    content: 'Selection:';
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: .4px;
    display: block;
    margin-bottom: -2px;
  }

  .bf-sidebar .bin-dd { width: 100%; }

  /* 4-icon sensor row */
  .bf-sidebar-btns { flex-direction: row !important; gap: 8px; flex: none !important; }

  .bf-sens-btn {
    flex-direction: column;
    flex: 1;
    padding: 10px 4px;
    gap: 0;
    justify-content: center;
    align-items: center;
    min-width: 0;
    border-radius: 12px;
    font-size: 0;
  }
  .bf-sens-btn span { display: none; }
  .bf-sens-btn img { width: 22px; height: 22px; }

  /* Date block inside sidebar */
  .bf-sidebar-date {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
  .bf-sidebar-date .date-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: .4px;
  }
  .bf-sidebar-date .date-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgb(243, 243, 243);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    width: 100%;
  }
  .bf-sidebar-date .date-in { width: auto; flex: 1; font-size: 12px; }

  /* SENSOR NAME BAR — grey strip */
 .bf-panel {
    border-radius: 0;
    border: none;
    background: var(--bg);
    display: flex;
    flex-direction: column;
  }
  .bf-panel-top {
    order: 1;
    padding: 12px 16px;
    background: rgb(238, 238, 238); /* 🚨 Lighter grey from desktop */
    border-bottom: 1px solid var(--border);
    margin: 0;
  }
  .bf-panel-top .date-row { display: none; }

  /* CHART — full width, below name bar */
  .chart-scroll-wrap {
    order: 2;
    flex: none;
    height: 200px;
    min-height: 200px;
    background: rgb(245, 245, 245); /* 🚨 Lightest grey from desktop */
    border-bottom: 1px solid var(--border);
  }

  /* AVG + WORM — white rounded card */
  .bf-mid {
    order: 3;
    grid-template-columns: 1fr;
    background: rgb(245, 245, 245);
    padding: 16px 16px 0 16px; /* Spaced to match Quick Insights */
    gap: 12px;
  }
  .bf-avg-box {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px 20px;
    min-height: 110px;
  }
  
  .bf-avg-lbl { font-size: 15px; color: var(--text-sub); font-weight: 400; margin-bottom: 4px; }
  .bf-avg-num { font-size: 42px; }
  .bf-avg-unit { font-size: 20px; }
  
  .bf-worm { 
    width: 80px; 
    height: 80px; 
    right: 16px; 
    bottom: 12px; 
  }

  /* INSIGHTS — white rounded card */
  .bf-ins-box {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px 20px;
    margin: 0 0 24px 0; /* Bottom spacing to anchor the page */
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  }
  .page-body { padding: 28px 32px; }
  .bins-grid { gap: 20px; }

   .dash-card-row {
    width: 100%;
    height: auto;
    padding: 24px 28px;
  }
  .dash-main-clipart {
    width: 100%;
    max-width: 340px;
    height: auto;
  }
  .dash-title { font-size: 20px; }
  .dash-desc { font-size: 12px; }
  .dash-row-icon { width: 68px; height: 68px; }

  
}

/* Fix for Massive 1080p/4k Monitors */
@media (min-width: 1920px) {
  .bin-crumb { margin: -56px -64px 32px -64px !important; padding: 24px 28px !important; background: #e2e2e2; border-bottom: 1px solid #111; }
}

/* ════════════════════════════════════════════
   RESPONSIVE  —  MOBILE  ≤ 768px
   ════════════════════════════════════════════ */

/* --- Responsive snaps for the grey header --- */
@media (min-width: 1440px) {
  .bin-crumb { margin: -48px -56px 32px -56px; padding: 24px 28px; background: #e2e2e2; border-bottom: 1px solid #111; }
}
@media (max-width: 1024px) {
  .bin-crumb { margin: -28px -32px 24px -32px; padding: 16px 28px; background: #e2e2e2; border-bottom: 1px solid #111; }
}
@media (max-width: 768px) {
  .bin-crumb { 
    margin: -20px -20px 0px -20px; 
    padding: 16px 20px; 
    border-radius: 16px 16px 0 0; 
    background: #e2e2e2 !important; 
    border-bottom: 1px solid #111 !important; 
  }
}
@media (max-width: 480px) {
  .bin-crumb { 
    padding: 16px; 
    background: #e2e2e2; 
    border-bottom: 1px solid #111; 
  }
}
  
@media (max-width: 768px) {
  :root { --sb-w: 0px; --gap: 12px; }

.topbar { 
    padding: 0 12px; 
    display: flex;
    justify-content: space-between; /* Pushes logo left, controls right */
    align-items: center;
  }
  .hamburger { display: none; }
  .topbar-logo { 
    position: static; 
    transform: none; 
    left: auto;
  }
  .topbar-right { order: 1; }
  .refresh-label { display: none; }

  /* Bigger logo on mobile */
  .logo-img {
    height: 24px;
  }

  /* Tighter pill on mobile */
  .tb-bin-selector {
    min-width: unset;
    max-width: 180px;
    padding: 4px 10px 4px 4px;
    height: 32px;
  }

  .tb-bin-icon-bg {
    width: 24px;
    height: 24px;
  }

  .tb-bin-icon-bg img {
    width: 13px;
    height: 13px;
  }

  .tb-bin-dropdown {
    font-size: 12px;
    padding-right: 16px;
  }

  .tb-chevron {
    right: 8px;
    width: 10px;
    height: 10px;
  }

  .sidebar {
    width: 240px;
    transform: translateX(-100%);
    z-index: 200;
    padding: 16px 0;
    align-items: flex-start;
  }
  
   
  
  .nav-item {
    flex-direction: row;
    width: 100%;
    height: auto;
    padding: 14px 24px;
    border-radius: 0;
    gap: 14px;
    justify-content: flex-start;
  }
  
  .nav-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, .7);
  }
  
  .nav-item.active .nav-label { color: #fff; }
  .nav-item.active::before { top: 0; bottom: 0; left: 0; width: 4px; height: auto; }
  
  .sidebar-bottom { align-items: stretch; padding: 0 24px; }
  .support-card { display: flex; margin-bottom: 24px; width: 100%; }
  .nav-logout { border: 1px solid rgba(255, 255, 255, 0.8); justify-content: center; border-radius: 8px; }

  .main {
    margin-left: 0;
    height: auto;
    min-height: calc(100dvh - var(--tb-h));
    overflow: auto;
    padding-bottom: calc(var(--gap) + 64px);
    margin: 0;
  }
  
  .page { overflow: visible; }
  .page-card { min-height: 0; border-radius: 16px;max-width: 500px; align-self: center; margin-top: 16%; }
  .page-body { padding: 20px 20px;  }
  .bottom-nav { display: flex; }

  .home-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding-bottom: 12px;
  }
  
.bins-grid { grid-template-columns: 1fr; gap: 16px; }
  .bin-card { aspect-ratio: auto; min-height: 160px; padding: 20px 24px; }
  
  /* --- FIXED MOBILE MONITORING LAYOUT --- */
  
  /* Float Mode Selector to Top Right */
  .bin-banner { position: relative; }
  .mode-selector-wrap {
    position: absolute;
    top: 16px;
    right: 16px;
    transform: scale(0.85);
    transform-origin: top right;
  }

   
  .sensor-grid { grid-template-columns: 1fr; gap: 12px; }
  
  .sensor-card {
    display: grid !important;
    grid-template-columns: 48px 1fr 56px !important; /* Left Icon | Middle Text | Right Ring */
    
    /* FIX: Split the gaps so horizontal spacing stays wide, but vertical spacing gets tight */
    column-gap: 16px !important; 
    row-gap: 2px !important; 
    
    align-items: center !important;
    padding: 16px 20px !important;
    min-height: auto !important;
  }

  /* 'Unwrap' the inner HTML containers */
  .sc-info, .ring-wrap {
    display: contents !important;
  }
  
  /* 2. Fix the Icon... (keep your existing .ring-icon code here) */
  .ring-icon {
    grid-column: 1 !important;
    grid-row: 1 / span 2 !important;
    width: 48px !important;
    height: 48px !important;
    background: var(--sidebar) !important;
    border-radius: 50% !important;
    position: static !important; 
    transform: none !important;
    margin: 0 !important;
  }
  .ring-icon img {
    width: 24px !important;
    height: 24px !important;
    filter: brightness(0) invert(1) !important; 
    margin: auto !important;
  }
  
  /* 3. Middle Text (Pushed tightly together) */
  .sc-name {
    grid-column: 2 !important;
    grid-row: 1 !important;
    font-size: 14px !important;
    margin: 0 !important;
    align-self: end !important; /* Pushes bottom of name down */
    background: transparent !important;
    padding: 0 !important;
    border: none !important;
  }
  .sc-status {
    grid-column: 2 !important;
    grid-row: 2 !important;
    font-size: 13px !important;
    margin: 0 !important;
    align-self: start !important; /* Pushes top of status up */
  }
  
  /* 4. Right Progress Ring */
  .ring-svg {
    grid-column: 3 !important;
    grid-row: 1 / span 2 !important;
    width: 56px !important;
    height: 56px !important;
    position: relative !important; /* Kills the absolute positioning */
    transform: rotate(-90deg) !important;
    margin: 0 !important;
  }
  .ring-track, .ring-arc {
    stroke-width: 6 !important;
  }
  
  /* 5. Value Text perfectly centered INSIDE the ring */
  .sc-value {
    grid-column: 3 !important;
    grid-row: 1 / span 2 !important;
    justify-self: center !important;
    align-self: center !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    text-align: center !important;
    margin: 0 !important;
    z-index: 2 !important;
    position: static !important;
  }
  .sc-unit {
    font-size: 11px !important;
    margin-left: 1px !important;
  }

  /* Keep Dashboard mobile grids intact */
  /* Dashboard — mobile stacked layout */
.dash-layout {
  flex-direction: column;
  gap: 0;
  align-items: center;
}
.dash-left {
  flex: unset;
  width: 100%;
  padding: 16px 16px 8px;
  align-items: center;
}
.dash-welcome {
  align-self: center;
  text-align: center;
}
.dash-main-clipart {
  width: 260px;
  height: auto;
}
.dash-right {
  flex: unset;
  width: 100%;
  padding: 8px 16px 16px;
  align-items: center;
  gap: 16px;
}
.dash-select-label {
  text-align: center;
  width: 100%;
}
.dash-card-row {
  width: 100%;
  max-width: 420px;
  height: auto;
  padding: 20px 24px;
}
  .dash-row-icon { width: 56px; height: 56px; }
  .dash-title { font-size: 20px; }
  .dash-desc { font-size: 13px; }
  .dash-card-row:hover { transform: none; box-shadow: none; border-color: transparent; }
  .sub-layout { flex-direction: column; }
  .sub-left { width: 100%; flex-direction: row; flex-wrap: wrap; gap: 8px; align-items: center; }

  /* QI stats: single column on mobile */
  .qi-stats-row { grid-template-columns: 1fr 1fr; }

  /* Recent QI card: stack sensor pills */
  .rqi-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .rqi-sensors { gap: 6px; }
.mobile-logout-card {
    display: block;




  }



  


/* ════════════════════════════════════════════
   RESPONSIVE  —  SMALL PHONE  ≤ 480px
   ════════════════════════════════════════════ */
@media (max-width: 480px) {
  .page-body { padding: 16px 16px; }
  .bin-card { min-height: 140px; }
  .sensor-grid { grid-template-columns: 1fr; gap: 12px; }
  .ring-wrap { width: 64px; height: 64px; }
  .banner-title { font-size: 30px; }
}

/* ════════════════════════════════════════════
   DESKTOP ONLY  (bottom nav handling)
   ════════════════════════════════════════════ */
@media (min-width: 769px) {
  .bottom-nav { display: none !important; }
  .sidebar { transform: none !important; }
}

@media (hover: none) {
  .bin-card:hover { transform: none; box-shadow: 0 1px 4px rgba(0, 0, 0, .06); }
  .dash-card-row:hover { transform: none; }
}
}

/* ── QI + BF: fills viewport at 100%, scrolls when zoomed out ── */
#page-quick-insights,
#page-bin-fluctuation {
  flex: 1;
  min-height: 0;
}

#page-quick-insights .page-card,
#page-bin-fluctuation .page-card {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: visible;
}

#page-quick-insights .qi-page-body,
#page-bin-fluctuation .page-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#page-quick-insights .qi-layout,
#page-bin-fluctuation .bf-layout {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#page-quick-insights .qi-panel,
#page-bin-fluctuation .bf-panel {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  min-height: 500px;
}

#page-quick-insights .qi-tbl-wrap {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
}

#page-bin-fluctuation .chart-scroll-wrap {
  flex: 1;
  min-height: 120px;
}


#page-quick-insights .bin-crumb,
#page-bin-fluctuation .bin-crumb {
  position: sticky;
  top: 0;
  left: 1px;
  z-index: 10;
}


@media (min-width: 1100px) and (max-width: 1250px) {
  #page-quick-insights .qi-layout,
  #page-bin-fluctuation .bf-layout {
    margin-top: -1px;
  }
}
 
@media (max-width: 768px) {
  .home-header {
    display: flex !important;
    flex-direction: row !important; 
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: nowrap !important; 
    width: 100% !important;
    gap: 4px !important; /* Minimized gap */
  }

  .home-title {
    font-size: 20px !important; /* Smaller title to make room */
    flex-shrink: 0;
  }

  .status-pills {
    display: flex !important;
    flex-direction: row !important;
    gap: 6px !important;
    flex-shrink: 1; /* Allows pills to shrink if needed */
  }

  /* Shrink the actual containers */
  .spill {
    padding: 6px 10px !important;
    font-size: 14px !important;
    gap: 6px !important;
    height: 36px; /* Uniform height */
  }

  .spill-half {
    padding: 6px 8px !important;
    gap: 6px !important;
  }

  .spill img {
    width: 16px !important;
    height: 16px !important;
  }
}

@media (max-width: 480px) {
  .page-body {
    
  }
  
  /* Force a smaller font on the values if they still overflow */
  .spill span {
    font-size: 12px !important;
  }
}


@media (max-width: 768px) {
  /* target the gas level values specifically to prevent unit overlap */
  #b1-gas-card .sc-value, 
  #b2-gas-card .sc-value {
    display: flex !important;
    flex-direction: column !important; /* Forces ppm under the number */
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
  }

  #b1-gas-card .sc-unit, 
  #b2-gas-card .sc-unit {
    margin-left: 0 !important;
    margin-top: -2px !important; /* Pulls unit closer to the number */
    font-size: 10px !important;  /* Slightly smaller to ensure fit */
  }

  /* Adjust the numeric value size to ensure it fits the progress ring */
  #b1-gas-card .sc-value, 
  #b2-gas-card .sc-value {
    font-size: 14px !important; 
  }
}


@media (max-width: 768px) {
  /* Targeted fix specifically for the Settings page card */
  #page-settings {
    height: auto !important;
    min-height: initial !important;
    max-height: none !important;
  }

  #page-settings .page-card {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important; /* Prevents the last items from being clipped */
  }

  #page-settings .page-body {
    height: auto !important;
    flex: none !important;
    overflow-y: visible !important;
    padding-bottom: 60px !important; /* Space for mobile logout and bottom nav */
  }

  /* Force settings cards to stack naturally instead of stretching */
  #page-settings .settings-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
  }
}


@media (max-width: 768px) {
  /* 1. Give the content more horizontal room by reducing side padding */
  #page-settings .page-body {
    padding: 24px 16px !important; /* Reduced from 32px/22px to give cards more width */
  }

  /* 2. Ensure the grid and its columns take up the full available width */
  #page-settings .settings-grid {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
  }

  #page-settings .settings-col {
    width: 100% !important;
    gap: 16px !important;
  }

  /* 3. Fix the "Connected Device" card rows to prevent text overlap */
  .settings-card {
    padding: 20px 16px !important; /* Slightly tighter internal padding */
    width: 100% !important;
  }

  .dev-row {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 8px !important; /* Space between label and value */
  }

  .dev-key {
    flex-shrink: 0 !important; /* Keep labels from squishing */
    font-size: 12px !important;
  }

  .dev-val {
    text-align: right !important;
    word-break: break-all !important; /* Prevents long IP/IDs from breaking layout */
    font-size: 12px !important;
    min-width: 0; /* Allows text overflow logic to work */
  }

  /* 4. Fix WiFi Manager status bar for narrow screens */
  .wm-status-bar {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
    padding: 12px !important;
  }

  .wm-status-actions {
    width: 100% !important;
    justify-content: flex-start !important;
  }
}

 
 /* Card Container */
.bins-scroll-container {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;     /* Forces all bins into a single horizontal line */
    gap: 16px;             /* Space between cards */
    overflow-x: auto;      /* Enables horizontal scrollbar */
    overflow-y: hidden;    /* Prevents vertical expansion */
    padding: 10px 4px 20px 4px; 
    
    /* CRITICAL FIX: Match the parent's width exactly and prevent stretching */
    width: 100%;           
    max-width: calc(100% - 8px); /* Account for side borders/padding */
    box-sizing: border-box; 
    
    /* Modern Scrollbar Styling */
    scrollbar-width: thin; 
    scrollbar-color: var(--green-mid) transparent;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling for mobile */
}
/* Status Chip */
.bin-status-chip {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 9px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  border: 1px solid #111;
}
.bin-status-chip.online { background: #dcfce7; color: #166534; }
.bin-status-chip.offline { background: #fee2e2; color: #991b1b; }

/* Central Illustration */
.bin-card-illus {
  width: 90px;
  height: 90px;
  background: var(--green-pale);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  border: 1px solid #111;
}
.bin-card-illus img { width: 50px; height: 50px; }

 
.claimed-bin-name { font-size: 16px; font-weight: 700; color: #111; }
.claimed-bin-id { font-size: 12px; color: #888; font-family: monospace; }

/* Actions Bar */
.bin-card-actions {
  display: flex;
  gap: 12px;
  width: 100%;
}
.bin-card-actions .btn-icon-sm {
  flex: 1;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid #111;
  border-radius: 10px;
  box-shadow: 0px 2px 0px #111;
}
.bin-card-actions .btn-icon-sm:active { transform: translateY(2px); box-shadow: none; }
.bin-card-actions .btn-icon-sm img { width: 18px; height: 18px; }
.bin-card-actions .btn-icon-sm.delete:hover { background: #fee2e2; }
 
/* --- FINAL FIXED CLAIMED BINS STYLING --- */

.claimed-bin-card {
    flex: 0 0 180px;       /* Fixed 180px width: Do not grow, do not shrink */
    width: 180px;          /* Fallback fixed width */
    position: relative;
    background: #ffffff;
    border: 1.5px solid #111;
    border-radius: 20px;
    overflow: hidden; 
    box-shadow: 0px 4px 0px #111;
    display: flex;
    flex-direction: column;
}

.bin-visual-header {
    position: relative;
    width: 100%;
    height: 100px;
    background: #f1f8d4; /* AVONIC light green */
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1.5px solid #111;
}

.bin-image {
    width: 65px;
    height: 65px;
    object-fit: contain;
}

/* Red X Button anchored to the top-right of the green header */
.bin-delete-x {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: white;
    border: 1.5px solid #111;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ef4444;
    font-size: 14px;
    font-weight: bold;
    z-index: 10;
   
    cursor: pointer;
}

/* Info section: Uses Flexbox to stack items vertically */
.bin-card-info {
    padding: 12px 10px 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.claimed-bin-name {
    font-size: 15px;
    font-weight: 700;
    color: #111;
    cursor: pointer;
}

/* Status Chip: Now follows natural document flow (no absolute position) */
.bin-status-chip {
    position: static !important; /* Forces it out of absolute mode from old styles */
    font-size: 9px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid #111;
    display: inline-block;
    margin: 4px 0;
    text-transform: uppercase;
}

.bin-status-chip.online { background: #dcfce7; color: #166534; }
.bin-status-chip.offline { background: #fee2e2; color: #991b1b; }

.claimed-bin-id {
    font-size: 11px;
    color: #888;
    font-family: monospace;
}

/* --- ISOLATED SETTINGS WIDTH & SCROLL FIX --- */
@media (min-width: 769px) and (max-width: 899px) {
  /* 1. Ensure the main container doesn't restrict horizontal growth */
  .main {
    height: auto !important;
    overflow-y: auto !important;
    padding: 24px 16px !important; /* Give more breathing room for the cards */
  }

  /* 2. Force the Settings page to allow content expansion */
  #page-settings {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  /* 3. Force the grid and columns to maximize width */
  #page-settings .settings-grid {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important; /* Breaks the 630px desktop limit */
    gap: 20px !important;
  }

  #page-settings .settings-col {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0; /* Standard fix for flexbox children overflow */
  }

  /* 4. Ensure individual cards stretch to fill the column */
  #page-settings .settings-card {
    width: 100% !important;
    box-sizing: border-box;
  }
}

 

/* Secondary Button Upgrade */
.btn-secondary {
  background: white !important;
  border: 1.5px solid #111 !important;
  color: #111 !important;
   
  font-weight: 700 !important;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: #f9f9f9 !important;
  transform: translateY(-2px);
}

.btn-secondary:active {
  transform: translateY(2px);
  box-shadow: none !important;
}

/* Helper for password divider inside modals */
.auth-divider {
  margin: 12px 0;
  border-top: 1px dashed #ddd;
}
/* ── Phase 4: Driver.js Tour — Neobrutalism Skin ─────────── */
.av-tour-popover.driver-popover {
  background: var(--card);
  border: 2.5px solid black;
  border-radius: 14px;
  box-shadow: 5px 5px 0 black;
  font-family: 'Quicksand', sans-serif;
  color: var(--text);
  max-width: 300px;
  padding: 22px 20px 18px;
}

.av-tour-popover .driver-popover-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--topbar);
  margin-bottom: 8px;
  line-height: 1.3;
}

.av-tour-popover .driver-popover-description {
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.65;
}

.av-tour-popover .driver-popover-progress-text {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.av-tour-popover .driver-popover-footer {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.av-tour-popover .driver-popover-next-btn,
.av-tour-popover .driver-popover-prev-btn,
.av-tour-popover .driver-popover-done-btn {
  padding: 8px 16px;
  font-family: 'Quicksand', sans-serif;
  font-size: 12px;
  font-weight: 800;
  border-radius: 8px;
  border: 2px solid black;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  line-height: 1;
}

.av-tour-popover .driver-popover-next-btn,
.av-tour-popover .driver-popover-done-btn {
  background: var(--yellow);
  color: #1a1a1a;
  box-shadow: 3px 3px 0 black;
}

.av-tour-popover .driver-popover-prev-btn {
  background: var(--card);
  color: var(--text-sub);
  box-shadow: 3px 3px 0 black;
}

.av-tour-popover .driver-popover-next-btn:hover,
.av-tour-popover .driver-popover-done-btn:hover,
.av-tour-popover .driver-popover-prev-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 black;
}

.av-tour-popover .driver-popover-next-btn:active,
.av-tour-popover .driver-popover-done-btn:active,
.av-tour-popover .driver-popover-prev-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 black;
}

/* Close × inside popover */
.av-tour-popover .driver-popover-close-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color var(--t), background var(--t);
}

.av-tour-popover .driver-popover-close-btn:hover {
  color: var(--topbar);
  background: var(--green-pale);
}

/* Overlay tint */
.driver-overlay {
  background: rgba(15, 28, 18, 0.68) !important;
}

/* Highlighted element ring */
.driver-active-element {
  outline: 3px solid var(--yellow) !important;
  outline-offset: 4px !important;
  border-radius: 8px !important;
}

/* ── Phase 5: Contextual Tooltips ────────────────────────── */
.av-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 2px solid black;
  box-shadow: 1.5px 1.5px 0 black;
  background: var(--card);
  color: var(--topbar);
  font-size: 10px;
  font-weight: 800;
  font-family: 'Quicksand', sans-serif;
  cursor: help;
  position: relative;
  vertical-align: middle;
  margin-left: 5px;
  flex-shrink: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--t), color var(--t), box-shadow var(--t);
  /* Establish stacking context so ::after sits above siblings */
  z-index: 0;
}

.av-help:hover,
.av-help.av-tip-open {
  background: var(--topbar);
  color: #fff;
  box-shadow: 2px 2px 0 black;
  z-index: 100;
}

/* Tooltip bubble */
.av-help::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 230px;
  padding: 10px 13px;
  background: var(--topbar);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  border-radius: 10px;
  border: 2px solid black;
  box-shadow: 3px 3px 0 black;
  white-space: normal;
  text-align: left;
  pointer-events: none;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

/* Arrow */
.av-help::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: black;
  pointer-events: none;
  z-index: 201;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

/* Show on hover (desktop) or .av-tip-open (mobile tap) */
.av-help:hover::after,
.av-help:hover::before,
.av-help.av-tip-open::after,
.av-help.av-tip-open::before {
  opacity: 1;
  visibility: visible;
}

/* Flip upward → downward when near top of screen */
.av-help.av-tip-flip::after {
  bottom: auto;
  top: calc(100% + 10px);
}
.av-help.av-tip-flip::before {
  bottom: auto;
  top: calc(100% + 5px);
  border-top-color: transparent;
  border-bottom-color: black;
}
/* ── Driver.js spotlight fix ──────────────────────────────── */
.driver-overlay {
  background: rgba(0, 0, 0, 0.65) !important;
  z-index: 9998 !important;
}

.driver-active-element {
  position: relative !important;
  z-index: 9999 !important;
  opacity: 1 !important;
  filter: brightness(1) !important;
  -webkit-filter: brightness(1) !important;
  border-radius: 12px !important;
  outline: 3px solid #ecbd0100 !important;
  outline-offset: 4px !important;
  box-shadow: none !important;
}

.driver-popover {
  z-index: 10000 !important;
}


/* Force Quicksand uniformly across all Driver.js elements */
.av-tour-popover.driver-popover * {
  font-family: 'Quicksand', sans-serif !important;
}


/* Ensure the highlighted element text is always readable */
.driver-active-element {
  transition: background-color 0.3s ease, color 0.3s ease !important;
}

 
/* 2. Fix the Topbar Stacking Issue */
/* When a topbar element is active, we must ensure its parent container 
   does not clip the highlight or fight the overlay stacking */
.topbar:has(.driver-active-element) {
  z-index: 9999 !important;
}

/* 3. Smooth the Transition */
.driver-active-element {
  transition: background-color 0.2s ease, color 0.2s ease !important;
}

/* ── Phase 4: Tour Modal (Steps 6 & 7) Darken & Font Fix ── */

/* 1. Force the dark background during the modal preview steps */
#sys-modal-overlay.tour-preview {
    background: rgba(0, 0, 0, 0.75) !important; /* Matches tour darkness */
    z-index: 10000 !important; /* Lifts overlay above topbar */
    display: block !important;
    opacity: 1 !important;
}

/* 2. Lift the modal above the dark overlay */
#sensor-detail-modal.tour-preview {
    z-index: 10001 !important;
}

/* 3. Force Quicksand uniformly for the modal and tour popovers */
#sensor-detail-modal.tour-preview,
#sensor-detail-modal.tour-preview *,
.av-tour-popover.driver-popover,
.av-tour-popover.driver-popover * {
    font-family: 'Quicksand', sans-serif !important;
}

/* ════════════════════════════════════════════
   EXPORT MODAL (Split Layout)
   ════════════════════════════════════════════ */
.export-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  background: transparent;
  color: #111;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  letter-spacing: 0.5px;
}

.export-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

.export-modal {
  padding: 0 !important; /* Overrides sys-modal default padding */
  max-width: 680px !important; /* Wider for the split layout */
  border: 1.5px solid #111;
  border-radius: 20px;
  overflow: hidden;
  background: #ffffff;
}

.export-modal-inner {
  display: flex;
  flex-direction: row;
  width: 100%;
  min-height: 440px; 
}

/* ── Left Side: Preview ── */
.export-left {
  flex: 1;
  background: #ffffff;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.export-preview-badge {
  display: inline-block;
  border: 1.5px solid #111;
  border-radius: 20px;
  padding: 6px 18px;
  font-weight: 800;
  font-size: 14px;
  color: #111;
  background: #dcdcdc; /* Matching the wireframe pill */
  width: fit-content;
  margin-bottom: 24px;
}

.export-a4-placeholder {
  flex: 1;
  background: #fdfdfd;
  border: 1px dashed #ccc;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #aaa;
  font-weight: 600;
  font-size: 14px;
  width: 100%;
  /* A4 Aspect Ratio constraint */
  aspect-ratio: 1 / 1.414;
  margin: 0 auto;
  max-height: 500px; 
}

/* ── Right Side: Controls ── */
.export-right {
  width: 250px;
  background: #dcdcdc; /* Wireframe grey */
  border-left: 1.5px solid #111;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.export-title {
  font-size: 16px;
  font-weight: 800;
  color: #111;
  margin-bottom: 24px;
}

.export-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1; /* Pushes the Exit button to the bottom */
}

.export-opt-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border: 1.5px solid #111;
  border-radius: 8px;
  padding: 14px;
  font-weight: 800;
  font-size: 14px;
  color: #111;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

.export-opt-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 2px 2px 0px #111;
}

.export-opt-btn:active {
  transform: translate(1px, 1px);
  box-shadow: 0px 0px 0px #111;
}

.export-opt-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.export-exit-btn {
  width: 100%;
  background: #4a4a4a;
  color: #ffffff;
  border: 1.5px solid #111;
  border-radius: 8px;
  padding: 12px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 24px;
}

.export-exit-btn:hover {
  background: #333333;
}

/* ── Mobile Adjustments ── */
@media (max-width: 768px) {
  .export-modal-inner {
    flex-direction: column;
  }
  .export-right {
    width: 100%;
    border-left: none;
    border-top: 1.5px solid #111;
    padding-bottom: 24px; /* Ensure bottom padding */
  }
  .export-a4-placeholder {
    max-height: 300px; /* Restrict height on mobile so it fits the screen */
  }
}

/* ── Export Checkboxes ── */
.export-settings-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.export-check {
  font-size: 13px;
  font-weight: 700;
  color: #111;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.export-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #111; /* Makes the native checkbox black */
  cursor: pointer;
  border: 1.5px solid #111;
}

/* ── Export Live Preview & Pagination ── */
.export-pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  font-weight: 700;
  color: #111;
}

.ex-page-btn {
  background: #ffffff;
  border: 1.5px solid #111;
  border-radius: 6px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: bold;
  transition: 0.1s;
}

.ex-page-btn:hover:not(:disabled) { background: #e2e2e2; }
.ex-page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.export-a4-wrapper {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: #f0f0f0;
  border-radius: 8px;
  border: 1.5px solid #ccc;
  overflow: hidden;
  padding: 16px;
}

.export-a4-placeholder {
  background: #ffffff;
  width: 100%;
  aspect-ratio: 1 / 1.414; /* Pure A4 Ratio */
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  padding: 18px; 
  font-family: 'Quicksand', sans-serif;
  overflow: hidden;
  position: relative;
  color: #111;
  /* Override the old flex centering */
  display: block; 
}

/* Miniaturized Document Styles */
.ex-prev-header h1 { font-size: 14px; margin: 0 0 4px 0; border-bottom: 1px solid #111; padding-bottom: 4px; }
.ex-prev-meta { font-size: 8px; color: #666; margin-bottom: 12px; }
.ex-prev-sensor-h2 { font-size: 12px; margin: 0 0 6px 0; display: flex; align-items: center; gap: 4px; color: #2e4f39;}
.ex-prev-insight { background: #f9f9f9; padding: 6px; font-size: 8px; margin-bottom: 10px; border-radius: 3px; }
.ex-prev-stats { display: flex; gap: 6px; margin-bottom: 12px; }
.ex-prev-stat-box { border: 1px solid #ccc; padding: 6px; border-radius: 4px; flex: 1; text-align: center; font-size: 7px; }
.ex-prev-stat-box span { display: block; font-size: 11px; font-weight: bold; margin-top: 2px;}
.ex-prev-table { width: 100%; border-collapse: collapse; font-size: 7.5px; text-align: center; }
.ex-prev-table th, .ex-prev-table td { border-bottom: 1px solid #eee; padding: 4px; }
.ex-prev-table th { background: #fafafa; }


/* ── Mobile Tweaks for Export Button ── */
@media (max-width: 768px) {
  .export-btn-text {
    display: none;
  }
  
  .export-btn {
    padding: 8px 10px; /* Squares up the button since it's just an icon now */
  }
}

/* ════════════════════════════════════════════
   EXPORT MODAL MOBILE PAGINATION
   ════════════════════════════════════════════ */
.ex-mobile-preview-btn, .ex-mobile-back {
  display: none; /* Hidden by default on Desktop */
}

@media (max-width: 768px) {
  /* Default Mobile State: Show Controls (Page 1) */
  .export-left {
    display: none; 
  }
  
  .export-right {
    display: flex;
    width: 100%;
    border-left: none;
    padding-bottom: 24px;
  }

  /* Show the mobile navigation buttons */
  .ex-mobile-preview-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    background: #eef5ed;
    color: #2e4f39;
    border: 1.5px solid #2e4f39;
    border-radius: 8px;
    font-weight: 800;
    font-size: 14px;
    margin-bottom: 20px;
    cursor: pointer;
    transition: background 0.2s;
  }
  
  .ex-mobile-preview-btn:active {
    background: #d4e8d8;
  }

  .ex-mobile-back {
    display: block;
    background: transparent;
    border: none;
    color: #111;
    font-weight: 800;
    font-size: 14px;
    padding: 0 0 16px 0;
    margin-bottom: 16px;
    border-bottom: 1.5px solid #ccc;
    width: 100%;
    text-align: left;
    cursor: pointer;
  }

  /* Active Preview State (Page 2) */
  .export-modal-inner.show-mobile-preview .export-left {
    display: flex;
    flex-direction: column;
    width: 100%;
  }
  
  .export-modal-inner.show-mobile-preview .export-right {
    display: none;v
  }
}