/* 浅蓝主题 */
:root {
  --bg: #f2f7fc; --panel: #ffffff; --ink: #1f2a37; --muted: #6b7a8c; --line: #e2eaf3;
  --accent: #2b7de9; --accent-soft: #e6f0fd; --accent-ink: #1a5fbf;
  --nav: #e8f2fc; --nav-ink: #4a6380;
  --good: #1f9d55; --good-soft: #e3f6ea; --warn: #c27c0e; --warn-soft: #fdf3dc; --bad: #d83931; --bad-soft: #fde4e3;
  --info: #2b7de9; --info-soft: #e6f0fd;
  --radius: 12px; --shadow: 0 1px 2px rgba(30,70,120,.05), 0 6px 20px rgba(30,70,120,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1722; --panel: #16212f; --ink: #e4ecf5; --muted: #8fa2b8; --line: #243346;
    --accent: #5ea3ff; --accent-soft: #19304d; --accent-ink: #8cc0ff;
    --nav: #121d2a; --nav-ink: #9fb3c9;
    --good: #4ade80; --good-soft: #143022; --warn: #fbbf24; --warn-soft: #33290f; --bad: #f87171; --bad-soft: #3a1a1c;
    --info: #5ea3ff; --info-soft: #19304d;
    --shadow: none; color-scheme: dark;
  }
}

