:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #d9e0ea;
  --text: #1c2430;
  --muted: #697586;
  --primary: #2364d2;
  --ok: #0f8f61;
  --warn: #b46900;
  --bad: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

h1 {
  margin: 0 0 4px;
  font-size: 18px;
}

p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.status-grid {
  display: flex;
  gap: 8px;
}

.pill {
  min-width: 92px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #f9fbff;
  font-size: 12px;
  text-align: center;
}

.pill.ok {
  color: var(--ok);
  border-color: #b7e4d2;
  background: #ecfdf5;
}

.pill.warn {
  color: var(--warn);
  border-color: #fedf89;
  background: #fffaeb;
}

.pill.bad {
  color: var(--bad);
  border-color: #fecdca;
  background: #fef3f2;
}

.layout {
  height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: 280px minmax(420px, 1fr) 420px;
  gap: 1px;
  background: var(--line);
}

.sidebar,
.dashboard,
.bet-monitor {
  min-height: 0;
  background: var(--panel);
}

.sidebar,
.bet-monitor {
  padding: 14px;
  overflow: auto;
}

.dashboard {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: auto;
}

.panel-title {
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 700;
}

.jnd28-panel {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.jnd28-current,
.jnd28-last {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcff;
}

.jnd28-last {
  margin-top: 8px;
}

.jnd28-last-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.jnd28-last-head strong {
  flex: 1;
  padding: 4px 6px;
  border-radius: 5px;
  color: #0b4a6f;
  background: #e6f6ff;
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}

.jnd28-current span,
.jnd28-last span,
.jnd28-current small,
.jnd28-history-row span {
  color: var(--muted);
  font-size: 12px;
}

.jnd28-current strong,
.jnd28-last strong {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.45;
}

.jnd28-current small {
  display: inline-flex;
  width: fit-content;
  min-width: 92px;
  justify-content: center;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--warn);
  background: #fffaeb;
  font-family: "Consolas", "SFMono-Regular", monospace;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}

.jnd28-current small.urgent,
.jnd28-current small.opening {
  color: #b42318;
  background: #fff1f0;
  box-shadow: inset 0 0 0 1px #fecaca;
}

.secondary-button {
  color: var(--primary);
  border-color: #bdd0f5;
  background: #eef4ff;
}

.jnd28-history {
  display: grid;
  gap: 7px;
  margin-top: 8px;
}

.jnd28-history.hidden {
  display: none;
}

