* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif; font-size: 14px; color: #222; background: #f5f6f8; }

/* 登录 */
.login-mask { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #eef1f5; min-height: 100vh; }
.login-box { width: 360px; background: #fff; border: 1px solid #e0e3e8; border-radius: 12px; padding: 32px; }
.login-box h1 { margin: 0 0 6px; font-size: 20px; }
.login-box .sub { margin: 0 0 24px; color: #888; font-size: 13px; }
.login-box label { display: block; margin-bottom: 16px; font-size: 13px; color: #555; }
.login-box input { display: block; width: 100%; margin-top: 6px; padding: 9px 10px; border: 1px solid #d5d9e0; border-radius: 6px; font-size: 14px; }
.login-box button { width: 100%; padding: 10px; background: #2563eb; color: #fff; border: 0; border-radius: 6px; font-size: 14px; cursor: pointer; }
.login-box .err { color: #dc2626; font-size: 12px; min-height: 18px; }

/* 顶部 */
header { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; background: #fff; border-bottom: 1px solid #e0e3e8; padding: 12px 18px; position: sticky; top: 0; z-index: 20; }
.brand { font-size: 17px; font-weight: 600; white-space: nowrap; }
.stats { color: #888; font-size: 12px; white-space: nowrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
button, input[type="search"] { padding: 7px 11px; font-size: 13px; border: 1px solid #d5d9e0; border-radius: 6px; background: #fff; cursor: pointer; }
button:hover { background: #f0f3f8; }
button.primary { background: #2563eb; color: #fff; border-color: #2563eb; }
button.primary:hover { background: #1d4ed8; }
button.danger { color: #dc2626; }
input[type="search"] { width: 190px; cursor: text; }

.tip-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 18px; font-size: 12px; color: #888; background: #fff; border-bottom: 1px solid #eceef1; }
.tip-right { display: flex; align-items: center; gap: 8px; }
button.mini { padding: 3px 8px; font-size: 11px; line-height: 1.4; border: 1px solid #d5d9e0; border-radius: 5px; background: #fff; color: #555; cursor: pointer; }
button.mini:hover { background: #eef4ff; color: #2563eb; border-color: #93b4f7; }
.chk { display: flex; align-items: center; gap: 5px; cursor: pointer; white-space: nowrap; }

/* 顶部横向滚动条（与表格底部同步，避免滚到底部才能横拖） */
/* 左右不留 padding：让顶部滚动条与表格可视区严格等宽，滚动位置 1:1 对应 */
.top-scroll-wrap { margin: 10px 18px 0; background: #fafbfc; border: 1px solid #e0e3e8; border-bottom: 0; border-radius: 8px 8px 0 0; padding: 3px 0; }
.top-scroll { overflow-x: auto; overflow-y: hidden; height: 16px; }
.top-scroll::-webkit-scrollbar { height: 12px; }
.top-scroll::-webkit-scrollbar-track { background: #eef0f3; border-radius: 6px; }
.top-scroll::-webkit-scrollbar-thumb { background: #b8c0cc; border-radius: 6px; }
.top-scroll::-webkit-scrollbar-thumb:hover { background: #9aa5b4; }
#topScrollFiller { height: 2px; }
#matrixTable { border-radius: 0 0 8px 8px; margin-top: 0 !important; }

/* 表格 */
#matrixTable { height: calc(100vh - 140px); margin: 12px 18px; background: #fff; border: 1px solid #e0e3e8; border-radius: 8px; overflow: hidden; }
.tabulator { font-size: 13px; border: 0; }
.tabulator .tabulator-header { background: #f8fafc; }
.tabulator .tabulator-header .tabulator-col { background: #f8fafc; border-right: 1px solid #e8eaee; }
.tabulator .tabulator-header .tabulator-col-title { font-weight: 600; }
.tabulator .tabulator-header .tabulator-col[field^="sup_"] { cursor: pointer; }
.tabulator .tabulator-header .tabulator-col[field^="sup_"]:hover .tabulator-col-title { color: #2563eb; }
.tabulator .tabulator-row { border-bottom: 1px solid #f0f1f3; }
.tabulator .tabulator-cell { border-right: 1px solid #f0f1f3; }
.tabulator-row-even { background: #fff; }
.tabulator-row-odd { background: #fcfcfd; }
.tabulator .tabulator-row:hover { background: #f5f9ff; }

.cell-price { cursor: text; min-height: 100%; display: flex; flex-direction: column; justify-content: center; padding: 0 8px; line-height: 1.35; }
.cell-price .v { font-variant-numeric: tabular-nums; }
.cell-price .prev { font-size: 11px; color: #dc2626; }
.cell-price.empty { color: #bbb; }
.style-img { width: 64px; height: 64px; object-fit: contain; border-radius: 4px; background: #fafafa; cursor: zoom-in; border: 1px solid #eee; }
.style-img:hover { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.15); }
.style-noimg { color: #ccc; font-size: 12px; text-align: center; }
.style-name-lg { color: #1f2937; font-weight: 600; font-size: 13px; cursor: pointer; display: inline-block; padding: 2px 4px; border-radius: 4px; }
.style-name-lg:hover { background: #eef4ff; color: #2563eb; }
.style-name-none { color: #bbb; font-size: 12px; cursor: pointer; display: inline-block; padding: 2px 4px; border-radius: 4px; }
.style-name-none:hover { background: #f0f3f8; color: #666; }
.supplier-off { opacity: .45; }

/* 图片放大层 */
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(15,18,24,.9); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.lightbox img { max-width: 92vw; max-height: 86vh; object-fit: contain; border-radius: 6px; background: #fff; cursor: zoom-out; box-shadow: 0 8px 40px rgba(0,0,0,.5); }
.lb-cap { color: #e5e7eb; font-size: 14px; }
.lb-close { position: absolute; top: 18px; right: 24px; background: none; border: 0; color: #fff; font-size: 34px; line-height: 1; cursor: pointer; padding: 4px 10px; }
.lb-close:hover { background: rgba(255,255,255,.12); border-radius: 6px; }
.badge-off { display: inline-block; font-size: 10px; color: #999; border: 1px solid #ddd; border-radius: 3px; padding: 0 3px; margin-left: 4px; }

footer { padding: 0 18px 16px; font-size: 12px; color: #999; }

.global-err { margin: 10px 18px 0; padding: 10px 12px; background: #fef2f2; border: 1px solid #fecaca; border-radius: 6px; color: #b91c1c; font-size: 13px; }
.flash { position: fixed; top: 18px; right: 18px; z-index: 100; padding: 10px 16px; border-radius: 8px; font-size: 13px; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.flash-ok { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.flash-err { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }

/* 模态框 */
.modal-mask { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.4); z-index: 50; }
.modal-box { width: 480px; max-width: 92vw; max-height: 88vh; display: flex; flex-direction: column; background: #fff; border-radius: 10px; overflow: hidden; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid #e8eaee; font-size: 15px; font-weight: 600; }
.modal-head button { border: 0; background: none; font-size: 22px; line-height: 1; padding: 0 4px; color: #888; }
.modal-body { padding: 18px; overflow: auto; font-size: 13px; }
.modal-body label { display: block; margin-bottom: 14px; }
.modal-body input[type=text], .modal-body input[type=file], .modal-body textarea { display: block; width: 100%; margin-top: 6px; padding: 8px 10px; border: 1px solid #d5d9e0; border-radius: 6px; font-size: 13px; }
.modal-body textarea { min-height: 120px; font-family: inherit; }
.modal-body .hint { color: #999; font-size: 12px; margin-top: 6px; line-height: 1.6; }
.modal-body .err { color: #dc2626; font-size: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid #e8eaee; }
.modal-foot button { min-width: 74px; }
.preview { background: #f8fafc; border: 1px solid #e8eaee; border-radius: 6px; padding: 10px; max-height: 240px; overflow: auto; font-size: 12px; line-height: 1.8; }
