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

:root {
  --bg: #0b0f1a;
  --surface: #131929;
  --surface2: #1a2235;
  --accent: #00AEEF;
  --accent2: #00d4aa;
  --warn: #f59e0b;
  --danger: #ef4444;
  --text: #e2e8f0;
  --muted: #64748b;
  --border: #1e2d45;
  --radius: 12px;
}

body { background: var(--bg); color: var(--text); font-family: 'Segoe UI', system-ui, sans-serif; min-height: 100vh; }

header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.logo { display: flex; align-items: center; gap: 10px; font-size: 1.2rem; font-weight: 700; }
.logo small { font-size: 0.7rem; color: var(--muted); font-weight: 400; margin-left: 4px; }
#clock { font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; }

main { padding: 24px 28px; }

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px; margin-bottom: 28px;
}

.device-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; cursor: pointer; transition: border-color 0.2s, box-shadow 0.2s;
  position: relative; overflow: hidden;
}
.device-card:hover { border-color: var(--accent); box-shadow: 0 0 20px rgba(0,174,239,0.12); }
.device-card.active { border-color: var(--accent); box-shadow: 0 0 24px rgba(0,174,239,0.2); }
.device-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  opacity: 0; transition: opacity 0.2s;
}
.device-card.active::before, .device-card:hover::before { opacity: 1; }

.card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.device-name { font-size: 1rem; font-weight: 600; }
.device-id { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }
.status-badge {
  font-size: 0.7rem; font-weight: 600; padding: 3px 10px; border-radius: 99px; text-transform: uppercase;
  letter-spacing: 0.05em;
}
.status-online { background: rgba(0,212,170,0.15); color: var(--accent2); }
.status-degraded { background: rgba(245,158,11,0.15); color: var(--warn); }
.status-offline { background: rgba(239,68,68,0.15); color: var(--danger); }
.status-no-data { background: rgba(100,116,139,0.15); color: var(--muted); }

.card-location { font-size: 0.78rem; color: var(--muted); margin-bottom: 16px; }
.card-location svg { vertical-align: middle; margin-right: 4px; }

.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric { background: var(--surface2); border-radius: 8px; padding: 10px 14px; }
.metric-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 4px; }
.metric-value { font-size: 1.3rem; font-weight: 700; line-height: 1; }
.metric-unit { font-size: 0.7rem; color: var(--muted); }

.bar-wrap { margin-top: 6px; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.bar { height: 100%; border-radius: 2px; transition: width 0.8s ease; }
.bar-accent { background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.bar-warn { background: var(--warn); }
.bar-danger { background: var(--danger); }

.card-footer { margin-top: 14px; font-size: 0.72rem; color: var(--muted); display: flex; justify-content: space-between; }

/* Charts */
.chart-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.chart-header { margin-bottom: 20px; }
.chart-header h2 { font-size: 1rem; font-weight: 600; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.chart-box { background: var(--surface2); border-radius: 8px; padding: 16px; }
.chart-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 10px; }
canvas { width: 100% !important; height: 120px !important; }

@media (max-width: 600px) {
  main { padding: 16px; }
  header { padding: 12px 16px; }
  .metrics { grid-template-columns: 1fr 1fr; }
}
