:root {
      --bg-main: #0b0f19;
      --bg-card: rgba(23, 31, 48, 0.7);
      --bg-card-hover: rgba(30, 41, 64, 0.85);
      --border-color: rgba(255, 255, 255, 0.08);
      --text-main: #f3f4f6;
      --text-muted: #9ca3af;
      --accent-primary: #10b981;
      --accent-primary-hover: #059669;
      --accent-secondary: #6366f1;
      --accent-warning: #f59e0b;
      --accent-danger: #ef4444;
      --shadow-glow: 0 0 25px rgba(16, 185, 129, 0.15);
      --input-bg: rgba(15, 23, 42, 0.8);
      --modal-bg: #0f172a;
    }

    body.light-theme {
      --bg-main: #f1f5f9;
      --bg-card: #ffffff;
      --bg-card-hover: #f8fafc;
      --border-color: #cbd5e1;
      --text-main: #0f172a;
      --text-muted: #64748b;
      --accent-primary: #10b981;
      --accent-primary-hover: #059669;
      --accent-secondary: #4f46e5;
      --shadow-glow: 0 4px 20px rgba(0, 0, 0, 0.05);
      --input-bg: #ffffff;
      --modal-bg: #ffffff;
    }

    body.light-theme {
      background-image: 
        radial-gradient(at 10% 10%, rgba(99, 102, 241, 0.05) 0px, transparent 50%),
        radial-gradient(at 90% 90%, rgba(16, 185, 129, 0.05) 0px, transparent 50%);
    }

    body.light-theme .sidebar {
      background: #ffffff;
      box-shadow: 4px 0 20px rgba(0, 0, 0, 0.04);
    }

    body.light-theme .nav-btn {
      color: #475569;
    }

    body.light-theme .nav-btn:hover {
      background: rgba(16, 185, 129, 0.08);
      color: #059669;
    }

    body.light-theme .nav-btn.active {
      background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(99, 102, 241, 0.15));
      color: #047857;
    }

    body.light-theme .card {
      box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
    }

    body.light-theme table th {
      background: #f1f5f9;
      color: #475569;
    }

    body.light-theme table tr:hover {
      background: #f8fafc;
    }

    body.light-theme .form-control {
      background: #ffffff !important;
      color: #0f172a !important;
      border-color: #cbd5e1 !important;
    }

    body.light-theme .modal-card {
      background: #ffffff;
      color: #0f172a;
      box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    }

    body.light-theme code {
      background: #e2e8f0 !important;
      color: #4338ca !important;
    }

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

    h1, h2, h3, h4, h5, h6, .brand-title {
      font-family: 'Outfit', sans-serif;
    }

    body {
      background-color: var(--bg-main);
      color: var(--text-main);
      min-height: 100vh;
      display: flex;
      flex-direction: row;
      overflow-x: hidden;
      background-image: 
        radial-gradient(at 10% 10%, rgba(99, 102, 241, 0.08) 0px, transparent 50%),
        radial-gradient(at 90% 90%, rgba(16, 185, 129, 0.08) 0px, transparent 50%);
    }

    /* Left Vertical Sidebar Navigation */
    .sidebar {
      width: 290px;
      min-width: 290px;
      height: 100vh;
      position: sticky;
      top: 0;
      background: rgba(11, 15, 25, 0.95);
      backdrop-filter: blur(16px);
      border-right: 1px solid var(--border-color);
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      padding: 1.5rem 1.25rem;
      z-index: 100;
      box-shadow: 10px 0 30px rgba(0,0,0,0.3);
    }

    .sidebar-brand {
      display: flex;
      align-items: center;
      gap: 0.85rem;
      margin-bottom: 2rem;
    }

    .sidebar-brand .logo-icon {
      width: 44px;
      height: 44px;
      background: linear-gradient(135deg, #10b981, #6366f1);
      border-radius: 12px;
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: var(--shadow-glow);
    }

    .sidebar-brand h1 {
      font-size: 1.2rem;
      font-weight: 700;
      letter-spacing: -0.02em;
      background: linear-gradient(135deg, #ffffff, #d1d5db);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }

    .sidebar-brand p {
      font-size: 0.72rem;
      color: #9ca3af;
    }

    .sidebar-nav {
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
      flex: 1;
    }

    .nav-btn {
      width: 100%;
      justify-content: flex-start;
      background: transparent;
      border: none;
      color: #94a3b8;
      padding: 0.75rem 1.1rem;
      font-size: 0.92rem;
      font-weight: 500;
      border: 1px solid transparent;
      border-radius: 10px;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 0.75rem;
      transition: all 0.2s ease;
    }

    .nav-btn:hover {
      color: #ffffff;
      background: rgba(255, 255, 255, 0.04);
    }

    .nav-btn.active {
      background: rgba(255, 255, 255, 0.08);
      color: #ffffff;
      border: 1px solid rgba(255, 255, 255, 0.12);
      font-weight: 600;
      box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    }

    /* Left Sidebar Footer: Device Status Widget */
    .sidebar-footer {
      background: rgba(255, 255, 255, 0.02);
      border: 1px solid var(--border-color);
      border-radius: 14px;
      padding: 1rem;
      margin-top: 1.5rem;
    }

    /* Main Workspace */
    main {
      flex: 1;
      min-width: 0;
      padding: 2rem;
      overflow-y: auto;
    }

    .header-actions {
      display: flex;
      align-items: center;
      gap: 0.75rem;
    }

    .btn {
      padding: 0.6rem 1.2rem;
      border-radius: 10px;
      font-size: 0.85rem;
      font-weight: 600;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
      border: none;
    }

    .btn-primary {
      background: linear-gradient(135deg, var(--accent-primary), #059669);
      color: white;
      box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
    }

    .btn-primary:hover {
      transform: translateY(-1px);
      box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    }

    .btn-secondary {
      background: rgba(255, 255, 255, 0.06);
      color: var(--text-main);
      border: 1px solid var(--border-color);
    }

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

    .btn-sim {
      background: linear-gradient(135deg, #6366f1, #4f46e5);
      color: white;
      box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
    }

    .btn-sim:hover {
      transform: translateY(-1px);
      box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
    }

    /* Main Container */
    main {
      flex: 1;
      padding: 2rem;
      max-width: 1440px;
      margin: 0 auto;
      width: 100%;
    }

    .tab-content {
      display: none;
      animation: fadeIn 0.3s ease;
    }

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

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

    .admin-only {
      display: none;
    }

    /* KPI Grid */
    .kpi-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
      gap: 1.25rem;
      margin-bottom: 2rem;
    }

    .kpi-card {
      background: var(--bg-card);
      border: 1px solid var(--border-color);
      border-radius: 16px;
      padding: 1.25rem 1.5rem;
      backdrop-filter: blur(12px);
      display: flex;
      align-items: center;
      justify-content: space-between;
      transition: transform 0.2s ease, border-color 0.2s ease;
    }

    .kpi-card:hover {
      transform: translateY(-2px);
      border-color: rgba(255, 255, 255, 0.15);
    }

    .kpi-info p {
      font-size: 0.8rem;
      color: var(--text-muted);
      font-weight: 500;
    }

    .kpi-info h2 {
      font-size: 1.75rem;
      font-weight: 700;
      margin-top: 0.25rem;
    }

    .kpi-icon {
      width: 50px;
      height: 50px;
      border-radius: 14px;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .kpi-icon.emerald { background: rgba(16, 185, 129, 0.15); color: #10b981; }
    .kpi-icon.indigo { background: rgba(99, 102, 241, 0.15); color: #6366f1; }
    .kpi-icon.amber { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
    .kpi-icon.rose { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

    /* Dashboard Layout */
    .dashboard-layout {
      display: grid;
      grid-template-columns: 2fr 1fr;
      gap: 1.5rem;
    }

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

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

    .card-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 1.25rem;
    }

    .card-title {
      font-size: 1.1rem;
      font-weight: 600;
      display: flex;
      align-items: center;
      gap: 0.6rem;
    }

    /* Live Feed Ticker */
    .live-feed-list {
      display: flex;
      flex-direction: column;
      gap: 0.85rem;
    }

    .live-feed-item {
      background: rgba(255, 255, 255, 0.03);
      border: 1px solid var(--border-color);
      border-radius: 14px;
      padding: 1rem;
      display: flex;
      align-items: center;
      justify-content: space-between;
      transition: all 0.2s ease;
      animation: slideIn 0.3s ease;
    }

    .live-feed-item:hover {
      background: rgba(255, 255, 255, 0.05);
    }

    @keyframes slideIn {
      from { opacity: 0; transform: translateX(-10px); }
      to { opacity: 1; transform: translateX(0); }
    }

    .feed-user {
      display: flex;
      align-items: center;
      gap: 1rem;
    }

    .feed-avatar {
      width: 46px;
      height: 46px;
      border-radius: 50%;
      object-fit: cover;
      border: 2px solid rgba(16, 185, 129, 0.5);
    }

    .feed-details h4 {
      font-size: 0.95rem;
      font-weight: 600;
    }

    .feed-details p {
      font-size: 0.78rem;
      color: var(--text-muted);
      margin-top: 0.15rem;
    }

    .badge {
      padding: 0.3rem 0.75rem;
      border-radius: 20px;
      font-size: 0.75rem;
      font-weight: 600;
      display: inline-flex;
      align-items: center;
      gap: 0.35rem;
    }

    .badge-success { background: rgba(16, 185, 129, 0.18); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
    .badge-warning { background: rgba(245, 158, 11, 0.18); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
    .badge-danger { background: rgba(239, 68, 68, 0.18); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }
    .badge-info { background: rgba(99, 102, 241, 0.18); color: #818cf8; border: 1px solid rgba(99, 102, 241, 0.3); }

    /* Tables */
    .table-container {
      overflow-x: auto;
      border-radius: 12px;
      border: 1px solid var(--border-color);
    }

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

    th {
      background: rgba(255, 255, 255, 0.04);
      padding: 0.9rem 1.25rem;
      font-size: 0.78rem;
      font-weight: 600;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.05em;
      border-bottom: 1px solid var(--border-color);
    }

    td {
      padding: 1rem 1.25rem;
      font-size: 0.88rem;
      border-bottom: 1px solid var(--border-color);
      color: var(--text-main);
    }

    tr:last-child td { border-bottom: none; }
    tr:hover td { background: rgba(255, 255, 255, 0.02); }

    /* Forms & Inputs */
    .form-group {
      margin-bottom: 1.25rem;
    }

    .form-group label {
      display: block;
      font-size: 0.82rem;
      font-weight: 600;
      color: var(--text-muted);
      margin-bottom: 0.4rem;
    }

    .form-control {
      width: 100%;
      background: rgba(0, 0, 0, 0.25);
      border: 1px solid var(--border-color);
      border-radius: 10px;
      padding: 0.75rem 1rem;
      color: var(--text-main);
      font-size: 0.9rem;
      outline: none;
      transition: border-color 0.2s ease;
    }

    .form-control:focus {
      border-color: #10b981;
      box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
    }

    /* Modal Overlay */
    .modal-overlay {
      position: fixed;
      top: 0; left: 0; right: 0; bottom: 0;
      background: rgba(0, 0, 0, 0.75);
      backdrop-filter: blur(8px);
      z-index: 100;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 1rem;
    }

    .modal-overlay.active {
      display: flex;
    }

    .modal-card {
      background: #131b2e;
      border: 1px solid var(--border-color);
      border-radius: 20px;
      width: 100%;
      max-width: 540px;
      padding: 1.75rem;
      box-shadow: 0 20px 40px rgba(0,0,0,0.5);
      animation: modalUp 0.3s ease;
    }

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

    .modal-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 1.5rem;
    }

    .modal-close {
      background: transparent;
      border: none;
      color: var(--text-muted);
      cursor: pointer;
      font-size: 1.25rem;
    }

    .modal-close:hover { color: white; }
      background: rgba(255, 255, 255, 0.02);
    }

    tr:hover td {
      background: rgba(255, 255, 255, 0.02);
    }

    .emp-avatar {
      width: 38px;
      height: 38px;
      border-radius: 50%;
      object-fit: cover;
    }

    .pulse-dot {
      width: 8px;
      height: 8px;
      background-color: var(--success);
      border-radius: 50%;
      box-shadow: 0 0 10px var(--success);
      animation: pulse 1.5s infinite;
    }

    @keyframes pulse {
      0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
      70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
      100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
    }