/* ============================================================
   MikroTik Network Manager - Main Stylesheet
   public/css/style.css
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --bg2: #1a1d27;
  --bg3: #222636;
  --card: #1e2235;
  --border: #2d3250;
  --accent: #4f7ef8;
  --accent2: #6c8fff;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --orange: #f97316;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --text3: #64748b;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

html { font-size: 15px; }
body { 
  background: var(--bg); 
  color: var(--text); 
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; 
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; } 
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ---- LAYOUT ---- */
.app-layout { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 220px; background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.main-content { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }

/* ---- SIDEBAR ---- */
.sidebar-logo { padding: 22px 20px 18px; border-bottom: 1px solid var(--border); }
.sidebar-logo .logo-title { font-size: 1rem; font-weight: 700; color: var(--text); letter-spacing: .5px; }
.sidebar-logo .logo-sub { font-size: 0.72rem; color: var(--text3); margin-top: 2px; }
.sidebar-logo svg { margin-bottom: 8px; }

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 20px; cursor: pointer; color: var(--text2); font-size: 0.88rem; font-weight: 500; border-radius: 0; transition: all .2s; border-left: 3px solid transparent; }
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: rgba(79,126,248,.12); color: var(--accent2); border-left-color: var(--accent); }
.nav-item .nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }
.nav-badge { margin-left: auto; background: var(--red); color: #fff; font-size: 0.7rem; font-weight: 700; padding: 1px 6px; border-radius: 10px; min-width: 18px; text-align: center; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); }
.btn-logout { width: 100%; background: transparent; border: 1px solid var(--border); color: var(--text2); padding: 8px; border-radius: 8px; cursor: pointer; font-size: 0.82rem; transition: all .2s; }
.btn-logout:hover { background: var(--red); border-color: var(--red); color: #fff; }

/* ---- TOPBAR ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; background: var(--bg2); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.topbar-title { font-size: 1.1rem; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.connection-status { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text2); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text3); }
.status-dot.connected { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.disconnected { background: var(--red); }

/* ---- PAGES ---- */
.page { display: none; padding: 24px; }
.page.active { display: block; }

/* ---- STATS ROW ---- */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.stat-label { font-size: 0.75rem; color: var(--text3); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.stat-sub { font-size: 0.75rem; color: var(--text3); margin-top: 4px; }
.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }
.stat-value.accent { color: var(--accent2); }

/* ---- CARDS ---- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 0.95rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 16px 20px; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---- INTERFACE LIST ---- */
.iface-list { display: flex; flex-direction: column; gap: 8px; }
.iface-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--bg3); border-radius: 8px; border: 1px solid var(--border); transition: background 0.15s ease; }
.iface-item:hover { background: rgba(255, 255, 255, 0.05); }
.iface-status { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.iface-status.up { background: var(--green); box-shadow: 0 0 6px var(--green); }
.iface-status.down { background: var(--text3); }
.iface-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.iface-name { font-weight: 600; font-size: 0.88rem; min-width: 120px; }
.iface-ip { font-size: 0.8rem; color: var(--text2); flex: 1; }
.iface-bw { display: flex; align-items: center; gap: 14px; font-size: 0.8rem; }
.iface-rates { display: flex; align-items: center; gap: 10px; }
.bw-dl { color: var(--green); }
.bw-ul { color: var(--accent2); }

/* ---- BANDWIDTH CHART ---- */
.chart-container { height: 200px; position: relative; }

/* ---- TOOLBAR & FILTER TABS ---- */
.device-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 18px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
}

.filter-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg2);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text2);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  font-family: 'Poppins', sans-serif;
}

.filter-tab:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}

.filter-tab.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(79,126,248,0.3);
}

.tab-badge {
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: 10px;
  background: rgba(255,255,255,0.15);
  font-weight: 600;
}

.tab-badge.green {
  background: rgba(34,197,94,0.25);
  color: #22c55e;
}

