/* settings：系统设置视图（二级导航 / 卡片表单 / 账号池 / 模型 / 用户 / 关于）。 */

.set-head {
  flex: none;
  min-height: var(--page-head-height);
  padding: 8px 28px;
  width: 100%;
  display: flex; flex-direction: column; justify-content: center;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.set-head h1 { margin: 0; font-size: 19px; font-weight: 600; line-height: 1.4; }
.set-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }

.set-body {
  flex: 1; min-height: 0;
  display: flex; gap: 28px;
  width: 100%;
  padding: 18px 28px 0;
}
.set-nav {
  width: 184px; flex: none;
  display: flex; flex-direction: column; gap: 2px;
  padding-bottom: 24px;
}
.set-nav button {
  display: flex; align-items: center; justify-content: flex-start; gap: 10px;
  width: 100%; text-align: left;
  background: none; border: 1px solid transparent; border-radius: calc(7px * var(--radius-scale));
  color: var(--muted);
  font-size: 13.5px;
  padding: 8px 12px;
  min-height: 40px;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}
.set-nav button:hover { color: var(--text); background: var(--panel); }
.set-nav button.active {
  color: var(--amber);
  background: color-mix(in srgb, var(--amber) 10%, transparent);
  border-color: var(--amber-dim);
}
/* 选中底块交给 ink.ts 的滑动条，切换分区时从上一项滑过来 */
.set-nav > .ink {
  background: color-mix(in srgb, var(--amber) 10%, transparent);
  border: 1px solid var(--amber-dim); border-radius: calc(7px * var(--radius-scale));
}
.set-nav[data-ink-ready] button.active { background: transparent; border-color: transparent; }
.set-nav .count {
  margin-left: auto;
  font-family: var(--mono); font-size: 11px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line); border-radius: var(--radius-pill);
  padding: 0 7px;
}
.set-nav button.active .count { color: var(--amber); border-color: var(--amber-dim); }

.set-content {
  flex: 1; min-width: 0;
  overflow-y: auto;
  padding-bottom: 40px;
  /* overflow-y 也会裁掉横向溢出：贴边的输入框焦点环（outline 2px + 偏移 1px）会被切掉一截。
   * 留出 4px 再用负外边距抵回，内容位置不变。 */
  padding-inline: 4px; margin-inline: -4px;
}
.set-section { display: flex; flex-direction: column; gap: 16px; }
.set-section > * { flex-shrink: 0; }

.sec-intro {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.sec-intro h2 { margin: 0; font-size: 15px; font-weight: 600; }
.sec-intro p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; max-width: 46em; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: calc(10px * var(--radius-scale));
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 14px;
}
.card h3 { margin: 0; font-size: 13.5px; font-weight: 600; }
.card h3.agent-h3 { display: flex; align-items: center; gap: 8px; }
.card .card-desc { margin: -8px 0 0; color: var(--muted); font-size: 12.5px; }
/* 「界面与提示」里的个人偏好卡片：勾选项用正文色，说明是小号灰字 */
:is(#set-local-saving, #set-chat-suggestions, #set-chat-tasks, #set-chat-followups) .note { margin:0; color:var(--muted); font-size:12px; line-height:1.6; }
:is(#set-local-saving, #set-chat-suggestions, #set-chat-tasks) label.check { color:var(--text); align-items:flex-start; }
:is(#set-local-saving, #set-chat-suggestions, #set-chat-tasks) label.check input { flex:none; margin-top:3px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; color: var(--muted); }
.field input, .field :is(select, .select-trigger) { width: 100%; }
.field .hint { font-size: 12px; color: var(--muted); opacity: 0.85; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 130px; }
.card-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding-top: 2px;
}
.card-foot .note { margin-right: auto; font-size: 12px; color: var(--muted); }

/* 生效时机标签：琥珀=需重启，绿=热生效 */
.tag {
  display: inline-flex; align-items: center;
  font-size: 11px;
  border: 1px solid var(--line); border-radius: calc(4px * var(--radius-scale));
  color: var(--muted);
  padding: 0 6px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.tag.restart { color: var(--warn); border-color: var(--warn-line); }
.tag.live { color: var(--green); border-color: var(--green-line); }

/* 账号池列表 */
.acct-list { display: flex; flex-direction: column; gap: 10px; }
.acct-row {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: calc(10px * var(--radius-scale));
  padding: 13px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 16px;
  align-items: center;
}
.acct-row.stale { border-color: var(--red-line); }
.acct-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.acct-type {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: 0.06em;
  border: 1px solid color-mix(in srgb, var(--brand) 45%, transparent);
  border-radius: calc(4px * var(--radius-scale));
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 8%, transparent);
  padding: 2px 7px 2px 5px;
  flex: none;
}
.acct-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-slug { font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.acct-state {
  grid-column: 1;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted);
}
.acct-state .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); flex: none; display: inline-block; }
.st { display: inline-flex; align-items: center; gap: 6px; }
.st.ok { color: var(--green); }
.st.ok .dot { background: var(--green); }
.st.warn { color: var(--red); }
.st.warn .dot { background: var(--red); }
.acct-actions {
  grid-row: 1 / 3; grid-column: 2;
  display: flex; gap: 6px; align-items: center;
}
.acct-empty { color: var(--muted); font-size: 13px; padding: 18px 4px; }

