/* ==========================================================================
   AzollaSense - IoT Eco-Agriculture Monitoring Web App
   ========================================================================== */

:root {
  /* Nature & Foliage Theme Palette */
  --bg-primary: #e6f3e7;
  --bg-gradient-start: #eaf5eb;
  --bg-gradient-mid: #dceddf;
  --bg-gradient-end: #d1e7d4;

  --primary-dark: #194627;
  --primary-forest: #235c35;
  --primary-emerald: #2e7a46;
  --primary-leaf: #499b62;
  --primary-accent: #58b675;
  --primary-light: #e4f5e7;
  --primary-subtle: #f1f9f2;

  /* Telemetry Sensor Card Themes */
  --water-bg-start: #e3f3fd;
  --water-bg-end: #ceeafb;
  --water-border: #b5def7;
  --water-text: #164f6e;
  --water-icon: #2196f3;

  --temp-bg-start: #fff4e7;
  --temp-bg-end: #fde8d4;
  --temp-border: #f8cfb2;
  --temp-text: #61341a;
  --temp-icon: #e65100;

  --ph-bg-start: #e8f8eb;
  --ph-bg-end: #d7f3dc;
  --ph-border: #bce7c4;
  --ph-text: #1b5327;
  --ph-icon: #2e7d32;

  --cov-bg-start: #eaf7ee;
  --cov-bg-end: #d6f2df;
  --cov-border: #bfe9cc;
  --cov-text: #1b5327;
  --cov-icon: #2e7d32;

  /* Neutrals & Surfaces */
  --card-bg: rgba(255, 255, 255, 0.88);
  --card-border: rgba(185, 219, 194, 0.55);
  --text-primary: #1a3824;
  --text-secondary: #476a52;
  --text-muted: #6f8f78;
  --shadow-sm: 0 4px 14px rgba(33, 76, 45, 0.06);
  --shadow-md: 0 8px 24px rgba(28, 68, 39, 0.09);
  --shadow-lg: 0 16px 40px rgba(24, 60, 34, 0.14);

  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-full: 9999px;

  --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-brand: 'Outfit', var(--font-main);

  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Base Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  min-height: 100vh;
  font-family: var(--font-main);
  color: var(--text-primary);
  background: radial-gradient(circle at 10% 20%, #eef7f0 0%, #e1efe3 50%, #d4e8d8 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* Ambient Leaf Background Pattern (CSS SVG Decoration) */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    radial-gradient(circle at 90% 10%, rgba(138, 197, 155, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 10% 85%, rgba(116, 185, 137, 0.18) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(186, 227, 198, 0.12) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ==========================================================================
   App Loader (Welcome Backdrop)
   ========================================================================== */
.app-loader {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image:
    linear-gradient(180deg, rgba(18, 46, 27, 0.55) 0%, rgba(18, 46, 27, 0.38) 100%),
    url("../assets/welcome_bg.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: none;
}

.app-loader.is-dismissed {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Top presentation bar (View Switcher & IoT Controls) */
.presentation-bar {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(138, 197, 155, 0.4);
  box-shadow: 0 8px 24px rgba(25, 60, 35, 0.12);
  z-index: 1000;
  transition: var(--transition-normal);
}

.presentation-bar:hover {
  box-shadow: 0 12px 30px rgba(25, 60, 35, 0.18);
}

.presentation-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-forest);
  padding-right: 8px;
  border-right: 1px solid #d4e8d8;
}

.presentation-title img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

/* Device Wrapper & Outer Layout */
.app-viewport {
  position: relative;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1;
}

/* Mobile Screen Window */
.app-screen {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 90vh;
  max-height: 850px;
  background: linear-gradient(180deg, #e4f2e6 0%, #daf0dd 35%, #d1eadd 100%);
  border-radius: 40px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 40px rgba(24, 60, 34, 0.14);
}

@media (max-width: 520px) {
  .app-screen {
    border-radius: 0;
    height: 100vh;
    max-height: none;
  }
}

/* App Header */
.main-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(138, 197, 155, 0.3);
  z-index: 100;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.brand-text {
  font-family: var(--font-brand);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  position: relative;
}

.brand-leaf-accent {
  display: inline-block;
  width: 20px;
  height: 20px;
  vertical-align: middle;
  margin-left: 2px;
  transform: translateY(-4px);
  filter: drop-shadow(0 2px 4px rgba(45, 122, 70, 0.25));
}

.profile-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(144, 203, 161, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(35, 92, 53, 0.08);
  cursor: pointer;
  transition: var(--transition-fast);
}

.profile-btn:hover {
  background: #ffffff;
  transform: scale(1.05);
  box-shadow: 0 5px 14px rgba(35, 92, 53, 0.15);
}

.profile-avatar-svg {
  width: 24px;
  height: 24px;
  fill: #3b7b4e;
}

/* Content Area with Smooth Scroll */
.screen-scroll-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 72px 18px 88px;
  scrollbar-width: none;
  scrollbar-color: rgba(69, 133, 89, 0.3) transparent;
  -ms-overflow-style: none;
}

.screen-scroll-container::-webkit-scrollbar {
  width: 4px;
}

.screen-scroll-container::-webkit-scrollbar-thumb {
  background: rgba(69, 133, 89, 0.3);
  border-radius: 4px;
}

/* Tab Panels Transitions */
.tab-panel {
  display: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.tab-panel.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.welcome-dome-artwork {
  width: 170px;
  height: 170px;
  object-fit: contain;
  filter: drop-shadow(0 10px 24px rgba(29, 78, 43, 0.2));
  animation: gentleFloat 4s ease-in-out infinite alternate;
}

@keyframes gentleFloat {
  0% {
    transform: translateY(0);
  }

  100% {
    transform: translateY(-8px);
  }
}

.welcome-title {
  font-family: var(--font-brand);
  font-size: 38px;
  font-weight: 800;
  color: var(--primary-dark);
  margin-top: 16px;
  letter-spacing: -0.6px;
}

.welcome-subtitle {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 6px;
  max-width: 280px;
  line-height: 1.4;
}

.welcome-cta-btn {
  margin-top: 24px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 34px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #2b7944 0%, #1f5d33 100%);
  border: none;
  border-radius: var(--radius-full);
  box-shadow: 0 8px 24px rgba(35, 92, 53, 0.35);
  cursor: pointer;
  transition: var(--transition-normal);
  z-index: 2;
}

.welcome-cta-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 12px 28px rgba(35, 92, 53, 0.45);
}

/* ==========================================================================
   1. Dashboard Screen
   ========================================================================== */
.sub-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 6px 0 12px;
}

.page-title {
  font-family: var(--font-brand);
  font-size: 26px;
  font-weight: 800;
  color: var(--primary-dark);
  letter-spacing: -0.4px;
}

.quick-chevron-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(138, 197, 155, 0.4);
  color: var(--primary-leaf);
  cursor: pointer;
  transition: var(--transition-fast);
}

.quick-chevron-btn:hover {
  background: #ffffff;
  color: var(--primary-dark);
  transform: translateX(2px);
}

/* Live Pond Camera Monitor Tank */
.tank-feed-card {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #192a1f;
  border-radius: 18px;
  border: 2px solid rgba(120, 167, 134, 0.7);
  box-shadow: 0 8px 24px rgba(25, 59, 36, 0.16);
  overflow: hidden;
  margin-bottom: 16px;
}

