/* ==========================================================================
   CodeArts2API 控制台样式
   --------------------------------------------------------------------------
   约束（改动前请先读 docs/adr/0002-console-strict-csp.md）：
   * CSP 为 style-src 'self' / img-src 'none'：不得引用外部字体、图片、
     @import 或 url(...)；所有图标都用内联 SVG，颜色一律走 CSS 变量。
   * HTML 不得出现内联 style 属性，因此布局/尺寸只能靠这里的类。
   * 只用系统字体，离线可用。
   ========================================================================== */

:root{
  color-scheme:dark;

  /* 表面：靠明度差分层，而不是靠描边和阴影 */
  --bg:#0c0e14;
  --bg-soft:#14171f;
  --surface:#14171f;
  --surface-2:#1a1e28;
  --surface-3:#202531;
  --line:#262c3a;
  --line-2:#343c4e;

  /* 文字 */
  --text:#e8ebf2;
  --text-2:#a8b0c2;
  --text-3:#8892a6;

  /* 强调与语义色 */
  --accent:#5b7cfa;
  --accent-text:#9aafff;
  --accent-solid:#4565db;
  --accent-solid-hover:#5271eb;
  --accent-soft:rgba(91,124,250,.13);
  --ok:#3ddc97;
  --ok-soft:rgba(61,220,151,.12);
  --ok-line:rgba(61,220,151,.28);
  --warn:#f5b545;
  --warn-soft:rgba(245,181,69,.12);
  --warn-line:rgba(245,181,69,.30);
  --err:#f4717d;
  --err-soft:rgba(244,113,125,.12);
  --err-line:rgba(244,113,125,.30);

  /* 几何 */
  --r-xs:6px;
  --r-sm:8px;
  --r-md:10px;
  --r-lg:11px;
  --sidebar-w:208px;
  --topbar-h:64px;

  --font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",
    Arial,"PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;
  --mono:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;
  --pop:0 18px 44px rgba(0,0,0,.55);
  --panel-shadow:0 1px 2px rgba(0,0,0,.15);
}

:root[data-theme="light"]{
  color-scheme:light;
  --bg:#f4f5f8;--bg-soft:#fff;--surface:#fff;--surface-2:#f8f9fb;--surface-3:#edf0f6;
  --line:#e2e5ec;--line-2:#cfd5e0;
  --text:#181d29;--text-2:#545c6e;--text-3:#687389;
  --accent:#3d5fe0;--accent-text:#3d5fe0;--accent-solid:#3d5fe0;--accent-solid-hover:#304fc9;--accent-soft:rgba(61,95,224,.09);
  --ok:#0c8051;--ok-soft:rgba(15,157,99,.09);--ok-line:rgba(15,157,99,.24);
  --warn:#98650c;--warn-soft:rgba(180,118,17,.09);--warn-line:rgba(180,118,17,.24);
  --err:#c23635;--err-soft:rgba(207,59,52,.08);--err-line:rgba(207,59,52,.24);
  --pop:0 12px 36px rgba(22,28,44,.15);--panel-shadow:0 1px 2px rgba(16,20,32,.04);
}

*,*::before,*::after{box-sizing:border-box}

html{-webkit-text-size-adjust:100%}

body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font:14px/1.55 var(--font);
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}

