/* AlexAPI 控制台 —— Semi Design 风格 */
.brand-logo { width: 30px; height: 30px; object-fit: contain; border-radius: 7px; }
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 20% 10%, #e8f0ff, transparent 42%), var(--bg); padding: 20px; }
.auth-card { width: 410px; max-width: 100%; background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-pop); padding: 34px; text-align: center; }
.auth-logo { width: 64px; height: 64px; object-fit: contain; border-radius: 14px; margin-bottom: 8px; }
.auth-card h1 { margin: 0; font-size: 27px; letter-spacing: .5px; }
.auth-card .muted { margin: 7px 0 24px; }
.full { width: 100%; margin-top: 12px; }
.dev-code { color: var(--warn); font-size: 12px; min-height: 18px; margin-top: 8px; }

:root {
  --primary: #0064fa;
  --primary-hover: #0055d4;
  --primary-light: #e8f0ff;
  --danger: #f93920;
  --danger-hover: #d92c14;
  --warn: #f5a623;
  --success: #03a852;
  --bg: #f4f5f7;
  --card: #ffffff;
  --border: #e8eaee;
  --text-0: #1c1f23;
  --text-1: #484c52;
  --text-2: #85888f;
  --header-h: 60px;
  --sider-w: 236px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(28, 31, 35, .06), 0 4px 14px rgba(28, 31, 35, .04);
  --shadow-pop: 0 4px 16px rgba(28, 31, 35, .14);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text-0);
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------------- 顶栏 ---------------- */
.app-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand-name { font-size: 17px; font-weight: 700; color: var(--text-0); letter-spacing: .5px; }
.brand-badge {
  font-size: 11px; color: var(--primary); background: var(--primary-light);
  padding: 1px 8px; border-radius: 999px; font-weight: 500;
}
.header-right { display: flex; align-items: center; gap: 16px; }
.upstream-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text-1);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 12px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #c9cdd4; display: inline-block; }
.dot.ok { background: var(--success); box-shadow: 0 0 0 3px rgba(3, 168, 82, .15); }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 3px rgba(249, 57, 32, .12); }
.user-chip { display: flex; align-items: center; gap: 8px; cursor: default; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #4d82ff, #0064fa);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.user-name { font-size: 13px; color: var(--text-1); }
.icon-btn {
  border: none; background: transparent; cursor: pointer; color: var(--text-1);
  width: 32px; height: 32px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--bg); }

