/* 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;
}

/* Remote Command Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

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

.modal-box {
  background: #FFFFFF;
  border: 1px solid var(--border-card);
  border-radius: 12px;
  width: 500px;
  max-width: 90vw;
  padding: 24px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

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

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  transition: color 0.2s ease;
}

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

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

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-input, .form-select {
  width: 100%;
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 6px;
  outline: none;
  font-size: 0.9rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

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

/* 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 Overrides - prevent horizontal scrolling & ensure columns fit completely */
.modal-box .logs-table-wrapper {
  overflow-x: hidden !important;
}

.modal-box .logs-table {
  min-width: 100% !important;
  width: 100% !important;
  table-layout: fixed;
}

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

.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 */
.modal-gateways-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

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

.gw-telemetry-card {
  background: rgba(11, 17, 30, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.2s ease;
}

.gw-telemetry-card:hover {
  border-color: rgba(0, 229, 255, 0.35);
  background: rgba(14, 23, 42, 0.98);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.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: #F8FAFC;
  white-space: nowrap;
}

.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: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.gw-status-pill.amber {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.4);
}

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

.gw-status-pill.green .gw-pulse-dot {
  background: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);
  animation: pulse-dot 1.8s infinite;
}

.gw-status-pill.amber .gw-pulse-dot {
  background: var(--accent-amber);
  box-shadow: 0 0 6px var(--accent-amber);
}

.gw-power-metric {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.gw-battery-svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--accent-cyan);
}

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

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

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

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

.gw-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.74rem;
  color: var(--text-dim);
}

.gw-signal-item {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  font-weight: 500;
}

.gw-signal-svg {
  width: 13px;
  height: 13px;
  fill: var(--accent-cyan);
}

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

.btn-primary {
  background: linear-gradient(135deg, #0070BA, #0091FF);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 10px 18px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  box-shadow: 0 4px 14px rgba(0, 145, 255, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0082D8, #1AA3FF);
  box-shadow: 0 6px 18px rgba(0, 145, 255, 0.5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #F8FAFC;
  color: #334155;
  border: 1px solid var(--border-light);
  padding: 10px 18px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-secondary:hover {
  background: #F1F5F9;
  color: var(--text-main);
  border-color: #94A3B8;
}

/* 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: 24px;
  right: 24px;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast-item {
  pointer-events: auto;
  min-width: 320px;
  max-width: 420px;
  background: #FFFFFF;
  border: 1px solid var(--border-card);
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: var(--text-main);
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
}

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

.toast-item.success {
  border-color: rgba(5, 150, 105, 0.45);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08), 0 0 12px rgba(5, 150, 105, 0.15);
}

.toast-item.error {
  border-color: rgba(220, 38, 38, 0.45);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08), 0 0 12px rgba(220, 38, 38, 0.15);
}

.toast-item.info {
  border-color: rgba(0, 102, 178, 0.45);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08), 0 0 12px rgba(0, 102, 178, 0.15);
}

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

.toast-item.success .toast-icon-wrap {
  background: rgba(16, 185, 129, 0.2);
  color: #10B981;
}

.toast-item.error .toast-icon-wrap {
  background: rgba(239, 68, 68, 0.2);
  color: #EF4444;
}

.toast-item.info .toast-icon-wrap {
  background: rgba(56, 189, 248, 0.2);
  color: #38BDF8;
}

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

.toast-title {
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: 0.02em;
}

.toast-desc {
  font-size: 0.78rem;
  color: #CBD5E1;
  line-height: 1.4;
  word-break: break-word;
}

.toast-close {
  background: none;
  border: none;
  color: #64748B;
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
  line-height: 1;
}

.toast-close:hover {
  color: #F8FAFC;
}

/* 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; }
}

