/* ===================== 主题变量 ===================== */
:root {
    --accent: #2563eb;
    --accent-hover: #3b82f6;
    --accent-glow: rgba(37, 99, 235, .35);
    --accent-soft: rgba(37, 99, 235, .08);
    --radius: 14px;
    --radius-sm: 9px;
    --font: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
    --mono: "Cascadia Code", "Consolas", "Courier New", monospace;
    --transition: .2s cubic-bezier(.4, 0, .2, 1);
}
[data-theme="dark"] {
    --bg: #0a0a12;
    --bg2: #101018;
    --card: #13131c;
    --card2: #181822;
    --border: #222230;
    --border2: #2c2c3c;
    --text: #e4e4ee;
    --text2: #9a9ab0;
    --muted: #606078;
    --log-bg: #080810;
    --ok: #22c55e; --err: #ef4444; --warn: #f59e0b; --info: #8890a8;
    --shadow: 0 8px 48px rgba(0,0,0,.55);
    --glow-opacity: .14;
}
[data-theme="light"] {
    --bg: #f2f3f7;
    --bg2: #ffffff;
    --card: #ffffff;
    --card2: #fafbfd;
    --border: #e2e4ec;
    --border2: #d2d5e0;
    --text: #1a1a2e;
    --text2: #555b6e;
    --muted: #9096a8;
    --log-bg: #f7f8fc;
    --ok: #16a34a; --err: #dc2626; --warn: #d97706; --info: #667085;
    --shadow: 0 8px 40px rgba(30,40,90,.1);
    --glow-opacity: .07;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
    position: relative;
}
input, button, select, textarea { font-family: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: normal; font-size: 11px; }

/* ===================== 背景光晕 ===================== */
.bg-glow {
    position: fixed; inset: 0; pointer-events: none; z-index: 0;
    background:
        radial-gradient(900px 400px at 20% -10%, rgba(37,99,235,var(--glow-opacity)), transparent 60%),
        radial-gradient(700px 500px at 80% 70%, rgba(99,102,241,calc(var(--glow-opacity) * .7)), transparent 60%);
}

/* ===================== 登录页 ===================== */
.login-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 20px;
    background:
        radial-gradient(1000px 500px at 50% -10%, rgba(37,99,235,.22), transparent 60%),
        radial-gradient(800px 600px at 80% 80%, rgba(99,102,241,.1), transparent 60%),
        var(--bg);
}
.login-card {
    width: 100%; max-width: 400px;
    background: var(--card); border: 1px solid var(--border);
    border-radius: 20px; padding: 42px 34px 30px;
    box-shadow: var(--shadow); text-align: center;
    position: relative; z-index: 1;
}
.login-logo { display: flex; justify-content: center; margin-bottom: 20px; }
.logo-badge {
    width: 60px; height: 60px; border-radius: 18px;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: #fff; font-size: 32px; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 28px rgba(37,99,235,.4);
}
.logo-badge.sm {
    width: 42px; height: 42px; border-radius: 12px;
    box-shadow: 0 4px 14px rgba(37,99,235,.35);
    flex-shrink: 0;
}
.login-title { font-size: 23px; font-weight: 700; margin-bottom: 6px; }
.login-sub { color: var(--text2); font-size: 13px; margin-bottom: 28px; }
.login-form .field { margin-bottom: 14px; }
.login-error { color: var(--err); font-size: 13px; margin-bottom: 12px; min-height: 18px; }
.login-foot { color: var(--muted); font-size: 11px; margin-top: 24px; }

/* ===================== 通用控件 ===================== */
input[type=text], input[type=password], select {
    width: 100%; padding: 11px 14px; font-size: 14px;
    background: var(--card2); color: var(--text);
    border: 1px solid var(--border2); border-radius: var(--radius-sm);
    outline: none; transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--muted); }

/* 自定义 select 下拉箭头 */
.select-wrap { position: relative; }
.select-wrap select {
    cursor: pointer; appearance: none; padding-right: 36px;
}
.select-arrow {
    position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
    pointer-events: none; color: var(--muted);
}

