* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: #f1f5f9; color: #1e293b; font-size: 14px; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; padding: 7px 10px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; outline: none; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.15); }
label { display: block; font-size: 12px; color: #64748b; margin: 8px 0 4px; }
.btn { display: inline-block; padding: 7px 14px; border: none; border-radius: 6px; background: #2563eb; color: #fff; cursor: pointer; font-size: 13px; }
.btn:hover { background: #1d4ed8; }
.btn.green { background: #16a34a; } .btn.green:hover { background: #15803d; }
.btn.red { background: #dc2626; } .btn.red:hover { background: #b91c1c; }
.btn.gray { background: #64748b; } .btn.gray:hover { background: #475569; }
.btn.warn { background: #d97706; } .btn.warn:hover { background: #b45309; }
.btn.sm { padding: 3px 8px; font-size: 12px; border-radius: 4px; }
.btn.ghost { background: #fff; color: #334155; border: 1px solid #cbd5e1; }
.lnk { font-size: 12px; color: #2563eb; text-decoration: none; align-self: center; }
.lnk:hover { text-decoration: underline; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 登录 */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 60%, #3b82f6 100%); }
.login-card { background: #fff; border-radius: 14px; padding: 40px 36px; width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-card h1 { font-size: 20px; text-align: center; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: #64748b; font-size: 13px; margin-bottom: 20px; }

/* 布局 */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 200px; background: #0f2744; color: #cbd5e1; flex-shrink: 0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.logo { padding: 18px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.logo b { color: #fff; font-size: 16px; display: block; }
.logo span { font-size: 11px; color: #7d95b5; }
.nav { flex: 1; padding: 8px 0; overflow-y: auto; }
.nav a { display: flex; align-items: center; gap: 8px; padding: 10px 18px; color: #cbd5e1; text-decoration: none; font-size: 13.5px; border-left: 3px solid transparent; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(37,99,235,.25); color: #fff; border-left-color: #60a5fa; }
.nav .badge { margin-left: auto; background: #dc2626; color: #fff; font-size: 11px; border-radius: 8px; padding: 0 6px; }
.me { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; }
.main { flex: 1; padding: 20px 24px; min-width: 0; }
.page-title { font-size: 18px; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-title .spacer { flex: 1; }

/* 卡片 */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: #fff; border-radius: 10px; padding: 14px 16px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.card .t { font-size: 12px; color: #64748b; }
.card .v { font-size: 20px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.card .v.up { color: #dc2626; } .card .v.down { color: #16a34a; }
.card .s { font-size: 11px; color: #94a3b8; margin-top: 3px; }
.panel { background: #fff; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.06); padding: 16px; margin-bottom: 16px; }
.panel h3 { font-size: 14px; margin-bottom: 12px; color: #334155; }

/* 表格 */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 8px 10px; background: #f8fafc; color: #64748b; font-weight: 600; white-space: nowrap; border-bottom: 1px solid #e2e8f0; }
td { padding: 8px 10px; border-bottom: 1px solid #f1f5f9; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:hover td { background: #f8fafc; }
td.wrap { white-space: normal; }
.num { text-align: right; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; }
.tag.blue { background: #dbeafe; color: #1d4ed8; }
.tag.green { background: #dcfce7; color: #15803d; }
.tag.red { background: #fee2e2; color: #b91c1c; }
.tag.gray { background: #f1f5f9; color: #64748b; }
.tag.yellow { background: #fef9c3; color: #a16207; }
.muted { color: #94a3b8; font-size: 12px; }

/* 表单区 */
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > div { flex: 1; min-width: 130px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: end; }
.toolbar > div { min-width: 130px; }
.toolbar label { margin-top: 0; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 12px; padding: 22px; width: 480px; max-width: 94vw; max-height: 88vh; overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal h3 { margin-bottom: 14px; font-size: 15px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.alert { padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.alert.err { background: #fee2e2; color: #b91c1c; }
.alert.warn { background: #fef9c3; color: #a16207; }
.alert.ok { background: #dcfce7; color: #15803d; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid #e2e8f0; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { padding: 8px 16px; border: none; background: none; cursor: pointer; font-size: 13.5px; color: #64748b; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tabs button.active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } .sidebar { width: 60px; } .sidebar .logo b, .sidebar .logo span, .sidebar .nav a .txt, .sidebar .me { display: none; } }

/* 总览图表 */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; margin-top: 2px; }
.chart-grid .panel { margin-bottom: 0; display: flex; flex-direction: column; padding: 18px 18px 14px; }
.chart-head { display: flex; align-items: center; gap: 8px; padding-bottom: 10px; border-bottom: 1px solid #f1f5f9; }
.chart-head .ico { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex: none; }
.chart-head h3 { font-size: 14px; margin: 0; }
.chart-head .sub { font-size: 11.5px; color: #94a3b8; }
.chart-head .lnk { margin-left: auto; }
.chart-body { margin-top: 12px; flex: 1; display: flex; flex-direction: column; justify-content: center; }

/* 宽表横向滚动容器：列过多时整体在容器内滚动，操作列不再溢出页面 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* 销售管理表：自适应列宽 + 单元格可换行（窗口过窄时客户/货品/状态/发票/操作自动折成两行，不再出现底部横向拉条） */
.sales-tbl { font-size: 12.5px; table-layout: auto; }
.sales-tbl th, .sales-tbl td { padding: 3px 8px; line-height: 1.3; white-space: normal; word-break: break-word; overflow-wrap: anywhere; }
.sales-tbl .ono { display: inline-block; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.sales-tbl .num { white-space: nowrap; }
.sales-tbl .nowrap { white-space: nowrap; }
/* 销售管理顶部检索框：随工具栏自适应宽度（参考蓝筹销售录入页布局） */
.toolbar .search { flex: 1 1 240px; max-width: 440px; }
.toolbar .search input { width: 100%; }
