:root {
  --bg-dark: #0f172a;
  --card-bg: rgba(30, 41, 59, 0.7);
  --border-color: rgba(255, 255, 255, 0.1);
  --primary: #10b981;
  --primary-hover: #059669;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
}

body {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 0% 0%, rgba(16, 185, 129, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(59, 130, 246, 0.15) 0px, transparent 50%);
  color: var(--text-main);
  min-height: 100vh;
}

/* App Layout Grid with Sidebar */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
}

/* Fixed Left Sidebar Menu */
.sidebar {
  width: 260px;
  min-width: 260px;
  max-width: 260px;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  background: #0b1329;
  border-right: 1px solid var(--border-color);
  display: flex !important;
  flex-direction: column !important;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

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

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #10b981, #059669);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 20px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  flex-shrink: 0;
}

.brand h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.725rem;
  color: var(--text-muted);
}

.sidebar-close-btn {
  display: none !important;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
  display: flex !important;
  flex-direction: column !important;
  gap: 6px;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.nav-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 10px 8px 4px;
}

/* Sidebar Tab Buttons - Clickable & Large Vertical Target */
.tab-btn {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 12px;
  width: 100% !important;
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  outline: none;
  white-space: nowrap;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.08);
  transform: translateX(3px);
}

.tab-btn.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(16, 185, 129, 0.05)) !important;
  color: #34d399 !important;
  font-weight: 600;
  border: 1px solid rgba(16, 185, 129, 0.4) !important;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

.nav-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.6);
  flex-shrink: 0;
}

/* Main Content Area Offset by Fixed Left Sidebar */
.main-content {
  margin-left: 260px;
  width: calc(100% - 260px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  flex: 1;
}

header {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 80;
}

.header-page-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.mobile-toggle-btn {
  display: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 1.2rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.mobile-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.auth-box {
  display: flex;
  gap: 10px;
  align-items: center;
}

.auth-box button {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.auth-box button:hover {
  background: var(--primary-hover);
}

.content-body {
  max-width: 1300px;
  width: 100%;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
  flex: 1;
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.card-stat {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-connected    { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.4); }
.badge-connecting   { background: rgba(59, 130, 246, 0.2);  color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.4);  }
.badge-disconnected { background: rgba(239, 68, 68, 0.2);   color: #f87171; border: 1px solid rgba(239, 68, 68, 0.4);   }
.badge-qr           { background: rgba(245, 158, 11, 0.2);  color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.4);  }
.badge-reconnecting { background: rgba(251, 146, 60, 0.2);  color: #fb923c; border: 1px solid rgba(251, 146, 60, 0.4); animation: pulse-badge 1.4s ease-in-out infinite; }
.badge-session_expired { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3); }

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.panel {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 12px;
}

.panel-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.btn {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-primary { background: var(--primary); border: none; color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); border: none; color: #fff; }
.btn-warning { background: var(--warning); border: none; color: #000; }

.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem;
  gap: 1rem;
}

.qr-container img {
  width: 250px;
  height: 250px;
  border-radius: 12px;
  border: 4px solid #fff;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  color: var(--text-muted);
  font-weight: 500;
}

.logs-console {
  background: #090d16;
  border-radius: 12px;
  padding: 1rem;
  font-family: monospace;
  font-size: 0.85rem;
  max-height: 350px;
  overflow-y: auto;
  color: #38bdf8;
}

footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

/* Mobile Sidebar Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 99;
}

/* Responsive Media Queries */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 1000;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close-btn {
    display: block !important;
  }

  .sidebar-overlay.active {
    display: block;
  }

  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
  }

  .mobile-toggle-btn {
    display: flex !important;
  }

  header {
    padding: 0.85rem 1rem;
  }

  .content-body {
    padding: 0 1rem;
    margin: 1rem auto;
  }
}

@media (max-width: 600px) {
  header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .auth-box {
    justify-content: space-between;
  }

  .grid-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .card-stat {
    padding: 0.85rem;
  }

  .stat-value {
    font-size: 1.35rem;
  }
}

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

/* Dedicated Login Page Styles */
.login-body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 0% 0%, rgba(16, 185, 129, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(59, 130, 246, 0.15) 0px, transparent 50%);
}

.login-container {
  width: 100%;
  max-width: 440px;
  padding: 1.5rem;
  display: flex;
  justify-content: center;
}

.login-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px);
  text-align: center;
}

.login-logo {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #10b981, #059669);
  border-radius: 18px;
  margin: 0 auto 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.35);
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1.75rem;
  line-height: 1.4;
}

.login-form-group {
  margin-bottom: 1.25rem;
  text-align: left;
}

.login-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: block;
}

.login-input {
  width: 100%;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.login-toggle-pw {
  position: absolute;
  right: 12px;
  top: 34px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
}

.login-error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
  padding: 8px 12px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  text-align: left;
}

.login-submit-btn {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 13px;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.login-submit-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

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

.login-footer-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1.5rem;
}

