:root {
  --brand: #ff7a00;
  --brand-dark: #e56a00;
  --brand-soft: #fff4e8;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --line: #eaecf0;
  --bg: #f5f6f8;
  --card: #ffffff;
  --ok: #079455;
  --ok-soft: #ecfdf3;
  --warn: #dc6803;
  --warn-soft: #fffaeb;
  --danger: #d92d20;
  --danger-soft: #fef3f2;
  --blue: #175cd3;
  --blue-soft: #eff8ff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.05);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
h1, h2, h3, h4, p { margin: 0; }
[hidden] { display: none !important; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden; background: #0b1220;
}
.login-bg {
  position: absolute; inset: -20%;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 138, 31, 0.35), transparent 42%),
    radial-gradient(circle at 82% 18%, rgba(70, 130, 255, 0.28), transparent 40%),
    radial-gradient(circle at 50% 90%, rgba(255, 170, 80, 0.22), transparent 45%),
    linear-gradient(135deg, #0c1526 0%, #141f33 55%, #0b1220 100%);
  filter: blur(2px);
}
.login-card {
  position: relative; width: 400px; max-width: calc(100vw - 40px);
  background: rgba(255, 255, 255, 0.98);
  border-radius: 22px; padding: 34px 34px 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.login-brand h1 { font-size: 22px; letter-spacing: 1px; }
.login-brand p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.logo-mark {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center;
  background: linear-gradient(135deg, #ff9a2e, #ff6a00 70%);
  color: #fff; font-size: 26px; font-weight: 700;
  box-shadow: 0 8px 18px rgba(255, 106, 0, 0.32);
}
.logo-mark.small { width: 38px; height: 38px; border-radius: 12px; font-size: 19px; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 7px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border: 1px solid #d0d5dd; border-radius: 10px;
  background: #fff; color: var(--ink); outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(255, 122, 0, 0.14);
}
.form-error { color: var(--danger); font-size: 13px; margin: 0 0 12px; }
.login-tip { margin-top: 18px; text-align: center; color: #98a2b3; font-size: 12px; line-height: 1.7; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 238px; flex: 0 0 238px; position: sticky; top: 0; height: 100vh;
  background: linear-gradient(180deg, #111c2f 0%, #0d1626 100%);
  color: #c6d0df; display: flex; flex-direction: column; padding: 20px 14px 16px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 20px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-text strong { color: #fff; font-size: 16px; letter-spacing: .5px; }
.brand-text span { font-size: 11px; color: #7f8da3; letter-spacing: 2px; }
.nav { margin-top: 14px; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  font-size: 13.5px; color: #b9c4d4; transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: linear-gradient(90deg, rgba(255,122,0,.22), rgba(255,122,0,.08)); color: #ffb066; }
.nav .ico { width: 18px; text-align: center; font-style: normal; opacity: .9; }
.nav-group { margin: 16px 12px 6px; font-size: 11px; color: #64748b; letter-spacing: 1px; }
.nav-badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 99px; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.07); padding-top: 14px; }
.admin-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; padding: 0 4px; }
.admin-chip div { display: flex; flex-direction: column; line-height: 1.35; }
.admin-chip strong { color: #fff; font-size: 13px; }
.admin-chip span:last-child { font-size: 11px; color: #7f8da3; }
.avatar-dot {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, #ffb15c, #ff7a00); color: #fff; font-weight: 700;
}
.sidebar .btn-ghost { background: rgba(255,255,255,.06); color: #c6d0df; border-color: rgba(255,255,255,.1); }
.sidebar .btn-ghost:hover { background: rgba(255,255,255,.12); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 78px; padding: 0 30px; display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 19px; font-weight: 600; }
.page-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.server-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.view { padding: 24px 30px 46px; max-width: 1440px; width: 100%; }

/* ---------- 通用组件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  padding: 9px 15px; border-radius: 9px; font-size: 13px; cursor: pointer; transition: all .15s;
  white-space: nowrap;
}
.btn:hover { background: #f9fafb; border-color: #d0d5dd; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { color: var(--danger); border-color: #fda29b; background: #fff; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { background: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: none; color: var(--blue); cursor: pointer; padding: 0 4px; font-size: 12.5px; }
.btn-link:hover { text-decoration: underline; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px 22px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.card-desc { color: var(--muted); font-size: 12.5px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { padding: 18px 20px; position: relative; overflow: hidden; }
.stat .label { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 10px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.stat .foot { margin-top: 8px; color: #98a2b3; font-size: 12px; }
.stat .ico-box {
  position: absolute; right: 16px; top: 16px; width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center; font-size: 17px;
}
.tone-orange { background: var(--brand-soft); color: var(--brand); }
.tone-blue { background: var(--blue-soft); color: var(--blue); }
.tone-green { background: var(--ok-soft); color: var(--ok); }
.tone-red { background: var(--danger-soft); color: var(--danger); }

.section { margin-top: 20px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-head h3 { font-size: 15px; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.input {
  padding: 9px 12px; border: 1px solid #d0d5dd; border-radius: 9px; background: #fff;
  outline: none; min-width: 180px; font-size: 13px;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(255,122,0,.12); }
.seg { display: inline-flex; background: #eef1f5; border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; padding: 6px 13px; border-radius: 7px; font-size: 12.5px;
  color: var(--muted); cursor: pointer;
}
.seg button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(16,24,40,.12); font-weight: 500; }

table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 500;
  padding: 12px 14px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap;
}
.table td { padding: 13px 14px; border-bottom: 1px solid #f2f4f7; font-size: 13px; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fcfcfd; }
.table .num { font-variant-numeric: tabular-nums; }
.table .actions { display: flex; gap: 4px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
.empty { padding: 46px 20px; text-align: center; color: #98a2b3; font-size: 13px; }
.empty .empty-ico { font-size: 30px; display: block; margin-bottom: 8px; opacity: .4; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill.gray { background: #f2f4f7; color: #667085; }
.pill.green { background: var(--ok-soft); color: var(--ok); }
.pill.orange { background: var(--warn-soft); color: var(--warn); }
.pill.red { background: var(--danger-soft); color: var(--danger); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.purple { background: #f4f3ff; color: #5925dc; }

.user-cell { display: flex; align-items: center; gap: 9px; min-width: 140px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: #f2f4f7; object-fit: cover;
  display: grid; place-items: center; color: #98a2b3; font-size: 12px; flex: 0 0 30px; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt20 { margin-top: 20px; }
.flex { display: flex; align-items: center; } .between { justify-content: space-between; } .gap8 { gap: 8px; } .gap12 { gap: 12px; }

.pager { display: flex; align-items: center; justify-content: space-between; padding: 14px 4px 4px; color: var(--muted); font-size: 12.5px; }
.pager-btns { display: flex; gap: 5px; }
.pager-btns button {
  min-width: 30px; height: 30px; border: 1px solid var(--line); background: #fff; border-radius: 7px;
  color: var(--ink-2); cursor: pointer; font-size: 12.5px;
}
.pager-btns button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager-btns button:disabled { opacity: .45; cursor: not-allowed; }

/* 图表 */
.chart { display: flex; align-items: flex-end; gap: 14px; height: 190px; padding: 12px 6px 0; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; height: 100%; justify-content: flex-end; }
.chart-bars { display: flex; align-items: flex-end; gap: 4px; flex: 1; width: 100%; justify-content: center; }
.chart-bar { width: 12px; min-height: 3px; border-radius: 4px 4px 2px 2px; background: var(--brand); transition: height .3s; }
.chart-bar.blue { background: #84adff; }
.chart-x { font-size: 11px; color: #98a2b3; white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, 0.55); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fadeIn .16s ease;
}
.modal {
  background: #fff; border-radius: 16px; width: 680px; max-width: 100%; max-height: 88vh;
  display: flex; flex-direction: column; box-shadow: 0 24px 70px rgba(0,0,0,.3);
  animation: pop .18s ease;
}
.modal.wide { width: 920px; }
.modal.narrow { width: 440px; }
.modal-head { padding: 19px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-head h3 { font-size: 16px; font-weight: 600; }
.modal-head p { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.modal-close { border: 0; background: none; font-size: 20px; color: #98a2b3; cursor: pointer; line-height: 1; padding: 2px; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 9px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.detail-item .k { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.detail-item .v { font-size: 13.5px; font-weight: 500; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 15px; }
.tabs button { border: 0; background: none; padding: 9px 14px; font-size: 13px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 500; }
.kv-list { display: flex; flex-direction: column; gap: 0; }
.kv { display: flex; justify-content: space-between; gap: 20px; padding: 11px 0; border-bottom: 1px dashed #eef1f5; font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); }
.kv .v { text-align: right; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track { width: 38px; height: 22px; border-radius: 99px; background: #d0d5dd; position: relative; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }

.pkg-head, .pkg-row { display: grid; grid-template-columns: 1fr 1fr 42px; gap: 12px; align-items: center; }
.pkg-head { font-size: 12px; color: var(--muted); padding-bottom: 7px; }
.pkg-row { padding: 5px 0; }
.pkg-row input {
  width: 100%; padding: 8px 11px; border: 1px solid #d0d5dd; border-radius: 8px; outline: none; font-size: 13px;
}
.pkg-row input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(255,122,0,.12); }
.pkg-row .pkg-remove { width: 34px; height: 34px; padding: 0; color: var(--muted); }
.divider { height: 1px; background: var(--line); margin: 20px 0; }
.help-text { color: #98a2b3; font-size: 12px; line-height: 1.7; margin-top: 5px; }
.code { background: #f8fafc; border: 1px dashed #d0d5dd; border-radius: 8px; padding: 3px 7px; font-family: ui-monospace, monospace; font-size: 12px; }

/* Toast */
.toast-root { position: fixed; top: 88px; right: 24px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #101828; color: #fff; padding: 10px 16px; border-radius: 9px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: slideIn .2s ease; max-width: 360px;
}
.toast.ok { background: #054f31; }
.toast.err { background: #7a271a; }
@keyframes slideIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

.loading { padding: 50px; text-align: center; color: #98a2b3; }
.spinner {
  width: 22px; height: 22px; border: 2px solid #e4e7ec; border-top-color: var(--brand);
  border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: -5px; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: -260px; z-index: 60; transition: left .2s; }
  .sidebar.open { left: 0; }
  .view { padding: 18px 16px 40px; }
  .topbar { padding: 0 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
}
