:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --bg: #f8f9fa;
  --card-bg: #ffffff;
  --text: #202124;
  --text-muted: #5f6368;
  --border: #dadce0;
  --success: #0d904f;
  --error: #c5221f;
  --warning: #ea8600;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
  --font: 'Segoe UI', Roboto, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Navigation */
.navbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar__brand {
  font-weight: 700;
  font-size: 18px;
  color: var(--primary);
  text-decoration: none;
  margin-right: 32px;
}

.navbar__links {
  display: flex;
  gap: 4px;
  list-style: none;
}

.navbar__links a {
  text-decoration: none;
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.navbar__links a:hover,
.navbar__links a.active {
  background: rgba(26,115,232,0.08);
  color: var(--primary);
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.page-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 20px;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card--header {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  text-decoration: none;
}

.btn--primary {
  background: var(--primary);
  color: #fff;
}
.btn--primary:hover { background: var(--primary-dark); }

.btn--outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--border);
}
.btn--outline:hover { background: rgba(26,115,232,0.06); }

.btn--sm { padding: 6px 12px; font-size: 13px; }

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text);
  transition: border-color 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(26,115,232,0.2);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

th {
  background: #f1f3f4;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

tr:hover td { background: rgba(26,115,232,0.03); }

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s ease;
  max-width: 400px;
}

.toast--success { background: var(--success); }
.toast--error { background: var(--error); }
.toast--info { background: var(--primary); }

@keyframes toast-in {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.badge--ok { background: #e6f4ea; color: var(--success); }
.badge--warn { background: #fef7e0; color: var(--warning); }
.badge--err { background: #fce8e6; color: var(--error); }

/* Spinner */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Summary row */
.summary-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.summary-item {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 12px 20px;
  box-shadow: var(--shadow);
  min-width: 140px;
}

.summary-item__label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.summary-item__value {
  font-size: 22px;
  font-weight: 700;
  margin-top: 2px;
}

/* Grid */
.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* Report layout */
.report-layout {
  display: flex;
  min-height: calc(100vh - 56px);
}

.report-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}

.report-sidebar__title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 20px;
}

.report-sidebar a {
  display: block;
  padding: 8px 20px;
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.report-sidebar a:hover,
.report-sidebar a.active {
  background: rgba(26,115,232,0.08);
  color: var(--primary);
}

.report-main {
  flex: 1;
  padding: 24px;
  max-width: calc(100% - 220px);
  overflow-x: hidden;
}

.report-header {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.report-header .form-group { margin-bottom: 0; min-width: 140px; }
.report-header label { font-size: 12px; }
.report-header .form-control { padding: 8px 10px; font-size: 13px; }

.report-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

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

.kpi-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
}

.kpi-card__icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  font-size: 18px;
}

.kpi-card__value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
}

.kpi-card__label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.kpi-card__change {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 8px;
}

.kpi-card__prev {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Device grid */
.device-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.device-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.device-card__title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.device-card__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
  border-bottom: 1px solid #f1f3f4;
}

.device-card__row:last-child { border-bottom: none; }

.device-card__metric-label { color: var(--text-muted); }
.device-card__metric-value { font-weight: 600; }

/* Change indicators */
.change--up { color: var(--success); background: #e6f4ea; }
.change--down { color: var(--error); background: #fce8e6; }
.change--neutral { color: var(--text-muted); background: #f1f3f4; }

/* Section headers */
.section-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-top: 8px;
}

/* Sortable table headers */
th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover { color: var(--primary); }

th.sortable::after {
  content: ' \2195';
  font-size: 11px;
  opacity: 0.5;
}

th.sortable.sort-asc::after { content: ' \2191'; opacity: 1; }
th.sortable.sort-desc::after { content: ' \2193'; opacity: 1; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state__icon { font-size: 48px; margin-bottom: 12px; }
.empty-state__text { font-size: 16px; }

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

@media (max-width: 768px) {
  .navbar { padding: 0 12px; }
  .navbar__links a { padding: 8px 10px; font-size: 13px; }
  .container { padding: 16px; }
  .summary-row { gap: 8px; }
  .report-sidebar { display: none; }
  .report-main { max-width: 100%; padding: 16px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .report-header { flex-direction: column; align-items: stretch; }
}
