/* ============================================================
   仓储管家 · 样式
   ============================================================ */

:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e8eef5;
  --line-2: #f1f5f9;
  --brand: #0d9488;
  --brand-2: #0f766e;
  --brand-soft: #ecfdf5;
  --in: #0d9488;
  --out: #4f46e5;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 30px -24px rgba(15, 23, 42, .35);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  background-image:
    radial-gradient(1200px 600px at 100% -10%, rgba(13, 148, 136, .08), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, rgba(79, 70, 229, .06), transparent 55%);
  background-attachment: fixed;
}

button { font-family: inherit; }
input, select, textarea { font-family: inherit; }
h1, h2, h3, h4 { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ---------------- 布局 ---------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  position: sticky;
  top: 0;
  height: 100vh;
  background: rgba(255, 255, 255, .92);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  backdrop-filter: blur(8px);
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 22px; text-decoration: none; color: inherit; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; flex: 0 0 38px;
  background: linear-gradient(135deg, #14b8a6, #0f766e 60%, #115e59);
  color: #fff; display: grid; place-items: center;
  box-shadow: 0 6px 16px -6px rgba(13, 148, 136, .8);
}
.brand-img {
  width: 38px; height: 38px; border-radius: 11px; flex: 0 0 38px;
  box-shadow: 0 6px 16px -6px rgba(14, 116, 184, .55);
}
.brand-mark svg { width: 21px; height: 21px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15.5px; letter-spacing: .3px; }
.brand-text span { font-size: 10.5px; color: var(--muted-2); letter-spacing: 1.6px; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border: 0; border-radius: 10px;
  background: transparent; color: #475569; font-size: 13.8px; font-weight: 550;
  cursor: pointer; text-align: left; transition: background .15s, color .15s;
}
.nav-item svg { width: 19px; height: 19px; flex: 0 0 19px; opacity: .85; }
.nav-item:hover { background: #f4f7fb; color: var(--ink); }
.nav-item.active {
  background: var(--brand-soft); color: var(--brand-2);
  box-shadow: inset 0 0 0 1px rgba(13, 148, 136, .12);
}
.nav-item.active svg { opacity: 1; }

.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line-2); }
.live { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.live i {
  width: 7px; height: 7px; border-radius: 50%; background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, .16); animation: pulse 2.4s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .45 } }
.side-note { margin-top: 8px; font-size: 11px; color: var(--muted-2); word-break: break-all; line-height: 1.5; }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 28px;
  background: rgba(255, 255, 255, .8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.top-title h1 { font-size: 19px; font-weight: 700; letter-spacing: .2px; }
.top-title p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 9px; }

.sync-state {
  font-size: 12px; color: #15803d; background: #f0fdf4;
  border: 1px solid #dcfce7; padding: 4px 9px; border-radius: 999px;
  white-space: nowrap;
}
.sync-state.err { color: #b91c1c; background: #fef2f2; border-color: #fee2e2; }

.views { flex: 1; width: 100%; max-width: 1480px; margin: 0 auto; padding: 20px 28px 40px; }

/* ---------------- 通用组件 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  font-size: 13.3px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, transform .06s, box-shadow .15s;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: #f8fafc; border-color: #d7e0ea; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, #10b3a4, #0d9488);
  border-color: #0d9488; color: #fff;
  box-shadow: 0 1px 2px rgba(13, 148, 136, .35), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.btn.primary:hover { filter: brightness(1.04); background: linear-gradient(180deg, #10b3a4, #0d9488); }
.btn.ghost { background: #fff; }
.btn.danger { color: #b91c1c; border-color: #fecaca; background: #fff; }
.btn.danger:hover { background: #fef2f2; }
.btn.sm { height: 29px; padding: 0 10px; font-size: 12.3px; border-radius: 8px; }
.btn.icon-btn { width: 36px; padding: 0; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.input, .select, .textarea {
  height: 38px; width: 100%;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 0 12px; font-size: 13.4px; color: var(--ink); background: #fff;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 74px; padding: 9px 12px; line-height: 1.6; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  border-color: rgba(13, 148, 136, .55);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, .12);
}
.input::placeholder { color: #a8b3c1; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; font-weight: 600; color: var(--muted); }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title { font-size: 14.5px; font-weight: 680; display: flex; align-items: center; gap: 8px; }
.card-title i { width: 7px; height: 7px; border-radius: 2px; background: var(--brand); display: inline-block; }
.card-sub { font-size: 12px; color: var(--muted); font-weight: 400; }
.card-hint { font-size: 12px; color: var(--muted-2); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 14px; margin-top: 14px; }
.grid-even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.mt14 { margin-top: 14px; }

/* ---------------- KPI ---------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 15px 13px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 9px; position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; right: -22px; top: -26px; width: 86px; height: 86px;
  border-radius: 50%; background: var(--tint, rgba(13, 148, 136, .07));
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; position: relative; z-index: 1; }
.kpi-label { font-size: 12.2px; color: var(--muted); font-weight: 550; }
.kpi-ico { width: 27px; height: 27px; border-radius: 8px; display: grid; place-items: center; background: var(--tint, rgba(13, 148, 136, .1)); color: var(--tone, var(--brand)); }
.kpi-ico svg { width: 15px; height: 15px; }
.kpi-value { font-size: 25px; font-weight: 720; letter-spacing: -.4px; line-height: 1.1; position: relative; z-index: 1; }
.kpi-value small { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.kpi-foot { font-size: 11.8px; color: var(--muted-2); display: flex; align-items: center; gap: 5px; position: relative; z-index: 1; }
.trend-up { color: #0d9488; font-weight: 600; }
.trend-down { color: #dc2626; font-weight: 600; }
.trend-flat { color: var(--muted-2); }

/* ---------------- 图表 ---------------- */
.chart-host { position: relative; width: 100%; }
.chart-host svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-empty { padding: 46px 0; text-align: center; color: var(--muted-2); font-size: 12.5px; }

.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 3px; }

