:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17202a;
  background: #f7f8f9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

[hidden] {
  display: none !important;
}

.topbar {
  display: flex;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid #dfe3e6;
  background: #ffffff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #17202a;
  text-decoration: none;
}

.brand span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 6px;
  color: #ffffff;
  background: #17202a;
  font-size: 13px;
  font-weight: 700;
}

.brand strong {
  font-size: 15px;
}

.connection {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #687684;
  font-size: 12px;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #87939d;
}

.connection-dot.connected {
  background: #1f8f5f;
}

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 26px 28px 40px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 30px;
}

button,
input {
  font: inherit;
}

button {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid #c9d0d6;
  border-radius: 6px;
  color: #17202a;
  background: #ffffff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  border-color: #87939d;
  background: #f3f5f6;
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid #1d6fd6;
  outline-offset: 2px;
}

.auth-view {
  display: grid;
  min-height: calc(100vh - 122px);
  grid-template-columns: minmax(240px, 1fr) minmax(320px, 520px);
  align-items: center;
  gap: 64px;
}

.auth-view > div p {
  margin-top: 5px;
  color: #687684;
  font-size: 13px;
  line-height: 20px;
}

.auth-view form {
  padding: 22px 0;
  border-top: 1px solid #dfe3e6;
  border-bottom: 1px solid #dfe3e6;
}

.auth-view label,
.history-tools label {
  display: block;
  margin-bottom: 5px;
  color: #687684;
  font-size: 11px;
  line-height: 16px;
}

.token-control,
.search-control {
  display: flex;
  gap: 8px;
}

.token-control input,
.search-control input {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 1px solid #c9d0d6;
  border-radius: 5px;
  color: #17202a;
  background: #ffffff;
  font-size: 12px;
}

.token-control button {
  min-width: 72px;
  color: #ffffff;
  border-color: #17202a;
  background: #17202a;
}

.token-control button:hover {
  background: #303b44;
}

.auth-meta {
  display: flex;
  min-height: 20px;
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
  color: #687684;
  font-size: 11px;
  line-height: 18px;
}

.error,
.app-error {
  color: #b42318;
}

.heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 18px;
}

.heading p {
  margin-top: 3px;
  color: #687684;
  font-size: 12px;
  line-height: 18px;
}

code {
  color: #687684;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
  border-top: 1px solid #dfe3e6;
  border-bottom: 1px solid #dfe3e6;
}

.overview div {
  display: grid;
  min-width: 0;
  gap: 4px;
  padding: 18px;
}

.overview div + div {
  border-left: 1px solid #e3e7ea;
}

.overview strong {
  overflow: hidden;
  font-size: 24px;
  line-height: 30px;
  text-overflow: ellipsis;
}

.overview span {
  color: #687684;
  font-size: 11px;
  line-height: 16px;
}

.insights {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr);
  margin-bottom: 18px;
  border-bottom: 1px solid #dfe3e6;
}

.insights > div {
  min-width: 0;
  padding: 0 18px 18px;
}

.insights > div:first-child {
  padding-left: 0;
  border-right: 1px solid #e3e7ea;
}

.insights h2 {
  margin-bottom: 12px;
  color: #4e5d69;
  font-size: 12px;
  line-height: 18px;
}

.trend {
  display: grid;
  min-height: 92px;
  grid-template-columns: repeat(7, minmax(34px, 1fr));
  align-items: end;
  gap: 8px;
}

.trend-day {
  display: grid;
  min-width: 0;
  grid-template-rows: 64px 16px;
  align-items: end;
  gap: 5px;
  color: #687684;
  font-size: 10px;
  text-align: center;
}

.trend-bar {
  width: min(28px, 75%);
  min-height: 2px;
  margin: 0 auto;
  border-radius: 3px 3px 0 0;
  background: #1d6fd6;
}

.top-authors {
  display: grid;
  margin: 0;
  padding-left: 24px;
  gap: 7px;
  font-size: 12px;
}

.top-authors li::marker {
  color: #87939d;
}

.top-authors span {
  color: #687684;
}

.history-tools {
  max-width: 560px;
  margin-bottom: 12px;
}

.search-control button {
  flex: 0 0 auto;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid #dfe3e6;
  border-radius: 7px;
  background: #ffffff;
}

table {
  width: 100%;
  min-width: 1150px;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid #e8ebed;
  text-align: left;
  vertical-align: top;
}

th {
  color: #687684;
  background: #fafbfb;
  font-size: 11px;
  font-weight: 600;
}

td {
  font-size: 12px;
  line-height: 18px;
}

th:nth-child(1) { width: 150px; }
th:nth-child(2) { width: 150px; }
th:nth-child(3) { width: 150px; }
th:nth-child(4) { width: auto; }
th:nth-child(5) { width: 80px; }
th:nth-child(6) { width: 70px; }
th:nth-child(7) { width: 220px; }

tbody tr:last-child td {
  border-bottom: 0;
}

.author,
.post {
  overflow: hidden;
  text-overflow: ellipsis;
}

.author span {
  display: block;
  color: #687684;
}

.post a {
  display: -webkit-box;
  overflow: hidden;
  color: #17202a;
  text-decoration: none;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.post a:hover {
  color: #1d6fd6;
  text-decoration: underline;
}

.metrics {
  color: #4e5d69;
  white-space: nowrap;
}

.empty {
  padding: 48px 20px;
  color: #687684;
  text-align: center;
}

.load-more {
  display: block;
  margin: 14px auto 0;
}

.app-error {
  margin-top: 12px;
  font-size: 12px;
}

@media (max-width: 720px) {
  .topbar {
    padding: 0 14px;
  }

  main {
    padding: 18px 14px 32px;
  }

  .auth-view {
    min-height: calc(100vh - 92px);
    grid-template-columns: 1fr;
    align-content: center;
    gap: 26px;
  }

  .overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overview div:nth-child(3) {
    border-left: 0;
  }

  .overview div:nth-child(n + 3) {
    border-top: 1px solid #e3e7ea;
  }

  .insights {
    grid-template-columns: 1fr;
  }

  .insights > div,
  .insights > div:first-child {
    padding: 0 0 16px;
    border-right: 0;
  }

  .trend {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
  }

  .token-control,
  .search-control {
    flex-wrap: wrap;
  }

  .token-control input,
  .search-control input {
    flex-basis: 100%;
  }

  .token-control button,
  .search-control button {
    flex: 1;
  }
}