/* ---------------- 布局 ---------------- */
.app-body { display: flex; flex: 1; min-height: calc(100vh - var(--header-h) - 42px); }
.sider {
  width: var(--sider-w); background: #fff; border-right: 1px solid var(--border);
  flex-shrink: 0; transition: width .18s ease, transform .18s ease;
}
.sider.collapsed { width: 0; overflow: hidden; border-right: none; }
.sider-scroll { position: sticky; top: var(--header-h); padding: 14px 12px; max-height: calc(100vh - var(--header-h) - 42px); overflow-y: auto; }
.nav-group { margin-bottom: 18px; }
.nav-group-title { font-size: 12px; color: var(--text-2); padding: 4px 12px 6px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 6px;
  color: var(--text-1); font-size: 14px; transition: background .12s;
}
.nav a:hover { background: var(--bg); color: var(--text-0); }
.nav a.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-ico { font-style: normal; font-size: 15px; width: 20px; text-align: center; }
.sider-foot { border-top: 1px solid var(--border); margin-top: 8px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.side-link { font-size: 13px; color: var(--text-2); }
.side-link:hover { color: var(--primary); }

.main { flex: 1; min-width: 0; padding: 20px 24px 32px; }

/* ---------------- 页脚 ---------------- */
.app-footer {
  height: 42px; display: flex; align-items: center; justify-content: center;
  color: var(--text-2); font-size: 12px; background: transparent;
}

/* ---------------- 卡片 / 页头 ---------------- */
.page-banner {
  background: linear-gradient(90deg, var(--primary-light), #f3f7ff 60%);
  border: 1px solid #d9e6ff; border-radius: var(--radius);
  padding: 12px 16px; display: flex; align-items: center; gap: 10px;
  color: #2b4770; margin-bottom: 16px; font-size: 13px;
}
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.page-title { font-size: 20px; font-weight: 700; margin: 0; }
.page-sub { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 14px; border-radius: 6px;
  border: 1px solid transparent; font-size: 13px; cursor: pointer;
  transition: all .12s; user-select: none; white-space: nowrap;
  font-family: inherit;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-light { background: #fff; border-color: var(--border); color: var(--text-1); }
.btn-light:hover:not(:disabled) { border-color: #c9cdd4; background: var(--bg); }
.btn-danger { background: #fff; border-color: var(--border); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #fff3f1; border-color: #ffc7bd; }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover:not(:disabled) { background: var(--danger-hover); }
.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; border-radius: 5px; }
.btn-link { border: none; background: transparent; color: var(--primary); padding: 0 6px; height: auto; }
.btn-link:hover { color: var(--primary-hover); text-decoration: underline; }
.btn-link.danger { color: var(--danger); }

/* ---------------- 表单 ---------------- */
.input, .select, textarea.input {
  height: 32px; border: 1px solid var(--border); border-radius: 6px;
  padding: 0 10px; font-size: 13px; color: var(--text-0); background: #fff;
  outline: none; font-family: inherit; width: 100%;
}
textarea.input { height: auto; padding: 8px 10px; resize: vertical; }
.input:focus, .select:focus, textarea.input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(0, 100, 250, .12); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2385888f' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; cursor: pointer; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filter-bar .input, .filter-bar .select { width: 180px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.form-item { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-1); }
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-hint { font-size: 12px; color: var(--text-2); margin-top: 4px; }
.form-row { display: flex; gap: 12px; }
.form-row > .form-item { flex: 1; }

/* ---------------- 标签 / 徽章 ---------------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; padding: 1px 9px; border-radius: 4px;
  background: var(--bg); color: var(--text-1); border: 1px solid var(--border);
  white-space: nowrap;
}
.tag-blue { background: var(--primary-light); color: var(--primary); border-color: #c6dbff; }
.tag-green { background: #e9f9f0; color: var(--success); border-color: #c3ecd4; }
.tag-orange { background: #fff3e0; color: #d97706; border-color: #ffe1b3; }
.tag-red { background: #fff0ed; color: var(--danger); border-color: #ffcdc2; }
.tag-purple { background: #f3edff; color: #6b4fd8; border-color: #e0d4ff; }
.status-tag { display: inline-flex; align-items: center; gap: 5px; }
.status-tag i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }

/* ---------------- 开关 ---------------- */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px; background: #dbdcdf;
  transition: background .15s; cursor: pointer;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s;
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:disabled + .track { opacity: .5; cursor: not-allowed; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 600; color: var(--text-1);
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  background: #fafbfc; white-space: nowrap; position: sticky; top: 0;
}
.table td { padding: 11px 12px; border-bottom: 1px solid #f2f3f5; vertical-align: middle; }
.table tbody tr:hover { background: #f7f9fc; }
.table .mono { font-family: Consolas, "JetBrains Mono", monospace; font-size: 12px; }
.table.compact td, .table.compact th { padding: 6px 10px; }
.table-empty { text-align: center; color: var(--text-2); padding: 40px 0 !important; }
.cell-key { display: flex; align-items: center; gap: 6px; min-width: 220px; }
.cell-key .key-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quota-line { font-size: 12px; color: var(--text-1); margin: 3px 0 4px; }
.progress { height: 5px; background: #edeef1; border-radius: 999px; overflow: hidden; max-width: 130px; }
.progress > i { display: block; height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s; }
.progress > i.warn { background: var(--warn); }
.progress > i.danger { background: var(--danger); }
.group-chain { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.group-chain .arrow { color: var(--text-2); font-size: 11px; }
.check {
  width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; display: block;
}

/* ---------------- 分页 ---------------- */
.pagination { display: flex; align-items: center; justify-content: space-between; padding-top: 14px; flex-wrap: wrap; gap: 10px; }
.pagination .info { color: var(--text-2); font-size: 12px; }
.pager { display: flex; align-items: center; gap: 6px; }
.pager button {
  min-width: 28px; height: 28px; border: 1px solid var(--border); background: #fff;
  border-radius: 5px; cursor: pointer; color: var(--text-1); font-size: 13px;
}
.pager button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pager button.cur { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager button:disabled { opacity: .4; cursor: not-allowed; }
.pager .ellipsis { color: var(--text-2); padding: 0 2px; }

/* ---------------- 统计卡 ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.stat-label { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--text-2); margin-left: 3px; }
.stat-extra { font-size: 12px; color: var(--text-2); margin-top: 4px; }
.stat-extra b.ok { color: var(--success); } .stat-extra b.bad { color: var(--danger); }

.chart-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 14px; }
@media (max-width: 980px) { .chart-grid { grid-template-columns: 1fr; } }
canvas.chart { width: 100%; height: 260px; display: block; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }

/* ---------------- 模型广场 ---------------- */
.model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.model-card {
  border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
  padding: 12px 14px; transition: box-shadow .15s, border-color .15s; cursor: default;
}
.model-card:hover { box-shadow: var(--shadow-pop); border-color: #c6dbff; }
.model-name { font-family: Consolas, monospace; font-size: 13px; font-weight: 600; word-break: break-all; }
.model-owner { color: var(--text-2); font-size: 12px; margin-top: 4px; display: flex; justify-content: space-between; align-items: center; }

/* ---------------- 代码块 ---------------- */
.code-block { position: relative; background: #0d1117; color: #e6edf3; border-radius: var(--radius); padding: 14px 16px; overflow-x: auto; font-family: Consolas, "JetBrains Mono", monospace; font-size: 12.5px; line-height: 1.65; }
.code-block .cb-title { position: absolute; top: 8px; right: 10px; }
.code-block .copy-btn { background: #21262d; border: 1px solid #30363d; color: #8b949e; height: 24px; font-size: 11px; border-radius: 5px; padding: 0 10px; cursor: pointer; }
.code-block .copy-btn:hover { color: #e6edf3; border-color: #8b949e; }
.doc-section h3 { font-size: 15px; margin: 22px 0 10px; }
.doc-section p, .doc-section li { color: var(--text-1); font-size: 13px; }
.doc-section code.inline { background: #eef1f5; padding: 1px 6px; border-radius: 4px; font-family: Consolas, monospace; font-size: 12px; color: #c7254e; }

/* ---------------- 空状态 ---------------- */
.empty { text-align: center; padding: 44px 0; color: var(--text-2); }
.empty .ico { font-size: 34px; margin-bottom: 8px; }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(28, 31, 35, .45); z-index: 500;
  display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px;
  animation: fadeIn .15s ease;
}
.modal {
  background: #fff; border-radius: 10px; box-shadow: var(--shadow-pop);
  width: 560px; max-width: 100%; max-height: 82vh; display: flex; flex-direction: column;
  animation: popIn .18s ease;
}
.modal.modal-lg { width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 10px; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { border: none; background: transparent; font-size: 18px; color: var(--text-2); cursor: pointer; width: 30px; height: 30px; border-radius: 6px; }
.modal-close:hover { background: var(--bg); color: var(--text-0); }
.modal-body { padding: 6px 20px 16px; overflow-y: auto; }
.modal-foot { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--border); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------------- Toast ---------------- */
#toast-root { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 600; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow-pop);
  border-radius: 8px; padding: 9px 18px; font-size: 13px; display: flex; align-items: center; gap: 8px;
  animation: popIn .18s ease;
}
.toast.ok { border-left: 3px solid var(--success); }
.toast.err { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--primary); }

/* ---------------- 其他 ---------------- */
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }
.kv-table { width: 100%; font-size: 13px; border-collapse: collapse; }
.kv-table td { padding: 6px 8px; border-bottom: 1px dashed #eee; }
.kv-table td:first-child { color: var(--text-2); width: 110px; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid #c6dbff; border-top-color: var(--primary); border-radius: 50%; animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d4d7dc; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
