/* ============================================================
   Qwen 控制台 —— 样式
   设计纪律(导师评审定的,别乱改):
     * 只做一套浅色。中文小字在深底上会发虚,户外更看不清。
       唯一的深色块是日志面板,一眼有"机房控制台"的味道。
     * 语义色压深一档,不用 #22C55E 那种亮色 —— 压深了对比度过 4.5:1,
       而且不显玩具。
     * 绿只表示状态,蓝只表示"可以点的东西",红只表示失败/耗尽。
       三者绝不混用。
     * 卡片靠 1px 边框,不靠阴影。不要彩色阴影、发光、玻璃拟态。
     * 所有数字用等宽 + tabular-nums,倒计时跳秒时不会左右抖。
   ============================================================ */

:root {
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --surface-sunken: #F1F3F6;
  --border: #E4E7EC;
  --border-strong: #CDD3DB;

  --ink: #16191D;
  --ink-2: #5A6472;
  --ink-3: #8B94A1;

  --ok: #128A4A;   --ok-bg: #E8F5EE;
  --warn: #B26A00; --warn-bg: #FDF3E2;
  --bad: #C4342B;  --bad-bg: #FCEDEC;
  --busy: #1B62D6; --busy-bg: #EAF1FD;
  --idle: #8B94A1;

  --brand: #1B62D6;
  --brand-hover: #1750B4;

  --log-bg: #12161C;
  --log-ink: #C7D0DA;
  --log-dim: #6C7684;

  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC",
          "Microsoft YaHei", "Source Han Sans SC", "Noto Sans SC", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --sh-2: 0 4px 12px rgba(16, 24, 40, .08);
  --sh-3: 0 12px 32px rgba(16, 24, 40, .14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------------------------------------------------------------- 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: 56px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-size: 16px; font-weight: 600; letter-spacing: .01em; }
.topbar__quota {
  margin-left: auto;
  font-size: 13px; color: var(--ink-2);
  display: flex; align-items: baseline; gap: 6px;
}
.topbar__quota b { font-size: 16px; font-weight: 600; color: var(--ink); font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- 布局 */
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
.cols { display: grid; gap: 24px; grid-template-columns: 1fr; }
@media (min-width: 960px) {
  .cols { grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr); align-items: start; }
  .col-side { position: sticky; top: 72px; }
}
.sec-head { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; }
.sec-head h2 { font-size: 16px; font-weight: 600; margin: 0; }
.sec-head .spacer { margin-left: auto; }

/* ---------------------------------------------------------------- 卡片 */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
@media (max-width: 640px) { .card { padding: 16px; } }

/* ---------------------------------------------------------------- 按钮 */
.btn {
  font: inherit; font-size: 14px; font-weight: 500;
  height: 36px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .12s, border-color .12s, color .12s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-sunken); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn--danger { color: var(--bad); border-color: #EBC3C0; }
.btn--danger:hover:not(:disabled) { background: var(--bad-bg); }
.btn--ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-sunken); color: var(--ink); }
.btn--sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn--block { width: 100%; }
@media (max-width: 640px) { .btn { height: 44px; } .btn--sm { height: 34px; } }

