/* ============================================================
   中转站监控 · 设计令牌
   ============================================================ */
:root {
  color-scheme: light;

  --primary: #4f46e5;
  --primary-2: #6366f1;
  --primary-soft: rgba(79, 70, 229, 0.09);

  --green: #16a34a;
  --green-soft: rgba(22, 163, 74, 0.1);
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, 0.09);
  --amber: #d97706;
  --amber-soft: rgba(217, 119, 6, 0.1);

  --bg: #f3f4f9;
  --bg-blur: rgba(243, 244, 249, 0.84);
  --card: #ffffff;
  --card-2: #f4f5f9;
  --text: #101828;
  --text-2: #475467;
  --text-3: #8b93a3;
  --line: rgba(16, 24, 40, 0.07);
  --line-strong: rgba(16, 24, 40, 0.13);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 12px 32px -22px rgba(16, 24, 40, 0.32);
  --shimmer: rgba(255, 255, 255, 0.72);
  --tabbar: rgba(255, 255, 255, 0.95);

  --radius: 16px;
  --radius-sm: 12px;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --primary: #6366f1;
  --primary-2: #818cf8;
  --primary-soft: rgba(99, 102, 241, 0.16);

  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.12);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.12);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.12);

  --bg: #0a0c12;
  --bg-blur: rgba(10, 12, 18, 0.82);
  --card: #141822;
  --card-2: #1c212d;
  --text: #eef1f7;
  --text-2: #b6bdcc;
  --text-3: #7f8899;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 16px 40px -26px rgba(0, 0, 0, 0.9);
  --shimmer: rgba(255, 255, 255, 0.06);
  --tabbar: rgba(16, 20, 28, 0.84);
}

/* ============================================================
   基础
   ============================================================ */
* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

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

body {
  background: var(--bg);
  color: var(--text);
  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.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

body.locked {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: var(--primary);
}

.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;
}

.muted {
  color: var(--text-3);
  font-size: 12px;
}

.hint {
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-3);
}

.footnote {
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
  padding: 4px 8px 8px;
}

::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* ============================================================
   布局
   ============================================================ */
.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px calc(88px + env(safe-area-inset-bottom, 0px));
  min-height: 100vh;
}

main {
  padding-top: 6px;
}

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

.view {
  padding-bottom: 4px;
}

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

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

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

.card-head > div .card-note {
  margin-top: 3px;
  white-space: normal;
}

@media (min-width: 600px) {
  .app {
    padding-left: 20px;
    padding-right: 20px;
  }

  .stack {
    gap: 16px;
  }

  .card {
    padding: 20px;
  }
}

/* ============================================================
   顶部状态条
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 0 10px;
  background: var(--bg-blur);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
}

.status-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: left;
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.status-btn:active {
  transform: scale(0.994);
}

.status-btn:disabled {
  cursor: default;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--text-3);
  box-shadow: 0 0 0 4px rgba(139, 147, 163, 0.12);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.status-dot.ok {
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-soft);
}

.status-dot.err {
  background: var(--red);
  box-shadow: 0 0 0 4px var(--red-soft);
}

.status-dot.idle {
  background: var(--text-3);
  box-shadow: 0 0 0 4px rgba(139, 147, 163, 0.12);
}

.status-name {
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-ver {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.status-lat {
  margin-left: auto;
  flex: none;
  font-size: 11.5px;
  font-weight: 550;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.refresh-ic {
  width: 15px;
  height: 15px;
  flex: none;
  color: var(--text-3);
}

.status-btn.is-spinning .refresh-ic {
  animation: spin 0.9s linear infinite;
}

.status-btn.is-pulsing .refresh-ic {
  animation: fadePulse 0.9s ease-in-out 2;
}

.icon-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--text-2);
  transition: transform 0.12s ease;
}

.icon-btn:active {
  transform: scale(0.95);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.ic-sun {
  display: none;
}

html[data-theme="dark"] .ic-sun {
  display: block;
}

html[data-theme="dark"] .ic-moon {
  display: none;
}

/* ============================================================
   横幅提示
   ============================================================ */
