:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #697586;
  --line: #d8dde6;
  --active: #1f9d55;
  --cooldown: #d79b08;
  --invalid: #d64545;
  --accent: #2463eb;
  --accent-dark: #1d4fc0;
  --shadow: 0 10px 30px rgba(20, 30, 50, 0.08);
}

* {
  box-sizing: border-box;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 700;
}

h2 {
  font-size: 18px;
}

h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

.topbar p,
.hint,
.subtle {
  color: var(--muted);
}

.topbar-actions,
.filters,
.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(520px, 1.55fr);
  gap: 18px;
  padding: 18px;
}

.summary {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
}

.metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric strong {
  font-size: 30px;
  line-height: 1;
}

.metric.active strong {
  color: var(--active);
}

.metric.cooldown strong {
  color: var(--cooldown);
}

.metric.invalid strong {
  color: var(--invalid);
}

.metric-label {
  color: var(--muted);
  font-weight: 600;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

td {
  max-width: 360px;
}

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

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  font-weight: 700;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}

.status-active .dot {
  background: var(--active);
}

.status-cooldown .dot {
  background: var(--cooldown);
}

.status-invalid .dot,
.status-failed .dot {
  background: var(--invalid);
}

.status-running .dot,
.status-submitting .dot,
.status-pending .dot {
  background: var(--accent);
}

.status-succeeded .dot {
  background: var(--active);
}

.mono {
  color: #2d3748;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  word-break: break-all;
}

.truncate {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.button,
select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}

.button:hover {
  border-color: #aeb8c8;
}

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

.button.primary:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

.button.secondary {
  background: #f9fafb;
}

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

.button.danger {
  border-color: #f0c6c6;
  color: var(--invalid);
}

.button.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

select,
input {
  min-height: 34px;
  padding: 0 10px;
  background: #fff;
}

.key-input {
  width: 210px;
}

textarea {
  width: 100%;
  padding: 10px;
  background: #fff;
  resize: vertical;
}

.modal {
  width: min(860px, calc(100vw - 36px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(20, 30, 50, 0.24);
}

.modal.wide {
  width: min(1040px, calc(100vw - 36px));
}

.modal::backdrop {
  background: rgba(20, 30, 50, 0.42);
}

.modal-body {
  padding: 18px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.field span {
  color: var(--muted);
  font-weight: 700;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.split section,
.auth-card,
.help-box {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.auth-card,
.help-box {
  background: #fbfcfe;
}

.import-help {
  margin-bottom: 12px;
}

.help-box {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.mono-inline {
  color: #2d3748;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
}

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

.path-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.compact-table {
  max-height: 380px;
}

.auth-session {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.message {
  min-height: 22px;
  margin-top: 14px;
  color: var(--muted);
}

.task-detail {
  display: grid;
  gap: 12px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
}

.detail-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

pre {
  max-height: 340px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #111827;
  color: #f9fafb;
  white-space: pre-wrap;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #17202a;
  color: #fff;
  box-shadow: var(--shadow);
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

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

  .split,
  .detail-grid,
  .path-picker {
    grid-template-columns: 1fr;
  }

  .key-input {
    width: 100%;
  }
}
