/* ============================================================
   TMS API 控制台 —— 深色科技感主题
   纯手写，零外部依赖（不引用任何 CDN / 字体 / 图标库）
   ============================================================ */

:root {
  --bg-0:        #060915;
  --bg-1:        #0b1024;
  --bg-2:        #111834;
  --surface:     rgba(22, 29, 58, 0.88);
  --surface-2:   rgba(31, 40, 74, 0.75);
  --border:      rgba(120, 132, 190, 0.18);
  --border-soft: rgba(120, 132, 190, 0.10);

  --text:        #e8ecf8;
  --text-dim:    #a4adca;
  --text-mute:   #6f7a9c;

  --accent:      #6366f1;
  --accent-2:    #818cf8;
  --cyan:        #22d3ee;
  --success:     #34d399;
  --danger:      #f87171;
  --warn:        #fbbf24;

  --r-card: 16px;
  --r-input: 10px;
  --r-pill: 999px;

  --shadow: 0 18px 40px -18px rgba(0,0,0,.85);
  --glow:  0 0 0 1px rgba(99,102,241,.25), 0 12px 40px -12px rgba(99,102,241,.45);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg-0);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
               "PingFang SC", "Hiragino Sans GB", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------- 背景装饰 ---------- */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(99,102,241,.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,102,241,.055) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 30%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 30%, transparent 78%);
}
/* 背景光晕：用径向渐变实现柔化效果，不用 filter:blur（那玩意儿很吃性能，
   而且这台服务器没有独立显卡，手机上也会拖慢渲染） */
.bg-glow {
  position: fixed; z-index: 0; pointer-events: none;
  border-radius: 50%; opacity: .45;
}
.bg-glow-1 { width: 900px; height: 900px; top: -380px; left: -260px;
  background: radial-gradient(circle, rgba(99,102,241,.42) 0%, rgba(99,102,241,.14) 38%, transparent 66%); }
.bg-glow-2 { width: 820px; height: 820px; top: -320px; right: -280px;
  background: radial-gradient(circle, rgba(34,211,238,.26) 0%, rgba(34,211,238,.08) 38%, transparent 66%); }

.hidden { display: none !important; }

/* ---------- 品牌标识 ---------- */
.brand-mark {
  width: 46px; height: 46px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  color: #fff; font-weight: 800; font-size: 22px;
  box-shadow: 0 8px 24px -8px rgba(99,102,241,.9);
}
.brand-mark.small { width: 30px; height: 30px; border-radius: 9px; font-size: 15px; }

/* ---------- 登录页 ---------- */
.login-wrap {
  position: relative; z-index: 1;
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 34px 30px 26px;

  box-shadow: var(--shadow), 0 0 0 1px rgba(255,255,255,.02) inset;
  animation: rise .5s cubic-bezier(.2,.7,.3,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.brand-text h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: .2px; }
.brand-text p  { margin: 2px 0 0; font-size: 12.5px; color: var(--text-mute); }

.field { display: block; margin-bottom: 15px; }
.field > span {
  display: block; margin-bottom: 7px;
  font-size: 12.5px; color: var(--text-dim); font-weight: 500;
}
input[type=text], input[type=password], input[type=number], input[type=search], select {
  width: 100%; padding: 11px 13px;
  background: rgba(9, 13, 28, .72);
  border: 1px solid var(--border);
  border-radius: var(--r-input);
  color: var(--text); font-size: 14px; font-family: inherit;
  transition: border-color .16s, box-shadow .16s, background .16s;
  outline: none;
}
input::placeholder { color: #5b6484; }
input:focus, select:focus {
  border-color: var(--accent);
  background: rgba(12, 17, 36, .9);
  box-shadow: 0 0 0 3px rgba(99,102,241,.16);
}
select { cursor: pointer; }
select option { background: #12172e; color: var(--text); }

.form-error {
  margin: 0 0 14px; padding: 9px 12px;
  background: rgba(248,113,113,.1);
  border: 1px solid rgba(248,113,113,.3);
  border-radius: 9px;
  color: #fca5a5; font-size: 12.5px;
}

.login-hint { margin: 18px 0 0; text-align: center; font-size: 12px; color: var(--text-mute); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-input);
  background: var(--surface-2);
  color: var(--text); font-size: 13px; font-family: inherit; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: all .16s;
}
.btn:hover { border-color: rgba(129,140,248,.5); background: rgba(38,48,86,.8); transform: translateY(-1px); }
.btn:active { transform: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  border-color: transparent; color: #fff; font-weight: 600;
  box-shadow: 0 10px 26px -12px rgba(99,102,241,.95);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-2), var(--accent)); }
