/* ==========================================================================
   CDN 创建平台 — 内部运维工具样式
   纯 CSS，无外部资源；系统字体栈；支持 prefers-color-scheme: dark
   ========================================================================== */

/* ---------- 设计变量 ---------- */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
    "Liberation Mono", "Courier New", monospace;

  --bg: #f3f5f7;
  --bg-auth: #eceff3;
  --surface: #ffffff;
  --surface-2: #f7f9fa;
  --border: #dde2e8;
  --border-strong: #c9d1da;

  --text: #1f2933;
  --text-2: #52606d;
  --text-3: #7b8794;

  --accent: #0b5fff;
  --accent-hover: #0950d8;
  --accent-active: #0842b4;
  --accent-soft: #e8f0ff;
  --accent-ring: rgba(11, 95, 255, 0.18);

  --ok: #1e7e34;
  --ok-bg: #e7f5ea;
  --ok-border: #bfe3c8;

  --err: #c0392b;
  --err-bg: #fdecea;
  --err-border: #f3c1ba;

  --warn: #8a5a00;

  --radius: 8px;
  --radius-sm: 6px;

  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.05),
    0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-pop: 0 8px 24px rgba(16, 24, 40, 0.12);

  --topbar-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181d;
    --bg-auth: #10141a;
    --surface: #1c222a;
    --surface-2: #232a33;
    --border: #323b46;
    --border-strong: #45505d;

    --text: #e4e9ef;
    --text-2: #a7b2bd;
    --text-3: #7d8894;

    --accent: #5b8cff;
    --accent-hover: #759dff;
    --accent-active: #8fb0ff;
    --accent-soft: #1e2c4d;
    --accent-ring: rgba(91, 140, 255, 0.28);

    --ok: #4cc26e;
    --ok-bg: #16301f;
    --ok-border: #2a5436;

    --err: #f0705f;
    --err-bg: #3a1d19;
    --err-border: #5c2f28;

    --warn: #d9a13b;

    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35),
      0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.5);
  }
}

/* ---------- 基础 ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button {
  font-family: inherit;
}

::selection {
  background: var(--accent-soft);
}

/* JS 视图切换 */
.hide {
  display: none !important;
}

.view {
  min-height: 100vh;
}

/* ==========================================================================
   登录视图
   ========================================================================== */

.view-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(11, 95, 255, 0.05), transparent 60%),
    var(--bg-auth);
}

.auth-wrap {
  width: 100%;
  max-width: 400px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo {
  color: var(--accent);
  display: inline-flex;
  margin-bottom: 12px;
}

.auth-title {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.auth-sub {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-3);
}

.auth-card {
  padding: 28px 28px 24px;
}

.auth-card + .auth-card {
  margin-top: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 18px;
}

/* ==========================================================================
   卡片 / 面板
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 24px 72px;
}

.panel {
  margin-bottom: 20px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.panel-num {
  flex: none;
  width: 26px;
  height: 26px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.panel-head-text {
  min-width: 0;
}

.panel-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}

.panel-desc {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text-3);
}

.panel-head-actions {
  margin-left: auto;
  flex: none;
  display: flex;
  align-items: center;
}

.panel-body {
  padding: 20px 24px 22px;
}

.panel-body-flush {
  padding: 0;
}

.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
}

.panel-foot .msg-area {
  flex: 1 1 auto;
  min-width: 0;
}

.panel-foot .btn-row {
  flex: none;
  margin-top: 0;
}

/* ==========================================================================
   表单
   ========================================================================== */

.form-row {
  margin-bottom: 14px;
}

.panel-body > .form-row:last-child,
.auth-card > .form-row:last-of-type {
  margin-bottom: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 20px;
}

.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid .form-row {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-2);
  margin-bottom: 6px;
}

.input {
  display: block;
  width: 100%;
  height: 36px;
  padding: 0 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease,
    background-color 0.15s ease;
}

.input::placeholder {
  color: var(--text-3);
}

.input:hover:not(:disabled):not(:focus) {
  border-color: var(--text-3);
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.input:disabled {
  background: var(--surface-2);
  color: var(--text-3);
  cursor: not-allowed;
}

.input-mono {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.01em;
}

/* ---------- 单选组 ---------- */
.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin-bottom: 16px;
}

.radio-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 0;
}

.radio-item input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.radio-item input[type="radio"]:hover {
  border-color: var(--accent);
}