.tank-image-wrapper {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.tank-image-wrapper.has-stopped-frame::before {
  content: "";
  position: absolute;
  inset: -14px;
  background-image: var(--stopped-feed-frame);
  background-position: center;
  background-size: contain;
  background-repeat: no-repeat;
  filter: blur(12px) brightness(0.72);
  transform: scale(1.04);
}

.tank-image-wrapper.is-stream-stopped img {
  visibility: hidden;
}

.tank-image-wrapper:fullscreen {
  width: 100vw;
  height: 100vh;
  aspect-ratio: unset;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tank-feed-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.tank-image-wrapper:fullscreen img {
  object-fit: contain;
}

/* Feed Overlays */
.feed-live-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(14, 30, 20, 0.85);
  backdrop-filter: blur(8px);
  color: #a8f3be;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(168, 243, 190, 0.3);
  z-index: 3;
}

.live-pulse-dot {
  width: 7px;
  height: 7px;
  background: #00e676;
  border-radius: 50%;
  box-shadow: 0 0 8px #00e676;
  animation: pulseGlow 1.5s infinite;
}

@keyframes pulseGlow {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.4;
    transform: scale(0.85);
  }
}

.feed-toggle-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid #bedec6;
  cursor: pointer;
  z-index: 3;
  transition: var(--transition-fast);
}

.feed-toggle-btn:hover {
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.feed-fullscreen-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--primary-dark);
  border-radius: 8px;
  border: 1px solid #bedec6;
  cursor: pointer;
  z-index: 3;
  transition: var(--transition-fast);
}

.feed-fullscreen-btn:hover {
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transform: scale(1.05);
}

/* Stream start / stop controls */
.stream-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(25, 70, 39, 0.85);
  color: #fff;
  border: 2px solid #69f0ae;
  padding: 12px 24px;
  border-radius: 50px;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  z-index: 5;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  transition: 0.2s ease;
}

.stream-play-btn:hover {
  transform: translate(-50%, -50%) scale(1.05);
}

.stream-stop-btn {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(183, 28, 28, 0.9);
  color: #fff;
  border: 2px solid #ff8a80;
  padding: 10px 22px;
  border-radius: 50px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  z-index: 5;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  transition: 0.2s ease;
}

.stream-stop-btn:hover {
  transform: translateX(-50%) scale(1.05);
}

/* AI vision toggle states (base .feed-toggle-btn = OFF look) */
.feed-toggle-btn.vision-on {
  background: #2e7d32;
  color: #ffffff;
  border-color: #69f0ae;
}

.feed-toggle-btn.is-loading {
  cursor: wait;
  opacity: 0.9;
}

.vision-toggle-loader,
.feed-loading-spinner {
  display: inline-block;
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: feedLoaderRotate 0.8s linear infinite !important;
  will-change: transform;
}

.feed-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(168, 243, 190, 0.6);
  border-radius: 999px;
  background: rgba(14, 30, 20, 0.84);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}

.feed-loading-spinner {
  width: 20px;
  height: 20px;
  border-width: 3px;
  color: #69f0ae;
}

@keyframes feedLoaderRotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Generic visibility utility (replaces inline display:none) */
.is-hidden {
  display: none !important;
}

/* 2x2 Sensor Telemetry Grid */
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.sensor-card {
  position: relative;
  display: flex;
  align-items: center;
  padding: 14px 12px;
  border-radius: 18px;
  border: 1px solid;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-normal);
  overflow: hidden;
}

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

/* Subtle organic wave decoration in card corner */
.sensor-card::after {
  content: '';
  position: absolute;
  right: -10px;
  bottom: -15px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  opacity: 0.25;
  background: currentColor;
  pointer-events: none;
}

.sensor-card.water {
  background: linear-gradient(135deg, var(--water-bg-start) 0%, var(--water-bg-end) 100%);
  border-color: var(--water-border);
  color: var(--water-text);
}

.sensor-card.temperature {
  background: linear-gradient(135deg, var(--temp-bg-start) 0%, var(--temp-bg-end) 100%);
  border-color: var(--temp-border);
  color: var(--temp-text);
}

.sensor-card.ph {
  background: linear-gradient(135deg, var(--ph-bg-start) 0%, var(--ph-bg-end) 100%);
  border-color: var(--ph-border);
  color: var(--ph-text);
}

.sensor-card.coverage {
  background: linear-gradient(135deg, var(--cov-bg-start) 0%, var(--cov-bg-end) 100%);
  border-color: var(--cov-border);
  color: var(--cov-text);
}

.light-intensity-card {
  margin: -4px 0 20px;
  padding: 16px;
  border: 1px solid #f0dfa5;
  border-radius: 18px;
  background: linear-gradient(135deg, #fffbea 0%, #fff4c9 100%);
  color: #684d08;
  box-shadow: var(--shadow-sm);
}

.light-intensity-heading {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 15px;
}

.light-intensity-icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: 13px;
  background: #ffe89a;
  color: #ad7800;
}

.light-intensity-icon svg {
  width: 24px;
  height: 24px;
}

.light-intensity-heading h3 {
  margin: 0 0 3px;
  font-size: 14px;
  font-weight: 800;
}

.light-intensity-heading p {
  margin: 0;
  color: #8b7747;
  font-size: 11px;
}

.light-intensity-value {
  margin-left: auto;
  font-family: var(--font-brand);
  font-size: 21px;
  font-weight: 800;
  white-space: nowrap;
}

.light-meter-track {
  position: relative;
  height: 10px;
  overflow: hidden;
  border-radius: 99px;
  background: #f0e5c4;
}

.light-meter-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f6ca50 0%, #f29b38 100%);
  transition: width 350ms ease;
}

.light-meter-threshold {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 75%;
  width: 2px;
  background: #684d08;
}

.light-intensity-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
  color: #8b7747;
  font-size: 10px;
}

.light-intensity-status {
  color: #684d08;
  font-weight: 700;
}

.sensor-icon-box {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 10px;
}

.sensor-icon-box svg {
  width: 36px;
  height: 36px;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.08));
}

.sensor-info {
  display: flex;
  flex-direction: column;
}

.sensor-label {
  font-size: 13px;
  font-weight: 600;
  opacity: 0.9;
  line-height: 1.1;
  margin-bottom: 2px;
}

.sensor-value {
  font-family: var(--font-brand);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

/* Browning Detection CV Section */
.section-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.capture-trigger-btn {
  margin-left: auto;
  padding: 8px 13px;
  border: 1px solid #9ac8a5;
  border-radius: 999px;
  background: #edf7ef;
  color: var(--primary-forest);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.capture-trigger-btn:disabled {
  cursor: wait;
  opacity: 0.65;
}

.section-icon-svg {
  width: 22px;
  height: 22px;
  fill: var(--primary-forest);
}

.section-title-text {
  font-family: var(--font-brand);
  font-size: 20px;
  font-weight: 800;
  color: var(--primary-dark);
}

.capture-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 22px;
}

.capture-detail {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px 14px;
  border: 1px solid rgba(138, 197, 155, 0.4);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
}

.capture-detail span {
  color: var(--text-muted, #718078);
  font-size: 12px;
}

.capture-detail strong {
  color: var(--primary-dark);
  font-size: 16px;
}

/* ==========================================================================
   3. Status Screen
   ========================================================================== */
.status-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.back-circle-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(138, 197, 155, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--primary-dark);
  transition: var(--transition-fast);
}

.back-circle-btn:hover {
  background: #ffffff;
  transform: translateX(-2px);
}

.status-screen-title {
  font-family: var(--font-brand);
  font-size: 24px;
  font-weight: 800;
  color: var(--primary-dark);
}

.logs-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ebf6ee;
  border: 1px solid #bde1c7;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-forest);
  cursor: pointer;
  transition: var(--transition-fast);
}

.logs-pill-btn:hover {
  background: #d8eedc;
}

/* Status Center Badge overlapping tank bottom */
.tank-status-container {
  position: relative;
  margin-bottom: 26px;
}

.system-status-badge {
  position: absolute;
  bottom: -15px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #2d6b3e 0%, #1f502d 100%);
  color: #ffffff;
  padding: 8px 22px;
  border-radius: var(--radius-full);
  box-shadow: 0 6px 16px rgba(22, 59, 33, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.4);
  z-index: 5;
}

