/* =========================================================
   Greenhouse Dashboard — Design System
   Night Garden Glass auth + light premium greenhouse dashboard | Inter | Full-width
   ========================================================= */

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

:root {
  --color-primary: #0f766e;
  --color-primary-hover: #0d9488;
  --color-primary-dark: #115e59;
  --color-accent: #059669;
  --color-accent-soft: #ecfdf5;
  --color-accent-border: #a7f3d0;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-text-subtle: #94a3b8;
  --color-surface: #ffffff;
  --color-surface-muted: #f8fafc;
  --color-bg: #f1f5f9;
  --color-border: #e2e8f0;
  --color-danger: #ef4444;
  --color-danger-hover: #dc2626;
  --color-danger-soft: #fef2f2;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 18px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.08);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Courier New", ui-monospace, monospace;
  --space-page: 16px;
  --transition: 0.2s ease;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  padding: 0 var(--space-page);
  min-height: 100vh;
  line-height: 1.5;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition);
}

a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

button {
  font-family: inherit;
}

.hidden {
  display: none !important;
}

/* =========================================================
   AUTH — Night Garden Glass
   Dark teal forest + frosted card + soft glow orbs
   Scoped under .auth-body — light dashboard uses body:not(.auth-body)
   ========================================================= */

.auth-body {
  --night-bg: #020c0a;
  --night-deep: #022c22;
  --night-teal: #0f766e;
  --night-emerald: #059669;
  --night-mint: #6ee7b7;
  --night-glow: rgba(15, 118, 110, 0.45);
  --night-text: #ecfdf5;
  --night-muted: #94a3b8;
  --night-subtle: #64748b;
  --glass-bg: rgba(6, 40, 34, 0.55);
  --glass-border: rgba(110, 231, 183, 0.22);
  --glass-input: rgba(2, 20, 18, 0.55);

  position: relative;
  isolation: isolate;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
  overflow-x: hidden;
  overflow-y: auto;
  color: var(--night-text);
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(15, 118, 110, 0.35), transparent 55%),
    radial-gradient(ellipse 60% 50% at 100% 100%, rgba(5, 150, 105, 0.18), transparent 50%),
    linear-gradient(165deg, #020c0a 0%, #022c22 42%, #031a16 100%);
}

/* Soft botanical grid veil */
.auth-body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(110, 231, 183, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(110, 231, 183, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 70% at 50% 45%, #000 20%, transparent 75%);
}

/* Faint leaf silhouette (CSS-only) */
.auth-body::after {
  content: "🌿";
  position: fixed;
  right: -2%;
  bottom: -4%;
  font-size: clamp(10rem, 28vw, 22rem);
  line-height: 1;
  opacity: 0.06;
  filter: blur(1px);
  pointer-events: none;
  z-index: 0;
  transform: rotate(-18deg);
  user-select: none;
}

/* Animated glow orbs */
.auth-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.auth-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
  will-change: transform;
  animation: auth-orb-float 18s ease-in-out infinite;
}

.auth-orb--1 {
  width: min(42vw, 420px);
  height: min(42vw, 420px);
  top: -8%;
  left: -6%;
  background: radial-gradient(circle, rgba(15, 118, 110, 0.7) 0%, transparent 70%);
  animation-duration: 22s;
}

.auth-orb--2 {
  width: min(36vw, 360px);
  height: min(36vw, 360px);
  bottom: 5%;
  right: -4%;
  background: radial-gradient(circle, rgba(5, 150, 105, 0.55) 0%, transparent 70%);
  animation-duration: 26s;
  animation-delay: -6s;
}

.auth-orb--3 {
  width: min(28vw, 280px);
  height: min(28vw, 280px);
  top: 42%;
  left: 55%;
  background: radial-gradient(circle, rgba(52, 211, 153, 0.35) 0%, transparent 70%);
  animation-duration: 20s;
  animation-delay: -12s;
}

