:root {
  /* Light Theme (Default) */
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-nav: #ffffff;
  --border-color: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --terminal-bg: #0f172a;
  --input-bg: #f8fafc;
  --badge-bg: #f1f5f9;
  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --card-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --modal-overlay-bg: rgba(15, 23, 42, 0.6);
  --remote-bg: #1e293b;
  --remote-btn-bg: #334155;
  --radius: 12px;
}

[data-theme="dark"] {
  /* Dark Theme */
  --bg-main: #0b0f19;
  --bg-card: #131b2e;
  --bg-card-hover: #1b2640;
  --bg-nav: #0f172a;
  --border-color: #1e293b;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --terminal-bg: #030712;
  --input-bg: #0f172a;
  --badge-bg: #1e293b;
  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --card-shadow-hover: 0 10px 20px -3px rgba(0, 0, 0, 0.6);
  --modal-overlay-bg: rgba(0, 0, 0, 0.8);
  --remote-bg: #030712;
  --remote-btn-bg: #1e293b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* ==========================================================================
   Navbar
   ========================================================================== */
.navbar {
  background-color: var(--bg-nav);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-icon {
  font-size: 1.8rem;
  color: var(--primary);
  filter: drop-shadow(0 0 6px rgba(37, 99, 235, 0.3));
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

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

.nav-metrics {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.metric-badge {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  background-color: var(--badge-bg);
  border: 1px solid var(--border-color);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.metric-total strong { color: var(--text-main); }
.metric-online strong { color: var(--success); }
.metric-offline strong { color: var(--text-dim); }
.metric-alerts strong { color: var(--danger); }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.ws-status {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  background: rgba(22, 163, 74, 0.1);
  color: var(--success);
  border: 1px solid rgba(22, 163, 74, 0.25);
  font-weight: 600;
  white-space: nowrap;
}

.ws-status.disconnected {
  background: rgba(220, 38, 38, 0.1);
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.25);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
  box-shadow: 0 0 6px currentColor;
}

/* ==========================================================================
   Controls Bar
   ========================================================================== */
.controls-bar {
  padding: 1rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  width: 320px;
  max-width: 100%;
  color: var(--text-muted);
  box-shadow: var(--card-shadow);
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  width: 100%;
  font-size: 0.88rem;
}

.search-box input::placeholder {
  color: var(--text-dim);
}

.filter-tabs {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 4px;
  gap: 4px;
  box-shadow: var(--card-shadow);
  overflow-x: auto;
  max-width: 100%;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.45rem 0.95rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tab-btn.active, .tab-btn:hover {
  background: var(--primary);
  color: #ffffff;
}

.view-options {
  display: flex;
  gap: 0.5rem;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #ffffff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg-card); color: var(--text-main); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--bg-card-hover); }
.btn-danger { background: var(--danger); color: #ffffff; }
.btn-danger:hover { opacity: 0.9; }
.btn-success { background: var(--success); color: #ffffff; }
.btn-warning { background: var(--warning); color: #ffffff; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.78rem; }
.btn-icon { width: 38px; height: 38px; padding: 0; }

/* ==========================================================================
   Device Grid & Cards
   ========================================================================== */
.main-content {
  flex: 1;
  padding: 0 1.75rem 2.5rem 1.75rem;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 5rem 1rem;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 3rem;
  color: var(--primary);
  margin-bottom: 1.25rem;
}

.empty-state p {
  font-size: 0.88rem;
  margin-top: 0.5rem;
  color: var(--text-dim);
}

.device-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--card-shadow);
}

.device-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-shadow-hover);
  border-color: rgba(37, 99, 235, 0.4);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.85rem;
  gap: 0.5rem;
}

.card-title {
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.25rem;
  word-break: break-word;
}

.card-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.mac-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.76rem;
  background: var(--badge-bg);
  color: var(--primary);
  border: 1px solid var(--border-color);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  padding: 0.25rem 0.55rem;
  border-radius: 12px;
  font-weight: 600;
  text-transform: uppercase;
  flex-shrink: 0;
}

.status-pill.online {
  background: rgba(22, 163, 74, 0.12);
  color: var(--success);
}

.status-pill.offline {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-dim);
}

.telemetry-bars {
  margin: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.t-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--badge-bg);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--primary);
  transition: width 0.4s ease;
}

.bar-fill.warning { background: var(--warning); }
.bar-fill.danger { background: var(--danger); }

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-color);
  gap: 0.5rem;
}