::selection{background:rgba(77,124,255,.35);color:#fff}

*{scrollbar-width:thin;scrollbar-color:var(--line-2) transparent}
::-webkit-scrollbar{width:10px;height:10px}
::-webkit-scrollbar-thumb{background:var(--line-2);border:2px solid var(--bg);border-radius:99px}
::-webkit-scrollbar-thumb:hover{background:#3a4459}
::-webkit-scrollbar-track{background:transparent}

a{color:var(--accent-text)}

:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:4px}

/* ===== 骨架：左侧栏 + 主列 ============================================== */

.app{
  display:grid;
  grid-template-columns:var(--sidebar-w) minmax(0,1fr);
  min-height:100vh;
}

.sidebar{
  position:sticky;
  top:0;
  align-self:start;
  height:100vh;
  display:flex;
  flex-direction:column;
  gap:16px;
  padding:0 8px 16px;
  background:var(--bg-soft);
  border-right:1px solid var(--line);
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
  padding:22px 9px 20px;
  border-bottom:1px solid var(--line);
  min-width:0;
}
.brand-mark{
  flex:none;
  display:grid;
  place-items:center;
  width:32px;
  height:32px;
  border-radius:9px;
  background:var(--accent-soft);
  border:1px solid rgba(77,124,255,.28);
  color:var(--accent-text);
}
.brand-mark .ico{width:18px;height:18px}
.brand-text{min-width:0}
.brand-name{
  display:block;
  font-size:13.5px;
  font-weight:600;
  letter-spacing:.1px;
  color:var(--text);
  white-space:nowrap;
}
.brand-sub{
  display:block;
  font-size:11.5px;
  color:var(--text-3);
  letter-spacing:.4px;
}

/* 导航：桌面端竖排，窄屏折成横向滚动条 */
nav.tabs{
  display:flex;
  flex-direction:column;
  gap:2px;
}
nav.tabs button{
  display:flex;
  align-items:center;
  gap:10px;
  width:100%;
  padding:9px 10px;
  border:0;
  border-radius:var(--r-sm);
  background:transparent;
  color:var(--text-2);
  font:inherit;
  font-size:13.5px;
  text-align:left;
  cursor:pointer;
  transition:background-color .14s ease,color .14s ease;
}
nav.tabs button .ico{
  flex:none;
  width:16px;
  height:16px;
  opacity:.85;
}
nav.tabs button:hover{background:var(--surface-2);color:var(--text)}
nav.tabs button.on{
  background:var(--accent-soft);
  color:var(--accent-text);
  font-weight:600;
}
nav.tabs button.on .ico{color:var(--accent-text);opacity:1}
nav.tabs button:focus-visible{outline-offset:-2px}

.sidebar-foot{
  margin-top:auto;
  display:flex;
  flex-direction:column;
  gap:10px;
  padding:14px 8px 0;
  border-top:1px solid var(--line);
}
.sidebar-foot .badge{white-space:normal;line-height:1.45;justify-content:flex-start}

/* ===== 顶栏 ============================================================= */

.main{display:flex;flex-direction:column;min-width:0}

.topbar{
  position:sticky;
  top:0;
  z-index:20;
  display:flex;
  align-items:center;
  gap:16px;
  min-height:var(--topbar-h);
  /* 左右内边距跟随 main 的居中宽度，保证标题与正文左缘对齐 */
  padding:12px 24px;
  background:var(--surface);
  border-bottom:1px solid var(--line);
}
.page-head{min-width:0}
.page-head h1{
  margin:0;
  font-size:16px;
  font-weight:600;
  letter-spacing:-.01em;
  line-height:1.25;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.page-hint{
  margin:2px 0 0;
  font-size:12.5px;
  color:var(--text-3);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.topbar-actions{
  display:flex;
  align-items:center;
  gap:8px;
  margin-left:auto;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.sync{
  font-size:11.5px;
  color:var(--text-3);
  font-variant-numeric:tabular-nums;
  white-space:nowrap;
}

.pw-group{
  position:relative;
  display:flex;
  align-items:center;
  gap:4px;
}
/* 折叠态：只露一个图标按钮，点开才出现输入框 */
.pw-toggle{
  display:inline-flex;
  align-items:center;
  gap:6px;
  height:30px;
  padding:0 10px;
  border:1px solid var(--line-2);
  border-radius:var(--r-sm);
  background:var(--surface);
  color:var(--text-2);
  font:inherit;
  font-size:12.5px;
  cursor:pointer;
  transition:border-color .14s ease,color .14s ease,background .14s ease;
}
.pw-toggle:hover{background:var(--surface-3);color:var(--text)}
.pw-toggle:focus-visible{outline-offset:1px}
.pw-toggle .ico{width:13px;height:13px}
.pw-toggle.on{color:var(--ok);border-color:var(--ok-line);background:var(--ok-soft)}
.pw-toggle.on .ico{color:var(--ok)}

.pw-panel{
  position:absolute;
  top:calc(100% + 8px);
  right:0;
  z-index:30;
  display:none;
  flex-direction:column;
  gap:8px;
  width:260px;
  padding:12px;
  border:1px solid var(--line-2);
  border-radius:var(--r-sm);
  background:var(--surface);
  box-shadow:0 12px 32px rgba(0,0,0,.28);
}
.pw-panel.open{display:flex}
.pw-panel label{
  font-size:12px;
  color:var(--text-3);
}
.pw-panel input{
  width:100%;
  height:30px;
  padding:0 9px;
  border:1px solid var(--line-2);
  border-radius:var(--r-xs);
  background:var(--bg);
  color:var(--text);
  font:inherit;
  font-size:12.5px;
}
.pw-panel input::placeholder{color:var(--text-3)}
.pw-panel input:focus{outline:none;border-color:var(--accent)}
.pw-panel .row{gap:6px}
.pw-panel .hint{font-size:11.5px;line-height:1.5}

main{
  width:100%;
  max-width:1680px;
  /* 宽屏下居中，否则内容会贴在侧栏右边、右侧留一大片空白 */
  margin:0 auto;
  padding:22px 24px 64px;
}

/* 页签面板：切换时轻微上浮，尊重 reduced-motion */
section{display:none}
section.on{
  display:block;
  animation:panelIn .24s cubic-bezier(.2,.7,.3,1) both;
}
@keyframes panelIn{
  from{opacity:0;transform:translateY(6px)}
  to{opacity:1;transform:none}
}

/* ===== 卡片与标题 ======================================================= */

.card{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:var(--r-lg);
  padding:18px 18px 16px;
  margin-bottom:20px;
  box-shadow:var(--panel-shadow);
}
.card-head{
  display:flex;
  align-items:flex-start;
  gap:16px;
  flex-wrap:wrap;
  margin:-18px -18px 14px;
  padding:14px 18px;
  border-bottom:1px solid var(--line);
}
.card-head > div:first-child{min-width:0;flex:1}
.card h2{
  margin:0;
  font-size:14.5px;
  font-weight:600;
  letter-spacing:0;
  color:var(--text);
}
.card-sub{
  margin:4px 0 0;
  font-size:12.5px;
  line-height:1.6;
  color:var(--text-3);
}
.card-actions{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
  margin-left:auto;
}
.card-actions > input,.card-actions > select{height:32px}
.card-actions > .hint{margin:0}
/* 卡头里的「标签 + 控件」组合（如 账号 [下拉框]） */
.inline-field{
  display:inline-flex;
  align-items:center;
  gap:6px;
  font-size:12.5px;
  color:var(--text-3);
}
.inline-field select{
  height:32px;
  max-width:220px;
  padding:0 8px;
  border:1px solid var(--line-2);
  border-radius:var(--r-sm);
  background:var(--surface);
  color:var(--text);
  font:inherit;
  font-size:12.5px;
}
.inline-field select:focus{outline:none;border-color:var(--accent)}
.subpanel{background:var(--surface-2)}

/* ===== KPI ============================================================== */

.kpis{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:0;
  margin-bottom:20px;
  border:1px solid var(--line);
  border-radius:11px;
  overflow:hidden;
  background:var(--surface);
}
.kpi{
  display:flex;
  flex-direction:column;
  gap:6px;
  padding:14px 16px 15px;
  background:var(--surface);
  border:0;
  border-right:1px solid var(--line);
  border-bottom:1px solid var(--line);
  border-radius:0;
}
.kpi .k{font-size:12px;color:var(--text-2)}
.kpi .v{
  font-family:var(--mono);
  font-size:26px;
  font-weight:600;
  line-height:1.1;
  letter-spacing:-.02em;
  font-variant-numeric:tabular-nums;
  word-break:break-word;
}
.kpi .sub{font-size:11.5px;color:var(--text-3)}

/* ===== 额度 ============================================================= */

.quota{display:flex;flex-direction:column;gap:12px}
.quota-head{
  display:flex;
  align-items:flex-end;
  gap:12px;
  flex-wrap:wrap;
}
.quota-num{
  font-size:30px;
  font-weight:600;
  line-height:1;
  letter-spacing:-.03em;
  font-variant-numeric:tabular-nums;
}
.quota-unit{font-size:12.5px;color:var(--text-3);margin-left:8px}
.quota-head .badge{margin-bottom:3px}
.quota-foot{
  display:flex;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
  font-size:12px;
  color:var(--text-3);
  font-variant-numeric:tabular-nums;
}

.bar{
  height:6px;
  background:var(--surface-3);
  border-radius:99px;
  overflow:hidden;
}
.bar > i{
  display:block;
  height:100%;
  border-radius:inherit;
  background:var(--accent);
  transition:width .45s cubic-bezier(.2,.7,.3,1);
}
.bar.warn > i{background:var(--warn)}
.bar.err > i{background:var(--err)}

/* 账号积分额度：表格里的迷你进度条，避免撑宽单元格 */
.credit-bar{width:120px;margin-top:3px}

/* ===== 表格 ============================================================= */

.table-wrap{
	overscroll-behavior-x:contain;
  width:100%;
  overflow-x:auto;
  margin:0 0 2px;
}
table{
  width:100%;
  min-width:860px;
  border-collapse:separate;
  border-spacing:0;
  font-size:13px;
}
#accounts td:first-child{min-width:120px;white-space:nowrap}
.key-cell{min-width:330px}
.key-value{width:100%;min-width:300px}
th,td{
  text-align:left;
  padding:10px 12px;
  vertical-align:middle;
  border-bottom:1px solid var(--line);
}
thead th{
  padding-top:10px;
  padding-bottom:10px;
  background:var(--surface-2);
  color:var(--text-3);
  font-weight:500;
  font-size:11.5px;
  letter-spacing:.2px;
  white-space:nowrap;
  border-bottom-color:var(--line-2);
}
tbody tr:last-child td{border-bottom:0}
tbody td{transition:background-color .12s ease}
tbody tr:hover td{background:var(--surface-2)}
td.actions-cell{display:table-cell;white-space:nowrap}
td.actions-cell > .btn + .btn{margin-left:4px}
td.empty{
  padding:30px 12px;
  text-align:center;
  color:var(--text-3);
  font-size:13px;
}

.mono{
  font-family:var(--mono);
  font-size:12px;
  font-variant-numeric:tabular-nums;
  letter-spacing:-.1px;
  white-space:nowrap;
}
.nowrap{white-space:nowrap}
.cell-stack{display:table-cell}
.cell-stack > span,.cell-stack > .bar{display:block;margin-top:3px}
.cell-stack .sub{
  font-family:var(--font);
  font-size:11px;
  color:var(--text-3);
  letter-spacing:0;
}
.muted{color:var(--text-3)}
.trunc{max-width:280px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* ===== 按钮 ============================================================= */

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  height:32px;
  padding:0 12px;
  border:1px solid var(--line-2);
  border-radius:var(--r-sm);
  background:var(--surface-2);
  color:var(--text);
  font:inherit;
  font-size:13px;
  line-height:1;
  white-space:nowrap;
  cursor:pointer;
  transition:background-color .14s ease,border-color .14s ease,color .14s ease,
    transform .06s ease;
}
.btn:hover{background:var(--surface-3);border-color:var(--accent)}
.btn:active{transform:translateY(1px)}
.btn:focus-visible{outline-offset:1px}
.btn .ico{width:14px;height:14px}

.btn.primary{
  background:var(--accent-solid);
  border-color:var(--accent-solid);
  color:#fff;
  font-weight:500;
}
.btn.primary:hover{background:var(--accent-solid-hover);border-color:var(--accent-solid-hover)}

.btn.ghost{
  background:transparent;
  border-color:transparent;
  color:var(--text-2);
}
.btn.ghost:hover{background:var(--surface-3);border-color:transparent;color:var(--text)}

.btn.danger{color:var(--err)}
.btn.danger:hover{background:var(--err-soft);border-color:var(--err-line)}

.btn.xs{height:26px;padding:0 9px;font-size:12px;border-radius:var(--r-xs)}

.btn:disabled{opacity:.5;cursor:not-allowed}
.btn[aria-busy="true"]{opacity:.65;cursor:progress}

/* <a class="btn"> 也按按钮渲染（浏览器登录的授权链接） */
a.btn{text-decoration:none}

/* ===== 表单 ============================================================= */

input,select,textarea{
  width:100%;
  min-width:0;
  height:34px;
  padding:0 10px;
  border:1px solid var(--line-2);
  border-radius:var(--r-sm);
  background:var(--surface-2);
  color:var(--text);
  font:inherit;
  font-size:13px;
  transition:border-color .14s ease,background-color .14s ease;
}
textarea{
  height:auto;
  min-height:96px;
  padding:9px 10px;
  font-family:var(--mono);
  font-size:12px;
  line-height:1.6;
  resize:vertical;
}
input::placeholder,textarea::placeholder{color:var(--text-3)}
input:hover,select:hover,textarea:hover{border-color:var(--accent)}
input:focus,select:focus,textarea:focus{
  outline:none;
  border-color:var(--accent);
  background:var(--surface);
}
select{
  appearance:none;
  padding-right:30px;
  background-image:
    linear-gradient(45deg,transparent 50%,var(--text-3) 50%),
    linear-gradient(135deg,var(--text-3) 50%,transparent 50%);
  background-position:calc(100% - 16px) 15px,calc(100% - 11px) 15px;
  background-size:5px 5px,5px 5px;
  background-repeat:no-repeat;
  cursor:pointer;
}
input[type=number]{font-variant-numeric:tabular-nums}

/* 开关：替代默认 checkbox，保留原生可聚焦/可点击行为 */
input[type=checkbox]{
  appearance:none;
  -webkit-appearance:none;
  position:relative;
  flex:none;
  width:34px;
  height:20px;
  padding:0;
  border:1px solid var(--line-2);
  border-radius:99px;
  background:var(--surface-3);
  cursor:pointer;
  transition:background-color .18s ease,border-color .18s ease;
}
input[type=checkbox]::after{
  content:"";
  position:absolute;
  top:2px;
  left:2px;
  width:14px;
  height:14px;
  border-radius:50%;
  background:var(--text-2);
  transition:transform .18s cubic-bezier(.3,.8,.3,1),background-color .18s ease;
}
input[type=checkbox]:checked{background:var(--accent-solid);border-color:var(--accent-solid)}
input[type=checkbox]:checked::after{transform:translateX(14px);background:#fff}
input[type=checkbox]:focus-visible{outline:2px solid var(--accent);outline-offset:2px}

.check{
  display:flex;
  align-items:flex-start;
  gap:10px;
  font-size:13px;
  line-height:1.55;
  color:var(--text);
  cursor:pointer;
}
.check input{margin-top:1px}
.check .check-hint{display:block;font-size:12px;color:var(--text-3);margin-top:2px}

.field{display:flex;flex-direction:column;gap:6px;min-width:0}
.field > label,.field-label{
  font-size:12px;
  color:var(--text-2);
  letter-spacing:0;
}
.field-hint{font-size:11.5px;color:var(--text-3);line-height:1.5}

.field-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(240px,1fr));
  gap:14px 18px;
}
.field-grid.cols-2{grid-template-columns:repeat(auto-fit,minmax(300px,1fr))}

.inline-fields{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.inline-fields .w-hour{width:72px}
.inline-fields .sep{color:var(--text-3)}

/* ===== 设置分组 ========================================================= */

.settings-group{
  padding-top:18px;
  margin-top:18px;
  border-top:1px solid var(--line);
}
.settings-group.first{padding-top:0;margin-top:0;border-top:0}
.settings-group h3{
  margin:0 0 4px;
  font-size:13px;
  font-weight:600;
  color:var(--text);
}
.settings-group .group-hint{
  margin:0 0 14px;
  font-size:12px;
  line-height:1.65;
  color:var(--text-3);
}
.settings-group .group-hint:last-child{margin-bottom:0}

/* ===== 提示与状态 ======================================================= */

.hint{
  margin:10px 0 0;
  font-size:12px;
  line-height:1.7;
  color:var(--text-3);
}
.hint b{color:var(--text-2);font-weight:600}
.hint:first-child{margin-top:0}
.hint.m-0{margin:0}

.callout{
  display:flex;
  gap:10px;
  margin-top:12px;
  padding:12px 14px;
  border:1px solid var(--warn-line);
  border-radius:var(--r-md);
  background:var(--warn-soft);
  font-size:12.5px;
  line-height:1.65;
  color:var(--text);
}
.callout-title{color:var(--warn);font-weight:600;white-space:nowrap}

.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:2px 9px;
  border:1px solid transparent;
  border-radius:99px;
  background:var(--surface-3);
  color:var(--text-2);
  font-size:11.5px;
  line-height:1.65;
  white-space:nowrap;
  font-variant-numeric:tabular-nums;
}
.badge.ok{background:var(--ok-soft);color:var(--ok);border-color:var(--ok-line)}
.badge.err{background:var(--err-soft);color:var(--err);border-color:var(--err-line)}
.badge.warn{background:var(--warn-soft);color:var(--warn);border-color:var(--warn-line)}
.dot{
  flex:none;
  width:6px;
  height:6px;
  border-radius:50%;
  background:currentColor;
}
.badge:not(.ok):not(.err):not(.warn) .dot{animation:pulse 1.6s ease-in-out infinite}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.35}}

.warn-text{color:var(--warn)}
.err-text{color:var(--err)}

code{
  padding:1px 5px;
  border-radius:4px;
  background:var(--surface-3);
  color:var(--text-2);
  font-family:var(--mono);
  font-size:11.5px;
  word-break:break-word;
}

/* ===== Toast ============================================================ */

.toast{
  position:fixed;
  right:20px;
  bottom:20px;
  z-index:50;
  display:none;
  max-width:min(460px,calc(100vw - 40px));
  padding:12px 14px 12px 16px;
  border:1px solid var(--line-2);
  border-left:3px solid var(--accent);
  border-radius:var(--r-md);
  background:var(--surface-2);
  color:var(--text);
  font-size:13px;
  line-height:1.6;
  white-space:pre-wrap;
  word-break:break-word;
  box-shadow:var(--pop);
  cursor:pointer;
}
.toast.show{display:block;animation:toastIn .2s ease}
.toast.ok{border-left-color:var(--ok)}
.toast.err{border-left-color:var(--err);max-height:40vh;overflow:auto}
@keyframes toastIn{
  from{opacity:0;transform:translateY(8px)}
  to{opacity:1;transform:none}
}

/* ===== 工具类（替代内联 style，使 CSP 可收紧到 style-src 'self'） ====== */

.hidden{display:none}
.sr-only{
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip:rect(0 0 0 0);
  white-space:nowrap;
  border:0;
}
.skip{
  position:absolute;
  left:12px;
  top:-48px;
  z-index:100;
  padding:8px 14px;
  border-radius:var(--r-sm);
  background:var(--accent-solid);
  color:#fff;
  font-size:13px;
  text-decoration:none;
  transition:top .14s ease;
}
.skip:focus{top:12px}

.row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.row.between{justify-content:space-between}
.m-0{margin:0}
.mt-8{margin-top:8px}
.mt-12{margin-top:12px}
.mt-14{margin-top:14px}
.mb-12{margin-bottom:12px}
.mb-0{margin-bottom:0}
.w-70{width:70px}
.w-hour{width:72px}
.w-180{width:180px}
.w-190{width:190px}
.w-200{width:200px}
.w-250{width:250px}
.w-280{width:280px}
.w-520{width:520px}
.w-full{width:100%}
.w-auto{width:auto}
.grow-320{flex:1;min-width:320px}
.tall{min-height:160px}
.ico{
  width:16px;
  height:16px;
  fill:none;
  stroke:currentColor;
  stroke-width:1.6;
  stroke-linecap:round;
  stroke-linejoin:round;
}

/* ===== 响应式 =========================================================== */

@media (max-width:1100px){
  .pw-group input{width:132px}
  main{padding:20px 20px 64px}
  .topbar{padding:10px 20px}
}

@media (max-width:920px){
  .app{grid-template-columns:minmax(0,1fr)}
  .sidebar{
    position:static;
    height:auto;
    flex-direction:row;
    flex-wrap:wrap;
    align-items:center;
    gap:8px 14px;
    padding:10px 16px;
    border-right:0;
    border-bottom:1px solid var(--line);
  }
  .brand{padding:0}
  .brand-sub{display:none}
  .sidebar-foot{margin-left:auto;padding:0}
  .sidebar-foot .badge{font-size:11px;padding:2px 8px}
  nav.tabs{
    order:3;
    width:100%;
    flex-direction:row;
    gap:4px;
    overflow-x:auto;
    padding-bottom:2px;
    scrollbar-width:none;
  }
  nav.tabs::-webkit-scrollbar{display:none}
  nav.tabs button{
    width:auto;
    gap:7px;
    padding:7px 9px;
    white-space:nowrap;
  }
  nav.tabs button .ico{width:15px;height:15px}
  nav.tabs button.on{box-shadow:inset 0 -2px 0 var(--accent)}
  .topbar{
    position:sticky;
    top:0;
    padding:10px 16px;
    min-height:0;
    flex-wrap:wrap;
    gap:10px;
  }
  .page-hint{display:none}
  .topbar-actions{width:100%;margin-left:0;justify-content:flex-start}
  .pw-group{flex:1;min-width:180px}
  .pw-group input{flex:1;width:auto}
  .sync{display:none}
  main{padding:16px 16px 56px}
  .card{padding:15px 15px 14px;border-radius:12px}
  .card-head{gap:10px}
  .card-actions{margin-left:0;width:100%}
  .field-grid{grid-template-columns:1fr}
  .kpis{grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:10px}  .kpi{padding:12px 13px}
  .kpi .v{font-size:22px}
  .quota-num{font-size:26px}
  .w-180,.w-190,.w-200,.w-250,.w-280,.w-520{width:100%}
  .grow-320{min-width:0}
}

@media (max-width:520px){
  .page-head h1{font-size:17px}
  .btn{height:30px;padding:0 10px;font-size:12.5px}
  .btn.xs{height:25px;padding:0 8px}
  .kpis{grid-template-columns:1fr 1fr}
  .toast{right:12px;bottom:12px;max-width:calc(100vw - 24px)}
}

@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{
    animation-duration:.001ms!important;
    animation-iteration-count:1!important;
    transition-duration:.001ms!important;
  }
  section.on{animation:none}
}

