/* 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: 7px;
  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);
}
.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: 999px;
  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;
}
.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: 10px;
  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; }

.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-family: var(--mono); font-size: 10.5px;
  border: 1px solid var(--line); border-radius: 4px;
  color: var(--muted);
  padding: 0 6px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.tag.restart { color: var(--amber); border-color: var(--amber-dim); }
.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: 10px;
  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: 4px;
  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-family: var(--mono); font-size: 11.5px; 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: 8px; 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; }

/* 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: 8px;
}
.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-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: 4px;
  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: 5px;
  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; }

/* 价目表：八列，窄屏允许横向滚动。
 * 单价输入框定宽等宽字体，数字上下对齐才好核对；超阈值那四个挤在一格里。 */
.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(--amber); }
.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: 6px;
  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-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-family: var(--mono); font-size: 10.5px;
  letter-spacing: 0.06em;
  border: 1px solid var(--line); border-radius: 4px;
  color: var(--muted);
  padding: 1px 7px;
  flex: none;
}
.user-row .u-role.admin { color: var(--amber); border-color: var(--amber-dim); }
.user-row .u-meta {
  font-family: var(--mono); font-size: 11.5px; 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-tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  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); }
.mt-sub { color: var(--muted); font-size: 11.5px; margin-top: 4px; overflow-wrap: anywhere; }
.mt-bar { height: 4px; border-radius: 999px; background: var(--panel-2); overflow: hidden; margin-top: 8px; }
.mt-bar span { display: block; height: 100%; border-radius: 999px; background: var(--green); transition: width 0.4s ease; }
.mt-bar span.warn { background: var(--amber); }
.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);
}
.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: 999px;
    padding: 6px 14px; font-size: 13px;
    background: var(--panel);
  }
  .set-nav button.active { border-color: var(--amber-dim); }

  .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; }
  /* 代理表有 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-family: var(--mono); font-size: 11.5px;
  border: 1px solid var(--line); border-radius: 4px;
  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-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(--amber); background: color-mix(in srgb, var(--amber) 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(--amber); }
.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; } }
