/* LobsterAI 控制台 —— 单文件样式，深浅双主题，响应式 */
:root {
  --accent: #e8552d;
  --accent-soft: rgba(232, 85, 45, .12);
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --blue: #3b82f6;
  --radius: 14px;
  --radius-sm: 9px;
}
:root, [data-theme="dark"] {
  --bg: #0e1116;
  --bg-elev: #161b22;
  --bg-elev2: #1c232d;
  --border: #2a313c;
  --text: #e6e9ee;
  --text-dim: #9aa4b2;
  --text-faint: #6b7685;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f5f6f8;
  --bg-elev: #ffffff;
  --bg-elev2: #f0f2f5;
  --border: #e2e5ea;
  --text: #1d2430;
  --text-dim: #5b6573;
  --text-faint: #8a94a3;
  --shadow: 0 10px 30px rgba(30,40,60,.10);
  color-scheme: light;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
/* 保证 hidden 属性始终生效（.login-wrap 的 display:grid 会覆盖 UA 默认隐藏） */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
input, select, textarea {
  font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--bg-elev2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px; width: 100%;
  outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 84px; }
label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 5px; font-weight: 500; }
.field { margin-bottom: 14px; }
.hint { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--bg-elev2); color: var(--text);
  border-radius: var(--radius-sm); padding: 8px 14px; cursor: pointer;
  font-size: 13.5px; transition: transform .08s, opacity .15s, background .15s;
  white-space: nowrap;
}
.btn:hover { opacity: .88; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 7px; }

/* 登录 */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), transparent); }
.login-card { width: 100%; max-width: 360px; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 34px 30px; box-shadow: var(--shadow); }
.login-logo { font-size: 44px; text-align: center; }
.login-card h1 { text-align: center; font-size: 20px; margin: 10px 0 2px; }
.login-sub { text-align: center; color: var(--text-dim); font-size: 12.5px; margin-bottom: 22px; }
.login-card input { margin-bottom: 14px; }
.login-err { color: var(--red); font-size: 12.5px; min-height: 18px; margin-top: 10px; text-align: center; }

/* 布局 */
#app-view { display: flex; min-height: 100vh; }
.sidebar {
  width: 214px; flex-shrink: 0; background: var(--bg-elev); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 10px 18px; }
.brand-logo { font-size: 24px; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: var(--radius-sm); color: var(--text-dim); font-size: 14px;
}
.nav-item:hover { background: var(--bg-elev2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-ico { width: 20px; text-align: center; }
.sidebar-foot { display: flex; gap: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
.sidebar-foot .btn { flex: 1; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 16px 26px;
  border-bottom: 1px solid var(--border); background: var(--bg);
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 17px; font-weight: 700; }
.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.content { padding: 24px 26px 60px; max-width: 1240px; width: 100%; }
.nav-toggle { display: none; }

/* 卡片 / 栅格 */
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.card + .card { margin-top: 18px; }
.card-title { font-size: 14px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card-title .spacer { flex: 1; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.stat-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat-label { font-size: 12.5px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--text-faint); margin-top: 3px; }

/* 表格 */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--text-dim); font-weight: 600; font-size: 12px;
  padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-elev2); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.right { text-align: right; }

/* 徽标 */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge-green { background: rgba(34,197,94,.14); color: var(--green); }
.badge-amber { background: rgba(245,158,11,.15); color: var(--amber); }
.badge-red { background: rgba(239,68,68,.14); color: var(--red); }
.badge-blue { background: rgba(59,130,246,.14); color: var(--blue); }
.badge-gray { background: var(--bg-elev2); color: var(--text-dim); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green); } .dot-amber { background: var(--amber); }
.dot-red { background: var(--red); } .dot-gray { background: var(--text-faint); }

.chip { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--bg-elev2);
  border: 1px solid var(--border); font-size: 11.5px; margin: 1px 3px 1px 0; color: var(--text-dim); }

