:root {
  --bg: #0a0b0d;
  --bg-1: #111317;
  --bg-2: #171a1f;
  --bg-3: #20242b;
  --border: #2a2f37;
  --text: #eef1f5;
  --text-dim: #aab2bd;       /* brighter than before so 灰字看得清 */
  --text-faint: #7e8794;
  --blue: #3b82f6;
  --blue-dim: #2f6fe0;
  --green: #22c55e;
  --orange: #f59e0b;
  --danger: #ef4444;
  --accent: var(--blue);
  --radius: 12px;
  --mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --log-bg: #06070a;
  --log-text: #aeb6c2;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
  /* Premium tokens */
  --accent-2: #6366f1;
  --grad-primary: linear-gradient(135deg, #4f8cff 0%, #6366f1 100%);
  --grad-text: linear-gradient(135deg, #7eb0ff 0%, #a5a8ff 100%);
  --ring: 0 0 0 3px rgba(79,140,255,.30);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.30);
  --shadow-md: 0 8px 24px rgba(0,0,0,.38);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.55);
  --glow: 0 6px 18px rgba(79,110,247,.40);
}

/* ---------- Light theme ---------- */
[data-theme="light"] {
  --bg: #f5f6f8;
  --bg-1: #ffffff;
  --bg-2: #f0f2f5;
  --bg-3: #e4e8ee;
  --border: #dce0e6;
  --text: #1b1f24;
  --text-dim: #515a66;
  --text-faint: #8a929c;
  --blue: #2f6fe0;
  --blue-dim: #2a63c8;
  --log-bg: #f4f6f8;
  --log-text: #475063;
  --shadow: 0 8px 30px rgba(20,30,55,.12);
  /* Premium tokens */
  --accent-2: #6366f1;
  --grad-primary: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
  --grad-text: linear-gradient(135deg, #2f6fe0 0%, #6366f1 100%);
  --ring: 0 0 0 3px rgba(47,111,224,.18);
  --shadow-sm: 0 1px 2px rgba(20,30,55,.06);
  --shadow-md: 0 8px 24px rgba(20,30,55,.10);
  --shadow-lg: 0 24px 60px rgba(20,30,55,.16);
  --glow: 0 6px 18px rgba(59,110,224,.28);
}

html { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }
body, .btn, .field input, .composer textarea, .side-type, .sidebar, .modal,
.theme-toggle, .login-card, .type-card, .run-card { transition: background .2s ease, color .2s ease, border-color .2s ease; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border); background: var(--bg-2); color: var(--text);
  padding: 9px 16px; border-radius: 9px; cursor: pointer; font-size: 13px;
  font-family: var(--sans); transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: var(--bg-3); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dim); }
.btn.ghost { background: transparent; }
.btn.warn { background: var(--orange); border-color: var(--orange); color: #1a1205; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.block { width: 100%; }
.btn.big { padding: 11px 16px; font-size: 14px; font-weight: 600; }
.btn.small { padding: 6px 11px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Login ---------- */
.login-view { display: flex; align-items: center; justify-content: center; height: 100vh; padding: 20px; }
.login-card {
  width: 380px; max-width: 100%; background: var(--bg-1); border: 1px solid var(--border);
  border-radius: 16px; padding: 34px 30px; display: flex; flex-direction: column; gap: 14px; align-items: stretch;
}
.login-logo { width: 76px; height: 76px; border-radius: 18px; object-fit: cover; align-self: center; box-shadow: 0 0 30px rgba(59,130,246,.25); }
.login-title { text-align: center; margin: 6px 0 0; font-size: 22px; }
.login-sub { text-align: center; color: var(--text-dim); margin: -6px 0 8px; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-dim); }
.field input, .cfg input, .cfg select {
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 10px 12px; font-size: 14px; outline: none;
}
.field input:focus { border-color: var(--blue); }
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; }
.hint { color: var(--blue); font-size: 12px; min-height: 16px; margin: 0; }
.error { color: var(--danger); font-size: 12px; min-height: 16px; margin: 0; }

/* ---------- Shell ---------- */
.shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 290px; flex-shrink: 0; background: var(--bg-1); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px;
}
.side-head { display: flex; flex-direction: column; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; }
.brand strong { display: block; font-size: 15px; }
.brand span { display: block; font-size: 11px; color: var(--text-faint); }