.chart-tip {
  position: absolute; z-index: 5; pointer-events: none;
  background: rgba(15, 23, 42, .94); color: #fff; font-size: 11.8px;
  padding: 8px 10px; border-radius: 8px; line-height: 1.55; white-space: nowrap;
  transform: translate(-50%, -114%); box-shadow: 0 8px 24px -10px rgba(0, 0, 0, .5);
  opacity: 0; transition: opacity .12s;
}
.chart-tip.show { opacity: 1; }
.chart-tip b { font-weight: 650; }

/* 环形图 */
.donut-wrap { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.donut-wrap svg { flex: 0 0 auto; }
.donut-legend { flex: 1; min-width: 130px; display: flex; flex-direction: column; gap: 7px; }
.donut-row { display: flex; align-items: center; gap: 8px; font-size: 12.3px; color: var(--ink-2); }
.donut-row i { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 8px; }
.donut-row .pct { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }

/* 横向条 */
.hbars { display: flex; flex-direction: column; gap: 11px; }
.hbar { display: grid; grid-template-columns: 118px 1fr 78px; align-items: center; gap: 10px; font-size: 12.5px; }
.hbar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.hbar-track { display: block; height: 9px; background: #eef2f7; border-radius: 99px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #2dd4bf, #0d9488); }
.hbar-val { text-align: right; font-weight: 620; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.2px; }
table.data th {
  text-align: left; font-size: 11.6px; font-weight: 620; color: var(--muted);
  padding: 8px 10px; background: #fafcfe; border-bottom: 1px solid var(--line);
  white-space: nowrap; letter-spacing: .2px;
}
table.data th:first-child { border-top-left-radius: 9px; }
table.data th:last-child { border-top-right-radius: 9px; }
table.data td { padding: 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data tbody tr:hover td { background: #f9fbfd; }
table.data td.right, table.data th.right { text-align: right; }
table.data .strong { font-weight: 600; }
table.data .sub { font-size: 11.6px; color: var(--muted-2); margin-top: 2px; }
table.data .qty-in { color: #0f766e; font-weight: 650; }
table.data .qty-out { color: #4338ca; font-weight: 650; }
table.data .qty-adj { color: #b45309; font-weight: 650; }
table.data .row-actions { display: flex; gap: 6px; justify-content: flex-end; opacity: .35; transition: opacity .15s; }
table.data tbody tr:hover .row-actions { opacity: 1; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11.6px; font-weight: 620; line-height: 1.7; white-space: nowrap; }
.badge.in { background: #ecfdf5; color: #047857; }
.badge.out { background: #eef2ff; color: #4338ca; }
.badge.adj { background: #fffbeb; color: #b45309; }
.badge.low { background: #fef2f2; color: #b91c1c; }
.badge.ok { background: #f0fdf4; color: #15803d; }
.badge.soft { background: #f1f5f9; color: #475569; }

/* ---------------- 工具栏 ---------------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1 1 220px; min-width: 160px; }
.toolbar .input, .toolbar .select { height: 36px; }
.search-box { position: relative; flex: 1 1 240px; min-width: 180px; }
.search-box svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted-2); }
.search-box .input { padding-left: 33px; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 12.8px; color: var(--ink-2); cursor: pointer; user-select: none; white-space: nowrap; }
.chk input { width: 15px; height: 15px; accent-color: var(--brand); }

/* ---------------- 看板细节 ---------------- */
.low-list { display: flex; flex-direction: column; gap: 2px; }
.low-row { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 9px; cursor: pointer; }
.low-row:hover { background: #f8fafc; }
.low-dot { width: 7px; height: 7px; border-radius: 50%; background: #ef4444; flex: 0 0 7px; box-shadow: 0 0 0 3px rgba(239, 68, 68, .12); }
.low-main { flex: 1; min-width: 0; overflow: hidden; }
.low-name { display: block; font-size: 13px; font-weight: 570; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.low-sub { display: block; font-size: 11.5px; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.low-qty { text-align: right; font-variant-numeric: tabular-nums; }
.low-qty b { color: #b91c1c; font-size: 13.5px; }
.low-qty span { display: block; font-size: 11px; color: var(--muted-2); }

.recent-list { display: flex; flex-direction: column; }
.recent-row { display: grid; grid-template-columns: 62px minmax(0, 1fr) 92px 96px 108px; gap: 10px; align-items: center; padding: 9px 4px; border-bottom: 1px dashed var(--line-2); font-size: 12.8px; }
.recent-row:last-child { border-bottom: 0; }
.recent-item { min-width: 0; }
.recent-item b { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item span { color: var(--muted-2); font-size: 11.3px; }
.recent-qty { text-align: right; font-weight: 620; font-variant-numeric: tabular-nums; }
.recent-meta { color: var(--muted); font-size: 11.8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-time { color: var(--muted-2); font-size: 11.6px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- 出入库登记 ---------------- */
.entry-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.seg { display: inline-flex; background: #f1f5f9; border-radius: 11px; padding: 4px; gap: 3px; }
.seg button {
  border: 0; background: transparent; padding: 7px 18px; border-radius: 8px;
  font-size: 13.2px; font-weight: 620; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; transition: .15s;
}
.seg button svg { width: 15px; height: 15px; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.seg button.on[data-type="in"] { color: #0f766e; }
.seg button.on[data-type="out"] { color: #4338ca; }

.picker { position: relative; }
.picker .input { padding-left: 34px; }
.picker > svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted-2); }
.picker-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 40;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg); max-height: 320px; overflow: auto; padding: 5px;
}
.picker-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.picker-item:hover, .picker-item.on { background: #f0fdfa; }
.picker-code { font-size: 11.5px; color: var(--muted-2); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.picker-name { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-name em { font-style: normal; color: var(--muted-2); font-size: 11.5px; margin-left: 6px; }
.picker-stock { font-size: 11.8px; color: var(--muted); white-space: nowrap; }
.picker-empty { padding: 14px; text-align: center; color: var(--muted-2); font-size: 12.5px; }

.lines-table { width: 100%; border-collapse: collapse; min-width: 560px; }
.lines-table th { font-size: 11.6px; color: var(--muted); font-weight: 620; text-align: left; padding: 8px; border-bottom: 1px solid var(--line); }
.lines-table td { padding: 8px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.lines-table .item-nm { font-weight: 600; font-size: 13px; }
.lines-table .item-sub { font-size: 11.4px; color: var(--muted-2); }
.lines-table .qty-box { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.lines-table .qty-box button { width: 26px; height: 30px; border: 0; background: #f8fafc; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; }
.lines-table .qty-box button:hover { background: #eef2f7; color: var(--ink); }
.lines-table .qty-box input { width: 54px; height: 30px; border: 0; text-align: center; font-size: 13px; font-weight: 600; outline: none; font-variant-numeric: tabular-nums; }
.lines-table .inp-sm { height: 30px; width: 82px; border: 1px solid var(--line); border-radius: 8px; text-align: right; padding: 0 8px; font-size: 12.8px; outline: none; }
.lines-table .inp-sm:focus { border-color: rgba(13, 148, 136, .5); }
.lines-table tr.bad td { background: #fff7f7; }
.lines-table .line-warn { font-size: 11px; color: #dc2626; margin-top: 3px; }
.line-del { border: 0; background: transparent; color: var(--muted-2); cursor: pointer; padding: 4px; border-radius: 6px; }
.line-del:hover { color: #dc2626; background: #fef2f2; }

.entry-summary { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding-top: 14px; margin-top: 8px; border-top: 1px dashed var(--line); }
.sum-item { font-size: 12.5px; color: var(--muted); }
.sum-item b { font-size: 17px; color: var(--ink); margin-left: 6px; font-variant-numeric: tabular-nums; }
.sum-item b.teal { color: var(--brand-2); }
.sum-item b.indigo { color: #4338ca; }

/* ---------------- 设置 ---------------- */
.set-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.kv { display: flex; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px dashed var(--line-2); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; text-align: right; word-break: break-all; }
.addr-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.addr { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #f8fafc; border: 1px solid var(--line-2); border-radius: 9px; padding: 9px 11px; font-size: 12.8px; }
.addr code { font-family: "JetBrains Mono", Consolas, monospace; color: var(--brand-2); font-size: 12.6px; }
.set-actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 6px; }
.tips { font-size: 12.3px; color: var(--muted); line-height: 1.85; }
.tips b { color: var(--ink-2); }

/* ---------------- 空状态 / 加载 ---------------- */
.empty { padding: 46px 16px; text-align: center; color: var(--muted-2); font-size: 13px; }
.empty svg { width: 40px; height: 40px; opacity: .35; margin-bottom: 10px; }
.empty b { display: block; color: var(--muted); font-weight: 600; margin-bottom: 4px; }

.skeleton { background: linear-gradient(90deg, #f1f5f9 25%, #f8fafc 37%, #f1f5f9 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 50% } 100% { background-position: 0 50% } }

/* ---------------- Toast ---------------- */
.toast-wrap { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 9px; padding: 10px 16px; border-radius: 11px;
  background: rgba(15, 23, 42, .94); color: #fff; font-size: 13px; font-weight: 550;
  box-shadow: var(--shadow-lg); animation: toastIn .22s ease;
  max-width: min(88vw, 460px);
}
.toast.ok { background: linear-gradient(180deg, #0f9d8f, #0d7d72); }
.toast.err { background: linear-gradient(180deg, #e04848, #c53030); }
.toast svg { width: 16px; height: 16px; flex: 0 0 16px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px) } to { opacity: 1; transform: none } }

/* ---------------- Modal ---------------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 150; background: rgba(15, 23, 42, .38);
  backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.modal {
  width: min(560px, 100%); max-height: min(86vh, 780px);
  background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: modalIn .18s cubic-bezier(.2, .8, .3, 1);
  overflow: hidden;
}
.modal.wide { width: min(760px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.985) } to { opacity: 1; transform: none } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.modal-head h2 { font-size: 16px; font-weight: 680; }
.modal-close { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 5px; border-radius: 7px; }
.modal-close:hover { background: #f1f5f9; color: var(--ink); }
.modal-close svg { width: 18px; height: 18px; display: block; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { padding: 13px 20px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 9px; background: #fcfdfe; }

/* 登录 */
.login-mask { position: fixed; inset: 0; z-index: 300; background: linear-gradient(160deg, #0f172a, #134e4a); display: grid; place-items: center; padding: 20px; }
.login-box { width: min(360px, 100%); background: #fff; border-radius: 18px; padding: 30px 26px; box-shadow: var(--shadow-lg); text-align: center; }
.login-mark { width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 14px; background: linear-gradient(135deg, #14b8a6, #0f766e); color: #fff; display: grid; place-items: center; }
.login-mark svg { width: 27px; height: 27px; }
.login-box h2 { font-size: 18px; margin-bottom: 6px; }
.login-box p { margin: 0 0 18px; font-size: 12.5px; color: var(--muted); }
.login-box input { width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 0 13px; font-size: 14px; outline: none; margin-bottom: 12px; }
.login-box input:focus { border-color: rgba(13, 148, 136, .6); box-shadow: 0 0 0 3px rgba(13, 148, 136, .12); }
.login-err { color: #dc2626; font-size: 12.5px; margin-top: 10px; min-height: 16px; }

/* ---------------- 移动端 ---------------- */
.tabbar { display: none; }

@media (max-width: 1240px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .sidebar { display: none; }
  .topbar { padding: 12px 16px; }
  .views { padding: 14px 16px 96px; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: rgba(255, 255, 255, .96); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 24px -18px rgba(15, 23, 42, .5);
  }
  .tab {
    flex: 1; border: 0; background: transparent; color: var(--muted-2);
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-size: 10.5px; padding: 4px 0; cursor: pointer;
  }
  .tab svg { width: 20px; height: 20px; }
  .tab.active { color: var(--brand-2); }
  .tab-main { position: relative; }
  .tab-fab {
    width: 44px; height: 44px; border-radius: 50%; margin-top: -20px; margin-bottom: 1px;
    background: linear-gradient(160deg, #14b8a6, #0d9488); color: #fff;
    display: grid; place-items: center;
    box-shadow: 0 8px 18px -6px rgba(13, 148, 136, .75), 0 0 0 4px #fff;
  }
  .tab-fab svg { width: 22px; height: 22px; }
  .grid-2, .grid-even, .set-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid, .form-grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .recent-row { grid-template-columns: 58px minmax(0, 1fr) 78px; }
  .recent-row .recent-meta, .recent-row .recent-time { display: none; }
  .sync-state { display: none; }
}

@media (max-width: 640px) {
  .top-title h1 { font-size: 17px; }
  .top-title p { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 13px; }
  .kpi-value { font-size: 21px; }
  .card { padding: 14px; border-radius: 13px; }
  .form-grid, .form-grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .btn.primary span { display: none; }
  .btn.primary { width: 38px; padding: 0; }
  .btn.primary.keep-text { width: auto; padding: 0 14px; }
  .btn.primary.keep-text span { display: inline; }
  .form-grid .btn.primary { width: 100%; padding: 0 14px; }
  .form-grid .btn.primary span { display: inline; }
  .chart-legend { font-size: 11.5px; gap: 12px; }
  .donut-wrap { justify-content: center; }
  .hbar { grid-template-columns: 76px 1fr 54px; }
  .modal { max-height: 92vh; }
  .modal-body { padding: 14px; }
  .table-wrap { margin: 0 -14px; padding: 0 14px; }
  .stock-table th:nth-child(2), .stock-table td:nth-child(2) { display: none; }
  .moves-table th:nth-child(5), .moves-table td:nth-child(5),
  .moves-table th:nth-child(6), .moves-table td:nth-child(6),
  .moves-table th:nth-child(7), .moves-table td:nth-child(7),
  .moves-table th:nth-child(8), .moves-table td:nth-child(8) { display: none; }
  .moves-table td:nth-child(1) { font-size: 11px; white-space: nowrap; }
  .moves-table td:nth-child(2), .moves-table td:nth-child(4) { white-space: nowrap; }
  .row-actions { opacity: 1; }
  .row-actions .btn { height: 26px; padding: 0 7px; font-size: 11.6px; }
  .lines-table { min-width: 600px; }
  .card-head { flex-wrap: wrap; row-gap: 8px; }
  .card-head .seg { margin-left: auto; }
  .seg button { padding: 6px 11px; font-size: 12.3px; }
  .card-head .seg button { padding: 4px 8px; font-size: 11.6px; }
}

/* ============================================================
   ECharts 容器与新看板
   ============================================================ */
.echart { width: 100%; height: 258px; }
.echart.tall { height: 288px; }
.echart.gauge { height: 158px; }
.echart.heat { height: 250px; }
.chart-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: -2px 0 4px; }
.seg-sm button { padding: 4px 9px; font-size: 11.5px; }
.seg-sm { padding: 3px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.health-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; margin-top: 2px; }
.health-item { display: flex; align-items: center; gap: 6px; font-size: 11.8px; color: var(--muted); background: #f8fafc; border-radius: 8px; padding: 5px 8px; }
.health-item i { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 6px; }
.health-item b { margin-left: auto; color: var(--ink); font-size: 13px; font-variant-numeric: tabular-nums; }
.health-foot { margin-top: 9px; font-size: 11.5px; color: var(--muted-2); }
.health-foot b { color: var(--ink-2); }
.kpi-num { font-variant-numeric: tabular-nums; }
.kpi { transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
.kpi:hover { transform: translateY(-2px); border-color: #dbe5ef; box-shadow: 0 14px 30px -24px rgba(15, 23, 42, .55); }
.card { transition: box-shadow .22s ease, border-color .22s ease; }
.card:hover { box-shadow: 0 14px 34px -28px rgba(15, 23, 42, .45); }

/* 动效 ------------------------------------------------------ */
@keyframes cardIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.view.anim .kpi, .view.anim .card {
  animation: cardIn .55s cubic-bezier(.2, .8, .3, 1) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.view.enter { animation: viewIn .26s ease both; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.06); } 100% { transform: scale(1); } }
.kpi-num.bump { display: inline-block; animation: bump .45s ease; }

@media (max-width: 1240px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 980px) {
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .echart { height: 240px; }
  .echart.tall { height: 258px; }
}
@media (max-width: 640px) {
  .echart { height: 220px; }
  .echart.tall { height: 248px; }
  .echart.gauge { height: 148px; }
  .echart.heat { height: 248px; }
  .grid-3 { gap: 10px; margin-top: 10px; }
  .chart-toolbar { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .view.anim .kpi, .view.anim .card { animation: none; }
}

/* orders */
.badge.ok { background: #f0fdf4; color: #15803d; }
.badge.void { background: #f1f5f9; color: #94a3b8; }
.order-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 18px; font-size: 12.8px; }
.order-meta > div { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.order-meta > div span { color: #94a3b8; font-size: 11.5px; flex: 0 0 52px; }
.order-meta > div.wide { grid-column: 1 / -1; }
.list-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; }
.list-foot span { font-size: 12.3px; color: #94a3b8; }
tr.clickable { cursor: pointer; }
.orders-table td:first-child { font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .orders-table th:nth-child(3), .orders-table td:nth-child(3),
  .orders-table th:nth-child(5), .orders-table td:nth-child(5) { display: none; }
  .orders-table td:nth-child(1) { font-size: 11px; }
  .order-meta { grid-template-columns: 1fr; }
}

/* BOM */
.bom-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.bom-toolbar { display: flex; gap: 8px; align-items: center; }
.bom-table td { font-size: 12.6px; }
.bom-table th { font-size: 11.4px; }
@media (max-width: 640px) {
  .bom-head { gap: 6px; }
  .bom-head > div:last-child { width: 100%; }
  .bom-toolbar { flex-direction: column; align-items: stretch; }
}

/* ============================================================
   登录 / 账号
   ============================================================ */
body:not(.authed) .app,
body:not(.authed) .tabbar { display: none; }
body.authed .login-page { display: none; }

.login-page {
  position: fixed; inset: 0; z-index: 900;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background:
    radial-gradient(900px 520px at 12% 8%, rgba(13,148,136,.16), transparent 62%),
    radial-gradient(760px 460px at 92% 92%, rgba(79,70,229,.14), transparent 60%),
    #f4f8fb;
}
.login-card {
  width: 100%; max-width: 372px;
  background: #fff; border-radius: 22px;
  padding: 32px 28px 22px;
  box-shadow: 0 24px 60px rgba(15,23,42,.12), 0 2px 8px rgba(15,23,42,.04);
  text-align: center;
}
.login-logo { width: 74px; height: 74px; border-radius: 19px; box-shadow: 0 8px 18px rgba(13,148,136,.22); }
.login-card h1 { margin: 14px 0 5px; font-size: 22px; letter-spacing: -.4px; color: #0f172a; }
.login-sub { margin: 0 0 22px; font-size: 12.3px; color: #64748b; letter-spacing: .2px; }
.login-field { display: block; text-align: left; margin-bottom: 13px; }
.login-field span { display: block; font-size: 12px; color: #64748b; margin-bottom: 6px; }
.login-field input {
  width: 100%; height: 44px; border: 1px solid #dbe3ec; border-radius: 11px;
  padding: 0 13px; font-size: 14px; color: #0f172a; background: #f8fafc; outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.login-field input:focus { border-color: #0d9488; background: #fff; box-shadow: 0 0 0 3px rgba(13,148,136,.12); }
.login-submit { height: 44px; margin-top: 4px; }
.login-err { min-height: 18px; margin-top: 10px; font-size: 12.3px; color: #dc2626; }
.login-foot { margin-top: 16px; font-size: 11.5px; color: #94a3b8; line-height: 1.7; }

/* 顶栏用户 */
.user-chip {
  position: relative; display: flex; align-items: center; gap: 8px;
  padding: 5px 9px 5px 5px; margin-left: 2px;
  border: 1px solid #e3eaf2; border-radius: 999px; background: #fff;
  cursor: pointer; user-select: none;
}
.user-chip:hover { border-color: #cbd5e1; background: #f8fafc; }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #14b8a6, #0d9488);
  color: #fff; font-size: 12px; font-weight: 700;
}
.user-chip-name { font-size: 12.5px; color: #334155; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chev { width: 14px; height: 14px; color: #94a3b8; }
.user-menu {
  position: absolute; right: 0; top: calc(100% + 9px); z-index: 120;
  width: 182px; padding: 6px;
  background: #fff; border: 1px solid #e6edf5; border-radius: 13px;
  box-shadow: 0 16px 38px rgba(15,23,42,.14);
}
.user-menu button {
  display: block; width: 100%; padding: 9px 10px;
  border: 0; border-radius: 8px; background: none;
  text-align: left; font-size: 12.8px; color: #334155; cursor: pointer;
}
.user-menu button:hover { background: #f1f5f9; }
.user-menu button.danger { color: #dc2626; }
.user-menu-head { padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid #eef2f7; }
.user-menu-head b { display: block; font-size: 13px; color: #0f172a; }
.user-menu-head span { font-size: 11.5px; color: #94a3b8; }

.users-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.users-toolbar .note { font-size: 12px; color: #64748b; line-height: 1.7; }
.users-table td .who { display: flex; align-items: center; gap: 9px; }
.users-table td .who .user-avatar { width: 30px; height: 30px; font-size: 12px; }
.pwd-card { max-width: 430px; padding: 24px; }
.pwd-card h3 { margin: 0 0 4px; font-size: 16px; }
.pwd-card .hint { margin: 0 0 18px; font-size: 12.3px; color: #64748b; }
.pwd-row { margin-bottom: 14px; }
.pwd-row label { display: block; font-size: 12px; color: #64748b; margin-bottom: 6px; }
.pwd-foot { margin-top: 6px; font-size: 11.8px; color: #94a3b8; }

@media (max-width: 720px) {
  .login-card { padding: 26px 20px 18px; border-radius: 18px; }
  .user-chip-name { display: none; }
  .user-menu { right: -6px; }
  .users-table th:nth-child(5), .users-table td:nth-child(5),
  .users-table th:nth-child(6), .users-table td:nth-child(6) { display: none; }
}

/* 只读账号标记 */
.readonly-chip {
  display: inline-flex; align-items: center; height: 28px; padding: 0 10px;
  border-radius: 999px; background: #f1f5f9; color: #475569;
  font-size: 11.5px; font-weight: 650; letter-spacing: .2px; white-space: nowrap;
}

/* 单行登记 */
.entry-hint {
  margin-top: 14px; padding: 10px 13px; border-radius: 10px;
  background: #f8fafc; border: 1px dashed #dbe3ec;
  font-size: 12.5px; color: #64748b; line-height: 1.6;
}
.entry-hint.ok { background: #f0fdfa; border-color: #99f6e4; color: #0f766e; }
.entry-hint.bad { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.entry-hint b { color: #0f172a; }
.entry-remark { margin-top: 14px; }
.entry-remark textarea.input {
  height: auto; min-height: 66px; padding: 10px 13px;
  resize: vertical; line-height: 1.6; font-family: inherit;
}
.entry-card .entry-summary { margin-top: 16px; }

/* 货号选择器 */
.article-picker { position: relative; display: flex; align-items: center; gap: 6px; }
.article-picker .input { flex: 1; min-width: 0; }
.article-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 140;
  max-height: 280px; overflow: auto; padding: 4px;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  box-shadow: 0 16px 36px rgba(15,23,42,.16);
}
.article-item { padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.article-item:hover { background: #f0fdfa; }
.article-item .ai-main { font-size: 13px; font-weight: 600; color: #0f172a; }
.article-item .ai-main span { font-weight: 400; color: #64748b; }
.article-item .ai-sub { margin-top: 2px; font-size: 11.5px; color: #94a3b8; }
.article-empty { padding: 12px; text-align: center; font-size: 12.5px; color: #94a3b8; }

/* 货品二级面板 */
.goods-picker { position: relative; }
.goods-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; height: 40px; padding: 0 12px; cursor: pointer;
  background: #fff; border: 1px solid #dbe3ec; border-radius: 10px;
  font-size: 13.5px; color: #0f172a; text-align: left;
}
.goods-trigger:hover { border-color: #cbd5e1; }
.goods-trigger svg { width: 14px; height: 14px; color: #94a3b8; flex: 0 0 14px; }
.goods-panel {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 160;
  display: flex; max-height: 300px; overflow: hidden;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  box-shadow: 0 18px 40px rgba(15,23,42,.18);
}
.goods-cats {
  flex: 0 0 112px; overflow: auto; padding: 6px;
  background: #f8fafc; border-right: 1px solid #eef2f7;
}
.goods-cat {
  display: block; width: 100%; padding: 8px 9px; margin-bottom: 2px;
  border: 0; border-radius: 8px; background: none; text-align: left;
  font-size: 12.3px; color: #475569; cursor: pointer;
}
.goods-cat:hover { background: #eef2f7; }
.goods-cat.on { background: #0d9488; color: #fff; font-weight: 600; }
.goods-items { flex: 1; overflow: auto; padding: 6px; }
.goods-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 8px 9px; border: 0; border-radius: 8px;
  background: none; text-align: left; font-size: 12.8px; color: #0f172a; cursor: pointer;
}
.goods-item:hover { background: #f0fdfa; }
.goods-item b { font-weight: 600; }
.goods-item span { font-size: 11px; color: #94a3b8; }
@media (max-width: 720px) {
  .goods-panel { max-height: 260px; }
  .goods-cats { flex-basis: 96px; }
}

/* 必填项标红 */
.input.invalid {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .12) !important;
  background: #fff;
}
.goods-cat.add { color: #0d9488; font-weight: 600; }

/* 导入装柜明细 */
.import-pick {
  padding: 18px 16px;
  text-align: center;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
}
.import-pick-title { font-size: 14px; font-weight: 600; color: #0f172a; }
.import-pick-sub { margin: 5px 0 13px; font-size: 12px; color: #94a3b8; }
.import-pick-btn { display: inline-flex; align-items: center; gap: 6px; }
.import-pick-btn svg { width: 15px; height: 15px; }
.import-pick-name {
  margin-top: 10px;
  font-size: 12px;
  color: #64748b;
  word-break: break-all;
}
.import-tip { margin: 10px 0 0; font-size: 12px; color: #64748b; }

/* AI 识别配置 */
.ai-form { display: grid; gap: 10px; margin-top: 10px; }
.ai-form label { display: grid; gap: 5px; font-size: 12.5px; color: #475569; }

#view-moves table.data th,
#view-moves table.data td { text-align: center; }

@media (min-width: 981px) {
  #view-moves table.moves-table { table-layout: fixed; }
  #view-moves .moves-table td { padding-block: 8px; overflow-wrap: anywhere; }
  #view-moves .moves-table th,
  #view-moves .moves-table td { padding-inline: 6px; }
  #view-moves .moves-table th:nth-child(1) { width: 11%; }
  #view-moves .moves-table th:nth-child(2) { width: 7%; }
  #view-moves .moves-table th:nth-child(3) { width: 23%; }
  #view-moves .moves-table th:nth-child(4) { width: 8%; }
  #view-moves .moves-table th:nth-child(5) { width: 10%; }
  #view-moves .moves-table th:nth-child(6) { width: 12%; }
  #view-moves .moves-table th:nth-child(7) { width: 7%; }
  #view-moves .moves-table th:nth-child(8) { width: 11%; }
  #view-moves .moves-table th:nth-child(9) { width: 7%; }
  #view-moves .moves-table th:nth-child(10) { width: 4%; }
}

.container-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 12px; align-items: start; }
.container-card { border: 1px solid var(--line-2); border-radius: 12px; background: #f9fbfd; }
.container-card summary { cursor: pointer; padding: 14px; }
.container-card summary > span { display: block; margin-top: 5px; overflow-wrap: anywhere; }
.container-card-totals { font-size: 13px; }
.container-card-lines { padding: 0 14px 14px; }
.container-card-lines > div { padding-top: 10px; border-top: 1px solid var(--line-2); }
.container-card-person { color: #0f766e; margin: 5px 0; }
.container-card-line { width: 100%; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 6px 0; font: inherit; text-align: left; border: 0; background: transparent; color: inherit; cursor: pointer; }
.container-card-line:hover span { text-decoration: underline; }
.container-card-line b { white-space: nowrap; }
.import-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 8px; align-items: end; }
.import-fields label { display: grid; gap: 4px; }
.import-preview input { min-width: 90px; padding: 5px; }

/* Keep the import preview on the modal's scroll surface. */
#modalMask .modal:has(#ciPreview) {
  width: min(1160px, 100%);
}
.modal:has(#ciPreview) .modal-body {
  container-type: inline-size;
  padding: clamp(14px, 2vw, 28px);
}
#ciFields { margin-block: 16px; }
#ciFields .import-tip { margin: 0 0 12px; }
.import-fields {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
  gap: 12px 16px;
}
.import-fields label { min-width: 0; gap: 6px; }
.import-fields .input, .import-fields .select { width: 100%; min-width: 0; }
#ciPreview .table-wrap { overflow: visible; }
#ciPreview .import-preview th,
#ciPreview .import-preview td { padding: 9px 7px; }
#ciPreview .import-preview input { width: 100%; min-width: 0; }
#ciPreview .import-preview td:nth-child(6) { min-width: 125px; overflow-wrap: anywhere; }
#ciPreview .import-preview td:nth-child(n+7) { text-align: center; }

@container import-preview (max-width: 739px) {
  #ciPreview .import-preview,
  #ciPreview .import-preview tbody { display: block; }
  #ciPreview .import-preview thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  #ciPreview .import-preview tr {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 120px), 1fr));
    gap: 10px 12px;
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--line-2);
    border-radius: 10px;
  }
  #ciPreview .import-preview td {
    min-width: 0;
    padding: 0;
    border: 0;
    text-align: left;
    overflow-wrap: anywhere;
  }
  #ciPreview .import-preview td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    color: var(--muted);
  }
}

.import-review { display: grid; gap: 16px; align-items: start; }
#ciPreview { container: import-preview / inline-size; min-width: 0; }
#ciPreview:empty { display: none; }
#ciPreview tr[hidden] { display: none; }
.import-assistant { grid-row: 1; min-width: 0; padding: 14px; border: 1px solid var(--line-2); border-radius: 12px; background: #f9fbfd; }
.import-assistant summary { cursor: pointer; font-weight: 650; }
.import-assistant p { margin: 10px 0; }
.import-assistant-actions { display: flex; flex-wrap: wrap; gap: 8px; }
#ciCommand { display: grid; gap: 10px; margin: 16px 0 12px; }
#ciCommand label { font-size: 14px; line-height: 1.5; }
#modalMask #ciCommand #ciQuestion {
  width: 100%;
  min-width: 0;
  min-height: 114px;
  padding: 11px 13px;
  resize: vertical;
  font-size: 14px;
  line-height: 1.8;
}
#modalMask #ciCommand #ciQuestion::placeholder { color: var(--muted); opacity: 1; }
#ciAssistantReply { overflow-wrap: anywhere; white-space: pre-line; }
#ciApplySuggestion { margin-top: 10px; }
@container (min-width: 1000px) {
  .import-review { grid-template-columns: minmax(0, 1fr) clamp(290px, 26%, 350px); }
  .import-assistant { grid-column: 2; }
}


.import-preview-panel { min-width: 0; }
.import-selection { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 10px; }
.import-selection label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.modal:has(#ciPreview) input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: #0d9488; cursor: pointer; vertical-align: middle; }
#ciPreview .import-check { width: 48px; text-align: center; }
#ciPreview .import-check input { padding: 0; }
.modal:has(#ciPreview) :is(.input, .select, .btn, .import-tip, .import-pick-name, .import-assistant, .import-selection, .import-fields, .import-preview, .import-preview th, #ciInfo, #ciErrors) { font-size: 13px; line-height: 1.5; }
@container import-preview (max-width: 739px) {
  #ciPreview .import-check { width: auto; text-align: left; }
  #ciPreview .import-preview td:nth-child(n+7) { text-align: left; }
  #ciPreview .import-preview td::before { font-size: 13px; }
}

#ciPreview .import-preview tbody tr:hover td { background: transparent; }
#ciPreview .import-preview td { font-variant-numeric: tabular-nums; }
#ciPreview .import-preview :is(.input, .import-qty-value) {
  height: 34px;
  border-radius: 8px;
}
#ciPreview .import-qty-value {
  display: grid;
  place-items: center;
  background: #f4f7fa;
  border: 1px solid transparent;
}
#ciPreview .import-qty input { text-align: center; }
#ciPreview .import-preview tr:has([data-select-row]:checked) { background: #f0faf7; }
@container import-preview (min-width: 740px) {
  #ciPreview .import-preview { table-layout: fixed; }
  #ciPreview .import-preview th { padding: 9px 5px; }
  #ciPreview .import-preview td { padding: 6px 5px; }
  #ciPreview .import-preview th:nth-child(1) { width: 6%; }
  #ciPreview .import-preview th:nth-child(2) { width: 16%; }
  #ciPreview .import-preview th:nth-child(3) { width: 15%; }
  #ciPreview .import-preview th:nth-child(4) { width: 12%; }
  #ciPreview .import-preview th:nth-child(5) { width: 12%; }
  #ciPreview .import-preview th:nth-child(6) { width: 16%; }
  #ciPreview .import-preview th:nth-child(n+7) { text-align: center; }
}
@container import-preview (max-width: 739px) {
  #ciPreview .import-preview tr { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  #ciPreview .import-preview td { grid-column: span 2; }
  #ciPreview .import-preview td:nth-child(2) { grid-column: span 4; }
  #ciPreview .import-preview td:nth-child(6) { min-width: 0; }
  #ciPreview .import-preview td:nth-child(6) { grid-column: span 6; }
  #ciPreview .import-preview .import-qty { text-align: center; }
}

.import-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-block: 12px; }


/* 表格文字统一居中 */
.data th,
.data td { text-align: center; }
.data .right { text-align: center; }
.data td .row-actions { justify-content: center; }

.data th,
.data td,
.data .right { text-align: center !important; }