/* ==========================================================================
   Modals & Diagnostics Drawer
   ========================================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--modal-overlay-bg);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

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

.modal-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  width: 950px;
  max-width: 96vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.modal-small {
  width: 480px;
}

.modal-header {
  padding: 1.15rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-nav);
  gap: 1rem;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.modal-title-group h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
}

.btn-close:hover { color: var(--text-main); }

/* Diagnostics Navigation Tabs */
.diag-tabs {
  display: flex;
  background: var(--bg-card-hover);
  border-bottom: 1px solid var(--border-color);
  padding: 0 1rem;
  overflow-x: auto;
  scrollbar-width: thin;
}

.diag-tab {
  padding: 0.85rem 1.1rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.diag-tab.active, .diag-tab:hover {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-pane {
  display: none;
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

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

/* Gauges */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.gauge-card {
  background: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.15rem;
  text-align: center;
}

.gauge-card h4 {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.circle-metric {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.network-metric {
  font-size: 1.8rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.metric-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* Details Table */
.details-table-card {
  background: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.details-table-card h3 {
  font-size: 0.95rem;
  margin-bottom: 1rem;
  color: var(--text-main);
}

.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.info-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.info-table td:first-child {
  color: var(--text-muted);
  width: 35%;
  font-weight: 500;
}

.info-table td:last-child {
  color: var(--text-main);
  word-break: break-all;
}

/* Screen Mirror */
.screen-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.form-group.inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.form-group select {
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  outline: none;
}

.tv-screen-wrapper {
  display: flex;
  justify-content: center;
  background: #000000;
  border-radius: var(--radius);
  padding: 1rem;
  border: 2px solid var(--border-color);
  min-height: 280px;
}

.tv-frame {
  max-width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.tv-frame img {
  max-width: 100%;
  max-height: 480px;
  object-fit: contain;
  border-radius: 6px;
  user-select: none;
  -webkit-user-drag: none;
}

.badge-interactive {
  font-size: 0.76rem;
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary);
  border: 1px solid rgba(37, 99, 235, 0.25);
  padding: 0.3rem 0.65rem;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.screen-nav-bar {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.touch-ripple {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.6);
  border: 2px solid #ffffff;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.4);
  animation: ripple-anim 0.45s ease-out forwards;
  z-index: 50;
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.8);
}

@keyframes ripple-anim {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.8); opacity: 0; }
}

.screen-placeholder {
  padding: 4rem 1.5rem;
  text-align: center;
  color: #94a3b8;
}

.screen-placeholder i {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  color: #64748b;
}

/* Terminal */
.terminal-quick-cmds {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-chip {
  background: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-size: 0.76rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.terminal-window {
  background: var(--terminal-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1rem;
  height: 320px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  color: #38bdf8;
  line-height: 1.45;
  white-space: pre-wrap;
}

.terminal-line.error { color: #f87171; }
.terminal-line.system { color: #c084fc; }
.terminal-line.cmd { color: #4ade80; }

.terminal-input-bar {
  display: flex;
  align-items: center;
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 0.5rem 0.75rem;
  gap: 0.5rem;
}

.terminal-input-bar .prompt {
  color: #4ade80;
  font-family: monospace;
  font-weight: 700;
}

.terminal-input-bar input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-family: monospace;
  font-size: 0.85rem;
}

/* Logcat Stream */
.logs-toolbar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.logs-toolbar select, .logs-toolbar input {
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  font-size: 0.82rem;
  outline: none;
}

.logs-stream-window {
  background: var(--terminal-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  height: 360px;
  overflow-y: auto;
  padding: 0.85rem;
  font-family: monospace;
  font-size: 0.8rem;
  line-height: 1.4;
}

.log-line { padding: 2px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.04); }
.log-line.error { color: #f87171; }
.log-line.warn { color: #fbbf24; }
.log-line.info { color: #60a5fa; }
.log-line.debug { color: #94a3b8; }
.log-line.verbose { color: #64748b; }

/* Virtual Remote Controller */
.remote-layout {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  justify-content: center;
  padding: 1rem 0;
  flex-wrap: wrap;
}

.remote-controller {
  background: var(--remote-bg);
  border: 2px solid var(--border-color);
  border-radius: 36px;
  padding: 1.5rem 1.25rem;
  width: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
}

.remote-top-row, .remote-row {
  display: flex;
  justify-content: space-around;
  width: 100%;
}

.btn-remote {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: var(--remote-btn-bg);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-remote:active {
  transform: scale(0.92);
  background: var(--primary);
}

.btn-remote.red { background: #b91c1c; border-color: #ef4444; }

.dpad {
  position: relative;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: #0f172a;
  border: 2px solid #334155;
}

.dpad-btn {
  position: absolute;
  background: #1e293b;
  border: none;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
}

.dpad-btn:active { background: var(--primary); }

.dpad-btn.up { top: 0; left: 45px; width: 70px; height: 45px; border-radius: 35px 35px 0 0; }
.dpad-btn.down { bottom: 0; left: 45px; width: 70px; height: 45px; border-radius: 0 0 35px 35px; }
.dpad-btn.left { top: 45px; left: 0; width: 45px; height: 70px; border-radius: 35px 0 0 35px; }
.dpad-btn.right { top: 45px; right: 0; width: 45px; height: 70px; border-radius: 0 35px 35px 0; }
.dpad-btn.ok { top: 48px; left: 48px; width: 64px; height: 64px; border-radius: 50%; font-weight: 700; background: #334155; }

.remote-instructions {
  max-width: 320px;
}

.remote-instructions h3 { margin-bottom: 0.5rem; font-size: 1.1rem; color: var(--text-main); }
.remote-instructions p { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1rem; }
.remote-instructions ul { padding-left: 1.25rem; font-size: 0.82rem; color: var(--text-muted); line-height: 1.6; }

/* Actions & Apps Tab */
.actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.action-card {
  background: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.action-card h4 {
  font-size: 0.95rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.action-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.action-card input[type="text"], .action-card input[type="file"], textarea {
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.6rem 0.85rem;
  border-radius: 6px;
  font-size: 0.85rem;
  width: 100%;
  outline: none;
}

.btn-group {
  display: flex;
  gap: 0.5rem;
}

/* Broadcast Modal Body */
.modal-body {
  padding: 1.5rem;
}

.modal-body p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: var(--bg-nav);
}

/* ==========================================================================
   Responsive Breakpoints & Mobile Optimization
   ========================================================================== */
@media (max-width: 900px) {
  .navbar {
    padding: 0.75rem 1rem;
  }
  .controls-bar {
    padding: 0.75rem 1rem;
  }
  .main-content {
    padding: 0 1rem 2rem 1rem;
  }
  .nav-metrics {
    order: 3;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .nav-actions {
    margin-left: auto;
  }
}

@media (max-width: 768px) {
  .controls-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .search-box {
    width: 100%;
  }
  .filter-tabs {
    width: 100%;
    justify-content: space-between;
  }
  .device-grid {
    grid-template-columns: 1fr;
  }
  .modal-overlay {
    padding: 0;
  }
  .modal-container {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
  .modal-header {
    padding: 0.85rem 1rem;
  }
  .tab-pane {
    padding: 1rem;
  }
  .hide-mobile {
    display: none;
  }
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .stats-row {
    grid-template-columns: 1fr;
  }
  .btn-chip {
    font-size: 0.7rem;
    padding: 0.2rem 0.45rem;
  }
  .modal-header-actions .btn-sm {
    padding: 0.3rem 0.5rem;
    font-size: 0.72rem;
  }
}
