:root {
  --bg-dark: #eef2f6; /* slightly darker, cooler gray for background */
  --bg-panel: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.95);
  --border-light: rgba(0, 0, 0, 0.05);
  --text-main: #1e293b; /* slightly richer dark text */
  --text-muted: #64748b;
  
  --accent-blue: #0ea5e9;
  --accent-green: #10b981;
  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  
  --font-family: 'Inter', sans-serif;
  --sidebar-width: 260px;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
}

.text-blue { color: var(--accent-blue); }
.text-green { color: var(--accent-green); }
.text-purple { color: var(--accent-purple); }
.text-pink { color: var(--accent-pink); }

/* --- APP LAYOUT --- */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* --- SIDEBAR --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-panel);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: rgba(0, 229, 255, 0.1);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 229, 255, 0.2);
}

.sidebar-logo h2 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.sidebar-logo .accent {
  color: var(--accent-purple);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 8px;
  transition: all 0.2s ease;
  position: relative;
}

.nav-item:hover {
  background: rgba(0, 0, 0, 0.03);
  color: var(--text-main);
}

.nav-item.active {
  background: rgba(0, 229, 255, 0.1);
  color: var(--text-main);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 60%;
  width: 4px;
  background: var(--accent-blue);
  border-radius: 0 4px 4px 0;
}

.nav-divider {
  height: 1px;
  background: var(--border-light);
  margin: 16px 0;
}

.badge {
  background: #ef4444;
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: auto;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--border-light);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  cursor: pointer;
}

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

.user-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.user-role {
  font-size: 0.75rem;
  color: var(--accent-blue);
}

/* --- MAIN CONTENT --- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-image: radial-gradient(circle at top right, rgba(14, 165, 233, 0.05), transparent 50%),
                    radial-gradient(circle at bottom left, rgba(139, 92, 246, 0.05), transparent 50%);
}

.top-nav {
  height: 70px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  z-index: 5;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #ef4444;
  box-shadow: 0 0 10px #ef4444;
}
.dot.connected {
  background-color: var(--accent-green);
  box-shadow: 0 0 10px var(--accent-green);
}

.status-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-green);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.status-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.top-nav-icons {
  display: flex;
  align-items: center;
  gap: 20px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: color 0.2s ease;
}
.icon-btn:hover { color: var(--text-main); }
.badge.small {
  position: absolute;
  top: -8px;
  right: -8px;
  padding: 2px 4px;
  font-size: 0.6rem;
}
.user-avatar.small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0,0,0,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- DASHBOARD CORE --- */
.dashboard-core {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Hero Section */
.hero-section {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 24px;
}

.hero-text h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 8px;
}
.hero-text .accent {
  color: var(--accent-purple);
}
.hero-text p {
  color: var(--text-muted);
  font-size: 1rem;
}

.battery-visual {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(0,0,0,0.02);
  padding: 12px 20px;
  border-radius: 12px;
  border: 1px solid var(--border-light);
}
.battery-body {
  width: 80px;
  height: 30px;
  border: 2px solid var(--accent-blue);
  border-radius: 6px;
  padding: 3px;
  position: relative;
}
.battery-cap {
  width: 6px;
  height: 12px;
  background-color: var(--accent-blue);
  border-radius: 0 4px 4px 0;
  margin-left: -12px;
}
.battery-level {
  height: 100%;
  background: var(--accent-blue);
  border-radius: 3px;
  transition: width 0.5s ease;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.4);
}
.battery-stats {
  display: flex;
  flex-direction: column;
}
.battery-text {
  font-size: 1.5rem;
  font-weight: 700;
}
.battery-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Glass Panels */
.glass {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
}

/* Controls */
.controls-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
}

.select-input {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 0.95rem;
  padding: 10px 16px;
  border-radius: 8px;
  outline: none;
  cursor: pointer;
  appearance: none;
}
.select-input.small {
  padding: 6px 12px;
  font-size: 0.8rem;
}
.select-input:focus { border-color: var(--accent-blue); }

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}
.action-btn.primary {
  background: rgba(0, 229, 255, 0.1);
  color: var(--accent-blue);
  border: 1px solid rgba(0, 229, 255, 0.3);
}
.action-btn.primary:hover { background: rgba(0, 229, 255, 0.2); }

