:root {
  --bg: #0f1117;
  --bg-elev: #161a23;
  --bg-row: #1a1f2b;
  --bg-row-hover: #222838;
  --border: #262d3d;
  --text: #e6e9ef;
  --text-dim: #8b93a7;
  --accent: #8b5cf6;
  --accent-hover: #a78bfa;
  --green: #34d399;
  --amber: #fbbf24;
  --link: #93c5fd;
  --pill-bg: #1f2433;
  --pill-border: #2d3447;
}

[data-theme="light"] {
  --bg: #f6f7fb;
  --bg-elev: #ffffff;
  --bg-row: #ffffff;
  --bg-row-hover: #eef1f7;
  --border: #e2e6ef;
  --text: #1a1f2b;
  --text-dim: #5b6478;
  --pill-bg: #f0f3f9;
  --pill-border: #d8deeb;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

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

/* Topbar ----------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-weight: 700;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-right button,
.topbar-right .topbar-link {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.topbar-right button:hover,
.topbar-right .topbar-link:hover { border-color: var(--accent); color: var(--accent-hover); }
.topbar-right .topbar-link.primary {
  background: var(--accent, #2563eb);
  border-color: var(--accent, #2563eb);
  color: #fff;
}
.topbar-right .topbar-link.primary:hover { color: #fff; opacity: 0.9; }

/* Main / controls -------------------------------------------- */
main { max-width: 1400px; margin: 0 auto; padding: 24px 28px 80px; }

.controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.controls input[type="search"],
.controls select {
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
}
.controls input[type="search"] { flex: 1 1 280px; min-width: 220px; }
.controls select { min-width: 160px; }
.result-count { color: var(--text-dim); font-size: 12px; margin-left: auto; }

/* Table ------------------------------------------------------- */
.table-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  padding: 14px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: none;
  border-bottom: 1px solid var(--border);
  user-select: none;
  cursor: pointer;
  white-space: nowrap;
}
thead th[data-sort]:hover { color: var(--accent-hover); }
thead th.sort-asc::after  { content: " ↑"; color: var(--accent); }
thead th.sort-desc::after { content: " ↓"; color: var(--accent); }

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 13px;
}
tbody tr:hover { background: var(--bg-row-hover); }
tbody tr:last-child td { border-bottom: none; }

.pkg-name { color: var(--accent-hover); font-weight: 600; }
.pkg-file { color: var(--text-dim); font-family: ui-monospace, "JetBrains Mono", monospace; font-size: 11px; margin-top: 2px; max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num-cell { font-variant-numeric: tabular-nums; color: var(--text-dim); text-align: right; }
.release-link { font-family: ui-monospace, monospace; font-size: 12px; }
.distro-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--pill-border);
  background: var(--pill-bg);
  color: var(--text);
}
.distro-alpine { color: #38bdf8; border-color: rgba(56, 189, 248, 0.4); }
.distro-debian { color: #f87171; border-color: rgba(248, 113, 113, 0.4); }
.distro-ubuntu { color: #fb923c; border-color: rgba(251, 146, 60, 0.4); }
.version-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--pill-bg);
  border: 1px solid var(--pill-border);
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: var(--green);
}
.size-cell { font-variant-numeric: tabular-nums; color: var(--text-dim); }
.date-cell { font-family: ui-monospace, monospace; font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.cat-pill {
  display: inline-block;
  padding: 2px 10px;
  margin: 0 4px 2px 0;
  border-radius: 999px;
  border: 1px solid var(--pill-border);
  background: transparent;
  color: var(--text);
  font-size: 11px;
}

.actions { display: flex; gap: 6px; flex-wrap: nowrap; }
.actions a, .actions button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
  text-decoration: none;
}
.actions a:hover, .actions button:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
  text-decoration: none;
}
.actions .download { color: var(--green); border-color: rgba(52, 211, 153, 0.4); }
.actions .download:hover { background: rgba(52, 211, 153, 0.08); color: var(--green); }

.recipe-btn {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid rgba(139, 92, 246, 0.4);
  background: transparent;
  color: var(--accent-hover);
  font-size: 11px;
  cursor: pointer;
}
.recipe-btn:hover {
  background: rgba(139, 92, 246, 0.1);
  border-color: var(--accent);
}

.loading, .empty { text-align: center; padding: 40px; color: var(--text-dim); }

/* Pager ------------------------------------------------------- */
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-items: center;
  margin: 14px 0;
}
.page-btn {
  min-width: 34px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.page-btn:hover:not(:disabled):not(.active) {
  border-color: var(--accent);
  color: var(--accent-hover);
}
.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: default;
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-ellipsis { color: var(--text-dim); padding: 0 4px; user-select: none; }

/* Modal ------------------------------------------------------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(8, 10, 16, 0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(1100px, 94vw);
  height: min(80vh, 800px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-head #modalTitle { font-weight: 600; }
.modal-tabs { display: flex; gap: 4px; margin-left: 8px; flex: 1; }
.modal-tabs button {
  padding: 5px 12px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
.modal-tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.modal-head #modalClose {
  background: transparent; border: none; color: var(--text-dim);
  font-size: 18px; cursor: pointer;
}
.modal-body {
  flex: 1;
  margin: 0;
  padding: 16px;
  overflow: auto;
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
  font-size: 12px;
  white-space: pre;
  background: var(--bg);
  color: var(--text);
}

/* Footer ------------------------------------------------------ */
.footer {
  position: fixed; bottom: 0; left: 0; right: 0;
  padding: 8px 24px;
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  text-align: center;
}