.banner-host {
  position: fixed;
  left: 50%;
  top: calc(66px + env(safe-area-inset-top, 0px));
  transform: translateX(-50%);
  width: min(688px, calc(100% - 32px));
  z-index: 45;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.banner {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 8px 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: 0 14px 34px -20px rgba(16, 24, 40, 0.45);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  animation: slideDown 0.22s ease;
}

.banner.out {
  animation: fadeOut 0.18s ease forwards;
}

.banner-error {
  background: var(--red-soft);
  border-color: rgba(220, 38, 38, 0.22);
  color: var(--red);
}

html[data-theme="dark"] .banner-error {
  border-color: rgba(248, 113, 113, 0.24);
}

.banner-ok {
  background: var(--green-soft);
  border-color: rgba(22, 163, 74, 0.22);
  color: var(--green);
}

.banner-info {
  background: var(--primary-soft);
  border-color: rgba(79, 70, 229, 0.2);
  color: var(--primary);
}

.banner-text {
  flex: 1;
  min-width: 0;
  padding-top: 2px;
  word-break: break-word;
}

.banner-x {
  flex: none;
  width: 44px;
  height: 44px;
  margin: -6px -4px -6px 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: currentColor;
  font-size: 18px;
  line-height: 1;
  opacity: 0.7;
}

.banner-x:active {
  opacity: 1;
}

.banner-inline {
  animation: none;
  border-radius: var(--radius-sm);
  box-shadow: none;
  padding: 12px 14px;
  pointer-events: auto;
}

.banner-inline .banner-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.banner-inline strong {
  font-size: 13px;
  font-weight: 650;
}

.banner-inline span {
  font-size: 12px;
  opacity: 0.9;
}

/* ============================================================
   首页主卡片
   ============================================================ */
.hero {
  position: relative;
  overflow: hidden;
  padding: 20px 18px 18px;
}

.hero::before {
  content: "";
  position: absolute;
  inset: -70px -20% auto;
  height: 190px;
  background: radial-gradient(58% 100% at 18% 0%, var(--primary-soft), transparent 72%);
  pointer-events: none;
}

.hero > * {
  position: relative;
}

.hero-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.eyebrow {
  font-size: 13px;
  color: var(--text-3);
  font-weight: 500;
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: none;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hero-amount {
  display: flex;
  align-items: baseline;
  gap: 3px;
  margin: 6px 0 0;
  letter-spacing: -0.025em;
  line-height: 1.05;
}

.hero-cur {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-2);
}

.hero-num {
  font-size: clamp(32px, 9vw, 40px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hero-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
}

.hero-sub .warn {
  color: var(--amber);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.stat {
  min-width: 0;
}

.stat-k {
  font-size: 11px;
  color: var(--text-3);
  margin-bottom: 3px;
  white-space: nowrap;
}

.stat-v {
  font-size: 16px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   余额
   ============================================================ */
.balance-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.balance-num {
  font-size: clamp(26px, 7.4vw, 30px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.balance-num.is-unlimited {
  font-size: 24px;
  letter-spacing: 0.02em;
  color: var(--primary);
}

.balance-used {
  flex: none;
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  padding-bottom: 2px;
}

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

.bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary-2), var(--primary));
  transition: width 0.55s cubic-bezier(0.22, 0.7, 0.3, 1);
}

.balance-foot {
  margin-top: 9px;
  font-size: 11.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   趋势图
   ============================================================ */
.chart {
  width: 100%;
  height: 186px;
  margin-top: 2px;
  user-select: none;
  -webkit-user-select: none;
}

.chart svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart .axis-line {
  stroke: var(--line-strong);
  stroke-width: 1;
}

.chart .grid-line {
  stroke: var(--line);
  stroke-width: 1;
  stroke-dasharray: 4 6;
}

.chart .axis-x {
  fill: var(--text-3);
  font-size: 10.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.chart .trend-bar {
  cursor: pointer;
  outline: none;
}

.chart .trend-hit {
  fill: transparent;
}

.chart .trend-fill {
  fill: var(--primary);
  transition: opacity 0.2s ease;
}

.chart .trend-bar:not(.is-active) .trend-fill {
  opacity: 0.3;
}

.chart .trend-bar:hover .trend-fill {
  opacity: 0.6;
}

.chart .trend-bar.is-active .trend-fill {
  opacity: 1;
}

.chart .trend-bar:focus-visible .trend-fill {
  stroke: var(--primary);
  stroke-width: 2;
  stroke-opacity: 0.45;
}

/* ============================================================
   列表 / 行
   ============================================================ */
.list {
  display: flex;
  flex-direction: column;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  min-height: 44px;
}

.row:last-child {
  border-bottom: 0;
  padding-bottom: 2px;
}

.row:first-child {
  padding-top: 4px;
}

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

.row-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-sub {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-amt {
  flex: none;
  font-size: 14px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--text-3);
  display: inline-block;
}

.dot.ok {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.dot.err {
  background: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}

.dot.idle {
  background: var(--text-3);
  opacity: 0.6;
}

/* ============================================================
   模型列表
   ============================================================ */
.models {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.model-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.model-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.model-name {
  font-size: 13.5px;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-amt {
  flex: none;
  font-size: 13px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

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

.model-bar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary-2), var(--primary));
  opacity: 0.75;
}

.model-sub {
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   24 小时分布
   ============================================================ */
.hourly {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 76px;
  margin-top: 12px;
}

.hbar {
  flex: 1 1 0;
  min-width: 0;
  min-height: 3px;
  background: var(--card-2);
  border-radius: 3px;
  transition: background 0.2s ease;
}

.hbar.has {
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
}

.hour-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  font-size: 10px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.hourly + .hour-axis + .hint {
  margin-top: 10px;
}

/* ============================================================
   日志
   ============================================================ */
.log-list {
  display: flex;
  flex-direction: column;
}

.log-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.log-row:last-child {
  border-bottom: 0;
  padding-bottom: 2px;
}

.log-time {
  flex: none;
  width: 50px;
  padding-top: 2px;
  font-size: 11.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.log-main {
  flex: 1;
  min-width: 0;
}

.log-top {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

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

.log-sub {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.log-cost {
  flex: none;
  font-size: 13px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding-top: 1px;
}

.tag {
  flex: none;
  font-size: 9.5px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--primary-soft);
  color: var(--primary);
}

/* ============================================================
   折叠卡片
   ============================================================ */
.collapsible {
  padding: 0;
}

.collapsible > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 0 18px;
  border-radius: var(--radius);
  cursor: pointer;
  list-style: none;
  user-select: none;
  -webkit-user-select: none;
}

.collapsible > summary::-webkit-details-marker {
  display: none;
}

.collapsible > summary .card-note {
  margin-left: auto;
}

.chev {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--text-3);
  transition: transform 0.22s ease;
}

.collapsible[open] > summary .chev {
  transform: rotate(180deg);
}

.collapsible-body {
  padding: 0 18px 16px;
}

/* ============================================================
   按钮
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-align: center;
  transition: transform 0.12s ease, background 0.18s ease, opacity 0.18s ease;
}

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

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 10px 22px -14px rgba(79, 70, 229, 0.95);
}

.btn-primary:hover {
  background: var(--primary-2);
}

.btn-ghost {
  background: var(--card-2);
  color: var(--text);
  border-color: var(--line);
}

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

.btn-sm {
  min-height: 44px;
  padding: 0 15px;
  border-radius: 12px;
  font-size: 13.5px;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 4px;
  margin: -10px -4px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 600;
}

.spinner {
  width: 15px;
  height: 15px;
  flex: none;
  border: 2px solid currentColor;
  border-bottom-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  opacity: 0.9;
}

/* ============================================================
   密钥视图
   ============================================================ */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px 0;
}

.section-head h2 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.section-head p {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.keycard {
  padding: 16px 16px 14px;
}

.key-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.key-id {
  flex: 1;
  min-width: 0;
}

.key-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.key-name {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.mask {
  margin-top: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 11.5px;
  color: var(--text-3);
  word-break: break-all;
  line-height: 1.45;
}

.chip {
  display: inline-flex;
  align-items: center;
  flex: none;
  padding: 4px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text-2);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.chip-on {
  background: var(--green-soft);
  color: var(--green);
  border-color: transparent;
}

.chip-off {
  background: var(--card-2);
  color: var(--text-3);
}

.chip-err {
  background: var(--red-soft);
  color: var(--red);
  border-color: transparent;
}

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

.key-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.key-stats > div {
  min-width: 0;
}

.key-stats .k {
  display: block;
  margin-bottom: 2px;
  font-size: 10.5px;
  color: var(--text-3);
}

.key-stats strong {
  display: block;
  font-size: 15px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.key-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-3);
}

.key-foot .text-danger {
  color: var(--red);
}

.result {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 550;
  line-height: 1.4;
  background: var(--green-soft);
  color: var(--green);
  animation: slideDown 0.2s ease;
}

.result.err {
  background: var(--red-soft);
  color: var(--red);
}

.result.loading {
  background: var(--card-2);
  color: var(--text-3);
  font-weight: 500;
}

.result-main {
  font-weight: 650;
}

.result-meta {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}

.keycard.is-checking {
  opacity: 0.92;
}

/* ============================================================
   设置表单
   ============================================================ */
.form-card .card-title {
  font-size: 15px;
  margin-bottom: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 17px;
}

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

.field label {
  font-size: 13px;
  font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.5;
  font-size: 13.5px;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-3);
  opacity: 0.85;
}

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

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b93a3' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  background-size: 14px 14px;
}

input[type="number"] {
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   底部导航
   ============================================================ */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 35;
  display: flex;
  gap: 4px;
  max-width: 720px;
  margin: 0 auto;
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px));
  background: var(--tabbar);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
}

@media (min-width: 760px) {
  .tabbar {
    border-radius: 20px 20px 0 0;
    border: 1px solid var(--line);
    border-bottom: 0;
  }
}

.tab {
  flex: 1;
  min-height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  border-radius: 13px;
  background: none;
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 600;
  transition: color 0.16s ease, background 0.16s ease;
}

.tab svg {
  width: 21px;
  height: 21px;
  stroke-width: 1.9;
}

.tab.active {
  color: var(--primary);
  background: var(--primary-soft);
}

/* ============================================================
   登录遮罩
   ============================================================ */
.login {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(120% 78% at 50% 0%, var(--primary-soft), transparent 62%), var(--bg);
}

.login-card {
  width: 100%;
  max-width: 352px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 30px 22px 24px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: 0 28px 64px -34px rgba(16, 24, 40, 0.55);
  text-align: center;
}

.logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 2px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(150deg, var(--primary-2), var(--primary));
  color: #ffffff;
  box-shadow: 0 14px 26px -14px rgba(79, 70, 229, 0.9);
}

.logo svg {
  width: 28px;
  height: 28px;
}

.login-card h1 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.login-sub {
  font-size: 12.5px;
  color: var(--text-3);
  margin-bottom: 4px;
}

.login-card input {
  min-height: 48px;
  text-align: center;
  letter-spacing: 0.14em;
  background: var(--card-2);
}

.login-error {
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 12.5px;
  text-align: left;
}

.login-foot {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-3);
}

.shake {
  animation: shake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

/* ============================================================
   引导 / 空态 / 骨架屏
   ============================================================ */
.guide {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 30px 22px 26px;
  text-align: center;
}

.guide-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: var(--primary-soft);
  color: var(--primary);
}

.guide-icon svg {
  width: 26px;
  height: 26px;
}

.guide h2 {
  font-size: 17px;
  font-weight: 700;
}

.guide p {
  max-width: 300px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-3);
}