.action-btn.danger {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.action-btn.danger:hover { background: rgba(239, 68, 68, 0.2); }

.action-btn.purple-glow {
  background: linear-gradient(135deg, #a855f7, #c026d3);
  color: white;
  box-shadow: 0 4px 15px rgba(192, 38, 211, 0.4);
}
.action-btn.purple-glow:hover { opacity: 0.9; }

.action-btn.dark {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-main);
  border: 1px solid var(--border-light);
}
.action-btn.dark:hover { background: rgba(0, 0, 0, 0.1); }

/* Admin Panel */
.admin-panel {
  padding: 20px;
  border: 1px solid rgba(181, 0, 255, 0.3);
  box-shadow: inset 0 0 20px rgba(181, 0, 255, 0.05);
}
.panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.panel-header h3 {
  font-size: 1.1rem;
  color: var(--accent-purple);
  font-weight: 600;
}
.panel-body {
  display: flex;
  gap: 16px;
  align-items: center;
}
.status-msg {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.metric-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.icon-box {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-blue { background: rgba(0, 229, 255, 0.1); color: var(--accent-blue); border: 1px solid rgba(0,229,255,0.2); }
.icon-green { background: rgba(0, 255, 136, 0.1); color: var(--accent-green); border: 1px solid rgba(0,255,136,0.2); }
.icon-purple { background: rgba(181, 0, 255, 0.1); color: var(--accent-purple); border: 1px solid rgba(181,0,255,0.2); }
.icon-pink { background: rgba(255, 0, 127, 0.1); color: var(--accent-pink); border: 1px solid rgba(255,0,127,0.2); }

.card-header h4 {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.card-value {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.card-value .unit {
  font-size: 1.25rem;
  color: var(--text-muted);
}

.capacity-value-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.circular-progress {
  width: 50px;
  height: 50px;
}
.circular-progress svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.circle-bg { fill: none; stroke: rgba(0,0,0,0.08); stroke-width: 3.5; }
.circle-fg { fill: none; stroke: var(--accent-pink); stroke-width: 3.5; stroke-linecap: round; transition: stroke-dasharray 0.5s ease; filter: drop-shadow(0 0 4px var(--accent-pink)); }

.sparkline-container {
  height: 40px;
  margin-bottom: 16px;
  width: 100%;
}

.card-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
}
.progress-bar-container {
  flex: 1;
  height: 6px;
  background: rgba(0,0,0,0.05);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}
.bar-blue { background: var(--accent-blue); box-shadow: 0 0 8px var(--accent-blue); }
.bar-green { background: var(--accent-green); box-shadow: 0 0 8px var(--accent-green); }
.bar-purple { background: var(--accent-purple); box-shadow: 0 0 8px var(--accent-purple); }

.footer-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Bottom Row */
.bottom-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  min-height: 300px;
}

.main-chart-panel {
  padding: 24px;
  display: flex;
  flex-direction: column;
}
.main-chart-panel h4 {
  font-size: 1.1rem;
  margin-bottom: 16px;
}

.chart-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.legend-dot {
  width: 12px;
  height: 4px;
  border-radius: 2px;
}
.dot-blue { background: var(--accent-blue); }
.dot-green { background: var(--accent-green); }
.dot-purple { background: var(--accent-purple); }

.main-chart-container {
  flex: 1;
  position: relative;
  min-height: 200px;
}

.activity-panel {
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.panel-header-simple {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.text-btn {
  background: rgba(0,0,0,0.03);
  border: 1px solid var(--border-light);
  color: var(--accent-blue);
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
}

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

.activity-item {
  display: flex;
  gap: 12px;
}

.activity-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.activity-icon.success { background: rgba(0,255,136,0.1); color: var(--accent-green); border: 1px solid rgba(0,255,136,0.3); }
.activity-icon.warning { background: rgba(255,222,0,0.1); color: #ffde00; border: 1px solid rgba(255,222,0,0.3); }
.activity-icon.info { background: rgba(0,229,255,0.1); color: var(--accent-blue); border: 1px solid rgba(0,229,255,0.3); }

.activity-content {
  flex: 1;
}
.activity-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.activity-desc {
  font-size: 0.85rem;
}
.activity-tag {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0,0,0,0.05);
  color: var(--text-muted);
}
.activity-tag.info-tag { background: rgba(0,229,255,0.1); color: var(--accent-blue); }
.activity-tag.warning-tag { background: rgba(255,222,0,0.1); color: #ffde00; }

@media (max-width: 1200px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .bottom-row { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
  .metrics-grid { grid-template-columns: 1fr; }
}