.filter-tab.active .tab-badge.green {
  background: rgba(255,255,255,0.25);
  color: #fff;
}

.tab-badge.red {
  background: rgba(239,68,68,0.25);
  color: #ef4444;
}

.filter-tab.active .tab-badge.red {
  background: rgba(255,255,255,0.25);
  color: #fff;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  width: 280px;
  transition: border .2s;
}

.search-box:focus-within {
  border-color: var(--accent);
}

.search-box .search-icon {
  font-size: 0.85rem;
  color: var(--text3);
  margin-right: 8px;
}

.search-box input {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.85rem;
  padding: 8px 0;
  width: 100%;
  outline: none;
  font-family: 'Poppins', sans-serif;
}

/* ---- DEVICE TABLE ---- */
.device-table { 
  width: 100%; 
  border-collapse: collapse; 
  min-width: 760px;
}
.device-table th { 
  text-align: center; 
  font-size: 0.8rem; 
  font-weight: 600; 
  text-transform: uppercase; 
  letter-spacing: .6px; 
  color: #94a3b8; 
  padding: 12px 14px; 
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.45);
  vertical-align: middle;
}
.device-table td { 
  text-align: center;
  padding: 13px 14px; 
  border-bottom: 1px solid rgba(255, 255, 255, 0.06); 
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.92rem; 
  vertical-align: middle; 
}
.device-table th:last-child,
.device-table td:last-child { 
  border-right: none; 
}
.device-table tr:last-child td { 
  border-bottom: none; 
}
.device-table tr:hover td { 
  background: rgba(255, 255, 255, 0.04); 
}