@keyframes auth-orb-float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(4%, -6%) scale(1.06); }
  66% { transform: translate(-5%, 3%) scale(0.96); }
}

@media (prefers-reduced-motion: reduce) {
  .auth-orb {
    animation: none;
  }
}

/* Frosted glass card */
.auth-body .auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 40px 36px 36px;
  border-radius: 20px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 24px 64px rgba(0, 0, 0, 0.45),
    0 0 80px rgba(15, 118, 110, 0.12);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  color: var(--night-text);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}


.auth-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #6ee7b7;
}
.auth-brand-icon { display: block; color: #ecfdf5; filter: drop-shadow(0 0 10px rgba(110, 231, 183, 0.55)); }
.auth-brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  font-size: 1.55rem;
  line-height: 1;
  background: linear-gradient(145deg, rgba(15, 118, 110, 0.55), rgba(5, 150, 105, 0.25));
  border: 1px solid rgba(110, 231, 183, 0.35);
  box-shadow: 0 8px 24px rgba(15, 118, 110, 0.35);
}

.auth-brand-name {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--night-mint);
  opacity: 0.9;
}

.auth-body .auth-card h1 {
  font-size: 1.85rem;
  font-weight: 700;
  color: #f0fdf4;
  letter-spacing: -0.035em;
  margin-bottom: 8px;
  text-align: center;
}

.auth-body .auth-card .subtitle {
  color: var(--night-muted);
  font-size: 0.95rem;
  margin-bottom: 28px;
  text-align: center;
  line-height: 1.45;
}

.auth-body .input-group {
  margin-bottom: 18px;
}

.auth-body .input-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #a7f3d0;
  margin-bottom: 8px;
}

.auth-body .input-group input {
  width: 100%;
  padding: 13px 15px;
  font-size: 1rem;
  font-family: inherit;
  color: #ecfdf5;
  background: var(--glass-input);
  border: 1px solid rgba(110, 231, 183, 0.18);
  border-radius: 12px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.auth-body .input-group input::placeholder {
  color: #64748b;
}

.auth-body .input-group input:hover {
  border-color: rgba(110, 231, 183, 0.35);
}

.auth-body .input-group input:focus {
  background: rgba(2, 24, 20, 0.75);
  border-color: #2dd4bf;
  box-shadow:
    0 0 0 3px rgba(45, 212, 191, 0.22),
    0 0 24px rgba(15, 118, 110, 0.25);
}

.auth-body .btn-primary {
  position: relative;
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 14px 18px;
  font-size: 1.02rem;
  font-weight: 650;
  font-family: inherit;
  color: #022c22;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  overflow: hidden;
  background: linear-gradient(135deg, #14b8a6 0%, #059669 55%, #0f766e 100%);
  box-shadow:
    0 10px 28px rgba(5, 150, 105, 0.4),
    0 1px 0 rgba(255, 255, 255, 0.25) inset;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.auth-body .btn-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.28) 50%, transparent 70%);
  transform: translateX(-120%);
  transition: transform 0.55s ease;
}

.auth-body .btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
  box-shadow:
    0 14px 36px rgba(5, 150, 105, 0.5),
    0 1px 0 rgba(255, 255, 255, 0.3) inset;
}

.auth-body .btn-primary:hover::after {
  transform: translateX(120%);
}

.auth-body .btn-primary:active {
  transform: translateY(0);
}

.auth-body .btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

@media (prefers-reduced-motion: reduce) {
  .auth-body .btn-primary::after {
    display: none;
  }
}

.auth-body .footer-text {
  text-align: center;
  margin-top: 24px;
  font-size: 0.9rem;
  color: var(--night-muted);
}

.auth-body .footer-text a {
  color: var(--night-mint);
  font-weight: 600;
  text-decoration: none;
}

.auth-body .footer-text a:hover {
  color: #a7f3d0;
  text-decoration: underline;
}

.auth-body .error-msg {
  margin-top: 14px;
  padding: 10px 12px;
  font-size: 0.875rem;
  color: #fecaca;
  background: rgba(127, 29, 29, 0.45);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 10px;
  text-align: center;
}

