/* ════════════════════════════════════════════════════════════════════════════
   GreenNode Command Center — Master Stylesheet
   Dark teal / cyan dashboard theme
════════════════════════════════════════════════════════════════════════════ */

:root {
  --bg-primary: #0a1a1a;
  --bg-secondary: #0d2020;
  --bg-card: #0f2525;
  --bg-card2: #122828;
  --bg-hover: #163030;
  --border-color: #1a3535;
  --border-light: #1e3e3e;

  --accent: #00d4aa;
  --accent-glow: #00d4aa33;
  --accent-dim: #00a882;
  --accent-chart: #00e5bb;

  --text-primary: #e0f4f0;
  --text-secondary: #7ab5a8;
  --text-muted: #4a7a70;
  --text-dim: #2a5550;

  --danger: #ff4655;
  --danger-dim: #cc2233;
  --warning: #ffa726;
  --success: #00d4aa;
  --info: #42b6f5;

  --sidebar-w: 220px;
  --sidebar-r-w: 240px;
  --topnav-h: 56px;
  --footer-h: 52px;
  --radius: 10px;
  --radius-sm: 6px;

  --font-main: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-accent: 0 0 20px rgba(0, 212, 170, 0.15);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-main);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 13px;
  line-height: 1.5;
}

/* ── SCROLLBARS ── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

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

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-dim);
}

/* ══════════ TOP NAV ══════════ */
.topnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topnav-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 24px;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.topnav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  color: var(--accent);
  filter: drop-shadow(0 0 8px var(--accent));
}

.brand-name {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.brand-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-family: var(--font-mono);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  animation: pulse-dot 2s ease-in-out infinite;
}

.status-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 6px var(--danger);
}

@keyframes pulse-dot {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

.topnav-links {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: center;
}

.nav-link {
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.03em;
  transition: all 0.2s;
  position: relative;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-glow);
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.system-selector-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
}

.system-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  white-space: nowrap;
}

.system-select {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--accent);
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 28px 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2300d4aa'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: all 0.2s;
}

.system-select:hover {
  border-color: var(--accent-dim);
  background-color: var(--bg-hover);
}

.system-select option {
  background: var(--bg-card2);
  color: var(--text-primary);
}

.topnav-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 200px;
  justify-content: flex-end;
}

.current-time {
  text-align: right;
}

.time-label {
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
}

.time-value {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.05em;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--accent);
  border-color: var(--accent-dim);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

/* ══════════ LAYOUT ══════════ */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--sidebar-r-w);
  min-height: calc(100vh - var(--topnav-h) - var(--footer-h));
  margin-top: var(--topnav-h);
  margin-bottom: var(--footer-h);
  gap: 0;
}

/* ══════════ LEFT SIDEBAR ══════════ */
.sidebar-left {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 16px 12px;
  overflow-y: auto;
  max-height: calc(100vh - var(--topnav-h) - var(--footer-h));
  position: sticky;
  top: var(--topnav-h);
}

.sidebar-section {
  margin-bottom: 20px;
}

.section-title {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
}

/* Stat Cards */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  border-color: var(--accent-dim);
  background: var(--bg-hover);
}

.stat-icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cpu-icon {
  background: rgba(0, 212, 170, 0.1);
  color: var(--accent);
}

.mem-icon {
  background: rgba(66, 182, 245, 0.1);
  color: var(--info);
}

.uptime-icon {
  background: rgba(255, 167, 38, 0.1);
  color: var(--warning);
}

.stat-info {
  flex: 1;
  min-width: 0;
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  font-family: var(--font-mono);
}

.stat-value sup {
  font-size: 13px;
}

.stat-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--border-color);
}

.stat-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-chart));
  border-radius: 2px;
  transition: width 1s ease;
}

/* Env Cards */
.env-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: all 0.2s;
}

.env-card:hover {
  border-color: var(--accent-dim);
  background: var(--bg-hover);
}

