:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --line: #d7dee8;
  --text: #172033;
  --muted: #667085;
  --accent: #0b6bcb;
  --accent-strong: #084f97;
  --ok: #0f8a5f;
  --warn: #a75d00;
  --bad: #b42318;
  --mark: #eef6ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  overflow-y: auto;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 0 12px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary {
  background: #fff;
  color: var(--accent);
  border-color: #b8cce2;
}

button.secondary:hover {
  background: var(--mark);
}

button.danger {
  background: #fff;
  color: var(--bad);
  border-color: #e2b8b8;
}

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

.sort-btn {
  height: auto;
  border: 0;
  background: transparent;
  color: #344054;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
}

.sort-btn:hover {
  background: transparent;
  color: var(--accent);
}

.sort-btn.active {
  color: var(--accent);
}

input,
select,
textarea {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

input,
select {
  height: 34px;
  padding: 0 10px;
}

textarea {
  min-height: 74px;
  max-height: 160px;
  resize: vertical;
  padding: 8px 10px;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
  display: grid;
  gap: 12px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: grid;
  gap: 12px;
  padding: 14px 18px;
}

.title-row,
.button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

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

.repo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid #b8cce2;
  border-radius: 6px;
  background: #fff;
  color: var(--accent);
  padding: 0 12px;
  text-decoration: none;
  font-weight: 650;
  white-space: nowrap;
}

.repo-link:hover {
  background: var(--mark);
}

h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0;
}

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

.controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 120px minmax(220px, 1fr) 92px 92px 92px;
  gap: 8px;
  align-items: center;
}

.guide {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--line);
}

.guide div {
  background: #fff;
  padding: 10px 12px;
  display: grid;
  gap: 3px;
}

.guide b {
  font-size: 13px;
}

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

.action-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.search-refresh,
.filters {
  display: grid;
  gap: 8px;
  align-items: end;
}

.search-refresh {
  grid-template-columns: minmax(260px, 1fr) auto minmax(180px, 0.45fr);
}

.search-refresh label input {
  width: 100%;
}

.filters {
  grid-template-columns: 150px 150px 150px auto;
}

