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

:root {
  --bg:          #f5f6f8;
  --surface:     #ffffff;
  --border:      #e2e4e9;
  --text-1:      #111827;
  --text-2:      #4b5563;
  --text-3:      #9ca3af;
  --accent:      #0078d4;
  --accent-ring: rgba(0, 120, 212, .12);
  --radius:      8px;
  --shadow:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh;
}

/* ── LOADING ─────────────────────────────────────────────────────────────── */
#loading {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-3);
  font-size: .875rem;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── HEADER ──────────────────────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  padding: 0 40px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.header-brand { display: flex; align-items: center; gap: 12px; }
.header-logo {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.header-logo svg { width: 16px; height: 16px; }
.header-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -.01em;
}
.header-sub {
  font-size: .7rem;
  color: var(--text-3);
  margin-top: 1px;
}
.header-meta {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: .75rem;
  color: var(--text-3);
}
.header-meta strong { color: var(--text-2); font-weight: 500; }
.header-link {
  font-size: .75rem;
  color: var(--text-3);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color .15s;
}
.header-link:hover { color: var(--text-2); }

/* ── NAVIGATION ──────────────────────────────────────────────────────────── */
.topnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.topnav-inner {
  padding: 0 40px;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 2px;
}
.nav-btn {
  height: 44px;
  padding: 0 14px;
  border: none;
  background: none;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color .15s;
  white-space: nowrap;
  border-radius: 0;
}
.nav-btn::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity .15s;
}
.nav-btn:hover { color: var(--text-1); }
.nav-btn.active { color: var(--accent); }
.nav-btn.active::after { opacity: 1; }

.nav-sep {
  flex: 1;
}

/* ── MAIN ────────────────────────────────────────────────────────────────── */
main {
  padding: 32px 40px 56px;
}

/* ── STAT CARDS ──────────────────────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--card-color, var(--border));
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1;
  letter-spacing: -.02em;
}
.stat-label {
  font-size: .68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-3);
  margin-top: 7px;
}

/* ── CONTROLS ────────────────────────────────────────────────────────────── */
.controls-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.search-wrap {
  flex: 1;
  min-width: 240px;
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 11px;
  color: var(--text-3);
  pointer-events: none;
  width: 15px;
  height: 15px;
}
input[type="search"] {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .8125rem;
  color: var(--text-1);
  background: var(--bg);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input[type="search"]::placeholder { color: var(--text-3); }
input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
  background: var(--surface);
}
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }
.controls-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  flex-shrink: 0;
}
select {
  padding: 8px 30px 8px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .8rem;
  color: var(--text-2);
  background: var(--bg);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  transition: border-color .15s;
}
select:focus { border-color: var(--accent); }
.clear-btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .8rem;
  color: var(--text-2);
  background: var(--bg);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.clear-btn:hover { border-color: #c0c4cc; background: #ededf0; }
.clear-btn:disabled { opacity: .4; cursor: default; pointer-events: none; }

/* ── TOOLBAR ─────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.section-title {
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -.01em;
}
.section-count {
  font-size: .72rem;
  font-weight: 500;
  color: var(--text-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px 10px;
  white-space: nowrap;
}
/* keep legacy selector working for any leftover references */
.result-count { font-size: .78rem; color: var(--text-3); }

/* ── TABLE ───────────────────────────────────────────────────────────────── */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.table-scroll {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 360px);
  min-height: 200px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
  table-layout: fixed;
}
thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  padding: 9px 14px;
  text-align: left;
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-3);
  white-space: nowrap;
  user-select: none;
  overflow: hidden;
}
thead th.sortable { cursor: pointer; }
thead th.sortable:hover { color: var(--text-2); background: #f3f4f6; }
thead th.sort-asc::after  { content: ' ▲'; font-size: .6rem; color: var(--accent); }
thead th.sort-desc::after { content: ' ▼'; font-size: .6rem; color: var(--accent); }

/* Column resize handle */
.col-resize {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: 5px;
  cursor: col-resize;
  background: transparent;
  z-index: 3;
}
.col-resize:hover, .col-resize.active { background: var(--accent); opacity: .4; }
tbody tr { transition: background .08s; }
tbody tr:hover td { background: #f8f9fb; }
tbody tr:not(:last-child) td { border-bottom: 1px solid #f0f1f5; }
td {
  padding: 9px 14px;
  color: var(--text-2);
  vertical-align: middle;
}
td.col-num  { color: var(--text-3); font-size: .73rem; width: 44px; }
td.col-pub  { color: var(--text-1); font-weight: 500; }
td.col-name { color: var(--text-1); }
td.col-ver  {
  font-family: ui-monospace, 'Cascadia Code', 'Fira Mono', Menlo, monospace;
  font-size: .75rem;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: .7rem;
  font-weight: 500;
  white-space: nowrap;
}
.badge-yes { background: #dcfce7; color: #15803d; }
.badge-no  { background: #f3f4f6; color: #9ca3af; }

/* Tags */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 500;
  white-space: nowrap;
}
.tag-arch {
  background: #eff6ff;
  color: #1d4ed8;
  font-family: ui-monospace, 'Cascadia Code', Menlo, monospace;
  font-size: .7rem;
}
.tag-locale {
  background: #f3f4f6;
  color: var(--text-2);
  margin: 1px;
}

/* Empty state */
.empty-state {
  padding: 56px 24px;
  text-align: center;
  color: var(--text-3);
}
.empty-state p { font-size: .9rem; margin-top: 12px; }

/* ── STATISTICS VIEW ─────────────────────────────────────────────────────── */
.stats-page-header {
  margin-bottom: 24px;
}
.stats-page-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-1);
}
.stats-page-header p {
  font-size: .8rem;
  color: var(--text-3);
  margin-top: 4px;
}
#stats-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}
.stats-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--card-color, var(--border));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}
.stats-block-title {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-3);
  margin-bottom: 16px;
}
/* Publisher bars */
.pub-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: .8rem;
}
.pub-name {
  width: 160px;
  flex-shrink: 0;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width .3s ease;
}
.pub-count {
  width: 36px;
  text-align: right;
  font-size: .75rem;
  color: var(--text-3);
  flex-shrink: 0;
}
/* Stats tables */
.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
}
.stats-table thead th {
  padding: 6px 10px;
  text-align: left;
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
}
.stats-table tbody td {
  padding: 7px 10px;
  color: var(--text-2);
  vertical-align: middle;
}
.stats-table tbody tr:not(:last-child) td {
  border-bottom: 1px solid #f0f1f5;
}
.stats-table tbody tr:hover td { background: #f8f9fb; }
.stats-note {
  margin-top: 10px;
  font-size: .75rem;
  color: var(--text-3);
}

/* ── CHANGES VIEW ────────────────────────────────────────────────────────── */
.changes-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
}
.changes-tab {
  padding: 7px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.changes-tab:hover { background: var(--bg); color: var(--text-1); }
.changes-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.changes-meta {
  font-size: .78rem;
  color: var(--text-3);
  margin-bottom: 24px;
}
.changes-meta strong { color: var(--text-2); }
.changes-section { margin-bottom: 28px; }
.changes-empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--text-3);
  font-size: .875rem;
}
.changes-no-data {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  color: var(--text-3);
  font-size: .875rem;
}

