/* ==========================================================
   多网站自动运维中心 - 后台样式
   简洁、专业、适合 Windows 桌面浏览器
   ========================================================== */
:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --border: #e3e7ee;
  --border-strong: #cfd6e0;
  --text: #1f2937;
  --text-2: #4b5563;
  --muted: #8a94a6;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eaf1ff;
  --side: #1b2433;
  --side-2: #243044;
  --side-text: #c4cdda;
  --ok: #15803d;
  --ok-soft: #e8f6ee;
  --warn: #b45309;
  --warn-soft: #fdf3e2;
  --fail: #c62828;
  --fail-soft: #fdecec;
  --info-soft: #eef2f7;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --font: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --mono: Consolas, "Cascadia Mono", "Courier New", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: #f1f3f7; padding: 1px 5px; border-radius: 4px; }
h1, h2, h3 { margin: 0; font-weight: 600; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.text-ok { color: var(--ok); } .text-warn { color: var(--warn); } .text-fail { color: var(--fail); }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 216px; flex-shrink: 0; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; }
.brand-logo { width: 38px; height: 38px; border-radius: 8px; background: var(--primary); color: #fff; font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; letter-spacing: .5px; }
.brand-name { font-weight: 600; color: #fff; font-size: 14px; }
.brand-name.dark { color: var(--text); font-size: 16px; }
.brand-sub { font-size: 11px; color: var(--muted); }
.nav { padding: 6px 10px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; color: var(--side-text); border-radius: 6px; margin-bottom: 2px; }
.nav-item svg { width: 18px; height: 18px; fill: currentColor; opacity: .85; }
.nav-item:hover { background: var(--side-2); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--primary); color: #fff; }
.sidebar-foot { padding: 12px 16px; border-top: 1px solid #2c3850; font-size: 12px; }
.side-task { line-height: 1.4; }
.side-task.running { color: #93c5fd; cursor: pointer; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; background: var(--panel); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 20; }
.page-title { font-size: 18px; }
.topbar-right { display: flex; align-items: center; gap: 14px; color: var(--text-2); font-size: 13px; }
.content { padding: 20px 24px 120px; max-width: 1680px; width: 100%; }

/* ---------- 卡片 ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { font-size: 15px; }
.card-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grid-2-1 { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.side-col .card { margin-bottom: 16px; }
@media (max-width: 1280px) { .grid-2-1 { grid-template-columns: 1fr; } }
.empty { color: var(--muted); text-align: center; padding: 18px; }
.empty-state { text-align: center; padding: 48px; }

/* ---------- 主操作按钮 ---------- */
.main-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.actions-hint { margin-left: auto; }

/* ---------- 统计卡片 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; min-height: 76px; }
.stat-card .label { font-size: 12px; color: var(--muted); }
.stat-card .value { font-size: 24px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-card .sub { font-size: 11.5px; color: var(--muted); }
.stat-card.ok .value { color: var(--ok); }
.stat-card.warn .value { color: var(--warn); }
.stat-card.fail .value { color: var(--fail); }
.stat-card.clickable { cursor: pointer; }
.stat-card.clickable:hover { border-color: var(--border-strong); }
.skeleton { background: linear-gradient(90deg, #f3f5f8, #eaedf2, #f3f5f8); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- 按钮 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 6px; border: 1px solid transparent; font: inherit; font-size: 13.5px; cursor: pointer; background: #fff; color: var(--text); white-space: nowrap; user-select: none; }
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: #f6f8fb; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: #eef1f5; }
.btn-danger { background: var(--fail); color: #fff; }
.btn-danger-outline { border-color: #f0b8b8; color: var(--fail); }
.btn-danger-outline:hover:not(:disabled) { background: var(--fail-soft); }
.btn-lg { height: 42px; padding: 0 24px; font-size: 15px; font-weight: 600; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-xs { height: 24px; padding: 0 7px; font-size: 12px; border-color: var(--border); }
.btn-xs:hover:not(:disabled) { background: #f1f4f8; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; gap: 4px; flex-wrap: wrap; }

/* ---------- 表单 ---------- */
.input, input[type=text].input, select.input, textarea.input { height: 34px; border: 1px solid var(--border-strong); border-radius: 6px; padding: 0 10px; font: inherit; font-size: 13.5px; background: #fff; color: var(--text); }
textarea.input { height: auto; padding: 8px 10px; width: 100%; resize: vertical; }
.input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.input-sm { height: 28px; font-size: 12.5px; }
label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 10px; }
label > .input, label > input, label > select, label > textarea { display: block; width: 100%; margin-top: 4px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0 14px 8px 0; color: var(--text); }
label.inline input { width: auto; margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { font-weight: 600; font-size: 13px; color: var(--text); margin: 14px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border); grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.field-error { border-color: var(--fail) !important; }
.settings-form .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .settings-form .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.narrow-form { max-width: 460px; }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar-left, .toolbar-right { display: flex; gap: 8px; align-items: center; }
.toolbar-left.wrap { flex-wrap: wrap; }
.bulk-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; background: var(--primary-soft); border: 1px solid #cfdcf8; border-radius: 6px; padding: 7px 10px; margin-bottom: 10px; font-size: 13px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 600; color: var(--text-2); background: #f7f9fb; border-bottom: 1px solid var(--border); padding: 8px 10px; white-space: nowrap; }
.table td { border-bottom: 1px solid #eef1f5; padding: 8px 10px; vertical-align: middle; }
.table tbody tr:hover { background: #fafbfd; }
.table-compact td { padding: 6px 8px; }
.col-check { width: 32px; }
.col-actions { text-align: right; }
td.col-actions { white-space: nowrap; }
.site-name { font-weight: 600; color: var(--text); }
.site-domain { font-size: 12px; color: var(--muted); }
tr.disabled-row td { color: var(--muted); }
tr.disabled-row .site-name { color: var(--muted); }
.cell-sub { font-size: 11.5px; color: var(--muted); }

/* ---------- 状态 ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 500; white-space: nowrap; line-height: 20px; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-fail { background: var(--fail-soft); color: var(--fail); }
.badge-info { background: var(--info-soft); color: var(--text-2); }
.badge-run { background: var(--primary-soft); color: var(--primary); }
.dots { display: inline-flex; gap: 3px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #d7dce4; vertical-align: middle; }
.dot-ok { background: #22a05a; } .dot-warning { background: #e39b25; } .dot-fail { background: #dc3b3b; } .dot-unknown { background: #d7dce4; }
.legend .dot { margin: 0 2px 0 8px; }
.status-line { display: flex; align-items: center; gap: 6px; }

/* ---------- 列表 ---------- */
.list .list-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed #eceff3; font-size: 13px; }
.list .list-item:last-child { border-bottom: 0; }
.list-item .time { color: var(--muted); font-size: 12px; min-width: 42px; font-variant-numeric: tabular-nums; }
.list-item .body { flex: 1; min-width: 0; }
.list-item .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .desc { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.list-item.unread .title::after { content: " ●"; color: var(--primary); font-size: 10px; }

/* ---------- 任务面板 ---------- */
.task-panel { position: fixed; right: 20px; bottom: 20px; width: 460px; max-height: calc(100vh - 100px); background: #fff; border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: 0 10px 30px rgba(16, 24, 40, .18); z-index: 50; display: flex; flex-direction: column; }
.task-panel.minimized .tp-body { display: none; }
.tp-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); gap: 8px; }
.tp-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-body { padding: 12px 14px; overflow: auto; }
.progress { height: 8px; background: #edf0f4; border-radius: 4px; overflow: hidden; margin: 6px 0; }
.progress > div { height: 100%; background: var(--primary); transition: width .4s; }
.progress.done > div { background: var(--ok); }
.progress.has-fail > div { background: var(--warn); }
.tp-meta { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-2); }
.tp-current { background: #f7f9fb; border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; margin: 8px 0; font-size: 13px; }
.tp-counters { display: flex; gap: 12px; font-size: 12.5px; margin: 6px 0; }
.events { max-height: 240px; overflow-y: auto; font-size: 12.5px; background: #fbfcfd; border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; }
.events .ev { padding: 2px 0; white-space: pre-wrap; word-break: break-all; }
.events .ev time { color: var(--muted); margin-right: 6px; font-variant-numeric: tabular-nums; }
.ev-success { color: var(--ok); } .ev-warning { color: var(--warn); } .ev-error { color: var(--fail); } .ev-info { color: var(--text-2); }
.tp-result { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 10px; }
.result-table { width: 100%; font-size: 13px; border-collapse: collapse; }
.result-table td { padding: 3px 4px; }
.result-table td:first-child { color: var(--muted); width: 110px; }
.tp-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- 模态框 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 560px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal.wide { max-width: 860px; }
@media (max-width: 760px) {
  .app { display: block; }
  .sidebar { position: static; width: 100%; height: auto; }
  .sidebar .nav { display: flex; overflow-x: auto; }
  .sidebar .nav-item { flex-shrink: 0; }
  .sidebar-foot { display: none; }
  .main { min-width: 0; width: 100%; }
  .topbar { padding: 10px 12px; height: auto; gap: 8px; flex-wrap: wrap; }
  .topbar .clock { display: none; }
  .content { padding: 12px; }
  .settings-form .form-grid { grid-template-columns: minmax(0, 1fr); }
  .modal-body { overflow-wrap: anywhere; }
  .modal-body table { table-layout: fixed; width: 100%; }
  .modal-body td { overflow-wrap: anywhere; }
  #site-detail .detail-grid { grid-template-columns: minmax(0, 1fr); }
  #site-detail .card-head { flex-wrap: wrap; }
  #site-detail .btn { min-height: 44px; }
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-close { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-body { padding: 16px 18px; max-height: 70vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.confirm-text { font-size: 14px; white-space: pre-wrap; }
.result-banner { padding: 10px 12px; border-radius: 6px; font-weight: 600; margin-bottom: 10px; }
.result-banner.ok { background: var(--ok-soft); color: var(--ok); }
.result-banner.warn { background: var(--warn-soft); color: var(--warn); }
.result-banner.fail { background: var(--fail-soft); color: var(--fail); }
.kv { width: 100%; border-collapse: collapse; font-size: 13px; }
.kv th { text-align: left; color: var(--muted); font-weight: 400; width: 140px; padding: 5px 8px 5px 0; vertical-align: top; }
.kv td { padding: 5px 0; word-break: break-all; }
pre.code { background: #f6f8fa; border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-all; max-height: 260px; overflow: auto; margin: 6px 0; }
.sub-title { font-weight: 600; margin: 14px 0 6px; font-size: 13.5px; }

/* ---------- Toast ---------- */
.toast-root { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #1f2937; color: #fff; padding: 9px 16px; border-radius: 6px; font-size: 13.5px; box-shadow: 0 6px 18px rgba(0, 0, 0, .2); max-width: 640px; white-space: pre-wrap; }
.toast.success { background: #166534; } .toast.error { background: #b91c1c; } .toast.warning { background: #a16207; }

/* ---------- 分页 / 标签 ---------- */
.pager { display: flex; gap: 4px; justify-content: flex-end; margin-top: 10px; align-items: center; font-size: 13px; }
.pager .btn { min-width: 32px; }
.pager .btn.current { background: var(--primary); color: #fff; border-color: var(--primary); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab { border: 0; background: none; padding: 9px 16px; font: inherit; cursor: pointer; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------- 说明 ---------- */
.help-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; font-size: 13px; }
.help-grid p { margin: 4px 0 0; }
.help-details summary { cursor: pointer; color: var(--primary); margin-top: 10px; }
.help-text { font-size: 13px; color: var(--text-2); }
.help-list { margin: 0; padding-left: 20px; font-size: 13px; color: var(--text-2); }
.help-list li { margin: 4px 0; }
.win-task { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.check-list td:first-child { width: 28px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 20px; }
.detail-grid .k { font-size: 12px; color: var(--muted); }
.detail-grid .v { font-size: 14px; word-break: break-all; }

/* ---------- 登录 ---------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(160deg, #1b2433, #2b3a55); }
.auth-card { width: 380px; background: #fff; border-radius: 12px; padding: 28px; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.auth-brand { padding: 0 0 18px; }
.auth-form h2 { font-size: 17px; margin-bottom: 14px; }
.auth-form input { display: block; width: 100%; height: 38px; border: 1px solid var(--border-strong); border-radius: 6px; padding: 0 10px; font: inherit; margin-top: 4px; }
.auth-form .btn { height: 40px; margin-top: 8px; }

/* 表格内操作按钮不换行（窄屏时表格可横向滚动） */
td.col-actions .btn-group { flex-wrap: nowrap; }
.table label.inline { margin: 0; white-space: nowrap; }
.table td .badge + .cell-sub { margin-top: 2px; }
