:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --text: #1a1d23;
  --muted: #6b7280;
  --border: #e5e7eb;
  --ok: #178a4c;
  --warn: #b45309;
  --error: #c53030;
  --accent: #2563eb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --panel: #1d2025;
    --text: #e8eaed;
    --muted: #9aa0aa;
    --border: #2d3138;
    --ok: #4ade80;
    --warn: #f0b429;
    --error: #f87171;
    --accent: #60a5fa;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 24px 32px 64px;
}

header { position: relative; }
header h1 { margin: 0 0 4px; font-size: 22px; }
.subtitle { margin: 0 0 24px; color: var(--muted); font-size: 14px; }
.logout-btn {
  position: absolute;
  top: 0;
  right: 0;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}

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

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.card .value { font-size: 26px; font-weight: 700; }
.card .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 24px;
}

.panel h2 { margin: 0 0 14px; font-size: 16px; }
.panel .subtitle { margin: -8px 0 14px; }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.badge.error { background: color-mix(in srgb, var(--error) 18%, transparent); color: var(--error); }

.filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filters input, .filters select {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}
.filters button {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  font-size: 13px;
  cursor: pointer;
}

.empty { color: var(--muted); font-size: 13px; padding: 8px 0; }

.matrix-legend { display: flex; gap: 18px; margin-bottom: 14px; font-size: 12.5px; color: var(--muted); }
.legend-item { display: flex; align-items: center; gap: 6px; }

.status-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  border: none;
  padding: 0;
  font-family: inherit;
}
.status-dot.none { background: transparent; color: var(--border); border: 1px dashed var(--border); }

.status-pct {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  border: none;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}
.status-pct.ok { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.status-pct.warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.status-pct.error { background: color-mix(in srgb, var(--error) 20%, transparent); color: var(--error); }

button.status-pct.clickable {
  cursor: pointer;
  transition: transform 0.1s ease;
}
button.status-pct.clickable:hover { transform: scale(1.08); }
button.status-pct.clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  button.status-pct.clickable { transition: none; }
}

#matrix-table td, #matrix-table th { text-align: center; white-space: nowrap; }
#matrix-table td:first-child, #matrix-table th:first-child { text-align: left; white-space: nowrap; }
#matrix-table th { font-variant-numeric: tabular-nums; }

.active-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--text);
  font-size: 13px;
}
.active-filter #active-filter-label { font-weight: 600; }
.active-filter button {
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}