.auth-body .error-msg:empty {
  display: none;
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
}

.auth-body .logout-message {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 48px 24px;
  color: var(--night-muted);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.35);
  max-width: 360px;
}

.auth-body .logout-message h2 {
  color: #f0fdf4;
  font-size: 1.45rem;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

@media (max-width: 640px) {
  .auth-body {
    padding: 20px 14px;
  }

  .auth-body .auth-card {
    padding: 32px 22px 28px;
  }

  .auth-orb--1,
  .auth-orb--2,
  .auth-orb--3 {
    filter: blur(48px);
    opacity: 0.4;
  }
}


/* =========================================================
   DASHBOARD — Light premium greenhouse
   Soft mint wash + white cards + teal accents
   Auth night-garden styles above are untouched
   ========================================================= */

body:not(.auth-body) {
  color: var(--color-text);
  background:
    radial-gradient(ellipse 100% 60% at 50% -20%, rgba(167, 243, 208, 0.45), transparent 55%),
    radial-gradient(ellipse 50% 40% at 100% 0%, rgba(204, 251, 241, 0.5), transparent 45%),
    linear-gradient(180deg, #f8fafc 0%, #f0fdf4 45%, #f8fafc 100%);
  background-attachment: fixed;
}

.main-container {
  width: 100%;
  margin: 0 0 40px;
}

/* ---------- Header ---------- */
body:not(.auth-body) header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 18px 28px;
  margin: 16px 0 24px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--color-text);
  border: 1px solid rgba(167, 243, 208, 0.65);
  border-radius: var(--radius-lg);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 10px 30px rgba(15, 118, 110, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

body:not(.auth-body) header .logo {
  justify-self: start;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: -0.02em;
}

body:not(.auth-body) header .date {
  justify-self: center;
  background: var(--color-accent-soft);
  color: var(--color-primary-dark);
  padding: 8px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-accent-border);
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
}

body:not(.auth-body) header .logout-btn {
  justify-self: end;
  background: #ffffff;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

body:not(.auth-body) header .logout-btn:hover {
  background: var(--color-danger-soft);
  border-color: #fecaca;
  color: var(--color-danger);
}

/* ---------- Device tabs ---------- */
body:not(.auth-body) .device-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  margin: 0 0 12px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(167, 243, 208, 0.55);
  border-radius: var(--radius-lg);
  box-shadow: 0 6px 20px rgba(15, 118, 110, 0.06);
}

body:not(.auth-body) .device-tab {
  min-width: 140px;
  max-width: 260px;
  flex: 1;
  padding: 12px 20px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--transition);
}

body:not(.auth-body) .device-tab:hover {
  background: var(--color-surface-muted);
  color: var(--color-text);
}

body:not(.auth-body) .device-tab.active {
  background: var(--color-accent-soft);
  color: var(--color-primary-dark);
  border-color: var(--color-accent-border);
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.12);
}

body:not(.auth-body) .device-tabs-empty {
  padding: 20px;
  text-align: center;
  color: var(--color-text-muted);
  width: 100%;
}

/* ---------- Sensor / Graph tabs ---------- */
body:not(.auth-body) .tabs {
  display: flex;
  background: #ffffff;
  border: 1px solid rgba(167, 243, 208, 0.55);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow: hidden;
  margin-top: 4px;
  box-shadow: 0 6px 16px rgba(15, 118, 110, 0.04);
}

body:not(.auth-body) .tab-btn {
  flex: 1;
  padding: 16px 20px;
  border: none;
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border-bottom: 3px solid transparent;
}

body:not(.auth-body) .tab-btn:hover {
  background: #eef2f7;
  color: var(--color-text);
}

body:not(.auth-body) .tab-btn.active {
  background: #ffffff;
  color: var(--color-primary);
  border-bottom-color: var(--color-accent);
}