.env-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.temp-icon {
  background: rgba(255, 100, 100, 0.12);
  color: #ff7070;
}

.hum-icon {
  background: rgba(66, 182, 245, 0.12);
  color: var(--info);
}

.uv-icon {
  background: rgba(255, 200, 50, 0.12);
  color: #ffc832;
}

.rain-icon {
  background: rgba(0, 212, 170, 0.1);
  color: var(--accent);
}

.env-label {
  font-size: 10px;
  color: var(--text-muted);
}

.env-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  font-family: var(--font-mono);
}

.env-unit {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
}

.env-sub {
  font-size: 10px;
  color: var(--accent);
  font-weight: 500;
}

/* ══════════ MAIN CONTENT ══════════ */
.main-content {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(100vh - var(--topnav-h) - var(--footer-h));
}

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

.zones-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.btn-add-zone {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-add-zone:hover {
  background: var(--accent-glow);
  box-shadow: 0 0 12px var(--accent-glow);
}

/* Zone Tabs */
.zone-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}

.zone-tab {
  padding: 6px 18px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.2s;
}

.zone-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-primary);
}

.zone-tab:hover:not(.active) {
  border-color: var(--accent-dim);
  color: var(--text-primary);
}

/* Zone Grid */
.zones-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.zone-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}

.zone-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.zone-card.active-zone::before {
  opacity: 1;
}

.zone-card.active-zone {
  border-color: var(--accent-dim);
  box-shadow: 0 0 20px rgba(0, 212, 170, 0.08);
}

.zone-card:hover {
  border-color: var(--border-light);
  transform: translateY(-1px);
}

.zone-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.zone-name-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.zone-subtitle {
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.zone-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Toggle Switch */
.toggle {
  position: relative;
  width: 42px;
  height: 22px;
  flex-shrink: 0;
}

.toggle input {
  display: none;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 11px;
  cursor: pointer;
  transition: all 0.3s;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all 0.3s;
}

.toggle input:checked~.toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(0, 212, 170, 0.4);
}

.toggle input:checked~.toggle-slider::after {
  transform: translateX(20px);
  background: var(--bg-primary);
}

.zone-status {
  font-size: 10px;
  font-weight: 500;
}

.zone-status.on {
  color: var(--accent);
}

.zone-status.off {
  color: var(--text-muted);
}

.zone-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.zone-badge {
  font-size: 9px;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.zone-badge.moisture {
  color: var(--info);
  border-color: rgba(66, 182, 245, 0.3);
}

.zone-badge.flow {
  color: var(--accent);
  border-color: rgba(0, 212, 170, 0.3);
}

/* ══════════ ANALYTICS ROW ══════════ */
.analytics-row {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
}

.analytics-card,
.schedule-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
}

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

.analytics-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.analytics-period {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.analytics-actions {
  display: flex;
  gap: 4px;
}

.analytics-btn {
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: all 0.2s;
}

.analytics-btn.active,
.analytics-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.chart-container {
  position: relative;
  margin-bottom: 4px;
}

.chart-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.chart-current {
  position: absolute;
  top: 0;
  right: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}

canvas {
  max-height: 70px;
}

.chart-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ══════════ SCHEDULE ══════════ */
.schedule-header {
  margin-bottom: 12px;
}

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

.schedule-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.schedule-item:hover {
  border-color: var(--accent-dim);
}

.schedule-day {
  min-width: 28px;
  text-align: center;
}

.schedule-day-abbr {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  line-height: 1;
}

.schedule-day-full {
  font-size: 7px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  line-height: 1.5;
}

.schedule-info {
  flex: 1;
  min-width: 0;
}

.schedule-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.schedule-time {
  font-size: 10px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.schedule-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.indicator-active {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

.indicator-warning {
  background: var(--warning);
  box-shadow: 0 0 6px var(--warning);
}

.indicator-off {
  background: var(--text-dim);
}

.btn-view-calendar {
  width: 100%;
  margin-top: 12px;
  padding: 9px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-view-calendar:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
  background: var(--accent-glow);
}

/* ══════════ RIGHT SIDEBAR ══════════ */
.sidebar-right {
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  padding: 16px 12px;
  overflow-y: auto;
  max-height: calc(100vh - var(--topnav-h) - var(--footer-h));
  position: sticky;
  top: var(--topnav-h);
  display: flex;
  flex-direction: column;
  gap: 0;
}

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

.btn-live {
  padding: 3px 10px;
  background: var(--danger);
  border: none;
  border-radius: 20px;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  animation: live-pulse 2s ease-in-out infinite;
}

@keyframes live-pulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 70, 85, 0.6);
  }

  50% {
    box-shadow: 0 0 0 5px rgba(255, 70, 85, 0);
  }
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
}