/* ---------------------------------------------------------------- 徽章 */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 500; line-height: 1;
  padding: 5px 8px; border-radius: 6px;
  background: var(--surface-sunken); color: var(--ink-2);
}
.badge--live { background: var(--ok-bg); color: var(--ok); }
.badge--busy { background: var(--busy-bg); color: var(--busy); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--bad  { background: var(--bad-bg);  color: var(--bad); }
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------------------------------------------------------------- hero */
.hero__head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.hero__title { font-size: 20px; font-weight: 600; margin: 0 0 2px; }
.hero__sub { color: var(--ink-2); font-size: 13px; }
.hero__body { margin-top: 16px; }

.field {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-top: 1px solid var(--border);
}
.field__k { width: 62px; flex: none; color: var(--ink-2); font-size: 13px; }
.field__v {
  flex: 1; min-width: 0;
  font-family: var(--mono); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hero__acts { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
@media (max-width: 640px) {
  .hero__acts .btn { flex: 1 1 auto; }
}

/* 停止按钮"就地变身"确认 —— 比弹窗轻,又能防误触 */
.stop-confirm {
  display: flex; gap: 8px; align-items: center;
  padding: 8px 10px; border-radius: 8px;
  background: var(--bad-bg); border: 1px solid #EBC3C0;
  font-size: 13px; color: var(--bad);
}
.stop-confirm__txt { flex: 1; }

/* ---------------------------------------------------------------- 五步 */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.step {
  display: grid; grid-template-columns: 20px 1fr auto;
  align-items: center; gap: 10px;
  padding: 7px 0; font-size: 14px; color: var(--ink-3);
}
.step__dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--border-strong); justify-self: center;
}
.step[data-s="done"] { color: var(--ink-2); }
.step[data-s="done"] .step__dot { background: var(--ok); }
.step[data-s="now"] { color: var(--ink); font-weight: 500; }
.step[data-s="now"] .step__dot {
  background: var(--busy); box-shadow: 0 0 0 4px var(--busy-bg);
  animation: pulse 1.6s ease-in-out infinite;
}
.step[data-s="fail"] { color: var(--bad); font-weight: 500; }
.step[data-s="fail"] .step__dot { background: var(--bad); }
.step__t { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(27, 98, 214, .10); } }
@media (prefers-reduced-motion: reduce) {
  .step[data-s="now"] .step__dot { animation: none; }
  * { transition: none !important; }
}

.note { font-size: 13px; color: var(--ink-2); margin-top: 12px; }
.note--warn { color: var(--warn); }
.note--bad { color: var(--bad); }