.btn-block { width: 100%; padding: 11px; font-size: 14px; }

.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 8px; }
.btn-ghost { background: transparent; border-color: var(--border-soft); color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { color: #fca5a5; border-color: rgba(248,113,113,.28); background: rgba(248,113,113,.08); }
.btn-danger:hover { background: rgba(248,113,113,.16); border-color: rgba(248,113,113,.5); }

.icon-btn {
  border: none; background: transparent; color: var(--text-mute);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 7px;
}
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,.06); }

/* ---------- 主界面骨架 ---------- */
#view-app { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 22px;
  background: rgba(8, 12, 26, .94);
  border-bottom: 1px solid var(--border-soft);

  position: sticky; top: 0; z-index: 20;
}
.topbar-left  { display: flex; align-items: center; gap: 11px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.site-name { font-weight: 650; font-size: 15px; letter-spacing: .2px; }

.quota-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 13px; border-radius: var(--r-pill);
  background: rgba(34,211,238,.09);
  border: 1px solid rgba(34,211,238,.26);
  color: #a5f3fc; font-size: 12.5px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.quota-chip .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--cyan); box-shadow: 0 0 8px var(--cyan);
}
.quota-chip.low { background: rgba(251,191,36,.1); border-color: rgba(251,191,36,.3); color: #fde68a; }
.quota-chip.low .dot { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.quota-chip.empty { background: rgba(248,113,113,.1); border-color: rgba(248,113,113,.3); color: #fca5a5; }
.quota-chip.empty .dot { background: var(--danger); box-shadow: 0 0 8px var(--danger); }

.user-menu { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 10px 5px 5px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-family: inherit; font-size: 13px; cursor: pointer;
  transition: all .16s;
}
.user-btn:hover { border-color: rgba(129,140,248,.5); }
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  font-size: 12px; font-weight: 700; color: #fff;
}
.caret { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.6; opacity: .6; }
.user-name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dropdown {
  position: absolute; right: 0; top: calc(100% + 9px); min-width: 208px;
  background: #131a35; border: 1px solid var(--border);
  border-radius: 13px; padding: 6px; box-shadow: var(--shadow);
  animation: rise .16s ease both;
}
.dropdown-head { padding: 9px 11px 11px; border-bottom: 1px solid var(--border-soft); margin-bottom: 6px; }
.dropdown-name { font-weight: 600; font-size: 13.5px; }
.dropdown-sub  { font-size: 11.5px; color: var(--text-mute); margin-top: 2px; }
.dropdown-item {
  display: block; width: 100%; text-align: left;
  padding: 8px 11px; border-radius: 8px; border: none; background: none;
  color: var(--text-dim); font-size: 13px; font-family: inherit; cursor: pointer;
  text-decoration: none; transition: all .14s;
}
.dropdown-item:hover { background: rgba(99,102,241,.14); color: var(--text); }
.dropdown-item.danger:hover { background: rgba(248,113,113,.14); color: #fca5a5; }

/* ---------- 标签导航 ---------- */
.tabs {
  display: flex; gap: 4px; overflow-x: auto;
  padding: 0 18px;
  background: rgba(8, 12, 26, .92);
  border-bottom: 1px solid var(--border-soft);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; padding: 12px 15px;
  color: var(--text-mute); text-decoration: none;
  font-size: 13.5px; font-weight: 500; white-space: nowrap;
  transition: color .16s;
}
.tab:hover { color: var(--text-dim); }
.tab.active { color: var(--text); }
.tab.active::after {
  content: ''; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  border-radius: 2px 2px 0 0;
  box-shadow: 0 0 12px rgba(99,102,241,.8);
}

/* ---------- 内容区 ---------- */
.content { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 26px 22px 60px; }
.foot { padding: 18px; text-align: center; font-size: 11.5px; color: #4d5573; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 20px;
}
.page-head h2 { margin: 0; font-size: 20px; font-weight: 680; letter-spacing: .2px; }
.page-head p  { margin: 5px 0 0; font-size: 12.5px; color: var(--text-mute); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 18px 20px;
  box-shadow: 0 10px 30px -20px rgba(0,0,0,.9);
}
.card + .card { margin-top: 16px; }
.card-title { margin: 0 0 3px; font-size: 14.5px; font-weight: 640; }
.card-sub   { margin: 0 0 16px; font-size: 12px; color: var(--text-mute); }

.grid-stats { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }

.stat {
  position: relative; overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 18px 20px;

}
.stat::before {
  content: ''; position: absolute; inset: 0 auto auto 0; width: 100%; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: .8;
}
.stat.cyan::before   { background: linear-gradient(90deg, var(--cyan), transparent); }
.stat.success::before{ background: linear-gradient(90deg, var(--success), transparent); }
.stat-label { font-size: 12px; color: var(--text-mute); margin-bottom: 9px; letter-spacing: .3px; }
.stat-value {
  font-size: 26px; font-weight: 720; letter-spacing: -.4px;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.stat-value .unit { font-size: 13px; font-weight: 500; color: var(--text-mute); margin-left: 3px; }
.stat-extra { margin-top: 7px; font-size: 11.5px; color: var(--text-mute); }

/* ---------- 用量柱状图（纯 CSS/JS，无图表库） ---------- */
.chart {
  display: flex; align-items: flex-end; gap: 10px;
  height: 168px; padding: 14px 2px 0;
}
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.bar-track {
  width: 100%; flex: 1; display: flex; align-items: flex-end;
  background: rgba(255,255,255,.028);
  border-radius: 8px; overflow: hidden;
}
.bar-fill {
  width: 100%; min-height: 3px; border-radius: 8px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 16px -4px rgba(99,102,241,.9);
  transition: height .5s cubic-bezier(.2,.7,.3,1);
}
.bar-fill[data-zero="1"] { background: rgba(255,255,255,.07); box-shadow: none; }
.bar-label { font-size: 10.5px; color: var(--text-mute); white-space: nowrap; }
.bar-value { font-size: 10.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* 图表空状态 */
.chart-empty {
  height: 168px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  color: var(--text-dim); font-size: 13px; text-align: center;
}
.chart-empty-icon { font-size: 30px; opacity: .35; margin-bottom: 8px; }

/* ---------- 表格 ---------- */
.table-scroll { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 9px 12px;
  color: var(--text-mute); font-weight: 560; font-size: 11.5px;
  letter-spacing: .4px; text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tbody tr { transition: background .14s; }
tbody tr:hover { background: rgba(99,102,241,.055); }
tbody tr:last-child td { border-bottom: none; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, "Cascadia Mono", monospace; font-size: 12px; }

/* ---------- 徽标 / 状态 ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 560; white-space: nowrap;
}
.pill-ok    { background: rgba(52,211,153,.12); color: #6ee7b7; border: 1px solid rgba(52,211,153,.26); }
.pill-off   { background: rgba(148,163,184,.1); color: #9aa4bf; border: 1px solid rgba(148,163,184,.22); }
.pill-warn  { background: rgba(251,191,36,.12); color: #fde68a; border: 1px solid rgba(251,191,36,.26); }
.pill-err   { background: rgba(248,113,113,.12); color: #fca5a5; border: 1px solid rgba(248,113,113,.26); }
.pill-info  { background: rgba(34,211,238,.12); color: #a5f3fc; border: 1px solid rgba(34,211,238,.26); }

/* ---------- 模型卡片 ---------- */
.grid-models { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.model-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 13px; padding: 14px 16px;
  transition: all .18s;
}
.model-card:hover { border-color: rgba(129,140,248,.45); transform: translateY(-2px); box-shadow: var(--glow); }
.model-icon {
  width: 34px; height: 34px; flex: 0 0 auto; border-radius: 10px;
  display: grid; place-items: center; font-size: 15px;
  background: linear-gradient(135deg, rgba(99,102,241,.25), rgba(34,211,238,.18));
  border: 1px solid rgba(129,140,248,.3);
}
.model-name { font-weight: 600; font-size: 13.5px; word-break: break-all; }
.model-meta { font-size: 11.5px; color: var(--text-mute); margin-top: 2px; }

/* ---------- 代码/地址块 ---------- */
.code-block {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: rgba(6, 10, 22, .8);
  border: 1px solid var(--border);
  border-radius: 11px; padding: 12px 14px;
}
.code-block code {
  flex: 1; min-width: 200px;
  font-family: ui-monospace, Consolas, monospace; font-size: 13px;
  color: #a5b4fc; word-break: break-all;
}

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.pager-info { font-size: 12.5px; color: var(--text-mute); }
.pager-btns { display: flex; gap: 8px; }

/* ---------- 空态 / 加载 ---------- */
.empty { padding: 46px 20px; text-align: center; color: var(--text-mute); font-size: 13px; }
.empty-icon { font-size: 34px; opacity: .35; margin-bottom: 10px; }
.loading-block { display: grid; place-items: center; padding: 76px 0; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2.5px solid rgba(99,102,241,.2);
  border-top-color: var(--accent);
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(3, 6, 16, .82);

  display: grid; place-items: center; padding: 20px;
  animation: fade .16s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 440px; max-height: 88vh; overflow: auto;
  background: #121a36;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  animation: rise .22s cubic-bezier(.2,.7,.3,1) both;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 17px 20px 13px; border-bottom: 1px solid var(--border-soft);
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 650; }
.modal-body { padding: 18px 20px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 9px;
  padding: 13px 20px 18px;
}
.modal-foot:empty { display: none; }

/* 密钥展示 */
.key-reveal {
  background: rgba(6, 10, 22, .85);
  border: 1px solid rgba(34,211,238,.3);
  border-radius: 11px; padding: 13px;
  font-family: ui-monospace, Consolas, monospace; font-size: 12.5px;
  word-break: break-all; color: #a5f3fc;
  user-select: all;
}
.alert { padding: 11px 13px; border-radius: 10px; font-size: 12.5px; margin-bottom: 14px; }
.alert-warn { background: rgba(251,191,36,.1); border: 1px solid rgba(251,191,36,.28); color: #fde68a; }
.alert-info { background: rgba(34,211,238,.09); border: 1px solid rgba(34,211,238,.24); color: #a5f3fc; }

/* ---------- 提示条 ---------- */
.toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 80;
  display: flex; flex-direction: column; gap: 9px; align-items: flex-end;
}
.toast {
  padding: 11px 16px; border-radius: 11px;
  background: #1a2342; border: 1px solid var(--border);
  color: var(--text); font-size: 13px; box-shadow: var(--shadow);
  animation: slideIn .22s cubic-bezier(.2,.7,.3,1) both;
  max-width: 320px;
}
.toast.ok   { border-color: rgba(52,211,153,.4); }
.toast.err  { border-color: rgba(248,113,113,.45); }
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* ---------- 小工具类 ---------- */
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.muted { color: var(--text-mute); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }

/* ---------- 移动端 ---------- */
@media (max-width: 720px) {
  .content { padding: 18px 14px 50px; }
  .topbar { padding: 10px 14px; }
  .site-name { display: none; }
  .user-name { display: none; }
  .page-head { align-items: flex-start; }
  .stat-value { font-size: 22px; }
  .table-scroll { margin: 0 -14px; padding: 0 14px; }
  th, td { padding: 9px 9px; }
  .chart { height: 132px; gap: 5px; }
  .bar-value { display: none; }
  .modal { max-width: 100%; }
}