/* 账号行上的出口 IP 标签 */
.acct-proxy {
  display: inline-flex; align-items: center;
  max-width: 26em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--green);
}
.acct-proxy.none { color: var(--muted); opacity: 0.75; }
/* 账号行上的「N 个可用模型」：点开可用模型弹窗 */
.acct-models-link {
  padding: 0; border: 0; background: none; font: inherit; color: var(--amber);
  cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px;
}
.acct-models-link.none { color: var(--muted); }
.acct-models-link:hover { color: var(--text); }

/* IP 代理池 */
.px-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.px-bridge {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--muted);
  padding: 9px 12px;
  border: 1px dashed var(--line); border-radius: calc(8px * var(--radius-scale));
}
.px-bridge.bad { color: var(--red); border-color: var(--red-line); border-style: solid; }
.px-table th, .px-table td { padding-left: 10px; padding-right: 10px; }
.px-table td { vertical-align: middle; }
/* 骨架行与带操作按钮的真实行同高 */
.px-table .skeleton-row td { padding-top: 17px; padding-bottom: 17px; }
.price-table .skeleton-row td { padding-top: 18px; padding-bottom: 18px; }
.px-actions .btn { padding-left: 7px; padding-right: 7px; gap: 5px; }
.px-name { display: flex; align-items: center; gap: 7px; font-weight: 500; }
.px-scheme {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em;
  border: 1px solid var(--line); border-radius: calc(4px * var(--radius-scale));
  color: var(--muted);
  padding: 1px 6px;
}
.px-copy {
  font-size: 12px; color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line); border-radius: calc(5px * var(--radius-scale));
  padding: 2px 8px;
}
.px-copy:hover { border-color: var(--accent); color: var(--text-hi); }
.px-auth { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.px-acct, .px-probe { font-family: var(--mono); font-size: 11.5px; }
.px-acct.dim, .px-probe.dim { color: var(--muted); opacity: 0.7; }
.px-probe.good { color: var(--green); }
.px-probe.bad { color: var(--red); }
.px-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* 模型列表 */
.model-default { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.model-default label { font-size: 13px; color: var(--muted); }
.model-default .select-trigger, .model-default select:not(.select-native) { flex: 1; min-width: 180px; }
.model-rows { display: flex; flex-direction: column; }
.model-row {
  display: grid; align-items: center; gap: 12px;
  grid-template-columns: minmax(90px, 1fr) minmax(0, 1.6fr) minmax(140px, 1.3fr) 76px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--line-soft);
}
.model-row:last-child { border-bottom: none; }
.model-row .m-label { min-width: 0; font-size: 13.5px; overflow-wrap: anywhere; }
.model-row .m-id {
  font-family: var(--mono); font-size: 11.5px; color: var(--muted);
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.model-row .m-reasoning {
  min-width: 0; justify-content: flex-start; text-align: left;
  white-space: normal; overflow-wrap: anywhere;
}
.model-row .m-remove { justify-self: end; }
.model-add { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--line); }
.model-add input { flex: 1; min-width: 120px; }

/* 模型管理：账号模型 / 价格 / 系统模型列表三个标签页 */
.mdl-tabs { align-self: flex-start; }
.mdl-tabs .scope-btn { display: inline-flex; align-items: center; gap: 6px; }
.mdl-panel { display: flex; flex-direction: column; gap: 16px; }
.mdl-panel > * { flex-shrink: 0; }
/* 每个标签页顶部一行：筛选 / 开关 + 「?」说明，操作按钮靠右 */
.mdl-toolbar { display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap; min-height: 34px; }
.mdl-toolbar input[type="search"] { flex: 1; min-width: 160px; max-width: 320px; }
.mdl-toolbar label.check { color: var(--text); }
.mdl-toolbar .note { color: var(--muted); font-size: 12px; }
.mdl-toolbar-end { margin-left: auto; }
.mdl-system-state { margin: 0; font-size: 12.5px; color: var(--text); }
.mdl-system-state:empty { display: none; }
.help-line { display: block; }
.help-line + .help-line { margin-top: 6px; }

/* 账号模型的显示开关（mv-）：账号模型在对话下拉里的显示开关 */
.mv-list { display: flex; flex-direction: column; gap: 22px; }
/* 按协议分组：Claude 协议 / OpenAI 协议 */
.mv-group { display: flex; flex-direction: column; gap: 10px; }
.mv-group-head { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; font-weight: 600; }
.mv-group-sub { font-size: 12px; font-weight: 400; color: var(--muted); }
.mv-cards { display: flex; flex-direction: column; gap: 8px; }
/* 账号卡片：收起时只有一行摘要，点开才列模型 */
.mv-card { padding: 0; gap: 0; }
.mv-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; min-height: 52px; }
.mv-head > .mv-title { padding-left: 4px; }
.mv-toggle {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap;
  padding: 8px 10px; margin: 0;
  background: none; border: 0; border-radius: calc(8px * var(--radius-scale));
  color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.mv-toggle:hover { background: var(--panel-2); }
.mv-toggle:focus-visible { outline: 2px solid var(--amber); outline-offset: -2px; }
.mv-chev {
  width: 6px; height: 6px; flex: none; margin: 0 2px 0 4px;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg); transition: transform 140ms ease;
}
.mv-card.open .mv-chev { transform: rotate(45deg); }
.mv-chev-none { visibility: hidden; margin-left: 14px; }
.mv-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.mv-account { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mv-slug { font-family: var(--mono); font-size: 11.5px; font-weight: 400; color: var(--muted); white-space: nowrap; }
.mv-summary { margin-left: auto; display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.mv-warn { color: var(--warn); }
.mv-warn::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: currentColor; vertical-align: 1px; }
/* 列定义在列表上，各行用 subgrid 共用：价格、跑腿按钮文字长短不一时也能对齐 */
.mv-rows {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) max-content max-content max-content 36px;
  column-gap: 14px;
  padding: 2px 18px 6px; border-top: 1px solid var(--line-soft);
}
@media (prefers-reduced-motion: reduce) { .mv-chev { transition: none; } }
.mv-row {
  grid-column: 1 / -1;
  display: grid; align-items: center; row-gap: 4px;
  grid-template-columns: subgrid;
  padding: 9px 2px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.mv-row:last-child { border-bottom: none; }
.mv-row:has(.mv-switch:disabled) { cursor: default; }
/* 默认标签、价格和跑腿按钮都可能隐藏，各列显式定位，避免后面的列往前挤 */
.mv-row > .mv-name { grid-column: 1; }
.mv-row > .mv-effort { grid-column: 2; }
.mv-row > .mv-price { grid-column: 3; justify-self: start; }
.mv-row > .mv-delegation { grid-column: 4; justify-self: start; }
.mv-row > .mv-tag { grid-column: 5; justify-self: end; }
.mv-row > .mv-switch { grid-column: 6; justify-self: end; }
.mv-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.mv-label, .mv-id, .mv-effort { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-label { font-size: 13.5px; }
.mv-id { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.mv-effort { font-size: 12px; color: var(--muted); }
.mv-tag {
  font-size: 11px; color: var(--amber); white-space: nowrap;
  border: 1px solid var(--amber-dim); border-radius: var(--radius-pill); padding: 1px 8px;
}
.mv-row.off .mv-name, .mv-row.off .mv-effort, .mv-row.off .mv-price, .mv-row.off .mv-delegation { opacity: 0.5; }
.mv-delegation { max-width: 100%; justify-content: flex-start; font-size: 12px; overflow: hidden; white-space: nowrap; color: var(--muted); }
.mv-delegation .action-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* 价格列：实际计费的输入 / 输出单价；兜底价与未定价用警示色 */
/* 宽屏不用负外边距对齐文字：内容定宽的列会因此少算 10px，按钮文字被截断 */
.mv-price { max-width: 100%; justify-content: flex-start; font-size: 12px; font-family: var(--mono); overflow: hidden; }
.mv-price .action-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.mv-price.warn, .mv-price.warn:hover:not(:disabled) { color: var(--warn); }
.mv-price[data-kind="unpriced"] { font-family: var(--sans); }
/* 开关：复选框换成滑块外观，保留原生的键盘操作与选中语义 */
.mv-switch {
  appearance: none; -webkit-appearance: none;
  position: relative; flex: none; margin: 0;
  width: 34px; height: 20px;
  border: 1px solid var(--line); border-radius: var(--radius-pill);
  background: var(--panel-2);
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.mv-switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: var(--radius-pill);
  background: var(--muted);
  transition: transform .15s, background-color .15s;
}
.mv-switch:checked { background: var(--accent); border-color: var(--accent); }
.mv-switch:checked::after { transform: translateX(14px); background: var(--on-accent); }
.mv-switch:disabled { opacity: 0.55; cursor: default; }
.mv-switch:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .mv-switch, .mv-switch::after { transition: none; } }

/* 价目表：八列，窄屏允许横向滚动。
 * 单价输入框定宽等宽字体，数字上下对齐才好核对；超阈值那四个挤在一格里。 */
.sec-hint { font-size: 12px; }
.sec-actions { display: flex; flex-wrap: wrap; gap: 8px; max-width: 100%; }

.price-table-wrap { margin: -4px -4px 0; overflow-x: auto; }
.price-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.price-table th {
  text-align: left; font-weight: 500; font-size: 12px; color: var(--muted);
  padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.price-table th.num { text-align: right; }
.price-table .th-sub { font-size: 10.5px; opacity: .75; font-weight: 400; }
.price-table td { padding: 5px 8px; border-bottom: 1px solid var(--line-soft); }
.price-table tr:last-child td { border-bottom: none; }
.price-table .pt-key {
  font-family: var(--mono); font-size: 12px;
  white-space: nowrap; max-width: 230px; overflow: hidden; text-overflow: ellipsis;
}
/* agent 兜底价（claude / codex）与具体模型行区分开：它管的是一整类 */
.price-table .pt-key.fallback { color: var(--muted); font-style: italic; }
.price-table input.rate {
  width: 78px; text-align: right;
  font-family: var(--mono); font-size: 12px;
  padding: 3px 6px;
}
.price-table input.rate.wide { width: 96px; }
.price-table .pt-long { display: flex; gap: 4px; justify-content: flex-end; }
.price-table .pt-del {
  min-width: 28px; min-height: 28px; border-radius: calc(6px * var(--radius-scale));
  border: 0; background: none; color: var(--muted); cursor: pointer;
  padding: 2px 6px; font-size: 15px; line-height: 1;
}
.price-table .pt-del:hover { color: var(--red); background: color-mix(in srgb, var(--red) 10%, transparent); }
.price-add { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--line); }
/* 价格目录：折叠卡片，标题行只显示来源与状态 */
.price-fold { display: block; padding: 0; }
.price-fold > summary { display: flex; align-items: center; gap: 12px; padding: 14px 18px; list-style: none; cursor: pointer; border-radius: inherit; }
.price-fold > summary::-webkit-details-marker { display: none; }
.price-fold > summary::before {
  content: ""; width: 6px; height: 6px; flex: none;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg); transition: transform 140ms ease;
}
.price-fold[open] > summary::before { transform: rotate(45deg); }
.price-fold > summary:hover { background: var(--panel-2); }
.price-fold > summary:focus-visible { outline: 2px solid var(--amber); outline-offset: -3px; }
.price-fold .price-catalog-head { display: flex; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; min-width: 0; }
.price-fold-title { font-size: 13.5px; font-weight: 600; }
.price-fold #price-catalog-status { font-size: 12.5px; color: var(--muted); line-height: 1.6; overflow-wrap: anywhere; }
.price-fold-body { display: flex; flex-direction: column; gap: 16px; padding: 2px 18px 18px; }
.price-sync-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
@media (prefers-reduced-motion: reduce) { .price-fold > summary::before { transition: none; } }
.price-add input { flex: 1; min-width: 160px; }

/* 用户管理 */
.user-list { display: flex; flex-direction: column; }
.user-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--line-soft);
}
.user-row:last-child { border-bottom: none; }
.user-row .u-name { font-size: 13.5px; font-weight: 600; flex: none; }
.user-row .u-role {
  font-size: 11px;
  border: 1px solid var(--line); border-radius: calc(4px * var(--radius-scale));
  color: var(--muted);
  padding: 1px 7px;
  flex: none;
}
.user-row .u-role.admin { color: var(--text); border-color: var(--muted); }
.user-row .u-meta {
  font-size: 12px; color: var(--muted);
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-row .u-actions { margin-left: auto; display: flex; gap: 8px; flex: none; }
.user-add { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--line); }
.user-add input { flex: 1; min-width: 140px; }

