:root {
  --bg-main: #f0f3f6;
  --bg-card: rgba(255, 255, 255, 0.75);
  --bg-sidebar: rgba(255, 255, 255, 0.85);
  --border-glass: rgba(255, 255, 255, 0.45);
  --shadow-premium: 0 10px 30px -5px rgba(0, 0, 0, 0.04), 0 4px 12px -2px rgba(0, 0, 0, 0.02);
  --shadow-glow-green: 0 4px 15px rgba(34, 197, 94, 0.2);
  --shadow-glow-blue: 0 4px 15px rgba(59, 130, 246, 0.2);
  
  --primary: #1e293b;
  --secondary: #64748b;
  --accent: #2563eb;
  --accent-light: #3b82f6;
  --success: #22c55e;
  --success-bg: #e6f9ed;
  --danger: #ef4444;
  --danger-bg: #fdf2f2;
  --warning: #f59e0b;
  --warning-bg: #fef8e8;
  
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease-out;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(224, 231, 255, 0.5) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(209, 250, 229, 0.4) 0%, transparent 45%);
  color: var(--primary);
  display: flex;
  height: 100vh;
  overflow: hidden;
  font-size: 14px;
}

.app-container {
  display: flex;
  width: 100%;
  height: 100%;
}

/* Glassmorphism Common Class */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  box-shadow: var(--shadow-premium);
  border-radius: 20px;
}

/* Sidebar & Header Combined Layout */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 24px;
  gap: 20px;
}

/* Top Navigation Bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  height: 64px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(15px);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  box-shadow: var(--shadow-premium);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  color: var(--primary);
}

.brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #3b82f6, #10b981);
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  font-size: 16px;
}

/* Top Pill Menu Tabs */
.nav-pills {
  display: flex;
  background: #e2e8f0;
  padding: 4px;
  border-radius: 12px;
  gap: 2px;
}

.nav-item {
  padding: 8px 16px;
  color: var(--secondary);
  font-weight: 500;
  font-size: 13px;
  text-decoration: none;
  border-radius: 8px;
  transition: var(--transition-fast);
  cursor: pointer;
}

.nav-item:hover {
  color: var(--primary);
  background: rgba(255, 255, 255, 0.5);
}

.nav-item.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 4px 10px -2px rgba(0, 0, 0, 0.05);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.search-bar {
  display: flex;
  align-items: center;
  background: #f1f5f9;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 6px 12px;
  width: 220px;
  transition: var(--transition);
}

.search-bar:focus-within {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-bar input {
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  margin-left: 6px;
  color: var(--primary);
  width: 100%;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  padding: 4px 12px 4px 4px;
  border-radius: 20px;
  border: 1px solid #e2e8f0;
  font-weight: 500;
  font-size: 13px;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #3b82f6;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

/* Page Content Base */
.content-area {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.page {
  display: none;
  height: 100%;
  overflow-y: auto;
  animation: pageFadeIn 0.3s ease-out forwards;
}

.page.active {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.page-title h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.page-title p {
  font-size: 13px;
  color: var(--secondary);
  margin-top: 2px;
}

/* Stats Cards with Sparklines */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.stat-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-card);
}

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-value-container {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -1px;
}

.stat-indicator {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 600;
}

.indicator-green {
  background: var(--success-bg);
  color: var(--success);
}

.indicator-blue {
  background: #eff6ff;
  color: var(--accent);
}

/* Sparkline visualization styles */
.sparkline-box {
  width: 70px;
  height: 35px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
}

.sparkbar {
  flex: 1;
  background: #cbd5e1;
  border-radius: 2px 2px 0 0;
  min-height: 4px;
  transition: height 0.6s ease;
}

.stat-card:hover .sparkbar {
  background: var(--accent-light);
}

.stat-card:hover .sparkbar:nth-child(even) {
  background: var(--success);
}

/* Main Dashboard 2-Column Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  flex: 1;
  min-height: 0;
}

/* Left Sidebar - Operations & Devices */
.ops-panel {
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow: hidden;
  height: 100%;
}

.ops-header {
  margin-bottom: 16px;
}

.ops-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
}

.ops-tabs {
  display: flex;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 8px;
  margin-top: 12px;
  gap: 2px;
}

.ops-tab {
  flex: 1;
  padding: 6px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  color: var(--secondary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.ops-tab:hover {
  color: var(--primary);
}

.ops-tab.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.ops-device-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ops-device-card {
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  transition: var(--transition);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ops-device-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
  transform: translateY(-1px);
}

.ops-device-card.selected {
  border-color: var(--accent-light);
  background: #f8fafc;
}

.device-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.device-card-name {
  font-weight: 600;
  color: var(--primary);
  font-size: 13px;
}

.device-card-detail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--secondary);
  margin-top: 2px;
}

.battery-progress-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.battery-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--secondary);
  width: 65px;
}

.battery-bar-container {
  flex: 1;
  height: 4px;
  background: #f1f5f9;
  border-radius: 2px;
  overflow: hidden;
}

.battery-bar-fill {
  height: 100%;
  background: var(--success);
  border-radius: 2px;
}

/* Right Panel - Map & Workload Charts */
.main-dashboard-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100%;
  overflow-y: auto;
}

/* Map/Visual Schema Panel */
.map-panel {
  flex: 1;
  min-height: 320px;
  position: relative;
  overflow: hidden;
  padding: 24px;
}

.map-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 20px;
}

