@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600;700&family=Fira+Sans:wght@300;400;500;600;700&display=swap');

/* ==========================================================================
   Design tokens — ui-ux-pro-max (Glassmorphism, Light/Dark adaptive)
   ========================================================================== */

/* 默认：暗色主题 */
:root, [data-theme="dark"] {
  --bg: #0F172A;
  --fg: #F8FAFC;
  --card: rgba(27, 35, 54, 0.62);
  --card-solid: #1B2336;
  --muted: #272F42;
  --muted-fg: #94A3B8;
  --primary: #1E293B;
  --secondary: #334155;
  --secondary-hover: #3E4C63;
  --accent: #22C55E;
  --on-accent: #0F172A;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.32);
  --destructive: #EF4444;
  --warn: #F59E0B;
  --ring: rgba(255, 255, 255, 0.7);
  --shadow: 0 10px 36px rgba(2, 6, 23, 0.45);
  --input-bg: rgba(11, 17, 32, 0.7);
  --log-panel-bg: rgba(11, 17, 32, 0.85);
  --glow-1: rgba(34, 197, 94, 0.13);
  --glow-2: rgba(59, 130, 246, 0.12);
  --glow-3: rgba(30, 41, 59, 0.55);
  --sidebar-bg: rgba(15, 23, 42, 0.75);
  --help-bg: rgba(39, 47, 66, 0.4);
  --help-open-bg: rgba(39, 47, 66, 0.6);
  --text-dim: #D7E0EC;
}

/* 白天/明色主题 */
[data-theme="light"] {
  --bg: #F1F5F9;
  --fg: #0F172A;
  --card: rgba(255, 255, 255, 0.78);
  --card-solid: #FFFFFF;
  --muted: #E2E8F0;
  --muted-fg: #64748B;
  --primary: #0F172A;
  --secondary: #E2E8F0;
  --secondary-hover: #CBD5E1;
  --accent: #16A34A;
  --on-accent: #FFFFFF;
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.18);
  --destructive: #DC2626;
  --warn: #D97706;
  --ring: rgba(15, 23, 42, 0.4);
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --input-bg: rgba(255, 255, 255, 0.9);
  --log-panel-bg: #0B1120;
  --glow-1: rgba(34, 197, 94, 0.14);
  --glow-2: rgba(59, 130, 246, 0.12);
  --glow-3: rgba(203, 213, 225, 0.6);
  --sidebar-bg: rgba(255, 255, 255, 0.88);
  --help-bg: rgba(241, 245, 249, 0.7);
  --help-open-bg: rgba(226, 232, 240, 0.65);
  --text-dim: #334155;
}

/* 系统偏好跟随（当未显式设置 data-theme 时） */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #F1F5F9;
    --fg: #0F172A;
    --card: rgba(255, 255, 255, 0.78);
    --card-solid: #FFFFFF;
    --muted: #E2E8F0;
    --muted-fg: #64748B;
    --primary: #0F172A;
    --secondary: #E2E8F0;
    --secondary-hover: #CBD5E1;
    --accent: #16A34A;
    --on-accent: #FFFFFF;
    --border: rgba(15, 23, 42, 0.09);
    --border-strong: rgba(15, 23, 42, 0.18);
    --destructive: #DC2626;
    --warn: #D97706;
    --ring: rgba(15, 23, 42, 0.4);
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    --input-bg: rgba(255, 255, 255, 0.9);
    --log-panel-bg: #0B1120;
    --glow-1: rgba(34, 197, 94, 0.14);
    --glow-2: rgba(59, 130, 246, 0.12);
    --glow-3: rgba(203, 213, 225, 0.6);
    --sidebar-bg: rgba(255, 255, 255, 0.88);
    --help-bg: rgba(241, 245, 249, 0.7);
    --help-open-bg: rgba(226, 232, 240, 0.65);
    --text-dim: #334155;
  }
}