.status-badge-leaf {
  width: 20px;
  height: 20px;
}

.system-status-badge span {
  font-family: var(--font-brand);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

/* Recent Logs Section */
.logs-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 10px;
}

.logs-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-brand);
  font-size: 20px;
  font-weight: 800;
  color: var(--primary-dark);
}

.view-all-link {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-leaf);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  transition: var(--transition-fast);
}

.view-all-link:hover {
  color: var(--primary-dark);
}

.logs-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.recent-notifications { max-height: 390px; overflow-y: auto; padding: 2px; }
.notification-card {
  padding: 12px 14px;
  border: 1px solid;
  border-left-width: 5px;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.notification-card-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.notification-card-heading strong { font-size: 14px; }
.notification-card-heading time { flex: 0 0 auto; font-size: 11px; opacity: .75; }
.notification-card p { margin: 5px 0 0; font-size: 13px; line-height: 1.45; }
.notification-warning, .notification-critical, .notification-error { color: #8e3200; background: #fff3e0; border-color: #ffb74d; }
.notification-success { color: #1b5e20; background: #e8f5e9; border-color: #81c784; }
.notification-info { color: #0d477a; background: #e3f2fd; border-color: #64b5f6; }
.notifications-empty { margin: 0; padding: 14px; color: var(--text-muted); text-align: center; }

.log-item-card {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-fast);
}

.log-item-card:hover {
  transform: translateY(-1px);
}

.log-item-card.pump {
  background: #eaf5fb;
  border-color: #c0e3f8;
}

.log-item-card.browning {
  background: #fdf5e7;
  border-color: #f7deb6;
}

.log-item-card.canopy {
  background: #eef8f0;
  border-color: #c9ecd2;
}

.log-icon-wrapper {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  flex-shrink: 0;
}

.log-icon-wrapper svg {
  width: 32px;
  height: 32px;
}

.log-content {
  flex: 1;
}

.log-primary-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.log-secondary-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 2px;
}

.log-time-stamp {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ==========================================================================
   4. Settings Screen
   ========================================================================== */
.settings-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.settings-gear-badge {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(138, 197, 155, 0.4);
  color: var(--primary-forest);
}

.settings-gear-badge svg {
  width: 22px;
  height: 22px;
}

/* Settings Category Segmented Bar */
.settings-segmented-bar {
  display: flex;
  background: rgba(214, 237, 219, 0.75);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 18px;
  border: 1px solid rgba(144, 203, 161, 0.5);
}

.segment-item {
  flex: 1;
  text-align: center;
  padding: 8px 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.segment-item.active {
  background: #ffffff;
  color: var(--primary-dark);
  box-shadow: 0 3px 8px rgba(35, 92, 53, 0.12);
}

/* Settings List Group */
.settings-group {
  margin-bottom: 18px;
}

.settings-group-title {
  font-family: var(--font-brand);
  font-size: 19px;
  font-weight: 800;
  color: var(--primary-dark);
  margin-bottom: 10px;
}

.settings-card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-row-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(175, 218, 186, 0.6);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-fast);
}

.setting-row-card:hover {
  background: #ffffff;
}

.config-input-pair {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.config-input {
  width: 92px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #c9dbcd;
  border-radius: 10px;
  background: #fbfdfb;
  color: var(--text-primary);
  font: 700 14px var(--font-main);
  text-align: right;
}

.setting-select {
  max-width: 150px;
  padding: 9px 30px 9px 10px;
  border: 1px solid #c9dbcd;
  border-radius: 10px;
  background: #fbfdfb;
  color: var(--text-primary);
  font: 700 13px var(--font-main);
  cursor: pointer;
}

.sensor-update-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  margin: 4px 2px 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.last-sensor-update {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.config-input:focus {
  outline: 2px solid rgba(73, 155, 98, 0.35);
  border-color: var(--primary-leaf);
}

.config-input[aria-invalid="true"] {
  border-color: #c62828;
  background: #fff7f7;
}

.setting-help-text {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.6;
  padding: 4px 6px;
}

@media (max-width: 560px) {
  .setting-row-card:has(.config-input-pair) {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .config-input-pair {
    width: 100%;
    justify-content: flex-end;
  }
}

.setting-left-side {
  display: flex;
  align-items: center;
  gap: 12px;
}

.setting-icon-container {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: #eaf6ee;
  border: 1px solid #c2e8cd;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-forest);
}

.setting-icon-container svg {
  width: 22px;
  height: 22px;
}

.setting-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.setting-right-side {
  display: flex;
  align-items: center;
  gap: 10px;
}

.setting-status-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Toggle Switch */
.switch-control {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
}

.switch-control input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-knob {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd8cf;
  border-radius: 34px;
  transition: var(--transition-normal);
}

.slider-knob::before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: var(--transition-normal);
}

input:checked+.slider-knob {
  background-color: #3b8b54;
}

input:checked+.slider-knob::before {
  transform: translateX(20px);
}

.chevron-arrow {
  color: var(--text-muted);
}

/* Prominent Save Button */
.settings-save-btn {
  width: 100%;
  padding: 14px 20px;
  margin-top: 14px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #2f7947 0%, #1e5c33 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-brand);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.3px;
  box-shadow: 0 8px 24px rgba(33, 94, 53, 0.35);
  cursor: pointer;
  transition: var(--transition-normal);
}

.settings-save-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(33, 94, 53, 0.45);
}

.settings-save-btn:active {
  transform: translateY(0);
}

/* ==========================================================================
   Bottom Navigation Bar (3 Tabs: Dashboard, Status, Settings)
   ========================================================================== */
.bottom-nav-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 76px;
  background: rgba(243, 252, 245, 0.94);
  backdrop-filter: blur(14px);
  border-top: 1px solid rgba(138, 197, 155, 0.5);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 16px 8px;
  z-index: 50;
}

.nav-tab-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 16px;
  transition: var(--transition-fast);
  color: #386743;
}

.nav-tab-btn:hover {
  transform: translateY(-2px);
}

.nav-icon-box {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2px;
}

.nav-icon-box svg {
  width: 28px;
  height: 28px;
  transition: var(--transition-fast);
}

.nav-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1px;
}

/* Active indicator underline pill */
.nav-tab-btn.active {
  color: var(--primary-dark);
}

.nav-tab-btn.active .nav-icon-box svg {
  transform: scale(1.1);
}

.nav-tab-btn::after {
  content: '';
  position: absolute;
  bottom: -6px;
  width: 48px;
  height: 4px;
  background: #275d35;
  border-radius: 4px;
  transform: scaleX(0);
  transition: transform 0.25s ease;
}

.nav-tab-btn.active::after {
  transform: scaleX(1);
}

/* Divider line between nav items */
.nav-divider {
  width: 1px;
  height: 30px;
  background: rgba(144, 203, 161, 0.4);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.toast {
  background: #1b4526;
  color: #ffffff;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: 100%;
  box-sizing: border-box;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(20px);
  }
}

