﻿  /* Import premium Google Font Inter */
  @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

  :root {
    --bg-dark: #0a0c10;
    --panel-bg: rgba(18, 22, 33, 0.65);
    --panel-border: rgba(255, 255, 255, 0.08);
    --accent-purple: #8b5cf6;
    --accent-cyan: #06b6d4;
    --accent-blue: #3b82f6;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-dim: #6b7280;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --sidebar-width: 260px;
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-glow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  }

  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }

  body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
  }

  /* Core layout helper */
  .app-container {
    display: flex;
    min-height: 100vh;
    background: radial-gradient(circle at 10% 10%, rgba(139, 92, 246, 0.1) 0%, transparent 40%),
                radial-gradient(circle at 90% 80%, rgba(6, 182, 212, 0.1) 0%, transparent 40%);
  }

  /* Utility classes */
  .hidden {
    display: none !important;
  }

  /* ------------------- AUTH PAGE ------------------- */
  .auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
    padding: 20px;
    background: radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.15) 0%, transparent 60%);
  }

  .auth-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-glow);
    animation: fadeIn 0.5s ease-out;
  }

  .auth-header {
    text-align: center;
    margin-bottom: 30px;
  }

  .auth-header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
  }

  .auth-header p {
    color: var(--text-secondary);
    font-size: 14px;
  }

  /* Forms styling */
  .form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .input-control {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    outline: none;
    transition: var(--transition-fast);
  }

  .input-control:focus {
    border-color: var(--accent-blue);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
  }

  select.input-control {
    appearance: none;
    background-color: #1a1f2e;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
    color: var(--text-primary);
  }

  select.input-control option {
    background-color: #1a1f2e;
    color: var(--text-primary);
  }

  select.input-control option:disabled {
    color: var(--text-dim);
  }

  /* Buttons */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    border: none;
    outline: none;
    transition: var(--transition-fast);
    text-decoration: none;
  }

  .btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    color: #fff;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
  }

  .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.45);
    filter: brightness(1.1);
  }

  .btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--panel-border);
  }

  .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
  }

  .btn-danger {
    background: var(--danger);
    color: #fff;
  }

  .btn-danger:hover {
    filter: brightness(1.15);
  }

  .btn-icon {
    padding: 8px;
    border-radius: var(--radius-sm);
  }

  .btn-block {
    width: 100%;
  }

  /* ------------------- SIDEBAR ------------------- */
  .sidebar {
    width: var(--sidebar-width);
    background: rgba(10, 12, 16, 0.85);
    border-right: 1px solid var(--panel-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    height: 100vh;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    padding: 30px 20px;
    z-index: 100;
    flex-shrink: 0;
  }

  .sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
  }

  .brand-logo {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
  }

  .brand-name {
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.5px;
  }

  .sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
  }

  .sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
  }

  .sidebar-link i {
    font-size: 18px;
    width: 20px;
    text-align: center;
  }

  .sidebar-link:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
  }

  .sidebar-link.active {
    background: rgba(139, 92, 246, 0.15);
    color: var(--text-primary);
    border: 1px solid rgba(139, 92, 246, 0.25);
    box-shadow: inset 0 0 12px rgba(139, 92, 246, 0.05);
  }

  .sidebar-footer {
    border-top: 1px solid var(--panel-border);
    padding-top: 20px;
    margin-top: auto;
  }

  .user-info-panel {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
  }

  .avatar {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--accent-cyan);
    border: 1px solid rgba(255,255,255,0.15);
  }

  .user-details {
    overflow: hidden;
  }

  .username-display {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    text-overflow: ellipsis;
    display: block;
  }

  .role-display {
    font-size: 11px;
    color: var(--text-secondary);
    display: block;
    text-transform: uppercase;
  }

  /* ------------------- MAIN CONTENT ------------------- */
  .main-content {
    flex-grow: 1;
    padding: 40px;
    max-width: 1400px;
    margin: 0 auto;
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
  }

  .page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 35px;
  }

  .page-title h2 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
  }

  .page-title p {
    color: var(--text-secondary);
    font-size: 14px;
  }

  .page-actions {
    display: flex;
    gap: 12px;
  }

  /* ------------------- DASHBOARD WIDGETS ------------------- */
  .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
  }

  .stat-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 130px;
    position: relative;
    overflow: hidden;
  }

  .stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--card-accent, var(--accent-blue));
  }

  .stat-card-header {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .stat-card-value {
    font-size: 36px;
    font-weight: 700;
    line-height: 1;
    margin-top: 15px;
    background: linear-gradient(135deg, #ffffff 60%, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  .stat-card-icon {
    font-size: 20px;
    color: var(--card-accent, var(--accent-blue));
    opacity: 0.8;
  }

  /* ------------------- TABLES & VIEWS ------------------- */
  .content-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
  }

  .panel-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
  }

  .panel-title {
    font-weight: 600;
    font-size: 16px;
  }

  .header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
  }

  .select-filter {
    height: 38px;
    padding-top: 0;
    padding-bottom: 0;
    font-size: 14px;
    min-width: 140px;
  }

  .search-box {
    position: relative;
    max-width: 240px;
    width: 100%;
  }

  .search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    font-size: 15px;
  }

  .search-box .input-control {
    padding-left: 40px;
    width: 100%;
    font-size: 14px;
    height: 38px;
    padding-top: 0;
    padding-bottom: 0;
  }

  .table-responsive {
    overflow-x: auto;
    width: 100%;
  }

  .custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
  }

  .custom-table th {
    background: rgba(255, 255, 255, 0.02);
    padding: 16px 24px;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--panel-border);
    white-space: nowrap;
  }

  .custom-table td {
    padding: 16px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: var(--text-primary);
    vertical-align: middle;
  }

  .custom-table tbody tr {
    transition: var(--transition-fast);
  }

  .custom-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.015);
  }

  .custom-table tbody tr:last-child td {
    border-bottom: none;
  }

  /* Tags/Badges */
  .badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .badge-success {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
  }

  .badge-purple {
    background: rgba(139, 92, 246, 0.12);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.2);
  }

  .badge-danger {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
  }

  .badge-secondary {
    background: rgba(156, 163, 175, 0.12);
    color: var(--text-secondary);
    border: 1px solid rgba(156, 163, 175, 0.2);
  }

  /* Actions column icons */
  .actions-cell {
    display: flex;
    gap: 8px;
  }

  .action-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    font-size: 16px;
  }

  .action-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
  }

  .action-btn.edit:hover { color: var(--accent-cyan); }
  .action-btn.allocate:hover { color: var(--success); }
  .action-btn.transfer:hover { color: var(--accent-purple); }
  .action-btn.retire:hover { color: var(--danger); }

  /* ------------------- MODAL ------------------- */
  .modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
  }

  .modal-overlay.show {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
  }

  .modal-container {
    background: #111422;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glow);
    width: 100%;
    max-width: 550px;
    transform: scale(0.9);
    transition: transform var(--transition-normal);
    overflow: hidden;
  }

  .modal-overlay.show .modal-container {
    transform: scale(1);
  }

  .modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .modal-header h3 {
    font-size: 18px;
    font-weight: 600;
  }

  .modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: var(--transition-fast);
  }

  .modal-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
  }

  .modal-body {
    padding: 24px;
  }

  .modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--panel-border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: rgba(255,255,255,0.01);
  }

  /* ------------------- TOAST NOTIFICATION ------------------- */
  .toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
  }

  .toast {
    background: #181d2a;
    border-left: 4px solid var(--accent-blue);
    border-top: 1px solid var(--panel-border);
    border-right: 1px solid var(--panel-border);
    border-bottom: 1px solid var(--panel-border);
    color: var(--text-primary);
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    min-width: 300px;
    max-width: 450px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    animation: slideInRight var(--transition-fast) forwards;
    pointer-events: auto;
  }

  .toast.success { border-left-color: var(--success); }
  .toast.error { border-left-color: var(--danger); }
  .toast.warning { border-left-color: var(--warning); }

  .toast-content {
    font-size: 14px;
    flex-grow: 1;
  }

  .toast-close {
    cursor: pointer;
    color: var(--text-dim);
    transition: var(--transition-fast);
    font-size: 14px;
  }

  .toast-close:hover {
    color: var(--text-primary);
  }

  /* ------------------- LOADER ------------------- */
  .loader-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 12, 16, 0.6);
    backdrop-filter: blur(3px);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 15px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
  }

  .loader-backdrop.show {
    opacity: 1;
    pointer-events: all;
  }

  .spinner {
    width: 40px;
    height: 40px;
    border: 3.5px solid rgba(255, 255, 255, 0.08);
    border-top: 3.5px solid var(--accent-cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }

  /* ------------------- KEYFRAMES ------------------- */
  @keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }

  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
  }

  @keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
  }

  @keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
  }

  /* ------------------- SKELETON LOADING ------------------- */
  .skeleton-row td {
    padding: 18px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
  }

  .skeleton-cell {
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(90deg,
      rgba(255,255,255,0.04) 25%,
      rgba(255,255,255,0.09) 50%,
      rgba(255,255,255,0.04) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
  }

  .skeleton-cell.wide  { width: 70%; }
  .skeleton-cell.short { width: 35%; }
  .skeleton-cell.slim  { width: 20%; }

  /* ------------------- EMPTY STATES ------------------- */
  .empty-state-cell {
    text-align: center;
    padding: 56px 24px !important;
    border-bottom: none !important;
  }

  .empty-state-icon {
    font-size: 38px;
    color: var(--text-dim);
    margin-bottom: 14px;
    display: block;
    opacity: 0.6;
  }

  .empty-state-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
  }

  .empty-state-sub {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 22px;
  }

  /* ------------------- ROW STATUS COLOURING ------------------- */
  .custom-table tbody tr[data-status="In Stock"] {
    box-shadow: inset 3px 0 0 var(--success);
  }

  .custom-table tbody tr[data-status="Allocated"] {
    box-shadow: inset 3px 0 0 var(--accent-purple);
  }

  .custom-table tbody tr[data-status="Retired"] {
    box-shadow: inset 3px 0 0 rgba(255,255,255,0.1);
    opacity: 0.5;
  }

  .custom-table tbody tr[data-status="Retired"]:hover {
    opacity: 0.7;
  }

  /* ------------------- DEVICE DETAIL VIEW ------------------- */
  .detail-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0;
    padding: 8px 0;
  }

  .detail-info-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 20px 24px;
    border-right: 1px solid var(--panel-border);
    border-bottom: 1px solid var(--panel-border);
  }

  .detail-info-item:last-child {
    border-right: none;
  }

  .detail-info-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-dim);
  }

  .detail-info-value {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.4;
  }

  .action-btn.view:hover { color: var(--accent-blue); }

  .asset-tag-link {
    font-weight: 600;
    color: var(--accent-cyan);
    cursor: pointer;
    white-space: nowrap;
  }

  .asset-tag-link:hover {
    text-decoration: underline;
    color: #22d3ee;
  }

  /* Count badge in panel titles */
  .count-badge {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
    vertical-align: middle;
  }

  /* Dashboard lower panels responsive */
  @media(max-width: 800px) {
    #dashboard-lower-panels {
      grid-template-columns: 1fr !important;
    }
  }

  /* ------------------- RESPONSIVE LAYOUT ------------------- */
  @media(max-width: 900px) {
    .app-container {
      flex-direction: column;
    }

    .sidebar {
      width: 100%;
      height: auto;
      padding: 15px 20px;
      flex-direction: row;
      justify-content: space-between;
      align-items: center;
      position: sticky;
      top: 0;
      border-right: none;
      border-bottom: 1px solid var(--panel-border);
    }

    .sidebar-header {
      margin-bottom: 0;
    }

    .sidebar-menu {
      display: none; /* Hide standard sidebar navigation on tablet/mobile */
    }

    .sidebar-footer {
      margin-top: 0;
      border-top: none;
      padding-top: 0;
    }

    .user-info-panel {
      margin-bottom: 0;
    }

    .main-content {
      width: 100%;
      padding: 20px;
    }
    
    .stats-grid {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  @media(max-width: 600px) {
    .stats-grid {
      grid-template-columns: 1fr;
    }

    .page-header {
      flex-direction: column;
      align-items: flex-start;
      gap: 15px;
    }

    .page-actions {
      width: 100%;
    }

    .page-actions .btn {
      flex-grow: 1;
    }
  }