.side-section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-faint); margin: 16px 4px 8px; }
.side-types { display: flex; flex-direction: column; gap: 6px; }
.side-type {
  display: flex; align-items: center; gap: 10px; text-align: left;
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  padding: 11px 12px; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 500;
}
.side-type:hover { background: var(--bg-3); }
.side-type.active { border-color: var(--blue); background: rgba(59,130,246,.12); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot.blue { background: var(--blue); } .dot.green { background: var(--green); } .dot.orange { background: var(--orange); }

.side-nav { display: flex; flex-direction: column; gap: 3px; margin-top: 14px; }
.nav-item { text-align: left; background: transparent; border: none; color: var(--text-dim); padding: 9px 11px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.nav-item:hover { background: var(--bg-2); color: var(--text); }
.nav-item.active { background: var(--bg-3); color: var(--text); }

.history-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.history-item {
  text-align: left; background: transparent; border: none; color: var(--text-dim);
  padding: 10px 11px; border-radius: 9px; cursor: pointer; font-size: 13px;
  display: flex; flex-direction: column; gap: 3px; overflow: hidden;
}
.history-item:hover { background: var(--bg-2); color: var(--text); }
.history-item.active { background: var(--bg-3); color: var(--text); }
.history-item .hi-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item .hi-meta { font-size: 11px; color: var(--text-faint); }

.side-foot { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 8px; }
.account { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.account-meta { display: flex; flex-direction: column; line-height: 1.2; }
.plan-tag { font-size: 11px; color: var(--orange); }

/* ---------- Main / views ---------- */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.view { display: none; flex-direction: column; height: 100%; overflow: hidden; }
.view.active { display: flex; }
/* Top padding clears the fixed top-right bar (用户订阅/账号/退出) so page titles
   like 用户订阅 / 我的资料 / 管理后台 don't sit underneath it. */
.view.scroll { overflow-y: auto; padding: 68px 32px 28px; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.view-head h2 { margin: 0; }
.muted { color: var(--text-dim); }
.tiny { font-size: 12px; }

/* ---------- Home stream ---------- */
.run-stream { flex: 1; overflow-y: auto; padding: 26px 14% 16px; }
@media (max-width: 1200px) { .run-stream { padding: 26px 6% 16px; } }

.hero { max-width: 760px; margin: 4vh auto 0; text-align: center; }
.hero img { width: 92px; height: 92px; border-radius: 22px; object-fit: cover; box-shadow: 0 0 40px rgba(59,130,246,.3); }
.hero h1 { font-size: 24px; margin: 16px 0 8px; }
.hero p { color: var(--text-dim); }

.type-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: 880px; margin: 26px auto 0; }
@media (max-width: 900px) { .type-cards { grid-template-columns: 1fr; } }
.type-card {
  text-align: left; background: var(--bg-1); border: 1px solid var(--border); color: var(--text);
  border-radius: 14px; padding: 18px; cursor: pointer; transition: border-color .15s, transform .1s;
}
.type-card:hover { border-color: var(--blue); transform: translateY(-2px); }
.type-card.active { border-color: var(--blue); background: rgba(59,130,246,.1); }
.type-card .tc-icon { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 17px; margin-bottom: 10px; }
.tc-icon.blue { background: rgba(59,130,246,.18); } .tc-icon.green { background: rgba(34,197,94,.16); } .tc-icon.orange { background: rgba(245,158,11,.16); }
.type-card h3 { margin: 0 0 6px; font-size: 15px; }
.type-card p { margin: 0; font-size: 12.5px; color: var(--text-dim); }

/* messages */
.msg { display: flex; gap: 12px; max-width: 820px; margin: 0 auto 18px; }
.msg .m-avatar { width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0; object-fit: cover; }
.msg .m-avatar.user { background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.msg.user { flex-direction: row-reverse; }
.msg .bubble { background: var(--bg-1); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.msg.user .bubble { background: var(--bg-3); }
.confirm-actions { display: flex; gap: 8px; margin-top: 12px; }

/* run card */
.run-card { flex: 1; background: var(--bg-1); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.run-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.run-card-head h3 { margin: 0; font-size: 15px; }
.run-head-right { display: flex; align-items: center; gap: 8px; }
.status-pill { font-size: 12px; padding: 3px 11px; border-radius: 999px; background: var(--bg-3); color: var(--orange); border: 1px solid var(--orange); }
.status-pill.running { color: var(--blue); border-color: var(--blue); }
.status-pill.completed { color: var(--green); border-color: var(--green); }
.status-pill.failed { color: var(--danger); border-color: var(--danger); }

.phase-line { font-size: 13px; color: var(--text-dim); margin-bottom: 12px; }
.bar-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-dim); margin-bottom: 5px; }
.progress { height: 7px; background: var(--bg-3); border-radius: 999px; overflow: hidden; margin-bottom: 12px; }
.progress > span { display: block; height: 100%; background: var(--blue); width: 0%; transition: width .4s; }
.progress.green > span { background: var(--green); }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 10px; margin: 6px 0 12px; }
.metric { background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px; text-align: center; }
.metric span { display: block; font-size: 11px; color: var(--text-faint); margin-bottom: 4px; }
.metric strong { font-size: 18px; }
.metric.high strong { color: var(--danger); } .metric.medium strong { color: var(--orange); }

.section-title { font-size: 13px; font-weight: 600; color: var(--text-dim); margin: 14px 0 8px; }

/* Collapsible detail sections (progressive disclosure): folded by default so the
   high-level summary is what users see first; expand for 用例 / 运行日志 detail. */
details.sec { border-top: 1px solid var(--border); margin-top: 4px; }
details.sec > summary {
  cursor: pointer; list-style: none; user-select: none;
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--text-dim); padding: 12px 0 10px;
}
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::before {
  content: "▸"; color: var(--text-faint); font-size: 11px; transition: transform .15s ease;
}
details.sec[open] > summary::before { transform: rotate(90deg); }
details.sec > summary:hover { color: var(--text); }
details.sec > summary .sec-title { color: var(--text); }
.cases-toolbar { margin: 0 0 8px; }
.log-box { background: var(--log-bg); border: 1px solid var(--border); border-radius: 8px; font-family: var(--mono); font-size: 12px; color: var(--log-text); padding: 12px; max-height: 240px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; }
.artifacts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.artifacts a { font-size: 12px; color: var(--text); text-decoration: none; background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 11px; }
.artifacts a:hover { border-color: var(--blue); }

/* Generated test cases preview (inside run card) */
.cases-dl { font-size: 12px; color: var(--blue); text-decoration: none; margin-left: 6px; }
.cases-dl:hover { text-decoration: underline; }
.cases-preview { max-height: 340px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.qcase { border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; background: var(--bg-2); }
.qcase-head { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; flex-wrap: wrap; font-size: 11px; }
.qc-id { font-family: var(--mono); color: var(--text-faint); }
.qc-type { background: rgba(59,130,246,.16); color: var(--blue); border-radius: 999px; padding: 1px 8px; }
.qc-dim { color: var(--text-dim); }
.qcase-text { font-size: 12.5px; color: var(--text); white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.qcase-extra { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--border); font-size: 12px; color: var(--text-dim); white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.qc-extra-label { display: inline-block; margin-right: 6px; font-size: 10px; font-weight: 600; color: var(--accent-2); }
.findings { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.finding { background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.finding .f-head { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.sev { font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.sev.high, .sev.critical { background: rgba(239,68,68,.16); color: var(--danger); }
.sev.medium { background: rgba(245,158,11,.16); color: var(--orange); }
.sev.low, .sev.info { background: rgba(34,197,94,.14); color: var(--green); }

/* 结果总结里的环图 + 成功率（复用 .donut 样式，尺寸缩小一点）。 */
.summary-chart { display: flex; align-items: center; gap: 20px; margin: 10px 0 4px; padding: 12px 14px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; flex-wrap: wrap; }
.summary-chart .donut { width: 118px; height: 118px; }
.sc-legend { display: flex; flex-direction: column; gap: 8px; }
.scl { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.scl b { font-weight: 700; margin-left: 2px; }
.sc-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.sc-dot.bad { background: var(--danger); }
.sc-dot.ok { background: var(--green); }

/* ---------- Composer (fixed bottom) ---------- */
.composer { border-top: 1px solid var(--border); background: var(--bg-1); padding: 12px 14%; display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 1200px) { .composer { padding: 12px 6%; } }
.composer-typebar { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }
.composer-typebar strong { color: var(--text); }
.ctb-config { margin-left: auto; background: transparent; border: 1px solid var(--border); color: var(--text-dim); border-radius: 7px; padding: 4px 10px; cursor: pointer; font-size: 12px; }
.config-panel { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; max-height: 46vh; overflow-y: auto; }
.cfg-title { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-faint); margin: 4px 2px 8px; }
.type-options { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px dashed var(--border); }
.opt-group { display: flex; flex-direction: column; gap: 7px; }
.opt-group > .opt-label { font-size: 12px; color: var(--text-dim); }
.opt-group > .opt-label .req { color: var(--orange); margin-left: 4px; font-size: 11px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  background: var(--bg-3); border: 1px solid var(--border); color: var(--text-dim);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 12.5px;
  transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { color: var(--text); }
.chip.active { background: rgba(59,130,246,.16); border-color: var(--blue); color: var(--blue); }
.opt-select { background: var(--bg-3); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 9px 12px; font-size: 13px; align-self: flex-start; min-width: 200px; }
.cfg-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 1000px) { .cfg-grid { grid-template-columns: repeat(2, 1fr); } }
.cfg { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-dim); }
.composer textarea { width: 100%; resize: none; background: var(--bg-2); border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: 12px 14px; font-size: 14px; font-family: var(--sans); outline: none; }
.composer textarea:focus { border-color: var(--blue); }
.composer-actions { display: flex; align-items: center; justify-content: space-between; }
.composer-hint { color: var(--text-faint); font-size: 12px; }

/* ---------- Pricing ---------- */
.pricing-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 18px; }
@media (max-width: 1100px) { .pricing-grid { grid-template-columns: repeat(2, 1fr); } }
.price-card { background: var(--bg-1); border: 1px solid var(--border); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.price-card.active { border-color: var(--blue); }
.price-card.enterprise { border-color: var(--orange); }
.price-card h3 { margin: 0; font-size: 17px; }
.price-card .price { font-size: 22px; font-weight: 700; }
.price-card .price small { font-size: 12px; color: var(--text-faint); font-weight: 400; }
.price-card ul { margin: 0; padding-left: 18px; color: var(--text-dim); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.price-card .tag { align-self: flex-start; font-size: 11px; padding: 2px 9px; border-radius: 999px; background: var(--bg-3); color: var(--text-dim); }
.price-card.active .tag { background: rgba(59,130,246,.18); color: var(--blue); }
.price-card[data-plan] { cursor: pointer; }
.price-card ul { flex: 1; }
.price-btn { margin-top: 6px; width: 100%; }
.plan-hint { margin-top: 14px; min-height: 18px; color: var(--blue); font-size: 13px; }

/* Back button on profile / subscription / admin views */
.view-back { align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; margin-bottom: 14px; }

/* ---------- Profile ---------- */
.profile-form { max-width: 460px; display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.profile-form .field input:disabled { opacity: .6; cursor: not-allowed; }
.profile-actions { display: flex; align-items: center; gap: 12px; margin-top: 4px; }

/* ---------- Admin ---------- */
.admin-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.admin-search {
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 7px 12px; font-size: 13px; outline: none; min-width: 240px;
}
.admin-search:focus { border-color: var(--blue); box-shadow: var(--ring); }
.admin-grid { display: grid; grid-template-columns: 1fr; gap: 18px; margin-top: 16px; }
.admin-users { overflow-x: auto; }
.admin-users table { min-width: 720px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-faint); font-weight: 500; font-size: 12px; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--bg-2); }
tbody tr.active { background: var(--bg-3); }
.admin-detail { background: var(--bg-1); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.run-row { padding: 10px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; background: var(--bg-2); }
.run-row .rr-obj { font-size: 13px; margin-bottom: 4px; }
.run-row .rr-meta { font-size: 11px; color: var(--text-faint); }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { width: 420px; max-width: 92%; background: var(--bg-1); border: 1px solid var(--border); border-radius: 14px; padding: 22px; }
.modal h3 { margin: 0 0 8px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.modal.wide { width: 840px; max-width: 94%; max-height: 86vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.modal-head h3 { margin: 0; }
.modal-head-actions { display: flex; gap: 8px; }
.btn.small { padding: 4px 11px; font-size: 12px; }
.report-view { overflow: auto; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 18px 22px; line-height: 1.6; }
.report-view h1 { font-size: 20px; margin: 2px 0 14px; }
.report-view h2 { font-size: 16px; margin: 20px 0 8px; border-bottom: 1px solid var(--border); padding-bottom: 5px; }
.report-view h3 { font-size: 14px; margin: 14px 0 6px; }
.report-view p { margin: 8px 0; }
.report-view ul { margin: 6px 0; padding-left: 20px; }
.report-view li { margin: 3px 0; }
.report-view code { background: var(--bg-1); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-size: 12px; }
.report-view .md-table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 13px; }
.report-view .md-table th, .report-view .md-table td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.report-view .md-table th { background: var(--bg-1); }
.art-btn { font-size: 12px; color: var(--text); background: var(--bg-2); border: 1px solid var(--blue); border-radius: 8px; padding: 6px 11px; cursor: pointer; }
.art-btn:hover { background: var(--blue); color: #fff; }

/* ---------- Theme toggle (floating) ---------- */
.theme-toggle {
  position: fixed; top: 14px; right: 16px; z-index: 100;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg-2); color: var(--text);
  cursor: pointer; font-size: 16px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
  transition: background .15s, border-color .15s, transform .1s;
}
.theme-toggle:hover { background: var(--bg-3); border-color: var(--blue); }
.theme-toggle:active { transform: scale(.92); }

/* ---------- Top-right bar (subscription + user info) ---------- */
.topbar {
  position: fixed; top: 12px; right: 66px; z-index: 40;
  display: flex; align-items: center; gap: 10px;
}
.topbar-btn {
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: 8px 16px; cursor: pointer; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-sm); transition: background .15s, border-color .15s, transform .1s;
}
.topbar-btn:hover { background: var(--bg-3); border-color: var(--blue); transform: translateY(-1px); }
.topbar-btn.active { background: rgba(59,130,246,.14); border-color: var(--blue); color: var(--blue); }
.account-chip.active { border-color: var(--blue); box-shadow: var(--ring); }
.account-chip {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 14px 4px 4px; box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, transform .1s;
}
.account-chip:hover { border-color: var(--blue); background: var(--bg-3); transform: translateY(-1px); }
.account-chip .account-meta { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.account-chip #userName { font-size: 13px; }
.account-chip .plan-tag { font-size: 10px; color: var(--orange); }
@media (max-width: 760px) {
  .topbar .account-meta, .topbar-btn { display: none; }
  .topbar { right: 60px; gap: 8px; }
}

/* ============================================================
   Commercial polish layer
   ============================================================ */

/* Ambient depth on the page background */
body {
  background:
    radial-gradient(920px 520px at 80% -8%, rgba(99,102,241,.12), transparent 60%),
    radial-gradient(820px 520px at 2% 2%, rgba(59,130,246,.09), transparent 55%),
    var(--bg);
  background-attachment: fixed;
}

/* Typography refinement */
h1, h2, h3 { letter-spacing: -0.012em; }
.login-title, .hero h1, .view-head h2 { font-weight: 700; }

/* Brand + hero wordmark as gradient text */
.brand strong, .login-title, .hero h1 {
  background: var(--grad-text);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}

/* Buttons: gradient primary, soft lift, focus ring */
.btn { border-radius: 10px; font-weight: 500; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn.primary { background: var(--grad-primary); border: none; color: #fff; box-shadow: var(--glow); }
.btn.primary:hover { background: var(--grad-primary); filter: brightness(1.08); transform: translateY(-1px); }
.btn.primary:active { transform: translateY(0); filter: brightness(1); }
.btn.big { border-radius: 12px; letter-spacing: .01em; }

/* Inputs: focus ring */
.field input:focus, .composer textarea:focus,
.cfg input:focus, .cfg select:focus, .opt-select:focus {
  border-color: var(--blue); box-shadow: var(--ring);
}

/* Sidebar subtle vertical gradient */
.sidebar { background: linear-gradient(180deg, var(--bg-1), var(--bg)); }
.side-type.active { box-shadow: inset 3px 0 0 var(--blue); }

/* Login screen: premium glow + elevated card */
.login-view { background: radial-gradient(760px 440px at 50% -12%, rgba(99,102,241,.20), transparent 62%); }
.login-card { box-shadow: var(--shadow-lg); border-radius: 18px; }
.login-logo { box-shadow: 0 0 44px rgba(99,102,241,.42); }

/* Avatars use the brand gradient */
.avatar { background: var(--grad-primary); }
.msg .m-avatar.user { background: var(--grad-primary); }

/* Cards: elevation + hover lift + accent strips */
.type-card, .price-card, .run-card, .metric { box-shadow: var(--shadow-sm); }
.type-card:hover { box-shadow: var(--shadow-md); }
.price-card { position: relative; overflow: hidden; }
.price-card.active { box-shadow: 0 12px 32px rgba(79,110,247,.20); }
.price-card.active::before, .price-card.enterprise::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
}
.price-card.active::before { background: var(--grad-primary); }
.price-card.enterprise::before { background: linear-gradient(135deg, var(--orange), #f97316); }

/* Chips active uses gradient tint */
.chip.active { background: linear-gradient(135deg, rgba(79,140,255,.18), rgba(99,102,241,.18)); }

/* Status pill weight */
.status-pill { font-weight: 600; }

/* Composer elevation above the page */
.composer { box-shadow: 0 -10px 26px rgba(0,0,0,.20); }
[data-theme="light"] .composer { box-shadow: 0 -10px 26px rgba(20,30,55,.06); }

/* Modal elevation */
.modal { box-shadow: var(--shadow-lg); }

/* Refined scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--bg-3) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   Commercial polish v2 — sharper light mode, premium micro-details
   ============================================================ */

/* Light mode: more depth + crisper surfaces so it doesn't look flat */
[data-theme="light"] body {
  background:
    radial-gradient(960px 540px at 82% -10%, rgba(99,102,241,.10), transparent 60%),
    radial-gradient(820px 520px at 0% 0%, rgba(59,130,246,.08), transparent 55%),
    linear-gradient(180deg, #f7f9fc 0%, #eef1f6 100%);
}
[data-theme="light"] .sidebar {
  background: linear-gradient(180deg, #ffffff, #f4f6fa);
  border-right-color: #e3e8ef;
}
[data-theme="light"] .type-card,
[data-theme="light"] .price-card,
[data-theme="light"] .run-card,
[data-theme="light"] .admin-detail,
[data-theme="light"] .login-card,
[data-theme="light"] .msg .bubble {
  background: #ffffff;
  border-color: #e6eaf0;
}
/* Light mode: only neutral buttons become white cards. Colored CTAs keep their
   fill so their white text stays legible (otherwise white-on-white = invisible). */
[data-theme="light"] .btn:not(.primary):not(.danger):not(.warn) { background: #ffffff; }
[data-theme="light"] .btn:not(.primary):not(.danger):not(.warn):hover { background: #f1f4f9; }
[data-theme="light"] .btn.primary { background: var(--grad-primary); color: #fff; }
[data-theme="light"] .btn.primary:hover { background: var(--grad-primary); }
[data-theme="light"] .btn.danger { background: var(--danger); color: #fff; }
[data-theme="light"] .btn.warn { background: var(--orange); color: #1a1205; }

/* Sidebar nav: animated accent bar on active/hover */
.nav-item { position: relative; transition: background .15s, color .15s; }
.nav-item::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 0; border-radius: 999px; background: var(--grad-primary);
  transition: height .18s ease;
}
.nav-item.active::before { height: 60%; }
.nav-item.active { font-weight: 600; }

/* Section/view headers: stronger hierarchy + subtle divider */
.view.scroll .view-head { padding-bottom: 14px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.view-head h2 { font-size: 19px; }

/* Cards: smoother hover transitions everywhere */
.type-card, .price-card, .run-card, .metric, .finding, .artifacts a {
  transition: border-color .15s ease, transform .12s ease, box-shadow .18s ease, background .15s ease;
}
.price-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.metric:hover { border-color: var(--blue); }

/* Admin table: premium data-grid feel — sticky header, zebra, hover accent */
#adminUsersTable { border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
#adminUsersTable thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg-2); backdrop-filter: blur(6px);
  text-transform: uppercase; letter-spacing: .04em; font-size: 11px;
  border-bottom: 1px solid var(--border);
}
#adminUsersTable tbody tr:nth-child(even) { background: color-mix(in srgb, var(--bg-2) 45%, transparent); }
#adminUsersTable tbody tr:hover { background: color-mix(in srgb, var(--blue) 10%, transparent); box-shadow: inset 3px 0 0 var(--blue); }
#adminUsersTable tbody tr.active { background: color-mix(in srgb, var(--blue) 16%, transparent); box-shadow: inset 3px 0 0 var(--blue); }
#adminUsersTable td { white-space: nowrap; }

/* Status pills get a soft tinted fill (not just outline) */
.status-pill { background: color-mix(in srgb, currentColor 14%, transparent); }

/* Theme toggle: glassy, refined, gentle rotate on hover */
.theme-toggle {
  width: 40px; height: 40px;
  background: color-mix(in srgb, var(--bg-2) 78%, transparent);
  backdrop-filter: blur(10px) saturate(1.2);
  box-shadow: var(--shadow-md);
}
.theme-toggle:hover { transform: rotate(18deg); border-color: var(--blue); box-shadow: var(--glow); }
.theme-toggle:active { transform: rotate(0) scale(.9); }

/* Profile form card-ifies for a more finished look */
.profile-form {
  background: var(--bg-1); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px; box-shadow: var(--shadow-sm);
}
.profile-form .field span { font-weight: 500; }

/* Primary buttons: a touch more premium with layered sheen */
.btn.primary { position: relative; overflow: hidden; }
.btn.primary::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.18), transparent 45%);
  pointer-events: none;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ============================================================
   Result dashboard (online HTML view of test cases + charts)
   ============================================================ */
/* flex:0 1 auto so the modal hugs its content (no blank gap when short) but
   still shrinks + scrolls when the case list is tall. */
.result-view { overflow: auto; padding: 4px 2px; flex: 0 1 auto; min-height: 0; }
.result-meta { display: flex; flex-wrap: wrap; gap: 10px 32px; padding: 12px 16px; margin: 2px 0 14px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-sm); }
.result-meta .rm { display: flex; flex-direction: column; gap: 3px; }
.result-meta .rm span { font-size: 11px; color: var(--text-faint); }
.result-meta .rm b { font-size: 14px; color: var(--text); font-weight: 600; }
.result-summary { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; margin: 4px 0 10px; }
.donut { width: 140px; height: 140px; flex-shrink: 0; }
.donut-num { font-size: 24px; font-weight: 700; fill: var(--text); }
.donut-label { font-size: 11px; fill: var(--text-dim); }
.result-cards { display: flex; gap: 12px; flex-wrap: wrap; }
.rc { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; min-width: 104px; box-shadow: var(--shadow-sm); }
.rc span { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.rc strong { font-size: 21px; }
.rc.bad strong { color: var(--danger); }
.rc.ok strong { color: var(--green); }
.result-h { margin: 18px 0 8px; font-size: 14px; }
.result-cat { width: 100%; border-collapse: collapse; font-size: 13px; }
.result-cat th, .result-cat td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.result-cat th { color: var(--text-faint); font-weight: 500; font-size: 12px; }
.mini-bar { display: inline-block; width: 110px; height: 7px; background: var(--bg-3); border-radius: 999px; overflow: hidden; margin-right: 8px; vertical-align: middle; }
.mini-bar span { display: block; height: 100%; background: var(--danger); }
.result-filter { display: flex; gap: 8px; margin: 4px 0 12px; }
.case-list { display: flex; flex-direction: column; gap: 10px; }
.case { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--bg-1); border-left: 3px solid var(--border); }
.case.bad { border-left-color: var(--danger); }
.case.ok { border-left-color: var(--green); }
.case-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; font-size: 12px; flex-wrap: wrap; }
.case-idx { color: var(--text-faint); font-family: var(--mono); }
.case-cat { color: var(--text-dim); }
.case-verdict { margin-left: auto; font-weight: 600; }
.case-verdict.bad { color: var(--danger); }
.case-verdict.ok { color: var(--green); }
.case-q { font-size: 13px; margin: 2px 0; word-break: break-word; }
.case details { margin-top: 6px; }
.case summary { cursor: pointer; color: var(--blue); font-size: 13px; }
.case pre { white-space: pre-wrap; word-break: break-word; background: var(--log-bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: 12px; color: var(--log-text); margin: 6px 0 0; max-height: 320px; overflow: auto; }

/* Private-model inputs: monospace for URLs / model ids / keys */
#cfgCustomUrl, #cfgCustomModel, #cfgCustomKey { font-family: var(--mono); font-size: 12px; }

/* 新建任务后闪一下输入框边框。用 outline 而不是 box-shadow，避免和 :focus
   已有的静态 ring 叠在一起互相干扰；颜色走 var(--blue) 以适配浅色主题。
   全局的 prefers-reduced-motion 规则会自动关掉这个动画。 */
@keyframes composer-flash {
  from { outline: 2px solid var(--blue); outline-offset: 0; }
  to   { outline: 2px solid transparent; outline-offset: 8px; }
}
.composer textarea.flash { animation: composer-flash .7s ease-out; }
