/* ==========================================================================
   cf-auto-update 管理控制台
   零依赖、零构建。设计令牌集中在 :root，方便整体换肤。
   ========================================================================== */

:root {
  --bg: #0a0e13;
  --bg-glow: rgba(246, 130, 31, 0.08);
  --surface: #11161d;
  --surface-2: #161d26;
  --surface-3: #1c2531;
  --border: #232c38;
  --border-strong: #313d4d;
  --text: #e6edf7;
  --text-dim: #a9b6c7;
  --muted: #7d8b9e;
  --accent: #f6821f;
  --accent-soft: rgba(246, 130, 31, 0.14);
  --green: #3fb950;
  --green-soft: rgba(63, 185, 80, 0.14);
  --red: #f85149;
  --red-soft: rgba(248, 81, 73, 0.14);
  --blue: #58a6ff;
  --blue-soft: rgba(88, 166, 255, 0.14);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

/* 关键：类选择器里的 display 会覆盖 hidden 属性的 UA 样式，必须显式兜底 */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--bg-glow), transparent 70%),
    var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 1.5rem;
}
h2 {
  font-size: 1.2rem;
}
h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

p {
  margin: 0;
}

code,
.mono {
  font-family: var(--mono);
  font-size: 0.85em;
}

a {
  color: var(--blue);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.muted {
  color: var(--muted);
  font-size: 0.875rem;
}

.hint {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

/* ------------------------------------------------------------------ 品牌 */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: #10151b;
  flex: none;
}

.brand-mark svg {
  width: 17px;
  height: 17px;
}

.brand-text {
  font-size: 0.95rem;
}

/* ------------------------------------------------------------------ 登录 */

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

.login-card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 1.35rem;
  margin-top: 4px;
}

.login-card .muted {
  margin-top: -10px;
}

.login-foot {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.6;
}

.advanced {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface-2);
}

.advanced summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-dim);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.advanced summary::-webkit-details-marker {
  display: none;
}

.advanced[open] summary {
  margin-bottom: 10px;
}

.advanced .hint {
  margin-top: 8px;
}

/* ------------------------------------------------------------------ 表单 */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-dim);
}

input,
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input::placeholder,
textarea::placeholder {
  color: #55637a;
}

textarea {
  min-height: 96px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.55;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  padding: 0;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--text-dim);
  cursor: pointer;
}

/* ------------------------------------------------------------------ 按钮 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface-3);
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.06s, opacity 0.15s;
  white-space: nowrap;
}

.btn:hover {
  background: #232d3b;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  color: #10151b;
  font-weight: 600;
}

.btn.primary:hover {
  background: #ff9233;
}

.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
}

.btn.ghost:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--surface-2);
}

.btn.danger {
  background: transparent;
  border-color: rgba(248, 81, 73, 0.4);
  color: var(--red);
}

.btn.danger:hover {
  background: var(--red-soft);
}

.btn.small {
  padding: 5px 10px;
  font-size: 0.8rem;
}

.btn.block {
  width: 100%;
}

.btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

/* ------------------------------------------------------------------ 顶栏 */

.app {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 24px;
  background: rgba(10, 14, 19, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.tabs {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}

.tab {
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.repo {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ 布局 */

.main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.panel-head h2 {
  margin-bottom: 4px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 14px;
}

/* ------------------------------------------------------------------ 卡片 */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.project {
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.15s, transform 0.15s;
}

.project:hover {
  border-color: var(--border-strong);
}

.project.disabled {
  opacity: 0.6;
}

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

.project-name {
  font-weight: 620;
  font-size: 1rem;
  letter-spacing: -0.01em;
  word-break: break-all;
}

.badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
  background: var(--surface-3);
  color: var(--text-dim);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.badge.worker {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(246, 130, 31, 0.3);
}

.badge.pages {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: rgba(88, 166, 255, 0.3);
}

.badge.on {
  color: var(--green);
  background: var(--green-soft);
  border-color: rgba(63, 185, 80, 0.3);
}

.badge.off {
  color: var(--muted);
}

.badge.upstream {
  color: var(--text-dim);
}

.project-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--muted);
}

.project-meta .row {
  display: flex;
  gap: 8px;
  min-width: 0;
}

.project-meta .row span:first-child {
  flex: none;
  width: 62px;
  color: #62708a;
}

.project-meta .row code {
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-foot {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* ------------------------------------------------------------------ 账户 */

.account-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-key {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--accent);
}

.account-id {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ 运行记录 */

.runs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.run {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
}

.run:hover {
  border-color: var(--border-strong);
}

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

.dot.success {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.dot.failure,
.dot.cancelled {
  background: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}

.dot.in_progress,
.dot.queued {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.run-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-meta {
  color: var(--muted);
  font-size: 0.78rem;
  font-family: var(--mono);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ 设置 */

.settings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}

.settings .card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.84rem;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border);
}

.kv:last-of-type {
  border-bottom: none;
}

.kv span {
  color: var(--muted);
}

.kv code {
  color: var(--text-dim);
  word-break: break-all;
  text-align: right;
}

.cred {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  padding: 5px 0;
}

.cred .mark {
  width: 18px;
  text-align: center;
}

.cred.ok .mark {
  color: var(--green);
}

.cred.warn .mark {
  color: var(--accent);
}

.cred.bad .mark {
  color: var(--red);
}

.links {
  margin: 0;
  padding-left: 18px;
  font-size: 0.86rem;
  line-height: 2;
}

/* ------------------------------------------------------------------ 空状态 / 提示 */

.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.alert {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  line-height: 1.5;
}

.alert.error {
  background: var(--red-soft);
  color: #ff9d96;
  border: 1px solid rgba(248, 81, 73, 0.3);
}

.alert.info {
  background: var(--blue-soft);
  color: #9ecbff;
  border: 1px solid rgba(88, 166, 255, 0.3);
}

.alert.warn {
  background: var(--accent-soft);
  color: #ffc48a;
  border: 1px solid rgba(246, 130, 31, 0.3);
}

/* ------------------------------------------------------------------ 模态框 */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 7, 10, 0.72);
  backdrop-filter: blur(4px);
  animation: fade 0.14s ease-out;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.modal {
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow);
  animation: rise 0.16s ease-out;
}

@keyframes rise {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
}

.modal.wide {
  max-width: 860px;
}

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

.modal-head h3 {
  font-size: 1rem;
}

.modal-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.modal-close:hover {
  background: var(--surface-3);
  color: var(--text);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-top: 6px;
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.seg {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  gap: 2px;
}

.seg button {
  padding: 5px 14px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.seg button.active {
  background: var(--surface-3);
  color: var(--text);
}

.file-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.file-row:last-child {
  border-bottom: none;
}

.file-row .name {
  font-family: var(--mono);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row .size {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.upload-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.upload-zone:hover,
.upload-zone.drag {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-soft);
}

/* ------------------------------------------------------------------ Toast */

.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  min-width: 220px;
  max-width: 380px;
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  animation: slide 0.18s ease-out;
}

.toast.ok {
  border-color: rgba(63, 185, 80, 0.4);
}

.toast.err {
  border-color: rgba(248, 81, 73, 0.45);
}

@keyframes slide {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
}

/* ------------------------------------------------------------------ 响应式 */

@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 14px;
  }

  .tabs {
    order: 3;
    width: 100%;
    margin-left: 0;
    overflow-x: auto;
  }

  .topbar-right {
    gap: 8px;
  }

  .repo {
    display: none;
  }

  .main {
    padding: 20px 14px 60px;
  }

  .grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .panel-head {
    align-items: flex-start;
  }
}

/* 尊重系统的"减少动态效果"设置 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
