:root {
  color-scheme: dark;
  --bg: transparent;
  --panel: #131a2e;
  --line: #2a3450;
  --text: #e8ecf6;
  --muted: #98a2bd;
  --accent: #22d3ee;
  --accent-2: #a855f7;
  --bad-bg: #3a1620;
  --bad-text: #fca5a5;
  --good-bg: #12301f;
  --good-text: #86efac;
}

/* Dark surfaces to match the site theme */
input {
  background: #0d1426 !important;
}
input:focus {
  outline-color: rgba(34, 211, 238, 0.25);
}
.author-item,
th {
  background: #0f1729 !important;
}
.bar {
  background: #1f2942;
}

/* Quick-pick chips for my packages */
.quick-picks {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.quick-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.chip {
  height: auto;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 650;
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.12);
  color: #67e8f9;
  border: 1px solid rgba(34, 211, 238, 0.35);
  cursor: pointer;
}
.chip:hover {
  background: rgba(34, 211, 238, 0.22);
}

/* Collapsible author explorer */
.author-explorer {
  margin-top: 12px;
}
.author-explorer > summary {
  cursor: pointer;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent);
  font-weight: 650;
  font-size: 13px;
  list-style: none;
}
.author-explorer > summary::-webkit-details-marker { display: none; }
.author-explorer[open] > summary {
  border-radius: 8px 8px 0 0;
  border-bottom: 0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 840px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.app-shell {
  width: min(1180px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.toolbar,
.summary,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.toolbar {
  padding: 18px;
}

.brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 720;
}

h2 {
  font-size: 15px;
  font-weight: 700;
}

.brand p,
label,
.summary span,
.status {
  color: var(--muted);
}

.controls {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, minmax(130px, 0.7fr)) auto auto;
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 650;
}

input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text);
  font: inherit;
  background: #fff;
}

input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(23, 107, 135, 0.16);
}

.check {
  display: flex;
  align-items: center;
  height: 38px;
  gap: 8px;
  white-space: nowrap;
}

.check input {
  width: 16px;
  height: 16px;
}

button {
  height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 720;
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.status {
  min-height: 34px;
  margin: 12px 0;
  padding: 8px 2px;
  font-size: 13px;
}

.status.error,
.status.ok {
  border-radius: 6px;
  padding: 10px 12px;
}

.status.error {
  background: var(--bad-bg);
  color: var(--bad-text);
}

.status.ok {
  background: var(--good-bg);
  color: var(--good-text);
}

.author-panel {
  margin-bottom: 12px;
}

.author-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 120px auto;
  gap: 12px;
  align-items: end;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.author-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1px;
  background: var(--line);
}

.author-layout > div {
  min-height: 260px;
  background: var(--panel);
  padding: 14px 16px;
}

h3 {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
}

.author-list {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
}

.author-item {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 10px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
}

.author-item:hover,
.author-item.active {
  border-color: var(--accent);
  outline: 3px solid rgba(23, 107, 135, 0.12);
}

.author-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.author-item span {
  color: var(--muted);
  font-size: 12px;
}

.author-table-wrap {
  max-height: 320px;
}

.muted-cell {
  max-width: 360px;
  color: var(--muted);
}

.small {
  color: var(--muted);
  font-size: 11px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  overflow: hidden;
}

.summary div {
  display: grid;
  gap: 4px;
  padding: 16px;
  border-right: 1px solid var(--line);
}

.summary div:last-child {
  border-right: 0;
}

.summary span {
  font-size: 12px;
  font-weight: 650;
}

.summary strong {
  font-size: 24px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.panel {
  min-height: 260px;
  overflow: hidden;
}

.panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.chart-panel {
  margin-top: 12px;
  min-height: 340px;
}

.chart-wrap {
  position: relative;
  height: 290px;
  padding: 14px 16px 18px;
}

#download-chart {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-axis {
  stroke: #c9d5da;
  stroke-width: 1;
}

.chart-grid {
  stroke: #edf2f4;
  stroke-width: 1;
}

.chart-label {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.chart-area {
  fill: rgba(23, 107, 135, 0.12);
}

.chart-point {
  fill: var(--accent-2);
  stroke: #fff;
  stroke-width: 2;
}

.empty {
  color: var(--muted);
  font-size: 13px;
}

#chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.bar-list {
  display: grid;
  gap: 10px;
  padding: 14px 16px 18px;
}

.bar-row {
  display: grid;
  gap: 5px;
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}

.bar-meta span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 680;
}

.bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7eef1;
}

.bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.table-panel {
  margin-top: 12px;
}

.table-wrap {
  max-height: 280px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  background: #f9fbfc;
  color: var(--muted);
  font-size: 12px;
}

td:last-child,
th:last-child {
  text-align: right;
}

@media (max-width: 980px) {
  body {
    min-width: 0;
  }

  .app-shell {
    width: calc(100vw - 24px);
    padding-top: 12px;
  }

  .brand,
  .controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .summary,
  .grid,
  .author-layout,
  .author-controls {
    grid-template-columns: 1fr;
  }

  .summary div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}
