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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  padding: 24px 16px 48px;
  background: #f6f8fa;
  color: #24292e;
}

.container { max-width: 1100px; margin: 0 auto; }

h1 { font-size: 1.4rem; font-weight: 600; margin: 0 0 20px; color: #0366d6; }

/* ── search bar ── */
.search-row { display: flex; gap: 8px; margin-bottom: 12px; }
#search-input {
  flex: 1; padding: 8px 12px; font-size: 1rem;
  border: 1px solid #d1d5da; border-radius: 6px; outline: none;
}
#search-input:focus { border-color: #0366d6; box-shadow: 0 0 0 3px #c8e1ff44; }
.btn {
  padding: 8px 16px; border: 1px solid #d1d5da; border-radius: 6px;
  font-size: 0.875rem; cursor: pointer; background: #fafbfc; white-space: nowrap;
}
.btn:hover { background: #f3f4f6; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: #0366d6; color: #fff; border-color: #0366d6; font-size: 1rem;
  padding: 8px 20px;
}
.btn-primary:hover { background: #0256b3; }
.btn-primary:disabled { background: #8abaed; border-color: #8abaed; }

/* ── search help box ── */
details.help-box {
  background: #fff; border: 1px solid #e1e4e8; border-radius: 6px;
  margin-bottom: 12px; font-size: 0.85rem;
}
details.help-box > summary {
  padding: 8px 14px; cursor: pointer; font-weight: 600; color: #0366d6;
  list-style: none;
}
details.help-box > summary::-webkit-details-marker { display: none; }
details.help-box > summary::before { content: "? "; }
details.help-box[open] > summary::before { content: "↑ "; }
.help-body { padding: 0 14px 14px; }
.help-body p { margin: 6px 0; color: #444; }
.help-note { font-size: 0.8rem; color: #6a737d; margin-top: 8px !important; }
.help-table { border-collapse: collapse; width: 100%; margin-top: 6px; }
.help-table th {
  text-align: left; padding: 4px 10px; background: #f6f8fa;
  border-bottom: 2px solid #e1e4e8; font-size: 0.8rem; color: #586069;
}
.help-table td {
  padding: 5px 10px; border-bottom: 1px solid #f0f0f0;
  vertical-align: top; line-height: 1.5;
}
.help-table tr:last-child td { border-bottom: none; }
.help-table code { background: #f3f4f6; padding: 1px 5px; border-radius: 3px; font-size: 0.82rem; }

/* inline AND-tag colours in query meta */
code.tag-ilike { background: #f1f8ff; color: #0366d6; padding: 1px 6px; border-radius: 3px; }
code.tag-regex  { background: #fff8c5; color: #735c0f; padding: 1px 6px; border-radius: 3px; }

/* ── status bar ── */
#status-bar { height: 4px; border-radius: 2px; background: #e1e4e8; margin-bottom: 16px; overflow: hidden; }
#status-bar.loading { background: #e1e4e8; }
#status-bar.loading::after {
  content: ""; display: block; height: 100%; width: 40%; background: #0366d6;
  border-radius: 2px; animation: slide 1.4s ease-in-out infinite;
}
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
#status-bar.done  { background: #28a745; }
#status-bar.error { background: transparent; }

/* ── banners ── */
.banner {
  border-radius: 6px; padding: 10px 14px; margin-bottom: 12px; font-size: 0.88rem;
}
.banner-error  { background: #ffdce0; border: 1px solid #f97583; color: #86181d; }
.banner-info   { background: #fff8c5; border: 1px solid #f0c000; color: #735c0f; }
.banner-warn   { background: #ffece0; border: 1px solid #f06a00; color: #7a3500; }
.banner-warn .banner-dismiss {
  float: right; cursor: pointer; font-size: 0.85rem; margin-left: 12px;
  opacity: 0.7; text-decoration: underline;
}
.banner-warn .banner-dismiss:hover { opacity: 1; }

/* ── query meta ── */
.query-meta {
  background: #fff; border: 1px solid #e1e4e8; border-radius: 6px;
  padding: 12px 16px; margin-bottom: 12px; font-size: 0.88rem;
}
.meta-row { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.meta-row:last-child { margin-bottom: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  background: #f1f8ff; border: 1px solid #c8e1ff; border-radius: 12px;
  padding: 2px 9px; font-size: 0.78rem; color: #0366d6;
}
.chip.zero { background: #f6f8fa; border-color: #e1e4e8; color: #6a737d; }
.chip.total { background: #e6ffed; border-color: #85e89d; color: #22863a; font-weight: 600; }
.chip-clickable { cursor: pointer; transition: background 0.1s; }
.chip-clickable:hover { background: #dbedff; }
.chip-clickable:focus-visible { outline: 2px solid #0366d6; outline-offset: 1px; }

/* ── toolbar ── */
.toolbar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap;
}
.toolbar-right { margin-left: auto; display: flex; gap: 8px; }

/* ── pagination ── */
.pagination {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin: 16px 0; font-size: 0.875rem;
}
.pagination .page-info { color: #586069; margin: 0 4px; }
.page-num {
  min-width: 32px; height: 32px; padding: 0 8px;
  border: 1px solid #d1d5da; border-radius: 6px; background: #fafbfc;
  cursor: pointer; font-size: 0.875rem; display: inline-flex;
  align-items: center; justify-content: center;
}
.page-num:hover { background: #f3f4f6; }
.page-num.active { background: #0366d6; color: #fff; border-color: #0366d6; font-weight: 600; }
.page-num:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── advisory cards ── */
details.advisory {
  background: #fff; border: 1px solid #e1e4e8; border-radius: 6px;
  margin-bottom: 10px; overflow: hidden;
}
details.advisory > summary {
  padding: 11px 14px; cursor: pointer; font-weight: 600;
  list-style: none; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
details.advisory > summary::-webkit-details-marker { display: none; }
details.advisory > summary::before {
  content: "▶"; font-size: 0.65rem; transition: transform 0.15s; flex-shrink: 0;
  margin-top: 2px;
}
details.advisory[open] > summary::before { transform: rotate(90deg); }

.adv-id       { font-size: 0.95rem; }
.adv-source   { font-size: 0.75rem; color: #6a737d; font-weight: normal; font-family: monospace; }
.adv-matched  { font-size: 0.72rem; color: #fff; background: #0366d6; border-radius: 10px;
                padding: 1px 7px; font-weight: normal; }

.adv-body    { padding: 0 14px 14px; }
.adv-meta    { font-size: 0.83rem; color: #586069; margin-bottom: 8px; }
.adv-summary { margin-bottom: 10px; font-size: 0.9rem; line-height: 1.5; }

/* ── section accordions inside advisory ── */
details.section { margin-bottom: 4px; }
details.section > summary {
  cursor: pointer; font-size: 0.83rem; font-weight: 600;
  padding: 3px 0; list-style: none;
}
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary::before { content: "▸ "; color: #0366d6; }
details.section[open] > summary::before { content: "▾ "; }

/* ── tables ── */
.data-table {
  width: 100%; border-collapse: collapse; font-size: 0.78rem;
  margin-top: 5px; overflow-x: auto; display: block;
}
.data-table th {
  background: #f6f8fa; text-align: left; padding: 4px 8px;
  border-bottom: 2px solid #e1e4e8; white-space: nowrap; font-size: 0.73rem;
  color: #586069; text-transform: uppercase; letter-spacing: 0.03em;
}
.data-table td {
  padding: 4px 8px; border-bottom: 1px solid #f0f0f0;
  vertical-align: top; max-width: 400px; overflow-wrap: anywhere;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table a { color: #0366d6; text-decoration: none; }
.data-table a:hover { text-decoration: underline; }
.mono { font-family: monospace; font-size: 0.78rem; }

/* ── nested impacted packages ── */
details.pkg { margin: 4px 0 4px 10px; }
details.pkg > summary { font-family: monospace; font-size: 0.78rem; cursor: pointer; list-style: none; }
details.pkg > summary::-webkit-details-marker { display: none; }
details.pkg > summary::before { content: "▸ "; color: #0366d6; }
details.pkg[open] > summary::before { content: "▾ "; }

/* ── drill-down panel (chip cross-advisory view) ── */
.drill-down {
  background: #fff; border: 1px solid #e1e4e8; border-radius: 6px;
  padding: 10px 14px; margin-bottom: 12px;
}
.drill-down > h3 { margin: 0 0 8px; font-size: 0.95rem; color: #24292e; }
.adv-badge {
  display: inline-block; font-family: monospace; font-size: 0.75rem;
  background: #f1f8ff; border: 1px solid #c8e1ff; border-radius: 4px;
  padding: 1px 6px; color: #0366d6; cursor: pointer; text-decoration: none;
  white-space: nowrap;
}
.adv-badge:hover { background: #dbedff; text-decoration: underline; }
