* { margin: 0; padding: 0; box-sizing: border-box; }
    :root {
      --color-primary: #6366f1;
      --color-primary-dark: #4f46e5;
      --color-secondary: #8b5cf6;
      --color-bg: #f8fafc;
      --color-surface: #ffffff;
      --color-text: #1e293b;
      --color-muted: #64748b;
      --color-border: #e2e8f0;
      --color-success: #10b981;
      --color-warning: #f59e0b;
      --color-danger: #ef4444;
      --radius-sm: 8px;
      --radius-md: 12px;
      --radius-lg: 16px;
      --shadow-card: 0 4px 16px rgba(15, 23, 42, 0.08);
      --shadow-elevated: 0 20px 50px rgba(15, 23, 42, 0.18);
      --gradient-brand: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    }
    body {
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
      background: var(--color-bg);
      color: var(--color-text);
    }
    .hidden { display: none !important; }
    
    /* Auth Pages */
    .auth-container {
      min-height: 100vh;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 20px;
      background: var(--gradient-brand);
    }
    .auth-box {
      background: var(--color-surface);
      padding: 40px;
      border-radius: var(--radius-md);
      box-shadow: var(--shadow-elevated);
      max-width: 400px;
      width: 100%;
    }
    .auth-box h1 {
      font-size: 24px;
      margin-bottom: 8px;
      color: var(--color-primary);
    }
    .auth-box .subtitle {
      color: var(--color-muted);
      margin-bottom: 24px;
      font-size: 14px;
    }
    .form-group {
      margin-bottom: 20px;
    }
    .form-group label {
      display: block;
      margin-bottom: 6px;
      font-weight: 500;
      font-size: 14px;
    }
    .form-group input {
      width: 100%;
      padding: 12px;
      border: 1px solid var(--color-border);
      border-radius: var(--radius-sm);
      font-size: 14px;
    }
    .form-group input:focus {
      outline: none;
      border-color: var(--color-primary);
    }
    .btn {
      width: 100%;
      padding: 12px;
      background: var(--color-primary);
      color: white;
      border: none;
      border-radius: var(--radius-sm);
      font-size: 14px;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.2s;
    }
    .btn:hover {
      background: var(--color-primary-dark);
    }
    .btn:disabled {
      background: #ccc;
      cursor: not-allowed;
    }
    .btn-danger {
      background: #dc2626;
    }
    .btn-danger:hover {
      background: #b91c1c;
    }
    .btn-secondary {
      background: #e2e8f0;
      color: var(--color-text);
    }
    .btn-secondary:hover {
      background: #cbd5e1;
    }
    .btn-small {
      padding: 8px 16px;
      font-size: 14px;
      width: auto;
    }
    .auth-links {
      margin-top: 20px;
      text-align: center;
      font-size: 14px;
    }
    .auth-link-button {
      appearance: none;
      background: transparent;
      border: 0;
      color: var(--color-primary);
      cursor: pointer;
      font: inherit;
      padding: 0;
      text-decoration: none;
    }
    .auth-link-button:hover,
    .auth-link-button:focus-visible {
      text-decoration: underline;
    }
    .auth-link-button[aria-disabled="true"] {
      cursor: not-allowed;
      opacity: 0.65;
    }
    .error-message {
      background: #fee;
      color: #c00;
      padding: 12px;
      border-radius: var(--radius-sm);
      margin-bottom: 16px;
      font-size: 14px;
    }
    .success-message {
      background: #efe;
      color: #060;
      padding: 12px;
      border-radius: var(--radius-sm);
      margin-bottom: 16px;
      font-size: 14px;
    }
    
    /* Dashboard */
    .dashboard {
      display: none;
      min-height: 100vh;
    }
    .dashboard.active {
      display: block;
    }
    .header {
      background: var(--color-surface);
      border-bottom: 1px solid var(--color-border);
      padding: 16px 24px;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    .header h1 {
      font-size: 20px;
      color: var(--color-primary);
    }
    .header .user-info {
      display: flex;
      align-items: center;
      gap: 16px;
    }
    .header .user-email {
      font-size: 14px;
      color: var(--color-muted);
    }
    .dashboard-status {
      max-width: 1600px;
      margin: 16px auto 0;
      padding: 12px 16px;
      border: 1px solid var(--color-border);
      border-radius: var(--radius-sm);
      background: #eef6ff;
      color: var(--color-primary);
      box-shadow: var(--shadow-card);
    }
    .dashboard-status.warning-state {
      border-color: rgba(245, 158, 11, 0.45);
      background: #fffbeb;
      color: #92400e;
    }
    .dashboard-status.error-state {
      border-color: #fecaca;
      background: #fff1f2;
      color: #b91c1c;
    }
    .dashboard-status:focus {
      outline: 3px solid rgba(37, 99, 235, 0.35);
      outline-offset: 2px;
    }
    .dashboard-status.warning-state:focus {
      outline-color: rgba(245, 158, 11, 0.4);
    }
    .dashboard-status.error-state:focus {
      outline-color: rgba(220, 38, 38, 0.35);
    }
    
    /* Main Layout */
    .main-content {
      display: grid;
      grid-template-columns: 350px 1fr;
      gap: 20px;
      padding: 24px;
      max-width: 1600px;
      margin: 0 auto;
    }
    .sidebar {
      background: var(--color-surface);
      border-radius: var(--radius-md);
      padding: 20px;
      box-shadow: var(--shadow-card);
      max-height: calc(100vh - 120px);
      overflow-y: auto;
    }
    .sidebar h2 {
      color: #333;
      margin-bottom: 16px;
      font-size: 1.3em;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    .sidebar-actions {
      display: flex;
      gap: 8px;
      margin-bottom: 16px;
    }
    .fleet-kpi-grid {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 14px;
      max-width: 1600px;
      margin: 0 auto;
      padding: 24px 24px 0;
    }
    .fleet-kpi-card {
      position: relative;
      overflow: hidden;
      background: var(--color-surface);
      border: 1px solid var(--color-border);
      border-radius: var(--radius-md);
      padding: 16px;
      box-shadow: var(--shadow-card);
      text-align: left;
      cursor: pointer;
      font: inherit;
      appearance: none;
    }
    .fleet-kpi-card.skeleton {
      min-height: 110px;
      background: linear-gradient(90deg, #eef2ff 0%, #f8fafc 45%, #eef2ff 100%);
    }
    .fleet-kpi-card.skeleton::after {
      content: '';
      position: absolute;
      inset: 0;
      transform: translateX(-100%);
      background: linear-gradient(90deg, transparent, rgba(255,255,255,0.72), transparent);
      animation: skeleton-shimmer 1.4s infinite;
    }
    .kpi-status-card {
      grid-column: 1 / -1;
    }
    .fleet-kpi-card::before {
      content: '';
      position: absolute;
      inset: 0 auto 0 0;
      width: 4px;
      background: #94a3b8;
    }
    .fleet-kpi-card.tone-success::before { background: var(--color-success); }
    .fleet-kpi-card.tone-warning::before { background: var(--color-warning); }
    .fleet-kpi-card.tone-danger::before { background: var(--color-danger); }
    .fleet-kpi-card:hover,
    .fleet-kpi-card:focus-visible {
      border-color: var(--color-brand);
      outline: 3px solid rgba(79, 70, 229, 0.18);
      outline-offset: 2px;
    }
    .fleet-kpi-card.active {
      border-color: var(--color-brand);
      box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.16), var(--shadow-card);
    }
    .fleet-kpi-label {
      display: block;
      color: var(--color-muted);
      font-size: 12px;
      font-weight: 700;
      letter-spacing: 0.04em;
      text-transform: uppercase;
    }
    .fleet-kpi-value {
      display: block;
      color: var(--color-text);
      font-size: 30px;
      font-weight: 800;
      margin-top: 6px;
    }
    .fleet-kpi-helper {
      display: block;
      color: var(--color-muted);
      font-size: 12px;
      margin-top: 4px;
    }
    .map-panel {
      background: var(--color-surface);
      border-radius: var(--radius-md);
      padding: 20px;
      box-shadow: var(--shadow-card);
    }
    .map-panel-header {
      display: flex;
      justify-content: space-between;
      gap: 16px;
      align-items: flex-start;
      margin-bottom: 14px;
    }
    .map-panel-header h2 {
      color: var(--color-text);
      font-size: 18px;
    }
    .eyebrow {
      color: var(--color-primary-dark);
      font-size: 11px;
      font-weight: 800;
      letter-spacing: 0.08em;
      margin-bottom: 3px;
      text-transform: uppercase;
    }
    .map-panel-summary {
      color: var(--color-muted);
      font-size: 13px;
      max-width: 280px;
      text-align: right;
    }
    .map-sync-status {
      margin-top: 6px;
      max-width: 320px;
      padding: 8px 10px;
      border: 1px solid rgba(99, 102, 241, 0.24);
      border-radius: var(--radius-sm);
      background: rgba(238, 242, 255, 0.82);
      color: var(--color-primary-dark);
      font-size: 12px;
      font-weight: 700;
      line-height: 1.35;
      text-align: right;
    }
    .map-sync-status.error-state {
      border-color: rgba(220, 38, 38, 0.35);
      background: rgba(254, 242, 242, 0.9);
      color: var(--color-danger);
    }
    .map-sync-status:focus {
      outline: 3px solid rgba(99, 102, 241, 0.35);
      outline-offset: 2px;
    }
    .map-panel-body {
      position: relative;
    }
    .map-panel-body[aria-busy="true"] #map {
      opacity: 0.72;
      transition: opacity 0.2s ease;
    }
    #map {
      height: calc(100vh - 245px);
      min-height: 420px;
      border-radius: var(--radius-sm);
      border: 1px solid var(--color-border);
    }
    .map-panel-empty {
      position: absolute;
      inset: 18px;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 24px;
      border: 1px dashed rgba(99, 102, 241, 0.35);
      border-radius: var(--radius-sm);
      background: rgba(248, 250, 252, 0.92);
      color: var(--color-muted);
      text-align: center;
      pointer-events: none;
      z-index: 400;
    }
    .map-panel-empty:focus {
      outline: 3px solid rgba(99, 102, 241, 0.35);
      outline-offset: 2px;
    }
    .map-panel-error {
      position: absolute;
      left: 16px;
      right: 16px;
      top: 16px;
      z-index: 500;
      padding: 12px 14px;
      border: 1px solid rgba(245, 158, 11, 0.45);
      border-radius: var(--radius-sm);
      background: rgba(255, 251, 235, 0.96);
      color: #92400e;
      font-size: 13px;
      font-weight: 700;
      box-shadow: var(--shadow-card);
    }
    .map-popup {
      min-width: 180px;
      color: var(--color-text);
    }
    .map-popup-title {
      font-weight: 800;
      margin-bottom: 6px;
    }
    .map-popup-meta {
      color: var(--color-muted);
      font-size: 12px;
      margin-top: 5px;
    }
    .map-popup-summary {
      color: var(--color-text);
      font-weight: 700;
    }
    .map-popup-cta {
      display: inline-flex;
      align-items: center;
      margin-top: 8px;
      font-weight: 800;
    }
    
    /* Device Cards */
    .device-card {
      background: var(--color-surface);
      border: 1px solid var(--color-border);
      border-radius: var(--radius-md);
      padding: 16px;
      margin-bottom: 12px;
      color: var(--color-text);
      cursor: pointer;
      transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
      box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
    }
    .device-card:hover {
      transform: translateY(-2px);
      border-color: rgba(99, 102, 241, 0.4);
      box-shadow: 0 8px 22px rgba(15, 23, 42, 0.12);
    }
    .device-card.selected {
      border-color: var(--color-primary);
      box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18), var(--shadow-card);
    }
    .device-card.stale {
      border-color: rgba(245, 158, 11, 0.45);
    }
    .device-card.deactivated {
      opacity: 0.74;
    }
    .device-card-header {
      display: flex;
      gap: 10px;
      justify-content: space-between;
      align-items: flex-start;
      margin-bottom: 8px;
    }
    .device-name {
      font-size: 16px;
      font-weight: 600;
      margin-bottom: 4px;
    }
    .device-serial {
      font-size: 12px;
      color: var(--color-muted);
      font-family: monospace;
    }
    .device-stats {
      display: flex;
      justify-content: space-between;
      font-size: 12px;
      color: var(--color-muted);
      margin-top: 8px;
      padding-top: 8px;
      border-top: 1px solid var(--color-border);
      gap: 10px;
    }
    .device-location-summary {
      margin-top: 10px;
      padding: 10px;
      border-radius: var(--radius-sm);
      background: #f8fafc;
      color: var(--color-text);
      font-size: 13px;
      line-height: 1.45;
    }
    .device-location-summary .muted {
      color: var(--color-muted);
      font-size: 12px;
    }
    .device-diagnostic-summary {
      background: #eff6ff;
      border: 1px solid #bfdbfe;
      border-radius: var(--radius-sm);
      color: #1e3a8a;
      margin: 10px 0 14px;
      padding: 10px;
    }
    .device-diagnostic-summary.compact {
      margin: 8px 0 0;
      padding: 8px;
    }
    .device-diagnostic-summary h3 {
      color: #1d4ed8;
      font-size: 11px;
      font-weight: 800;
      letter-spacing: 0.04em;
      margin-bottom: 6px;
      text-transform: uppercase;
    }
    .device-diagnostic-summary p {
      font-size: 12px;
      line-height: 1.4;
      margin-bottom: 8px;
    }
    .device-diagnostic-summary dl {
      display: grid;
      gap: 6px;
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .device-diagnostic-summary div {
      min-width: 0;
    }
    .device-diagnostic-summary dt {
      color: #2563eb;
      font-size: 10px;
      font-weight: 800;
      text-transform: uppercase;
    }
    .device-diagnostic-summary dd {
      color: #1e3a8a;
      font-size: 11px;
      font-weight: 700;
      overflow-wrap: anywhere;
    }
    .device-actions {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      margin-top: 10px;
    }
    .device-action-btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: auto;
      padding: 7px 11px;
      background: rgba(99, 102, 241, 0.1);
      color: var(--color-primary-dark);
      border: 1px solid rgba(99, 102, 241, 0.18);
      border-radius: var(--radius-sm);
      font-size: 12px;
      font-weight: 600;
    }
    .device-action-btn:hover {
      background: rgba(99, 102, 241, 0.16);
    }

    .device-card-clickarea:focus-visible,
    .location-history-header:focus-visible,
    .location-item:focus-visible,
    .device-action-btn:focus-visible,
    .device-detail-close:focus-visible {
      outline: 3px solid rgba(99, 102, 241, 0.55);
      outline-offset: 3px;
      border-radius: var(--radius-sm);
    }
    .device-action-btn.disabled,
    .device-action-btn[aria-disabled="true"],
    .device-action-btn[disabled] {
      pointer-events: none;
      opacity: 0.5;
      cursor: not-allowed;
    }
    .status-badge {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      border-radius: 999px;
      padding: 5px 9px;
      font-size: 12px;
      font-weight: 700;
      line-height: 1;
      white-space: nowrap;
      border: 1px solid transparent;
    }
    .status-badge.sm {
      padding: 4px 7px;
      font-size: 11px;
    }
    .status-badge::before {
      content: '';
      width: 7px;
      height: 7px;
      border-radius: 999px;
      background: currentColor;
    }
    .status-success { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
    .status-warning { background: #fef3c7; color: #92400e; border-color: #fde68a; }
    .status-danger { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
    .status-muted { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }

    .activation-intro {
      color: var(--color-muted);
      font-size: 14px;
      line-height: 1.5;
      margin: 0 0 18px;
    }
    .field-hint {
      color: var(--color-muted);
      display: block;
      font-size: 12px;
      line-height: 1.4;
      margin-top: 6px;
    }
    .modal-help {
      color: var(--color-muted);
      font-size: 13px;
      line-height: 1.45;
      margin: 0 0 14px;
    }
    .settings-validation-status {
      background: #fff7ed;
      border: 1px solid #fed7aa;
      border-radius: var(--radius-sm);
      color: #9a3412;
      font-size: 14px;
      margin-bottom: 16px;
      padding: 12px;
    }
    .auth-validation-status {
      background: #fff7ed;
      border: 1px solid #fed7aa;
      border-radius: var(--radius-sm);
      color: #9a3412;
      font-size: 14px;
      line-height: 1.45;
      margin-bottom: 16px;
      padding: 12px;
    }
    .dev-demo-login-hint {
      background: #eff6ff;
      border: 1px solid #bfdbfe;
      border-radius: var(--radius-sm);
      color: #1d4ed8;
      font-size: 13px;
      line-height: 1.45;
      margin: 0 0 10px;
      padding: 10px 12px;
    }
    #fillDevDemoLogin {
      margin-bottom: 14px;
      width: 100%;
    }
    input[aria-invalid="true"] {
      border-color: #f97316;
      box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.14);
    }
    
    /* Location History */
    .location-history {
      margin-top: 12px;
      padding-top: 12px;
      border-top: 1px solid var(--color-border);
      overflow: hidden;
      transition: max-height 0.3s ease;
    }
    .location-history.expanded {
      max-height: 400px;
      overflow-y: auto;
    }
    .location-history-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 8px;
      cursor: pointer;
    }
    .location-history-header:hover {
      opacity: 0.8;
    }
    .history-filter-chips {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      margin: 8px 0 10px;
    }
    .history-filter-chip {
      background: #f8fafc;
      border: 1px solid var(--color-border);
      border-radius: 999px;
      color: var(--color-muted);
      cursor: pointer;
      font-size: 11px;
      font-weight: 700;
      padding: 6px 10px;
      transition: background 0.2s, border-color 0.2s, color 0.2s;
    }
    .history-filter-chip:hover,
    .history-filter-chip:focus-visible {
      border-color: var(--color-primary);
      color: var(--color-primary-dark);
      outline: none;
    }
    .history-filter-chip.active {
      background: #eef2ff;
      border-color: #c7d2fe;
      color: var(--color-primary-dark);
    }
    .history-filter-status {
      color: var(--color-muted);
      font-size: 12px;
      margin: -4px 0 10px;
      outline: none;
    }
    .history-filter-status:focus {
      color: var(--color-primary-dark);
    }
    .location-item {
      background: #f8fafc;
      padding: 8px;
      border-radius: var(--radius-sm);
      margin-bottom: 6px;
      cursor: pointer;
      transition: background 0.2s;
      font-size: 12px;
    }
    .location-item:hover {
      background: #eef2ff;
    }
    .location-item.latest {
      background: #ecfdf5;
      border: 1px solid #a7f3d0;
    }
    .location-item.selected {
      background: #dbeafe;
      border: 1px solid #93c5fd;
    }
    .location-time {
      font-weight: 600;
      margin-bottom: 4px;
    }
    .location-coords {
      color: var(--color-muted);
      font-family: monospace;
      font-size: 11px;
    }
    .toggle-icon {
      transition: transform 0.3s;
    }
    .toggle-icon.rotated {
      transform: rotate(180deg);
    }
    
    /* Modal */
    .modal {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0,0,0,0.5);
      align-items: center;
      justify-content: center;
      z-index: 1000;
    }
    .modal.active {
      display: flex;
    }
    .modal-content {
      background: var(--color-surface);
      padding: 32px;
      border-radius: var(--radius-md);
      max-width: 500px;
      width: 90%;
      max-height: 90vh;
      overflow-y: auto;
    }
    .modal-header {
      margin-bottom: 24px;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    .modal-header h2 {
      font-size: 20px;
      color: #111;
    }
    .modal-actions {
      display: flex;
      gap: 12px;
      margin-top: 24px;
    }

    .form-status[role="status"],
    .form-status[role="alert"] {
      line-height: 1.45;
    }
    form[aria-busy="true"] {
      opacity: 0.86;
    }
    form[aria-busy="true"] input {
      background: #f8fafc;
    }
    button[disabled],
    .rename-action-btn[disabled] {
      opacity: 0.7;
      cursor: not-allowed;
    }
    .settings-section {
      margin-bottom: 24px;
      padding-bottom: 24px;
      border-bottom: 1px solid var(--color-border);
    }
    .settings-section:last-child {
      border-bottom: none;
    }
    .settings-section h3 {
      font-size: 16px;
      margin-bottom: 16px;
      color: #333;
    }
    
    /* Admin Panel */
    .admin-section {
      background: var(--color-surface);
      border-radius: var(--radius-md);
      padding: 20px;
      margin-bottom: 20px;
      box-shadow: var(--shadow-card);
    }
    .admin-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 16px;
    }
    .admin-stats {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
      gap: 16px;
      margin-bottom: 20px;
    }
    .stat-card {
      background: var(--gradient-brand);
      color: white;
      padding: 16px;
      border-radius: var(--radius-sm);
    }
    .stat-value {
      font-size: 32px;
      font-weight: bold;
    }
    .stat-label {
      font-size: 14px;
      opacity: 0.9;
    }

    @keyframes skeleton-shimmer {
      100% { transform: translateX(100%); }
    }
    
    @media (max-width: 1024px) {
      .fleet-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }
      .main-content {
        grid-template-columns: 1fr;
      }
      .sidebar {
        max-height: 400px;
      }
      #map {
        height: 460px;
      }
    }

    /* Utility and migrated inline styles */
    .empty-state {
      color: var(--color-muted);
      text-align: center;
    }
    .device-list-status {
      border: 1px dashed rgba(99, 102, 241, 0.35);
      border-radius: var(--radius-md);
      color: var(--color-muted);
      padding: 20px;
      text-align: center;
    }
    .device-list-status.loading-state {
      background: linear-gradient(90deg, #f8fafc, #eef2ff, #f8fafc);
      font-weight: 700;
    }
    .device-list-status.error-state {
      border-color: rgba(239, 68, 68, 0.35);
      background: #fef2f2;
      color: #991b1b;
      font-weight: 700;
    }
    .empty-state-card {
      background: rgba(255, 255, 255, 0.72);
    }
    .empty-state-title {
      color: var(--color-text);
      font-weight: 800;
      margin-bottom: 6px;
    }
    .empty-state-action {
      margin-top: 14px;
    }
    .sr-only {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: -1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
      white-space: nowrap;
      border: 0;
    }
    .empty-state.padded {
      padding: 20px;
    }
    .modal-content-wide {
      max-width: 1200px;
      width: 95%;
    }
    .device-card-clickarea {
      cursor: pointer;
    }
    .locations-list {
      margin-top: 8px;
    }
    .location-empty,
    .location-error {
      font-size: 12px;
      opacity: 0.85;
    }
    .location-empty {
      color: var(--color-muted);
    }
    .location-error {
      color: var(--color-danger);
      font-weight: 700;
    }
    .location-empty:focus,
    .location-error:focus {
      outline: 3px solid rgba(37, 99, 235, 0.24);
      outline-offset: 3px;
      border-radius: var(--radius-sm);
    }
    .device-action-body {
      font-size: 14px;
      margin-bottom: 20px;
    }
    .device-action-confirmation {
      background: #fffbeb;
      border: 1px solid rgba(245, 158, 11, 0.38);
      border-radius: var(--radius-sm);
      color: #92400e;
      font-size: 14px;
      font-weight: 700;
      line-height: 1.45;
      margin-bottom: 16px;
      padding: 12px;
    }
    .modal-actions button.requires-confirmation {
      outline: 3px solid rgba(245, 158, 11, 0.32);
      outline-offset: 2px;
    }
    .admin-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 20px;
    }
    .admin-scroll-list {
      max-height: 500px;
      overflow-y: auto;
    }
    .admin-filter {
      padding: 8px;
      border-radius: var(--radius-sm);
      border: 1px solid var(--color-border);
    }
    .admin-filter-status {
      color: var(--color-muted);
      font-size: 12px;
      font-weight: 700;
      margin: -4px 0 12px;
    }
    .admin-user-card {
      background: linear-gradient(135deg, #10b981 0%, #059669 100%);
      color: white;
      border-color: transparent;
    }
    .admin-user-card .device-serial {
      color: rgba(255,255,255,0.86);
    }
    .admin-card-meta {
      font-size: 12px;
      margin-top: 8px;
      padding-top: 8px;
      border-top: 1px solid rgba(255,255,255,0.3);
    }
    .admin-error-state {
      color: #dc2626;
      padding: 20px;
    }
    .admin-device-group {
      margin-bottom: 20px;
    }
    .admin-group-title {
      font-size: 14px;
      margin-bottom: 8px;
    }
    .admin-device-card {
      margin-bottom: 10px;
    }
    .admin-device-card-clickarea {
      display: block;
      border-radius: var(--radius-sm);
    }
    .admin-meta-row {
      margin-bottom: 4px;
    }
    .admin-status {
      font-weight: 600;
    }
    .status-success-text { color: #059669; }
    .status-warning-text { color: #d97706; }
    .status-danger-text { color: #dc2626; }
    .status-muted-text { color: #6b7280; }
    .admin-inline-action {
      padding: 4px 12px;
      font-size: 12px;
      background: rgba(15, 23, 42, 0.2);
      margin-top: 10px;
    }
    .rename-device-info {
      background: #f0f0f0;
      padding: 12px;
      border-radius: 4px;
      margin-bottom: 16px;
    }
    .rename-actions {
      display: flex;
      gap: 10px;
      margin-top: 16px;
    }
    .rename-action-btn {
      flex: 1;
      padding: 12px;
      border: none;
      border-radius: var(--radius-sm);
      background: var(--color-primary);
      color: white;
      cursor: pointer;
      font-weight: 700;
    }
    .rename-action-btn:hover {
      background: var(--color-primary-dark);
    }
    .rename-action-btn.secondary {
      background: #e2e8f0;
      color: var(--color-text);
    }
    .rename-action-btn.secondary:hover {
      background: #cbd5e1;
    }


    /* Device Detail Drawer */
    .device-detail-drawer {
      background: var(--color-surface);
      border: 1px solid var(--color-border);
      border-radius: var(--radius-md);
      box-shadow: var(--shadow-card);
      padding: 20px;
    }
    .device-detail-empty {
      color: var(--color-muted);
      font-size: 14px;
      line-height: 1.5;
      padding: 24px;
      text-align: center;
    }
    .device-detail-header {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      align-items: flex-start;
      margin-bottom: 14px;
    }
    .device-detail-header h2 {
      color: var(--color-text);
      font-size: 18px;
      line-height: 1.25;
    }
    .device-detail-close {
      width: 32px;
      height: 32px;
      border: 1px solid var(--color-border);
      border-radius: 999px;
      background: var(--color-surface);
      color: var(--color-muted);
      cursor: pointer;
      font-size: 20px;
      line-height: 1;
    }
    .device-detail-close:hover {
      color: var(--color-text);
      border-color: rgba(99, 102, 241, 0.35);
    }
    .device-detail-status-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      color: var(--color-muted);
      font-size: 12px;
      margin-bottom: 14px;
    }
    .device-detail-meta {
      display: grid;
      grid-template-columns: 1fr;
      gap: 10px;
      margin-bottom: 16px;
    }
    .device-detail-meta div,
    .device-detail-location {
      background: #f8fafc;
      border: 1px solid var(--color-border);
      border-radius: var(--radius-sm);
      padding: 10px;
    }
    .device-detail-location.no-location {
      border-color: rgba(245, 158, 11, 0.35);
      background: #fffbeb;
    }
    .device-detail-location:focus {
      outline: 3px solid rgba(37, 99, 235, 0.25);
      outline-offset: 2px;
    }
    .device-detail-meta dt,
    .device-detail-location h3,
    .device-detail-history h3 {
      color: var(--color-muted);
      font-size: 11px;
      font-weight: 800;
      letter-spacing: 0.04em;
      margin-bottom: 4px;
      text-transform: uppercase;
    }
    .device-detail-meta dd,
    .device-detail-location p {
      color: var(--color-text);
      font-size: 13px;
      word-break: break-word;
    }
    .device-detail-actions {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      margin: 14px 0;
    }
    .device-action-btn.disabled,
    .device-action-btn[disabled] {
      opacity: 0.5;
      pointer-events: none;
    }
    .device-detail-history-list {
      list-style: none;
      margin-top: 8px;
    }
    .device-detail-history-item {
      display: flex;
      justify-content: space-between;
      gap: 8px;
      width: 100%;
      padding: 9px 0;
      border: 0;
      border-bottom: 1px solid var(--color-border);
      background: transparent;
      color: var(--color-muted);
      cursor: pointer;
      font: inherit;
      font-size: 12px;
      text-align: left;
    }
    .device-detail-history-item.latest {
      color: var(--color-text);
      font-weight: 600;
    }
    .device-detail-history-item:hover,
    .device-detail-history-item.selected {
      color: var(--color-primary-dark);
      background: rgba(99, 102, 241, 0.06);
    }
    .device-detail-history-item:focus-visible {
      outline: 3px solid rgba(99, 102, 241, 0.35);
      outline-offset: 2px;
    }
    .device-detail-history-item strong {
      color: inherit;
      font-family: monospace;
      white-space: nowrap;
    }
    .device-detail-muted,
    .device-detail-error {
      color: var(--color-muted);
      font-size: 13px;
      margin-top: 8px;
    }
    .device-detail-error {
      color: var(--color-danger);
    }

    @media (min-width: 1025px) {
      .main-content {
        grid-template-columns: 350px minmax(0, 1fr) 320px;
        align-items: start;
      }
      .device-detail-drawer {
        max-height: calc(100vh - 120px);
        overflow-y: auto;
        position: sticky;
        top: 24px;
      }
    }

    @media (max-width: 1024px) {
      .device-detail-drawer {
        order: 3;
      }
    }

    @media (max-width: 768px) {
      .header {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
        padding: 14px 16px;
      }
      .header .user-info {
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
        width: 100%;
      }
      .header .user-info .btn-small {
        width: 100%;
      }
      .fleet-kpi-grid {
        grid-template-columns: 1fr;
        padding: 16px 14px 0;
      }
      .main-content {
        gap: 14px;
        padding: 14px;
      }
      .sidebar {
        max-height: none;
        padding: 16px;
      }
      .sidebar h2 {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
      }
      .sidebar-actions,
      .device-actions,
      .device-detail-actions,
      .rename-actions {
        flex-direction: column;
      }
      .device-action-btn,
      .rename-action-btn {
        justify-content: center;
        text-align: center;
        width: 100%;
      }
      .map-panel {
        padding: 14px;
      }
      .map-panel-header {
        flex-direction: column;
      }
      .map-panel-summary {
        max-width: none;
        text-align: left;
      }
      #map {
        height: 360px;
        min-height: 320px;
      }
      .map-panel-error {
        left: 10px;
        right: 10px;
        top: 10px;
      }
      .device-detail-drawer {
        bottom: 0;
        left: 0;
        max-height: 78vh;
        overflow-y: auto;
        padding: 16px;
        position: fixed;
        right: 0;
        transform: translateY(calc(100% - 72px));
        transition: transform 0.2s ease;
        z-index: 1000;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        box-shadow: var(--shadow-elevated);
      }
      .device-detail-drawer.is-open {
        transform: translateY(0);
      }
      .device-detail-drawer::before {
        content: '';
        display: block;
        width: 44px;
        height: 4px;
        margin: 0 auto 12px;
        border-radius: 999px;
        background: var(--color-border);
      }
      .device-detail-empty {
        padding: 10px 16px 16px;
      }
      .device-detail-status-row,
      .device-detail-history-item {
        align-items: flex-start;
        flex-direction: column;
      }
      .admin-grid {
        grid-template-columns: 1fr;
      }
    }
