:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d9dee7;
  --line-strong: #bdc6d4;
  --text: #172033;
  --muted: #657187;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --warn: #b45309;
  --danger: #b42318;
  --ok: #16794c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
input,
select,
.tab {
  font: inherit;
}

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  height: 36px;
  padding: 0 16px;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: var(--accent-dark);
}

button:disabled {
  border-color: var(--line);
  background: #e4e8ee;
  color: #8b95a6;
  cursor: not-allowed;
}

input[type="search"] {
  height: 40px;
  min-width: 0;
  border: 1px solid var(--line-strong);
  background: white;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input[type="date"],
select {
  height: 40px;
  border: 1px solid var(--line-strong);
  background: white;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input[type="date"]:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.shell {
  width: min(1700px, calc(100vw - 32px));
  margin: 28px auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-bottom: 18px;
}

h1 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 700;
}

p {
  margin: 0;
  color: var(--muted);
}

.tabs {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  background: var(--panel);
}

.tab {
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  min-width: 92px;
  padding: 0 14px;
  text-decoration: none;
}

.tab:last-child {
  border-right: 0;
}

.tab.active {
  background: var(--accent);
  color: white;
}

.view {
  display: none;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 18px;
}

.view.active {
  display: block;
}

.searchbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 14px;
}

.searchbar input {
  height: 56px;
  font-size: 20px;
}

.searchbar button {
  height: 56px;
  min-width: 96px;
}

.filterbar {
  display: grid;
  grid-template-columns: minmax(220px, 360px) 128px 128px 112px max-content max-content;
  gap: 10px;
  margin-bottom: 14px;
  align-items: center;
  justify-content: start;
}

.filterbar select {
  width: 100%;
}

.filterbar button {
  justify-self: start;
}

.ranking-filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.ranking-view {
  padding-top: 0;
}

.ranking-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  padding: 18px 0;
}

.ranking-head h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.ranking-tabs {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  background: #f8fafc;
}

.ranking-tab {
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  min-width: 112px;
}

.ranking-tab:last-child {
  border-right: 0;
}

.ranking-tab.active {
  background: var(--accent);
  color: white;
}

.ranking-filterbar label {
  display: grid;
  min-width: 160px;
  gap: 6px;
  color: var(--muted);
}

.ranking-filterbar [hidden] {
  display: none;
}

.ranking-filter-actions {
  display: flex;
  gap: 10px;
  align-items: end;
}

.ranking-filter-actions button {
  flex: 0 0 auto;
}

.rankings-table {
  min-width: 1280px;
  table-layout: auto;
}

.name-cell {
  min-width: 180px;
  font-weight: 700;
}

.tags-cell {
  width: 300px;
  min-width: 300px;
  max-width: 300px;
}

.tag-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
  max-width: 300px;
}

.ranking-tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 24px;
  border: 1px solid #f3f3f3;
  border-radius: 9px;
  background: #deecf9;
  color: var(--text);
  padding: 2px 8px;
  line-height: 1.35;
  word-break: break-word;
}

.ranking-summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: #f8fafc;
  padding: 0 12px;
}

.ranking-summary strong {
  color: var(--accent);
  font-size: 20px;
  margin-right: 4px;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line-strong);
  background: white;
  color: var(--muted);
  font-weight: 700;
}

.rank-badge.gold {
  border-color: #eab308;
  background: #fef9c3;
  color: #854d0e;
}

.rank-badge.silver {
  border-color: #94a3b8;
  background: #f1f5f9;
  color: #475569;
}

.rank-badge.bronze {
  border-color: #d97706;
  background: #ffedd5;
  color: #9a3412;
}

.toolbar {
  display: flex;
  justify-content: flex-start;
  gap: 16px;
  align-items: center;
  min-height: 42px;
}

.toolbar #searchSummary {
  display: none;
}

.muted {
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1040px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #eef2f6;
  font-weight: 700;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: 0;
}

.select-col {
  width: 48px;
  text-align: center;
}

.url {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.progress {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 8px;
  align-items: center;
  min-width: 140px;
}

.bar {
  height: 8px;
  background: #e1e7ef;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.badge {
  display: inline-block;
  min-width: 64px;
  border: 1px solid var(--line-strong);
  padding: 4px 8px;
  text-align: center;
  color: var(--muted);
  background: #f8fafc;
}

.badge.ok {
  border-color: rgba(22, 121, 76, 0.35);
  color: var(--ok);
  background: rgba(22, 121, 76, 0.08);
}

.badge.warn {
  border-color: rgba(180, 83, 9, 0.35);
  color: var(--warn);
  background: rgba(180, 83, 9, 0.08);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.actions a,
.actions button,
.actions .disabled {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  border: 1px solid var(--line-strong);
  background: white;
  color: var(--text);
  padding: 0 10px;
  text-decoration: none;
  line-height: 1;
}

.actions a[href] {
  border-color: var(--accent);
  color: var(--accent);
}

.actions .disabled {
  color: #8b95a6;
  background: #f0f2f5;
  cursor: not-allowed;
}

.duration-cell {
  white-space: nowrap;
}

.priority-cell {
  min-width: 76px;
  white-space: nowrap;
}

.priority-button {
  border-color: #3cbd81;
  background: #3cbd81;
  color: white;
  height: 32px;
  padding: 0 12px;
}

.priority-button:hover:not(:disabled) {
  background: #2f9f6c;
  border-color: #2f9f6c;
}

.priority-badge {
  display: inline-block;
  min-width: 48px;
  border: 1px solid var(--line-strong);
  padding: 4px 8px;
  text-align: center;
  white-space: nowrap;
}

.priority-badge.normal {
  color: var(--muted);
  background: #f8fafc;
}

.priority-badge.high {
  border-color: #3cbd81;
  color: #0f6845;
  background: rgba(60, 189, 129, 0.16);
  box-shadow: 0 0 10px rgba(60, 189, 129, 0.28);
  font-weight: 700;
}

.pager {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  min-height: 36px;
}

.pager-summary {
  margin-right: 8px;
}

.pager button {
  min-width: 72px;
}

.pager-jump,
.pager-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.pager-jump input {
  width: 64px;
  height: 34px;
  padding: 6px 8px;
}

.pager-size select {
  height: 34px;
  min-width: 72px;
  padding: 6px 8px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  background: #172033;
  color: white;
  padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(20, 28, 45, 0.22);
}

@media (max-width: 720px) {
  .shell {
    width: calc(100vw - 20px);
    margin: 14px auto;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .ranking-head {
    align-items: stretch;
    flex-direction: column;
  }

  .ranking-tabs,
  .ranking-tab {
    width: 100%;
  }

  .tabs,
  .tab {
    width: 100%;
  }

  .searchbar,
  .filterbar {
    grid-template-columns: 1fr;
  }

  .ranking-filterbar {
    align-items: stretch;
    flex-direction: column;
  }

  .ranking-filter-actions {
    align-items: stretch;
  }

  .ranking-filter-actions button {
    flex: 1 1 0;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}

.retry-button {
  border-color: var(--warn);
  background: var(--warn);
  color: white;
}

.retry-button:hover:not(:disabled) {
  background: #92400e;
  border-color: #92400e;
}
