:root {
  --bg: #030712;
  --bg-accent: #0b0f19;
  --card-bg: rgba(17, 24, 39, 0.75);
  --card-border: rgba(255, 255, 255, 0.06);
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --accent-primary: #3b82f6;
  --accent-secondary: #10b981;
  --accent-danger: #f43f5e;
  --accent-warning: #f59e0b;
  --glass-bg: rgba(10, 15, 30, 0.85);
  --shadow-premium: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  --radius-lg: 20px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  background: var(--bg);
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(16, 185, 129, 0.05) 0px, transparent 50%);
  color: var(--text-primary);
  margin: 0;
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden; /* Evita scroll lateral no body */
}

header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
  background: rgba(5, 7, 10, 0.7);
  border-bottom: 1px solid var(--card-border);
  padding: 0.75rem 0;
}

.wrap {
  max-width: 100%;
  padding: 0 1rem;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

h2 {
  font-size: 1.25rem;
  font-weight: 800;
  background: linear-gradient(to right, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0;
}

.main-tabs {
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
}

.nav-btn {
  padding: 6px 16px;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  border: none;
  cursor: pointer;
}

.nav-btn.active {
  background: var(--accent-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.side-btn {
  text-align: left;
  padding: 10px 14px;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  border: none;
  cursor: pointer;
  width: 100%;
}

.side-btn.active {
  background: rgba(255, 255, 255, 0.05);
  color: var(--accent-primary);
  font-weight: 700;
}

.side-btn:hover { background: rgba(255, 255, 255, 0.03); }

.pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 99px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot.ok { background: var(--accent-secondary); box-shadow: 0 0 8px var(--accent-secondary); }
.dot.bad { background: var(--accent-danger); box-shadow: 0 0 8px var(--accent-danger); }

main {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 1.5rem;
  padding: 1.5rem 1rem;
  max-width: 1600px;
  margin: 0 auto;
}

/* Evita que o grid-item (container da direita) expanda além do viewport */
main > div {
  min-width: 0;
}

@media (max-width: 1420px) {
  main {
    grid-template-columns: 310px 1fr;
    gap: 1.25rem;
  }
}

@media (max-width: 1200px) {
  main { grid-template-columns: 1fr; }
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-premium);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin-bottom: 1.5rem;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.1);
}

.card h3 {
  padding: 1.2rem 1.5rem;
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.01);
}

.content {
  padding: 1.5rem;
  min-width: 0;
  width: 100%;
}

.row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.field {
  flex: 1;
  min-width: 150px;
}

label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

input, select {
  width: 100%;
  background: rgba(10, 15, 30, 0.6);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 0.7rem 1rem;
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

input:focus, select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
  background: rgba(10, 15, 30, 0.85);
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.2rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  gap: 0.5rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), #1d4ed8);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2563eb, #1e40af);
  transform: translateY(-1.5px);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
  border: 1px solid var(--card-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.btn-secondary:active {
  transform: translateY(0);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.08);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.2);
  box-shadow: 0 4px 12px rgba(244, 63, 94, 0.05);
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.3);
  color: white;
  transform: translateY(-1.5px);
  box-shadow: 0 6px 16px rgba(244, 63, 94, 0.2);
}

.btn-danger:active {
  transform: translateY(0);
}

.tele-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.15);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  min-width: 800px;
}

th {
  background: rgba(15, 23, 42, 0.4);
  padding: 1rem;
  text-align: left;
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--card-border);
}

td {
  padding: 1rem;
  border-bottom: 1px solid var(--card-border);
  vertical-align: middle;
}

tr {
  transition: background-color 0.15s;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.015);
}

#map {
  height: 520px;
  border-radius: var(--radius-md);
  background: #0b0f19;
  border: 1px solid var(--card-border);
}

.preview-box {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--card-border);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  padding: 1.5rem;
  margin-bottom: 0;
}

@media (max-width: 768px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.kpi-card {
  position: relative;
  overflow: hidden;
  padding: 1.5rem 1.25rem;
  background: linear-gradient(145deg, rgba(20, 26, 42, 0.4), rgba(15, 23, 42, 0.7));
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  cursor: pointer;
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, 0.25);
  box-shadow: 0 10px 25px rgba(0,0,0,0.4);
}

.kpi-value {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 0.25rem;
}

.kpi-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--accent-primary);
}
.kpi-card:nth-child(2)::before { background: var(--accent-secondary); }
.kpi-card:nth-child(3)::before { background: var(--accent-danger); }
.kpi-card:nth-child(4)::before { background: var(--accent-warning); }

.badge {
  padding: 0.35rem 0.75rem;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: inline-block;
  border: 1px solid transparent;
}

.badge-online {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.2);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.1);
}

.badge-offline {
  background: rgba(244, 63, 94, 0.1);
  color: #f43f5e;
  border-color: rgba(244, 63, 94, 0.2);
  box-shadow: 0 0 8px rgba(244, 63, 94, 0.1);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.small {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.btn-small {
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  white-space: nowrap;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Custom scrollbar matching the theme */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Telemetry modern grid layout */
.tele-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 6px;
  max-width: 500px;
}

.tele-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 11px;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.tele-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.tele-icon {
  font-size: 12px;
  opacity: 0.9;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