body:not(.auth-body) .tab-content {
  background: #ffffff;
  color: var(--color-text);
  padding: 36px 32px;
  border: 1px solid rgba(167, 243, 208, 0.55);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: 0 14px 36px rgba(15, 118, 110, 0.08);
  min-height: 70vh;
}

body:not(.auth-body) .page-title {
  text-align: center;
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 28px;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

/* ---------- Sensor cards ---------- */
body:not(.auth-body) .sensor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
  width: 100%;
}

body:not(.auth-body) .sensor-grid-empty {
  text-align: center;
  color: var(--color-text-muted);
  width: 100%;
  padding: 24px;
  grid-column: 1 / -1;
}

body:not(.auth-body) .sensor-card {
  background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%);
  padding: 22px 28px;
  border-radius: var(--radius-lg);
  text-align: center;
  border: 1px solid rgba(167, 243, 208, 0.7);
  box-shadow: 0 4px 16px rgba(15, 118, 110, 0.07);
  transition: transform var(--transition), box-shadow var(--transition);
  min-width: 0;
  color: var(--color-text);
}

body:not(.auth-body) .sensor-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(15, 118, 110, 0.12);
}

body:not(.auth-body) .sensor-card .label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

body:not(.auth-body) .sensor-card .value {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--color-text);
  margin: 8px 0;
  letter-spacing: -0.03em;
}

body:not(.auth-body) .sensor-card .unit {
  font-size: 0.95rem;
  color: var(--color-text-muted);
}

body:not(.auth-body) .sensor-card.rain .value {
  color: var(--color-accent);
  font-size: 1.5rem;
}

/* ---------- Status box ---------- */
body:not(.auth-body) .status-box {
  text-align: center;
  background: var(--color-accent-soft);
  color: var(--color-primary-dark);
  padding: 20px 28px;
  border-radius: var(--radius-lg);
  max-width: 960px;
  width: 100%;
  margin: 24px auto;
  font-size: 1.05rem;
  font-weight: 500;
  border: 1px solid var(--color-accent-border);
  box-shadow: 0 4px 14px rgba(15, 118, 110, 0.06);
  line-height: 1.7;
}

/* ---------- AI section ---------- */
body:not(.auth-body) .ai-section {
  margin-top: 30px;
  padding: 24px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(167, 243, 208, 0.65);
  box-shadow: 0 4px 16px rgba(15, 118, 110, 0.06);
  width: 100%;
  color: var(--color-text);
}

body:not(.auth-body) .ai-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

body:not(.auth-body) .ai-icon {
  font-size: 1.5em;
  line-height: 1;
}

body:not(.auth-body) .ai-header h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-primary);
}

body:not(.auth-body) .ai-header p,
body:not(.auth-body) #aiStatus {
  margin: 4px 0 0 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

body:not(.auth-body) #analyzeBtn,
body:not(.auth-body) .btn-analyze {
  width: 100%;
  padding: 14px;
  font-size: 1.05rem;
  font-family: inherit;
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 650;
  transition: transform var(--transition), box-shadow var(--transition), filter var(--transition);
  margin-bottom: 20px;
  background: linear-gradient(135deg, #0d9488 0%, #0f766e 55%, #115e59 100%);
  box-shadow: 0 8px 22px rgba(15, 118, 110, 0.28);
}

body:not(.auth-body) #analyzeBtn:hover,
body:not(.auth-body) .btn-analyze:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow: 0 12px 28px rgba(15, 118, 110, 0.35);
}

body:not(.auth-body) #analyzeBtn:disabled,
body:not(.auth-body) .btn-analyze:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

body:not(.auth-body) #aiReport {
  margin-top: 10px;
}

body:not(.auth-body) .ai-report-card {
  background: #ffffff;
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  color: var(--color-text);
}

body:not(.auth-body) .ai-block {
  margin-bottom: 18px;
}

body:not(.auth-body) .ai-block:last-of-type {
  margin-bottom: 0;
}