/* Panel presentation: compact WorkBuddy-inspired account workspace. */
.nav-count{margin-left:auto;font:11px var(--mono);padding:1px 6px;border-radius:4px;background:var(--surface-3);color:var(--text-2)}
#nav-accounts{order:-1}
.sidebar-note{font-size:10.5px;color:var(--text-3);display:flex;justify-content:space-between;gap:4px}
.heading-count{font-size:11px;font-weight:400;color:var(--text-3);margin-left:8px}
.pool-stats{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));background:var(--surface);border:1px solid var(--line);border-radius:11px;overflow:hidden;margin-bottom:18px;box-shadow:var(--panel-shadow)}
.pool-stat{padding:18px 16px;border-right:1px solid var(--line);min-width:0}
.pool-stat:last-child{border-right:0}
.stat-value{font:600 27px/1.2 var(--mono);letter-spacing:-1px;white-space:nowrap}
.stat-value.text-value{font:600 18px/1.8 var(--font);letter-spacing:0}
.stat-label{font-size:12px;color:var(--text-2);margin-top:8px}
.stat-note{font-size:10.5px;color:var(--text-3);margin-top:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pool-stat.good .stat-value{color:var(--ok)}
.pool-stat.warning .stat-value{color:var(--warn)}
.connection-strip{display:flex;justify-content:space-between;align-items:center;gap:12px;border:1px solid var(--line);background:var(--surface);border-radius:8px;padding:9px 14px;margin-bottom:20px;font-size:12px}
.connection-info{display:flex;align-items:center;gap:10px;flex-wrap:wrap;min-width:0;color:var(--text-3)}
.connection-info code{color:var(--text-2);font:12px var(--mono);overflow-wrap:anywhere}
.connection-dot{width:6px;height:6px;border-radius:50%;background:var(--accent);flex:none}
.account-toolbar{display:flex;gap:14px;flex-wrap:wrap;align-items:center;margin-bottom:14px}
.account-search{display:flex;align-items:center;gap:8px;border:1px solid var(--line);border-radius:7px;background:var(--surface-2);padding:0 10px;min-width:190px;flex:0 1 245px;color:var(--text-3)}
.account-search:focus-within{border-color:var(--accent)}
.account-search .ico{width:14px;flex:none}
.account-search input{border:0;background:transparent;padding:7px 0;min-width:0;outline:none;box-shadow:none;font-size:12px}
.account-filters{display:flex;gap:4px;flex-wrap:wrap;align-items:center}
.filter-chip{background:transparent;color:var(--text-3);border:1px solid transparent;border-radius:6px;padding:5px 9px;font:12px var(--font);cursor:pointer;white-space:nowrap}
.filter-chip:hover{color:var(--text);background:var(--surface-2)}
.filter-chip.on{background:var(--accent-soft);color:var(--accent-text);font-weight:600}
.filter-count{font:11px var(--mono);color:var(--text-3);margin-left:auto}
.account-table{min-width:1300px}
.account-table th,.account-table td{padding:13px 12px}
.account-table td:nth-child(4){min-width:165px}
.account-table td:nth-child(5){min-width:175px}
.account-table td:nth-child(6){min-width:150px}
.account-table td.actions-cell{min-width:260px;max-width:300px;white-space:normal}
.account-table td.actions-cell .btn{margin:3px 4px 3px 0}
.account-table td:first-child{border-left:3px solid var(--line)}
.account-table tr[data-state="ready"] td:first-child{border-left-color:var(--ok)}
.account-table tr[data-state="cooling"] td:first-child,.account-table tr[data-state="busy"] td:first-child{border-left-color:var(--warn)}
.account-table tr[data-state="disabled"] td:first-child{border-left-color:var(--err)}
.account-identity{vertical-align:middle}
.account-who{display:flex;align-items:center;gap:10px;min-width:150px}
.account-avatar{display:grid;place-items:center;width:30px;height:30px;flex:none;border-radius:8px;background:var(--accent-soft);color:var(--accent-text);font-size:12px;font-weight:600}
.account-name{display:flex;flex-direction:column;gap:4px;min-width:0}
.account-title{font-size:12.5px;font-weight:550;max-width:190px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.account-caption{font-size:10.5px;color:var(--text-3)}
.credit-bar{height:5px;margin:7px 0}
.credit-bar progress{display:block;width:100%;height:5px;border:0;appearance:none;background:var(--surface-3);color:var(--ok)}
.credit-bar progress::-webkit-progress-bar{background:var(--surface-3)}
.credit-bar progress::-webkit-progress-value{background:var(--ok);border-radius:4px}
.credit-bar progress::-moz-progress-bar{background:var(--ok);border-radius:4px}
.credit-bar.warn progress::-webkit-progress-value{background:var(--warn)}
.credit-bar.err progress::-webkit-progress-value{background:var(--err)}
.credit-bar.warn progress::-moz-progress-bar{background:var(--warn)}
.credit-bar.err progress::-moz-progress-bar{background:var(--err)}
.badge{border-radius:5px;font-size:10.5px}
.settings-group h3{font-size:13px;color:var(--accent-text)}
@media(min-width:1500px){.kpis{grid-template-columns:repeat(8,minmax(0,1fr))}}
@media(min-width:601px) and (max-width:1600px){
  .account-table{min-width:980px}
  .account-table th:nth-child(2),.account-table td:nth-child(2),
  .account-table th:nth-child(3),.account-table td:nth-child(3),
  .account-table th:nth-child(7),.account-table td:nth-child(7),
  .account-table th:nth-child(9),.account-table td:nth-child(9){display:none}
}
@media(max-width:1200px){
  .pool-stats{grid-template-columns:repeat(3,minmax(0,1fr))}
  .pool-stat{border-bottom:1px solid var(--line)}
  .pool-stat:nth-child(3n){border-right:0}
  .pool-stat:nth-child(n+4){border-bottom:0}
}
@media(max-width:920px){
  .brand{border-bottom:0;padding:0}
  .sidebar{padding:12px 16px;gap:10px}
  .sidebar-foot{border-top:0;padding:0}
  .sidebar-note{display:none}
  nav.tabs button.on{box-shadow:none}
  .topbar{gap:8px;flex-wrap:nowrap}
  .topbar-actions{width:auto;margin-left:auto;flex-wrap:nowrap;gap:6px}
  .topbar-actions .btn{padding:0 9px}
  #localPanelStatus{font-size:10px;padding:2px 6px}
  #themeLabel{display:none}
  .card-head{margin:-15px -15px 14px;padding:13px 15px}
  .kpis{gap:0}
  .nav-count{display:none}
  .pool-stat{padding:14px 12px}
  .stat-value{font-size:23px}
  .stat-value.text-value{font-size:16px}
  .connection-info{gap:6px}
  .connection-info>span:not(.connection-dot){display:none}
}
@media(max-width:600px){
  .pool-stats{grid-template-columns:repeat(2,minmax(0,1fr))}
  .pool-stat:nth-child(3n){border-right:1px solid var(--line)}
  .pool-stat:nth-child(2n){border-right:0}
  .pool-stat:nth-child(n){border-bottom:1px solid var(--line)}
  .pool-stat:nth-last-child(-n+2){border-bottom:0}
  .stat-note{font-size:10px}
  .account-search{flex:1 1 100%;min-width:0}
  .account-toolbar{gap:9px}
  .account-filters{gap:2px}
  .filter-chip{padding:5px 7px;font-size:11px}
  .filter-count{font-size:10px}
  .account-table-wrap{overflow:visible}
  .account-table,.account-table tbody{display:block;min-width:0;width:100%}
  .account-table thead{display:none}
  .account-table tr{display:grid;grid-template-columns:1fr 1fr;border:1px solid var(--line);border-radius:9px;overflow:hidden;margin-bottom:12px;background:var(--surface)}
  .account-table td{display:block!important;min-width:0!important;max-width:none!important;border:0;padding:9px 12px;white-space:normal;font-size:12px}
  .account-table td::before{content:attr(data-label);display:block;font:10px var(--font);color:var(--text-3);margin-bottom:5px}
  .account-table td:first-child{grid-column:1/-1;border-bottom:1px solid var(--line);background:var(--surface-2);padding:12px}
  .account-table td:first-child::before,.account-table td.actions-cell::before{display:none}
  .account-table td:nth-child(3){display:none!important}
  .account-table td:nth-child(4){grid-column:1/-1}
  .account-table td.actions-cell{grid-column:1/-1;border-top:1px solid var(--line);padding:9px}
  .account-table td.empty{grid-column:1/-1;padding:30px 12px;background:transparent}
  .account-table .account-title{max-width:220px}
  .account-table .mono{font-size:11px;overflow-wrap:anywhere}
  .account-table .cell-stack .sub{font-size:10px}
  .account-table tr:hover td{background:transparent}
  #tab-keys table{min-width:0;display:block}
  #tab-keys thead{display:none}
  #keys{display:block}
  #keys tr{display:flex;flex-wrap:wrap;padding:12px 0;border-bottom:1px solid var(--line);gap:8px}
  #keys td{display:block;padding:4px 0;border:0;min-width:0}
  #keys .key-cell{flex:0 0 100%}
  #keys .key-value{min-width:0;width:100%}
  #keys td:nth-child(4),#keys td:nth-child(5),#keys td:nth-child(6){display:none}
  #keys .actions-cell{flex:0 0 100%}
}

/* Explicit add-account and delete confirmation dialogs. */
.modal{width:min(660px,calc(100vw - 32px));max-height:90vh;padding:0;border:1px solid var(--line);border-radius:14px;background:var(--surface);color:var(--text);box-shadow:var(--pop);overflow:auto}
.modal::backdrop{background:rgba(6,8,18,.62);backdrop-filter:blur(3px)}
.modal-small{width:min(440px,calc(100vw - 32px))}
.modal-head{display:flex;align-items:start;justify-content:space-between;gap:16px;padding:20px 22px;border-bottom:1px solid var(--line)}
.modal-head h2{font-size:17px;margin:0}
.modal-head p{font-size:12px;margin:6px 0 0;line-height:1.6}
.modal-body{padding:20px 22px}
.modal-body h3{font-size:14px;margin:0 0 10px}
.modal-actions{display:flex;gap:8px;justify-content:flex-end;flex-wrap:wrap;padding:16px 22px;border-top:1px solid var(--line);position:sticky;bottom:0;background:var(--surface)}
.modal-status{padding:12px 0;font-size:12px;color:var(--text-2);line-height:1.7}
.login-stepper{display:flex;gap:7px;margin-bottom:20px;flex-wrap:wrap}
.login-stepper span{font-size:12px;padding:6px 10px;border-radius:6px;background:var(--surface-2);color:var(--text-3)}
.login-stepper .active{background:var(--accent-soft);color:var(--accent-text)}
.login-preview{background:var(--surface-2);border:1px solid var(--line);padding:15px;border-radius:9px}
.login-preview strong{display:block;overflow-wrap:anywhere}
.login-advanced{font-size:12px;color:var(--text-3)}
.login-advanced summary{cursor:pointer}
#loginURL{font-size:11px;font-family:var(--mono)}
#loginPasted{min-height:100px;font-size:12px;font-family:var(--mono)}
#loginError,#deleteAccountError{font-size:12px;white-space:pre-wrap;overflow-wrap:anywhere}
@media(max-width:600px){.modal-head,.modal-body{padding:16px}.modal-actions{padding:12px 16px}.login-stepper{gap:4px}.login-stepper span{font-size:11px;padding:5px 6px}.modal .row{gap:7px}}

/* Usage overview: compact Sub2API-style summary cards with measured data. */
.usage-toolbar{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:20px}
.usage-toolbar h2{font-size:18px;margin:0 0 5px}
.usage-kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px;position:relative}
.usage-kpis::before{content:"";position:absolute;inset:-24px -16px;background:radial-gradient(ellipse at 30% 50%,rgba(27,192,175,.10),transparent 70%);pointer-events:none;z-index:0}
.usage-kpi{display:flex;align-items:center;gap:13px;padding:19px 16px;min-height:100px;background:var(--surface);border:1px solid var(--line);border-radius:16px;box-shadow:0 2px 3px rgba(15,23,42,.05);position:relative;min-width:0}
.usage-icon{display:flex;align-items:center;justify-content:center;width:36px;height:36px;border-radius:10px;flex:none}
.usage-icon svg{width:20px;height:20px;stroke:currentColor;fill:none;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round}
.usage-icon.requests{background:#dbeafe;color:#3478ff}.usage-icon.tokens{background:#fef3c7;color:#d97706}
.usage-icon.cost{background:#dcfce7;color:#00a854}.usage-icon.latency{background:#f3e8ff;color:#9333ea}
.usage-kpi-content{min-width:0}.usage-label{font-size:12px;color:var(--text-3);margin-bottom:2px}
.usage-value{font-size:21px;line-height:1.4;font-weight:650;letter-spacing:.1px;font-variant-numeric:tabular-nums;color:var(--text)}
.usage-kpi.cost .usage-value{color:var(--ok)}
.usage-sub{font-size:11px;line-height:1.6;color:var(--text-3);overflow-wrap:anywhere}
.usage-coverage{font-size:12px;line-height:1.8;color:var(--text-3);margin:16px 0 22px}
.usage-detail-grid{display:grid;grid-template-columns:1.5fr 1fr;gap:18px}
.usage-detail-grid .card{border-radius:14px}
.usage-token-row{margin:0 0 14px}.usage-token-label{display:flex;justify-content:space-between;font-size:12px;color:var(--text-2);margin-bottom:7px}
.usage-token-label strong{font-weight:600;font-variant-numeric:tabular-nums}
.usage-token-row progress{display:block;width:100%;height:6px;appearance:none;border:0;border-radius:8px;overflow:hidden;background:var(--surface-3)}
.usage-token-row progress::-webkit-progress-bar{background:var(--surface-3)}
.usage-token-row progress::-webkit-progress-value{background:#6695fa;border-radius:8px}
.usage-token-row.output progress::-webkit-progress-value{background:#a78bfa}.usage-token-row.cached progress::-webkit-progress-value{background:#34c997}
.usage-token-row progress::-moz-progress-bar{background:#6695fa}.usage-token-row.output progress::-moz-progress-bar{background:#a78bfa}.usage-token-row.cached progress::-moz-progress-bar{background:#34c997}
.usage-result{display:flex;align-items:center;justify-content:space-between;padding:11px 0;border-bottom:1px solid var(--line);font-size:13px;color:var(--text-2)}
.usage-result:last-child{border:0}.usage-result strong{font-size:19px;font-weight:600;font-variant-numeric:tabular-nums}.usage-result.good strong{color:var(--ok)}.usage-result.bad strong{color:var(--err)}
.usage-table{min-width:880px}.usage-table th,.usage-table td{white-space:nowrap}
@media(max-width:1200px){.usage-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:600px){.usage-kpis{gap:10px}.usage-kpi{padding:14px 10px;gap:9px;align-items:flex-start;border-radius:12px}.usage-icon{width:29px;height:29px;border-radius:8px;margin-top:3px}.usage-icon svg{width:17px;height:17px}.usage-value{font-size:20px}.usage-detail-grid{grid-template-columns:1fr;gap:0}.usage-sub{font-size:10px}.usage-toolbar{margin-bottom:15px}}
.pricing-table{min-width:1000px}.pricing-table input{width:105px;min-width:85px}.pricing-table select{min-width:75px}.pricing-source{max-width:350px;font-size:11px;overflow-wrap:anywhere}.usage-kpi.cost .usage-value{font-size:19px;overflow-wrap:anywhere}
.usage-filters{display:flex;flex-wrap:wrap;align-items:flex-end;gap:12px;background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:16px;margin-bottom:22px}
.usage-filters label{display:flex;flex-direction:column;gap:6px;font-size:12px;color:var(--text-2)}.usage-filters select{min-width:130px}.usage-filters input{min-width:150px}.usage-filters .hint{align-self:center}
.usage-pagination{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:12px;border-top:1px solid var(--line);padding-top:16px;margin-top:16px;font-size:12px;color:var(--text-2)}
.pagination-info,.pagination-buttons,.pagination-jump{display:flex;align-items:center;gap:8px}.pagination-info{flex-wrap:wrap}.pagination-info label,.pagination-jump label{display:flex;align-items:center;gap:6px}.pagination-info select{width:84px}.pagination-jump input{width:64px}.pagination-buttons{gap:4px}.pagination-ellipsis{padding:0 4px}
#priceEditDialog{width:min(620px,calc(100vw - 32px))}#priceEditError{color:var(--err)}
@media(max-width:600px){.usage-filters{gap:10px}.usage-filters input{min-width:0;width:132px}.usage-filters label{flex:1 1 120px}.usage-pagination{justify-content:center}.pagination-info{width:100%;justify-content:space-between}.pagination-buttons{flex-wrap:wrap;justify-content:center}.pagination-jump{width:100%;justify-content:center}}
#priceEditDialog{padding:24px}#priceEditDialog .card-head{margin:0 0 18px;padding:0 0 16px}#priceEditDialog .field-grid{grid-template-columns:repeat(3,minmax(0,1fr))}#priceEditDialog .row{justify-content:flex-end;margin-top:18px}
@media(max-width:600px){#priceEditDialog{padding:18px}#priceEditDialog .field-grid{grid-template-columns:1fr}}
#policyDialog{padding:24px;width:min(720px,calc(100vw - 32px))}#policyDialog .card-head{margin:0 0 18px;padding:0 0 16px}#policyDialog .field-grid{grid-template-columns:repeat(3,minmax(0,1fr))}#policyDialog .row{justify-content:flex-end;margin-top:18px}.policy-options{display:flex;flex-direction:column;gap:10px;margin:18px 0;font-size:13px}.policy-options input{width:auto;margin-right:8px}#policyError{color:var(--err)}.usage-finish{display:block;font:10px var(--mono);color:var(--text-3);margin-top:4px}
@media(max-width:600px){#policyDialog{padding:18px}#policyDialog .field-grid{grid-template-columns:1fr 1fr}}

body.admin-locked .app { visibility: hidden; }
#adminLoginDialog { max-width: 480px; }
#adminLoginDialog,#keyBudgetDialog,#modelHealthDialog{padding:24px}
#keyBudgetDialog .card-head,#modelHealthDialog .card-head{margin:0 0 18px;padding:0 0 16px;align-items:center;justify-content:space-between}
#keyBudgetDialog .card-head h2,#modelHealthDialog .card-head h2{margin:0;font-size:17px}
#adminLoginDialog h2{margin:0 0 14px;font-size:20px}
#adminLoginError,#keyBudgetError{color:var(--err)}
#keyBudgetSave{margin-top:16px}
@media(max-width:600px){#adminLoginDialog,#keyBudgetDialog,#modelHealthDialog{padding:18px}}