/* ---------------------------------------------------------------- 账号卡 */
.acct-list { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 760px) {
  .acct-list { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}
.acct {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
/* 左边一条蓝线 = "这个是活的"。比整块变色克制得多。 */
.acct[data-state="running"] { border-color: #BBD3F7; box-shadow: inset 3px 0 0 var(--busy); }
.acct[data-state="dead"] { opacity: .72; }
.acct__top { display: flex; align-items: center; gap: 8px; }
.acct__name { font-size: 16px; font-weight: 600; margin: 0; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct__meta { font-size: 12px; color: var(--ink-3); font-family: var(--mono); }
.acct__acts { display: flex; gap: 8px; margin-top: auto; }
.acct__acts .btn { flex: 1; }
.acct__acts .btn--icon { flex: none; width: 36px; padding: 0; }
.acct__msg { font-size: 13px; color: var(--ink-2); }

/* ---------------------------------------------------------------- 额度条 */
.qbar { display: grid; gap: 6px; }
.qbar__head { display: flex; align-items: baseline; gap: 8px; font-size: 13px; color: var(--ink-2); }
.qbar__num {
  margin-left: auto; font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 16px; font-weight: 600; color: var(--ink);
}
.qbar__unit { font-size: 12px; font-weight: 400; color: var(--ink-3); font-family: var(--font); }
.qbar__track { height: 8px; border-radius: 999px; background: #E9ECF1; overflow: hidden; }
.qbar__fill {
  height: 100%; border-radius: 999px; background: var(--q, var(--ok));
  transition: width .6s cubic-bezier(.2, .7, .3, 1);
}
.qbar__foot { font-size: 12px; color: var(--ink-3); }
.qbar[data-level="ok"]   { --q: var(--ok); }
.qbar[data-level="low"]  { --q: var(--warn); }
.qbar[data-level="crit"] { --q: var(--bad); }
.qbar[data-level="out"]  { --q: #C3C9D2; }
.qbar[data-level="out"] .qbar__num { color: var(--bad); }
@media (max-width: 640px) { .qbar__track { height: 10px; } }

/* ---------------------------------------------------------------- 日志 */
.logpanel {
  background: var(--log-bg); border: 1px solid #232A33;
  border-radius: 12px; overflow: hidden; position: relative;
}
.logpanel__bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid #232A33;
  font-size: 13px; color: var(--log-ink);
}
.logpanel__toggle {
  background: none; border: 0; color: var(--log-ink); font: inherit;
  display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 0;
}
.logpanel__last { color: var(--log-dim); font-size: 12px; max-width: 180px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logpanel__tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.logpanel__follow { color: var(--log-dim); font-size: 12px; }
.logpanel__search {
  background: #1B222B; border: 1px solid #2A323D; border-radius: 6px;
  color: var(--log-ink); font: inherit; font-size: 12px;
  padding: 4px 8px; width: 110px;
}
.logpanel__search::placeholder { color: var(--log-dim); }
.logpanel__body {
  margin: 0; padding: 12px 14px; height: min(52vh, 420px);
  overflow: auto; overscroll-behavior: contain;
  font-family: var(--mono); font-size: 13px; line-height: 1.55;
  color: var(--log-ink); white-space: pre-wrap; word-break: break-word;
}
.logpanel__body .ln { display: block; }
.logpanel__body .ln--err {
  background: rgba(196, 52, 43, .16);
  box-shadow: inset 3px 0 0 var(--bad);
  padding-left: 8px; margin-left: -8px;
}
.logpanel__body .ln--hit { background: rgba(178, 106, 0, .22); }
.logpanel__jump {
  position: absolute; right: 12px; bottom: 12px;
  background: var(--brand); border: 0; color: #fff; border-radius: 999px;
  height: 32px; padding: 0 14px; font: inherit; font-size: 13px; cursor: pointer;
  box-shadow: var(--sh-2);
}
@media (max-width: 720px) {
  .logpanel[data-open="false"] .logpanel__body { display: none; }
  .logpanel[data-open="false"] .logpanel__tools { display: none; }
  .logpanel[data-open="true"] { position: fixed; inset: 0; z-index: 50; border-radius: 0; }
  .logpanel[data-open="true"] .logpanel__body { height: calc(100dvh - 88px); }
  .logpanel[data-open="true"] .logpanel__search { width: 90px; }
}

/* ---------------------------------------------------------------- 弹窗 */
dialog {
  border: 0; border-radius: 12px; padding: 0; box-shadow: var(--sh-3);
  max-width: 520px; width: calc(100% - 32px); color: var(--ink);
}
dialog::backdrop { background: rgba(16, 24, 40, .35); }
.dlg__body { padding: 20px; }
.dlg__title { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.dlg__hint { font-size: 13px; color: var(--ink-2); margin: 0 0 12px; }
.dlg__acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
textarea, input[type="text"], input[type="password"], input[type="number"] {
  font: inherit; width: 100%; padding: 9px 11px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--ink);
}
textarea { font-family: var(--mono); font-size: 12px; min-height: 110px; resize: vertical; }
input:focus, textarea:focus, .btn:focus-visible {
  outline: 2px solid var(--busy); outline-offset: 1px;
}
.err { color: var(--bad); font-size: 13px; margin-top: 8px; min-height: 18px; }

/* ---------------------------------------------------------------- 登录 */
.gate {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.gate__box { width: 100%; max-width: 340px; }
.gate__title { font-size: 20px; font-weight: 600; margin: 0 0 4px; }
.gate__hint { color: var(--ink-2); font-size: 13px; margin: 0 0 20px; }

/* ---------------------------------------------------------------- 骨架屏 */
.skel {
  background: linear-gradient(90deg, #EDEFF3 25%, #F5F6F8 37%, #EDEFF3 63%);
  background-size: 400% 100%; animation: sk 1.4s ease infinite;
  border-radius: 8px;
}
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------------------------------------------------------------- 空状态 */
.empty { text-align: center; padding: 40px 20px; }
.empty__t { font-size: 16px; font-weight: 600; margin: 0 0 6px; }
.empty__d { color: var(--ink-2); font-size: 13px; margin: 0 0 16px; }
.empty code {
  display: block; font-family: var(--mono); font-size: 12px; color: var(--ink-2);
  background: var(--surface-sunken); border-radius: 6px; padding: 8px; margin-top: 8px;
  word-break: break-all;
}

/* ---------------------------------------------------------------- 提示条 */
.strip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px;
}
.strip--warn { background: var(--warn-bg); color: var(--warn); }
.strip--bad { background: var(--bad-bg); color: var(--bad); }
.strip--busy { background: var(--busy-bg); color: var(--busy); }
.strip .btn { margin-left: auto; }
