* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: #f5f7fa; color: #1f2329; font-size: 14px; }
.hidden { display: none !important; }
a { text-decoration: none; color: inherit; }

.btn { display: inline-block; padding: 10px 18px; border: 1px solid #d8dde5; border-radius: 8px; background: #fff; cursor: pointer; font-size: 14px; }
.btn.primary { background: #2b6de8; border-color: #2b6de8; color: #fff; }
.btn.danger { background: #e5484d; border-color: #e5484d; color: #fff; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.ghost { background: transparent; color: #c8d4e8; border-color: #3a4b68; }
.btn.block { display: block; width: 100%; margin-top: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1a2a4a 0%, #2b6de8 100%); }
.login-card { width: 360px; background: #fff; border-radius: 16px; padding: 36px 32px; text-align: center; }
.login-logo { width: 64px; height: 64px; line-height: 64px; background: #2b6de8; color: #fff; font-size: 32px; border-radius: 14px; margin: 0 auto 16px; }
.login-card h1 { font-size: 20px; margin-bottom: 6px; }
.sub { color: #8a919f; font-size: 13px; margin-bottom: 14px; }
.error { color: #e5484d; margin-top: 10px; font-size: 13px; min-height: 18px; }
.login-input { display: block; width: 100%; padding: 11px 14px; margin-top: 12px; border: 1px solid #d8dde5; border-radius: 8px; font-size: 14px; outline: none; }
.login-input:focus { border-color: #2b6de8; }
.uid-box { background: #f2f4f7; border-radius: 8px; padding: 12px; margin: 12px 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.uid-box code { word-break: break-all; font-size: 12px; color: #2b6de8; }

.app { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #1e2a44; color: #c8d4e8; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; border-bottom: 1px solid #2c3a58; }
.side-logo { width: 34px; height: 34px; line-height: 34px; text-align: center; background: #2b6de8; border-radius: 8px; color: #fff; font-weight: 700; }
.side-title { font-weight: 600; color: #fff; font-size: 14px; }
#nav { flex: 1; padding: 10px 0; }
#nav a { display: block; padding: 12px 18px; font-size: 14px; color: #c8d4e8; }
#nav a.active { background: #2b6de8; color: #fff; }
.side-foot { padding: 14px 18px; border-top: 1px solid #2c3a58; }
.me-name { color: #fff; margin-bottom: 8px; font-size: 13px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 56px; line-height: 56px; padding: 0 24px; background: #fff; border-bottom: 1px solid #e5e7eb; font-weight: 600; font-size: 16px; }
.content { padding: 20px 24px; }

.card { background: #fff; border-radius: 10px; padding: 18px; margin-bottom: 16px; }
.card h3 { font-size: 15px; margin-bottom: 12px; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { background: #fff; border-radius: 10px; padding: 16px; }
.stat .num { font-size: 24px; font-weight: 700; color: #2b6de8; }
.stat .label { color: #8a919f; font-size: 12px; margin-top: 4px; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type=text], .toolbar input[type=number], .toolbar select { height: 34px; padding: 0 10px; border: 1px solid #d8dde5; border-radius: 6px; font-size: 13px; }
.toolbar .spacer { flex: 1; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { padding: 6px 14px; border: 1px solid #d8dde5; border-radius: 6px; cursor: pointer; font-size: 13px; background: #fff; }
.chip.active { background: #eaf1ff; border-color: #2b6de8; color: #2b6de8; font-weight: 600; }

table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #f0f1f3; font-size: 13px; }
th { background: #f7f9fc; color: #6b7280; font-weight: 600; white-space: nowrap; }
tr:hover td { background: #fafbfd; }
td .link { color: #2b6de8; cursor: pointer; margin-right: 10px; }
td .link.danger { color: #e5484d; }
/* 卡片里（不在表格里）也要有可点的样子：补货/对账的「选中筛选结果」「清空」在 div 里 */
.link { color: #2b6de8; cursor: pointer; margin-right: 10px; }
.link.danger { color: #e5484d; }
.diff-neg { color: #c0392b; }
.diff-pos { color: #1aa15c; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.tag-blue { background: #eaf1ff; color: #2b6de8; }
.tag-red { background: #fdecec; color: #e5484d; }
.tag-green { background: #e8f7ef; color: #1aa15c; }
.tag-orange { background: #fdf3e5; color: #e8891d; }
.tag-gray { background: #f0f1f3; color: #6b7280; }
.empty { text-align: center; color: #9aa1ac; padding: 40px 0; }
.muted { color: #8a919f; font-size: 12px; }
.ckbox { width: 16px; height: 16px; cursor: pointer; }

.mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { width: 520px; max-width: 92vw; max-height: 86vh; overflow-y: auto; background: #fff; border-radius: 12px; padding: 22px; }
.modal h3 { margin-bottom: 14px; }
.field { margin-bottom: 12px; }
.field label { display: block; color: #6b7280; font-size: 12px; margin-bottom: 5px; }
.field input, .field select { width: 100%; height: 36px; padding: 0 10px; border: 1px solid #d8dde5; border-radius: 6px; font-size: 13px; }
.field textarea { width: 100%; min-height: 190px; padding: 10px; border: 1px solid #d8dde5; border-radius: 6px; font-size: 12px; font-family: ui-monospace, Menlo, Consolas, monospace; line-height: 1.6; resize: vertical; box-sizing: border-box; }
.import-hint { color: #6b7280; font-size: 12px; line-height: 1.75; margin-bottom: 10px; background: #f8fafc; border: 1px solid #eef2f7; border-radius: 6px; padding: 10px; }
.import-hint b { color: #374151; }
.import-sum { font-size: 13px; line-height: 1.8; margin: 4px 0 8px; }
.import-sum .ok { color: #059669; font-weight: 600; }
.import-sum .warn { color: #b45309; font-weight: 600; }
.import-sum .bad { color: #dc2626; font-weight: 600; }
.field .checks { display: flex; flex-wrap: wrap; gap: 8px; max-height: 280px; overflow-y: auto; border: 1px solid #e5e7eb; border-radius: 6px; padding: 10px; }
.check-item { padding: 5px 10px; border: 1px solid #d8dde5; border-radius: 5px; cursor: pointer; font-size: 13px; }
.check-item.on { background: #eaf1ff; border-color: #2b6de8; color: #2b6de8; }
.modal-ops { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

.toast { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.8); color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 200; font-size: 13px; max-width: 80vw; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bar-name { width: 220px; text-align: right; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 18px; background: #f0f1f3; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: #2b6de8; }
.loading { text-align: center; color: #9aa1ac; padding: 40px 0; }

/* 权限配置矩阵 */
.perm-table th, .perm-table td { vertical-align: middle; }
.perm-table tbody tr:hover td { background: #fafbfd; }
.perm-table input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.perm-table input[type="checkbox"]:disabled { cursor: not-allowed; opacity: .55; }

/* 表格行内操作：按钮化，彼此留间距，避免挤在一起点错 */
.row-ops { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.row-ops .op {
  padding: 4px 12px;
  border-radius: 14px;
  background: #f2f4f8;
  color: #2b6de8;
  font-size: 13px;
  line-height: 18px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.row-ops .op:hover { background: #e6ecf7; }
.row-ops .op.warn { background: #fff5e8; color: #c2740a; }
.row-ops .op.ok { background: #eaf7ef; color: #1a7f37; }
.row-ops .op.danger { background: #fdeef0; color: #e5484d; }
.row-ops .op.danger:hover { background: #fbe0e3; }

/* 弹窗里的门店搜索 */
.search-box { position: relative; margin-bottom: 8px; }
.search-box input { width: 100%; box-sizing: border-box; padding: 8px 30px 8px 10px; border: 1px solid #d8dde5; border-radius: 6px; font-size: 13px; }
.search-box .clr { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: #9aa1ad; cursor: pointer; font-size: 13px; }

/* 门店管理：店长列 + 地址列 */
.store-table td.addr { max-width: 240px; color: #4b5563; line-height: 1.55; }
.store-table .mgr-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; line-height: 1.6; }
.store-table .mgr-name { font-weight: 600; color: #1f2937; white-space: nowrap; }
.store-table .mgr-phone { color: #6b7280; font-size: 12px; white-space: nowrap; }

/* 员工列表：负责门店/仓（最多 3 个，多的折成「等 N 个」） */
.scope-cell { max-width: 260px; color: #4b5563; line-height: 1.55; }

/* 库存查询：缺货行置顶后的视觉标记 */
.inv-tip { display: flex; align-items: center; gap: 14px; margin: 12px 0 0; padding: 8px 12px; background: #fdf5f3; border: 1px solid #f7dcd6; border-radius: 6px; font-size: 12px; color: #8a6a62; }
.inv-tip .warn { color: #c0392b; font-weight: 600; }
.inv-tip .low { color: #b26a1f; font-weight: 600; }
tr.row-out td { background: #fdf6f5; }
tr.row-out td:first-child { box-shadow: inset 3px 0 0 #e2574c; }
tr.row-low td { background: #fffbf4; }
tr.row-low td:first-child { box-shadow: inset 3px 0 0 #e8a33d; }
td b.zero { color: #d64545; }