body:not(.auth-body) .ai-block-title {
  color: var(--color-primary);
  font-size: 1.05rem;
  font-weight: 700;
}

body:not(.auth-body) .ai-block p {
  margin: 8px 0 0 0;
  line-height: 1.55;
  color: var(--color-text);
}

body:not(.auth-body) .ai-suggestions {
  margin-top: 8px;
  line-height: 1.7;
}

body:not(.auth-body) .ai-suggestion-item {
  margin-bottom: 6px;
  color: var(--color-text);
}

body:not(.auth-body) .ai-meta {
  display: block;
  margin-top: 16px;
  color: var(--color-text-subtle);
  text-align: right;
  font-size: 0.8rem;
}

body:not(.auth-body) .ai-loading {
  color: var(--color-text-muted);
  font-style: italic;
  text-align: center;
  padding: 12px;
}

body:not(.auth-body) .ai-error {
  color: var(--color-danger);
  text-align: center;
  padding: 12px;
}

body:not(.auth-body) .ai-empty {
  color: #f43f5e;
  text-align: center;
  padding: 12px;
}

/* ---------- Chart / date filter ---------- */
body:not(.auth-body) .date-filter-bar {
  text-align: center;
  margin-bottom: 20px;
  background: var(--color-surface-muted);
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(167, 243, 208, 0.55);
  width: 100%;
  color: var(--color-text);
}

body:not(.auth-body) .date-filter-bar label {
  font-weight: 600;
  margin-right: 10px;
  color: var(--color-text);
}

body:not(.auth-body) .date-filter-bar input[type="date"],
body:not(.auth-body) #dateFilter {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--color-text);
  background: #ffffff;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

body:not(.auth-body) #dateFilter:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

body:not(.auth-body) #chartContainer {
  position: relative;
  width: 100%;
  height: 60vh;
  min-height: 420px;
  background: #ffffff;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid rgba(167, 243, 208, 0.55);
  box-shadow: 0 8px 24px rgba(15, 118, 110, 0.08);
  touch-action: none;
  user-select: none;
}

body:not(.auth-body) .graph-actions {
  text-align: center;
  margin: 28px 0;
  gap: 16px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
}

body:not(.auth-body) .graph-status,
body:not(.auth-body) #status.graph-status,
body:not(.auth-body) p.graph-status {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.95rem;
  margin-top: 8px;
}

/* ---------- Buttons ---------- */
body:not(.auth-body) button.green,
body:not(.auth-body) #resetZoom {
  padding: 12px 28px;
  border-radius: var(--radius-md);
  font-weight: 650;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition);
  color: #ffffff;
  border: none;
  background: linear-gradient(135deg, #14b8a6 0%, #0f766e 100%);
  box-shadow: 0 6px 18px rgba(15, 118, 110, 0.25);
}

body:not(.auth-body) button.green:hover,
body:not(.auth-body) #resetZoom:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.32);
}

body:not(.auth-body) button.red {
  background: linear-gradient(135deg, #f87171 0%, #ef4444 55%, #dc2626 100%);
  color: #fff;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 650;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.28);
  transition: all var(--transition);
}

body:not(.auth-body) button.red:hover {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  transform: translateY(-1px);
}

/* ---------- UID ---------- */
body:not(.auth-body) .uid-section {
  text-align: center;
  margin-top: 48px;
  padding-top: 28px;
  border-top: 1px solid #d1fae5;
  color: var(--color-text);
}

body:not(.auth-body) .uid-section h3 {
  margin-bottom: 14px;
  color: var(--color-text);
  font-size: 1.1rem;
  font-weight: 650;
}

body:not(.auth-body) #uidText {
  font-family: var(--font-mono);
  background: var(--color-surface-muted);
  padding: 12px 22px;
  border-radius: var(--radius-md);
  display: inline-block;
  font-size: 1.05rem;
  letter-spacing: 0.5px;
  margin-bottom: 18px;
  border: 1px solid rgba(167, 243, 208, 0.65);
  color: var(--color-text);
  word-break: break-all;
}

