:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #22263a;
  --border: #2e3348;
  --text: #e2e8f0;
  --text-muted: #8892a4;
  --accent: #6366f1;
  --accent-dim: #3730a3;
  --green: #22c55e;
  --yellow: #eab308;
  --orange: #f97316;
  --red: #ef4444;
  --blue: #3b82f6;
  --purple: #a855f7;
  --radius: 8px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

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

header {
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
  margin-bottom: 28px;
}

header .inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

header h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
header h1 span { color: var(--text-muted); font-weight: 400; }

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

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 24px; }

.tab {
  padding: 7px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.tab:hover { color: var(--text); background: var(--surface); }

.tab.active {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

/* Stat cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.card-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 4px;
}

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

/* DORA rating badge */
.dora-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dora-badge.Elite  { background: rgba(34,197,94,0.15);  color: var(--green);  }
.dora-badge.High   { background: rgba(59,130,246,0.15); color: var(--blue);   }
.dora-badge.Medium { background: rgba(234,179,8,0.15);  color: var(--yellow); }
.dora-badge.Low    { background: rgba(239,68,68,0.15);  color: var(--red);    }

/* Charts grid */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

@media (max-width: 860px) { .charts-grid { grid-template-columns: 1fr; } }

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.chart-card h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}

.chart-card.full-width { grid-column: 1 / -1; }

.chart-wrap { position: relative; height: 240px; }
.chart-wrap.tall { height: 320px; }

/* Tables */
.section { margin-bottom: 28px; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}

.section-header h2 {
  font-size: 14px;
  font-weight: 600;
}

.search-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  padding: 6px 12px;
  width: 240px;
  outline: none;
  transition: border-color 0.15s;
}

.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-muted); }

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

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

th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

.pr-title {
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pr-title a { color: var(--text); text-decoration: none; }
.pr-title a:hover { color: var(--accent); text-decoration: underline; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.badge-feature { background: rgba(99,102,241,0.15); color: var(--accent); }
.badge-bug     { background: rgba(239,68,68,0.15);  color: var(--red); }
.badge-revert  { background: rgba(249,115,22,0.15); color: var(--orange); }
.badge-other   { background: rgba(136,146,164,0.15); color: var(--text-muted); }
.badge-linear  { background: rgba(99,102,241,0.1);  color: #818cf8; border: 1px solid rgba(99,102,241,0.3); }
.badge-asana   { background: rgba(249,115,22,0.1);  color: #fb923c; border: 1px solid rgba(249,115,22,0.3); }
.badge-peng    { background: rgba(168,85,247,0.1);  color: #c084fc; border: 1px solid rgba(168,85,247,0.3); }

/* Org chip */
.org-chip {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap;
}

/* Empty state */
.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
  font-size: 13px;
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Error banner */
.error-banner {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--red);
  font-size: 13px;
  margin-bottom: 20px;
  display: none;
}

.error-banner.visible { display: block; }

/* DORA performance matrix */
.dora-matrix {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 28px;
}

.dora-matrix summary {
  padding: 14px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dora-matrix summary::before {
  content: '▸';
  font-size: 11px;
  transition: transform 0.15s;
}

.dora-matrix[open] summary::before { transform: rotate(90deg); }
.dora-matrix summary::-webkit-details-marker { display: none; }

.dora-matrix-body {
  padding: 0 20px 20px;
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
}

.matrix-table th,
.matrix-table td {
  padding: 9px 14px;
  font-size: 12px;
  border: 1px solid var(--border);
  text-align: left;
}

.matrix-table thead th {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
  border-color: var(--border);
}

.matrix-table .metric-name {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.matrix-table th.elite,  .matrix-table td.elite  { color: var(--green);  background: rgba(34,197,94,0.06); }
.matrix-table th.high,   .matrix-table td.high   { color: var(--blue);   background: rgba(59,130,246,0.06); }
.matrix-table th.medium, .matrix-table td.medium { color: var(--yellow); background: rgba(234,179,8,0.06); }
.matrix-table th.low,    .matrix-table td.low    { color: var(--red);    background: rgba(239,68,68,0.06); }

.matrix-source {
  font-size: 11px;
  color: var(--text-muted);
}

.matrix-source a { color: var(--text-muted); }
.matrix-source a:hover { color: var(--text); }

/* Lead time colours by duration */
.lt-fast   { color: var(--green); }
.lt-medium { color: var(--yellow); }
.lt-slow   { color: var(--orange); }
.lt-very-slow { color: var(--red); }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 10px 4px 0;
  min-height: 36px;
}

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

.page-buttons { display: flex; gap: 4px; }

.page-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 5px 10px;
  transition: background 0.15s, border-color 0.15s;
}

.page-btn:hover:not([disabled]) {
  background: var(--surface-2);
  border-color: var(--accent);
}

.page-btn[disabled] {
  color: var(--text-muted);
  cursor: default;
  opacity: 0.4;
}