.btn, .btn-primary {
    padding: 10px 18px; font-size: 14px; font-weight: 600;
    border-radius: var(--radius-sm); cursor: pointer; border: 1px solid var(--border2);
    background: var(--card2); color: var(--text); transition: all var(--transition); white-space: nowrap;
    display: inline-flex; align-items: center; gap: 7px; justify-content: center;
}
.btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.btn-primary {
    background: linear-gradient(135deg, var(--accent), #4f46e5);
    border-color: transparent; color: #fff;
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-hover), #6366f1);
    box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:disabled { opacity: .45; cursor: not-allowed; background: var(--accent); }
.btn-primary:disabled:hover { box-shadow: none; }
.btn-block { width: 100%; display: flex; text-align: center; text-decoration: none; }
.btn-sm { padding: 7px 14px; font-size: 13px; border-radius: 7px; }

/* ===================== 布局 ===================== */
.app {
    max-width: 1200px; margin: 0 auto; padding: 20px;
    min-height: 100vh; display: flex; flex-direction: column;
    position: relative; z-index: 1;
}
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 4px 18px; border-bottom: 1px solid var(--border); margin-bottom: 20px;
}
.brand {
    display: flex; align-items: center; gap: 12px;
    text-decoration: none; color: inherit;
}
.brand-txt { display: flex; flex-direction: column; gap: 2px; }
.brand-title { font-size: 18px; font-weight: 800; letter-spacing: .3px; }
.brand-sub { font-size: 11.5px; color: var(--text2); }
.topbar-actions { display: flex; gap: 6px; align-items: center; }
.icon-btn {
    width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border2);
    background: var(--card2); color: var(--text2); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    text-decoration: none; transition: all var(--transition);
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.icon-btn svg { flex-shrink: 0; }

.layout {
    display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
    gap: 20px; flex: 1;
}
.panel { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px;
    transition: border-color var(--transition);
}
.card-upload { padding-bottom: 14px; }

.card-title {
    font-size: 13px; font-weight: 700; color: var(--text);
    margin-bottom: 14px; letter-spacing: .3px;
    display: flex; align-items: center; gap: 8px;
}
.card-title svg { flex-shrink: 0; color: var(--accent); }

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label {
    display: block; font-size: 12px; color: var(--text2);
    margin-bottom: 6px; font-weight: 600;
}
.row { display: flex; gap: 8px; }
.row input { flex: 1; }

/* ===================== 上传区 ===================== */
.dropzone {
    border: 2px dashed var(--border2); border-radius: var(--radius-sm);
    padding: 28px 16px; text-align: center; cursor: pointer;
    transition: all var(--transition);
    background: var(--card2);
    position: relative;
}
.dropzone:hover, .dropzone.drag {
    border-color: var(--accent);
    background: linear-gradient(135deg, var(--accent-soft), rgba(99,102,241,.04));
}
.dz-inner { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.dz-ring {
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--accent-soft);
    display: flex; align-items: center; justify-content: center;
    color: var(--accent);
    transition: transform var(--transition);
}
.dropzone:hover .dz-ring, .dropzone.drag .dz-ring { transform: scale(1.08); }
.dz-ring svg { display: block; }
.dz-text { font-size: 13.5px; color: var(--text); }
.dz-link { color: var(--accent); font-weight: 600; cursor: pointer; }
.dz-link:hover { text-decoration: underline; }
.dz-hint { font-size: 11.5px; color: var(--muted); }

.file-info {
    margin-top: 12px; padding: 10px 14px; border-radius: var(--radius-sm);
    background: rgba(34,197,94,.08); border: 1px solid rgba(34,197,94,.2);
    font-size: 13px; color: var(--ok); display: flex; justify-content: space-between;
    align-items: center; gap: 10px;
}
.file-info .fi-name {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-weight: 600;
}
.file-info .fi-size { color: var(--text2); font-size: 12px; flex-shrink: 0; font-weight: 400; }