.pending-panel {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  display: grid;
  grid-template-columns: minmax(120px, 0.24fr) minmax(260px, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.pending-panel b {
  display: block;
  font-size: 13px;
}

.pending-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 30px;
  align-items: center;
}

.pending-chip {
  height: 28px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  border-color: #b8cce2;
  background: #fff;
  color: var(--accent);
}

.pending-chip:hover {
  background: var(--mark);
}

.pending-chip.conflict {
  border-color: #e2b8b8;
  color: var(--bad);
  background: #fff4f2;
}

.primary-action {
  font-weight: 700;
}

.settings {
  display: grid;
  grid-template-columns: minmax(150px, 0.6fr) minmax(190px, 0.7fr) minmax(260px, 1fr) 110px 150px;
  gap: 8px;
  align-items: end;
}

.credential-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.credential-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.credential-panel textarea {
  min-height: 54px;
  max-height: 110px;
}

.delay-control {
  display: grid;
  grid-template-columns: minmax(70px, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.delay-presets {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.delay-presets button {
  height: 30px;
  padding: 0 10px;
}

.bookmark-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.bookmarklet {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 6px;
  border: 1px solid #b8cce2;
  background: #fff;
  color: var(--accent);
  padding: 0 10px;
  text-decoration: none;
  font-weight: 650;
}

.bookmarklet.big {
  min-height: 54px;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  padding: 0 18px;
  font-size: 15px;
}

.bookmarklet.big:hover {
  background: var(--accent-strong);
}

label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: var(--text);
}

.check input {
  width: 16px;
  height: 16px;
}

.progress {
  height: 8px;
  background: #e9eef5;
  overflow: hidden;
}

.bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.18s ease;
}

.summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}

.metric {
  background: #fff;
  padding: 12px 18px;
}

.metric b {
  display: block;
  font-size: 22px;
  line-height: 1.1;
}

.notice {
  margin: 14px 18px 0;
  padding: 10px 12px;
  border: 1px solid #f3cf8d;
  background: #fff8eb;
  color: #714000;
  border-radius: 6px;
}

.bad-notice {
  border-color: #f0b8b3;
  background: #fff4f2;
  color: #8a1f17;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.42);
}

.modal {
  width: min(760px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
  padding: 16px;
  display: grid;
  gap: 14px;
}

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

.modal h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-color: var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

.icon-btn:hover {
  background: #f3f6fa;
  color: var(--text);
}

.modal-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 8px;
}

.modal-steps div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-steps b {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
}

.modal-steps span {
  font-size: 12px;
  color: #344054;
}

.modal-grid {
  display: grid;
  grid-template-columns: minmax(160px, 0.4fr) minmax(280px, 1fr);
  gap: 12px;
  align-items: end;
}

.bookmark-drop {
  border: 1px dashed #9eb9d7;
  border-radius: 8px;
  background: #f7fbff;
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(170px, 0.36fr) minmax(260px, 1fr);
  gap: 14px;
  align-items: center;
}

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

.modal-target,
.modal-warning {
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
}

.modal-target {
  border: 1px solid #c9d8e8;
  background: #f7fbff;
  color: #344054;
}

.modal-warning {
  border: 1px solid #f3cf8d;
  background: #fff8eb;
  color: #714000;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.modal-actions {
  position: sticky;
  bottom: -16px;
  background: #fff;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.content {
  padding: 14px 18px 24px;
  display: grid;
  gap: 12px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  background: #fff;
}

table {
  width: 100%;
  min-width: 1260px;
  border-collapse: collapse;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #eef3f8;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}

tbody tr:hover {
  background: #f9fbfd;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.course {
  min-width: 260px;
}

.course-title {
  font-weight: 650;
}

.course-title-button {
  height: auto;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  display: inline-flex;
  align-items: flex-start;
  gap: 7px;
  text-align: left;
  white-space: normal;
  font-weight: 650;
}

.course-title-button:hover {
  background: transparent;
  color: var(--accent);
}

.comment-badge,
.comment-count {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border-radius: 999px;
  background: #eef6ff;
  color: var(--accent);
  padding: 0 7px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.expanded-course {
  background: #fbfdff;
}

.comment-row td {
  padding: 0;
  background: #fbfdff;
}

.comment-panel {
  border-top: 1px solid #e7edf4;
  padding: 12px;
  display: grid;
  gap: 10px;
}

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

.comment-list {
  display: grid;
  gap: 8px;
}

.comment-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px 10px;
}

.comment-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.comment-meta b {
  color: var(--text);
}

.comment-item p {
  margin: 6px 0 0;
  white-space: pre-wrap;
}

.empty-comment {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  color: var(--muted);
}

.comment-form {
  display: grid;
  grid-template-columns: minmax(120px, 0.22fr) minmax(260px, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.comment-form textarea {
  min-height: 58px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}

.chip {
  display: inline-flex;
  align-items: center;
  height: 20px;
  border-radius: 999px;
  background: #edf2f7;
  color: #475467;
  font-size: 12px;
  padding: 0 7px;
}

.ok {
  color: var(--ok);
  font-weight: 700;
}

.warn {
  color: var(--warn);
  font-weight: 700;
}

.bad {
  color: var(--bad);
  font-weight: 700;
}

.select-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
  background: #edf2f7;
  color: #475467;
}

.select-status.clear {
  background: #ecfdf3;
  color: var(--ok);
}

.select-status.selected {
  background: #eef6ff;
  color: var(--accent);
}

.select-status.conflict {
  background: #fff4f2;
  color: var(--bad);
}

.select-status.full {
  background: #f2f4f7;
  color: var(--muted);
}

.select-status.unknown {
  background: #fff8eb;
  color: var(--warn);
}

.row-actions {
  display: grid;
  gap: 6px;
  min-width: 108px;
}

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

.empty {
  border: 1px solid var(--line);
  background: #fff;
  padding: 36px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 980px) {
  .controls,
  .settings,
  .guide,
  .filters,
  .search-refresh,
  .comment-form,
  .pending-panel,
  .modal-grid,
  .bookmark-drop {
    grid-template-columns: 1fr 1fr;
  }

  .summary {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

@media (max-width: 620px) {
  .controls,
  .settings,
  .guide,
  .filters,
  .search-refresh,
  .comment-form,
  .pending-panel,
  .modal-steps,
  .modal-grid,
  .bookmark-drop {
    grid-template-columns: 1fr;
  }

  .button-row button,
  .credential-actions button,
  .controls button,
  .header-actions,
  .header-actions button,
  .repo-link,
  .comment-form button,
  .search-refresh button,
  .pending-panel button,
  .modal-actions button {
    width: 100%;
  }
}