.guide .btn {
  margin-top: 6px;
  min-width: 148px;
}

.empty {
  padding: 18px 4px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-3);
}

.empty-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 28px 18px;
  text-align: center;
}

.empty-title {
  font-size: 15px;
  font-weight: 600;
}

.empty-sub {
  max-width: 280px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-3);
}

.empty-card .btn {
  margin-top: 4px;
}

.sk {
  position: relative;
  overflow: hidden;
}

.sk::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, var(--shimmer), transparent);
  animation: shimmer 1.5s infinite;
}

.sk-line {
  height: 12px;
  margin-bottom: 10px;
  border-radius: 7px;
  background: var(--card-2);
}

.sk-line:last-child {
  margin-bottom: 0;
}

.sk-line.w30 {
  width: 30%;
}

.sk-line.w36 {
  width: 36%;
}

.sk-line.w40 {
  width: 40%;
}

.sk-line.w44 {
  width: 44%;
}

.sk-line.tall {
  width: 68%;
  height: 30px;
  margin: 16px 0 14px;
  border-radius: 10px;
}

.sk-big {
  width: 62%;
  height: 42px;
  margin: 18px 0;
  border-radius: 11px;
  background: var(--card-2);
}

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

.sk-pill {
  flex: 1;
  height: 30px;
  border-radius: 9px;
  background: var(--card-2);
}