/* ===================== 分段选择 ===================== */
.seg {
    display: flex; gap: 5px; background: var(--card2);
    padding: 4px; border-radius: var(--radius-sm);
    margin-bottom: 14px; border: 1px solid var(--border2);
}
.seg-item {
    flex: 1; padding: 9px 6px; font-size: 12.5px; border: none;
    border-radius: 7px; background: transparent; color: var(--text2);
    cursor: pointer; font-weight: 600; transition: all var(--transition);
    display: flex; align-items: center; justify-content: center; gap: 6px;
}
.seg-item:hover { color: var(--text); }
.seg-item.active {
    background: linear-gradient(135deg, var(--accent), #4f46e5);
    color: #fff; box-shadow: 0 2px 8px var(--accent-glow);
}
.seg-item svg { flex-shrink: 0; }
.ks-fields { padding-top: 4px; }

/* ===================== 自定义复选框 ===================== */
.chk {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 9px 0; cursor: pointer;
}
.chk-box { position: relative; flex-shrink: 0; margin-top: 2px; }
.chk-box input {
    position: absolute; opacity: 0; width: 100%; height: 100%;
    cursor: pointer; z-index: 1;
}
.chk-mark {
    display: block; width: 20px; height: 20px;
    border: 2px solid var(--border2); border-radius: 6px;
    background: var(--card2);
    transition: all var(--transition);
    position: relative;
}
.chk-mark::after {
    content: ""; position: absolute; top: 3px; left: 6px;
    width: 5px; height: 9px; border: solid #fff;
    border-width: 0 2px 2px 0; transform: rotate(45deg) scale(0);
    transition: transform .15s;
}
.chk-box input:checked + .chk-mark {
    background: var(--accent); border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.chk-box input:checked + .chk-mark::after { transform: rotate(45deg) scale(1); }
.chk-body { display: flex; flex-direction: column; gap: 2px; }
.chk-label { font-size: 14px; font-weight: 600; color: var(--text); }
.chk-body em {
    font-style: normal; font-size: 11.5px; color: var(--muted);
    line-height: 1.45;
}

.btn-start {
    width: 100%; padding: 14px; font-size: 15px; margin-top: 4px;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-start svg { flex-shrink: 0; }

/* ===================== 日志面板 ===================== */
.logpanel { min-height: 420px; display: flex; flex-direction: column; }
.log-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
}
.log-head .card-title { margin-bottom: 0; }
.status-wrap { display: flex; align-items: center; gap: 7px; }
.status-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--muted); flex-shrink: 0;
    transition: background .3s;
}
.status-dot.ok { background: var(--ok); box-shadow: 0 0 8px rgba(34,197,94,.5); }
.status-dot.err { background: var(--err); box-shadow: 0 0 8px rgba(239,68,68,.5); }
.status-dot.run {
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
    animation: pulse-dot .8s ease-in-out infinite;
}
@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 6px var(--accent-glow); }
    50% { box-shadow: 0 0 16px var(--accent-glow), 0 0 32px rgba(37,99,235,.2); }
}
.status { font-size: 12.5px; color: var(--text2); font-weight: 600; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }
.status.run { color: var(--accent); }

.log {
    flex: 1; background: var(--log-bg); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px; overflow-y: auto;
    font-family: var(--mono); font-size: 12.5px; line-height: 1.65;
    white-space: pre-wrap; word-break: break-all;
    min-height: 280px; max-height: 60vh;
}
.log .l-OK    { color: var(--ok); }
.log .l-ERR   { color: var(--err); }
.log .l-WARN  { color: var(--warn); }
.log .l-INFO  { color: var(--info); }
.log-empty { color: var(--muted); }

.progress {
    height: 4px; background: var(--card2); border-radius: 2px;
    overflow: hidden; margin-top: 14px;
}
.progress .bar {
    height: 100%; width: 40%;
    background: linear-gradient(90deg, var(--accent), #6366f1, var(--accent));
    background-size: 200% 100%;
    border-radius: 2px;
    animation: progress-slide 1.4s ease-in-out infinite;
}
@keyframes progress-slide {
    0% { margin-left: -40%; }
    100% { margin-left: 100%; }
}
#downloadBtn { margin-top: 14px; }
#downloadBtn svg { flex-shrink: 0; }

/* ===================== 弹窗 ===================== */
.modal {
    position: fixed; inset: 0; display: flex;
    align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.modal-card {
    width: 100%; max-width: 380px; background: var(--card);
    border: 1px solid var(--border); border-radius: 18px;
    padding: 26px; box-shadow: var(--shadow);
    position: relative; z-index: 1;
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 18px; }
.modal-msg { font-size: 12.5px; min-height: 20px; margin: 4px 0 12px; }
.modal-msg.err { color: var(--err); }
.modal-msg.ok  { color: var(--ok); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ===================== 页脚 ===================== */
.footer {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 18px 0 6px; margin-top: auto;
    font-size: 12px; color: var(--muted);
    border-top: 1px solid var(--border);
}
.footer-dot { color: var(--border2); }

/* ===================== 响应式 ===================== */
@media (max-width: 860px) {
    .layout { grid-template-columns: 1fr; }
    .app { padding: 14px; }
    .brand-sub { display: none; }
    .logpanel { min-height: 340px; }
    .log { max-height: 44vh; min-height: 200px; }
    .btn-start { padding: 15px; font-size: 16px; }
    .login-card { padding: 32px 22px 24px; }
}
@media (max-width: 480px) {
    .seg-item { font-size: 11.5px; padding: 9px 4px; }
    .card { padding: 15px; }
    .brand-title { font-size: 15px; }
    .logo-badge { width: 50px; height: 50px; border-radius: 15px; }
    .logo-badge.sm { width: 36px; height: 36px; border-radius: 10px; }
}
