:root {
  --bg: #0d0f14;
  --surface: #1a1d2e;
  --surface-2: #252840;
  --primary: #3b82f6;
  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;
  --text: #f1f5f9;
  --text-muted: #64748b;
  --border: #2d3150;
  --header-height: 56px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  height: 100vh;
  overflow: hidden;
}

.dashboard-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-right: 16px;
}

.header-update {
  font-size: 12px;
  color: var(--text-muted);
}

.dashboard-main {
  height: calc(100vh - var(--header-height));
  overflow: hidden;
  padding: 16px;
}

.viewers-grid {
  height: 100%;
  display: grid;
  gap: 16px;
}

/* Grid configurations */
.grid-1-1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.grid-2-1 { grid-template-columns: repeat(2, 1fr); grid-template-rows: 1fr; }
.grid-3-1 { grid-template-columns: repeat(3, 1fr); grid-template-rows: 1fr; }
.grid-2-2 { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); }
.grid-3-2 { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); }
.grid-4-2 { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(2, 1fr); }

/* Viewer card */
.viewer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: border-color 0.2s;
}

.viewer-card.status-ok { border-left: 4px solid var(--success); }
.viewer-card.status-error { border-left: 4px solid var(--error); }
.viewer-card.status-pending { border-left: 4px solid var(--warning); }

.card-icon {
  font-size: 64px;
  line-height: 1;
  margin-bottom: 12px;
  text-align: center;
}

.card-status-img {
  width: 80px;
  height: 80px;
  object-fit: contain;
}

.card-status-img--wide {
  width: 80%;
  height: auto;
  max-height: 160px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.card-status-img--medium {
  width: 50%;
  height: auto;
  max-height: 120px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.card-status-fallback {
  font-size: 64px;
  line-height: 1;
}

.card-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.card-name--center {
  text-align: center;
  font-size: 19px;
}

.card-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.card-meta--center {
  text-align: center;
}

.card-status {
  font-size: 13px;
  font-weight: 500;
  margin-top: auto;
}

.card-status--center {
  text-align: center;
}

.card-status.ok { color: var(--success); }
.card-status.error { color: var(--error); }
.card-status.pending { color: var(--warning); }

.card-payload {
  flex: 1;
  overflow: auto;
  margin-top: 8px;
}

.payload-table {
  width: 100%;
  border-collapse: collapse;
}

.payload-table tr + tr {
  border-top: 1px solid var(--border);
}

.payload-table td {
  padding: 6px 4px;
  vertical-align: top;
  font-size: 13px;
  line-height: 1.4;
}

.pd-key {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  padding-right: 12px;
  width: 1%;
}

.pd-val {
  color: var(--text);
  word-break: break-word;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination button {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  padding: 6px 12px;
  transition: background 0.15s;
}

.pagination button:hover { background: var(--primary); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .page-info { font-size: 13px; color: var(--text-muted); }

/* Empty state */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 16px;
}

@media (max-width: 768px) {
  body { overflow: auto; }
  .dashboard-main { height: auto; overflow-y: auto; }
  .viewers-grid {
    height: auto !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: none !important;
  }
  .card-icon { font-size: 48px; }
}
