/* ============================================================
   共用样式：移动端优先，无框架，无外部字体
   ============================================================ */

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #16181d;
  --ink-2: #5a626f;
  --ink-3: #8b93a1;
  --line: #e5e7eb;
  --line-2: #eef0f3;
  --brand: #2563eb;
  --brand-soft: #eff4ff;
  --ok: #15803d;
  --ok-soft: #e9f7ee;
  --warn: #b45309;
  --warn-soft: #fdf5e6;
  --danger: #c81e1e;
  --danger-soft: #fdecec;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.05);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ============================ 布局 ============================ */

.page {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px calc(32px + env(safe-area-inset-bottom));
}

.page--wide {
  max-width: 1120px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.brand__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.muted {
  color: var(--ink-2);
  font-size: 13px;
}

.tiny {
  font-size: 12px;
  color: var(--ink-3);
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* ============================ 卡片 ============================ */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.card + .card {
  margin-top: 14px;
}

.card__title {
  font-size: 13px;
  font-weight: 650;
  color: var(--ink-2);
  letter-spacing: 0.02em;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.field {
  margin-bottom: 12px;
}

.field:last-child {
  margin-bottom: 0;
}

label.label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}

input,
select,
textarea {
  width: 100%;
  font: inherit;
  font-size: 16px; /* 16px 避免 iOS 聚焦缩放 */
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}

textarea {
  min-height: 76px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 14px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-3);
}

input.key-input {
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 0.01em;
}

select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%238b93a1' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 34px;
}

.row {
  display: flex;
  gap: 10px;
}

.row > * {
  flex: 1;
  min-width: 0;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
  user-select: none;
}

.btn:active {
  transform: scale(0.985);
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--block {
  width: 100%;
}

.btn--ghost {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.btn--soft {
  background: var(--brand-soft);
  color: var(--brand);
}

.btn--danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn--sm {
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 8px;
}

.btn--xs {
  font-size: 12px;
  padding: 5px 9px;
  border-radius: 7px;
}

/* ============================ 状态 ============================ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--line-2);
  color: var(--ink-2);
  white-space: nowrap;
}

.chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.chip--ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.chip--warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.chip--danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.chip--info {
  background: var(--brand-soft);
  color: var(--brand);
}

.chip--plain {
  background: var(--line-2);
  color: var(--ink-2);
}

.chip--plain::before {
  display: none;
}

.alert {
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 13.5px;
  margin-bottom: 12px;
  display: none;
}

.alert--show {
  display: block;
}

.alert--error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #f6d5d5;
}

.alert--info {
  background: var(--brand-soft);
  color: #1d4ed8;
  border: 1px solid #dbe6ff;
}

.alert--warn {
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid #f3e3c3;
}

/* ============================ 额度展示 ============================ */

.balance {
  text-align: center;
  padding: 6px 0 2px;
}

.balance__label {
  font-size: 12.5px;
  color: var(--ink-3);
  font-weight: 600;
}

.balance__value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  margin: 4px 0 2px;
}

.balance__num {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.balance__unit {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
}

.bar {
  height: 9px;
  border-radius: 999px;
  background: var(--line-2);
  overflow: hidden;
  margin: 14px 0 8px;
}

.bar__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--brand);
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  min-width: 2px;
}

.bar__fill--warn {
  background: #e8a33d;
}

.bar__fill--danger {
  background: var(--danger);
}

.bar__meta {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--ink-3);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: 16px;
}

.stat {
  background: var(--card);
  padding: 11px 8px;
  text-align: center;
}

.stat__label {
  font-size: 11.5px;
  color: var(--ink-3);
  margin-bottom: 2px;
}

.stat__value {
  font-size: 15px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

/* ============================ 图表 ============================ */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 92px;
  padding-top: 6px;
}

.chart__col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  height: 100%;
  min-width: 0;
}

.chart__bar {
  width: 100%;
  max-width: 26px;
  border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, #5c8bfa, var(--brand));
  min-height: 2px;
  transition: height 0.4s ease;
}