/* 工具条 */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .grow { flex: 1; }
.toolbar select, .toolbar input { width: auto; padding: 7px 10px; font-size: 13px; }

/* 进度条 */
.bar { height: 6px; border-radius: 99px; background: var(--bg-elev2); overflow: hidden; min-width: 70px; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--green); }
.bar.amber > i { background: var(--amber); } .bar.red > i { background: var(--red); }
.bar.gray > i { background: var(--text-faint); }
.bar.blue > i { background: var(--blue); }
.quota-wrap { min-width: 120px; }
.quota-meta { font-size: 11px; color: var(--text-faint); margin-top: 3px; font-variant-numeric: tabular-nums; }

/* 图表 */
.chart { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-top: 10px; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; height: 100%; min-width: 0; }
.chart .bar-v { width: 100%; border-radius: 4px 4px 0 0; background: var(--accent); min-height: 2px;
  position: relative; transition: opacity .15s; }
.chart .bar-v:hover { opacity: .8; }
.chart .bar-fail { width: 100%; border-radius: 0 0 4px 4px; background: var(--red); min-height: 0; }
.chart-labels { display: flex; gap: 4px; margin-top: 6px; }
.chart-labels span { flex: 1; text-align: center; font-size: 10px; color: var(--text-faint);
  overflow: hidden; white-space: nowrap; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 100;
  display: grid; place-items: center; padding: 18px; backdrop-filter: blur(2px); }
.modal { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal.wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 15.5px; }
.modal-head .x { margin-left: auto; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }
.steps { display: flex; gap: 8px; margin-bottom: 16px; }
.steps .step { flex: 1; text-align: center; font-size: 12.5px; color: var(--text-faint); padding: 7px;
  border-radius: var(--radius-sm); background: var(--bg-elev2); cursor: pointer; }
.steps .step.on { color: var(--accent); font-weight: 600; box-shadow: inset 0 0 0 1px var(--accent); }

/* toast */
#toast-root { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--bg-elev2); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 10px 18px; box-shadow: var(--shadow); font-size: 13.5px;
  animation: toast-in .25s ease; max-width: 90vw; }
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

/* 测试台 */
.chat-box { display: flex; flex-direction: column; gap: 12px; }
.chat-msg { border-radius: var(--radius-sm); padding: 12px 15px; max-width: 92%; white-space: pre-wrap; word-break: break-word; }
.chat-msg.user { background: var(--accent-soft); align-self: flex-end; border: 1px solid var(--accent); }
.chat-msg.ai { background: var(--bg-elev2); align-self: flex-start; border: 1px solid var(--border); width: 92%; }
.chat-msg.ai.thinking { opacity: .75; }
.chat-log { display: flex; flex-direction: column; gap: 10px; min-height: 200px; max-height: 56vh; overflow-y: auto; padding: 4px; }
.chat-usage { font-size: 12px; color: var(--text-faint); margin-top: 8px; }

.empty { text-align: center; color: var(--text-faint); padding: 46px 20px; font-size: 13.5px; }
.empty .big { font-size: 38px; display: block; margin-bottom: 10px; }
.section-gap { margin-top: 18px; }
.flex { display: flex; gap: 8px; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; }
code.kbd { background: var(--bg-elev2); border: 1px solid var(--border); border-radius: 6px;
  padding: 1px 7px; font-size: 12px; }
.copy-val { display: flex; gap: 8px; align-items: center; }
.copy-val input { font-family: ui-monospace, monospace; font-size: 12.5px; }
.warn-box { background: rgba(245,158,11,.12); border: 1px solid var(--amber); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 12.5px; color: var(--text-dim); margin-bottom: 14px; }
.token-cell { min-width: 130px; }

/* 响应式 */
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 50;
    transform: translateX(-100%); transition: transform .2s; width: 230px;
  }
  .sidebar.open { transform: none; }
  .nav-toggle { display: inline-flex; }
  .content { padding: 16px 14px 60px; }
  .topbar { padding: 12px 14px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-value { font-size: 21px; }
}