.device-name { font-weight: 600; color: #ffffff; font-size: 0.95rem; font-family: 'Poppins', sans-serif; text-align: center; }
.device-mac { font-size: 0.88rem; font-weight: 500; color: #cbd5e1; font-family: 'Poppins', sans-serif; letter-spacing: 0.5px; text-align: center; }
.device-ip { font-size: 0.92rem; font-weight: 600; color: #38bdf8; font-family: 'Poppins', sans-serif; text-align: center; }

/* ---- STATUS BADGES ---- */
.badge { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; }
.badge-pending { background: rgba(245,158,11,.15); color: var(--yellow); }
.badge-approved { background: rgba(34,197,94,.12); color: var(--green); }
.badge-blocked { background: rgba(239,68,68,.12); color: var(--red); }
.badge-online { background: rgba(34,197,94,.12); color: var(--green); }
.badge-offline { background: rgba(100,116,139,.12); color: var(--text3); }

/* ---- BUTTONS ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 8px; border: none; font-size: 0.8rem; font-weight: 600; cursor: pointer; transition: all .2s; }
.btn-accept { background: rgba(34,197,94,.15); color: var(--green); border: 1px solid rgba(34,197,94,.3); }
.btn-accept:hover { background: var(--green); color: #fff; }
.btn-reject { background: rgba(239,68,68,.12); color: var(--red); border: 1px solid rgba(239,68,68,.25); }
.btn-reject:hover { background: var(--red); color: #fff; }
.btn-block { background: rgba(239,68,68,.12); color: var(--red); border: 1px solid rgba(239,68,68,.25); }
.btn-block:hover { background: var(--red); color: #fff; }
.btn-unblock { background: rgba(79,126,248,.12); color: var(--accent2); border: 1px solid rgba(79,126,248,.25); }
.btn-unblock:hover { background: var(--accent); color: #fff; }
.btn-icon { background: transparent; border: 1px solid var(--border); color: var(--text2); padding: 5px 8px; border-radius: 6px; cursor: pointer; font-size: 0.85rem; transition: all .2s; }
.btn-icon:hover { background: var(--bg3); color: var(--text); }

.action-buttons { display: flex; gap: 6px; justify-content: center; align-items: center; }

/* ---- PENDING ALERT ---- */
.pending-alert { display: none; background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px; color: var(--yellow); font-size: 0.88rem; align-items: center; gap: 10px; }
.pending-alert.show { display: flex; }

/* ---- TOAST ---- */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { pointer-events: auto; background: #1c2030; border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; padding: 12px 18px; font-size: 0.85rem; font-weight: 500; min-width: 280px; box-shadow: 0 12px 32px rgba(0,0,0,0.5); animation: slideIn .3s cubic-bezier(0.16, 1, 0.3, 1); display: flex; align-items: center; gap: 10px; color: #f8fafc; font-family: 'Poppins', sans-serif; }
.toast.success { border-left: 4px solid var(--green); }
.toast.error { border-left: 4px solid var(--red); }
.toast.info { border-left: 4px solid var(--accent); }
.toast.warning { border-left: 4px solid var(--yellow); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---- MODAL ---- */
.modal-overlay { 
  display: flex; 
  opacity: 0; 
  pointer-events: none; 
  position: fixed; 
  inset: 0; 
  background: rgba(10, 13, 22, 0.78); 
  backdrop-filter: blur(10px); 
  -webkit-backdrop-filter: blur(10px); 
  z-index: 2000; 
  align-items: center; 
  justify-content: center; 
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1); 
}
.modal-overlay.show,
.modal-overlay.active { 
  opacity: 1; 
  pointer-events: auto; 
}
.modal { 
  background: #181b28; 
  border: 1px solid rgba(255,255,255,0.1); 
  border-radius: 16px; 
  padding: 26px; 
  min-width: 320px; 
  max-width: 440px; 
  width: 92%; 
  box-shadow: 0 24px 60px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.06); 
  transform: scale(0.92) translateY(12px); 
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1); 
  font-family: 'Poppins', sans-serif; 
}
.modal-overlay.show .modal,
.modal-overlay.active .modal { 
  transform: scale(1) translateY(0); 
}
.modal h3 { font-size: 1.05rem; font-weight: 700; color: #fff; margin-bottom: 14px; }
.modal-input { width: 100%; background: var(--bg2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 10px 14px; font-size: 0.88rem; outline: none; font-family: 'Poppins', sans-serif; }
.modal-input:focus { border-color: var(--accent); }
.modal-buttons { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }
.btn-primary { background: var(--accent); color: #fff; border: none; padding: 9px 20px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 0.85rem; transition: all 0.2s; font-family: 'Poppins', sans-serif; }
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); }
.btn-secondary { background: var(--bg3); border: 1px solid var(--border); color: var(--text2); padding: 9px 20px; border-radius: 8px; cursor: pointer; font-size: 0.85rem; font-weight: 500; transition: all 0.2s; font-family: 'Poppins', sans-serif; }
.btn-secondary:hover { background: rgba(255,255,255,0.08); color: #fff; }

/* ---- EMPTY STATE ---- */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text3); }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.88rem; }

/* ---- LOADING SPINNER ---- */
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.2); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- DIVIDER ---- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 768px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---- MOBILE BOTTOM APP NAVIGATION & RESPONSIVE ---- */
.mobile-bottom-nav {
  display: none;
}
.mobile-logout-btn {
  display: none;
}
.topbar-logo-mobile {
  display: none;
}
.mobile-menu-btn,
.sidebar-close-btn,
.sidebar-overlay {
  display: none;
}

