/* SinyalPintar Intelligent Traffic Monitoring - Clean White Enterprise Theme */
:root {
  --bg-main: #F4F6F9;              /* Crisp light canvas background */
  --bg-sidebar: #FFFFFF;           /* Pure white sidebar */
  --bg-card: #FFFFFF;              /* Pure white card surface */
  --bg-card-hover: #F8FAFC;        /* Subtle slate hover */
  --border-card: #E2E8F0;          /* Clean slate border */
  --border-light: #CBD5E1;         /* Border for active/focused elements */
  --accent-cyan: #0066B2;          /* Royal Corporate Blue from SinyalPintar logo */
  --accent-cyan-glow: rgba(0, 102, 178, 0.16);
  --accent-blue: #0066B2;          /* Deep Corporate Blue from logo */
  --accent-blue-bright: #0077CC;
  --accent-blue-glow: rgba(0, 102, 178, 0.22);
  --accent-gold: #D97706;          /* Rich Amber/Gold from logo (high contrast on white) */
  --accent-gold-glow: rgba(217, 119, 6, 0.2);
  --accent-amber: #D97706;         /* Accessible amber on white */
  --accent-amber-glow: rgba(217, 119, 6, 0.18);
  --accent-orange: #C2410C;
  --accent-green: #059669;         /* Vibrant emerald green on white */
  --accent-red: #DC2626;           /* Crimson red on white */
  --text-main: #0F172A;            /* Slate-900: Crisp deep dark text */
  --text-muted: #64748B;          /* Slate-500 */
  --text-dim: #94A3B8;            /* Slate-400 */
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: var(--border-card);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-cyan);
}

/* Sidebar - permanently fixed to viewport */
.sidebar {
  width: 64px;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  flex-shrink: 0;
  z-index: 100;
  box-sizing: border-box;
  box-shadow: 1px 0 4px rgba(0, 0, 0, 0.03);
}

.sidebar-logo {
  margin-bottom: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 12px;
  transition: all 0.3s ease;
}

.sidebar-logo-img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 102, 178, 0.25));
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.25s ease;
}

.sidebar-logo:hover .sidebar-logo-img {
  transform: scale(1.12);
  filter: drop-shadow(0 4px 12px rgba(217, 119, 6, 0.4));
}

.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  align-items: center;
}

.sidebar-btn {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  border: 1px solid transparent;
  background: transparent;
  padding: 0;
  outline: none;
  position: relative;
  font-family: inherit;
}

.sidebar-btn:hover {
  color: var(--text-main);
  background: #F1F5F9;
}

.sidebar-btn.active {
  background: rgba(0, 102, 178, 0.08);
  color: var(--accent-cyan);
  border-color: rgba(0, 102, 178, 0.35);
  box-shadow: 0 0 12px rgba(0, 102, 178, 0.15);
}

.sidebar-alert-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 8px;
  height: 8px;
  background-color: var(--accent-red);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--accent-red);
  display: none;
}

.sidebar-alert-dot.active {
  display: block;
  animation: alert-pulse 1.8s infinite;
}

@keyframes alert-pulse {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

.sidebar-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Main Content Area */
.app-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-left: 64px;
  width: calc(100% - 64px);
}

/* Top Navigation Bar */
.navbar {
  height: 60px;
  background-color: #FFFFFF;
  border-bottom: 1px solid var(--border-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 102, 178, 0.25));
  transition: transform 0.2s ease;
}

.brand-section:hover .brand-logo-img {
  transform: scale(1.08);
}

.brand-text-group {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.15;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--accent-blue);
  line-height: 1.1;
}

.brand-title span {
  color: var(--accent-gold);
  text-shadow: none;
}

.brand-subtitle {
  font-size: 0.65rem;
  font-weight: 600;
  color: #64748B;
  letter-spacing: 0.02em;
  margin-top: 1px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
  height: 100%;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  height: 100%;
  border-bottom: 2px solid transparent;
  transition: color 0.2s;
  cursor: pointer;
}

.nav-link:hover {
  color: var(--accent-cyan);
}

.nav-link.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  font-weight: 600;
}

.user-section {
  display: flex;
  align-items: center;
  gap: 18px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 8px;
  transition: all 0.2s;
}

.icon-btn:hover {
  color: var(--text-main);
  background: #F1F5F9;
}

.notification-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background-color: var(--accent-red);
  border-radius: 50%;
  box-shadow: 0 0 4px var(--accent-red);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #F1F5F9;
  border: 1px solid var(--border-card);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 600;
}

