:root {
  --bg: #0d1117; --bg2: #161b22; --bg3: #1c2430;
  --border: #2d3748; --text: #e6edf3; --muted: #8b98a9;
  --accent: #4f8cff; --accent2: #7c5cff; --ok: #3fb950; --warn: #d29922; --err: #f85149;
  --radius: 10px; --gap: 20px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  font-size: 14px; line-height: 1.6;
}
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* topbar */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; background: var(--bg2); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; gap: 12px; align-items: center; }
.brand .logo { font-size: 13px; font-weight: 700; letter-spacing: 1px; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent2)); padding: 7px 10px; border-radius: 8px; }
.brand h1 { font-size: 18px; font-weight: 600; }
.brand .sub { font-size: 12px; color: var(--muted); }
.right { display: flex; gap: 10px; align-items: center; }
.pill { background: var(--bg3); border: 1px solid var(--border); padding: 6px 14px; border-radius: 999px; font-size: 13px; }
.pill .usd { color: var(--ok); font-weight: 600; }
.pill.low .usd { color: var(--err); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.dot.bad { background: var(--err); box-shadow: 0 0 6px var(--err); }

.banner { background: rgba(248, 81, 73, .12); border-bottom: 1px solid var(--err); color: var(--err); padding: 8px 24px; font-size: 13px; }

/* tabs */
.tabs { display: flex; gap: 4px; padding: 10px 24px 0; background: var(--bg2); border-bottom: 1px solid var(--border); }
.tab { background: none; border: none; color: var(--muted); padding: 10px 18px; font-size: 15px; cursor: pointer; border-bottom: 2px solid transparent; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

main { max-width: 1180px; margin: 20px auto; padding: 0 24px; }
.tabpane { display: none; }
.tabpane.active { display: grid; grid-template-columns: minmax(360px, 460px) 1fr; gap: var(--gap); align-items: start; }
#tab-history.active { display: block; }

/* cards */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card h2 { font-size: 15px; margin-bottom: 14px; color: var(--text); display: flex; align-items: center; gap: 10px; }

/* form */
.field { margin-bottom: 14px; }
.field > label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.field > label.check { display: flex; align-items: center; gap: 8px; color: var(--text); padding-top: 8px; cursor: pointer; }
select, input[type="text"], input[type="number"], textarea {
  width: 100%; background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font-size: 14px; font-family: inherit;
}
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { background: var(--bg3); border: 1px solid var(--border); color: var(--muted); border-radius: 999px; padding: 3px 12px; font-size: 12px; cursor: pointer; }
.chip:hover { color: var(--text); border-color: var(--accent); }

/* buttons */
.btn { border: 1px solid var(--border); background: var(--bg3); color: var(--text); border-radius: 8px; padding: 8px 16px; font-size: 14px; cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: none; color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.primary:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn.big { width: 100%; padding: 12px; font-size: 15px; }
.btn.ghost { font-size: 13px; padding: 6px 12px; }
.btn.sm { padding: 6px 14px; font-size: 13px; }
.btn.danger:hover { border-color: var(--err); color: var(--err); }
.body-btns { margin-top: 6px; }

/* recharge modal */
.modal { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.72); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.modal-box { width: min(540px, 92vw); background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; cursor: default; box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal-head h3 { font-size: 16px; }
.modal-head .lb-btn { position: static; font-size: 24px; padding: 0 8px; }
.topup-balance { font-size: 14px; margin-bottom: 14px; color: var(--muted); }
.topup-balance b { color: var(--ok); font-size: 22px; font-weight: 700; margin-left: 4px; }
.topup-info { margin-top: 16px; font-size: 12.5px; color: var(--muted); line-height: 1.8; }
.topup-info p { margin-bottom: 4px; }
.topup-links { margin-top: 14px; display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; }
.topup-links a { color: var(--accent); text-decoration: none; }
.topup-links a:hover { text-decoration: underline; }
.banner { cursor: pointer; }

/* result */
.result-body { min-height: 260px; }
.result-body.empty { display: flex; align-items: center; justify-content: center; color: var(--muted); text-align: center; padding: 40px 10px; border: 1px dashed var(--border); border-radius: 8px; }
.result-body .media { max-width: 100%; max-height: 520px; border-radius: 8px; border: 1px solid var(--border); background: #000; display: block; }
.result-body video { width: 100%; max-height: 480px; border-radius: 8px; background: #000; }
.result-meta { margin-top: 10px; font-size: 12px; color: var(--muted); }
.result-actions { margin-top: 10px; display: flex; gap: 10px; flex-wrap: wrap; }

/* gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.g-item { position: relative; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: #000; }
.g-item img { width: 100%; height: 150px; object-fit: cover; display: block; cursor: zoom-in; transition: transform .15s; }
.g-item:hover img { transform: scale(1.04); }
.g-item .dl { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.68); color: #fff; padding: 2px 9px; border-radius: 6px; font-size: 12px; text-decoration: none; }
.g-item .dl:hover { background: var(--accent); }
.g-item .cap { position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,.62); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 4px; }

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 8px; cursor: default; }
.lb-btn { position: absolute; color: #fff; font-size: 34px; cursor: pointer; user-select: none; line-height: 1; padding: 8px 16px; }
.lb-btn:hover { color: var(--accent); }
#lbClose { top: 14px; right: 20px; }
#lbPrev { left: 14px; top: 50%; transform: translateY(-50%); }
#lbNext { right: 14px; top: 50%; transform: translateY(-50%); }
.lb-info { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); color: var(--muted); font-size: 13px; background: rgba(0,0,0,.55); padding: 4px 14px; border-radius: 999px; }

/* badges */
.badge { font-size: 12px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.badge.run0 { color: var(--warn); border-color: var(--warn); }
.badge.run1 { color: var(--accent); border-color: var(--accent); animation: pulse 1.4s infinite; }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.fail { color: var(--err); border-color: var(--err); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

/* spinner */
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--accent); border-top-color: transparent; border-radius: 50%; animation: sp 0.8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes sp { to { transform: rotate(360deg); } }

/* frames upload */
.frames { display: flex; gap: 14px; margin-top: 10px; }
.frame-slot { width: 120px; }
.frame-slot .thumb { width: 120px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 6px; }
.upload-trigger { display: block; width: 100%; text-align: center; padding: 8px 0; background: var(--bg3); border: 1px dashed var(--border); border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 12px; }
.upload-trigger:hover { border-color: var(--accent); color: var(--text); }
input[type="file"] { width: 100%; background: var(--bg3); border: 1px dashed var(--border); border-radius: 8px; padding: 8px 10px; color: var(--muted); font-size: 13px; }
input[type="file"]:hover { border-color: var(--accent); }

/* reference thumbnails */
.refs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ref-item { position: relative; width: 84px; height: 84px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #000; }
.ref-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ref-item .rn { position: absolute; left: 3px; bottom: 3px; background: rgba(0,0,0,.62); color: #fff; font-size: 10px; padding: 0 5px; border-radius: 3px; }
.ref-item .rm { position: absolute; top: 3px; right: 3px; width: 19px; height: 19px; line-height: 17px; text-align: center; background: rgba(0,0,0,.65); border: 1px solid var(--border); border-radius: 50%; color: #fff; cursor: pointer; font-size: 12px; }
.ref-item .rm:hover { border-color: var(--err); color: var(--err); }

/* drop / paste zone */
.dropzone { position: relative; }
.dropzone .dropHint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.dropzone .dropHint b { color: var(--text); }
.dropzone.dragging input[type="file"] { border-color: var(--accent); border-style: solid; background: rgba(79, 140, 255, .08); }
.dropzone.dragging::after { content: '松开即添加参考图'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(79, 140, 255, .12); border: 1px dashed var(--accent); border-radius: 8px; color: var(--text); font-size: 13px; pointer-events: none; }
.zone-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.mini-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 12px; padding: 2px 0; }
.mini-btn:hover { text-decoration: underline; }

/* models report */
.models-box { width: min(780px, 94vw); max-height: 84vh; overflow: auto; }
.msec { margin: 14px 0 0; }
.msec h4 { font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.mlist { font-size: 12.5px; line-height: 1.9; }
.mlist .tag { display: inline-block; min-width: 46px; color: var(--muted); }
.mlist .tag.ok { color: var(--ok); }
.mlist .tag.no { color: var(--err); }
.mlist .tag.new { color: var(--warn); }
.kvrow { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12.5px; color: var(--muted); }
.kvrow b { color: var(--text); font-weight: 600; }
.mempty { font-size: 12.5px; color: var(--muted); }

/* login page */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.login-wrap { width: min(440px, 100%); }
.login-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 14px; padding: 26px 26px 20px; box-shadow: 0 14px 44px rgba(0,0,0,.45); }
.login-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.login-head .logo { font-size: 13px; font-weight: 700; letter-spacing: 1px; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent2)); padding: 7px 10px; border-radius: 8px; }
.login-head h1 { font-size: 19px; font-weight: 600; }
.login-sub { font-size: 13px; color: var(--muted); line-height: 1.7; margin-bottom: 18px; }
.login-check { margin: 4px 0 14px; font-size: 13px; }
.login-msg { font-size: 13px; color: var(--ok); background: rgba(63,185,80,.08); border: 1px solid var(--ok); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; line-height: 1.6; }
.login-msg.err-msg { color: var(--err); background: rgba(248,81,73,.08); border-color: var(--err); }
.login-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 16px; font-size: 12px; flex-wrap: wrap; }
.login-foot a { color: var(--accent); text-decoration: none; }
.login-foot a:hover { text-decoration: underline; }
.login-note { font-size: 11.5px; line-height: 1.7; margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 10px; }

/* user chip in topbar */
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.user-chip .uname { color: var(--text); font-weight: 600; }

/* camera */
.cam-box { width: min(680px, 94vw); }
.cam-video { width: 100%; max-height: 60vh; border-radius: 8px; background: #000; display: block; object-fit: contain; }
.cam-actions { display: flex; gap: 10px; margin-top: 12px; }
.cam-actions .btn.big { flex: 1; }
.cam-flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .18s; z-index: 110; }
.cam-flash.on { opacity: .75; }

/* progress bar */
.pbar { height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.pbar > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .5s; }
.pbar.indet > div { width: 40%; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide {
  0% { margin-left: -40%; }
  100% { margin-left: 100%; }
}
.prog-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.prog-row .pbar { flex: 1; margin-top: 0; }
.prog-row .pct { font-size: 12px; color: var(--muted); min-width: 38px; text-align: right; font-variant-numeric: tabular-nums; }
.elapsed { font-variant-numeric: tabular-nums; }
.status-line { margin-top: 6px; font-size: 13px; color: var(--muted); }
.status-line .taskid { font-family: Consolas, monospace; font-size: 12px; }
.err { color: var(--err); font-size: 14px; }
.err .muted { color: var(--muted); }
.ktag { background: var(--bg3); border: 1px solid var(--border); color: var(--muted); border-radius: 4px; padding: 1px 7px; font-size: 11px; margin-right: 6px; }

/* history */
.history-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.history-tools { display: flex; gap: 10px; align-items: center; }
.filters { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.fchip { background: var(--bg3); border: 1px solid var(--border); color: var(--muted); border-radius: 999px; padding: 4px 14px; font-size: 13px; cursor: pointer; }
.fchip:hover { color: var(--text); }
.fchip.active { color: #fff; background: var(--accent); border-color: var(--accent); }
.history { display: flex; flex-direction: column; gap: 10px; }
.hist-item { display: flex; gap: 14px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg3); align-items: center; flex-wrap: wrap; }
.hist-item .himg { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; background: #000; cursor: zoom-in; flex-shrink: 0; }
.hist-item .hbody { flex: 1; min-width: 220px; }
.hist-item .hmodel { font-weight: 600; font-size: 13px; }
.hist-item .hmeta { font-size: 12px; color: var(--muted); }
.hist-item .herr { color: var(--err); font-size: 12px; margin-top: 4px; word-break: break-all; }
.hist-item .hact { display: flex; gap: 8px; flex-wrap: wrap; }
.hist-detail { width: 100%; border-top: 1px dashed var(--border); margin-top: 8px; padding-top: 8px; font-size: 12px; color: var(--muted); word-break: break-all; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; }
.pager .btn:disabled { opacity: .4; cursor: not-allowed; }
.pager .muted { font-variant-numeric: tabular-nums; }

/* toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--bg3); border: 1px solid var(--accent); color: var(--text); padding: 10px 20px; border-radius: 8px; z-index: 99; box-shadow: 0 8px 24px rgba(0,0,0,.4); max-width: 80vw; }
.toast.err { border-color: var(--err); }

footer { text-align: center; padding: 18px; font-size: 12px; }

@media (max-width: 900px) {
  .tabpane.active { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 12px; }
}