/* 关于 */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 24px; margin: 0; }
.kv dt { color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }

/* 运维监控 */
.mon-auto { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.mon-auto input { accent-color: var(--accent); }

.mon-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
/* 骨架整块占满磁贴区的一行，内部排成与真实磁贴相同的网格 */
.mon-tiles-skeleton { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.mon-tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: calc(10px * var(--radius-scale));
  padding: 12px 14px;
}
.mt-label { color: var(--muted); font-size: 12px; }
.mt-value { font-family: var(--mono); font-size: 21px; font-weight: 600; margin-top: 2px; color: var(--text-hi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-sub { color: var(--muted); font-size: 11.5px; margin-top: 4px; overflow-wrap: anywhere; }
.mt-bar { height: 4px; border-radius: var(--radius-pill); background: var(--panel-2); overflow: hidden; margin-top: 8px; }
.mt-bar span { display: block; height: 100%; border-radius: var(--radius-pill); background: var(--green); transition: width 0.4s ease; }
.mt-bar span.warn { background: var(--warn); }
.mt-bar span.hot { background: var(--red); }

.mon-card { padding: 0; overflow: hidden; }
.mon-card-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.mon-card-head h3 { margin: 0; }
.mon-table-wrap { overflow-x: auto; }
.mon-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mon-table th, .mon-table td { padding: 9px 14px; text-align: left; white-space: nowrap; }
.mon-table th {
  color: var(--muted); font-size: 11.5px; font-weight: 500;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel-solid);
}
.mon-table th.num, .mon-table td.num { text-align: right; font-family: var(--mono); }
.mon-table tbody tr { border-bottom: 1px solid var(--line-soft); }
.mon-table tbody tr:last-child { border-bottom: none; }
.mon-table tr.off td { color: var(--muted); }
.mon-name { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.mon-status { display: flex; align-items: center; gap: 6px; }
.mon-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.mon-dot.on { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 22%, transparent); }
.mon-empty { text-align: center; color: var(--muted); padding: 24px; }

/* ---- 窄屏：二级导航胶囊自动换行，账号行纵向堆叠 ---- */
@media (max-width: 760px) {
  .set-head { padding: 8px 16px; }
  .set-body { flex-direction: column; gap: 0; padding: 12px 16px 0; }
  .set-nav {
    flex-direction: row; flex-wrap: wrap; width: 100%;
    gap: 6px;
    padding: 0 0 12px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 16px;
  }
  .set-nav button {
    flex: none; width: auto;
    border: 1px solid var(--line); border-radius: var(--radius-pill);
    padding: 6px 14px; font-size: 13px;
    background: var(--panel);
  }
  .set-nav button.active { border-color: var(--amber-dim); }
  .set-nav > .ink { border-radius: var(--radius-pill); }

  .acct-row { grid-template-columns: minmax(0, 1fr); }
  .acct-actions { grid-row: auto; grid-column: 1; padding-top: 4px; flex-wrap: wrap; }
  .acct-proxy { max-width: 100%; }
  .model-row { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding-block: 12px; }
  .model-row .m-label { grid-column: 1; grid-row: 1; }
  .model-row .m-id { grid-column: 1; grid-row: 2; }
  .model-row .m-reasoning { grid-column: 1; grid-row: 3; justify-self: start; max-width: 100%; margin-left: -11px; }
  .model-row .m-remove { grid-column: 2; grid-row: 1 / 4; }
  .mv-rows { display: flex; flex-direction: column; }
  /* 价格与跑腿两个按钮并排放在第三行；用位移而不是负外边距对齐文字，内容定宽的列才不会少算 */
  .mv-row { grid-template-columns: max-content minmax(0, 1fr) auto 36px; column-gap: 14px; }
  .mv-row > .mv-name { grid-column: 1 / 3; grid-row: 1; }
  .mv-row > .mv-effort { grid-column: 1 / 4; grid-row: 2; }
  .mv-row > .mv-price { grid-column: 1; grid-row: 3; }
  .mv-row > .mv-delegation { grid-column: 2 / 4; grid-row: 3; }
  .mv-row > .mv-tag { grid-column: 3; grid-row: 1; }
  .mv-row > .mv-switch { grid-column: 4; grid-row: 1 / 4; }
  .mv-price, .mv-delegation { translate: -10px 0; }
  .mdl-tabs { align-self: stretch; overflow-x: auto; }
  .mdl-toolbar input[type="search"] { max-width: none; }
  .mv-summary { margin-left: 0; flex-basis: 100%; padding-left: 20px; }
  .mv-manage .action-label { display: none; }
  .mv-rows { padding-inline: 14px; }
  /* 代理表有 7 列，窄屏必然横向滚动；操作列的按钮别再被挤成两行 */
  .px-actions { justify-content: flex-start; }
  .px-head-actions { width: 100%; }

  /* 用户行加上额度标签和「额度」按钮之后一行就装不下了：名字 + 角色 + 会话数 +
     额度 + 三个按钮，在 390px 上要 430px 左右，而按钮那一组是 flex:none，挤不动，
     于是直接顶出框外。窄屏拆成两行——信息一行，按钮另起一行。 */
  .user-row { flex-wrap: wrap; gap: 8px 10px; padding: 10px 2px; }
  .user-row .u-name { flex: 0 1 auto; min-width: 0; overflow-wrap: anywhere; }
  .user-row .u-meta { flex: 1 1 auto; }
  .user-row .u-actions { flex-basis: 100%; margin-left: 0; flex-wrap: wrap; }
  .card-foot { flex-wrap: wrap; }
  .card-foot .note { flex-basis: 100%; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 8px; }
}

/* ---- 用户行上的额度标签 ---- */
.user-row .u-quota {
  font-size: 11.5px; font-variant-numeric: tabular-nums;
  border: 1px solid var(--line); border-radius: calc(4px * var(--radius-scale));
  padding: 1px 7px; flex: none;
  color: var(--text);
}
.user-row .u-quota.off { color: var(--muted); opacity: 0.75; }
.user-row .u-quota.track { color: var(--muted); border-style: dashed; }
.user-row .u-quota.blocked { color: var(--red); border-color: var(--red-line); }

/* Price catalog: status, reviewable changes and protected custom rates. */
.price-catalog { gap: 16px; }
.price-catalog-head { display: grid; gap: 6px; }
.price-catalog-head p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.6; overflow-wrap: anywhere; }
.price-catalog .card-desc, .price-editor .card-desc, .price-history .card-desc { margin: 0; line-height: 1.6; }
.price-catalog .field-row { display: grid; grid-template-columns: minmax(220px, 1fr) auto auto auto; align-items: end; gap: 12px; }
.price-catalog .field { min-width: 0; }
.price-catalog .field input, .price-catalog .field-row > .btn { height: 36px; }
.price-catalog .field input { padding-block: 7px; font-size: 13px; line-height: 20px; }
.price-sync-options { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.price-auto { display: flex; align-items: center; gap: 6px; min-height: 36px; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.price-auto input { margin: 0; }
.price-notice { padding: 10px 12px; margin: 0; border-left: 3px solid var(--warn); background: color-mix(in srgb, var(--warn) 7%, transparent); font-size: 12.5px; line-height: 1.6; overflow-wrap: anywhere; }
.price-notice p { margin: 6px 0; }
.price-notice ul { margin: 8px 0; padding-left: 20px; max-height: 180px; overflow-y: auto; }
.price-changes { max-height: 460px; overflow-y: auto; margin: 12px 0; border-top: 1px solid var(--line); }
#price-diff { padding-top: 16px; border-top: 1px solid var(--line); }
#price-diff > p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.price-change { padding: 12px 0; border-bottom: 1px solid var(--line-soft); overflow-wrap: anywhere; }
.price-change label { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; cursor: pointer; }
.price-change label span { font-size: 12px; color: var(--warn); }
.price-change p { margin: 7px 0 0 24px; }
.price-change .card-desc { margin: 7px 0 0 24px; line-height: 1.5; }
.price-change a { color: var(--amber); text-underline-offset: 2px; }
.price-change-rates { font-size: 12px; font-variant-numeric: tabular-nums; }
.price-table .pt-key small { display: block; margin-top: 4px; font: 11px/1.4 var(--font-sans, sans-serif); color: var(--muted); }
.price-mode { display: flex; justify-content: flex-start; padding: 4px 0; font-size: 11px; color: var(--amber); background: none; border: 0; cursor: pointer; }
.price-history { display: block; padding: 0; }
.price-history summary {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 14px 18px;
  border-radius: inherit; list-style: none; cursor: pointer;
  font-size: 13.5px; font-weight: 600; line-height: 24px;
}
.price-history summary::-webkit-details-marker { display: none; }
.price-history summary::before {
  content: ""; width: 6px; height: 6px; flex: none;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg); transition: transform 140ms ease;
}
.price-history[open] summary::before { transform: rotate(45deg); }
.price-history summary:hover { background: var(--panel-2); }
.price-history summary:focus-visible { outline: 2px solid var(--amber); outline-offset: -3px; }
.price-history-body { display: grid; gap: 12px; padding: 0 18px 16px; }
.price-history-body p { margin: 0; }
.price-history-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line-soft); }
@media (max-width: 1200px) {
  .price-catalog .field-row { grid-template-columns: minmax(0, 1fr) auto auto; }
  .price-catalog .field { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .price-catalog .field-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .price-auto { grid-column: 1 / -1; }
  .price-history-row { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { .price-history summary::before { transition: none; } }

/* CLI update status stays readable on narrow settings panels. */
:is(#image-update-card, #image-update-ops) > p { margin: 0; line-height: 1.6; }
:is(#image-update-card, #image-update-ops) .note { font-size: 12px; color: var(--muted); }
#image-update-dirty:not([hidden]) { color: var(--warn); }
#image-update-dirty[hidden] { display: none; }
.image-update-log { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 280px; overflow: auto; font-size: 12px; }
.image-update-ref { overflow-wrap: anywhere; }
/* 任务进度：阶段与百分比一行，下面一条进度条；任务结束后停在终态，离开页面再回来不显示 */
.image-update-meter { display: flex; flex-direction: column; gap: 6px; padding: 10px 0 2px; }
.image-update-meter-head { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--text); }
#image-update-pct { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- 统一保存条：贴在设置内容区底部，有未保存的修改时出现 ---- */
.set-savebar {
  position: sticky; bottom: 12px; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  margin-top: 16px; padding: 10px 12px 10px 16px;
  background: var(--panel-solid); border: 1px solid var(--warn-line); border-radius: calc(10px * var(--radius-scale));
  box-shadow: var(--shadow-md);
}
.set-savebar[hidden] { display: none; }
.set-savebar-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.set-savebar-text { flex: 1; min-width: 0; font-size: 13px; color: var(--text); overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .set-savebar { bottom: max(8px, env(safe-area-inset-bottom)); flex-wrap: wrap; padding: 10px 12px; }
  .set-savebar-text { flex-basis: calc(100% - 20px); }
  .set-savebar .btn { flex: 1; }
}

/* 「了解更多」：卡片说明只留一句话，实现细节收在这里 */
.learn-more { font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.learn-more > summary { width: fit-content; cursor: pointer; color: var(--muted); list-style: none; display: inline-flex; align-items: center; gap: 4px; }
.learn-more > summary::-webkit-details-marker { display: none; }
.learn-more > summary::after { content: ""; width: 6px; height: 6px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: translateY(-2px) rotate(45deg); transition: transform 140ms ease; }
.learn-more[open] > summary::after { transform: translateY(1px) rotate(-135deg); }
.learn-more > summary:hover { color: var(--text); }
.learn-more > p { margin: 6px 0 0; }
.learn-more .sec-hint { margin: 6px 0 0; }
@media (prefers-reduced-motion: reduce) { .learn-more > summary::after { transition: none; } }
.card > .learn-more { margin-top: -8px; }
/* 智能决策：fieldset 只用来整体禁用，排版与 .set-section 相同，卡片之间留同样的间距 */
.decision-settings-fields { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.dc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.dc-head-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dc-head-text .card-desc { margin: 0; line-height: 1.55; }
.dc-switch { display: inline-flex; align-items: center; gap: 10px; flex: none; font-size: 12.5px; color: var(--text); cursor: pointer; }
.dc-key-state {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  font-size: 11.5px; color: var(--muted); white-space: nowrap;
  border: 1px solid var(--line); border-radius: var(--radius-pill); padding: 1px 9px;
}
.dc-key-state::before { content: ""; width: 6px; height: 6px; border-radius: var(--radius-pill); background: currentColor; opacity: .7; }
.dc-key-state[data-state="on"] { color: var(--green); border-color: var(--green-line); }
.dc-callout {
  margin: 0; padding: 8px 12px; font-size: 12px; line-height: 1.55; color: var(--muted);
  border: 1px solid var(--line); border-left: 3px solid var(--amber-dim);
  border-radius: calc(6px * var(--radius-scale)); background: var(--panel-2);
}
.dc-callout.warn { color: var(--warn); border-color: var(--warn-line); border-left-color: var(--warn); background: color-mix(in srgb, var(--warn) 6%, transparent); }
.card > .dc-callout { margin-top: -6px; }
/* 并排的字段按宽度自动换行：窄屏一行一个，免得下拉文字被截成「保留已…」 */
#sec-decision .field-row .field { flex: 1 1 200px; }
#sec-decision .learn-more > .field-row { margin-top: 12px; }
#sec-decision .learn-more .field { flex-basis: 160px; }
#sec-decision .field input:disabled { opacity: .55; cursor: not-allowed; }
@media (max-width: 560px) {
  .dc-head { flex-wrap: wrap; }
}