/* Dashboard Body */
.dashboard-content {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header Banner */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.dashboard-title-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dashboard-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.location-dropdown {
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  color: var(--accent-cyan);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.live-clock {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-family: monospace;
}

.btn-refresh {
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  color: var(--text-main);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.btn-refresh:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  background: rgba(0, 102, 178, 0.05);
}

.btn-refresh:active {
  transform: scale(0.96);
}

.btn-refresh.is-spinning {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  pointer-events: none;
}

@keyframes spin-refresh {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.btn-refresh.is-spinning svg,
.btn-refresh.rotating svg,
.chart-tool-btn.is-spinning {
  display: inline-block;
  animation: spin-refresh 0.7s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

/* Top 4 KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.kpi-card {
  background: #FFFFFF;
  border: 1px solid var(--border-card);
  border-radius: 10px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-light);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.07);
}

.kpi-card-cyan {
  border-top: 3px solid var(--accent-cyan);
}

.kpi-card-amber {
  border-top: 3px solid var(--accent-gold);
}

.kpi-header {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kpi-body {
  margin-top: 10px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.kpi-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
}

.kpi-unit {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
}

.kpi-trend {
  font-size: 0.85rem;
  font-weight: 600;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.kpi-trend.up {
  color: var(--accent-green);
}

.kpi-trend.down {
  color: var(--accent-amber);
}

.kpi-sparkline {
  margin-top: 12px;
  height: 28px;
  width: 100%;
}

.kpi-icon-value {
  display: flex;
  align-items: center;
  gap: 14px;
}

.kpi-icon-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 102, 178, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
}

.kpi-subtitle {
  font-size: 0.8rem;
  color: var(--accent-green);
  font-weight: 600;
  margin-top: 4px;
}

/* Middle Layout: Left 68% / Right 32% */
.middle-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

/* Chart Card */
.chart-card {
  background: #FFFFFF;
  border: 1px solid var(--border-card);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.chart-card.highlight-focus {
  animation: border-glow 1.6s ease;
}

@keyframes border-glow {
  0% { border-color: var(--border-card); box-shadow: none; }
  50% { border-color: var(--accent-cyan); box-shadow: 0 0 18px rgba(0, 102, 178, 0.2); }
  100% { border-color: var(--border-card); box-shadow: none; }
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.chart-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.chart-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-tool-btn {
  background: #F8FAFC;
  border: 1px solid var(--border-card);
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  transition: all 0.2s ease;
}

.chart-tool-btn:hover {
  color: var(--text-main);
  background: #F1F5F9;
  border-color: var(--border-light);
}

.chart-tool-btn.is-spinning {
  animation: spin-cw 0.75s linear infinite;
  color: var(--accent-cyan) !important;
  border-color: var(--accent-cyan) !important;
  pointer-events: none;
}

@keyframes spin-cw {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.chart-tool-select {
  background: #F8FAFC;
  border: 1px solid var(--border-card);
  color: var(--text-main);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  outline: none;
}

.chart-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-bottom: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot-cyan {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--accent-cyan);
  box-shadow: 0 0 4px rgba(0, 102, 178, 0.35);
}

.legend-box-amber {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--accent-gold);
  box-shadow: 0 0 4px rgba(217, 119, 6, 0.35);
}

.chart-canvas-wrapper {
  position: relative;
  flex: 1;
  min-height: 310px;
  width: 100%;
}

/* Right Column Panels */
.right-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.side-card {
  background: #FFFFFF;
  border: 1px solid var(--border-card);
  border-radius: 10px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.side-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.side-card-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

/* Real Interactive Map (MapLibre + OpenFreeMap Bright Vector) */
.map-wrapper {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 14px;
  border: 1px solid var(--border-card);
  height: 240px;
  background: #F1F5F9;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.device-real-map {
  width: 100%;
  height: 100%;
  background: #F1F5F9;
}

/* MapLibre GL control & popup overrides for OpenFreeMap */
.maplibregl-map {
  font-family: inherit !important;
}

.maplibregl-ctrl-group {
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(8px) !important;
  border: 1px solid var(--border-card) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
  border-radius: 6px !important;
  overflow: hidden;
}

.maplibregl-ctrl-group button {
  width: 26px !important;
  height: 26px !important;
  border-bottom: 1px solid var(--border-card) !important;
}

.maplibregl-ctrl-group button:hover {
  background-color: #F1F5F9 !important;
}

.maplibregl-ctrl-icon {
  filter: none;
}

/* Sleek Map Popup */
.maplibregl-popup {
  max-width: 240px !important;
  z-index: 900;
}

.maplibregl-popup-content {
  background: rgba(255, 255, 255, 0.98) !important;
  backdrop-filter: blur(12px) !important;
  color: var(--text-main) !important;
  border: 1px solid var(--border-card) !important;
  border-radius: 8px !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1) !important;
  padding: 10px 12px !important;
}

.maplibregl-popup-anchor-bottom .maplibregl-popup-tip {
  border-top-color: #FFFFFF !important;
}
.maplibregl-popup-anchor-top .maplibregl-popup-tip {
  border-bottom-color: #FFFFFF !important;
}
.maplibregl-popup-anchor-left .maplibregl-popup-tip {
  border-right-color: #FFFFFF !important;
}
.maplibregl-popup-anchor-right .maplibregl-popup-tip {
  border-left-color: #FFFFFF !important;
}

.maplibregl-popup-close-button {
  color: var(--text-muted) !important;
  font-size: 16px !important;
  padding: 2px 6px !important;
}
.maplibregl-popup-close-button:hover {
  color: var(--text-main) !important;
  background: transparent !important;
}

.map-popup-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-weight: 700;
  font-size: 0.84rem;
}

.map-popup-id {
  color: var(--accent-cyan);
}

.map-popup-title {
  color: var(--text-main);
  font-size: 0.78rem;
  font-weight: 600;
}

.map-popup-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.7rem;
}

.map-popup-status {
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
}
.map-popup-status.green {
  background: rgba(5, 150, 105, 0.1);
  color: #059669;
  border: 1px solid rgba(5, 150, 105, 0.3);
}
.map-popup-status.amber {
  background: rgba(217, 119, 6, 0.1);
  color: #D97706;
  border: 1px solid rgba(217, 119, 6, 0.3);
}

.map-popup-tech {
  color: var(--text-muted);
}

.map-popup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  border-top: 1px solid var(--border-card);
  padding-top: 6px;
}

.map-popup-stat {
  display: flex;
  flex-direction: column;
}

.map-popup-label {
  font-size: 0.62rem;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.map-popup-val {
  font-size: 0.74rem;
  color: var(--text-main);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-weight: 600;
}

/* Glassmorphism Location Pill Badge */
.map-overlay-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-card);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 7px;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  pointer-events: none;
}

.map-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
}