/* Generic Modal (Logs / Help) */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(14, 30, 20, 0.6);
  backdrop-filter: blur(6px);
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-box {
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border-radius: 24px;
  padding: 22px;
  box-shadow: var(--shadow-lg);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-title {
  font-family: var(--font-brand);
  font-size: 20px;
  font-weight: 800;
  color: var(--primary-dark);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
}

/* Responsive: hide the desktop presentation toolbar on small screens */
@media (max-width: 760px) {
  .presentation-bar {
    display: none;
  }
}

/* Desktop application shell */
@media (min-width: 900px) {
  html,
  body {
    height: 100%;
    min-height: 100%;
    overflow: hidden;
    background: #f3f7f3;
  }

  body::before {
    display: none;
  }

  .app-viewport {
    height: 100vh;
    min-height: 640px;
    justify-content: stretch;
    align-items: stretch;
    padding: 0;
  }

  .app-screen {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
    background: #f5f8f5;
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    grid-template-rows: 76px minmax(0, 1fr);
  }

  .main-header {
    position: relative;
    grid-column: 1 / -1;
    grid-row: 1;
    height: 76px;
    padding: 0 36px 0 32px;
    background: #fff;
    border-bottom-color: #e5ece6;
  }

  .brand-text {
    font-size: 27px;
  }

  .screen-scroll-container {
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
    padding: 34px clamp(28px, 4vw, 64px) 48px;
    scrollbar-width: thin;
  }

  .bottom-nav-bar {
    position: relative;
    grid-column: 1;
    grid-row: 2;
    height: auto;
    min-height: 0;
    padding: 28px 18px;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 8px;
    background: #fff;
    border-top: 0;
    border-right: 1px solid #e5ece6;
    backdrop-filter: none;
  }

  .bottom-nav-bar::before {
    content: "FARM WORKSPACE";
    margin: 4px 12px 12px;
    color: #819486;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.2px;
  }

  .nav-tab-btn {
    min-height: 52px;
    width: 100%;
    padding: 0 14px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    border-radius: 12px;
    text-align: left;
  }

  .nav-tab-btn:hover {
    transform: none;
    background: #f3f8f4;
  }

  .nav-tab-btn.active {
    background: #eaf5ec;
    color: #205c32;
  }

  .nav-icon-box {
    width: 30px;
    height: 30px;
    margin: 0;
    flex: 0 0 30px;
  }

  .nav-icon-box svg {
    width: 24px;
    height: 24px;
  }

  .nav-label {
    font-size: 14px;
    font-weight: 700;
  }

  .nav-tab-btn::after {
    display: none;
  }

  .nav-divider {
    display: none;
  }

  .sub-heading-row {
    margin-bottom: 24px;
  }

  .page-title {
    font-size: clamp(28px, 2.3vw, 36px);
  }

  .tank-feed-card {
    max-width: none;
    aspect-ratio: 16 / 9;
    max-height: min(48vh, 500px);
  }

  .tank-image-wrapper {
    min-height: 0;
    max-height: none;
  }

  .telemetry-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
  }

  .tab-panel {
    max-width: 1600px;
    margin: 0 auto;
  }
}