/* Visual Node Network styling */
.schema-container {
  width: 100%;
  height: calc(100% - 30px);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 20px;
}

.schema-node {
  position: relative;
  width: 120px;
  height: 140px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.02);
  z-index: 2;
  transition: var(--transition);
}

.schema-node:hover {
  transform: scale(1.03);
  border-color: var(--accent-light);
}

.schema-node-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 8px;
}

.node-icon-wrapper {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--accent);
}

.node-status-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #ffffff;
}

.node-status-dot.active {
  background: var(--success);
  box-shadow: var(--shadow-glow-green);
}

.node-status-dot.inactive {
  background: var(--secondary);
}

.node-temp {
  font-size: 14px;
  font-weight: 700;
  margin-top: 8px;
  color: var(--primary);
}

.node-state-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--secondary);
  margin-top: 2px;
}

/* Connecting lines in visual layout */
.schema-line-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.schema-path {
  fill: none;
  stroke: #cbd5e1;
  stroke-width: 2;
  stroke-dasharray: 4 4;
  animation: pathDash 20s linear infinite;
}

.schema-path.active {
  stroke: var(--success);
  stroke-width: 2.5;
  stroke-dasharray: 6 3;
}

@keyframes pathDash {
  to {
    stroke-dashoffset: -100;
  }
}

/* Workload & Charts section */
.bottom-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.chart-card {
  padding: 20px;
}

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

.chart-title {
  font-size: 14px;
  font-weight: 700;
}

.chart-subtitle-box {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.chart-subtitle-value {
  font-size: 20px;
  font-weight: 700;
}

.chart-subtitle-lbl {
  font-size: 11px;
  color: var(--secondary);
}

.chart-canvas-container {
  height: 180px;
  position: relative;
}

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: #0f172a;
}

.btn-secondary {
  background: #ffffff;
  border-color: #cbd5e1;
  color: var(--primary);
}

.btn-secondary:hover {
  background: #f8fafc;
}

.btn-danger {
  background: var(--danger-bg);
  border-color: rgba(239, 108, 108, 0.2);
  color: var(--danger);
}

.btn-danger:hover {
  background: #fde8e8;
}

/* Badges styling */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
}

.badge-online {
  background: var(--success-bg);
  color: var(--success);
}

.badge-offline {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-ac-on {
  background: #eff6ff;
  color: var(--accent);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.badge-ac-off {
  background: #f1f5f9;
  color: var(--secondary);
}

/* Table Design */
.table-panel {
  padding: 24px;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  background: #f8fafc;
  padding: 14px 18px;
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--secondary);
  border-bottom: 1px solid #e2e8f0;
}

td {
  padding: 14px 18px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--primary);
  font-size: 13px;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: #f8fafc;
}

/* System Logs Terminal */
.log-terminal-panel {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 180px);
}

.log-terminal {
  flex: 1;
  background: #1e293b;
  border-radius: 14px;
  padding: 20px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
  font-size: 12px;
  color: #e2e8f0;
  overflow-y: auto;
  line-height: 1.6;
}

.log-line {
  margin-bottom: 6px;
}

.log-time { color: #94a3b8; margin-right: 10px; }
.log-id { color: #38bdf8; margin-right: 8px; font-weight: 600; }
.log-info { color: #4ade80; font-weight: 600; }
.log-warn { color: #facc15; font-weight: 600; }
.log-err { color: #f87171; font-weight: 600; }

/* Commands Page styling */
.commands-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--secondary);
  margin-bottom: 6px;
}

.input {
  width: 100%;
  padding: 10px 14px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 13px;
  color: var(--primary);
  transition: var(--transition-fast);
}

.input:focus {
  outline: none;
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

textarea.input {
  min-height: 100px;
  resize: vertical;
}

/* Slide-in side panel detail view */
.side-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.side-panel-overlay.show {
  display: block;
  opacity: 1;
}

.side-panel {
  position: fixed;
  top: 16px;
  right: -460px;
  width: 440px;
  height: calc(100vh - 32px);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(25px);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  z-index: 201;
  box-shadow: 0 20px 40px -10px rgba(15, 23, 42, 0.15);
  transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.side-panel.open {
  right: 16px;
}

.side-panel-header {
  padding: 20px 24px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.5);
}

.side-panel-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.side-panel-close {
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--secondary);
  cursor: pointer;
}

.side-panel-content {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
}

/* Toast notifications */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.08);
  padding: 12px 18px;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  animation: toastIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

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

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

@keyframes toastOut {
  to { transform: translateY(-10px); opacity: 0; }
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Status Indicator footer in layout */
.server-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

/* ================= AUTH OVERLAY STYLE ================= */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 40px;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border-radius: 24px;
}

.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo {
  display: inline-flex;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.05));
}

.auth-header h1 {
  font-size: 24px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.auth-header p {
  color: var(--secondary);
  font-size: 13px;
  line-height: 1.5;
}

.auth-error {
  background: var(--danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--danger);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 20px;
  line-height: 1.4;
  animation: shake 0.35s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.input-group {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-group input {
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.8);
  color: var(--primary);
  font-size: 14px;
  outline: none;
  transition: var(--transition-fast);
}

.input-group input:focus {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.btn-auth {
  margin-top: 10px;
  width: 100%;
  justify-content: center;
  padding: 14px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 12px;
}

/* Logout Button */
.logout-btn {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.15);
  color: var(--danger);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  margin-left: 10px;
}

.logout-btn:hover {
  background: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
}
