/* ─── Reset & base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Ensure the [hidden] attribute always wins regardless of display rules below. */
[hidden] { display: none !important; }

:root {
  --color-bg:          #0d1117;
  --color-surface:     #161b22;
  --color-border:      #30363d;
  --color-text:        #e6edf3;
  --color-muted:       #8b949e;
  --color-primary:     #388bfd;
  --color-primary-bg:  #1f3a5f;
  --color-success:     #3fb950;
  --color-success-bg:  #122d22;
  --color-warning:     #d29922;
  --color-warning-bg:  #2d1e00;
  --color-danger:      #f85149;
  --color-danger-bg:   #3d1a1a;
  --color-neutral:     #8b949e;
  --radius:            6px;
  --font-mono:         ui-monospace, "Cascadia Code", "Fira Code", monospace;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre {
  font-family: var(--font-mono);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
code { padding: 2px 5px; font-size: 0.85em; }
pre {
  padding: 14px 16px;
  overflow-x: auto;
  white-space: pre;
  font-size: 0.82em;
  line-height: 1.55;
}
pre code { background: none; border: none; padding: 0; }

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

/* ─── Header ────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.logo { display: flex; align-items: center; gap: 8px; }
.logo-icon { font-size: 1.5rem; }
.logo-text { font-size: 1.25rem; font-weight: 700; color: var(--color-text); }
.tagline { color: var(--color-muted); font-size: 0.85rem; }

/* ─── Summary cards ─────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 24px 0;
}
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  text-align: center;
}
.stat-card.warning { border-color: var(--color-warning); }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 0.8rem; color: var(--color-muted); margin-top: 4px; }

/* ─── Filters ───────────────────────────────────────────────────────────── */
.filters {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 160px;
}
.filter-group label { font-size: 0.78rem; color: var(--color-muted); font-weight: 600; }
.filter-group input,
.filter-group select {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  padding: 6px 10px;
  font-size: 0.85rem;
  width: 100%;
}
.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: var(--color-primary);
}
.filter-actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding-bottom: 1px;
}

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 6px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { opacity: 0.85; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.btn-secondary { background: var(--color-surface); color: var(--color-text); }

.btn-sm { padding: 3px 10px; font-size: 0.78rem; }
.field-hint { display: block; font-size: 0.75rem; color: var(--color-muted); margin-top: 4px; font-style: italic; }
.field-hint-error { color: var(--color-warning); font-style: normal; }
.btn-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--color-primary);
  cursor: pointer;
  font-size: inherit;
  text-decoration: underline;
}

/* ─── Recent runs section ───────────────────────────────────────────────── */
.runs-section { margin-bottom: 28px; }
.runs-hint { font-size: 0.8rem; color: var(--color-muted); margin-bottom: 10px; }

.badge-success    { background: var(--color-success-bg); color: var(--color-success); }
.badge-failure    { background: var(--color-danger-bg);  color: var(--color-danger); }
.badge-cancelled  { background: color-mix(in srgb, var(--color-surface) 60%, var(--color-border)); color: var(--color-muted); }
.badge-in-progress { background: var(--color-primary-bg); color: var(--color-primary); }
.badge-skipped    { background: var(--color-surface); color: var(--color-muted); border: 1px solid var(--color-border); }

.badge-event {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius);
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-muted);
  text-transform: lowercase;
}

/* ─── Table section ─────────────────────────────────────────────────────── */
.table-section { margin-bottom: 32px; }
.table-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}
.table-title { font-size: 1.05rem; font-weight: 600; }
.result-count { font-size: 0.8rem; color: var(--color-muted); }
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 0.82rem;
}
thead { background: color-mix(in srgb, var(--color-surface) 60%, var(--color-border) 40%); }
th, td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}
th {
  font-weight: 600;
  color: var(--color-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--color-text); }
th.sort-asc .sort-icon::after  { content: " ↑"; }
th.sort-desc .sort-icon::after { content: " ↓"; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: color-mix(in srgb, var(--color-surface) 80%, var(--color-text) 5%); }

.mono { font-family: var(--font-mono); font-size: 0.78em; }
.text-muted { color: var(--color-muted); }
.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-user   { background: var(--color-primary-bg); color: var(--color-primary); }
.badge-org    { background: #2a1f5f; color: #9e7ce8; }
.badge-active   { background: var(--color-success-bg); color: var(--color-success); }
.badge-expired  { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-expiring { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-revoked  { background: var(--color-danger-bg); color: var(--color-danger); }

/* ─── Loading / error ───────────────────────────────────────────────────── */
.loading-state, .error-state {
  padding: 32px;
  text-align: center;
  color: var(--color-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.error-state { color: var(--color-danger); border-color: var(--color-danger); }

/* ─── Pagination ────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--color-muted);
}

/* ─── How-to section ────────────────────────────────────────────────────── */
.how-to {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 32px;
}
.how-to h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 10px;
}
.how-to h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 16px 0 6px;
  color: var(--color-muted);
}
.how-to p { margin: 8px 0; color: var(--color-muted); font-size: 0.85rem; }

/* ─── Footer ────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 16px 0;
  text-align: center;
  color: var(--color-muted);
  font-size: 0.8rem;
}

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-row { flex-direction: column; }
  .filter-group { flex: 1 1 100%; }
}

/* ─── Header auth area ──────────────────────────────────────────────────── */
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.btn-login-github {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-login-github svg { width: 15px; height: 15px; fill: currentColor; flex-shrink: 0; }

.user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  flex-shrink: 0;
}
.user-login { font-size: 0.85rem; font-weight: 600; }
.btn-sm { padding: 4px 10px; font-size: 0.78rem; }

/* ─── Vouch button in table header ────────────────────────────────────── */
.table-header { align-items: center; }

/* ─── Attestation creation modal ───────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: calc(var(--radius) * 2);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: var(--color-surface);
  z-index: 1;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  color: var(--color-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: var(--radius);
}
.modal-close:hover { background: var(--color-border); color: var(--color-text); }

#vouch-form { padding: 20px; }

.form-row {
  display: flex;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.form-group {
  flex: 1 1 220px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-group-full { flex: 1 1 100%; }
.form-group label { font-size: 0.78rem; font-weight: 600; color: var(--color-muted); }
.required { color: var(--color-danger); }
.optional { font-weight: 400; color: var(--color-muted); font-size: 0.75em; }
.form-group input,
.form-group select,
.form-group textarea {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  padding: 7px 10px;
  font-size: 0.85rem;
  width: 100%;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}
.form-group textarea { resize: vertical; }
.form-error {
  color: var(--color-danger);
  background: var(--color-danger-bg);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 0.82rem;
  margin-bottom: 12px;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

