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

:root {
  --bg: #0d1117;
  --card-bg: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #d29922;
  --grey: #21262d;
  --accent: #58a6ff;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
}

header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  background: var(--card-bg);
}

header h1 {
  margin: 0;
  font-size: 1.25rem;
}

header a {
  color: var(--text);
  text-decoration: none;
}

header a:hover {
  color: var(--accent);
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

h2 {
  margin-top: 0;
}

/* Device Grid */
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.device-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  text-decoration: none;
  color: var(--text);
  display: block;
  transition: border-color 0.15s;
}

.device-card:hover {
  border-color: var(--accent);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.success { background: var(--green); }
.status-dot.failure { background: var(--red); }
.status-dot.unknown { background: var(--grey); }

.card-label {
  font-weight: 600;
  font-size: 1rem;
}

.card-location {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.card-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  background: var(--green);
  color: var(--bg);
  font-weight: 600;
}

/* Raster */
.raster {
  margin: 1.5rem 0;
  overflow-x: auto;
}

.raster-grid {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 2px;
}

.raster-cell {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  cursor: pointer;
}

.raster-cell.success { background: var(--green); }
.raster-cell.failure { background: var(--red); }
.raster-cell.empty { background: var(--grey); }
.raster-cell.selected { outline: 2px solid var(--accent); outline-offset: 1px; }

.raster-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding-right: 0.5rem;
  white-space: nowrap;
}

.raster-header {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
}

/* Recordings Table */
.recordings {
  margin-top: 1.5rem;
}

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

.recordings th,
.recordings td {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.recordings th {
  color: var(--text-muted);
  font-weight: 600;
}

.recordings tr.pending {
  opacity: 0.5;
}

.recordings audio {
  height: 2rem;
  max-width: 200px;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.success { background: var(--green); color: var(--bg); }
.badge.failure { background: var(--red); color: var(--bg); }

/* Device Info */
.device-info {
  margin-bottom: 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.device-info span {
  margin-right: 1rem;
}

/* Loading / Error */
.loading {
  color: var(--text-muted);
  font-style: italic;
}
