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

:root, [data-theme="dark"] {
  --primary: #4f46e5;
  --primary-light: #818cf8;
  --primary-dark: #3730a3;
  --accent: #06b6d4;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --bg: #0f0e17;
  --card-bg: #1a1929;
  --card-border: rgba(255,255,255,0.07);
  --text: #f0eff7;
  --text-muted: #a09fc0;
  --radius: 20px;
}

[data-theme="light"] {
  --primary: #4f46e5;
  --primary-light: #818cf8;
  --primary-dark: #3730a3;
  --accent: #06b6d4;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --bg: #f4f3ff;
  --card-bg: #ffffff;
  --card-border: rgba(0,0,0,0.07);
  --text: #1e1b3a;
  --text-muted: #6b6a8a;
  --radius: 20px;
}

/* ── Body & Background ── */
body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 28px 24px;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(79,70,229,0.25) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 80%, rgba(6,182,212,0.15) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at 60% 40%, rgba(129,140,248,0.08) 0%, transparent 50%);
  z-index: 0;
  pointer-events: none;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(79,70,229,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79,70,229,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  z-index: 0;
  pointer-events: none;
}

/* ── Container ── */
.container {
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* ── Header ── */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--card-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.app-icon {
  width: 46px;
  height: 46px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 8px 24px rgba(79,70,229,0.4);
  flex-shrink: 0;
}

.brand-text h1 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.4px;
  margin-bottom: 2px;
}

.brand-text p {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.last-seen {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--card-border);
  padding: 8px 16px;
  border-radius: 9999px;
}

/* ── Glass Card ── */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 28px 30px;
  box-shadow: 0 32px 64px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.04) inset;
  position: relative;
  overflow: hidden;
}

.glass-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
}

/* ── Control Row ── */
.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.input-wrapper {
  flex: 1;
  min-width: 240px;
  position: relative;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  padding: 13px 16px 13px 40px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  outline: none;
  transition: all 0.25s ease;
}

input::placeholder {
  color: rgba(255,255,255,0.25);
}

input:focus {
  border-color: var(--primary-light);
  background: rgba(79,70,229,0.08);
  box-shadow: 0 0 0 4px rgba(79,70,229,0.15);
}

/* Light mode input styling */
[data-theme="light"] input {
  background: #ffffff;
  border: 1.5px solid rgba(79,70,229,0.25);
  color: var(--text);
}

[data-theme="light"] input::placeholder {
  color: rgba(79,70,229,0.35);
}

[data-theme="light"] input:focus {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(79,70,229,0.1);
}

/* ── Buttons ── */
.btn {
  padding: 13px 20px;
  border-radius: 12px;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.25s ease;
  white-space: nowrap;
}

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

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #6d28d9);
  color: white;
  box-shadow: 0 6px 20px rgba(79,70,229,0.35);
}

.btn-primary:hover {
  box-shadow: 0 10px 28px rgba(79,70,229,0.5);
}

.btn-outline {
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(255,255,255,0.1);
  color: var(--text-muted);
}

.btn-outline:hover {
  background: rgba(255,255,255,0.09);
  color: var(--text);
  border-color: rgba(255,255,255,0.2);
}

/* ── Display Grid ── */
.display-grid {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 24px;
}

/* ── Chart ── */
.chart-container {
  height: 450px;
  position: relative;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 16px;
}

/* ── Stats ── */
.realtime-stats {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stat-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 18px 20px;
  text-align: center;
  transition: all 0.3s ease;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.9px;
  font-weight: 700;
  margin-bottom: 10px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.stat-value.accent { color: var(--accent); }
.stat-value.primary { color: var(--primary-light); }

.unit {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
}

/* ── Cloud Status ── */
.cloud-status {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.cloud-status.muted  { color: var(--text-muted); }
.cloud-status.ok     { color: var(--success); }
.cloud-status.error  { color: var(--error); }

#cloud-card {
  border-left: 3px solid var(--text-muted);
  transition: border-color 0.4s ease;
}

.update-note {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 10px;
  line-height: 1.5;
  font-style: italic;
  border-top: 1px solid rgba(255,255,255,0.05);
  padding-top: 8px;
  opacity: 0.7;
}

/* ── Accent Card ── */
.accent-card {
  background: rgba(79,70,229,0.07);
  border-color: rgba(79,70,229,0.2);
}

.mode-label {
  font-size: 11px;
  color: var(--primary-light);
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ── Spin animation ── */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.spin {
  animation: spin 1.5s linear infinite;
}

/* ── Responsive ── */
@media (max-width: 1000px) {
  .display-grid {
    grid-template-columns: 1fr;
  }
  .chart-container {
    height: 320px;
  }
  .realtime-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  body {
    padding: 16px;
  }
  .realtime-stats {
    grid-template-columns: 1fr;
  }
  .last-seen {
    display: none;
  }
}