.chart__date {
  font-size: 10px;
  color: var(--ink-3);
  white-space: nowrap;
  transform: scale(0.92);
}

/* ============================ 列表 ============================ */

.list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-2);
}

.list__item:last-child {
  border-bottom: none;
}

.list__main {
  min-width: 0;
  flex: 1;
}

.list__title {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list__sub {
  font-size: 11.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.list__amount {
  font-size: 13.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.empty {
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
  padding: 22px 0;
}

/* ============================ 提示 ============================ */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  background: #16181d;
  color: #fff;
  font-size: 13.5px;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  z-index: 200;
  max-width: 86vw;
  text-align: center;
}

.toast--show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.skeleton {
  background: linear-gradient(90deg, var(--line-2) 25%, #f7f8fa 37%, var(--line-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
  border-radius: 6px;
}

@keyframes shimmer {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ============================================================
   后台专用
   ============================================================ */

.admin-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.tabs {
  display: flex;
  gap: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 8px 15px;
  cursor: pointer;
  white-space: nowrap;
}

.tab--active {
  background: var(--ink);
  color: #fff;
}

.panel {
  display: none;
}

.panel--active {
  display: block;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -18px;
  padding: 0 18px;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

table.data th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-3);
  padding: 8px 10px 8px 0;
  border-bottom: 1px solid var(--line);
}

table.data td {
  padding: 11px 10px 11px 0;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}

table.data tr:last-child td {
  border-bottom: none;
}

table.data td.num {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 12.5px;
}

.keylist {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.keycard {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 14px;
}

.keycard__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.keycard__name {
  font-weight: 650;
  font-size: 15px;
  word-break: break-all;
}

.keycard__mask {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
  word-break: break-all;
}

.keycard__actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.secret-box {
  margin-top: 12px;
  border: 1px dashed #c9d6f5;
  background: var(--brand-soft);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.secret-box__label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--brand);
  margin-bottom: 6px;
}

.secret-box__value {
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
  line-height: 1.5;
  user-select: all;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.44);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 300;
}

.modal--show {
  display: flex;
}

.modal__box {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: 0 24px 64px rgba(16, 24, 40, 0.24);
}

.modal__title {
  font-size: 16px;
  font-weight: 650;
  margin: 0 0 14px;
}

.modal__actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

.modal__actions .btn {
  flex: 1;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 360px;
}

@media (min-width: 860px) {
  .page {
    padding: 32px 24px 48px;
  }

  .admin-shell {
    grid-template-columns: repeat(12, 1fr);
  }

  .admin-shell > .col-12 {
    grid-column: span 12;
  }

  .admin-shell > .col-8 {
    grid-column: span 8;
  }

  .admin-shell > .col-6 {
    grid-column: span 6;
  }

  .admin-shell > .col-4 {
    grid-column: span 4;
  }

  .keylist {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  }
}

/* ============================================================
   用量概览 / 时间维度 / 按模型 / 明细
   ============================================================ */

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: 12px 0 14px;
}

.metric {
  background: var(--card);
  padding: 12px 6px;
  text-align: center;
}

.metric__label {
  font-size: 11.5px;
  color: var(--ink-3);
  margin-bottom: 4px;
  white-space: nowrap;
}

.metric__value {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  word-break: break-all;
}

.range-switch {
  display: flex;
  gap: 4px;
  background: var(--line-2);
  border-radius: 999px;
  padding: 3px;
  margin-bottom: 4px;
}

.range-btn {
  flex: 1;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 7px 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.range-btn--active {
  background: #fff;
  color: var(--brand);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

.token-split {
  border-top: 1px solid var(--line-2);
  padding-top: 10px;
}

.token-split__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  font-size: 13px;
}

.token-split__key {
  color: var(--ink-2);
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.token-split__val {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.token-split__row--total {
  border-top: 1px dashed var(--line);
  margin-top: 4px;
  padding-top: 9px;
  font-weight: 650;
}

.token-split__row--total .token-split__key {
  color: var(--ink);
}

.model-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.model-row__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.model-row__name {
  font-size: 13.5px;
  font-weight: 600;
  word-break: break-all;
}

.model-row__amount {
  font-size: 13.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.model-row__bar {
  height: 6px;
  border-radius: 999px;
  background: var(--line-2);
  overflow: hidden;
}

.model-row__bar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #5c8bfa, var(--brand));
  min-width: 2px;
}

.model-row__meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--ink-3);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.rec-list {
  display: flex;
  flex-direction: column;
}

.rec {
  padding: 10px 0;
  border-bottom: 1px solid var(--line-2);
}

.rec:last-child {
  border-bottom: none;
}

.rec__row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.rec__day {
  font-size: 12px;
  color: var(--ink-3);
  flex: none;
  width: 42px;
}

.rec__model {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rec__amount {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rec__row--sub {
  margin-top: 4px;
  padding-left: 50px;
  font-size: 11.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  flex-wrap: wrap;
  gap: 10px;
}

@media (min-width: 860px) {
  .metric__value {
    font-size: 21px;
  }

  .metric {
    padding: 16px 10px;
  }
}

/* ============================================================
   客户端自适应布局
   移动端：单列卡片流
   桌面端（>=900px）：12 栅格，额度/概览并排，趋势通栏，
                      按模型 + 明细并排，明细改表格
   ============================================================ */

/* ---- 搜索行：移动端纵向，按钮全宽 ---- */
.search-row .field {
  margin-bottom: 0;
}

.search-row .btn {
  width: 100%;
  margin-top: 12px;
}

/* ---- 明细表格：移动端用卡片，表格隐藏 ---- */
.rec-table-wrap {
  display: none;
}

.rec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.rec-table th {
  text-align: right;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  padding: 0 0 9px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.rec-table th:first-child,
.rec-table th:nth-child(2) {
  text-align: left;
}

.rec-table td {
  padding: 10px 0;
  border-bottom: 1px solid var(--line-2);
  text-align: right;
  white-space: nowrap;
}

.rec-table td:first-child {
  text-align: left;
  color: var(--ink-3);
  padding-right: 10px;
}

.rec-table td.rec-model {
  text-align: left;
  font-weight: 600;
  padding-right: 12px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rec-table td.num {
  font-variant-numeric: tabular-nums;
}

.rec-table td.hit {
  color: var(--brand);
}

.rec-table td.amt {
  font-weight: 700;
}

.rec-table tr:last-child td {
  border-bottom: none;
}

/* ---- 桌面端 ---- */
@media (min-width: 900px) {
  .page--client {
    max-width: 1180px;
    padding: 30px 28px 48px;
  }

  .page--client .topbar {
    margin-bottom: 20px;
  }

  /* 搜索行：输入框与按钮同一行 */
  .search-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
  }

  .search-row .field {
    flex: 1;
    min-width: 0;
  }

  .search-row .btn {
    width: auto;
    flex: none;
    margin-top: 0;
    padding: 0 30px;
    min-height: 50px;
  }

  /* 结果区 12 栅格 */
  #result {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
  }

  .card--quota {
    grid-column: span 4;
  }

  .card--summary {
    grid-column: span 8;
  }

  .card--trend {
    grid-column: span 12;
  }

  .card--models {
    grid-column: span 5;
  }

  .card--records {
    grid-column: span 7;
  }

  /* 趋势图在宽栏里给足高度 */
  #result .card--trend .chart {
    height: 168px;
    gap: 6px;
  }

  #result .card--trend .chart__bar {
    max-width: 40px;
  }

  #result .card--trend .chart__date {
    font-size: 10.5px;
    transform: none;
  }

  /* 配额卡在窄栏里纵向更紧凑 */
  .card--quota .balance__num {
    font-size: 40px;
  }

  /* 明细切换成表格 */
  .rec-table-wrap {
    display: block;
  }

  .rec-list {
    display: none;
  }
}

/* 中等宽度：额度卡与概览各占一半，避免挤 */
@media (min-width: 900px) and (max-width: 1099px) {
  .card--quota {
    grid-column: span 5;
  }

  .card--summary {
    grid-column: span 7;
  }

  .card--models,
  .card--records {
    grid-column: span 12;
  }
}

/* #result 用 class 控制显隐，避免内联 display 覆盖栅格 */
#result {
  display: none;
}

#result.is-visible {
  display: block;
}

