:root {
  --bg: #0b0d10;
  --panel: #13161b;
  --panel-2: #181c23;
  --border: #1f2530;
  --text: #e6e9ef;
  --dim: #8b96a8;
  --accent: #5ad6a8;
  --warn: #ffb454;
  --bad: #ff6b6b;
  --info: #7aa2ff;
  --link: #9fc0ff;
  --mono: "JetBrains Mono", "SF Mono", "Menlo", "Consolas", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

code, .mono { font-family: var(--mono); font-size: 0.92em; }

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 18px;
}

.dim { color: var(--dim); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(180deg, rgba(11,13,16,0.98), rgba(11,13,16,0.92));
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.topbar .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  padding-bottom: 8px;
}
.topbar .meta-line {
  padding-bottom: 12px;
  font-size: 12px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand .logo {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center; justify-content: center;
  background: rgba(90,214,168,0.12);
  color: var(--accent);
  font-weight: 700;
  font-size: 18px;
}
.brand .title { font-weight: 600; letter-spacing: 0.2px; }
.brand .subtitle { color: var(--dim); font-size: 12px; }

.nav { display: flex; gap: 8px; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.btn:hover { background: var(--panel-2); border-color: #2a3140; }
.btn.primary { background: rgba(90,214,168,0.10); color: var(--accent); border-color: rgba(90,214,168,0.35); }
.btn.primary:hover { background: rgba(90,214,168,0.18); }
.btn.ghost { background: transparent; }

/* Content */
.content { padding: 22px 18px 50px; display: flex; flex-direction: column; gap: 22px; }

/* KPI strip */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.kpi-label { color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; }
.kpi-value { font-size: 28px; font-weight: 600; margin: 6px 0 2px; font-family: var(--mono); color: var(--accent); }
.kpi-foot { font-size: 12px; }

@media (max-width: 880px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
}

/* Panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 16px 18px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.panel h2 {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text);
  margin: 0;
}

/* Segmented control */
.seg {
  display: inline-flex;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.seg-btn {
  border: 0;
  background: transparent;
  color: var(--dim);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: rgba(122,162,255,0.12); color: var(--info); }

/* Chart */
.chart-wrap { height: 230px; }
#trendCaption { margin-top: 8px; }

/* Drift list */
.drift-list { list-style: none; padding: 0; margin: 0; }
.drift-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--border);
}
.drift-list li:last-child { border-bottom: 0; }
.drift-list .badge {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}
.badge.lost   { background: rgba(255,107,107,0.13); color: var(--bad); }
.badge.gained { background: rgba(90,214,168,0.13); color: var(--accent); }
.badge.first-seen { background: rgba(122,162,255,0.13); color: var(--info); }
.badge.compromised-despite-provenance { background: rgba(255,180,84,0.16); color: var(--warn); }
.drift-list .pkg { font-family: var(--mono); }
.drift-list .ver { font-family: var(--mono); color: var(--dim); font-size: 12px; }
.drift-list .time { margin-left: auto; color: var(--dim); font-size: 11px; font-family: var(--mono); }

/* Controls */
.controls { display: flex; gap: 8px; flex-wrap: wrap; }
.controls input, .controls select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
}
.controls input:focus, .controls select:focus { outline: 2px solid rgba(122,162,255,0.4); border-color: rgba(122,162,255,0.6); }

/* Table */
.table-wrap { overflow-x: auto; }
.dir-table, .scan-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.dir-table th, .scan-table th {
  text-align: left;
  color: var(--dim);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  position: sticky;
  top: 0;
}
.dir-table td, .scan-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.dir-table tr:hover td { background: rgba(255,255,255,0.02); cursor: pointer; }
.dir-table .pkg-name { font-family: var(--mono); color: var(--text); }
.dir-table .ver-cell { font-family: var(--mono); color: var(--dim); }
.dir-table .weekly { font-family: var(--mono); text-align: right; color: var(--text); }

.prov-mark { font-family: var(--mono); font-weight: 700; font-size: 14px; }
.prov-yes { color: var(--accent); }
.prov-no  { color: #5a6378; }
.prov-mixed { color: var(--warn); }

.pagination {
  display: flex; gap: 10px; align-items: center; justify-content: center;
  margin-top: 12px;
}

/* Scan */
#scanInput {
  width: 100%;
  min-height: 120px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12px;
  resize: vertical;
  margin-bottom: 10px;
}
.row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.scan-table .compromised { color: var(--bad); font-weight: 600; }
.scan-table .untracked-row td { color: var(--dim); }
.scan-table .compromised-row td { background: rgba(255,107,107,0.05); }

/* About */
.about p { margin: 8px 0; }

/* Modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(720px, 100%);
  max-height: 80vh;
  overflow: auto;
  padding: 24px;
  position: relative;
}
.modal-close {
  position: absolute; right: 10px; top: 10px;
  background: transparent; color: var(--dim);
  border: 0; cursor: pointer; font-size: 16px;
}
.modal-close:hover { color: var(--text); }
.modal h3 { margin: 0 0 6px; font-family: var(--mono); font-size: 18px; }
.modal .modal-meta { color: var(--dim); font-size: 12px; margin-bottom: 14px; }
.history-list { list-style: none; padding: 0; margin: 0; }
.history-list li {
  display: grid;
  grid-template-columns: 18px 1.2fr 1.6fr 1fr;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.history-list .v { font-family: var(--mono); color: var(--text); }
.history-list .t { color: var(--dim); font-family: var(--mono); }
.history-list .builder { color: var(--dim); font-family: var(--mono); }

/* Toast */
.toast {
  position: fixed;
  right: 18px; bottom: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
  z-index: 60;
}
.toast.success { border-color: rgba(90,214,168,0.4); }
.toast.error   { border-color: rgba(255,107,107,0.4); }

/* Footer */
.footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 30px 18px 50px;
  border-top: 1px solid var(--border);
  margin-top: 30px;
}

/* Mobile tweaks */
@media (max-width: 600px) {
  .panel-head { flex-direction: column; align-items: flex-start; }
  .controls { width: 100%; }
  .controls select, .controls input { flex: 1; min-width: 0; }
  .nav .btn:not(.primary) { display: none; }
}