/* ── DOCS VIEW ───────────────────────────────────────────────────────────── */
.docs-container {
  max-width: 860px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.docs-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 28px;
}
.docs-section h2 {
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 8px;
}
.docs-section p {
  font-size: .8125rem;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: 16px;
}
.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
}
.docs-table thead th {
  padding: 8px 12px;
  text-align: left;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}
.docs-table thead th:first-child { border-radius: 4px 0 0 0; }
.docs-table thead th:last-child  { border-radius: 0 4px 0 0; }
.docs-table tbody td {
  padding: 9px 12px;
  color: var(--text-2);
  vertical-align: top;
  line-height: 1.5;
}
.docs-table tbody tr:not(:last-child) td { border-bottom: 1px solid #f0f1f5; }
.docs-table tbody tr:hover td { background: #f8f9fb; }
.docs-table code {
  font-family: ui-monospace, 'Cascadia Code', Menlo, monospace;
  font-size: .78rem;
  background: #f3f4f6;
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--text-1);
}

/* ── FOOTER ──────────────────────────────────────────────────────────────── */
footer {
  padding: 20px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: .73rem;
  color: var(--text-3);
  border-top: 1px solid var(--border);
  background: var(--surface);
}
footer a { color: var(--text-3); text-decoration: none; }
footer a:hover { color: var(--text-2); }
.footer-links { display: flex; align-items: center; gap: 8px; }
.footer-sep { color: var(--border); }
.footer-imprint-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: var(--text-3);
  cursor: pointer;
  font-family: inherit;
}
.footer-imprint-btn:hover { color: var(--text-2); }
.heart { color: #e5534b; }

/* ── IMPRINT MODAL ───────────────────────────────────────────────────────── */
.imprint-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(2px);
  z-index: 1000;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .18s ease, visibility .18s ease;
}
.imprint-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.imprint-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  width: 100%;
  max-width: 460px;
  overflow: hidden;
  transform: scale(.96);
  transition: transform .18s ease;
}
.imprint-overlay.open .imprint-modal {
  transform: scale(1);
}
.imprint-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.imprint-title {
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-1);
}
.imprint-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  border-radius: 6px;
  color: var(--text-3);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.imprint-close:hover { background: var(--bg); color: var(--text-1); }
.imprint-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: .8125rem;
  color: var(--text-2);
  line-height: 1.6;
}
.imprint-label {
  font-size: .72rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 500;
}
.imprint-name {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--text-1);
}
.imprint-body a { color: var(--accent); text-decoration: none; }
.imprint-body a:hover { text-decoration: underline; }
.imprint-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

/* ── RESPONSIVE ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .header-inner  { padding: 0 16px; }
  .header-meta   { display: none; }
  .topnav-inner  { padding: 0 16px; gap: 0; }
  main           { padding: 16px 16px 40px; }
  footer         { padding: 16px; flex-direction: column; text-align: center; }
  .stats-grid    { grid-template-columns: 1fr; }
  .docs-container { max-width: 100%; }
}