@media (min-width: 900px) {
  #result.is-visible {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
  }
}

/* 趋势柱宽约束：天多时不要撑得过粗 */
#result .card--trend .chart__bar {
  max-width: 26px;
}

#result .card--trend .chart__col {
  min-width: 0;
}

/* 趋势图：移动端加高，日期标签缩小避免相邻重叠 */
.page--client .card--trend .chart {
  height: 112px;
  gap: 3px;
}

.page--client .card--trend .chart__date {
  font-size: 9.5px;
  letter-spacing: -0.02em;
  transform: none;
  overflow: visible;
}

.page--client .card--trend .chart__col {
  overflow: visible;
}


/* 日期标签绘制在柱子之上，避免被相邻列的柱子盖住 */
.page--client .card--trend .chart__date {
  position: relative;
  z-index: 2;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff;
}

.page--client .card--trend .chart__bar {
  position: relative;
  z-index: 1;
}

/* 结果区与上方搜索卡的间距（桌面/移动统一） */
#result.is-visible {
  margin-top: 14px;
}

/* 桌面端：搜索卡不需要撑满整行 */
@media (min-width: 900px) {
  .page--client .search-card {
    max-width: 700px;
  }
}

/* 日期轴：独立一行，位于柱子下方，不参与柱区布局 */
.page--client .card--trend .chart-xaxis {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding: 0 2px;
  font-size: 10px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 柱区不再需要底部留白给轴标签 */
.page--client .card--trend .chart {
  height: 96px;
  padding-top: 4px;
}

@media (min-width: 900px) {
  .page--client .card--trend .chart {
    height: 168px;
  }
}

/* 客户端顶栏：登录后的 Key 与退出 */
.userbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.userbar__key {
  font-size: 11.5px;
  color: var(--ink-3);
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 时间维度有 5 个选项时，移动端压缩一下 */
@media (max-width: 420px) {
  .range-btn {
    font-size: 11.5px;
    padding: 7px 2px;
  }
}

/* 桌面端：同一行的卡片等高（额度卡与用量概览高度一致） */
@media (min-width: 900px) {
  #result.is-visible {
    align-items: stretch;
  }

  /* 额度卡内容撑开，充值按钮贴底 */
  .card--quota {
    display: flex;
    flex-direction: column;
  }

  .card--quota .btn[data-action="open-redeem"] {
    margin-top: auto !important;
  }


}

/* 桌面端：搜索卡居中 */
@media (min-width: 900px) {
  .page--client .search-card {
    margin-left: auto;
    margin-right: auto;
  }
}

/* 桌面端：未登录时顶栏与搜索卡同宽居中；登录后顶栏回到全宽对齐结果区 */
@media (min-width: 900px) {
  .page--client .topbar {
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
  }

  body.is-logged-in .page--client .topbar {
    max-width: none;
  }
}

/* 复选框恢复原生外观：全局 input{appearance:none} 会把它抹成空白方块，
   导致「使用可见浏览器窗口」看不出勾没勾 */
input[type="checkbox"] {
  appearance: auto;
  -webkit-appearance: auto;
  width: auto;
  height: auto;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: none;
  box-shadow: none;
  accent-color: var(--brand);
  vertical-align: middle;
}

/* ============================================================
   后台移动端适配（< 860px，与栅格断点对齐）
   概览与 API Key 本来就窄，问题集中在带筛选行和宽表格的面板
   ============================================================ */
@media (max-width: 859px) {
  /* grid 子项默认 min-width:auto，会被表格内容撑破，导致整页横向滚动 */
  .admin-shell > *,
  .panel,
  .card {
    min-width: 0;
  }

  /* 表单行改为纵向堆叠（原本三四个控件挤一行，总宽超过屏幕） */
  .row {
    flex-wrap: wrap;
    gap: 10px;
  }

  .row > * {
    flex: 1 1 100% !important;
    width: 100%;
    min-width: 0;
  }

  /* 表格容器自己横向滚动，不再把整页撑宽 */
  .table-wrap {
    max-width: 100%;
    margin: 0 -14px;
    padding: 0 14px;
  }

  /* 长文本（运维状态行、备注、掩码）允许断行 */
  .tiny,
  .muted {
    overflow-wrap: anywhere;
  }

  .card {
    padding: 16px 14px;
  }

  .card__title {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* 顶栏与面板内按钮组在小屏上留足点击高度 */
  .btn--xs {
    min-height: 30px;
  }

  /* 列表卡片里的操作按钮允许换行 */
  .keycard__actions,
  .list__actions {
    flex-wrap: wrap;
  }
}

/* 后台移动端：表格密度收紧，让一屏能看到更多列（可横向滑动） */
@media (max-width: 859px) {
  table.data {
    font-size: 12px;
  }

  table.data th {
    font-size: 11px;
    padding: 7px 8px 7px 0;
  }

  table.data td {
    padding: 9px 8px 9px 0;
  }

  table.data td.num {
    font-size: 11.5px;
  }

  /* 字段之间间距统一（原来 .row 内的字段与独立 .field 不一致） */
  .field + .field {
    margin-top: 12px;
  }

  .row + .field {
    margin-top: 12px;
  }
}

/* 后台移动端：列表项（账号池、Key 明细）改为上下两行，避免信息挤在一行 */
@media (max-width: 859px) {
  .list__item {
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 12px 0;
  }

  .list__main {
    flex: 1 1 100%;
  }

  .list__title {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    font-size: 13px;
    line-height: 1.35;
  }

  .list__sub {
    font-size: 11px;
    line-height: 1.5;
  }
}

/* ============================================================
   后台移动端：宽表格转「两列卡片」，避免横向滑动看操作按钮
   ============================================================ */
@media (max-width: 859px) {
  /* 账号池：账号 / 余额 / 名额 / 已售 / 状态 / 操作 */
  #accountList .table-wrap,
  #cdkList .table-wrap {
    overflow: visible;
    margin: 0;
    padding: 0;
  }

  #accountList thead,
  #cdkList thead {
    display: none;
  }

  #accountList table,
  #accountList tbody,
  #cdkList table,
  #cdkList tbody {
    display: block;
    width: 100%;
  }

  #accountList tr,
  #cdkList tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 12px;
    padding: 13px 0;
    border-bottom: 1px solid var(--line-2);
  }

  #accountList tr:last-child,
  #cdkList tr:last-child {
    border-bottom: none;
  }

  #accountList td,
  #cdkList td {
    display: block;
    padding: 0 !important;
    border: none !important;
    white-space: normal;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  /* 右侧数值列靠右对齐 */
  #accountList td:nth-child(2),
  #accountList td:nth-child(4),
  #cdkList td:nth-child(2) {
    text-align: right;
  }

  /* 状态与操作按钮独占一行 */
  #accountList td:nth-child(5),
  #accountList td:nth-child(6),
  #cdkList td:nth-child(3),
  #cdkList td:nth-child(4),
  #cdkList td:nth-child(5),
  #cdkList td:nth-child(6) {
    grid-column: 1 / -1;
  }

  #accountList td:nth-child(6),
  #cdkList td:nth-child(6) {
    margin-top: 2px;
  }
}

/* 后台移动端：筛选行里的按钮保持自适应宽度，不必拉满整行 */
@media (max-width: 859px) {
  .row > .btn {
    flex: 0 0 auto !important;
    width: auto;
    align-self: flex-start;
  }
}