@media (max-width: 768px) {
  .app-layout { 
    display: flex; 
    flex-direction: column; 
    height: auto; 
    min-height: 100vh; 
    overflow-x: hidden; 
  }

  /* Hide desktop sidebar on mobile since app bottom nav is used */
  .sidebar,
  .sidebar-overlay,
  .mobile-menu-btn,
  .sidebar-close-btn { 
    display: none !important; 
  }

  .topbar-logo-mobile {
    display: flex;
    align-items: center;
  }

  .mobile-logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.14);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fda4af;
    padding: 4px 9px;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.18s ease;
  }
  .mobile-logout-btn:hover {
    background: #ef4444;
    color: #fff;
  }

  /* Fixed Bottom App Navigation Bar (Compact) */
  .mobile-bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: rgba(15, 23, 42, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 -4px 25px rgba(0, 0, 0, 0.65);
    z-index: 1500;
    align-items: center;
    justify-content: space-around;
    padding: 2px 4px calc(2px + env(safe-area-inset-bottom));
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 3px 1px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.18s ease;
    font-family: 'Poppins', sans-serif;
    position: relative;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  .bottom-nav-item:active {
    transform: scale(0.92);
  }

  .bottom-nav-icon {
    font-size: 1.15rem;
    line-height: 1.1;
    position: relative;
    display: inline-block;
    transition: transform 0.18s ease, filter 0.18s ease;
  }

  .bottom-nav-label {
    font-size: 0.62rem;
    font-weight: 500;
    margin-top: 2px;
    letter-spacing: 0.1px;
    color: #94a3b8;
    transition: color 0.18s ease, font-weight 0.18s ease;
  }

  /* Active Tab */
  .bottom-nav-item.active {
    color: #38bdf8;
  }

  .bottom-nav-item.active .bottom-nav-icon {
    transform: translateY(-1px) scale(1.08);
    filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.6));
  }

  .bottom-nav-item.active .bottom-nav-label {
    color: #38bdf8;
    font-weight: 700;
  }

  .bottom-nav-badge {
    position: absolute;
    top: -4px;
    right: -8px;
    background: #ef4444;
    color: #ffffff;
    font-size: 0.58rem;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 8px;
    min-width: 12px;
    text-align: center;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.7);
    line-height: 1.2;
  }

  .main-content { 
    flex: 1; 
    width: 100%; 
    height: auto; 
    overflow-y: auto; 
    overflow-x: hidden;
  }

  .topbar { 
    padding: 6px 10px; 
    min-height: 46px;
    height: 46px;
  }
  .topbar-title { 
    font-size: 0.95rem; 
  }
  .topbar-right span#currentTime {
    display: none !important;
  }

  .stats-row { 
    grid-template-columns: 1fr 1fr; 
    gap: 6px; 
    margin-bottom: 10px;
  }
  .stat-card {
    padding: 8px 10px;
    border-radius: 8px;
  }
  .stat-label {
    font-size: 0.72rem;
    margin-bottom: 2px;
  }
  .stat-value {
    font-size: 1.15rem;
    line-height: 1.2;
  }
  .stat-sub {
    font-size: 0.65rem;
    margin-top: 2px;
  }

  .page { 
    padding: 8px 8px calc(58px + env(safe-area-inset-bottom)) 8px !important; 
  }

  .card {
    border-radius: 10px;
    margin-bottom: 10px;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
  }
  .card-header { 
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 8px 12px;
  }
  .card-title {
    font-size: 0.85rem;
  }
  .card-body {
    padding: 8px 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Compact Interface List on Mobile */
  .iface-list {
    gap: 6px !important;
  }
  .iface-item {
    padding: 7px 10px !important;
    gap: 8px !important;
    border-radius: 8px !important;
  }
  .iface-status {
    width: 7px !important;
    height: 7px !important;
    flex-shrink: 0 !important;
  }
  .iface-info {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 1px !important;
    flex: 1 !important;
    min-width: 0 !important;
  }
  .iface-name {
    font-size: 0.78rem !important;
    min-width: 0 !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  .iface-ip {
    font-size: 0.68rem !important;
    color: #94a3b8 !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  .iface-bw {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important;
    gap: 2px !important;
    flex-shrink: 0 !important;
    font-size: 0.72rem !important;
  }
  .iface-rates {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
  }
  .bw-dl, .bw-ul {
    font-size: 0.72rem !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    line-height: 1.15 !important;
  }
  .iface-bw .badge {
    font-size: 0.58rem !important;
    padding: 1px 5px !important;
    border-radius: 4px !important;
    line-height: 1.2 !important;
  }

  .device-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 8px 10px;
    width: 100%;
    box-sizing: border-box;
  }

  .filter-tabs {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 5px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
  }

  .filter-tab {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    box-sizing: border-box !important;
    background: var(--bg2) !important;
    border: 1px solid var(--border) !important;
    border-radius: 6px !important;
    padding: 6px 4px !important;
    font-size: 0.74rem !important;
    white-space: nowrap !important;
    gap: 4px !important;
  }

  .filter-tab.active {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    color: #fff !important;
  }

  .search-box {
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 5px 9px !important;
    border-radius: 6px !important;
    font-size: 0.78rem !important;
  }
  .search-box input {
    font-size: 0.78rem !important;
  }

  /* Compact Table on Mobile */
  .device-table { 
    display: table !important; 
    width: 100%;
    min-width: 660px;
  }
  .device-table th {
    padding: 5px 6px !important;
    font-size: 0.7rem !important;
    letter-spacing: 0.2px;
    font-weight: 600;
  }
  .device-table td {
    padding: 5px 6px !important;
    font-size: 0.74rem !important;
    line-height: 1.2 !important;
  }
  .device-name {
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    line-height: 1.15 !important;
    max-width: 130px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0 auto;
  }
  .device-mac {
    font-size: 0.65rem !important;
    color: #94a3b8 !important;
    letter-spacing: 0.2px !important;
    line-height: 1.1 !important;
  }
  .device-ip {
    font-size: 0.72rem !important;
    line-height: 1.1 !important;
  }
  .speed-hit-text {
    font-size: 0.76rem !important;
    line-height: 1.15 !important;
  }
  .speed-cap-subtext {
    font-size: 0.6rem !important;
    margin-top: 1px !important;
    line-height: 1.1 !important;
  }
  .speed-hit-badge {
    font-size: 0.56rem !important;
    padding: 1px 4px !important;
    margin-top: 1px !important;
  }

  /* Compact Quota & Usage Cell on Mobile */
  .quota-cell {
    min-width: 100px !important;
  }
  .quota-cell-active {
    min-width: 118px !important;
    max-width: 140px !important;
  }
  .quota-today-val {
    font-size: 0.74rem !important;
    line-height: 1.15 !important;
  }
  .quota-month-val {
    font-size: 0.65rem !important;
    line-height: 1.15 !important;
  }
  .quota-detail-row {
    font-size: 0.62rem !important;
    line-height: 1.15 !important;
  }
  .quota-progress-bar {
    height: 3px !important;
  }
  .quota-badge {
    font-size: 0.55rem !important;
    padding: 1px 4px !important;
  }

  /* Compact Badges */
  .badge {
    padding: 2px 6px !important;
    font-size: 0.62rem !important;
    gap: 3px !important;
  }

  /* Compact Action Buttons in Table */
  .action-buttons { 
    flex-wrap: nowrap !important;
    justify-content: center !important;
    gap: 3px !important;
  }
  .action-buttons .btn {
    padding: 3px 5px !important;
    font-size: 0.67rem !important;
    gap: 2px !important;
    border-radius: 5px !important;
  }
  .action-buttons .btn-icon {
    padding: 3px 5px !important;
    font-size: 0.72rem !important;
    border-radius: 5px !important;
  }
  .action-buttons .btn-usage {
    padding: 3px 5px !important;
    font-size: 0.67rem !important;
    border-radius: 5px !important;
  }
  .btn-accept, .btn-reject, .btn-block, .btn-unblock {
    padding: 3px 6px !important;
    font-size: 0.68rem !important;
  }

  /* Compact Pending Alert */
  .pending-alert {
    padding: 7px 10px !important;
    margin-bottom: 8px !important;
    font-size: 0.78rem !important;
    gap: 6px !important;
    border-radius: 8px !important;
  }
  .pending-alert .btn {
    padding: 3px 8px !important;
    font-size: 0.7rem !important;
  }

  /* Compact Empty State */
  .empty-state {
    padding: 16px 10px !important;
  }
  .empty-state .empty-icon {
    font-size: 1.6rem !important;
    margin-bottom: 4px !important;
  }
  .empty-state p {
    font-size: 0.76rem !important;
  }

  /* Compact Monthly Usage Rows in Modal */
  .monthly-usage-row {
    padding: 6px 10px !important;
    gap: 3px !important;
    border-radius: 6px !important;
  }
  .monthly-usage-row span[style*="font-weight:600"] {
    font-size: 0.78rem !important;
  }
  .monthly-usage-row span[style*="font-size:0.72rem"] {
    font-size: 0.65rem !important;
  }
  .monthly-usage-row span[style*="font-weight:700"] {
    font-size: 0.82rem !important;
  }
  .monthly-usage-row div[style*="height:5px"] {
    height: 3px !important;
  }
  #usageModal .stat-card {
    padding: 6px 6px !important;
  }
  #usageModal .stat-card .stat-label {
    font-size: 0.62rem !important;
  }
  #usageModal .stat-card .stat-value {
    font-size: 0.88rem !important;
  }

  .grid-2 { 
    grid-template-columns: 1fr; 
  }
  .chart-container {
    height: 150px !important;
  }

  /* Floating batch bar on mobile */
  .batch-bar {
    width: calc(100% - 16px);
    left: 8px;
    bottom: calc(58px + env(safe-area-inset-bottom)) !important;
    transform: translateY(140px);
    padding: 6px 10px;
    border-radius: 10px;
  }
  .batch-bar.show {
    transform: translateY(0);
  }
  .batch-bar-content {
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
  }
  .batch-actions {
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
  }
  .btn-batch-block,
  .btn-batch-unblock,
  .btn-batch-remove {
    padding: 4px 8px;
    font-size: 0.7rem;
  }

  /* Modals on mobile */
  .modal {
    width: 95% !important;
    max-width: 95vw !important;
    padding: 16px 12px !important;
    border-radius: 12px;
  }
}