/* Professional IoT Node Marker Pins */
.gw-marker-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.gw-marker-icon:hover {
  transform: scale(1.18);
}

.gw-marker-box {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 11px;
  background: #FFFFFF;
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  z-index: 2;
  position: relative;
  transition: all 0.2s ease;
}

.gw-marker-box.green {
  border: 2px solid #059669;
  box-shadow: 0 0 10px rgba(5, 150, 105, 0.3);
}

.gw-marker-box.amber {
  border: 2px solid #D97706;
  box-shadow: 0 0 10px rgba(217, 119, 6, 0.3);
}

.gw-marker-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  z-index: 1;
  animation: marker-radar 2.4s infinite ease-out;
  pointer-events: none;
}

.gw-marker-pulse.green {
  background: radial-gradient(circle, rgba(5, 150, 105, 0.35) 0%, rgba(5, 150, 105, 0) 70%);
}

.gw-marker-pulse.amber {
  background: radial-gradient(circle, rgba(217, 119, 6, 0.35) 0%, rgba(217, 119, 6, 0) 70%);
}

@keyframes marker-radar {
  0% { transform: translate(-50%, -50%) scale(0.6); opacity: 0.9; }
  100% { transform: translate(-50%, -50%) scale(1.7); opacity: 0; }
}

/* 4 Gateways Battery/Signal Telemetry Grid */
.gateways-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.gw-telemetry-card {
  background: #F8FAFC;
  border: 1px solid var(--border-card);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.25s ease;
}

.gw-telemetry-card:hover {
  background: #FFFFFF;
  border-color: var(--accent-cyan);
  box-shadow: 0 4px 12px rgba(0, 102, 178, 0.08);
}

.gw-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gw-id-badge {
  display: flex;
  align-items: center;
  gap: 6px;
}

.gw-name {
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--text-main);
  letter-spacing: 0.02em;
}

.gw-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
}

.gw-status-pill.green {
  background: rgba(5, 150, 105, 0.1);
  color: #059669;
  border: 1px solid rgba(5, 150, 105, 0.3);
}

.gw-status-pill.amber {
  background: rgba(217, 119, 6, 0.1);
  color: #D97706;
  border: 1px solid rgba(217, 119, 6, 0.3);
}

.gw-pulse-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}

.gw-power-metric {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.74rem;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  color: #E2E8F0;
  font-weight: 600;
}

.gw-battery-svg {
  width: 13px;
  height: 13px;
  stroke: #94A3B8;
  fill: none;
}

.gw-bar-track {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.gw-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.gw-bar-fill.green {
  background: linear-gradient(90deg, #059669, #10B981);
}

.gw-bar-fill.amber {
  background: linear-gradient(90deg, #D97706, #F59E0B);
}

.gw-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.70rem;
  color: #94A3B8;
}

.gw-signal-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.gw-signal-svg {
  width: 12px;
  height: 12px;
  fill: #38BDF8;
}

.gw-csq-val {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  color: #94A3B8;
}

/* Backward compatibility for previous classes */
.gw-status-badge {
  display: none;
}

/* Live Alert Box */
.alert-card-item {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.alert-tag-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.alert-title {
  font-weight: 700;
  font-size: 0.85rem;
  color: #92400E;
}

.badge-amber {
  background: #FEF3C7;
  color: #D97706;
  border: 1px solid #FCD34D;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-green {
  background: #D1FAE5;
  color: #059669;
  border: 1px solid #A7F3D0;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
}

.alert-location {
  font-size: 0.8rem;
  color: #475569;
}

.alert-details {
  font-size: 0.75rem;
  color: #78350F;
  border-top: 1px dashed #FDE68A;
  padding-top: 6px;
  margin-top: 4px;
}

/* Bottom Table Section */
.table-card {
  background: #FFFFFF;
  border: 1px solid var(--border-card);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.table-header-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-main);
  margin-bottom: 14px;
}

.logs-table-wrapper {
  overflow-x: auto;
}

.logs-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  font-size: 0.88rem;
  text-align: left;
}

.logs-table th {
  background-color: #F8FAFC;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-card);
  white-space: nowrap;
}

.logs-table td {
  padding: 13px 14px;
  border-bottom: 1px solid #F1F5F9;
  color: var(--text-main);
  white-space: nowrap;
}

.logs-table tr:hover td {
  background: #F8FAFC;
}

.status-active {
  color: var(--accent-green);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-active::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);
}

.status-warning {
  color: var(--accent-amber);
  font-weight: 600;
}

