:root {
    --bg: #f7f8fa;
    --card: #ffffff;
    --border: #e5e6eb;
    --text: #1f2329;
    --muted: #86909c;
    --sub: #4e5969;
    --primary: #2563eb;
    --primary-d: #1d4ed8;
    --danger: #d92c20;
    --danger-bg: #fef0ef;
    --ok: #00b42a;
    --warn: #ff7d00;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC",
        -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    color: var(--text);
    background: var(--bg);
}

button {
    font-family: inherit;
    font-size: 13px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    border-radius: 6px;
    padding: 6px 14px;
    cursor: pointer;
    transition: all .15s;
}
button:hover { background: #f2f3f5; border-color: #c9cdd4; }
button:disabled { color: #c9cdd4; cursor: not-allowed; background: #f7f8fa; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--primary-d); border-color: var(--primary-d); }
button.danger { color: var(--danger); border-color: #f2b8b5; }
button.danger:hover { background: var(--danger-bg); }

input[type="text"], input[type="password"], input[type="number"],
textarea, select {
    font-family: inherit;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    background: #fff;
    color: var(--text);
    outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); }
textarea { resize: vertical; }

/* ---------------- 登录 ---------------- */
.login-wrap {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #eef2ff, #f7f8fa);
}
.login-card {
    background: #fff;
    padding: 36px 32px;
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0,0,0,.08);
    width: 320px;
    text-align: center;
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card .sub { color: var(--muted); margin: 0 0 22px; }
.login-card input { width: 100%; margin-bottom: 14px; padding: 10px 12px; }
.login-card button { width: 100%; padding: 10px; font-weight: 600; }
.login-msg { color: var(--danger); min-height: 18px; font-size: 12px; }
.login-card .hint { color: var(--muted); font-size: 11px; margin-top: 14px; }
code { background: #f2f3f5; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---------------- 布局 ---------------- */
.app { display: flex; flex-direction: column; height: 100vh; }
.topbar {
    height: 52px; flex: 0 0 52px;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px;
    background: #fff; border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 15px; }
.top-actions button { margin-left: 8px; }

.body { flex: 1; display: flex; min-height: 0; }
.sidebar {
    width: 230px; flex: 0 0 230px;
    background: #fff; border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
}
.sidebar-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 14px 10px; font-weight: 600; color: var(--text);
}
.sidebar-head button { padding: 2px 10px; font-size: 16px; line-height: 1; }
.site-list { list-style: none; margin: 0; padding: 0 8px; overflow-y: auto; flex: 1; }
.site-list li {
    padding: 9px 10px; border-radius: 6px; cursor: pointer;
    margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.site-list li:hover { background: #f7f8fa; }
.site-list li.active { background: #e8f0fe; color: var(--primary-d); font-weight: 600; }

.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.content-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: 1px solid var(--border); background: #fff;
}
.current-site { font-weight: 600; }
.head-btns button { margin-left: 8px; }

.tabs { display: flex; gap: 4px; padding: 10px 16px 0; background: #fff; border-bottom: 1px solid var(--border); }
.tab {
    border: none; background: transparent; color: var(--sub);
    padding: 8px 18px; border-radius: 0; border-bottom: 2px solid transparent;
}
.tab:hover { background: transparent; color: var(--primary-d); }
.tab.active { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }

.tab-panel { display: none; padding: 14px 16px; overflow-y: auto; flex: 1; }
.tab-panel.active { display: block; }

/* ---------------- 卡片 ---------------- */
.card {
    background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
}
.card-title {
    font-weight: 700; font-size: 14px; margin-bottom: 12px;
    display: flex; align-items: center; gap: 8px;
}
.card-title .spacer, .row .spacer { flex: 1; }
.badge { background: #e8f0fe; color: var(--primary-d); border-radius: 10px; padding: 1px 8px; font-size: 12px; font-weight: 600; }

.row { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 12px; }
.hint.pre { white-space: pre-wrap; line-height: 1.6; margin-bottom: 10px; }

#urlInput { width: 100%; height: 110px; }

/* ---------------- 表格 ---------------- */
.table-wrap { max-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; margin-top: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
    position: sticky; top: 0; background: #f7f8fa; color: var(--sub);
    text-align: left; font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody td { padding: 6px 10px; border-bottom: 1px solid #f0f1f3; }
tbody tr:hover { background: #fafbfc; }
.c-check { width: 36px; text-align: center; }
.c-time { width: 150px; }
td.url-cell { max-width: 480px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-ok { color: var(--ok); font-weight: 600; }
.status-partial, .status-error { color: var(--danger); font-weight: 600; }

/* ---------------- 引擎配置 ---------------- */
.engines-layout { display: flex; gap: 14px; align-items: flex-start; }
.engine-list-card { width: 250px; flex: 0 0 250px; }
.engine-form-card { flex: 1; }
.engine-list { list-style: none; margin: 0; padding: 0; }
.engine-list li {
    padding: 8px 10px; border-radius: 6px; cursor: pointer; margin-bottom: 2px;
    display: flex; align-items: center; gap: 8px;
}
.engine-list li:hover { background: #f7f8fa; }
.engine-list li.active { background: #e8f0fe; color: var(--primary-d); font-weight: 600; }
.engine-list input[type="checkbox"] { width: 16px; height: 16px; }
.form .field { margin-bottom: 12px; }
.form label { display: block; color: var(--sub); margin-bottom: 4px; font-size: 12px; }
.form label .req { color: var(--danger); }
.form input[type="text"], .form input[type="password"], .form select, .form textarea { width: 100%; }
.form textarea { min-height: 100px; font-family: Consolas, "Microsoft YaHei", monospace; }

/* ---------------- 提交栏 ---------------- */
.submit-bar {
    flex: 0 0 auto; background: #fff; border-top: 1px solid var(--border);
    padding: 10px 16px; display: flex; flex-direction: column; gap: 8px;
}
.status-line { color: var(--muted); font-size: 13px; }
.progress { height: 6px; background: #e5e6eb; border-radius: 4px; overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--primary); transition: width .2s; }
.log {
    height: 110px; font-family: Consolas, "Microsoft YaHei", monospace;
    font-size: 12px; border: 1px solid var(--border); border-radius: 6px; padding: 8px; background: #fafbfc;
}

/* ---------------- 弹窗 ---------------- */
.modal {
    position: fixed; inset: 0; background: rgba(0,0,0,.4);
    display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal[hidden] { display: none; }
.modal-box {
    background: #fff; border-radius: 12px; width: 720px; max-width: 92vw;
    max-height: 86vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 700;
}
.modal-head button { border: none; background: transparent; font-size: 18px; cursor: pointer; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-body .field { margin-bottom: 14px; }
.modal-body label { display: block; color: var(--sub); margin-bottom: 5px; font-size: 12px; }
.modal-body input, .modal-body textarea, .modal-body select { width: 100%; }
.modal-body textarea { min-height: 90px; }
.modal-body pre { white-space: pre-wrap; line-height: 1.7; background: #f7f8fa; padding: 14px; border-radius: 8px; font-size: 12px; margin: 0; }
.modal-body .hint { margin-top: 10px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; }
.pill.ok { background: #e8ffea; color: var(--ok); }
.pill.fail { background: var(--danger-bg); color: var(--danger); }