.log-item {
  padding: 10px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border-color);
  transition: all 0.2s;
  animation: fadeInRight 0.3s ease;
}

.log-item:hover {
  background: var(--bg-hover);
  border-left-color: var(--accent);
}

@keyframes fadeInRight {
  from {
    transform: translateX(10px);
    opacity: 0;
  }

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

.log-item.info {
  border-left-color: var(--info);
}

.log-item.success {
  border-left-color: var(--accent);
}

.log-item.warning {
  border-left-color: var(--warning);
}

.log-item.error {
  border-left-color: var(--danger);
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 3px;
}

.log-message {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
  flex: 1;
}

.log-type-badge {
  font-size: 8px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.badge-info {
  background: rgba(66, 182, 245, 0.15);
  color: var(--info);
}

.badge-success {
  background: rgba(0, 212, 170, 0.15);
  color: var(--accent);
}

.badge-warning {
  background: rgba(255, 167, 38, 0.15);
  color: var(--warning);
}

.badge-error {
  background: rgba(255, 70, 85, 0.15);
  color: var(--danger);
}

.log-zone {
  font-size: 10px;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 2px;
}

.log-time {
  font-size: 9px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ══════════ FOOTER ══════════ */
.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--footer-h);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.footer-sep {
  color: var(--text-dim);
}

.footer-track {
  color: var(--accent);
}

.btn-emergency {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: var(--danger);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 0 20px rgba(255, 70, 85, 0.3);
}

.btn-emergency:hover {
  background: var(--danger-dim);
  box-shadow: 0 0 30px rgba(255, 70, 85, 0.5);
  transform: scale(1.02);
}

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

.footer-storage {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.btn-download-log {
  padding: 5px 12px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-download-log:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ══════════ LOADING ══════════ */
.loading-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 30px;
  color: var(--text-muted);
  font-size: 12px;
  width: 100%;
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ══════════ MODALS ══════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal {
  background: var(--bg-card2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 30px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  animation: slideUp 0.2s ease;
}

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

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

.modal-icon {
  font-size: 40px;
  margin-bottom: 16px;
}

.modal h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.modal p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn-cancel {
  padding: 10px 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-cancel:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.btn-confirm-danger {
  padding: 10px 24px;
  background: var(--danger);
  border: none;
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: all 0.2s;
}

.btn-confirm-danger:hover {
  background: var(--danger-dim);
}

/* Data modal */
.data-modal {
  max-width: 700px;
  max-height: 80vh;
  overflow-y: auto;
  text-align: left;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.modal-body {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  overflow-x: auto;
}

/* ══════════ EMPTY STATE ══════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 30px;
  color: var(--text-muted);
  font-size: 12px;
  grid-column: 1 / -1;
}

.empty-state-icon {
  font-size: 30px;
  opacity: 0.5;
}

/* ══════════ NOTIFICATION TOAST ══════════ */
.toast-container {
  position: fixed;
  top: calc(var(--topnav-h) + 12px);
  right: 16px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 16px;
  background: var(--bg-card2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
  animation: slideInRight 0.3s ease;
  border-left: 3px solid var(--accent);
  min-width: 220px;
  max-width: 320px;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.warning {
  border-left-color: var(--warning);
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

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

/* ══════════ RESPONSIVE ══════════ */
@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 200px 1fr 220px;
  }
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar-left,
  .sidebar-right {
    display: none;
  }

  .analytics-row {
    grid-template-columns: 1fr;
  }

  .current-time {
    display: none; /* Hide time to save space */
  }
}

@media (max-width: 600px) {
  .topnav {
    gap: 8px;
    height: auto;
    flex-wrap: wrap;
    padding: 10px;
    justify-content: center;
  }

  .brand-status {
    display: none;
  }

  .topnav-brand {
    flex: 1 1 100%;
    justify-content: center;
    margin-bottom: 4px;
    min-width: auto;
  }

  .topnav-links {
    flex: 1 1 100%;
    justify-content: center;
    margin-bottom: 8px;
  }

  .nav-link {
    padding: 4px 10px;
    font-size: 11px;
  }

  .system-selector-wrap {
    flex: 1 1 auto;
    justify-content: flex-start;
    border: none;
    padding: 0;
  }

  .system-select {
    max-width: 140px;
  }

  .topnav-right {
    flex: 1 1 auto;
    justify-content: flex-end;
    min-width: auto;
    gap: 8px;
  }

  .layout {
    margin-top: 120px;
    margin-bottom: 110px; /* Accommodate taller footer */
  }

  .app-footer {
    height: 110px;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    padding: 10px;
  }

  .footer-left {
    display: none;
  }

  .footer-center, .footer-right {
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .btn-emergency {
    width: 100%;
    justify-content: center;
  }
}

/* ══════════ MQTT MONITOR ══════════ */
.mqtt-status-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.mqtt-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-dim);
  transition: background 0.4s, box-shadow 0.4s;
}

.mqtt-dot.connected {
  background: var(--accent);
  box-shadow: 0 0 7px var(--accent);
  animation: pulse-dot 2s ease-in-out infinite;
}

.mqtt-dot.disconnected {
  background: var(--danger);
  box-shadow: 0 0 7px var(--danger);
  animation: none;
}

.mqtt-status-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  letter-spacing: 0.04em;
}

.mqtt-status-broker {
  font-size: 8px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90px;
}

.mqtt-log {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  height: 150px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 9.5px;
}

.mqtt-log-empty {
  color: var(--text-dim);
  font-size: 10px;
  text-align: center;
  margin: auto;
  font-family: var(--font-main);
}

.mqtt-msg {
  display: flex;
  gap: 5px;
  align-items: flex-start;
  line-height: 1.4;
  animation: fadeIn 0.2s ease;
}

.mqtt-msg-dir {
  flex-shrink: 0;
  font-weight: 700;
  font-size: 10px;
}

.mqtt-msg.send  .mqtt-msg-dir { color: var(--warning); }
.mqtt-msg.recv  .mqtt-msg-dir { color: var(--accent);  }
.mqtt-msg.info  .mqtt-msg-dir { color: var(--info);    }
.mqtt-msg.error .mqtt-msg-dir { color: var(--danger);  }

.mqtt-msg-time {
  flex-shrink: 0;
  color: var(--text-dim);
  font-size: 9px;
  padding-top: 1px;
}

.mqtt-msg-text {
  color: var(--text-secondary);
  word-break: break-all;
}

.mqtt-msg.send  .mqtt-msg-text { color: #ffd580; }
.mqtt-msg.recv  .mqtt-msg-text { color: var(--accent); }
.mqtt-msg.info  .mqtt-msg-text { color: var(--info); }
.mqtt-msg.error .mqtt-msg-text { color: var(--danger); }

.mqtt-clear-btn {
  width: 100%;
  margin-top: 6px;
  padding: 5px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.2s;
}

.mqtt-clear-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}