.radio-item input[type="radio"]:checked {
  border-color: var(--accent);
  border-width: 5px;
}

.radio-item input[type="radio"]:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-ring);
  outline: none;
}

.radio-text {
  font-size: 13.5px;
  color: var(--text);
}

/* ==========================================================================
   按钮
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 16px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    color 0.15s ease, box-shadow 0.15s ease;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:active:not(:disabled) {
  background: var(--accent-active);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--text-3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.btn-sm {
  height: 30px;
  padding: 0 12px;
  font-size: 12.5px;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.auth-card .btn-row .btn-primary {
  flex: 1;
}

/* ==========================================================================
   消息提示（JS 动态生成 .msg / .msg.ok / .msg.err）
   ========================================================================== */

.msg-area {
  min-height: 0;
  font-size: 13px;
}

.msg-area:empty {
  display: none;
}

.msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  line-height: 1.5;
  word-break: break-all;
}

.msg::before {
  flex: none;
  font-weight: 700;
  line-height: 1.5;
}

.msg.ok {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok);
}

.msg.ok::before {
  content: "✓";
}

.msg.err {
  background: var(--err-bg);
  border-color: var(--err-border);
  color: var(--err);
}

.msg.err::before {
  content: "✕";
}

/* ==========================================================================
   顶栏
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 960px;
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
  min-width: 0;
}

.topbar-title {
  font-size: 15px;
  font-weight: 650;
  color: var(--text);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
}

.user-badge {
  font-size: 12.5px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 12px;
  white-space: nowrap;
}

.user-badge #who {
  font-weight: 600;
  color: var(--text);
}

/* ==========================================================================
   创建进度（JS 动态生成 .s-ok / .s-err / .detail）
   ========================================================================== */

.progress {
  margin-top: 22px;
  padding: 16px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.progress-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 10px;
}

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
}

.steps li {
  position: relative;
  padding: 6px 0 6px 26px;
  font-size: 13.5px;
  color: var(--text-2);
}

/* 连接竖线 */
.steps li::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 26px;
  bottom: -4px;
  width: 2px;
  background: var(--border);
}

.steps li:last-child::after {
  display: none;
}

/* 默认（进行中/等待）圆点 */
.steps li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface);
  box-sizing: border-box;
}

/* 成功步骤：绿色圆底 + 对勾（伪元素绘制图标） */
.steps li.s-ok {
  color: var(--text);
}

.steps li.s-ok::before {
  content: "✓";
  border-color: var(--ok);
  background: var(--ok);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 12px;
  text-align: center;
}

/* 失败步骤：红色圆底 + 叉（伪元素绘制图标） */
.steps li.s-err {
  color: var(--err);
}

.steps li.s-err::before {
  content: "✕";
  border-color: var(--err);
  background: var(--err);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 12px;
  text-align: center;
}

/* 步骤详情：灰色小字 */
.detail {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-3);
  font-family: var(--font-mono);
  word-break: break-all;
}

/* ==========================================================================
   任务记录表格
   ========================================================================== */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th,
.table td {
  padding: 10px 16px;
  text-align: left;
  vertical-align: middle;
}

.table thead th {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table tbody td {
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr {
  transition: background-color 0.12s ease;
}

.table tbody tr:hover {
  background: var(--surface-2);
}

.table tbody:empty::after {
  content: "暂无任务记录";
  display: block;
  padding: 32px 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

.col-domain {
  width: 38%;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.col-status {
  width: 14%;
  white-space: nowrap;
}

.col-time {
  width: 24%;
  color: var(--text-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.col-action {
  width: 24%;
  white-space: nowrap;
}

/* ==========================================================================
   响应式（1280px 笔记本 → 1920px 显示器）
   ========================================================================== */

@media (min-width: 1600px) {
  .page,
  .topbar-inner {
    max-width: 1080px;
  }

  body {
    font-size: 14.5px;
  }
}

@media (max-width: 1400px) {
  .page,
  .topbar-inner {
    max-width: 880px;
  }
}

/* 窄于约 900px 时表单网格降为单列（极端窗口宽度兜底） */
@media (max-width: 900px) {
  .form-grid,
  .form-grid-3 {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 14px;
  }

  .panel-foot {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-foot .btn-row {
    justify-content: flex-end;
  }
}

/* ---------- 降低动态效果偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