/* ==========================================================================
   MODAL DIALOGS - Smooth, Modern Frosted Glass Aesthetic
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), backdrop-filter 0.3s ease;
  padding: 20px;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: #FFFFFF;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 18px;
  width: 520px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 26px;
  box-shadow: 0 25px 60px -15px rgba(15, 23, 42, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.04);
  transform: scale(0.93) translateY(14px);
  opacity: 0;
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.26s ease, box-shadow 0.3s ease;
}

.modal-overlay.open .modal-box {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.modal-box-cmd { width: 540px; }
.modal-box-reports { width: 560px; }
.modal-box-devices { width: 720px; }
.modal-box-alerts { width: 740px; }

/* Modal Inner Scrollbars */
.modal-box::-webkit-scrollbar {
  width: 6px;
}
.modal-box::-webkit-scrollbar-track {
  background: transparent;
}
.modal-box::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 999px;
}
.modal-box::-webkit-scrollbar-thumb:hover {
  background: var(--accent-cyan);
}

.modal-drag-indicator {
  display: none;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid #F1F5F9;
}

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

.modal-icon-badge {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease;
}

.modal-icon-badge:hover {
  transform: scale(1.08);
}

.modal-icon-blue {
  background: rgba(0, 102, 178, 0.09);
  border: 1px solid rgba(0, 102, 178, 0.22);
}

.modal-icon-cyan {
  background: rgba(0, 119, 204, 0.09);
  border: 1px solid rgba(0, 119, 204, 0.22);
}

.modal-icon-green {
  background: rgba(5, 150, 105, 0.09);
  border: 1px solid rgba(5, 150, 105, 0.22);
}

.modal-icon-amber {
  background: rgba(217, 119, 6, 0.09);
  border: 1px solid rgba(217, 119, 6, 0.22);
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0F172A;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0;
}

.modal-subtitle {
  font-size: 0.74rem;
  color: #64748B;
  display: block;
  margin-top: 2px;
}

.modal-topic-code {
  color: var(--accent-cyan);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  background: rgba(0, 102, 178, 0.08);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
}

.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #F1F5F9;
  border: 1px solid transparent;
  color: #64748B;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0;
  flex-shrink: 0;
}

.modal-close:hover {
  background: #E2E8F0;
  color: #0F172A;
  transform: scale(1.1) rotate(90deg);
}

.modal-close:active {
  transform: scale(0.92);
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 7px;
  letter-spacing: 0.01em;
}

.form-input, .form-select {
  width: 100%;
  background: #F8FAFC;
  border: 1.5px solid #E2E8F0;
  color: #0F172A;
  padding: 10px 14px;
  border-radius: 9px;
  outline: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.form-input:focus, .form-select:focus {
  background: #FFFFFF;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(0, 102, 178, 0.12);
}

.form-input:hover, .form-select:hover {
  border-color: #CBD5E1;
}

/* Date Input Styling & High-contrast Picker */
input[type="date"] {
  color-scheme: light;
  cursor: pointer;
  position: relative;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.75;
  font-size: 1.15rem;
  padding: 2px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
  background: rgba(0, 102, 178, 0.1);
  transform: scale(1.1);
}

.date-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.date-input-wrap .form-input {
  padding-right: 38px;
  cursor: pointer;
}

.date-icon-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--accent-cyan);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
  z-index: 2;
}

.date-icon-btn:hover {
  background: rgba(0, 102, 178, 0.1);
  color: var(--accent-blue);
}