@media (min-width: 900px) and (max-width: 1150px) {
  .app-screen {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .screen-scroll-container {
    padding-right: 28px;
    padding-left: 28px;
  }

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

/* Local account setup and sign-in */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 0%, #e4f1e6 0, #f4f7f2 48%, #e9efe8 100%);
  color: #183b24;
  font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
}
.auth-card {
  width: min(100%, 430px);
  padding: 38px clamp(24px, 7vw, 48px);
  border: 1px solid #dce8dc;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 22px 65px #1d48221c;
}
.auth-mark { font-size: 34px; }
.auth-eyebrow { margin: 18px 0 8px; color: #56815d; font-size: 11px; font-weight: 800; letter-spacing: .16em; }
.auth-card h1 { margin: 0; font-size: 32px; font-weight: 800; }
.auth-intro { margin: 10px 0 28px; color: #65756a; line-height: 1.6; }
.auth-card label { display: block; margin: 16px 0 7px; font-size: 13px; font-weight: 700; }
.auth-card input { box-sizing: border-box; width: 100%; padding: 13px 14px; border: 1px solid #d3dfd4; border-radius: 10px; background: #fbfdfb; color: #183b24; font: inherit; outline-color: #388e3c; }
.auth-error { min-height: 20px; margin: 12px 0 4px; color: #b42318; font-size: 13px; }
.auth-submit { width: 100%; padding: 13px; border: 0; border-radius: 10px; background: #276b38; color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.auth-submit:disabled { opacity: .65; cursor: wait; }
.auth-local-note { margin: 22px 0 0; color: #718076; font-size: 12px; line-height: 1.6; text-align: center; }
.logout-btn { padding: 8px 12px; border: 1px solid #d9e4d9; border-radius: 9px; background: #fff; color: #315b39; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.profile-logout-btn { width: 100%; margin-top: 18px; padding: 11px 14px; }
.local-user-form { display: grid; gap: 8px; margin-top: 22px; padding-top: 18px; border-top: 1px solid #e5ece5; }
.local-user-form h4 { margin: 0 0 4px; color: var(--primary-dark); }
.local-user-form label { font-size: 12px; font-weight: 700; }
.local-user-form input { width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid #d3dfd4; border-radius: 8px; font: inherit; }
.local-user-form select { width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid #d3dfd4; border-radius: 8px; background: #fff; font: inherit; }
.local-user-form button { margin-top: 4px; padding: 10px; border: 0; border-radius: 8px; background: #276b38; color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.local-user-form p { min-height: 18px; margin: 0; font-size: 12px; color: #315b39; }
.account-list { overflow: hidden; border: 1px solid var(--card-border); border-radius: 14px; background: #fff; }
.account-list-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 16px; border-bottom: 1px solid #edf1ec; }
.account-list-row:last-child { border-bottom: 0; }
.account-list-row > div { display: grid; gap: 4px; min-width: 0; }
.account-list-row strong { overflow-wrap: anywhere; color: var(--text-primary); font-size: 13px; }
.account-created-at, .account-admin-label, .account-role-label { color: var(--text-muted); font-size: 11px; }
.account-role-label { padding: 5px 9px; border-radius: 999px; background: #eef2ed; font-weight: 700; }
.account-role-label.is-admin { background: #e4f1e5; color: #276b38; }
.account-status { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; }
.account-status::before { width: 7px; height: 7px; border-radius: 50%; background: #9aa59b; content: ""; }
.account-status.is-active { color: #28713b; }
.account-status.is-active::before { background: #38a354; }
.account-status.is-idle { color: #986c16; }
.account-status.is-idle::before { background: #d6a638; }
.account-status.is-inactive { color: var(--text-muted); }
.account-admin-label { text-align: right; }
.account-delete-btn, .account-logout-btn { flex: 0 0 auto; padding: 7px 10px; border: 1px solid #d9e4d9; border-radius: 8px; background: #fff; color: #315b39; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.account-delete-btn { border-color: #efd4d0; background: #fff8f7; color: #a33b30; }
.account-delete-btn:disabled, .account-logout-btn:disabled { opacity: .55; cursor: wait; }
.account-add-form { max-width: 480px; }
.account-add-form .account-form-help { min-height: 0; color: var(--text-muted); line-height: 1.5; }
.account-add-form #add-user-message.is-error { color: #a33b30; }
.account-add-form button:disabled { opacity: .6; cursor: wait; }
.farm-name-form { display: grid; gap: 8px; margin-top: 16px; }
.farm-name-form label { font-size: 12px; font-weight: 700; }
.farm-name-form input { width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid #d3dfd4; border-radius: 8px; font: inherit; }
.farm-name-form button { padding: 10px; border: 0; border-radius: 8px; background: #276b38; color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.farm-name-form button:disabled { opacity: .6; cursor: wait; }
.farm-name-form p { min-height: 18px; margin: 0; font-size: 12px; color: #315b39; }
.farm-name-form p.is-error { color: #a33b30; }
@media (max-width: 560px) {
  .account-list-row { align-items: flex-start; flex-wrap: wrap; }
  .account-list-row > div { flex: 1 1 100%; }
}

/* ========================================================================
   AzollaSense visual system refresh
   ======================================================================== */
:root {
  color-scheme: light;
  --bg-primary: #f3f6f1;
  --bg-gradient-start: #f3f6f1;
  --bg-gradient-mid: #edf3ed;
  --bg-gradient-end: #e7efe7;
  --primary-dark: #183b28;
  --primary-forest: #24583a;
  --primary-emerald: #34764b;
  --primary-leaf: #4b9561;
  --primary-accent: #6ba77a;
  --primary-light: #e8f2e9;
  --primary-subtle: #f4f8f3;
  --card-bg: #ffffff;
  --card-border: #e2e9e1;
  --text-primary: #21372a;
  --text-secondary: #52675a;
  --text-muted: #78877d;
  --shadow-sm: 0 2px 8px rgba(25, 54, 34, .045);
  --shadow-md: 0 8px 24px rgba(25, 54, 34, .075);
  --shadow-lg: 0 20px 56px rgba(25, 54, 34, .18);
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 22px;
}

html { scroll-behavior: smooth; }
body {
  color: var(--text-primary);
  background: #f3f6f1;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
body::before { display: none; }
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(75, 149, 97, .35);
  outline-offset: 2px;
}

@media (max-width: 899px) {
  .app-viewport { min-height: 100dvh; align-items: stretch; }
  .app-screen {
    width: 100%;
    max-width: 820px;
    height: 100dvh;
    min-height: 0;
    max-height: none;
    border-radius: 0;
    background: #f6f8f5;
    box-shadow: none;
  }
  .main-header {
    height: 68px;
    padding-inline: clamp(16px, 4vw, 28px);
    background: rgba(255,255,255,.96);
    border-bottom: 1px solid #e6ebe5;
    box-shadow: 0 2px 8px rgba(24,59,40,.025);
  }
  .screen-scroll-container {
    padding: 84px clamp(16px, 4vw, 28px) calc(100px + env(safe-area-inset-bottom));
    scrollbar-width: thin;
    scrollbar-color: #d4dfd4 transparent;
  }
  .bottom-nav-bar {
    height: calc(76px + env(safe-area-inset-bottom));
    padding: 5px 12px calc(7px + env(safe-area-inset-bottom));
    background: rgba(255,255,255,.97);
    border-top: 1px solid #e6ebe5;
    box-shadow: 0 -5px 18px rgba(24,59,40,.045);
  }
}

.brand-text { color: var(--primary-dark); letter-spacing: -.7px; }
.brand-leaf-accent { filter: none; }
.profile-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #f1f6f0;
  border: 1px solid #e0e9df;
  box-shadow: none;
}
.profile-btn:hover { background: #e8f2e8; transform: none; box-shadow: none; }
.profile-avatar-svg { width: 25px; height: 25px; }

.sub-heading-row, .settings-header-row { margin-top: 0; margin-bottom: 18px; }
.page-title, .status-screen-title {
  color: var(--primary-dark);
  font-family: var(--font-brand);
  font-size: clamp(25px, 3vw, 34px);
  font-weight: 750;
  letter-spacing: -.8px;
  line-height: 1.15;
}
.quick-chevron-btn, .settings-gear-badge, .back-circle-btn {
  background: #fff;
  border: 1px solid var(--card-border);
  color: var(--primary-forest);
  box-shadow: var(--shadow-sm);
}
.quick-chevron-btn:hover, .back-circle-btn:hover { background: var(--primary-subtle); transform: none; }

.tank-feed-card {
  aspect-ratio: 16 / 10;
  max-height: 520px;
  margin-bottom: 20px;
  overflow: hidden;
  border: 1px solid #d6e0d6;
  border-radius: var(--radius-lg);
  background: #263a2d;
  box-shadow: var(--shadow-md);
}
.tank-feed-card img { object-fit: contain; }
.tank-image-wrapper:fullscreen img { object-fit: contain; }
.feed-live-badge { top: 14px; left: 14px; padding: 7px 11px; font-size: 10px; letter-spacing: .06em; }
.feed-toggle-btn, .feed-fullscreen-btn { top: 14px; right: 14px; padding: 8px 12px; border-radius: 10px; }
.feed-fullscreen-btn { top: auto; bottom: 14px; }
.stream-play-btn, .stream-stop-btn {
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
}

.sensor-update-meta {
  justify-content: flex-start;
  margin: 0 2px 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 550;
}
.last-sensor-update { color: var(--text-secondary); }
.telemetry-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 205px), 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.sensor-card {
  min-width: 0;
  min-height: 100px;
  padding: 16px;
  border: 1px solid var(--card-border) !important;
  border-radius: var(--radius-md);
  background: #fff !important;
  color: var(--text-primary) !important;
  box-shadow: var(--shadow-sm);
}
.sensor-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.sensor-card::after { right: -24px; bottom: -32px; width: 94px; height: 94px; opacity: .055; }
.sensor-icon-box {
  width: 42px;
  height: 42px;
  margin-right: 12px;
  border-radius: 13px;
  background: #eff5ef;
}
.sensor-card.water .sensor-icon-box { background: #eaf4f8; }
.sensor-card.temperature .sensor-icon-box { background: #fbf0e9; }
.sensor-card.ph .sensor-icon-box { background: #eaf4ee; }
.sensor-card.coverage .sensor-icon-box { background: #eff4e9; }
.sensor-icon-box svg { width: 30px; height: 30px; filter: none; }
.sensor-label { margin-bottom: 4px; color: var(--text-secondary); font-size: 12px; font-weight: 650; }
.sensor-value { color: var(--primary-dark); font-size: clamp(22px, 2.4vw, 27px); font-weight: 750; letter-spacing: -.6px; font-variant-numeric: tabular-nums; }

.light-intensity-card {
  margin: 0 0 24px;
  padding: 18px;
  border: 1px solid #eee5c9;
  border-radius: var(--radius-md);
  background: #fffdf7;
  color: #574814;
  box-shadow: var(--shadow-sm);
}
.light-intensity-icon { border-radius: 12px; }
.light-intensity-heading { margin-bottom: 14px; }
.light-intensity-heading h3 { color: var(--text-primary); font-size: 15px; font-weight: 700; }
.light-intensity-heading p, .light-intensity-footer { color: #81764f; }
.light-intensity-value { color: #493b12; font-size: 23px; font-variant-numeric: tabular-nums; }
.light-meter-track { height: 8px; background: #f1ebd9; }
.rain-dashboard-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid #eee8d6;
  color: #81764f;
  font-size: 12px;
}
.rain-dashboard-status strong { color: var(--text-primary); font-weight: 700; }
.rain-dashboard-status .rain-sensor-reading { margin-left: auto; font-variant-numeric: tabular-nums; }

.section-title-row { gap: 10px; margin: 28px 0 14px; }
.section-icon-svg { color: var(--primary-forest); }
.section-title-text { color: var(--primary-dark); font-size: 20px; font-weight: 750; letter-spacing: -.3px; }
.capture-trigger-btn {
  padding: 9px 14px;
  border: 1px solid #d5e4d6;
  border-radius: 10px;
  background: #edf5ed;
  color: var(--primary-forest);
  transition: background .18s ease, border-color .18s ease;
}
.capture-trigger-btn:hover { background: #e3efe3; border-color: #b9d3bb; }
.capture-details { gap: 10px; margin: 14px 0 26px; }
.capture-detail {
  min-width: 0;
  padding: 14px 15px;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.capture-detail span { font-size: 11px; font-weight: 600; }
.capture-detail strong { color: var(--primary-dark); font-size: 15px; overflow-wrap: anywhere; }

.status-top-bar { margin-bottom: 18px; }
.status-screen-title { font-size: 28px; }
.logs-pill-btn {
  border: 1px solid #dce7dc;
  border-radius: 11px;
  background: #fff;
  color: var(--primary-forest);
  box-shadow: var(--shadow-sm);
}
.tank-status-container { margin-bottom: 18px; }
.status-capture-time-badge { z-index: 2; }
.status-capture-details { margin: 0 0 22px; }
.system-status-badge {
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 14px;
  background: rgba(24,59,40,.91);
  box-shadow: 0 8px 24px rgba(20,48,31,.2);
  color: #f5fff5;
  font-size: 13px;
}
.system-status-badge span { font-weight: 700; }
.system-status-badge.is-alert { background: #8e3200; border-color: #ffb74d; }
.system-status-badge.is-normal { background: #1b5e20; border-color: #81c784; }
.logs-header-row { margin: 26px 0 12px; }
.logs-title-group { color: var(--primary-dark); font-size: 17px; font-weight: 750; }
.logs-title-group svg { color: var(--primary-forest); }
.view-all-link { color: var(--primary-forest); font-weight: 700; text-decoration: none; }
.view-all-link:hover { color: var(--primary-dark); }
.logs-list { gap: 10px; }
.log-item-card {
  min-width: 0;
  padding: 13px 15px;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.log-item-card:hover { transform: none; box-shadow: var(--shadow-md); }
.log-primary-text { color: var(--text-primary); font-weight: 700; }
.log-secondary-text, .log-time-stamp { color: var(--text-muted); }

.settings-header-row { align-items: center; }
.settings-gear-badge { border-radius: 12px; }
.settings-segmented-bar {
  position: sticky;
  top: 2px;
  z-index: 5;
  gap: 3px;
  margin-bottom: 22px;
  padding: 4px;
  border: 1px solid #e1e9e0;
  border-radius: 13px;
  background: #eaf0e9;
}
.segment-item {
  min-width: 0;
  padding: 10px 8px;
  border: 0;
  background: transparent;
  color: #637368;
  font-size: clamp(11px, 1.2vw, 13px);
  font-weight: 650;
}
.segment-item.active {
  background: #fff;
  color: var(--primary-dark);
  box-shadow: 0 1px 4px rgba(20,48,31,.1);
}
.settings-group { margin-bottom: 24px; }
.settings-group-title { margin: 0 0 10px 2px; color: var(--primary-dark); font-size: 16px; font-weight: 750; }
.settings-card-list { gap: 0; overflow: hidden; border: 1px solid var(--card-border); border-radius: 16px; background: #fff; box-shadow: var(--shadow-sm); }
.settings-card-list > .settings-group-title { margin: 0; padding: 14px 16px 8px; background: #fff; font-size: 14px; }
.settings-card-list > .setting-help-text { padding: 12px 16px 15px; }
.device-action-row { gap: 16px; }
.device-action-btn { flex: 0 0 auto; padding: 9px 16px; border: 1px solid #c62828; border-radius: 9px; color: #b71c1c; background: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.device-action-btn:hover { background: #fff5f5; }
.device-action-btn:disabled { opacity: .55; cursor: wait; }
.setting-row-card {
  min-width: 0;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid #edf1ec;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
  transition: background .18s ease;
}
.setting-row-card:last-child { border-bottom: 0; }
.setting-row-card:hover { background: #fbfcfa; }
.setting-icon-container { width: 36px; height: 36px; border: 0; border-radius: 11px; background: #eff5ef; }
.setting-label { color: var(--text-primary); font-size: 13px; font-weight: 650; }
.setting-status-text { color: var(--text-secondary); font-size: 12px; font-weight: 600; }
.setting-select, .config-input {
  min-height: 40px;
  border: 1px solid #dbe4da;
  border-radius: 10px;
  background-color: #fbfcfa;
  color: var(--text-primary);
  font-family: var(--font-main);
}
.config-input { padding: 8px 10px; font-size: 13px; }
.setting-select { font-size: 12px; }
.setting-help-text { padding: 10px 3px; color: var(--text-muted); }
.switch-control { width: 46px; height: 26px; flex: 0 0 46px; }
.slider-knob { background: #d7e0d7; }
.slider-knob::before { width: 20px; height: 20px; }
.switch-control input:checked + .slider-knob { background: var(--primary-emerald); }
.switch-control input:focus-visible + .slider-knob { outline: 3px solid rgba(75,149,97,.3); outline-offset: 2px; }
.settings-save-btn {
  position: sticky;
  bottom: 12px;
  z-index: 4;
  min-width: 140px;
  margin: 14px 0 10px auto;
  padding: 12px 22px;
  border: 0;
  border-radius: 12px;
  background: var(--primary-forest);
  box-shadow: 0 5px 14px rgba(36,88,58,.18);
}
.settings-save-btn:hover { background: var(--primary-dark); transform: translateY(-1px); }

.nav-tab-btn { color: #6a796e; }
.nav-tab-btn:hover { color: var(--primary-dark); }
.nav-tab-btn.active { color: var(--primary-forest); }
.nav-tab-btn.active .nav-icon-box svg { transform: none; }
.nav-icon-box { margin-bottom: 3px; }
.nav-label { font-size: 11px; font-weight: 650; }
.nav-divider { background: #e6ece5; }
.toast-container { width: min(100% - 32px, 440px); bottom: calc(88px + env(safe-area-inset-bottom)); }
.toast { justify-content: center; border: 1px solid rgba(255,255,255,.13); border-radius: 13px; background: #1e4930; box-shadow: 0 10px 26px rgba(18,45,29,.22); font-size: 13px; }

.modal-backdrop { background: rgba(17,39,25,.48); backdrop-filter: blur(8px); }
.modal-box {
  width: min(100%, 500px);
  max-height: min(86dvh, 760px);
  padding: 24px;
  border: 1px solid rgba(225,233,224,.9);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
}
.modal-header { margin-bottom: 18px; padding-bottom: 13px; border-bottom: 1px solid #edf1ec; }
.modal-title { font-size: 18px; }
.modal-close { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 10px; }
.modal-close:hover { background: #f1f5f0; color: var(--primary-dark); }
.modal-body { overscroll-behavior: contain; }
.logs-modal-box { width: min(1180px, 100%); max-width: 1180px; }
.logs-filter-form {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(140px, 1fr) auto auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
}
.logs-filter-form label { display: grid; gap: 5px; color: var(--text-muted); font-size: 12px; font-weight: 700; }
.logs-filter-form input {
  min-width: 0;
  min-height: 40px;
  padding: 7px 9px;
  border: 1px solid var(--card-border);
  border-radius: 9px;
  color: var(--text-primary);
  background: #fff;
  font: inherit;
}
.logs-action-btn, .logs-page-btn {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--primary-forest);
  border-radius: 9px;
  background: var(--primary-forest);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.logs-action-btn.secondary, .logs-page-btn { border-color: var(--card-border); background: #fff; color: var(--primary-forest); }
.logs-action-btn:disabled, .logs-page-btn:disabled { opacity: .5; cursor: default; }
.logs-table-status { min-height: 20px; margin: 8px 0; color: var(--text-muted); font-size: 12px; }
.logs-table-wrap { max-height: min(54vh, 520px); overflow: auto; border: 1px solid var(--card-border); border-radius: 10px; }
.telemetry-log-table { width: 100%; min-width: 860px; border-collapse: collapse; font-size: 12px; }
.telemetry-log-table th, .telemetry-log-table td { padding: 9px 10px; border-bottom: 1px solid #edf1ec; text-align: right; white-space: nowrap; }
.telemetry-log-table th { position: sticky; top: 0; z-index: 1; background: #f2f7f1; color: var(--primary-dark); font-size: 11px; }
.telemetry-log-table th:first-child, .telemetry-log-table td:first-child { text-align: left; }
.telemetry-log-table tbody tr:nth-child(even) { background: #fafcf9; }
.logs-pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; color: var(--text-muted); font-size: 12px; }
.logs-pagination > div { display: flex; gap: 8px; }

.auth-page { background: #f3f6f1; }
.auth-card { border-color: #e2e9e1; border-radius: 20px; box-shadow: 0 16px 48px rgba(25,54,34,.1); }
.auth-mark { display: grid; width: 125px; height: 125px; margin: 0 auto 18px; place-items: center; border-radius: 16px; }
.auth-mark img { display: block; width: 120px; height: 120px; object-fit: contain; }
.auth-eyebrow { color: var(--primary-forest); }
.auth-card h1 { color: var(--primary-dark); letter-spacing: -.7px; }
.auth-card input { min-height: 46px; border-radius: 10px; }
.auth-card input:focus { border-color: var(--primary-leaf); outline: 3px solid rgba(75,149,97,.16); }
.auth-submit, .local-user-form button {
  min-height: 46px;
  border-radius: 10px;
  background: var(--primary-forest);
  transition: background .18s ease, transform .18s ease;
}
.auth-submit:hover:not(:disabled), .local-user-form button:hover { background: var(--primary-dark); transform: translateY(-1px); }
.auth-submit:disabled { opacity: .66; }
.local-user-form input { min-height: 42px; border-color: #dce5da; border-radius: 9px; }
.local-user-form button { border: 0; }

@media (min-width: 900px) {
  html, body { background: #f3f6f1; }
  .app-viewport { min-height: 100dvh; }
  .app-screen {
    background: #f6f8f5;
    grid-template-columns: 248px minmax(0, 1fr);
    grid-template-rows: 76px minmax(0, 1fr);
  }
  .main-header { background: #fff; border-bottom-color: #e6ebe5; }
  .screen-scroll-container { padding: 34px clamp(28px, 4vw, 64px) 48px; }
  .bottom-nav-bar {
    position: relative;
    grid-column: 1;
    grid-row: 2;
    height: auto;
    min-height: 0;
    padding: 28px 18px;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 8px;
    background: #fff;
    border-top: 0;
    border-right: 1px solid #e6ebe5;
    box-shadow: none;
  }
  .bottom-nav-bar::before {
    content: "FARM WORKSPACE";
    margin: 4px 12px 12px;
    color: #819087;
    font-size: 10px;
    font-weight: 750;
    letter-spacing: 1.1px;
  }
  .nav-tab-btn {
    min-height: 48px;
    width: 100%;
    padding: 0 13px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    border-radius: 11px;
    text-align: left;
  }
  .nav-tab-btn:hover { transform: none; background: #f3f7f2; }
  .nav-tab-btn.active { background: #eaf3e9; color: var(--primary-dark); }
  .nav-icon-box { width: 30px; height: 30px; margin: 0; flex: 0 0 30px; }
  .nav-icon-box svg { width: 23px; height: 23px; }
  .nav-label { font-size: 13px; font-weight: 650; }
  .nav-tab-btn::after, .nav-divider { display: none; }
  .toast-container { bottom: 24px; }
}

@media (max-width: 560px) {
  .logs-modal-box { padding: 16px; }
  .logs-filter-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .logs-filter-form label { min-width: 0; }
  .logs-action-btn { width: 100%; padding-inline: 7px; }
  .logs-table-wrap { max-height: 52vh; }
  .logs-pagination { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
  .page-title { font-size: 26px; }
  .tank-feed-card { aspect-ratio: 4 / 3; border-radius: 17px; }
  .telemetry-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .sensor-card { min-height: 91px; padding: 12px 10px; border-radius: 14px; }
  .sensor-icon-box { width: 34px; height: 34px; flex-basis: 34px; margin-right: 8px; border-radius: 10px; }
  .sensor-icon-box svg { width: 26px; height: 26px; }
  .sensor-label { font-size: 10px; }
  .sensor-value { font-size: 21px; }
  .capture-trigger-btn { padding: 8px 10px; font-size: 11px; }
  .section-title-text { font-size: 17px; }
  .capture-details { gap: 8px; }
  .capture-detail { padding: 11px 12px; }
  .capture-detail strong { font-size: 14px; }
  .settings-segmented-bar { overflow-x: auto; }
  .segment-item { flex: 1 0 auto; }
  .setting-row-card { padding: 12px; }
  .setting-label { font-size: 12px; }
  .config-input { width: 78px; }
  .modal-box { padding: 18px; border-radius: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Product polish: consistent surfaces, clearer hierarchy and responsive shell. */
:root {
  --text-muted: #68786d;
  --card-border: #e1e8df;
  --shadow-sm: 0 2px 8px rgba(24, 59, 40, .045);
  --shadow-md: 0 10px 28px rgba(24, 59, 40, .08);
}

body { background: #f3f6f1; }
.app-screen { background: #f6f8f5; }
.main-header { flex: 0 0 auto; }
.brand-wrapper { min-width: 0; }
.brand-text { font-size: 24px; }
.screen-scroll-container {
  overscroll-behavior-y: contain;
  background-color: #f6f8f5;
}
.tab-panel { width: 100%; }
.sub-heading-row, .status-top-bar, .settings-header-row { align-items: center; }
.section-title-row { min-width: 0; }
.section-title-text { line-height: 1.3; }
.tank-feed-card, .sensor-card, .light-intensity-card, .capture-detail,
.log-item-card, .settings-card-list, .account-list {
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.sensor-card:hover, .log-item-card:hover { border-color: #d5e1d4 !important; }
button, .nav-tab-btn, .capture-trigger-btn, .logs-pill-btn, .device-action-btn {
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
button:disabled { cursor: not-allowed; }

@media (min-width: 900px) {
  html, body { overflow: hidden; }
  .app-viewport { min-height: 100dvh; }
  .app-screen {
    grid-template-columns: 256px minmax(0, 1fr);
    grid-template-rows: 72px minmax(0, 1fr);
  }
  .main-header { height: 72px; padding-inline: 30px 38px; }
  .screen-scroll-container { padding: 36px clamp(32px, 5vw, 72px) 56px; }
  .tab-panel { max-width: 1280px; }
  .page-title, .status-screen-title { font-size: clamp(30px, 2.5vw, 38px); }
  .tank-feed-card { aspect-ratio: 16 / 8; max-height: 460px; }
  .telemetry-grid { gap: 16px; }
  .bottom-nav-bar { padding: 26px 16px; }
  .nav-tab-btn { min-height: 50px; }
}

@media (min-width: 561px) and (max-width: 899px) {
  .app-screen { max-width: 820px; }
  .screen-scroll-container { padding-inline: clamp(24px, 5vw, 40px); }
  .telemetry-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .main-header { height: 62px; }
  .screen-scroll-container {
    padding: 78px 16px calc(96px + env(safe-area-inset-bottom));
  }
  .page-title, .status-screen-title { font-size: 25px; }
  .sub-heading-row, .settings-header-row { margin-bottom: 16px; }
  .sensor-card { gap: 0; }
  .sensor-label { line-height: 1.35; }
  .sensor-value { font-size: clamp(19px, 5.8vw, 22px); }
  .bottom-nav-bar { z-index: 120; }
  .nav-tab-btn { min-height: 54px; }
  .nav-label { font-size: 10px; }
  .logs-filter-form { gap: 8px; }
}

@media (max-width: 360px) {
  .screen-scroll-container { padding-inline: 12px; }
  .telemetry-grid { gap: 8px; }
  .sensor-card { padding-inline: 8px; }
  .sensor-icon-box { margin-right: 6px; }
  .capture-details { grid-template-columns: 1fr; }
  .brand-text { font-size: 21px; }
}

/* Shared type and spacing scale for settings, status and dashboard panels. */
:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --font-xs: 12px;
  --font-sm: 13px;
  --font-md: 15px;
  --font-lg: 18px;
}

body { font-size: var(--font-md); }
.section-title-text, .settings-group-title, .logs-title-group { font-size: var(--font-lg); }
.sensor-label, .setting-label, .setting-status-text, .setting-help-text,
.sensor-update-meta, .capture-detail span, .log-secondary-text,
.log-time-stamp { font-size: var(--font-xs); }
.setting-label { font-weight: 650; }
.setting-status-text { font-weight: 550; }
.settings-group { margin-bottom: var(--space-6); }
.settings-group-title { margin-bottom: var(--space-3); }
.settings-card-list { border-radius: var(--radius-md); }
.setting-row-card { min-height: 64px; padding: var(--space-3) var(--space-4); }
.setting-left-side { gap: var(--space-3); }
.setting-right-side { gap: var(--space-3); }
.setting-icon-container { width: 38px; height: 38px; flex: 0 0 38px; }
.config-input, .setting-select { min-height: 42px; font-size: var(--font-sm); }
.config-input-pair { gap: var(--space-2); }
.setting-help-text { padding: var(--space-2) var(--space-1); line-height: 1.55; }
.section-title-row { margin-block: 28px var(--space-3); }
.capture-details { gap: var(--space-3); }
.logs-header-row { margin-block: 26px var(--space-3); }
.log-item-card { padding: var(--space-3) var(--space-4); }

/* Keep controls legible and show that a switch command is being applied. */
.switch-control { width: 48px; height: 28px; flex: 0 0 48px; cursor: pointer; }
.switch-control input { cursor: pointer; }
.switch-control:has(input:disabled) { cursor: wait; }
.switch-control input:disabled + .slider-knob { cursor: wait; opacity: .82; }
.switch-control.is-pending .slider-knob::before {
  width: 16px;
  height: 16px;
  left: 6px;
  bottom: 6px;
  border: 2px solid rgba(41, 88, 55, .32);
  border-top-color: #28623b;
  background: transparent;
  box-shadow: none;
  animation: switch-loading-spin .7s linear infinite;
}
.switch-control.is-pending input:checked + .slider-knob::before {
  transform: translateX(20px);
}
@keyframes switch-loading-spin { to { rotate: 360deg; } }
@media (prefers-reduced-motion: reduce) {
  .switch-control.is-pending .slider-knob::before { animation-duration: 1.5s; }
}

@media (max-width: 560px) {
  .setting-row-card { min-height: 60px; padding: 10px 12px; }
  .setting-left-side { gap: 9px; }
  .setting-label { font-size: 12px; }
  .setting-status-text { font-size: 11px; }
  .settings-group-title { font-size: 16px; }
  .section-title-row { margin-top: 24px; }
}

/* Settings screen refinements */
.settings-header-row { margin-bottom: 22px; }
.settings-gear-badge { width: 42px; height: 42px; }
.settings-segmented-bar {
  display: flex;
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.settings-segmented-bar::-webkit-scrollbar { display: none; }
.segment-item {
  flex: 1 0 auto;
  min-height: 42px;
  white-space: nowrap;
  line-height: 1.2;
}
.settings-subgroup { min-width: 0; }
.settings-group { min-width: 0; }
.settings-card-list > .settings-group-title {
  padding: 16px 16px 10px;
  border-top: 1px solid #edf1ec;
  background: #f8faf7;
  font-size: 13px;
  line-height: 1.35;
}
.settings-card-list > .settings-group-title:first-child {
  border-top: 0;
}
.setting-row-card {
  gap: 14px;
}
.setting-row-card > .setting-left-side,
.setting-row-card > .setting-label {
  min-width: 0;
  flex: 1 1 auto;
}
.setting-label {
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.setting-right-side { flex: 0 0 auto; }
.config-input { width: 96px; }
.config-input-pair { flex: 0 0 auto; }
.setting-select { max-width: min(180px, 44vw); }
.setting-row-card > .setting-status-text {
  min-width: 0;
  text-align: right;
}
.settings-save-btn {
  display: block;
  width: fit-content;
  min-width: 148px;
  min-height: 46px;
  margin: 22px 0 16px auto;
  padding: 11px 24px;
  border-radius: 12px;
  background: var(--primary-forest);
  box-shadow: 0 5px 14px rgba(36, 88, 58, .18);
  font: 700 14px/1.2 var(--font-main);
  letter-spacing: 0;
}
.settings-save-btn:hover { box-shadow: 0 7px 18px rgba(36, 88, 58, .22); }

@media (min-width: 900px) {
  .settings-subgroup { max-width: 1040px; }
  .settings-segmented-bar { position: sticky; top: 0; }
  .settings-save-btn { bottom: 16px; }
}

@media (max-width: 560px) {
  .settings-header-row { margin-bottom: 16px; }
  .settings-segmented-bar { margin-inline: -2px; width: calc(100% + 4px); }
  .segment-item { padding-inline: 12px; font-size: 12px; }
  .setting-row-card { align-items: center; gap: 10px; }
  .setting-row-card:has(.config-input-pair) {
    align-items: stretch;
    gap: 8px;
  }
  .config-input-pair { justify-content: flex-end; }
  .config-input { width: min(96px, 29vw); }
  .setting-select { max-width: 48vw; }
  .settings-card-list > .settings-group-title { padding: 13px 12px 8px; }
  .settings-save-btn { width: 100%; margin-top: 18px; }
}

@media (max-width: 360px) {
  .setting-row-card { gap: 8px; }
  .config-input { width: 27vw; padding-inline: 6px; font-size: 12px; }
  .config-input-pair { gap: 5px; }
  .setting-row-card:has(.config-input-pair) { gap: 6px; }
}

@media (min-width: 900px) {
  #account-management-panel .settings-group {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr);
    align-items: start;
    gap: 12px 24px;
  }
  #account-management-panel .settings-group > h3,
  #account-management-panel .settings-group > p {
    grid-column: 1 / -1;
  }
  #account-management-panel .account-list { grid-column: 1; grid-row: 3; }
  #account-management-panel .account-add-form {
    grid-column: 2;
    grid-row: 3;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 20px;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    background: #fff;
    box-shadow: var(--shadow-sm);
  }
  #account-management-panel .account-add-form input { min-height: 42px; }
  #account-management-panel .account-add-form select { min-height: 42px; }
}

.role-user [data-admin-only],
.role-pending [data-admin-only],
.role-user #account-management-tab,
.role-pending #account-management-tab,
.role-user #account-management-panel,
.role-pending #account-management-panel {
  display: none !important;
}

/* Keep the Settings title and category bar pinned above the settings content. */
#view-settings .settings-header-row {
  position: static;
  margin: 0;
  padding: 8px 0;
  background: #f6f8f5;
  border-bottom: 1px solid rgba(225, 232, 223, .8);
}
#view-settings .settings-segmented-bar {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 7;
  margin-top: 0;
  background: #eaf0e9;
  box-shadow: 0 5px 12px rgba(24, 59, 40, .06);
}
#view-settings .settings-segmented-bar.is-docked {
  animation: settings-tabs-dock-in .22s cubic-bezier(.2, .75, .25, 1) both;
}
@keyframes settings-tabs-dock-in {
  from { transform: translateY(-9px); opacity: .82; }
  to { transform: translateY(0); opacity: 1; }
}
@media (max-width: 899px) {
  .main-header { background: #fff; }
  #view-settings .settings-segmented-bar { top: 68px; }
}
@media (max-width: 560px) {
  #view-settings .settings-segmented-bar { top: 62px; }
}
@media (prefers-reduced-motion: reduce) {
  #view-settings .settings-segmented-bar.is-docked { animation: none; }
}

/* Keep the mobile app shell inside the visible viewport as browser chrome changes. */
@media (max-width: 899px) {
  html.app-document {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }
  body.app-page {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }
  .app-viewport {
    --mobile-nav-height: calc(76px + env(safe-area-inset-bottom));
    position: fixed;
    inset: 0;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    min-height: 0;
    overflow: hidden;
  }
  .app-screen {
    height: 100%;
    min-height: 0;
  }
  .bottom-nav-bar {
    position: fixed;
    bottom: 0;
    height: var(--mobile-nav-height);
  }
  .screen-scroll-container {
    min-height: 0;
    padding-bottom: calc(var(--mobile-nav-height) + 40px);
    scroll-padding-bottom: calc(var(--mobile-nav-height) + 40px);
    -webkit-overflow-scrolling: touch;
  }
  #view-settings { transition: opacity .3s ease; }
  #view-settings.active { transform: none; }
}