:root {
  --font-body: "Fira Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Fira Code", ui-monospace, "Cascadia Code", Consolas, monospace;
  --radius: 16px;
  --radius-sm: 10px;
  --speed: 180ms;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html {
  overflow-x: hidden;
  width: 100%;
}
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--fg);
  font-family: var(--font-body); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden; width: 100%;
  transition: background-color 220ms ease, color 220ms ease;
}
.bg-glow { position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(520px 320px at 12% -6%, var(--glow-1), transparent 68%),
    radial-gradient(640px 420px at 88% 0%, var(--glow-2), transparent 70%),
    radial-gradient(800px 520px at 50% 110%, var(--glow-3), transparent 72%);
  transition: background 220ms ease;
}
h1, h2, h3 { font-family: var(--font-body); }
button, [role="button"] { cursor: pointer; }
a { color: var(--accent); }
code { font-family: var(--font-mono); font-size: 0.92em; background: rgba(148,163,184,0.14); border-radius: 5px; padding: 2px 7px; word-break: break-all; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 6px; }

/* ---------- glass surfaces ---------- */
.glass { background: var(--card); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--border); }
.card { background: var(--card); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px; margin-bottom: 18px; transition: background 220ms ease, border-color 220ms ease, box-shadow 220ms ease; }

/* ---------- 侧边栏与主布局 ---------- */
.layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; width: 100%; max-width: 100%; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 16px;
  padding: 22px 16px; border-radius: 0; border-top: 0; border-left: 0; border-bottom: 0;
  background: var(--sidebar-bg); transition: background 220ms ease; z-index: 30; }

.brand-wrapper { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 0 2px; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, rgba(34,197,94,0.24), rgba(34,197,94,0.06)); border: 1px solid rgba(34,197,94,0.35); color: var(--accent); flex: none; }
.brand h1 { margin: 0; font-size: 15.5px; font-weight: 600; letter-spacing: 0.2px; line-height: 1.2; white-space: nowrap; }
.brand p { margin: 0; font-size: 11px; color: var(--muted-fg); }

/* 移动端顶栏右侧快捷按钮 */
.mobile-top-tools { display: none; align-items: center; gap: 6px; }

.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; min-height: 0; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0;
  border-radius: 10px; background: transparent; color: var(--muted-fg); font: inherit; font-size: 13.5px;
  font-weight: 600; text-align: left; transition: background var(--speed), color var(--speed); flex-shrink: 0; }
.nav-item:hover { color: var(--fg); background: var(--muted); }
.nav-item.on { color: var(--accent); background: rgba(34, 197, 94, 0.13); }
[data-theme="light"] .nav-item.on { color: #15803D; background: rgba(22, 163, 74, 0.12); }

.side-foot { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.side-foot-row { display: flex; align-items: center; gap: 6px; }
.side-foot .pill { justify-content: center; }
.content { padding: 26px 28px 60px; max-width: 1060px; width: 100%; margin: 0 auto; min-width: 0; }

/* ---------- pills & badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 500; background: var(--muted); color: var(--muted-fg);
  border: 1px solid transparent; white-space: nowrap; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-fg); flex: none; }
.pill.ok { background: rgba(34,197,94,0.13); color: var(--accent); border-color: rgba(34,197,94,0.3); }
[data-theme="light"] .pill.ok { color: #15803D; background: rgba(22,163,74,0.12); border-color: rgba(22,163,74,0.25); }
.pill.ok .dot { background: var(--accent); }
.pill.warn { background: rgba(245,158,11,0.13); color: var(--warn); border-color: rgba(245,158,11,0.3); } .pill.warn .dot { background: var(--warn); }
.pill.err { background: rgba(239,68,68,0.13); color: var(--destructive); border-color: rgba(239,68,68,0.32); } .pill.err .dot { background: var(--destructive); }
.pill.pulse .dot { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent;
  border-radius: var(--radius-sm); padding: 8px 14px; font: inherit; font-size: 13.5px; font-weight: 600;
  color: var(--fg); background: var(--secondary); transition: background var(--speed), border-color var(--speed), color var(--speed), transform var(--speed); white-space: nowrap; }
.btn:hover { background: var(--secondary-hover); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: var(--border-strong); color: var(--muted-fg); }
.btn.ghost:hover { color: var(--fg); border-color: var(--border-strong); background: var(--muted); }
.btn.danger-ghost { background: transparent; border-color: rgba(239,68,68,0.35); color: var(--destructive); }
.btn.danger-ghost:hover { background: rgba(239,68,68,0.14); }
.btn.danger { background: var(--destructive); color: #fff; }
.btn.danger:hover { filter: brightness(0.92); }
.btn.sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.icon { padding: 7px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn svg { flex: none; }

/* ---------- stats row ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; width: 100%; }
.stat { padding: 15px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--card);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); min-width: 0; }
.stat .label { font-size: 12px; color: var(--muted-fg); display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.stat .value { font-family: var(--font-mono); font-size: 20px; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.stat .sub { font-size: 12px; color: var(--muted-fg); margin-top: 3px; }
.stat.cta { display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.stat.cta .btn { width: 100%; font-size: 13.5px; }

/* ---------- card head ---------- */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 15.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-head h2 svg { color: var(--muted-fg); }
.card-head .tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- accounts ---------- */
.account-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 14px 2px; border-top: 1px solid var(--border); }
.account-row:first-of-type { border-top: 0; }
.account-main { min-width: 0; flex: 1; }
.account-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; }
.account-name .name { overflow-wrap: anywhere; font-size: 14.5px; }
.account-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 5px; font-size: 12.5px; color: var(--muted-fg); }
.account-result { display: flex; gap: 7px; align-items: baseline; margin-top: 7px; font-size: 12.5px; color: var(--muted-fg); overflow-wrap: anywhere; }
.account-result .ok { color: var(--accent); } .account-result .bad { color: var(--destructive); }
[data-theme="light"] .account-result .ok { color: #15803D; }
.account-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; flex: none; }