.date-preset-btn {
  background: #F8FAFC;
  border: 1px solid var(--border-card);
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.date-preset-btn:hover {
  background: #F1F5F9;
  border-color: var(--border-light);
  color: var(--accent-cyan);
}

.date-preset-btn.active {
  background: rgba(0, 102, 178, 0.1);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  font-weight: 700;
}

/* Modal Tables - Clean, readable, with smooth horizontal scroll */
.modal-box .logs-table-wrapper {
  overflow-x: auto !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  border: 1px solid #E2E8F0 !important;
  border-radius: 10px !important;
  background: #FFFFFF !important;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.02);
}

.modal-box .logs-table {
  min-width: 500px !important;
  width: 100% !important;
  table-layout: auto !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

.modal-box .logs-table th {
  background: #F8FAFC !important;
  color: #475569 !important;
  font-size: 0.75rem !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.04em !important;
  padding: 10px 14px !important;
  border-bottom: 1px solid #E2E8F0 !important;
  white-space: nowrap !important;
}

.modal-box .logs-table td {
  padding: 10px 14px !important;
  font-size: 0.83rem !important;
  color: #1E293B !important;
  border-bottom: 1px solid #F1F5F9 !important;
  white-space: nowrap !important;
}

.modal-box .logs-table tbody tr:nth-child(even) td {
  background: #FAFCFF !important;
}

.modal-box .logs-table tbody tr:hover td {
  background: #F1F5F9 !important;
}

.modal-box .logs-table tr:last-child td {
  border-bottom: none !important;
}

.alerts-table th:last-child,
.alerts-table td:last-child,
.devices-power-table th:last-child,
.devices-power-table td:last-child {
  text-align: center !important;
}

/* Gateway Telemetry Cards in Devices Modal - Professional Slate Cards */
.modal-gateways-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (max-width: 600px) {
  .modal-gateways-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

.gw-telemetry-card {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
}

.gw-telemetry-card:hover {
  border-color: #CBD5E1;
  background: #FFFFFF;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
  transform: translateY(-1px);
}

.gw-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.gw-id-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.gw-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #0F172A;
  white-space: nowrap;
}

.gw-loc-tag {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.73rem;
  font-weight: 600;
  background: #E0F2FE;
  color: #0284C7;
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.gw-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  line-height: 1;
}

.gw-status-pill.green {
  background: #ECFDF5;
  color: #059669;
  border: 1px solid #A7F3D0;
}

.gw-status-pill.amber {
  background: #FFFBEB;
  color: #D97706;
  border: 1px solid #FDE68A;
}

.gw-pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.gw-status-pill.green .gw-pulse-dot {
  background: #10B981;
  box-shadow: 0 0 6px #10B981;
  animation: pulse-dot 1.8s infinite;
}

.gw-status-pill.amber .gw-pulse-dot {
  background: #F59E0B;
  box-shadow: 0 0 6px #F59E0B;
}

.gw-power-metric {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #475569;
  white-space: nowrap;
}

.gw-power-metric .gw-vbat {
  color: #64748B;
  font-size: 0.75rem;
}

.gw-power-metric .gw-pct {
  color: #0F172A;
  font-weight: 700;
}

.gw-battery-svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: #0284C7;
}

.gw-bar-track {
  width: 100%;
  height: 5px;
  background: #E2E8F0;
  border-radius: 999px;
  overflow: hidden;
}

.gw-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.gw-bar-fill.green {
  background: linear-gradient(90deg, #10B981, #06B6D4);
}

.gw-bar-fill.amber {
  background: linear-gradient(90deg, #F59E0B, #EA580C);
}

.gw-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.74rem;
  color: #64748B;
}

.gw-signal-item {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #475569;
  font-weight: 600;
}

.gw-signal-svg {
  width: 13px;
  height: 13px;
  fill: #0284C7;
}

.gw-csq-val {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.72rem;
  color: #64748B;
}

.modal-footer-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn-primary {
  background: linear-gradient(135deg, #0066B2 0%, #0088EE 100%);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 11px 20px;
  border-radius: 9px;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
  box-shadow: 0 4px 14px rgba(0, 102, 178, 0.28);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  user-select: none;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0077CC 0%, #0099FF 100%);
  box-shadow: 0 6px 20px rgba(0, 102, 178, 0.42);
  transform: translateY(-1.5px);
}

.btn-primary:active {
  transform: scale(0.98) translateY(0);
  box-shadow: 0 2px 8px rgba(0, 102, 178, 0.2);
}

.btn-secondary {
  background: #F8FAFC;
  color: #475569;
  border: 1.5px solid #E2E8F0;
  padding: 11px 20px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  user-select: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-secondary:hover {
  background: #F1F5F9;
  color: #0F172A;
  border-color: #CBD5E1;
}

.btn-secondary:active {
  transform: scale(0.98);
}

/* MQTT Terminal & Live Command Preview */
.mqtt-preview-box {
  background: #0F172A;
  border: 1px solid #1E293B;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 14px 0;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

.mqtt-preview-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #38BDF8;
  margin-bottom: 6px;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mqtt-dot-live {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #0091FF;
  box-shadow: 0 0 8px #0091FF;
  animation: pulse-dot 1.8s infinite;
}

.mqtt-preview-code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
  line-height: 1.5;
}

.mqtt-preview-row {
  display: flex;
  gap: 8px;
}

.mqtt-preview-row .k {
  color: #94A3B8;
  min-width: 65px;
}

.mqtt-preview-row .v {
  color: #F8FAFC;
  font-weight: 600;
  word-break: break-all;
}

.mqtt-preview-row .v.highlight {
  color: #34D399;
}

/* Command Helper & Warning Badges */
.cmd-helper-box {
  background: rgba(0, 102, 178, 0.06);
  border: 1px solid rgba(0, 102, 178, 0.2);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.78rem;
  color: #005B94;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.cmd-warning-box {
  background: rgba(220, 38, 38, 0.06);
  border: 1px solid rgba(220, 38, 38, 0.25);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.78rem;
  color: #B91C1C;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

/* Modern Toast Notification System */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-item {
  pointer-events: auto;
  min-width: 300px;
  max-width: 420px;
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: #0F172A;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.toast-item.show {
  transform: translateX(0);
  opacity: 1;
}

.toast-item.success {
  border-left: 4px solid #10B981;
}

.toast-item.error {
  border-left: 4px solid #EF4444;
}

.toast-item.info {
  border-left: 4px solid #0284C7;
}

.toast-item.warning {
  border-left: 4px solid #F59E0B;
}

.toast-icon-wrap {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-item.success .toast-icon-wrap {
  background: #ECFDF5;
  color: #059669;
}

.toast-item.error .toast-icon-wrap {
  background: #FEF2F2;
  color: #DC2626;
}

.toast-item.info .toast-icon-wrap {
  background: #E0F2FE;
  color: #0284C7;
}

.toast-item.warning .toast-icon-wrap {
  background: #FFFBEB;
  color: #D97706;
}

.toast-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toast-title {
  font-weight: 700;
  font-size: 0.84rem;
  color: #0F172A;
  line-height: 1.3;
}

.toast-desc {
  font-size: 0.74rem;
  font-weight: 500;
  color: #475569;
  line-height: 1.35;
  word-break: break-word;
}

.toast-close {
  background: #F1F5F9;
  border: none;
  color: #64748B;
  cursor: pointer;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.toast-close:hover {
  background: #E2E8F0;
  color: #0F172A;
}

/* Responsive adjustments */
@media (max-width: 1100px) {
  .middle-grid {
    grid-template-columns: 1fr;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 650px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .navbar {
    padding: 0 12px;
  }
  .nav-links {
    display: none;
  }
  .sidebar {
    display: none;
  }
  .app-container {
    margin-left: 0;
    width: 100%;
  }
}

/* Loading Spinner & Progress Indicators */
.btn-spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.spin-icon {
  animation: spin-cw 0.75s linear infinite;
}

.inline-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-cyan);
  box-shadow: 0 0 6px var(--accent-cyan);
  animation: pulse-dot 1.4s infinite;
  display: inline-block;
}

/* AES-128-GCM Command & History Badge Styles */
.enc-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.35);
  letter-spacing: 0.02em;
}

.enc-badge.plain {
  background: rgba(100, 116, 139, 0.12);
  color: #64748B;
  border-color: rgba(100, 116, 139, 0.3);
}

.cmd-resp-feed {
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--border-card);
  border-radius: 8px;
  background: #F8FAFC;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.75rem;
}

.cmd-resp-item {
  background: #FFFFFF;
  border: 1px solid var(--border-card);
  border-radius: 6px;
  padding: 6px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.cmd-resp-item.success {
  border-left: 3px solid #10B981;
}

.cmd-resp-item.rejected {
  border-left: 3px solid #EF4444;
}

.cmd-resp-item.queue {
  border-left: 3px solid #F59E0B;
}

.cmd-resp-item.waiting {
  border-left: 3px solid #0284C7;
  background: #F0F9FF;
  animation: pulseWaiting 1.8s infinite ease-in-out;
}

@keyframes pulseWaiting {
  0% { box-shadow: 0 0 0 0 rgba(2, 132, 199, 0.35); }
  70% { box-shadow: 0 0 0 6px rgba(2, 132, 199, 0); }
  100% { box-shadow: 0 0 0 0 rgba(2, 132, 199, 0); }
}

.cmd-resp-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #BAE6FD;
  border-top-color: #0284C7;
  border-radius: 50%;
  animation: spinFeed 0.8s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

@keyframes spinFeed {
  to { transform: rotate(360deg); }
}

.cmd-resp-item.highlight-new {
  animation: flashHighlight 2.5s ease-out;
}

@keyframes flashHighlight {
  0% { background: #E0F2FE; }
  100% { background: #FFFFFF; }
}

/* ==========================================================================
   MOBILE BOTTOM NAVIGATION & RESPONSIVE ADAPTATIONS (iOS & Android)
   ========================================================================== */

/* Hidden on desktop */
.mobile-bottom-nav {
  display: none;
}

.header-reports-btn {
  display: none;
}

/* Tablet & Smaller Screens (<= 1024px) */
@media (max-width: 1024px) {
  .middle-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
}

/* Mobile Devices (<= 768px) - Android & iPhone Optimized */
@media (max-width: 768px) {
  /* 1. Hide desktop sidebar, reclaim 100% screen width */
  .sidebar {
    display: none !important;
  }

  .app-container {
    margin-left: 0 !important;
    width: 100% !important;
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* 2. Top Header */
  .navbar {
    padding: 0 14px !important;
    height: 56px !important;
  }

  .brand-logo-img {
    width: 32px !important;
    height: 32px !important;
  }

  .brand-title {
    font-size: 1.1rem !important;
  }

  .brand-subtitle {
    display: none !important;
  }

  .nav-links {
    display: none !important;
  }

  .header-reports-btn {
    display: flex !important;
  }

  .user-section {
    gap: 10px !important;
  }

  .icon-btn {
    padding: 8px !important;
    min-width: 38px;
    min-height: 38px;
  }

  .user-avatar {
    width: 30px !important;
    height: 30px !important;
    font-size: 0.8rem !important;
  }

  /* 3. Dashboard Body & Header */
  .dashboard-content {
    padding: 14px 12px !important;
    gap: 14px !important;
  }

  .dashboard-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  .dashboard-title-wrapper {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .dashboard-title {
    font-size: 1.05rem !important;
    line-height: 1.25 !important;
  }

  .location-dropdown {
    width: 100% !important;
    padding: 10px 12px !important;
    font-size: 0.88rem !important;
    border-radius: 8px !important;
    background-position: right 10px center;
  }

  .header-right {
    justify-content: space-between !important;
    width: 100% !important;
  }

  .live-clock {
    font-size: 0.74rem !important;
  }

  .btn-refresh {
    padding: 8px 14px !important;
    font-size: 0.82rem !important;
    min-height: 38px !important;
    border-radius: 8px !important;
  }

  /* 4. KPI Grid: 2x2 Clean Mobile Cards */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .kpi-card {
    padding: 12px 12px !important;
    border-radius: 12px !important;
  }

  .kpi-header {
    font-size: 0.65rem !important;
    letter-spacing: 0.02em !important;
  }

  .kpi-body {
    margin-top: 6px !important;
    gap: 6px !important;
    flex-wrap: wrap !important;
  }

  .kpi-value {
    font-size: 1.65rem !important;
    line-height: 1.05 !important;
  }

  .kpi-unit {
    font-size: 0.76rem !important;
  }

  .kpi-trend {
    font-size: 0.7rem !important;
  }

  .kpi-sparkline {
    margin-top: 8px !important;
    height: 22px !important;
  }

  .kpi-subtitle {
    font-size: 0.7rem !important;
  }

  /* 5. Chart & Right Panels */
  .middle-grid {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  .chart-card {
    padding: 14px 12px !important;
    border-radius: 12px !important;
  }

  .chart-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  .chart-title {
    font-size: 0.95rem !important;
  }

  .chart-tools {
    width: 100% !important;
    justify-content: flex-start !important;
    gap: 6px !important;
    overflow-x: auto !important;
    padding-bottom: 4px !important;
    -webkit-overflow-scrolling: touch;
  }

  .chart-tool-btn {
    min-width: 36px !important;
    min-height: 36px !important;
    padding: 6px 10px !important;
    font-size: 0.85rem !important;
    flex-shrink: 0 !important;
  }

  .chart-tool-select {
    padding: 6px 10px !important;
    font-size: 0.78rem !important;
    flex-shrink: 0 !important;
  }

  .chart-legend {
    gap: 14px !important;
    font-size: 0.75rem !important;
    margin-bottom: 8px !important;
    flex-wrap: wrap !important;
  }

  .chart-canvas-wrapper {
    min-height: 250px !important;
    height: 250px !important;
  }

  .right-column {
    gap: 14px !important;
  }

  .side-card {
    padding: 14px 12px !important;
    border-radius: 12px !important;
  }

  .map-wrapper {
    height: 200px !important;
  }

  .gateways-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  .gw-telemetry-card {
    padding: 8px 10px !important;
    border-radius: 8px !important;
  }

  .gw-name {
    font-size: 0.8rem !important;
  }

  .gw-power-metric {
    font-size: 0.68rem !important;
  }

  .gw-csq-val {
    font-size: 0.64rem !important;
  }

  /* 6. Recent Logs Table */
  .table-card {
    padding: 14px 12px !important;
    border-radius: 12px !important;
  }

  .table-header-title {
    font-size: 0.95rem !important;
  }

  .logs-table-wrapper {
    border: 1px solid var(--border-card) !important;
    border-radius: 8px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    margin-top: 10px !important;
  }

  .logs-table th, .logs-table td {
    padding: 10px 10px !important;
    font-size: 0.75rem !important;
    white-space: nowrap !important;
  }

  /* 7. Bottom Navigation Bar (iOS / Android Native Feel) */
  .mobile-bottom-nav {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: calc(58px + env(safe-area-inset-bottom, 0px)) !important;
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    background: rgba(255, 255, 255, 0.96) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-top: 1px solid var(--border-card) !important;
    box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08) !important;
    z-index: 950 !important;
    justify-content: space-around !important;
    align-items: center !important;
  }

  .mobile-bottom-btn {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s ease, transform 0.15s ease;
    padding: 0;
  }

  .mobile-bottom-btn svg {
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .mobile-bottom-btn span {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.01em;
  }

  .mobile-bottom-btn:active {
    transform: scale(0.92);
  }

  .mobile-bottom-btn.active {
    color: var(--accent-cyan);
  }

  .mobile-bottom-btn.active svg {
    transform: translateY(-2px);
  }

  .mobile-bottom-btn.active span {
    font-weight: 700;
  }

  .mobile-alert-dot {
    position: absolute;
    top: 7px;
    right: calc(50% - 14px);
    width: 8px;
    height: 8px;
    background: var(--accent-red);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--accent-red);
    display: none;
  }

  /* Mobile Toast Banner - Centered at Top with Safe Area */
  .toast-container {
    top: max(10px, env(safe-area-inset-top, 10px)) !important;
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    align-items: center !important;
    z-index: 100000 !important;
  }

  .toast-item {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    padding: 9px 12px !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.16), 0 1px 3px rgba(0, 0, 0, 0.05) !important;
    transform: translateY(-40px) scale(0.96) !important;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease !important;
    gap: 9px !important;
  }

  .toast-item.show {
    transform: translateY(0) scale(1) !important;
  }

  .toast-title {
    font-size: 0.79rem !important;
    line-height: 1.25 !important;
  }

  .toast-desc {
    font-size: 0.7rem !important;
    line-height: 1.3 !important;
    color: #475569 !important;
  }

  /* 8. Modals Bottom-Sheet Transition & Proportional Mobile Hierarchy */
  .modal-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
    z-index: 1000 !important;
  }

  .modal-box,
  .modal-box-cmd,
  .modal-box-reports,
  .modal-box-devices,
  .modal-box-alerts {
    width: 100% !important;
    max-width: 100% !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-top-left-radius: 20px !important;
    border-top-right-radius: 20px !important;
    max-height: 86vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    padding: 10px 14px calc(20px + env(safe-area-inset-bottom, 0px)) !important;
    margin: 0 !important;
    box-shadow: 0 -12px 35px rgba(15, 23, 42, 0.28) !important;
    transform: translateY(100%) !important;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  .modal-overlay.open .modal-box {
    transform: translateY(0) !important;
  }

  .modal-drag-indicator {
    display: block !important;
    width: 36px !important;
    height: 4px !important;
    border-radius: 999px !important;
    background: #CBD5E1 !important;
    margin: 2px auto 8px auto !important;
  }

  .modal-header {
    position: sticky !important;
    top: -10px !important;
    background: #FFFFFF !important;
    z-index: 15 !important;
    padding-top: 4px !important;
    margin-bottom: 12px !important;
    padding-bottom: 10px !important;
    border-bottom: 1px solid #F1F5F9 !important;
  }

  .modal-title-group {
    gap: 8px !important;
  }

  .modal-icon-badge {
    width: 32px !important;
    height: 32px !important;
    font-size: 1rem !important;
    border-radius: 8px !important;
    flex-shrink: 0 !important;
  }

  .modal-title {
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
  }

  .modal-subtitle {
    font-size: 0.67rem !important;
    line-height: 1.25 !important;
    color: #64748B !important;
  }

  .modal-close {
    width: 30px !important;
    height: 30px !important;
    min-width: 30px !important;
    min-height: 30px !important;
    border-radius: 50% !important;
    background: #F1F5F9 !important;
    font-size: 1.15rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
  }

  /* Compact & Balanced Form Controls for Mobile */
  .form-group {
    margin-bottom: 10px !important;
  }

  .form-label {
    font-size: 0.74rem !important;
    font-weight: 700 !important;
    margin-bottom: 4px !important;
    color: #1E293B !important;
  }

  .form-input, .form-select {
    font-size: 0.82rem !important;
    min-height: 38px !important;
    height: 38px !important;
    padding: 6px 10px !important;
    border-radius: 8px !important;
    line-height: 1.3 !important;
  }

  .btn-primary, .btn-secondary {
    min-height: 40px !important;
    height: 40px !important;
    font-size: 0.82rem !important;
    font-weight: 700 !important;
    padding: 7px 14px !important;
    border-radius: 8px !important;
    white-space: nowrap !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
  }

  .date-preset-btn {
    min-height: 32px !important;
    padding: 4px 10px !important;
    font-size: 0.74rem !important;
    border-radius: 6px !important;
  }

  /* Modal Gateways Grid - Balanced 2x2 Grid on Mobile */
  .modal-gateways-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px !important;
  }

  .gw-telemetry-card {
    padding: 6px 8px !important;
    border-radius: 9px !important;
    gap: 4px !important;
  }

  .gw-name {
    font-size: 0.76rem !important;
  }

  .gw-loc-tag {
    font-size: 0.65rem !important;
    padding: 1px 4px !important;
  }

  .gw-status-pill {
    font-size: 0.62rem !important;
    padding: 1px 4px !important;
  }

  .gw-pulse-dot {
    width: 5px !important;
    height: 5px !important;
  }

  .gw-power-metric {
    font-size: 0.7rem !important;
    gap: 3px !important;
  }

  .gw-power-metric .gw-vbat {
    font-size: 0.67rem !important;
  }

  .gw-battery-svg {
    width: 12px !important;
    height: 12px !important;
  }

  .gw-bar-track {
    height: 3px !important;
  }

  .gw-card-foot {
    font-size: 0.65rem !important;
  }

  .gw-signal-item {
    gap: 3px !important;
  }

  .gw-signal-svg {
    width: 10px !important;
    height: 10px !important;
  }

  .gw-csq-val {
    font-size: 0.64rem !important;
  }

  /* Modal Tables Mobile Touch Scroll */
  .modal-box .logs-table-wrapper {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    border: 1px solid var(--border-card) !important;
    border-radius: 8px !important;
    margin-bottom: 12px !important;
  }

  .modal-box .logs-table {
    min-width: 440px !important;
    width: auto !important;
    table-layout: auto !important;
  }

  .modal-box .logs-table th {
    font-size: 0.68rem !important;
    padding: 7px 9px !important;
  }

  .modal-box .logs-table td {
    font-size: 0.74rem !important;
    padding: 7px 9px !important;
  }

  .modal-footer-actions {
    gap: 8px !important;
    margin-top: 12px !important;
  }

  /* Remote Modal Checkbox & Preview Optimizations */
  .enc-badge {
    font-size: 0.62rem !important;
    padding: 2px 5px !important;
  }

  .mqtt-preview-box {
    padding: 8px 10px !important;
    margin: 10px 0 !important;
    border-radius: 7px !important;
  }

  .mqtt-preview-header {
    font-size: 0.65rem !important;
    margin-bottom: 4px !important;
    padding-bottom: 4px !important;
  }

  .mqtt-preview-code {
    font-size: 0.72rem !important;
    line-height: 1.4 !important;
  }

  .mqtt-preview-row .k {
    min-width: 55px !important;
    font-size: 0.68rem !important;
  }

  .mqtt-preview-row .v {
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
  }

  .cmd-resp-feed {
    max-height: 120px !important;
    padding: 6px !important;
    gap: 4px !important;
  }

  .cmd-resp-item {
    padding: 5px 8px !important;
    font-size: 0.71rem !important;
  }
}

/* Compact Phones (<= 380px) - iPhone SE, Small Androids */
@media (max-width: 380px) {
  .modal-box,
  .modal-box-cmd,
  .modal-box-reports,
  .modal-box-devices,
  .modal-box-alerts {
    padding: 8px 10px calc(18px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .kpi-value {
    font-size: 1.4rem !important;
  }

  .kpi-card {
    padding: 9px 9px !important;
  }

  .gateways-grid {
    grid-template-columns: 1fr !important;
  }

  .brand-title {
    font-size: 0.95rem !important;
  }

  .modal-gateways-grid {
    gap: 5px !important;
  }

  .gw-telemetry-card {
    padding: 5px 6px !important;
  }
}