/* 飞书选项颜色（Lighter 浅色 / Standard 中等 / Darker 实色） */
.hue { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px; line-height: 20px; white-space: nowrap; font-weight: 500; }
.hue-Blue      { background: #e1eaff; color: #245bdb; }
.hue-Wathet    { background: #d9f3fd; color: #037eaa; }
.hue-Turquoise { background: #d5f6f2; color: #078372; }
.hue-Green     { background: #d9f5d6; color: #2ea121; }
.hue-Lime      { background: #eef6c6; color: #667901; }
.hue-Yellow    { background: #faf1d1; color: #aa7803; }
.hue-Orange    { background: #feead2; color: #b26206; }
.hue-Red       { background: #fde2e2; color: #d83931; }
.hue-Carmine   { background: #fdddef; color: #c71077; }
.hue-Purple    { background: #ece2fe; color: #7f3bf5; }
.hue-Gray      { background: #eff0f1; color: #646a73; }
.hue-Orange.std { background: #fed4a4; color: #8f4f04; }
.hue-Red.std    { background: #fbbfbc; color: #ac2c25; }
.hue-Red.dark   { background: #d83931; color: #fff; }
@media (prefers-color-scheme: dark) {
  .hue { filter: saturate(.9) brightness(.92); }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

.app { display: grid; grid-template-columns: 200px 1fr; min-height: 100vh; }
.nav { background: var(--nav); border-right: 1px solid var(--line); padding: 22px 12px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 16px; padding: 0 10px 22px; letter-spacing: .01em; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.brand::before { content: ""; width: 22px; height: 22px; border-radius: 7px; background: linear-gradient(135deg, #7cc0ff, #2b7de9); flex: none; }
.brand span { color: var(--accent); }
.nav .brand { flex-wrap: wrap; row-gap: 0; }
.nav .brand span { flex-basis: 100%; padding-left: 28px; font-size: 13px; font-weight: 600; }
.nav a { display: block; padding: 9px 12px; border-radius: 9px; text-decoration: none; color: var(--nav-ink); margin-bottom: 3px; font-weight: 500; }
.nav a.on { background: var(--panel); color: var(--accent-ink); font-weight: 650; box-shadow: var(--shadow); }
.nav a:hover:not(.on) { background: rgba(43,125,233,.08); color: var(--ink); }
.kpi { border-top: 3px solid #9cc8f7; }
th { background: #f6f9fd !important; }
@media (prefers-color-scheme: dark) { th { background: var(--panel) !important; } }
tbody tr.click:hover { background: #f3f8fe !important; }
@media (prefers-color-scheme: dark) { tbody tr.click:hover { background: #1b2838 !important; } }
.nav .foot { position: absolute; bottom: 16px; left: 12px; right: 12px; }
.nav .foot a { padding: 5px 12px; font-size: 13px; }
.who { padding: 8px 12px 6px; font-weight: 600; display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.who span { font-weight: 400; font-size: 12px; color: var(--muted); }
.who { cursor: pointer; border-radius: 8px; }
.who:hover { background: rgba(43,125,233,.08); }
.who .caret { display: inline; font-size: 10px; }
.whomenu { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); margin: 0 4px 6px; padding: 4px; }
.whomenu a { display: block; padding: 6px 10px !important; border-radius: 6px; }
.whomenu a:hover { background: var(--accent-soft); }
input:disabled, select:disabled, textarea:disabled { opacity: .65; cursor: not-allowed; background: var(--bg); }
main { padding: 24px 28px 60px; min-width: 0; }
h1 { font-size: 20px; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0 0 18px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }
input[type=text], input[type=number], input[type=date], input[type=search], input[type=password], select, textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 2px 8px; font-size: 12px; }
.chip { display: inline-flex; gap: 4px; }
.chip button { border: 1px solid var(--line); background: var(--panel); padding: 4px 10px; border-radius: 99px; cursor: pointer; font-size: 13px; }
.chip button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi .v { font-size: 22px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .s { color: var(--muted); font-size: 12px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 10px; font-size: 14px; }
.list { margin: 0; padding: 0; list-style: none; }
.list li { display: flex; gap: 8px; justify-content: space-between; padding: 7px 0; border-top: 1px solid var(--line); cursor: pointer; }
.list li:first-child { border-top: 0; }
.list .r { color: var(--muted); white-space: nowrap; }
.empty { color: var(--muted); padding: 12px 0; }

.tablewrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); max-height: calc(100vh - 190px); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { position: sticky; top: 0; background: var(--panel); font-weight: 600; color: var(--muted); font-size: 12px; z-index: 1; cursor: default; }
th.sort { cursor: pointer; }
th.sort:hover { color: var(--ink); }
td.n, th.n { text-align: right; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--bg); }
td .desc { color: var(--muted); max-width: 260px; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: bottom; }
td select { padding: 2px 6px; }
tbody tr.off td { opacity: .5; }
select.hue { border: 0; padding: 2px 8px; cursor: pointer; appearance: auto; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: var(--bg); color: var(--muted); }
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.info { background: var(--info-soft); color: var(--info); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.good { color: var(--good); } .warn { color: var(--warn); } .bad { color: var(--bad); } .muted { color: var(--muted); }
.bar { width: 70px; height: 6px; background: var(--line); border-radius: 3px; display: inline-block; vertical-align: middle; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--good); }

.drawer-bg { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 10; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--panel); z-index: 11; overflow: auto; padding: 20px 22px 80px; box-shadow: -8px 0 24px rgba(0,0,0,.12); }
.drawer h2 { margin: 0 0 14px; font-size: 18px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.form label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.form label.full { grid-column: 1 / -1; }
.form .hint { font-size: 11px; color: var(--muted); }
.section { margin-top: 20px; }
.section h4 { margin: 0 0 8px; font-size: 13px; }
.breakdown { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-variant-numeric: tabular-nums; }
.breakdown .tot { font-weight: 650; border-top: 1px solid var(--line); padding-top: 4px; }
.rows .row { display: grid; grid-template-columns: 1fr 110px 32px; gap: 6px; margin-bottom: 6px; }
.actions { position: sticky; bottom: -80px; background: var(--panel); padding: 12px 0; margin-top: 20px; display: flex; gap: 8px; border-top: 1px solid var(--line); }

/* 成本核算表 */
.bulkbar { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; }
.bulkbar .warn { color: var(--warn); font-weight: 600; }
.costtable { max-height: calc(100vh - 220px); font-size: 12px; }
.costtable th, .costtable td { padding: 2px 4px; line-height: 1.3; }
.costtable th { font-size: 11px; white-space: normal; vertical-align: bottom; }
.costtable tr.grph th { text-align: center; color: var(--accent-ink); font-weight: 600; padding: 3px 4px; border-bottom: 0; top: 0; }
.costtable thead tr:nth-child(2) th { top: 21px; }
.costtable .gend { border-right: 2px solid var(--line); }
.costtable td .desc { max-width: 110px; }
.costtable .hue { font-size: 11px; padding: 0 6px; line-height: 17px; }
.costtable td.ec input, .costtable td.ec select { padding: 2px 4px; border-color: transparent; background: transparent; text-align: right; border-radius: 5px; font-size: 12px; }
.costtable td.ec input::placeholder { color: var(--muted); opacity: .7; }
.costtable td.ec select { text-align: left; max-width: 108px; font-size: 11px; }
.costtable td.ec input:hover, .costtable td.ec select:hover { border-color: var(--line); background: var(--panel); }
.costtable td.ec input:focus, .costtable td.ec select:focus { background: var(--panel); }
.costtable td.dirty { background: #fff4c2; }
.costtable td.dirty input, .costtable td.dirty select { font-weight: 600; }
@media (prefers-color-scheme: dark) { .costtable td.dirty { background: #4a3d10; } }
.costtable td.cc { background: color-mix(in srgb, var(--nav) 55%, var(--panel)); }
.costtable td.oth { cursor: pointer; color: var(--muted); }
.costtable td.comp { white-space: nowrap; }
.costtable td.comp .cd small { font-size: 10px; font-weight: 600; margin-left: 1px; }
.costtable td.oth small { display: block; font-size: 10px; }
.costtable .stk { position: sticky; left: 0; background: var(--panel); z-index: 1; }
.costtable thead .stk { z-index: 2; background: #f6f9fd; }
.costtable td.ck, .costtable th.ck { width: 28px; text-align: center; }
.costtable input[type=number]::-webkit-inner-spin-button { display: none; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--warn); color: #fff; font-size: 11px; text-align: center; line-height: 18px; }

/* 概览：近期售价变动 */
.pricechg { margin-bottom: 14px; border-left: 3px solid var(--accent); padding: 8px 12px; font-size: 12px; }
.pricechg h3 { font-size: 13px; margin: 0 0 4px; }
.pricechg table { width: auto; min-width: 60%; }
.pricechg table td, .pricechg table th { padding: 2px 10px 2px 0; border-bottom: 0; }
.pricechg th { position: static; background: transparent !important; font-size: 11px; font-weight: 500; }
.pricechg .hue { font-size: 11px; padding: 0 6px; line-height: 16px; }
.pricechg .tag { font-size: 11px; padding: 0 6px; }
.pricechg .up { color: var(--good); font-weight: 600; }
.pricechg .down { color: var(--bad); font-weight: 600; }
.pricechg td .desc { max-width: 160px; }
.pricechg #pcmore { margin-top: 4px; padding: 0 8px; font-size: 11px; }
.pricechg .empty { padding: 2px 0; }

/* 库存：最近订单进度、快捷订货 */
#pbody td .desc { max-width: 170px; }
.lo { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.lo .bar { width: 48px; }
.btn.qo { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.btn.qo:hover { background: var(--accent); color: #fff; }

/* 产品图 */
td.imgcell { padding-top: 4px; padding-bottom: 4px; }
img.thumb { width: 64px; height: 44px; object-fit: cover; border-radius: 6px; display: block; cursor: zoom-in; background: var(--bg); border: 1px solid var(--line); }
.nothumb { display: inline-block; width: 64px; height: 44px; line-height: 44px; text-align: center; font-size: 11px; color: var(--muted); background: var(--bg); border-radius: 6px; border: 1px dashed var(--line); }
.lightbox { position: fixed; inset: 0; background: rgba(10, 20, 35, .78); z-index: 30; display: grid; place-items: center; cursor: zoom-out; padding: 20px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.pimg { margin: -4px 0 16px; }
.pimg img { width: 100%; max-height: 300px; object-fit: contain; background: var(--bg); border-radius: 10px; cursor: zoom-in; display: block; }
.pimg .noimg { height: 120px; display: grid; place-items: center; color: var(--muted); background: var(--bg); border: 1px dashed var(--line); border-radius: 10px; }
.pimgbar { display: flex; gap: 8px; margin-top: 8px; }

/* 订货：阶段 × 优先级 分类格 */
.matrixwrap { overflow-x: auto; margin-bottom: 14px; }
.matrix { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); border-collapse: separate; border-spacing: 0; box-shadow: var(--shadow); width: auto; min-width: 100%; }
.matrix th, .matrix td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 8px 12px; text-align: center; white-space: nowrap; }
.matrix th { position: static; background: var(--nav) !important; font-size: 12px; }
.matrix tr > *:last-child { border-right: 0; }
.matrix tbody tr:last-child > * { border-bottom: 0; }
.matrix td.mc { cursor: pointer; min-width: 92px; transition: background .12s; }
.matrix td.mc:hover { background: var(--accent-soft); }
.matrix td.mc b { display: block; font-size: 18px; line-height: 1.2; }
.matrix td.mc small { color: var(--muted); font-size: 11px; display: block; }
.matrix td.mc .late { color: var(--bad); font-size: 11px; font-style: normal; display: block; }
.matrix td.zero { color: var(--line); }
.matrix td.tot, .matrix tr.sum th { background: color-mix(in srgb, var(--nav) 50%, var(--panel)); }
.matrix td.on { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.matrix th.mc { cursor: pointer; }
.matrix th.mc.on { box-shadow: inset 0 0 0 2px var(--accent); }
.pmatrix td.mc { min-width: 78px; font-variant-numeric: tabular-nums; }
.pmatrix tbody th { text-align: left; color: var(--muted); font-weight: 500; }
.matrix .zero { color: var(--line); }
tbody tr.grp td { background: var(--nav); font-weight: 600; padding-top: 10px; }

/* 看板 */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.col { flex: 0 0 248px; background: var(--nav); border: 1px solid var(--line); border-radius: 14px; padding: 10px 8px 6px; transition: background .15s, outline-color .15s; outline: 2px dashed transparent; outline-offset: -2px; }
.col.auto { background: color-mix(in srgb, var(--nav) 60%, var(--bg)); }
.col.over { outline-color: var(--accent); background: var(--accent-soft); }
.col h4 { margin: 0 4px 8px; font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.col h4 span:first-child { display: flex; align-items: center; gap: 7px; }
.col .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.col .dot.hue-Red { background: #d83931; } .col .dot.hue-Blue { background: #3370ff; } .col .dot.hue-Wathet { background: #14b5f0; }
.col .dot.hue-Turquoise { background: #14c0a8; } .col .dot.hue-Green { background: #34c724; } .col .dot.hue-Yellow { background: #f5c400; }
.col .dot.hue-Orange { background: #ff8800; } .col .dot.hue-Purple { background: #9f6fff; } .col .dot.hue-Gray { background: #8f959e; }
.col .hint { font-size: 11px; color: var(--muted); margin: -4px 4px 8px; }
.col .cards { max-height: calc(100vh - 250px); overflow-y: auto; padding: 0 2px; min-height: 60px; }
.empty-col { color: var(--muted); text-align: center; padding: 14px 0; font-size: 12px; }
.kcard { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: 10px; padding: 9px 10px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: pointer; display: grid; gap: 5px; }
.kcard[draggable=true] { cursor: grab; }
.kcard:hover { border-color: #b9d4f3; }
.kcard.dragging { opacity: .35; }
.kcard.p-高 { border-left-color: #d83931; } .kcard.p-中 { border-left-color: #ff8800; } .kcard.p-低 { border-left-color: #34c724; }
.kcard .kh { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.kcard .kd { color: var(--muted); font-size: 12px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.kcard .km { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.kcard .kprog .bar { flex: 1; width: auto; min-width: 40px; }
.kcard .kprog .pc { font-size: 11px; font-weight: 600; color: var(--accent-ink); min-width: 30px; text-align: right; }
.kcard .kn { font-size: 12px; background: var(--bg); border-radius: 6px; padding: 3px 7px; }
.kcard .kf { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 12px; min-height: 22px; }
.kcard .kf .btn.sm { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }

.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login form { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: min(340px, 100%); display: grid; gap: 12px; box-shadow: var(--shadow); }
.err { color: var(--bad); font-size: 13px; min-height: 18px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 16px; border-radius: 8px; z-index: 20; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .nav { position: sticky; height: auto; display: flex; gap: 4px; overflow-x: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); z-index: 5; }
  .brand { display: none; }
  .nav .foot { position: static; }
  main { padding: 16px 16px 60px; }
  .grid2, .form { grid-template-columns: 1fr; }
  .tablewrap { max-height: none; }
}
