:root {
  --ink: #0b1220;
  --ink-2: #101a2e;
  --ink-3: #1b2740;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --line: #e6e9f0;
  --line-2: #eef1f6;
  --text: #101828;
  --text-2: #475467;
  --muted: #7c8aa3;
  --brand: #e0476f;
  --brand-soft: #fdeef2;
  --blue: #2f6bff;
  --blue-soft: #eaf0ff;
  --green: #10b981;
  --green-soft: #e8f8f2;
  --amber: #f59e0b;
  --amber-soft: #fef5e7;
  --red: #ef4444;
  --red-soft: #fdeeee;
  --violet: #7c5cfc;
  --violet-soft: #f0edff;
  --cyan: #06a6c9;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 18px -8px rgba(16, 24, 40, .12);
  --shadow-lg: 0 18px 40px -16px rgba(16, 24, 40, .22);
  --sidebar-w: 238px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
::selection { background: #ffd9e3; }

/* ---------- 侧边栏 ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, #0b1220 0%, #0f1b31 60%, #111f38 100%);
  color: #c8d3e6;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  overflow: hidden;
}
.sidebar::after {
  content: "";
  position: absolute;
  inset: auto -40% -30% -40%;
  height: 320px;
  background: radial-gradient(circle at 50% 100%, rgba(224, 71, 111, .28), transparent 65%);
  pointer-events: none;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 22px 20px 18px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(140deg, #e0476f, #ff8fae);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 17px; letter-spacing: -.5px;
  box-shadow: 0 6px 16px -6px rgba(224, 71, 111, .8);
}
.brand-name { color: #fff; font-weight: 700; letter-spacing: .16em; font-size: 15px; }
.brand-sub { font-size: 11px; color: #8f9db6; letter-spacing: .08em; }
.nav { padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; position: relative; z-index: 1; }
.nav-label { font-size: 10.5px; letter-spacing: .14em; color: #6c7c96; padding: 16px 10px 6px; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 10px;
  color: #b9c5d8; font-size: 13.5px; cursor: pointer;
  transition: background .15s, color .15s;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active { background: rgba(224, 71, 111, .16); color: #fff; box-shadow: inset 0 0 0 1px rgba(224, 71, 111, .32); }
.nav-item svg { width: 17px; height: 17px; flex: 0 0 17px; opacity: .9; }
.nav-badge { margin-left: auto; font-size: 10.5px; background: rgba(255,255,255,.12); padding: 1px 7px; border-radius: 20px; color: #dfe7f5; }
.sidebar-foot { padding: 14px 18px 20px; font-size: 11.5px; color: #7d8ca6; position: relative; z-index: 1; }
.sidebar-foot .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; margin-right: 6px; box-shadow: 0 0 0 3px rgba(16, 185, 129, .16); }
.sidebar-foot .dot.bad { background: var(--red); box-shadow: 0 0 0 3px rgba(239, 68, 68, .16); }

/* ---------- 主区 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 30px; background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 18px; margin: 0; letter-spacing: -.01em; }
.topbar .sub { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.page { padding: 26px 30px 60px; max-width: 1500px; width: 100%; }
.hamburger { display: none; }

/* ---------- 通用组件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 9px; font-size: 13px; font-weight: 550;
  cursor: pointer; transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: #d3dae7; background: #fbfcfe; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #17243c; border-color: #17243c; }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover { background: #d13a63; border-color: #d13a63; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: #f0f3f9; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-icon { padding: 8px; width: 34px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-h { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 0; }
.card-h h3 { margin: 0; font-size: 14.5px; letter-spacing: -.01em; }
.card-h .hint { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card-h .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-b { padding: 16px 20px 20px; }

.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { padding: 17px 18px 15px; position: relative; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 26px; font-weight: 700; letter-spacing: -.03em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.kpi .foot { color: var(--muted); font-size: 11.5px; margin-top: 6px; display: flex; gap: 8px; align-items: center; }
.kpi .spark { position: absolute; right: 12px; bottom: 12px; opacity: .9; }
.kpi-accent { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand); }
.kpi-accent.blue { background: var(--blue); }
.kpi-accent.green { background: var(--green); }
.kpi-accent.violet { background: var(--violet); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 20px;
  padding: 2px 8px; font-size: 11.5px; font-weight: 550; line-height: 1.7;
  background: #f2f4f8; color: var(--text-2); white-space: nowrap;
}
.badge.green { background: var(--green-soft); color: #0a7a57; }
.badge.amber { background: var(--amber-soft); color: #b06a02; }
.badge.red { background: var(--red-soft); color: #b42323; }
.badge.blue { background: var(--blue-soft); color: #1f4fd1; }
.badge.violet { background: var(--violet-soft); color: #5b3fd6; }
.badge.brand { background: var(--brand-soft); color: #b72a51; }
.badge.ghost { background: transparent; border: 1px solid var(--line); }

.table-wrap { overflow: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: var(--surface-2); position: sticky; top: 0; z-index: 1;
}
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: #fbfcff; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .strong { font-weight: 600; }
.tbl .asin { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--text-2); }
.prod { display: flex; align-items: center; gap: 10px; min-width: 240px; }
.prod img { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; background: #f2f4f8; border: 1px solid var(--line-2); }
.detail-img { width: 132px; height: 176px; flex: 0 0 132px; object-fit: contain; border-radius: 12px; background: #f7f9fd; border: 1px solid var(--line-2); }
.prod .t { font-weight: 550; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prod .s { color: var(--muted); font-size: 11.5px; }
.delta-up { color: var(--green); font-weight: 600; }
.delta-down { color: var(--red); font-weight: 600; }
.delta-flat { color: var(--muted); }

.tabs { display: inline-flex; background: #eef1f7; border-radius: 10px; padding: 3px; gap: 2px; }
.tab { border: none; background: none; padding: 6px 12px; font-size: 12.5px; border-radius: 8px; color: var(--text-2); cursor: pointer; font-weight: 550; }
.tab.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(16,24,40,.1); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: 20px; border: 1px solid var(--line); background: #fff; font-size: 12.5px; color: var(--text-2); cursor: pointer; transition: .15s; }
.chip:hover { border-color: #cfd8e8; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.kanban { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
.pill { padding: 4px 10px; border-radius: 20px; background: #f2f4f8; font-size: 12px; color: var(--text-2); border: 1px solid transparent; }
.pill.on { background: var(--brand-soft); color: #b72a51; border-color: #f8cdd9; }
.pill button { border: none; background: none; color: inherit; cursor: pointer; padding: 0 0 0 5px; opacity: .55; }

.input, .select {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 9px;
  padding: 8px 11px; font-size: 13px; color: var(--text); outline: none; transition: .15s;
}
.input:focus, .select:focus { border-color: #b9c6e4; box-shadow: 0 0 0 3px rgba(47, 107, 255, .1); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--text-2); font-weight: 550; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.search-box { position: relative; }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }
.search-box .input { padding-left: 33px; }

.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty .icon { font-size: 30px; margin-bottom: 8px; opacity: .6; }
.empty h4 { margin: 0 0 4px; color: var(--text-2); font-size: 14px; }
.skeleton { background: linear-gradient(90deg, #eef1f6 25%, #f6f8fb 37%, #eef1f6 63%); background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: 8px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.progress { height: 6px; border-radius: 6px; background: #eef1f7; overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--brand), #ff9bb4); transition: width .4s; }
.progress.blue > i { background: linear-gradient(90deg, var(--blue), #7ea6ff); }

.bar-track { height: 8px; background: #f1f4f9; border-radius: 6px; overflow: hidden; min-width: 70px; }
.bar-track > i { display: block; height: 100%; border-radius: 6px; background: var(--blue); }
.bar-track.brand > i { background: var(--brand); }
.bar-track.green > i { background: var(--green); }
.bar-track.amber > i { background: var(--amber); }

.insight { display: flex; gap: 12px; padding: 12px 4px; border-bottom: 1px dashed var(--line); }
.insight:last-child { border-bottom: none; }
.insight .ico { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 9px; display: grid; place-items: center; font-size: 14px; background: var(--blue-soft); }
.insight.warn .ico { background: var(--amber-soft); }
.insight .t { font-weight: 600; font-size: 13px; }
.insight .b { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-2); }
.legend .li { display: flex; align-items: center; gap: 6px; }
.legend .sw { width: 9px; height: 9px; border-radius: 3px; }

.chart { width: 100%; display: block; overflow: visible; }
.chart text { font-family: var(--font); fill: var(--muted); font-size: 10.5px; }
.chart .grid-line { stroke: #eef1f6; stroke-width: 1; }
.chart .axis { stroke: #e3e8f0; stroke-width: 1; }

.job-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line-2); }
.job-row:last-child { border-bottom: none; }
.job-status { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.job-status.running { background: var(--blue); box-shadow: 0 0 0 4px rgba(47,107,255,.12); animation: pulse 1.4s infinite; }
.job-status.queued { background: var(--amber); }
.job-status.done { background: var(--green); }
.job-status.failed { background: var(--red); }
.job-status.canceled { background: #b6bfcf; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(47,107,255,.04); } }

.log { background: #0d1526; color: #c6d3e8; border-radius: 10px; padding: 12px 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; max-height: 260px; overflow: auto; line-height: 1.75; }
.log .warn { color: #ffcf7a; }
.log .error { color: #ff9b9b; }
.log .ts { color: #64748b; margin-right: 8px; }

.matrix { display: grid; gap: 6px; }
.matrix .cell { padding: 8px 10px; border-radius: 8px; font-size: 12px; background: #f7f9fd; border: 1px solid var(--line-2); }
.seg { display: flex; gap: 6px; }

.hero {
  border-radius: 18px; padding: 24px 26px; color: #fff; position: relative; overflow: hidden;
  background: radial-gradient(900px 300px at 10% 0%, rgba(224,71,111,.42), transparent 60%), linear-gradient(135deg, #0b1220, #16233c 60%, #1c2c4a);
  box-shadow: var(--shadow-lg);
}
.hero h2 { margin: 0 0 6px; font-size: 20px; letter-spacing: -.02em; }
.hero p { margin: 0; color: #b7c4da; font-size: 13px; max-width: 720px; }
.hero .stats { display: flex; gap: 26px; margin-top: 18px; flex-wrap: wrap; }
.hero .st .v { font-size: 19px; font-weight: 700; }
.hero .st .k { font-size: 11.5px; color: #93a2bb; }

.drawer-mask { position: fixed; inset: 0; background: rgba(11, 18, 32, .42); backdrop-filter: blur(2px); z-index: 70; display: none; }
.drawer-mask.show { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 96vw); background: var(--bg);
  z-index: 71; box-shadow: -20px 0 60px rgba(11, 18, 32, .25); transform: translateX(100%);
  transition: transform .25s ease; display: flex; flex-direction: column;
}
.drawer.show { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 16px 22px; background: #fff; border-bottom: 1px solid var(--line); }
.drawer-head h3 { margin: 0; font-size: 15px; }
.drawer-body { padding: 20px 22px 40px; overflow: auto; }

.toast-wrap { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 90; }
.toast { background: #101a2e; color: #fff; padding: 10px 14px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow-lg); animation: tin .2s ease; max-width: 380px; }
.toast.err { background: #7f1d1d; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

.modal-mask { position: fixed; inset: 0; background: rgba(11,18,32,.45); display: grid; place-items: center; z-index: 80; padding: 20px; }
.modal { background: #fff; border-radius: 16px; width: min(560px, 96vw); box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-h { padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 600; }
.modal-b { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; max-height: 70vh; overflow: auto; }
.modal-f { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); }

.list-divider { height: 1px; background: var(--line-2); margin: 14px 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; } .items-center { align-items: center; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.between { justify-content: space-between; } .wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.score-ring { width: 54px; height: 54px; }

@media (max-width: 1280px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .22s; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 0 100vw rgba(11,18,32,.4); }
  .hamburger { display: inline-flex; }
  .page { padding: 18px 16px 50px; }
  .topbar { padding: 14px 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