.sk-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--card-2);
}

.sk-chart {
  height: 148px;
  margin-top: 16px;
  border-radius: 12px;
  background: var(--card-2);
}

/* ============================================================
   动画
   ============================================================ */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fadePulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateY(-4px);
  }
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

@keyframes shake {
  10%,
  90% {
    transform: translateX(-2px);
  }
  20%,
  80% {
    transform: translateX(4px);
  }
  30%,
  50%,
  70% {
    transform: translateX(-6px);
  }
  40%,
  60% {
    transform: translateX(6px);
  }
}

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

/* 无 JS 或脚本被拦截时的兜底：跟随系统深色偏好 */
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    color-scheme: dark;
    --primary: #6366f1;
    --primary-2: #818cf8;
    --primary-soft: rgba(99, 102, 241, 0.16);
    --green: #34d399;
    --green-soft: rgba(52, 211, 153, 0.12);
    --red: #f87171;
    --red-soft: rgba(248, 113, 113, 0.12);
    --amber: #fbbf24;
    --amber-soft: rgba(251, 191, 36, 0.12);
    --bg: #0a0c12;
    --bg-blur: rgba(10, 12, 18, 0.82);
    --card: #141822;
    --card-2: #1c212d;
    --text: #eef1f7;
    --text-2: #b6bdcc;
    --text-3: #7f8899;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 16px 40px -26px rgba(0, 0, 0, 0.9);
    --shimmer: rgba(255, 255, 255, 0.06);
    --tabbar: rgba(16, 20, 28, 0.84);
  }
}

/* ============================================================
   设置页补充：字段小标签 + 折叠说明
   ============================================================ */
.tag-inline {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: 1px;
}

code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--card-2);
  color: var(--text-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--card-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.4;
}

.howto {
  padding: 0;
  overflow: hidden;
}

.howto > summary {
  padding: 14px 16px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
}

.howto > summary::-webkit-details-marker {
  display: none;
}

.howto > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-right: 2px solid var(--text-3);
  border-bottom: 2px solid var(--text-3);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.2s ease;
}

.howto[open] > summary::after {
  transform: rotate(225deg) translateY(-2px);
}

.howto[open] > summary {
  border-bottom: 1px solid var(--line);
}

.howto-steps {
  margin: 0;
  padding: 14px 16px 4px 32px;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.75;
}

.howto-steps li {
  margin-bottom: 6px;
}

.howto-steps li::marker {
  color: var(--primary);
  font-weight: 700;
}

.howto .hint {
  padding: 0 16px;
  margin-top: 8px;
}

.howto .hint:last-child {
  padding-bottom: 14px;
}
