:root {
  --bg: #f4f6f9; --card: #fff; --text: #1f2933; --muted: #6b7785; --line: #e3e8ee;
  --primary: #1677ff; --primary-text: #fff; --ok: #1a8f4c; --warn: #c27c0e; --bad: #d4380d;
  --ok-bg: #e8f6ee; --warn-bg: #fdf3e2; --bad-bg: #fdecea; --info-bg: #e8f1ff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c; --card: #1d2128; --text: #e5e9ef; --muted: #8f9aa8; --line: #2d333c;
    --primary: #3c8cff; --ok: #4cc27f; --warn: #e3a440; --bad: #ff7a5c;
    --ok-bg: #173225; --warn-bg: #3a2c14; --bad-bg: #3c1d17; --info-bg: #1a2a44;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; }
[hidden] { display: none !important; }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h2 small { color: var(--muted); font-weight: normal; }
input, select, textarea, button, .button {
  font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px;
}
textarea { width: 100%; font-family: ui-monospace, Consolas, monospace; }
button, .button { cursor: pointer; text-decoration: none; display: inline-block; white-space: nowrap; }
button:hover, .button:hover { border-color: var(--primary); }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
button.link { border: none; background: none; color: var(--primary); padding: 4px 6px; }
button:disabled { opacity: .5; cursor: default; }
code { background: var(--bg); padding: 1px 4px; border-radius: 4px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; display: grid; gap: 12px; }
.login-card label { display: grid; gap: 4px; }
.error { color: var(--bad); min-height: 1.5em; margin: 0; }

.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
.tabs { display: flex; gap: 4px; }
.tabs button { border: none; background: none; padding: 6px 12px; border-radius: 6px; }
.tabs button.active { background: var(--info-bg); color: var(--primary); font-weight: 600; }
.spacer { flex: 1; }
.badge { font-size: 12px; color: var(--muted); }

main { padding: 16px; max-width: 1280px; margin: 0 auto; display: grid; gap: 16px; }
main > div { display: grid; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.row h2 { margin: 0; }
.filter { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.filter label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.filter label input, .filter label select { color: var(--text); font-size: 14px; }
.import { margin-top: 12px; }
.import summary { cursor: pointer; color: var(--primary); }
.import textarea { margin: 8px 0; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 13px; white-space: nowrap; }
td.mono { font-family: ui-monospace, Consolas, monospace; white-space: nowrap; }
tr.dim td { color: var(--muted); }
td .muted { color: var(--muted); font-size: 12px; }
.logs { font-size: 12px; color: var(--muted); margin-top: 4px; white-space: pre-line; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; white-space: nowrap; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag.info { background: var(--info-bg); color: var(--primary); }
.tag.dim { background: var(--bg); color: var(--muted); }

.progress { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); width: 0; transition: width .3s; }

.captcha-panel { position: fixed; right: 16px; bottom: 16px; z-index: 20; background: var(--card); border: 2px solid var(--warn); border-radius: 10px; padding: 12px; width: 300px; max-width: calc(100vw - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.18); max-height: 70vh; overflow-y: auto; overflow-x: hidden; }
.captcha-head { font-weight: 600; color: var(--warn); margin-bottom: 8px; }
.captcha-head small { color: var(--muted); font-weight: normal; }
.captcha-item { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 8px 0; border-top: 1px solid var(--line); }
.captcha-item img { width: 100%; max-width: 280px; min-height: 60px; object-fit: contain; background: #fff; border-radius: 4px; border: 1px solid var(--line); }
.captcha-item form { display: flex; gap: 6px; }
.captcha-item input { flex: 1; min-width: 0; width: 100%; font-size: 18px; letter-spacing: 4px; }

dialog { border: 1px solid var(--line); border-radius: 10px; padding: 0; width: min(960px, calc(100vw - 32px)); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.4); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); }
#modal-body { padding: 16px; display: grid; gap: 12px; }
#modal-body img { max-width: 100%; border: 1px solid var(--line); border-radius: 6px; }
.raw { max-height: 420px; overflow: auto; background: var(--bg); padding: 10px; border-radius: 6px; font-size: 12px; white-space: pre-wrap; word-break: break-all; }
.raw:empty { display: none; }

.toast { position: fixed; left: 50%; top: 16px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 6px; z-index: 30; max-width: calc(100vw - 32px); }
.digits { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 6px; margin-bottom: 8px; }
.digit { text-align: center; padding: 6px 0; border-radius: 6px; background: var(--bg); }
.digit b { display: block; font-size: 18px; }
.digit small { color: var(--muted); }
.digit.low { background: var(--warn-bg); }
.digit.low small { color: var(--warn); }
.trace { padding-left: 20px; display: grid; gap: 14px; margin: 0; }
.trace li { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.trace .trace-head { margin-bottom: 2px; }
.trace .url { word-break: break-all; font-size: 12px; }
.trace img { margin-top: 6px; }
#modal-body h3 { font-size: 15px; margin: 8px 0 0; }
.live-wrap { max-height: 70vh; overflow: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
#live-img { width: 100%; display: block; min-height: 200px; cursor: zoom-in; }
#live-img.actual { width: auto; max-width: none; cursor: zoom-out; }
.live-captcha { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px; border: 2px solid var(--warn); border-radius: 8px; }
.live-captcha img { height: 64px; background: #fff; border-radius: 4px; border: 1px solid var(--line); }
.live-captcha input { font-size: 18px; letter-spacing: 4px; width: 7em; }
.ver { color: var(--muted); font-weight: normal; font-size: 12px; }
.human-panel { bottom: auto; top: 70px; border-color: var(--primary); }
.human-panel .captcha-head { color: var(--primary); }
.live-tools { display: grid; gap: 6px; }
.live-tools .row { margin: 0; }
.live-tools button { font-size: 13px; padding: 4px 8px; }
#live-text { flex: 1; min-width: 160px; }
#live-img { cursor: crosshair; }
#live-img.actual { cursor: crosshair; }
.link.danger { color: var(--bad); }
