/* ============ 设计变量 ============ */
:root {
  --blue-950: #071A47;
  --blue-900: #0B2462;
  --blue-800: #12348A;
  --blue-700: #1846C2;
  --blue-600: #1F5BFF;
  --blue-500: #3D74FF;
  --blue-100: #E6EEFF;
  --blue-50:  #F2F6FF;

  --ink:      #0E1A33;
  --ink-2:    #3B4A66;
  --muted:    #556580;
  --faint:    #596985;
  --line:     #E4E9F2;
  --line-2:   #EEF2F8;
  --bg:       #F3F6FB;
  --surface:  #FFFFFF;

  --red:      #BD2C37;
  --red-soft: #FFF1F1;
  --red-line: #FFD4D5;
  --green:    #087451;
  --green-soft:#E8F8F2;
  --amber:    #C27803;

  --radius-lg: 18px;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(14, 26, 51, .05);
  --shadow:    0 1px 2px rgba(14, 26, 51, .04), 0 8px 24px -12px rgba(14, 26, 51, .12);
  --shadow-lg: 0 24px 60px -20px rgba(7, 26, 71, .35);

  --font: "Inter", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  --num:  "Bahnschrift", "DIN Alternate", "Inter", "Segoe UI", var(--font);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--blue-500); outline-offset: 2px; }

