:root {
  --bg: #0a0b0f;
  --bg-elevated: #0d0f14;
  --surface: #14161d;
  --surface-2: #1a1d26;
  --surface-3: #22262f;
  --border: #23262f;
  --border-strong: #2e323d;
  --text: #eceef2;
  --text-dim: #9aa1b1;
  --text-faint: #6b7180;
  --accent: #5b8cff;
  --accent-dim: #17233f;
  --accent-strong: #8fb0ff;
  --violet: #9b8cff;
  --violet-dim: #211c3f;
  --green: #3ecf8e;
  --green-dim: #0f2a20;
  --amber: #e6b450;
  --amber-dim: #332a12;
  --red: #f0616d;
  --red-dim: #331419;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sidebar-w: 236px;
}

* { box-sizing: border-box; }

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

a { color: inherit; }

/* --- layout shell: sidebar + content --- */

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 1.4rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--text);
  padding: 0.3rem 0.5rem 1.6rem;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.8rem;
  color: #04070f;
  letter-spacing: -0.02em;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text strong { font-size: 0.94rem; font-weight: 700; letter-spacing: -0.01em; }
.brand-text small { font-size: 0.68rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.87rem;
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.8; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--accent-dim); color: var(--accent-strong); }
.nav-link.active svg { opacity: 1; }

.content { flex: 1; min-width: 0; }

.topbar {
  padding: 1.5rem 2.4rem;
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 1.35rem; letter-spacing: -0.01em; }
.topbar p.lede { margin: 0.4rem 0 0; }

main.wrap {
  padding: 1.9rem 2.4rem 3.5rem;
  max-width: 1220px;
}

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    overflow-x: auto;
  }
  .sidebar .brand { padding: 0 1.2rem 0 0.2rem; flex-shrink: 0; }
  .sidebar nav { flex-direction: row; }
  .nav-link { white-space: nowrap; }
  .topbar, main.wrap { padding-left: 1.25rem; padding-right: 1.25rem; }
}

/* --- typography --- */

h2 { font-size: 1.05rem; margin: 2rem 0 0.9rem; letter-spacing: -0.005em; }
p.lede { color: var(--text-dim); max-width: 72ch; }

/* --- stat tiles --- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.stat-tile .icon-chip {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-tile .icon-chip svg { width: 17px; height: 17px; }

.icon-chip.blue { background: var(--accent-dim); color: var(--accent-strong); }
.icon-chip.violet { background: var(--violet-dim); color: var(--violet); }
.icon-chip.green { background: var(--green-dim); color: var(--green); }
.icon-chip.amber { background: var(--amber-dim); color: var(--amber); }
.icon-chip.red { background: var(--red-dim); color: var(--red); }
.icon-chip.gray { background: var(--surface-3); color: var(--text-dim); }

.stat-tile .value { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.02em; }
.stat-tile .label { color: var(--text-dim); font-size: 0.81rem; }

/* --- panels (toolbar + table grouped in one card) --- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.panel .table-scroll { overflow-x: auto; }

@media (max-width: 700px) {
  table.table { min-width: 640px; }
}

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

/* --- buttons --- */

button, .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent);
  color: #04070f;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: filter 0.12s ease, transform 0.05s ease;
}
button:hover, .btn:hover { filter: brightness(1.1); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }
button.secondary, .btn.secondary { background: var(--surface-3); color: var(--text); border: 1px solid var(--border-strong); }
button.danger { background: var(--red); color: #330b0f; }

/* --- toolbar / filters --- */

.toolbar {
  display: flex;
  gap: 0.6rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  align-items: center;
}
.toolbar input, .toolbar select {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.86rem;
}
.toolbar input { flex: 1; min-width: 180px; }
.toolbar input:focus, .toolbar select:focus { outline: none; border-color: var(--accent); }

.mono { font-family: var(--mono); font-size: 0.86rem; word-break: break-all; }

/* --- tables --- */

table.table { width: 100%; border-collapse: collapse; }
table.table th, table.table td {
  text-align: left;
  padding: 0.7rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
table.table th {
  color: var(--text-faint);
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
table.table td { font-size: 0.87rem; }
table.table tbody tr { transition: background 0.1s ease; }
table.table tbody tr:hover { background: var(--surface-2); cursor: pointer; }
table.table tbody tr:last-child td { border-bottom: none; }

/* --- badges --- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.22rem 0.6rem 0.22rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-3);
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge.green { color: var(--green); }
.badge.amber { color: var(--amber); }
.badge.red { color: var(--red); }
.badge.gray { color: var(--text-dim); }

/* --- detail panel (certificate view) --- */

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.4rem;
}
.detail-header h2 { margin: 0; }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 0.5rem 1rem; margin: 1rem 0 0; }
.kv dt { color: var(--text-dim); font-size: 0.83rem; }
.kv dd { margin: 0; font-size: 0.9rem; }

/* --- notices / empty state --- */

.notice {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.87rem;
  color: var(--text-dim);
  margin: 1rem 0;
}
.notice.warn { border-color: var(--amber); color: var(--amber); }
.notice.error { border-color: var(--red); color: var(--red); }

.empty {
  color: var(--text-faint);
  font-size: 0.88rem;
  padding: 2.5rem 0;
  text-align: center;
}
