/* 云虎工具箱 · 后台管理样式 */
:root {
  --brand: #00b3ff;
  --brand-dark: #0092d6;
  --brand-soft: #e6f7ff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e6ebf2;
  --bg: #f4f7fb;
  --card: #ffffff;
  --ok: #16a34a;
  --ok-soft: #e8f7ee;
  --warn: #f59e0b;
  --warn-soft: #fff7e6;
  --danger: #ef4444;
  --danger-soft: #feeceb;
  --info-soft: #eaf2ff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .05);
  --sidebar-w: 216px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 登录 ---------- */
.login-view {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 15% 10%, #0b2a44 0%, #071626 55%, #050d16 100%);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 388px; background: #fff; border-radius: 18px; padding: 30px 30px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.login-logo { width: 44px; height: 44px; border-radius: 10px; }
.login-brand h1 { font-size: 20px; letter-spacing: .5px; }
.login-brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: #fbfdff; 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(0, 179, 255, .15); background: #fff;
}
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 6px; }
.login-hint { color: var(--muted); font-size: 12px; text-align: center; margin: 14px 0 0; }
.btn-block { width: 100%; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: #0b1220; color: #cbd5e1;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; }
.side-logo { width: 32px; height: 32px; border-radius: 8px; }
.side-brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.side-brand-text strong { color: #fff; font-size: 15px; letter-spacing: .4px; }
.side-brand-text span { color: #64748b; font-size: 11px; }
.nav { flex: 1; overflow-y: auto; padding: 6px 10px 12px; }
.nav-group {
  color: #475569; font-size: 11px; letter-spacing: 1px; padding: 14px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 8px;
  color: #b6c2d2; font-size: 13.5px; margin-bottom: 2px; text-decoration: none; transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-item.active { background: linear-gradient(90deg, rgba(0, 179, 255, .22), rgba(0, 179, 255, .08)); color: #7fd6ff; }
.nav-item.active .ico { color: #7fd6ff; }
.nav-item .ico { width: 16px; text-align: center; font-style: normal; font-size: 13px; color: #64748b; }
.nav-badge {
  margin-left: auto; background: #ef4444; color: #fff; font-size: 11px; font-style: normal;
  min-width: 18px; height: 18px; border-radius: 9px; display: inline-flex; align-items: center;
  justify-content: center; padding: 0 5px;
}
.side-foot {
  padding: 12px 16px; border-top: 1px solid rgba(255, 255, 255, .06);
  display: flex; justify-content: space-between; font-size: 11px; color: #64748b;
}
.side-foot a { color: #7fd6ff; }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 56px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center;
  gap: 12px; padding: 0 20px; position: sticky; top: 0; z-index: 20;
}
.icon-btn { display: none; border: 0; background: transparent; font-size: 18px; cursor: pointer; color: var(--ink-2); }
.crumb { font-size: 15px; font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.badge-status {
  font-size: 12px; color: var(--ok); background: var(--ok-soft); padding: 4px 10px; border-radius: 20px;
}
.badge-status.off { color: var(--danger); background: var(--danger-soft); }
.admin-menu { position: relative; }
.admin-chip {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff;
  border-radius: 20px; padding: 4px 10px 4px 4px; cursor: pointer;
}
.avatar {
  width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), #2dd4bf);
  color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
}
.caret { color: var(--muted); font-size: 11px; }
.admin-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); min-width: 150px; padding: 6px; display: none; z-index: 30;
}
.admin-dropdown.open { display: block; }
.admin-dropdown button {
  display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px;
  border-radius: 7px; cursor: pointer; font-size: 13px;
}
.admin-dropdown button:hover { background: var(--brand-soft); }
.content { padding: 20px; max-width: 1600px; width: 100%; margin: 0 auto; }

/* ---------- 通用组件 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.card-head h3 { font-size: 15px; }
.card-head .sub { color: var(--muted); font-size: 12px; }
.card-body { padding: 16px 18px; }
.mt16 { margin-top: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); background: #fff;
  cursor: pointer; font-size: 13.5px; color: var(--ink-2); transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: #c9d8e6; background: #f8fbff; }
.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 { background: #fff; border-color: #f7c7c4; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--brand-dark); }
.btn-ghost:hover { background: var(--brand-soft); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-link { border: 0; background: none; color: var(--brand-dark); cursor: pointer; padding: 0 4px; font-size: 13px; }
.btn-link.danger { color: var(--danger); }
.btn-link:hover { text-decoration: underline; }

.input, .select, .textarea {
  padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fbfdff; outline: none;
  transition: border-color .15s, box-shadow .15s; font-size: 13.5px;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0, 179, 255, .13); background: #fff; }
.textarea { width: 100%; min-height: 120px; resize: vertical; line-height: 1.7; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar .input { min-width: 190px; }
.spacer { flex: 1; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { padding: 11px 12px; text-align: left; border-bottom: 1px solid #eef3f8; vertical-align: middle; }
table.data th { color: var(--muted); font-weight: 500; background: #fafcff; white-space: nowrap; font-size: 12.5px; }
table.data tbody tr:hover { background: #f9fcff; }
table.data td.nowrap { white-space: nowrap; }
table.data .ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-empty { padding: 44px 0; text-align: center; color: var(--muted); }
.table-empty .big { font-size: 28px; display: block; margin-bottom: 8px; opacity: .5; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; line-height: 18px; }
.badge.gray { background: #f1f5f9; color: #475569; }
.badge.blue { background: var(--info-soft); color: #2563eb; }
.badge.green { background: var(--ok-soft); color: var(--ok); }
.badge.orange { background: var(--warn-soft); color: #b45309; }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.cyan { background: var(--brand-soft); color: #0284c7; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pager .info { color: var(--muted); font-size: 12.5px; }
.pager .pages { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.pager button {
  min-width: 32px; height: 30px; border: 1px solid var(--line); background: #fff; border-radius: 7px; cursor: pointer;
  font-size: 13px; color: var(--ink-2);
}
.pager button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager button:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- 统计卡 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat-card .label { color: var(--muted); font-size: 12.5px; }
.stat-card .value { font-size: 26px; font-weight: 700; margin-top: 8px; letter-spacing: .5px; }
.stat-card .delta { font-size: 12px; color: var(--muted); margin-top: 6px; }
.stat-card .delta b { color: var(--ok); font-weight: 600; }
.stat-card::after {
  content: ""; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 179, 255, .14), transparent 70%);
}
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; }
.grid-2 > .card { min-width: 0; }

/* 柱状趋势图 */
.chart { height: 190px; display: flex; align-items: flex-end; gap: 8px; padding: 8px 4px 0; }
.chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.chart .bar-stack { width: 100%; max-width: 34px; display: flex; flex-direction: column; justify-content: flex-end; height: 140px; gap: 2px; }
.chart .bar { width: 100%; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, #38c6ff, #00b3ff); min-height: 2px; transition: height .3s; }
.chart .bar.alt { background: linear-gradient(180deg, #8b5cf6, #6d28d9); }
.chart .bar-label { font-size: 10px; color: var(--muted); white-space: nowrap; transform: scale(.92); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

.status-list { display: flex; flex-direction: column; gap: 10px; }
.status-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.status-row .name { width: 66px; color: var(--ink-2); }
.status-row .track { flex: 1; height: 8px; background: #eef3f8; border-radius: 8px; overflow: hidden; }
.status-row .fill { height: 100%; border-radius: 8px; background: linear-gradient(90deg, #38c6ff, #00b3ff); }
.status-row .n { width: 40px; text-align: right; color: var(--muted); }

/* 详情 */
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; }
.detail-item { font-size: 13px; display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px dashed #eef3f8; }
.detail-item .k { color: var(--muted); min-width: 84px; }
.detail-item .v { color: var(--ink); word-break: break-all; flex: 1; }
.section-title { font-size: 13px; font-weight: 600; margin: 18px 0 8px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ""; width: 3px; height: 13px; background: var(--brand); border-radius: 2px; }
.goods-cell { display: flex; gap: 8px; align-items: center; }
.goods-img { width: 38px; height: 38px; border-radius: 7px; object-fit: cover; background: #f1f5f9; flex: none; }
.goods-img.ph { display: inline-flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 15px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(8, 20, 35, .48); display: flex; align-items: flex-start;
  justify-content: center; padding: 5vh 16px; z-index: 100; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 620px; box-shadow: 0 22px 60px rgba(0, 0, 0, .3);
  animation: pop .16s ease-out;
}
.modal.wide { max-width: 860px; }
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 15.5px; }
.modal-close { border: 0; background: transparent; font-size: 18px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 18px 20px; max-height: 66vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 13px 20px; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }

/* ---------- Toast ---------- */
.toast-root { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 200px; max-width: 380px; background: #0f172a; color: #fff; padding: 11px 15px; border-radius: 10px;
  font-size: 13.5px; box-shadow: 0 12px 30px rgba(0, 0, 0, .25); animation: slidein .2s ease-out;
  border-left: 3px solid var(--brand);
}
.toast.ok { border-left-color: #22c55e; }
.toast.err { border-left-color: #ef4444; }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 空态 / 加载 ---------- */
.loading { padding: 48px; text-align: center; color: var(--muted); }
.loading .spin {
  width: 26px; height: 26px; border: 3px solid #e2e8f0; border-top-color: var(--brand); border-radius: 50%;
  margin: 0 auto 10px; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.code-box {
  background: #0b1220; color: #a5f3fc; border-radius: 9px; padding: 14px 16px; font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px; line-height: 1.65; overflow: auto; max-height: 340px; white-space: pre-wrap; word-break: break-all;
}
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  border: 0; background: transparent; padding: 9px 14px; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; font-size: 13.5px;
}
.tab.active { color: var(--brand-dark); border-bottom-color: var(--brand); font-weight: 600; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; }
.switch input { display: none; }
.switch .slider {
  width: 38px; height: 21px; border-radius: 20px; background: #cbd5e1; position: relative; transition: background .15s;
}
.switch .slider::after {
  content: ""; position: absolute; left: 2px; top: 2px; width: 17px; height: 17px; border-radius: 50%;
  background: #fff; transition: left .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::after { left: 19px; }

.kv-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.qr-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.qr-box {
  border: 1px dashed #cfe1ef; border-radius: 10px; padding: 12px; text-align: center;
  background: #fbfdff; display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.qr-box img { width: 148px; height: 148px; object-fit: contain; border-radius: 8px; background: #fff; }
.qr-box .qr-empty {
  width: 148px; height: 148px; border-radius: 8px; background: #f1f5f9; color: #94a3b8;
  display: flex; align-items: center; justify-content: center; font-size: 12px;
}
.qr-box label { font-size: 12.5px; color: var(--muted); }
.shot-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); cursor: zoom-in; }
.chip-edit { display: flex; gap: 6px; align-items: center; }
.chip-edit .input { flex: 1; }

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%); transition: transform .2s;
    box-shadow: 0 0 40px rgba(0, 0, 0, .3);
  }
  .sidebar.open { transform: none; }
  .icon-btn { display: inline-block; }
  .content { padding: 14px; }
  .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
}