.ico {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.num { font-family: var(--num); font-variant-numeric: tabular-nums; }

/* ============ 布局 ============ */
.app {
  display: grid; grid-template-columns: 248px 1fr; min-height: 100vh;
  background: linear-gradient(90deg, var(--blue-950) 248px, transparent 248px);
}

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 22px 16px 18px;
  color: #DCE5FF;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(61, 116, 255, .35), transparent 60%),
    linear-gradient(180deg, var(--blue-900), var(--blue-950));
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 24px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #4F86FF, var(--blue-600));
  box-shadow: 0 8px 20px -6px rgba(31, 91, 255, .7), inset 0 1px 0 rgba(255,255,255,.25);
}
.brand-mark svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linejoin: round; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { color: #fff; font-size: 16px; letter-spacing: .06em; }
.brand-text span { font-size: 12px; color: #93A8DA; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; letter-spacing: .12em; color: #97ACDB; padding: 14px 12px 6px; }
.nav a {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: #C3D0F2; text-decoration: none;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(255,255,255,.12); color: #fff; font-weight: 600; }
.nav a.active::before {
  content: ""; position: absolute; left: -16px; top: 9px; bottom: 9px; width: 3px;
  border-radius: 0 3px 3px 0; background: #7FA6FF;
}
.nav-badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--red); color: #fff;
  font: 600 12px/20px var(--num); text-align: center;
}
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.storage-note {
  display: flex; gap: 10px; padding: 12px; border-radius: 12px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08);
}
.storage-note .ico { color: #7FA6FF; margin-top: 1px; }
.storage-note b { display: block; color: #fff; font-size: 13px; font-weight: 600; }
.storage-note span { font-size: 12px; color: #93A8DA; }
.btn-ghost-light {
  border: 1px solid rgba(255,255,255,.14); background: transparent; color: #AFC0EA;
  border-radius: 10px; padding: 8px; font-size: 13px;
  transition: background .2s, color .2s;
}
.btn-ghost-light:hover { background: rgba(224, 57, 62, .16); color: #FFC9CB; border-color: rgba(224,57,62,.4); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  padding: 22px 36px 18px;
  background: rgba(243, 246, 251, .85);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.crumb { margin: 0 0 2px; font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.topbar h1 { margin: 0; font-size: 22px; line-height: 1.3; letter-spacing: .02em; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.today { color: var(--muted); font-size: 13px; }
.intro-link {
  color: var(--blue-700); font-size: 13px; font-weight: 600;
  text-decoration: none; white-space: nowrap; padding: 8px 0;
}
.intro-link:hover { text-decoration: underline; }

.content { padding: 8px 36px 48px; outline: none; animation: viewIn .35s var(--ease); }
.app-foot { display: flex; justify-content: flex-end; padding: 0 36px 20px; }
.app-foot button { min-height: 44px; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============ 通用组件 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; white-space: nowrap; text-decoration: none;
  transition: background .2s var(--ease), box-shadow .2s var(--ease), transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn .ico { width: 16px; height: 16px; stroke-width: 2.2; }
.btn-primary { background: var(--blue-600); color: #fff; box-shadow: 0 6px 16px -8px rgba(31, 91, 255, .8); }
.btn-primary:hover { background: var(--blue-700); }
.btn-outline { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn-outline:hover { border-color: #C9D5EA; background: var(--blue-50); color: var(--blue-700); }
.btn-quiet { background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--line-2); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #C72C31; }
.btn:disabled { opacity: .45; pointer-events: none; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent;
  display: inline-grid; place-items: center; color: var(--muted);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--line-2); color: var(--ink); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }
.icon-btn .ico { width: 17px; height: 17px; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 22px 0;
}
.card-head h3 { margin: 0; font-size: 15px; }
.card-head p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.link-btn {
  display: inline-flex; align-items: center; gap: 4px;
  border: 0; background: none; padding: 4px 0; color: var(--blue-600); font-size: 13px; font-weight: 600;
  text-decoration: none;
}
.link-btn .ico { width: 15px; height: 15px; transition: transform .2s var(--ease); }
.link-btn:hover .ico { transform: translateX(3px); }

.tag {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.tag-cat { background: var(--blue-50); color: var(--blue-700); border: 1px solid var(--blue-100); font-weight: 500; }
.tag-low { background: var(--red-soft); color: var(--red); border: 1px solid var(--red-line); }
.tag-low::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--red);
  box-shadow: 0 0 0 0 rgba(224, 57, 62, .5); animation: pulse 1.8s infinite;
}
.tag-ok { background: var(--green-soft); color: var(--green); }
.tag-ok::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(224, 57, 62, .5); }
  70% { box-shadow: 0 0 0 6px rgba(224, 57, 62, 0); }
  100% { box-shadow: 0 0 0 0 rgba(224, 57, 62, 0); }
}

/* ============ 数据总览 ============ */
.hero {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 26px 30px; margin-bottom: 20px; border-radius: var(--radius-lg);
  color: #fff;
  background:
    radial-gradient(80% 140% at 100% 0%, rgba(127, 166, 255, .45), transparent 60%),
    linear-gradient(120deg, var(--blue-700), var(--blue-600) 55%, #4A80FF);
  box-shadow: 0 20px 40px -24px rgba(31, 91, 255, .8);
}
.hero::after {
  content: ""; position: absolute; right: -40px; bottom: -80px; width: 280px; height: 280px;
  border-radius: 50%; border: 40px solid rgba(255,255,255,.07);
}
.hero h2 { margin: 0 0 6px; font-size: 20px; letter-spacing: .02em; }
.hero p { margin: 0; color: rgba(255,255,255,.82); }
.hero .hero-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.hero .chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; font-size: 12px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.18);
}
.hero .chip .ico { width: 14px; height: 14px; }
.hero .btn { position: relative; z-index: 1; background: #fff; color: var(--blue-700); box-shadow: 0 10px 24px -12px rgba(7,26,71,.6); }
.hero .btn:hover { background: var(--blue-50); }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 20px; }
.kpi {
  position: relative; padding: 22px 24px; overflow: hidden;
  display: flex; flex-direction: column; gap: 14px;
  text-align: left; font: inherit; color: inherit;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
button.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow), 0 16px 30px -18px rgba(14,26,51,.3); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi-icon {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: var(--blue-50); color: var(--blue-600);
}
.kpi-value { font-family: var(--num); font-variant-numeric: tabular-nums; font-size: 38px; line-height: 1; font-weight: 600; letter-spacing: -.01em; }
.kpi-value small { font-family: var(--font); font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 6px; letter-spacing: 0; }
.kpi-foot { font-size: 12px; color: var(--muted); }
.kpi.is-alert { border-color: var(--red-line); background: linear-gradient(180deg, #FFF7F7, #fff 60%); }
.kpi.is-alert .kpi-icon { background: var(--red-soft); color: var(--red); }
.kpi.is-alert .kpi-value { color: var(--red); }
.kpi.is-calm .kpi-icon { background: var(--green-soft); color: var(--green); }

.grid-2 { display: grid; grid-template-columns: 1.25fr 1fr; gap: 20px; margin-bottom: 20px; }

.alert-list { list-style: none; margin: 0; padding: 10px 12px 14px; }
.alert-item {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; align-items: center;
  padding: 12px 10px; border-radius: 12px;
}
.alert-item + .alert-item { border-top: 1px dashed var(--line); border-radius: 0; }
.alert-name { font-weight: 600; }
.alert-name span { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }
.alert-gap { font-size: 12px; color: var(--red); font-weight: 600; }
.meter { grid-column: 1 / -1; position: relative; height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.meter i { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: linear-gradient(90deg, #FF7A7E, var(--red)); }
.meter-cap { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

.cat-list { list-style: none; margin: 0; padding: 14px 22px 20px; display: flex; flex-direction: column; gap: 14px; }
.cat-row { display: grid; grid-template-columns: 76px 1fr 64px; align-items: center; gap: 12px; }
.cat-row .cat-name { font-weight: 600; font-size: 13px; }
.cat-bar { height: 10px; border-radius: 5px; background: var(--line-2); overflow: hidden; }
.cat-bar i { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--blue-500), var(--blue-600)); transform-origin: left; animation: grow .8s var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } }
.cat-row .cat-num { text-align: right; font-size: 13px; color: var(--ink-2); }
.cat-row .cat-num small { color: var(--faint); font-size: 11px; display: block; line-height: 1.2; }

.timeline { list-style: none; margin: 0; padding: 12px 22px 18px; }
.timeline li { display: grid; grid-template-columns: 10px 1fr auto; gap: 14px; align-items: baseline; padding: 9px 0; }
.timeline li + li { border-top: 1px solid var(--line-2); }
.timeline .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue-500); transform: translateY(-1px); }
.timeline .dot.import { background: #7A5AF8; }
.timeline .dot.delete, .timeline .dot.clear { background: var(--red); }
.timeline .dot.add { background: var(--green); }
.timeline time { color: var(--faint); font-size: 12px; white-space: nowrap; }

.empty-mini { padding: 28px 22px 30px; text-align: center; color: var(--muted); font-size: 13px; }
.empty-mini .ico { width: 28px; height: 28px; color: var(--green); display: block; margin: 0 auto 8px; }

/* 首次使用空状态 */
.welcome {
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 0; overflow: hidden;
}
.welcome-main { padding: 44px 44px 40px; }
.welcome-main h2 { margin: 14px 0 10px; font-size: 26px; line-height: 1.35; }
.welcome-main p { margin: 0 0 26px; color: var(--ink-2); max-width: 30em; }
.eyebrow { display: inline-block; font-size: 12px; font-weight: 600; letter-spacing: .12em; color: var(--blue-600); background: var(--blue-50); padding: 4px 10px; border-radius: 999px; }
.steps { list-style: none; margin: 0 0 30px; padding: 0; display: flex; flex-direction: column; gap: 14px; counter-reset: s; }
.steps li { display: flex; gap: 12px; align-items: flex-start; color: var(--ink-2); }
.steps li::before {
  counter-increment: s; content: counter(s);
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font: 600 12px var(--num);
  background: var(--blue-600); color: #fff;
}
.steps b { color: var(--ink); }
.welcome-art {
  position: relative; min-height: 320px;
  background:
    radial-gradient(60% 60% at 70% 30%, rgba(61,116,255,.22), transparent 70%),
    linear-gradient(160deg, var(--blue-50), #fff);
  border-left: 1px solid var(--line);
  display: grid; place-items: center;
}
.art-stack { position: relative; width: 240px; height: 220px; }
.art-card {
  position: absolute; border-radius: 14px; background: #fff; border: 1px solid var(--line);
  box-shadow: 0 18px 40px -20px rgba(14,26,51,.35); padding: 14px 16px;
}
.art-card.a { left: 0; top: 0; width: 200px; transform: rotate(-4deg); }
.art-card.b { right: 0; bottom: 0; width: 190px; transform: rotate(3deg); }
.art-card .l { height: 8px; border-radius: 4px; background: var(--line-2); margin: 8px 0; }
.art-card .l.s { width: 55%; }
.art-card .l.blue { background: var(--blue-100); width: 70%; }
.art-card .big { font: 600 28px/1 var(--num); color: var(--blue-600); }
.art-card .red { color: var(--red); }
.art-card small { color: var(--muted); font-size: 11px; }

/* ============ 库存列表 ============ */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.search {
  position: relative; flex: 1 1 260px; max-width: 360px;
}
.search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 17px; height: 17px; }
.search input {
  width: 100%; height: 38px; padding: 0 36px 0 38px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.search input:focus { outline: none; background: #fff; border-color: var(--blue-500); box-shadow: 0 0 0 4px rgba(61,116,255,.14); }
.search .clear { position: absolute; right: 4px; top: 3px; }
.search input::-webkit-search-cancel-button { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn {
  height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2); font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all .15s var(--ease);
}
.chip-btn em { font-style: normal; font: 600 11px var(--num); color: var(--faint); }
.chip-btn:hover { border-color: #C9D5EA; }
.chip-btn[aria-pressed="true"] { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.chip-btn[aria-pressed="true"] em { color: rgba(255,255,255,.75); }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 34px; height: 20px; border-radius: 10px; background: #D5DCE8; position: relative; margin: 0; cursor: pointer; transition: background .2s; }
.switch input::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .2s var(--ease); }
.switch input:checked { background: var(--red); }
.switch input:checked::after { transform: translateX(14px); }
.toolbar .spacer { flex: 1; }
.workbook-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.workbook-actions .btn { padding-inline: 10px; }
.import-grid .workbook-actions { margin: 0 18px 18px; }

.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; }
.grid th {
  position: sticky; top: 0;
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .04em;
  padding: 12px 16px; background: #FAFBFE; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.grid th.r, .grid td.r { text-align: right; }
.grid th button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.grid th button:hover { color: var(--ink); }
.grid th button .sort { opacity: .35; font-size: 10px; }
.grid th button[data-dir] .sort { opacity: 1; color: var(--blue-600); }
.grid td { padding: 10px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; white-space: nowrap; }
.grid tbody tr { transition: background .15s; }
.grid tbody tr:hover { background: #F8FAFE; }
.grid tbody tr.low { background: linear-gradient(90deg, #FFF6F6, transparent 45%); }
.grid tbody tr.low td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.grid tbody tr.flash { animation: flash 1.6s var(--ease); }
@keyframes flash { 0%, 30% { background: #FFF5D6; } 100% { background: transparent; } }
.cell-name { font-weight: 600; color: var(--ink); }
.cell-muted { color: var(--ink-2); }
.cell-stock { display: inline-flex; align-items: center; gap: 10px; justify-content: flex-end; }
.cell-stock b { font: 600 16px var(--num); min-width: 2ch; text-align: right; }
.tr-low .cell-stock b, tr.low .cell-stock b { color: var(--red); }
.mini { width: 56px; height: 5px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.mini i { display: block; height: 100%; border-radius: 3px; background: var(--blue-500); }
tr.low .mini i { background: var(--red); }
.cell-loc { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); }
.cell-loc .ico { width: 14px; height: 14px; color: var(--faint); }
mark { background: #FFE58F; color: inherit; border-radius: 3px; padding: 0 1px; }
.actions { display: inline-flex; gap: 2px; }

.table-foot { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; color: var(--muted); font-size: 12px; }

.empty {
  padding: 56px 20px; text-align: center; color: var(--muted);
}
.empty .ico { width: 40px; height: 40px; color: #C3CEE2; stroke-width: 1.4; margin-bottom: 10px; }
.empty h4 { margin: 0 0 4px; color: var(--ink); font-size: 15px; }
.empty p { margin: 0 0 16px; }

/* ============ 预警页 ============ */
.alert-banner {
  display: flex; align-items: center; gap: 14px; padding: 16px 20px; margin-bottom: 20px;
  border-radius: var(--radius); background: var(--red-soft); border: 1px solid var(--red-line); color: #9B1C20;
}
.alert-banner .ico { color: var(--red); width: 22px; height: 22px; }
.alert-banner.ok { background: var(--green-soft); border-color: #BDEBD9; color: #0B6B4D; }
.alert-banner.ok .ico { color: var(--green); }
.alert-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.a-card { padding: 20px; display: flex; flex-direction: column; gap: 14px; border-top: 3px solid var(--red); }
.a-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.a-card h4 { margin: 0; font-size: 16px; }
.a-card .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.a-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.a-nums div { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.a-nums span { display: block; font-size: 11px; color: var(--muted); }
.a-nums b { font: 600 20px/1.3 var(--num); }
.a-nums .neg b { color: var(--red); }

/* ============ 导入页 ============ */
.import-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.drop {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  min-height: 260px; padding: 32px; margin: 18px 22px 22px; border-radius: 16px; text-align: center;
  border: 1.5px dashed #BACBEB; background: linear-gradient(180deg, var(--blue-50), #fff);
  cursor: pointer; transition: border-color .2s, background .2s, transform .2s var(--ease);
}
.drop:hover, .drop.over { border-color: var(--blue-600); background: linear-gradient(180deg, var(--blue-100), #fff); }
.drop.over { transform: scale(1.01); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-icon { width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; background: #fff; color: var(--blue-600); box-shadow: var(--shadow); }
.drop-icon .ico { width: 28px; height: 28px; }
.drop h4 { margin: 6px 0 0; font-size: 16px; }
.drop p { margin: 0; color: var(--muted); font-size: 13px; }
.drop h4, .result-head p { overflow-wrap: anywhere; }
.file-notice { margin: -6px 18px 12px; color: var(--red); font-size: 13px; }
.file-notice:empty { margin: 0; }
.drop.busy { pointer-events: none; opacity: .7; }

.fields { list-style: none; margin: 0; padding: 14px 22px 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fields li { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--bg); font-size: 13px; }
.fields li .ico { width: 15px; height: 15px; color: var(--blue-600); stroke-width: 2.4; }
.fields li em { margin-left: auto; font-style: normal; font-size: 11px; color: var(--faint); }
.rules { margin: 0; padding: 0 22px 22px 40px; color: var(--ink-2); font-size: 13px; }
.rules li + li { margin-top: 6px; }

.result { margin-top: 20px; }
.result-head { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.file-badge { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: #E7F6EE; color: #13804F; }
.file-badge .ico { width: 24px; height: 24px; }
.result-head h3 { margin: 0; font-size: 15px; }
.result-head p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.stats { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.stat { padding: 6px 12px; border-radius: 10px; background: var(--bg); font-size: 12px; color: var(--muted); }
.stat b { font: 600 15px var(--num); color: var(--ink); margin-left: 4px; }
.stat.bad b { color: var(--red); }
.stat.good b { color: var(--green); }

.error-box { margin: 18px 22px 0; padding: 14px 16px; border-radius: 12px; background: var(--red-soft); border: 1px solid var(--red-line); color: #8E1A1E; font-size: 13px; }
.error-box b { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; color: var(--red); }
.error-box ul { margin: 0; padding-left: 20px; }
.error-box li + li { margin-top: 3px; }
.grid tr.bad td { background: #FFF6F6; }
.grid td .err-msg { color: var(--red); font-size: 12px; white-space: normal; min-width: 180px; display: block; }
.grid td .ok-msg { color: var(--green); display: inline-flex; }
.grid td .ok-msg .ico { width: 16px; height: 16px; stroke-width: 2.4; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); }
.result-actions .note { margin-right: auto; font-size: 12px; color: var(--muted); }
.mode { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.mode label { position: relative; }
.mode input { position: absolute; opacity: 0; }
.mode span { display: block; padding: 6px 14px; border-radius: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; transition: all .15s; }
.mode input:checked + span { background: #fff; color: var(--blue-700); font-weight: 600; box-shadow: var(--shadow-sm); }
.mode input:focus-visible + span { outline: 2px solid var(--blue-500); }

/* ============ 弹窗 ============ */
.modal {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: 20px;
  background: #fff; color: var(--ink); box-shadow: var(--shadow-lg);
}
.modal[open] { animation: pop .28s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal::backdrop { background: rgba(7, 26, 71, .38); backdrop-filter: blur(3px); }
.modal-sm { width: min(400px, calc(100vw - 32px)); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 22px 24px 4px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.modal-body { padding: 18px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px 20px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > :is(span, label) { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field > :is(span, label) i { color: var(--red); font-style: normal; }
.field input, .stepper {
  height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #fff;
  padding: 0 12px; transition: border-color .2s, box-shadow .2s;
}
.field input:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 4px rgba(61,116,255,.14); }
.field.invalid input, .field.invalid .stepper { border-color: var(--red); box-shadow: 0 0 0 4px rgba(224,57,62,.10); }
.field .err { font-style: normal; font-size: 12px; color: var(--red); min-height: 0; }
.field .err:empty { display: none; }
.stepper { display: flex; padding: 0; overflow: hidden; }
.stepper:focus-within { border-color: var(--blue-500); box-shadow: 0 0 0 4px rgba(61,116,255,.14); }
.stepper input { border: 0 !important; box-shadow: none !important; flex: 1; min-width: 0; text-align: center; font: 600 16px var(--num); height: 100%; }
.stepper button { width: 40px; border: 0; background: var(--bg); font-size: 18px; color: var(--ink-2); }
.stepper button:hover { background: var(--blue-50); color: var(--blue-600); }
.form-hint { font-size: 12px; padding: 10px 12px; border-radius: 10px; background: var(--bg); color: var(--muted); }
.form-hint:empty { display: none; }
.form-hint.low { background: var(--red-soft); color: var(--red); }

.confirm-body { text-align: center; padding-top: 28px; }
.confirm-icon { width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 16px; display: grid; place-items: center; background: var(--red-soft); color: var(--red); }
.confirm-icon .ico { width: 26px; height: 26px; }
.confirm-body h2 { margin: 0 0 6px; font-size: 17px; }
.confirm-body p { margin: 0; color: var(--ink-2); }
#confirmDialog .modal-foot, #downloadHelp .modal-foot { justify-content: center; }
#confirmDialog .modal-foot .btn { min-width: 110px; }

/* ============ 提示条 ============ */
.toasts { position: fixed; right: 24px; bottom: 24px; z-index: 50; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 240px; max-width: 380px;
  padding: 12px 16px; border-radius: 12px; background: var(--ink); color: #fff;
  box-shadow: var(--shadow-lg); font-size: 13px;
  animation: toastIn .3s var(--ease);
}
.toast .ico { width: 18px; height: 18px; color: #6EE7B7; }
.toast.error .ico { color: #FF9A9D; }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .25s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ============ 响应式 ============ */
@media (max-width: 1180px) {
  .grid-2, .import-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; background: none; }
  .sidebar {
    position: fixed; inset: auto 0 0 0; height: auto; z-index: 20; flex-direction: row;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: rgba(11, 36, 98, .97); backdrop-filter: blur(10px);
  }
  .brand, .nav-label, .sidebar-foot { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 3px; padding: 6px 10px; font-size: 11px; }
  .nav a.active::before { display: none; }
  .nav-badge { position: absolute; top: 0; right: 4px; margin: 0; min-width: 18px; height: 18px; font-size: 11px; line-height: 18px; }
  .main { padding-bottom: 76px; }
  .topbar { padding: 16px 18px 12px; }
  .content { padding: 4px 16px 32px; }
  .app-foot { padding-inline: 16px; }
  .today { display: none; }
  .kpis { grid-template-columns: 1fr; gap: 12px; }
  .kpi { padding: 16px 18px; gap: 10px; }
  .kpi-icon { width: 32px; height: 32px; }
  .kpi-value { font-size: 30px; }
  .welcome { grid-template-columns: 1fr; }
  .welcome-art { display: none; }
  .welcome-main { padding: 30px 24px; }
  .hero { flex-direction: column; align-items: flex-start; padding: 22px; }
}
@media (max-width: 720px) {
  .topbar h1 { font-size: 19px; }
  .topbar-right { gap: 12px; }
  .topbar .btn span, .topbar .btn-label { display: none; }
  .search { max-width: none; flex-basis: 100%; }
  .toolbar { gap: 8px; padding: 12px; }
  .toolbar .spacer { display: none; }
  .toolbar .workbook-actions { gap: 6px; }
  .toolbar .workbook-actions .btn { gap: 5px; padding-inline: 7px; font-size: 13px; }
  .toolbar .workbook-actions .ico { width: 14px; height: 14px; }
  .grid.stack thead { display: none; }
  .grid.stack, .grid.stack tbody { display: block; }
  .grid.stack tr {
    display: grid; grid-template-columns: 1fr auto; gap: 2px 12px;
    padding: 10px 16px; border-bottom: 1px solid var(--line-2);
  }
  .grid.stack td { padding: 0; border: 0; white-space: normal; }
  .grid.stack td[data-label]::before { content: attr(data-label) "："; color: var(--faint); font-size: 12px; }
  .grid.stack td.r { text-align: left; }
  .grid.stack .c-name { grid-column: 1; font-size: 15px; }
  .grid.stack td[data-label] { grid-column: 1; }
  .grid.stack .cell-stock { justify-content: flex-start; }
  .grid.stack .c-status { grid-column: 2; grid-row: 1; justify-self: end; }
  .grid.stack .c-actions { grid-column: 2; grid-row: 2 / span 5; align-self: end; }
  .grid.stack tbody tr.low td:first-child { box-shadow: none; }
  .grid.stack tbody tr.low { box-shadow: inset 3px 0 0 var(--red); }
  .fields { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .result-head .stats { margin-left: 0; }
  .toasts { left: 16px; right: 16px; bottom: 86px; }
  .toast { max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