.jnd28-history-row {
  display: grid;
  gap: 3px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.jnd28-history-row strong {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.35;
}

.target-list,
.discovered-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.target {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.discover-title {
  margin-top: 16px;
}

.discovered {
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcff;
}

.discovered strong {
  display: block;
  font-size: 13px;
}

.discovered span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.discovered button {
  height: 28px;
  margin-top: 7px;
  font-size: 12px;
}

.target.active {
  border-color: var(--primary);
  background: #eef4ff;
}

.target strong {
  display: block;
  font-size: 13px;
}

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

.target-form {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.player-panel {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}

.segmented button {
  color: var(--muted);
  border-color: var(--line);
  background: #f8fafc;
}

.segmented button.active {
  color: #fff;
  border-color: var(--primary);
  background: var(--primary);
}

.player-list {
  display: grid;
  gap: 7px;
  max-height: 280px;
  margin-top: 8px;
  overflow: auto;
}

.player-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcff;
}

.player-row strong,
.player-row span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-row strong {
  font-size: 13px;
}

.player-row strong em {
  display: inline-flex;
  margin-left: 4px;
  padding: 1px 5px;
  color: var(--primary);
  border-radius: 4px;
  background: #eef4ff;
  font-size: 11px;
  font-style: normal;
}

.player-row.protected {
  background: #fffaf0;
}

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

.player-row button {
  width: auto;
  min-width: 70px;
  height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.empty-mini {
  padding: 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcff;
  font-size: 12px;
  text-align: center;
}

input,
select,
button {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  font: inherit;
}

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

button:disabled {
  color: var(--muted);
  border-color: var(--line);
  background: #eef2f7;
  cursor: default;
}

.round-panel {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfcff;
}

.round-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.round-eyebrow {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
}

#roundPhase {
  display: block;
  font-size: 16px;
}

.round-current {
  max-width: 320px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.round-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.round-step {
  min-height: 58px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.round-step.done {
  border-color: #b7e4d2;
  background: #f0fdf7;
}

.round-step.active {
  border-color: #2364d2;
  box-shadow: inset 0 0 0 1px #2364d2;
}

.round-step strong,
.round-step span {
  display: block;
}

.round-step strong {
  font-size: 13px;
}

.round-step span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.round-step em {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-size: 12px;
  font-style: normal;
}

.round-details {
  display: grid;
  gap: 7px;
  max-height: 210px;
  margin-top: 10px;
  overflow: auto;
}

.round-detail-row {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.round-detail-row span,
.round-empty {
  color: var(--muted);
  font-size: 12px;
}

.round-detail-row pre {
  margin: 5px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  font: 12px/1.45 "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

.data-section {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.side-section {
  display: flex;
  min-height: 0;
  flex-direction: column;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.side-section:last-child {
  margin-bottom: 0;
  border-bottom: 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-head h2 {
  margin: 0;
  font-size: 15px;
}

.section-head button,
.date-filters button {
  width: auto;
  min-width: 72px;
}

.button-row {
  display: flex;
  gap: 8px;
}

.section-subhead {
  margin: 12px 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.date-filters {
  display: flex;
  gap: 8px;
}

.date-filters input {
  width: 180px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.play-summary {
  margin: 0 0 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.play-summary.hidden {
  display: none;
}

.play-summary table {
  min-width: 280px;
}

#previousPlaySummaryMain table {
  min-width: 360px;
}

.section-summary table {
  min-width: 360px;
}

.play-summary th,
.play-summary td {
  text-align: center;
}

.play-summary td {
  font-weight: 700;
}

.summary-hit {
  color: var(--ok);
  background: #ecfdf5;
}

.summary-tie {
  color: #b45309;
  background: #fffbeb;
  box-shadow: inset 0 0 0 1px #f59e0b;
}

.summary-miss {
  color: var(--bad);
  background: #fef3f2;
}

.summary-pending {
  color: var(--text);
  background: #fff;
}

.bet-table {
  max-height: calc((100vh - 150px) / 2);
}

.previous-bet-table {
  max-height: calc((100vh - 190px) / 2);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  background: #f8fafc;
  font-weight: 700;
}

.sort-button {
  width: auto;
  height: auto;
  min-width: 0;
  padding: 0;
  color: inherit;
  border: 0;
  background: transparent;
  font-weight: 700;
  text-align: left;
}

.sort-button.active {
  color: var(--primary);
}

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

.section-row td {
  color: var(--primary);
  background: #eef4ff;
  font-weight: 700;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.result {
  display: inline-flex;
  min-width: 54px;
  justify-content: center;
  padding: 3px 7px;
  border-radius: 5px;
  font-size: 12px;
}

.result-0 {
  color: var(--warn);
  background: #fffaeb;
}

.result-1 {
  color: var(--ok);
  background: #ecfdf5;
}

.result-2 {
  color: var(--bad);
  background: #fef3f2;
}

.watch-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  max-height: 96px;
  margin-bottom: 10px;
  overflow: auto;
}

.watch-manual {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) auto;
  gap: 8px;
  margin-bottom: 8px;
}

.watch-manual.hidden {
  display: none;
}

.watch-search-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 8px;
  margin-bottom: 8px;
}

.watch-search {
  min-width: 0;
}

.watch-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 240px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
}

.watch-chip input {
  width: auto;
  height: auto;
}

.watch-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.watch-remove {
  width: auto;
  height: 22px;
  min-width: 40px;
  padding: 0 6px;
  color: var(--bad);
  border-color: #fecdca;
  background: #fef3f2;
  font-size: 12px;
}

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

.mini-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
}

.mini-status.ok {
  color: var(--ok);
  background: #ecfdf5;
}

.mini-status.warn {
  color: var(--warn);
  background: #fffaeb;
}

.mini-status.bad {
  color: var(--bad);
  background: #fef3f2;
}

.reverse-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.stepper button {
  width: 28px;
  height: 24px;
  min-width: 28px;
  padding: 0;
  font-weight: 800;
}

.stepper strong {
  min-width: 24px;
  color: var(--text);
  text-align: center;
}

.reverse-players {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.reverse-players span {
  max-width: 150px;
  padding: 4px 7px;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  font-size: 12px;
}

.telegram-panel {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.telegram-latest {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.telegram-panel button {
  width: auto;
  min-width: 86px;
  padding: 0 8px;
}

.reverse-table table {
  min-width: 760px;
}

.reverse-current-row {
  background: #f8fafc;
}

.reverse-suggestion {
  min-width: 180px;
  font-weight: 700;
}

.reverse-result {
  display: inline-flex;
  justify-content: center;
  min-width: 48px;
  padding: 3px 7px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
}

.reverse-hit {
  color: var(--ok);
  background: #ecfdf5;
}

.reverse-miss {
  color: var(--bad);
  background: #fef3f2;
}

.reverse-tie {
  color: #b45309;
  background: #fffbeb;
  box-shadow: inset 0 0 0 1px #f59e0b;
}

.reverse-pending {
  color: var(--muted);
  background: #f8fafc;
}

@media (max-width: 980px) {
  .layout {
    height: auto;
    min-height: calc(100vh - 72px);
    grid-template-columns: 1fr;
  }

  .bet-monitor,
  .sidebar,
  .dashboard {
    max-height: none;
  }

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

  .date-filters {
    flex-wrap: wrap;
  }

  .watch-manual {
    grid-template-columns: 1fr;
  }
}