@media (max-width: 480px) {
  .stats-row { 
    grid-template-columns: 1fr 1fr; 
    gap: 5px; 
  }
  .stat-card {
    padding: 7px 8px;
  }
  .stat-label {
    font-size: 0.68rem;
  }
  .stat-value { 
    font-size: 1.05rem; 
  }
  .stat-sub {
    font-size: 0.62rem;
  }

  #usageModal [style*="grid-template-columns:repeat(3, 1fr)"],
  #usageModal [style*="grid-template-columns: repeat(3, 1fr)"] {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 5px !important;
  }
}


/* ---- BATCH ACTIONS & CHECKBOXES ---- */
.device-checkbox, .select-all-checkbox {
  width: 17px;
  height: 17px;
  accent-color: #6366f1;
  cursor: pointer;
  border-radius: 4px;
  vertical-align: middle;
}

.batch-bar {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(99, 102, 241, 0.35);
  border-radius: 14px;
  padding: 8px 16px;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.28s ease;
  font-family: 'Poppins', sans-serif;
}

.batch-bar.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.batch-bar-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.batch-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

.batch-badge {
  background: #6366f1;
  color: #fff;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 0.76rem;
  font-weight: 700;
}

.batch-divider {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, 0.12);
}

.batch-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-batch-block {
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  padding: 6px 13px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: 'Poppins', sans-serif;
}
.btn-batch-block:hover {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
  transform: translateY(-1px);
}

