:root {
  --bg: #f3efe6;
  --panel: #fffdf8;
  --line: #d5ccbc;
  --text: #251e15;
  --muted: #77634c;
  --accent: #b2522d;
  --accent-soft: #f4d7cb;
  --ok: #2f6f4e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 10% 0%, #fff7ed 0%, var(--bg) 50%, #ece5d8 100%);
  color: var(--text);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, #fff8ef 0%, #f7f1e5 100%);
}

.topbar h1 {
  margin: 0;
  font-size: 1.5rem;
}

.topbar p {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

.filters {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.filters select,
.filters button {
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.45rem 0.7rem;
  background: #fff;
  color: var(--text);
}

.filters button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: pointer;
}

.layout {
  padding: 1rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 1rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
}

.panel h2 {
  margin-top: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.7rem;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  padding: 0.7rem;
  background: #fff;
}

.stat-card .label {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
}

.stat-card .value {
  font-size: 1.2rem;
  font-weight: 700;
}

.chart-wrap {
  margin-top: 1rem;
}

#avg-chart {
  width: 100%;
  height: 220px;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: #fff;
}

.histogram {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 0.5rem;
}

.bin {
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.45rem;
  background: #fff;
}

.bin .bar {
  height: 10px;
  background: linear-gradient(90deg, #e6b39f 0%, var(--accent) 100%);
  border-radius: 10px;
  margin: 0.35rem 0;
}

.bin .meta {
  font-size: 0.75rem;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.55rem;
  text-align: left;
  vertical-align: top;
}

th[data-sort] {
  cursor: pointer;
}

th[data-sort]:hover {
  color: var(--accent);
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.changes-feed {
  display: grid;
  gap: 0.6rem;
}

.change-item {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 0.5rem;
  padding: 0.6rem;
  background: #fff;
}

.change-item .meta {
  font-size: 0.84rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.change-item .title {
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.change-item .diff {
  font-size: 0.9rem;
}

.change-empty {
  color: var(--muted);
  padding: 0.4rem 0;
}

a {
  color: var(--accent);
}

.ok {
  color: var(--ok);
}

@media (max-width: 900px) {
  .topbar {
    flex-direction: column;
    align-items: start;
  }
}
