:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2d3a;
  --text: #e4e4e7;
  --text-dim: #8b8d97;
  --accent: #c5382a;
  --accent-hover: #d94a3c;
  --green: #4ade80;
  --blue: #60a5fa;
  --yellow: #facc15;
}

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

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

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

/* ── Header ── */
header { text-align: center; margin-bottom: 24px; }
header h1 { font-size: 28px; font-weight: 700; }
header h1 span { color: var(--accent); }

/* ── Stats bar ── */
.stats-bar { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-bottom: 20px; }
.stat-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 18px; text-align: center; min-width: 140px;
}
.stat-item .value { font-size: 22px; font-weight: 700; color: var(--accent); }
.stat-item .label { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ── Update info ── */
.update-info {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 18px; margin-bottom: 20px;
}
.update-row { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--text-dim); }
.update-row strong { color: var(--text); }
.progress-bar { height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; background: var(--green); border-radius: 3px; transition: width .3s; }
.progress-label { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-dim); margin-top: 3px; }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.tab-btn {
  padding: 8px 18px; font-size: 14px; font-weight: 500;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-dim); cursor: pointer; transition: all .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Search ── */
.search-box { position: relative; margin-bottom: 16px; }
.search-box input {
  width: 100%; padding: 10px 14px 10px 40px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px; outline: none;
}
.search-box input:focus { border-color: var(--accent); }
.search-box input::placeholder { color: var(--text-dim); }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-dim); }

/* ── Toolbar ── */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; flex-wrap: wrap; gap: 8px; }
.results-info { font-size: 13px; color: var(--text-dim); }
.btn-small {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-dim); padding: 5px 12px;
  cursor: pointer; font-size: 12px; transition: all .15s;
}
.btn-small:hover { border-color: var(--accent); color: var(--text); }
.btn-small.btn-active { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-small.btn-active:hover { background: var(--accent-hover); }

/* ── Table ── */
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
thead th {
  background: #15171f; padding: 9px 14px; text-align: left;
  font-size: 12px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .5px; cursor: pointer; user-select: none; white-space: nowrap;
}
thead th:hover { color: var(--text); }
thead th.sorted { color: var(--accent); }
tbody tr { border-top: 1px solid var(--border); cursor: pointer; transition: background .12s; }
tbody tr:hover { background: #1f2230; }
tbody td { padding: 9px 14px; font-size: 13px; }
.mono { font-family: 'Consolas', 'Monaco', monospace; font-weight: 500; }
.count { font-weight: 700; color: var(--green); text-align: right; }
.dim { color: var(--text-dim); }

/* ── Pagination ── */
.pagination { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 14px; }
.pagination button {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); padding: 5px 12px; cursor: pointer; font-size: 13px;
}
.pagination button:hover { border-color: var(--accent); }
.pagination button:disabled { opacity: .3; cursor: default; }
.pagination span { font-size: 13px; color: var(--text-dim); }

/* ── Detail overlay ── */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  z-index: 100; display: flex; justify-content: center; align-items: flex-start;
  padding: 40px 16px; overflow-y: auto;
}
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; max-width: 850px; width: 100%; padding: 24px; position: relative;
}
.panel h2 { font-family: 'Consolas','Monaco',monospace; font-size: 18px; margin-bottom: 4px; word-break: break-all; }
.panel .sub { color: var(--text-dim); font-size: 13px; margin-bottom: 14px; }
.panel .close-btn {
  position: absolute; right: 14px; top: 14px;
  background: none; border: none; color: var(--text-dim); font-size: 22px; cursor: pointer; line-height: 1;
}
.panel .close-btn:hover { color: var(--text); }
.scroll-list { max-height: 55vh; overflow-y: auto; }
.scroll-list table { font-size: 12px; }
.scroll-list th { position: sticky; top: 0; z-index: 1; }

/* ── Links ── */
a.link { color: var(--accent); text-decoration: none; }
a.link:hover { text-decoration: underline; }

/* ── Charts ── */
.chart-section { margin-bottom: 28px; }
.chart-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 13px; }
.bar-name { width: 200px; text-align: right; font-family: 'Consolas','Monaco',monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 20px; background: var(--border); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .4s; }
.bar-val { width: 50px; font-weight: 600; color: var(--green); }

.histo-row { display: flex; align-items: flex-end; gap: 3px; height: 120px; margin-top: 8px; }
.histo-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.histo-bar { width: 100%; background: var(--blue); border-radius: 3px 3px 0 0; transition: height .3s; min-height: 2px; }
.histo-label { font-size: 10px; color: var(--text-dim); text-align: center; }
.histo-count { font-size: 10px; color: var(--text); font-weight: 600; }

/* ── Tags (categories) ── */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag {
  background: var(--border); border-radius: 4px; padding: 4px 10px;
  font-size: 12px; cursor: pointer; transition: all .15s;
}
.tag:hover { background: var(--accent); color: #fff; }
.tag .tag-count { color: var(--text-dim); margin-left: 4px; }

/* ── Frequently together ── */
.corr-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.corr-item {
  background: var(--border); border-radius: 4px; padding: 3px 8px;
  font-size: 12px; font-family: 'Consolas','Monaco',monospace; cursor: pointer;
}
.corr-item:hover { background: var(--accent); color: #fff; }
.corr-pct { color: var(--green); margin-left: 4px; font-family: -apple-system, sans-serif; }

/* ── Common settings panel ── */
.btn-icon { padding: 5px 7px; display: flex; align-items: center; }
.cs-add { display: flex; gap: 6px; margin-bottom: 14px; }
.cs-add input {
  width: 100%; padding: 7px 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 13px; outline: none;
  font-family: 'Consolas','Monaco',monospace;
}
.cs-add input:focus { border-color: var(--accent); }
.cs-suggestions {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 10;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  margin-top: 2px; overflow: hidden;
}
.cs-suggestion {
  padding: 6px 10px; font-size: 12px; cursor: pointer;
  font-family: 'Consolas','Monaco',monospace;
}
.cs-suggestion:hover { background: var(--accent); color: #fff; }
.cs-section { margin-bottom: 14px; }
.cs-title { font-size: 12px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.cs-row {
  display: flex; align-items: center; gap: 10px; padding: 5px 0;
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.cs-row .mono { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-row .dim { font-size: 11px; white-space: nowrap; }
.cs-row .btn-small { padding: 2px 8px; font-size: 11px; flex-shrink: 0; }

/* ── Loading / Error ── */
.loading { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.spinner {
  width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error { text-align: center; padding: 40px; color: #f87171; }