.btn-batch-unblock {
  background: rgba(34, 197, 94, 0.16);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #86efac;
  padding: 6px 13px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: 'Poppins', sans-serif;
}
.btn-batch-unblock:hover {
  background: #22c55e;
  color: #fff;
  border-color: #22c55e;
  transform: translateY(-1px);
}

.btn-batch-remove {
  background: rgba(244, 63, 94, 0.16);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: #fda4af;
  padding: 6px 13px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: 'Poppins', sans-serif;
}
.btn-batch-remove:hover {
  background: #e11d48;
  color: #fff;
  border-color: #e11d48;
  transform: translateY(-1px);
}

.btn-batch-cancel {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text2);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: 'Poppins', sans-serif;
}
.btn-batch-cancel:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

tr.row-selected td {
  background: rgba(99, 102, 241, 0.08) !important;
}

/* ---- SPEED LIMIT HIT (YELLOW HIGHLIGHT) ---- */
.cell-speed-hit {
  background: rgba(234, 179, 8, 0.16) !important;
  box-shadow: inset 0 0 14px rgba(234, 179, 8, 0.28);
  animation: pulse-yellow 2s infinite ease-in-out;
}

@keyframes pulse-yellow {
  0% {
    background: rgba(234, 179, 8, 0.12);
  }
  50% {
    background: rgba(234, 179, 8, 0.26);
    box-shadow: inset 0 0 18px rgba(234, 179, 8, 0.45);
  }
  100% {
    background: rgba(234, 179, 8, 0.12);
  }
}

