* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f2f4f7; color: #1f2430; font-size: 15px; line-height: 1.6;
}
.hidden { display: none !important; }

/* 登录 */
.view { min-height: 100vh; }
#login-view { display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 360px; text-align: center; }
.login-card h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: .5px; }
.login-card .sub { color: #7a8194; margin: 0 0 20px; font-size: 13px; }

.card {
  background: #fff; border: 1px solid #e6e9f0; border-radius: 12px;
  box-shadow: 0 1px 3px rgba(16,24,40,.06); padding: 18px;
}
input[type=text], input[type=password], textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #d7dbe6; border-radius: 8px;
  font-size: 15px; font-family: inherit; outline: none; background: #fbfcfe;
}
input:focus, textarea:focus { border-color: #4f6ef7; background: #fff; }
textarea { min-height: 90px; resize: vertical; }

button {
  cursor: pointer; border: 1px solid transparent; border-radius: 8px;
  padding: 9px 16px; font-size: 14px; font-family: inherit;
}
button.primary { background: #4f6ef7; color: #fff; }
button.primary:hover { background: #3f5ce0; }
button.primary:disabled { opacity: .55; cursor: not-allowed; }
button.ghost { background: #fff; border-color: #d7dbe6; color: #3a4256; }
button.ghost:hover { background: #f3f5f9; }
button.danger { background: #fff; border-color: #f2c2c2; color: #d63b3b; }
button.danger:hover { background: #fdf0f0; }

.msg { margin-top: 12px; font-size: 13px; min-height: 18px; }
.msg.inline { margin-top: 0; margin-left: 10px; }
.msg.err { color: #d63b3b; }
.msg.ok { color: #18a058; }

/* 主界面 */
.topbar {
  background: #fff; border-bottom: 1px solid #e6e9f0; padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.badge { font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: 20px; background: #eef1f8; color: #5a6376; }
.badge.ok { background: #e7f7ee; color: #18a058; }
.badge.warn { background: #fdf3e0; color: #c07a12; }
.actions { display: flex; gap: 8px; }

main { max-width: 820px; margin: 0 auto; padding: 24px 20px 60px; }

.new-task { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.new-task .row { display: flex; align-items: center; }

.task-list { display: flex; flex-direction: column; gap: 10px; }
.empty { text-align: center; color: #9aa1b2; padding: 40px 0; }
.task-card {
  background: #fff; border: 1px solid #e6e9f0; border-radius: 10px; padding: 14px 16px;
  cursor: pointer; transition: box-shadow .12s, transform .12s;
}
.task-card:hover { box-shadow: 0 4px 14px rgba(16,24,40,.09); transform: translateY(-1px); }
.task-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.task-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-bottom { display: flex; justify-content: space-between; margin-top: 6px; }
.muted { color: #8a91a3; font-size: 12px; }

.status { font-size: 12px; padding: 3px 10px; border-radius: 20px; white-space: nowrap; font-weight: 500; }
.st-pending { background: #eef1f8; color: #5a6376; }
.st-running { background: #e6efff; color: #2f5bdc; animation: pulse 1.6s infinite; }
.st-done { background: #e7f7ee; color: #18a058; }
.st-failed { background: #fdeaea; color: #d63b3b; }
.st-cancelled { background: #f1f2f6; color: #8a91a3; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

/* 弹窗 */
.modal {
  position: fixed; inset: 0; background: rgba(16,24,40,.45); z-index: 20;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal-box { width: 720px; max-width: 100%; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-head .ghost { font-size: 20px; padding: 2px 12px; line-height: 1.4; }
.detail-meta { margin-top: 8px; color: #8a91a3; font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.detail-desc pre { background: #f7f8fb; border: 1px solid #eef0f5; border-radius: 8px; padding: 12px; white-space: pre-wrap; word-break: break-word; margin: 12px 0 0; font-family: inherit; }
.detail-actions { margin-top: 14px; display: flex; gap: 8px; }
h3 { margin: 20px 0 10px; font-size: 14px; color: #3a4256; }
h3.err { color: #d63b3b; }

.progress-log { display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow-y: auto; }
.plog { border-left: 2px solid #e6e9f0; padding: 6px 10px; background: #fafbfd; border-radius: 0 8px 8px 0; }
.plog .plog-k { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; margin-right: 8px; }
.plog .plog-t { font-size: 11px; color: #aab0bf; }
.plog .plog-text { margin-top: 3px; white-space: pre-wrap; word-break: break-word; }
.k-text .plog-k { background: #eef1f8; color: #4f6ef7; }
.k-tool { border-left-color: #8b5cf6; }
.k-tool .plog-k { background: #f0ebfd; color: #7c4df4; }
.k-system .plog-k { background: #e9ecef; color: #5a6376; }
.k-error { border-left-color: #f26d6d; background: #fff8f8; }
.k-error .plog-k { background: #fdeaea; color: #d63b3b; }

.result-box pre { background: #f0f9f4; border: 1px solid #d9f0e3; border-radius: 8px; padding: 12px; white-space: pre-wrap; word-break: break-word; margin: 0; font-family: inherit; }
.result-box h3.err + pre { background: #fff5f5; border-color: #f3d9d9; }

/* 标签页 */
.tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.tab { background: #fff; border: 1px solid #d7dbe6; color: #5a6376; border-radius: 8px; padding: 8px 18px; cursor: pointer; font-size: 14px; }
.tab.active { background: #4f6ef7; color: #fff; border-color: #4f6ef7; }

/* 日志视图 */
.log-filter { margin-bottom: 12px; }
.log-filter select { padding: 8px 12px; border: 1px solid #d7dbe6; border-radius: 8px; font-size: 14px; background: #fff; color: #3a4256; }
.log-list { display: flex; flex-direction: column; gap: 16px; }
.day-block { background: #fff; border: 1px solid #e6e9f0; border-radius: 10px; padding: 12px 14px; }
.day-head { font-weight: 700; font-size: 14px; padding-bottom: 8px; border-bottom: 1px solid #eef0f5; margin-bottom: 6px; }
.day-head .muted { font-weight: 400; margin-left: 6px; }
.log-item { display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-radius: 8px; cursor: pointer; }
.log-item:hover { background: #f5f7fb; }
.log-time { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: #8a91a3; width: 44px; flex: none; }
.log-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-dur { font-size: 12px; color: #8a91a3; white-space: nowrap; }
.log-cost { font-size: 12px; color: #18a058; white-space: nowrap; }
.log-src { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: #eef1f8; color: #5a6376; white-space: nowrap; }