body:not(.auth-body) #qrcode {
  margin: 0 auto;
  display: inline-block;
}

body:not(.auth-body) #qrcode canvas {
  border-radius: var(--radius-sm);
  border: 1px solid rgba(167, 243, 208, 0.65);
}

/* =========================================================
   RESPONSIVE
   Phone ~640 | Tablet ~900 | Large desktop ~1400+
   ========================================================= */

@media (max-width: 900px) {
  :root {
    --space-page: 16px;
  }

  body:not(.auth-body) header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 16px 18px;
    gap: 12px;
  }

  body:not(.auth-body) header .logo {
    justify-self: unset;
    text-align: center;
  }

  body:not(.auth-body) header .date {
    justify-self: unset;
    text-align: center;
    width: 100%;
  }

  body:not(.auth-body) header .logout-btn {
    justify-self: unset;
    width: 100%;
  }

  body:not(.auth-body) .tab-content {
    padding: 28px 20px;
  }

  body:not(.auth-body) .device-tab {
    min-width: 120px;
    max-width: none;
    padding: 12px 14px;
  }

  body:not(.auth-body) .sensor-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
  }

  body:not(.auth-body) .status-box {
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  :root {
    --space-page: 10px;
  }

  body:not(.auth-body) header {
    padding: 14px 16px;
  }

  body:not(.auth-body) header .date {
    font-size: 0.875rem;
    padding: 6px 12px;
  }

  .auth-body .auth-card {
    padding: 32px 22px 28px;
  }

  body:not(.auth-body) .tab-content {
    padding: 24px 16px;
  }

  body:not(.auth-body) .page-title {
    font-size: 1.4rem;
    margin-bottom: 20px;
  }

  body:not(.auth-body) .tab-btn {
    padding: 14px 12px;
    font-size: 0.95rem;
  }

  body:not(.auth-body) .device-tab {
    min-width: 110px;
    padding: 12px 10px;
    font-size: 0.9rem;
  }

  body:not(.auth-body) .sensor-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  body:not(.auth-body) .sensor-card {
    padding: 18px 16px;
  }

  body:not(.auth-body) .sensor-card .value {
    font-size: 1.85rem;
  }

  body:not(.auth-body) #chartContainer {
    height: 45vh;
    min-height: 280px;
  }

  body:not(.auth-body) .ai-section {
    padding: 18px;
  }

  body:not(.auth-body) .date-filter-bar label {
    display: block;
    margin: 0 0 8px 0;
  }

  body:not(.auth-body) .graph-actions {
    flex-direction: column;
    align-items: stretch;
  }

  body:not(.auth-body) .graph-actions button {
    width: 100%;
  }
}

@media (min-width: 901px) {
  :root {
    --space-page: 24px;
  }
}

@media (min-width: 1400px) {
  :root {
    --space-page: 32px;
  }

  body:not(.auth-body) header {
    padding: 20px 32px;
  }

  body:not(.auth-body) header .logo {
    font-size: 1.45rem;
  }

  body:not(.auth-body) .tab-content {
    padding: 40px 40px;
  }

  body:not(.auth-body) .tab-btn {
    padding: 18px 24px;
    font-size: 1.05rem;
  }

  body:not(.auth-body) .device-tab {
    min-width: 160px;
    max-width: 280px;
    padding: 14px 24px;
  }

  body:not(.auth-body) .sensor-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
  }

  body:not(.auth-body) .sensor-card {
    padding: 26px 32px;
  }

  body:not(.auth-body) .sensor-card .value {
    font-size: 2.5rem;
  }

  body:not(.auth-body) .page-title {
    font-size: 1.9rem;
  }

  body:not(.auth-body) #chartContainer {
    height: 62vh;
    min-height: 480px;
  }

  body:not(.auth-body) .status-box {
    max-width: 960px;
    padding: 22px 36px;
    font-size: 1.1rem;
  }
}