/* ---------- jobs table ---------- */
.jobs-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.jobs-table th { text-align: left; padding: 7px 8px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.4px;
  text-transform: uppercase; color: var(--muted-fg); border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
.jobs-table td { padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.jobs-table tr:last-child td { border-bottom: 0; }
.jobs-table .mono { font-family: var(--font-mono); font-size: 12px; }
.jobs-table .num-ok { color: var(--accent); }
[data-theme="light"] .jobs-table .num-ok { color: #15803D; }
.jobs-table .num-bad { color: var(--destructive); }
.jobs-table td.actions-cell { text-align: right; white-space: nowrap; }

/* ---------- logs (终端始终深色高对比) ---------- */
.log-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border-strong); background: transparent; color: var(--muted-fg); font: inherit;
  font-size: 12px; font-weight: 500; border-radius: 999px; padding: 3px 10px; transition: all var(--speed); }
.chip:hover { color: var(--fg); }
.chip.on { background: rgba(34,197,94,0.14); border-color: rgba(34,197,94,0.4); color: var(--accent); }
[data-theme="light"] .chip.on { color: #15803D; background: rgba(22,163,74,0.12); border-color: rgba(22,163,74,0.3); }

.log-panel { background: var(--log-panel-bg); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  height: 380px; overflow-y: auto; padding: 10px 0; font-family: var(--font-mono); font-size: 12.5px; }
.log-line { display: flex; gap: 8px; padding: 3px 12px; border-left: 2px solid transparent; color: #E2E8F0; }
.log-line .t { color: #64748B; flex: none; }
.log-line .type { color: #93C5FD; flex: none; }
.log-line .msg { overflow-wrap: anywhere; min-width: 0; }
.log-line.info { border-left-color: rgba(34,197,94,0.6); }
.log-line.warn { border-left-color: rgba(245,158,11,0.7); } .log-line.warn .msg { color: #FCD34D; }
.log-line.error { border-left-color: rgba(239,68,68,0.7); } .log-line.error .msg { color: #FCA5A5; }
.log-empty { color: #64748B; text-align: center; padding: 40px 0; font-family: var(--font-body); }

/* ---------- forms ---------- */
label.field { display: block; font-size: 13px; font-weight: 600; margin: 0 0 13px; color: var(--text-dim); }
label.field .hint { font-weight: 400; color: var(--muted-fg); }
input, select, textarea { display: block; width: 100%; margin-top: 6px; padding: 9px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--input-bg); color: var(--fg);
  font: inherit; font-size: 13.5px; transition: border-color var(--speed), box-shadow var(--speed); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34,197,94,0.18); }
input::placeholder, textarea::placeholder { color: var(--muted-fg); opacity: 0.7; }
textarea { resize: vertical; white-space: pre; font-family: var(--font-mono); font-size: 12.5px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted-fg); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input[type="checkbox"] { width: auto; margin: 0; accent-color: var(--accent); }

/* ---------- details/help ---------- */
details.help { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; margin: 10px 0; background: var(--help-bg); }
details.help summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--text-dim); }
details.help[open] { background: var(--help-open-bg); }
details.help ol, details.help p { margin: 8px 0 4px; font-size: 13px; color: var(--muted-fg); }
details.help ol { padding-left: 18px; }

/* ---------- dialogs ---------- */
dialog { border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 20px;
  background: var(--card-solid); color: var(--fg); width: min(500px, calc(100vw - 28px));
  box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(2, 6, 23, 0.66); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 14px; font-size: 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.wizard-captcha { margin: 12px 0; min-height: 60px; }
#wizardBox { border: 1px dashed rgba(34,197,94,0.45); border-radius: var(--radius-sm); padding: 12px; margin-top: 6px; background: rgba(34,197,94,0.06); }
#wizardStepArea label { margin-top: 10px; }
#wizardMsg { margin: 8px 0 0; color: var(--muted-fg); font-size: 12.5px; min-height: 18px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; top: 60px; right: 14px; z-index: 90; display: flex; flex-direction: column; gap: 8px; max-width: min(340px, calc(100vw - 28px)); }
.toast { display: flex; gap: 8px; align-items: flex-start; padding: 10px 13px; border-radius: 10px; font-size: 13px;
  background: var(--card-solid); border: 1px solid var(--border-strong); box-shadow: var(--shadow);
  animation: toast-in 220ms ease; overflow-wrap: anywhere; color: var(--fg); }
.toast.ok { border-color: rgba(34,197,94,0.45); } .toast.ok svg { color: var(--accent); flex: none; margin-top: 1px; }
.toast.err { border-color: rgba(239,68,68,0.5); } .toast.err svg { color: var(--destructive); flex: none; margin-top: 1px; }
.toast.info svg { color: #3B82F6; flex: none; margin-top: 1px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- login ---------- */
.login-wrap { display: flex; justify-content: center; align-items: flex-start; min-height: 100vh; padding: 10vh 16px 0; width: 100%; }
.login-card { width: min(380px, 100%); padding: 26px 24px; }
.login-card h2 { margin: 0 0 4px; font-size: 18px; }
.login-card .sub { color: var(--muted-fg); font-size: 12.5px; margin: 0 0 18px; }
.error-text { color: var(--destructive); font-size: 12.5px; min-height: 18px; margin: 8px 0 0; }
.muted { color: var(--muted-fg); font-size: 12.5px; }
.empty { color: var(--muted-fg); font-size: 13px; text-align: center; padding: 20px 0; }

/* ==========================================================================
   响应式调整（手机端与平板端）
   ========================================================================== */
@media (max-width: 900px) {
  .layout { display: flex; flex-direction: column; width: 100%; max-width: 100%; }
  
  /* 手机端顶栏：品牌行 + 滚动标签栏，高度紧凑 */
  .sidebar {
    position: sticky; top: 0; z-index: 40; height: auto;
    padding: 8px 12px; gap: 6px; border-right: 0; border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  }
  
  .brand-wrapper {
    display: flex; align-items: center; justify-content: space-between;
  }
  .mobile-top-tools {
    display: flex; align-items: center; gap: 6px;
  }
  
  /* 移动端横向滑动的胶囊式标签栏 */
  .side-nav {
    display: flex; flex-direction: row; overflow-x: auto;
    padding: 2px 0 4px; gap: 6px; width: 100%;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .side-nav::-webkit-scrollbar { display: none; }
  .nav-item {
    width: auto; padding: 6px 12px; font-size: 12.5px; border-radius: 999px;
    background: var(--muted);
  }
  .nav-item.on {
    background: var(--accent); color: var(--on-accent);
  }
  [data-theme="light"] .nav-item.on {
    background: var(--accent); color: #fff;
  }
  
  /* 移动端底部信息隐藏（移至顶栏快捷区） */
  .side-foot { display: none; }
  
  .content { padding: 14px 12px 40px; }
  .card { padding: 14px 14px; margin-bottom: 14px; border-radius: 12px; }
  
  /* 统计卡：移动端 2 列，CTA 签到按钮卡片跨满整行 */
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
  .stat { padding: 12px 14px; border-radius: 12px; }
  .stat .value { font-size: 17px; }
  .stat.cta { grid-column: span 2; padding: 12px 14px; }
  
  .account-row { flex-direction: column; gap: 10px; }
  .account-actions { width: 100%; justify-content: flex-start; }
  
  /* 移动端历史表格隐藏“明细”列避免拥挤 */
  .jobs-table th:nth-child(4), .jobs-table td:nth-child(4) { display: none; }
  .field-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
