/* ===== Project Manager 样式 ===== */
:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #e3e7ee;
  --text: #1f2430;
  --muted: #8a93a2;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eff4ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --ok: #16a34a;
  --ok-soft: #f0fdf4;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --radius: 8px;
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --mono: ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.spacer { flex: 1; }

/* ===== 登录 ===== */
.login-wrap {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
}
.login-card {
  background: var(--panel);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  padding: 36px 40px;
  width: 340px;
  display: flex; flex-direction: column; gap: 12px;
  text-align: center;
}
.login-logo { font-size: 44px; }
.login-card h2 { font-size: 22px; }
.login-card .input { padding: 10px 12px; font-size: 15px; }
.btn-block { width: 100%; padding: 10px; font-size: 15px; }

/* ===== 顶栏 ===== */
.topbar {
  height: 52px;
  background: #111827;
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; flex-shrink: 0;
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 20px; }
.title { font-weight: 700; font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar .btn { background: #1f2937; border-color: #374151; color: #d1d5db; }
.topbar .btn:hover { background: #374151; }

.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-on { background: #14532d; color: #4ade80; }
.badge-off { background: #450a0a; color: #f87171; }
.badge-warn { background: #451a03; color: #fbbf24; }
.badge-none { background: #1f2937; color: #9ca3af; }

/* ===== 按钮 ===== */
.btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { background: #f1f5f9; border-color: #cbd5e1; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 3px 9px; font-size: 12px; border-radius: 6px; }

/* ===== 布局 ===== */
#main-view { display: flex; flex-direction: column; }
.layout { flex: 1; display: flex; overflow: hidden; }

.sidebar {
  width: 220px; min-width: 220px;
  height: 100vh;               /* 侧栏占满整个视口高度 */
  padding-top: 52px;           /* 顶部工具栏覆盖区 */
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; }
.panel-head h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.side-sec { border-top: 1px solid var(--border); margin-top: 4px; }

.tree { list-style: none; padding: 0 8px 12px; }
.tree li {
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  display: flex; align-items: center; gap: 8px;
}
.tree li:hover { background: #f1f5f9; }
.tree li.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tree li .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-on { background: var(--ok); }
.dot-off { background: #f87171; }
.dot-none { background: #cbd5e1; }
.tree li .pname { overflow: hidden; text-overflow: ellipsis; }
.tree li .pport { margin-left: auto; font-size: 11px; color: var(--muted); }
.tree-empty { cursor: default !important; color: var(--muted); font-size: 12px; }
.tree-empty:hover { background: none !important; }

/* ===== 主区 ===== */
.content { flex: 1; display: flex; flex-direction: column; overflow: hidden; padding-top: 52px; }
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); gap: 12px; }
.empty-icon { font-size: 48px; opacity: .6; }

#project-view { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.tabs { display: flex; gap: 4px; padding: 10px 18px 0; background: var(--panel); border-bottom: 1px solid var(--border); }
.tab {
  border: none; background: none;
  padding: 8px 16px;
  font-size: 13px; cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--accent); font-weight: 600; border-bottom-color: var(--accent); }

.tab-panel { flex: 1; overflow-y: auto; padding: 16px 18px; }

.overview-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.overview-head h2 { font-size: 20px; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-bottom: 14px; }
.info-item { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.info-item .k { font-size: 11px; color: var(--muted); }
.info-item .v { font-size: 14px; font-weight: 600; word-break: break-all; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.section-title { font-size: 14px; margin-bottom: 8px; color: var(--text); }

/* ===== 表格 ===== */
.table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--panel); }
.table th {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  font-size: 12px; color: var(--muted);
  position: sticky; top: 0;
}
.table td { border-bottom: 1px solid #eef1f6; padding: 7px 10px; }
.table tbody tr:hover { background: #f8fafc; }
.table .row-actions { white-space: nowrap; }

/* ===== 文件浏览器 ===== */
.filebar { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.crumb { font-size: 13px; color: var(--muted); }
.crumb b { color: var(--text); }
.file-table-wrap { flex: 1; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.file-table td { max-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name { cursor: pointer; color: var(--accent); }
.file-name:hover { text-decoration: underline; }
.f-ico { margin-right: 6px; }

.file-preview { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.preview-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.preview-content {
  padding: 12px;
  font-size: 12px;
  line-height: 1.6;
  max-height: 50vh;
  overflow: auto;
  background: #0d1117;
  color: #d6deeb;
  white-space: pre;
}
.preview-image { padding: 16px; text-align: center; }
.preview-image img { max-width: 100%; max-height: 50vh; border-radius: 6px; }
.preview-note { padding: 12px; color: var(--muted); }

/* ===== 日志 ===== */
.log-cols { display: flex; gap: 12px; height: calc(100% - 40px); }
.log-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.log-col h4 { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.log-box {
  flex: 1;
  background: #0d1117;
  color: #d6deeb;
  border-radius: var(--radius);
  padding: 12px;
  font-size: 12px;
  line-height: 1.5;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 200px;
}
.log-full { height: 60vh; }

/* ===== 弹窗 ===== */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal {
  background: var(--panel);
  border-radius: 12px;
  box-shadow: var(--shadow);
  width: 520px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 80px);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-lg { width: 880px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-close { border: none; background: none; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.modal-body label { font-size: 13px; font-weight: 600; display: block; margin-top: 6px; }
.modal-body label:first-child { margin-top: 0; }
.hint { font-size: 12px; color: var(--muted); }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: #fafbfc; }

.input {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.input::placeholder { color: #b6bdc9; }
select.input { padding: 6px 8px; }

.msg { font-size: 13px; padding: 8px 12px; border-radius: 6px; }
.msg-error { background: var(--danger-soft); color: var(--danger); }
.msg-ok { background: var(--ok-soft); color: var(--ok); }

/* ===== 上传 ===== */
.drop-zone {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.progress { height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* ===== Toast ===== */
#toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #111827; color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 200;
  max-width: 70vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.toast-warn { background: #92400e; }
#toast.toast-error { background: #b91c1c; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== 系统设置 ===== */
.health-box { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: #f8fafc; }
.health-row { padding: 3px 0; font-size: 13px; line-height: 1.5; }
.health-disk { font-size: 12px; color: var(--muted); padding-left: 12px; }
.text-danger { color: var(--danger); }
.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px; }

/* ===== 任务进度 ===== */
.task-stage { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.task-results { min-height: 140px; max-height: 40vh; white-space: pre-wrap; word-break: break-all; }

/* ===== 项目主页按钮 ===== */
.btn-home { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-home:hover { background: #15803d; border-color: #15803d; }

/* 侧栏项目行内主页快捷入口 */
.tree li .pgo {
  margin-left: 4px;
  text-decoration: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}
.tree li .pgo:hover { color: var(--accent); }

/* ===== 备忘录 ===== */
.memo-textarea {
  min-height: 220px;
  resize: vertical;
  font-family: var(--mono);
  line-height: 1.6;
  white-space: pre-wrap;
}
.memo-item .pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.memo-item .memo-time { margin-left: auto; font-size: 11px; color: var(--muted); flex-shrink: 0; }

/* ===== 定时任务 ===== */
.cron-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.cron-add .input { flex: 1; min-width: 130px; }
.cron-add #cron-command { flex: 2.2; }
.cron-head { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; }
.cron-table-wrap {
  overflow: auto;
  max-height: 52vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.cron-table-wrap .table th { position: sticky; top: 0; z-index: 1; }
.cron-sched { font-weight: 600; white-space: nowrap; }
.cron-cmd { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
