:root {
  color-scheme: light;
  --bg: #f4f2e7;
  --paper: #fffef8;
  --line: #d5c99c;
  --header: #edf67f;
  --text: #252525;
  --muted: #7d7a67;
  --red: #ef4a50;
  --green: #28a06a;
  --shadow: rgba(87, 73, 28, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 10px 16px;
  background: linear-gradient(#d8c99a, #bca86c);
  border-bottom: 3px solid #7f6b33;
  box-shadow: 0 2px 8px var(--shadow);
}

.brand {
  font-size: 20px;
  font-weight: 800;
}

.status {
  color: #473f25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.refresh {
  min-width: 64px;
  border: 1px solid #806b2d;
  border-radius: 4px;
  background: #fff9cc;
  color: #423714;
  font-weight: 700;
  line-height: 30px;
  cursor: pointer;
}

.refresh:disabled {
  cursor: wait;
  opacity: 0.65;
}

.panel {
  padding: 12px 0 24px;
}

.site-footer {
  padding: 0 16px 18px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.market-section {
  margin: 0 0 18px;
  border-top: 2px solid #8d7b43;
  border-bottom: 2px solid #8d7b43;
  background: rgba(255, 255, 255, 0.38);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 14px;
  background: linear-gradient(90deg, #fff1b8, #f3df8c);
  border-bottom: 2px solid #8d7b43;
}

.section-title h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1;
}

.section-title span {
  color: var(--muted);
  font-size: 13px;
}

.boards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  align-items: start;
  gap: 10px;
  padding: 10px;
}

.board {
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 1px 3px var(--shadow);
  min-width: 0;
}

.board-head {
  display: grid;
  grid-template-columns: 1fr 64px;
  align-items: center;
  min-height: 31px;
  background: var(--header);
  border-bottom: 1px solid var(--line);
}

.board-head h2 {
  margin: 0;
  padding: 0 6px;
  font-size: 18px;
  line-height: 30px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-head strong {
  display: block;
  height: 26px;
  margin-right: 4px;
  color: #fff;
  background: var(--red);
  font-size: 15px;
  line-height: 26px;
  text-align: center;
}

.board-head strong.down {
  background: var(--green);
}

.stock-list {
  margin: 0;
  padding: 4px;
  list-style: none;
}

.stock-row {
  display: grid;
  grid-template-columns: 34px minmax(68px, 1fr) 18px 32px 50px;
  gap: 4px;
  align-items: center;
  height: 24px;
  min-width: 0;
  font-size: 14px;
  line-height: 1;
}

.rank {
  color: #575757;
  font-weight: 700;
  text-align: right;
}

.name {
  min-width: 0;
  overflow: hidden;
  color: #df2b2f;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-change {
  color: #555;
  font-size: 12px;
  text-align: right;
}

.market-badge {
  display: block;
  width: 16px;
  height: 16px;
  border: 1px solid #d6b06b;
  color: #8a5715;
  background: #fff7c8;
  font-size: 11px;
  font-weight: 800;
  line-height: 14px;
  text-align: center;
}

.market-badge:empty {
  border-color: transparent;
  background: transparent;
}

.pct {
  position: relative;
  display: block;
  height: 21px;
  overflow: hidden;
  border: 1px solid #e2b3aa;
  background: #fff;
  text-align: center;
}

.pct i {
  position: absolute;
  inset: 0 auto 0 0;
  display: block;
  background: var(--red);
}

.stock-row.down .pct i {
  background: var(--green);
}

.pct b {
  position: relative;
  z-index: 1;
  color: #333;
  font-size: 13px;
  line-height: 19px;
}

@media (max-width: 680px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .brand {
    font-size: 18px;
  }

  .status {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .boards {
    grid-template-columns: repeat(auto-fill, minmax(174px, 1fr));
    gap: 8px;
    padding: 8px;
  }

  .stock-row {
    grid-template-columns: 30px minmax(54px, 1fr) 17px 28px 45px;
    font-size: 13px;
  }
}