.speed-hit-text {
  color: #fbbf24 !important;
  font-weight: 700 !important;
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

.speed-hit-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(234, 179, 8, 0.22);
  border: 1px solid #eab308;
  color: #fef08a;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 9999px;
  margin-top: 3px;
  letter-spacing: 0.2px;
  box-shadow: 0 0 10px rgba(234, 179, 8, 0.35);
  animation: badge-glow 2s infinite alternate;
}

@keyframes badge-glow {
  0% {
    box-shadow: 0 0 4px rgba(234, 179, 8, 0.3);
    border-color: #ca8a04;
  }
  100% {
    box-shadow: 0 0 12px rgba(234, 179, 8, 0.65);
    border-color: #fde047;
  }
}

tr.row-speed-hit {
  background: rgba(234, 179, 8, 0.03);
}

/* ---- USAGE ACTION BUTTON & MONTHLY HISTORY ---- */
.btn-usage {
  background: rgba(14, 165, 233, 0.14);
  border: 1px solid rgba(14, 165, 233, 0.35);
  color: #38bdf8;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: 'Poppins', sans-serif;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.btn-usage:hover {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
  transform: translateY(-1px);
}

.monthly-usage-row {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: background 0.15s ease;
}
.monthly-usage-row:hover {
  background: rgba(255, 255, 255, 0.06);
}
.monthly-usage-row.current-month {
  border-color: rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.07);
}

/* ---- QUOTA & DATA USAGE CELL ---- */
.quota-cell {
  display: inline-block;
  text-align: center;
  min-width: 130px;
}
.quota-cell-active {
  min-width: 145px;
  max-width: 185px;
  margin: 0 auto;
  text-align: left;
}
.quota-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}
.quota-today-val {
  font-weight: 600;
  font-size: 0.86rem;
  color: #f8fafc;
  line-height: 1.2;
}
.quota-month-val {
  font-size: 0.72rem;
  color: #a5b4fc;
  font-weight: 500;
  margin-top: 1px;
  line-height: 1.2;
}
.quota-detail-row {
  font-size: 0.7rem;
  color: var(--text3);
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
  line-height: 1.2;
}
.quota-progress-bar {
  height: 4px;
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}
.quota-progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}
.speed-cap-subtext {
  font-size: 0.68rem;
  color: #818cf8;
  font-weight: 500;
  margin-top: 2px;
  line-height: 1.1;
}
.speed-hit-sub-badge {
  font-size: 0.68rem;
  color: #fbbf24;
  font-weight: 700;
  margin-top: 2px;
  line-height: 1.1;
}
.speed-capped-sub-badge {
  font-size: 0.68rem;
  color: #818cf8;
  margin-top: 2px;
  line-height: 1.1;
}


