* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif; background: #f3f5f8; color: #1f2937; font-size: 14px; }
.hidden { display: none !important; }
.num { text-align: right; }

.btn-primary { background: #2563eb; color: #fff; border: none; border-radius: 6px; padding: 8px 16px; font-size: 14px; cursor: pointer; }
.btn-primary:hover { background: #1d4ed8; }
.btn-primary.sm { padding: 5px 12px; font-size: 13px; }
.btn-ghost { background: transparent; color: #4b5563; border: 1px solid #d1d5db; border-radius: 6px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.btn-ghost:hover { background: #eef1f5; }
.err-msg { color: #dc2626; font-size: 13px; min-height: 18px; margin-top: 4px; }

/* 登录 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#1e3a8a,#2563eb); }
.login-card { width: 360px; background: #fff; border-radius: 12px; padding: 36px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.login-logo { font-size: 20px; font-weight: 600; color: #1f2937; text-align: center; }
.login-sub { font-size: 13px; color: #6b7280; text-align: center; margin: 8px 0 28px; }
.login-card label { display: block; font-size: 13px; color: #374151; margin: 14px 0 6px; }
.login-card input { width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; }
.login-card .btn-primary { width: 100%; margin-top: 20px; padding: 11px; }

/* 顶栏 */
.topbar { height: 56px; background: #fff; border-bottom: 1px solid #e5e7eb; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; }
.brand { font-size: 16px; font-weight: 600; color: #111827; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.sync-badge { font-size: 12px; padding: 4px 10px; border-radius: 20px; background: #eef1f5; color: #6b7280; }
.sync-badge.ok { background: #dcfce7; color: #166534; }
.sync-badge.error { background: #fee2e2; color: #991b1b; }
.user-chip { font-size: 13px; color: #374151; font-weight: 500; }

.toolbar { display: flex; align-items: center; gap: 12px; padding: 14px 20px; }
.search { flex: 1; max-width: 380px; padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; }
.stat-chip { font-size: 13px; color: #6b7280; margin-left: auto; }

/* 表格 */
.table-wrap { background: #fff; margin: 0 20px 20px; border-radius: 10px; border: 1px solid #e5e7eb; overflow: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { background: #f9fafb; color: #6b7280; font-weight: 500; font-size: 12px; text-align: left; padding: 11px 14px; border-bottom: 1px solid #e5e7eb; position: sticky; top: 0; }
td { padding: 10px 14px; border-bottom: 1px solid #f0f1f3; font-size: 13px; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f8fafc; }
td.remaining-pos { color: #059669; font-weight: 600; }
td.remaining-zero { color: #9ca3af; }
td.remaining-over { color: #dc2626; font-weight: 600; }
.bill-no { color: #2563eb; font-weight: 500; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; background: #eef1f5; color: #4b5563; }
.empty-tip { padding: 40px; text-align: center; color: #9ca3af; }

/* 抽屉 */
.drawer-mask, .modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; width: 560px; max-width: 100vw; height: 100vh; background: #fff; z-index: 50; box-shadow: -8px 0 30px rgba(0,0,0,.15); display: flex; flex-direction: column; overflow: hidden; }
.drawer-head { padding: 18px 22px; border-bottom: 1px solid #e5e7eb; display: flex; justify-content: space-between; align-items: flex-start; }
.drawer-title { font-size: 17px; font-weight: 600; }
.drawer-meta { font-size: 12px; color: #6b7280; margin-top: 6px; line-height: 1.6; }
.icon-btn { background: none; border: none; font-size: 24px; color: #9ca3af; cursor: pointer; line-height: 1; }
.drawer-summary { display: flex; padding: 16px 22px; background: #f9fafb; border-bottom: 1px solid #e5e7eb; }
.sum-item { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.sum-item span { font-size: 12px; color: #6b7280; }
.sum-item b { font-size: 18px; }
.sum-item.highlight b { color: #059669; }
.over-warn { background: #fee2e2; color: #991b1b; padding: 10px 22px; font-size: 13px; }
.alloc-head { padding: 16px 22px 10px; display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.alloc-list { flex: 1; overflow: auto; padding: 0 22px; }
.alloc-item { border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; }
.alloc-line { display: flex; justify-content: space-between; align-items: center; }
.alloc-customer { font-weight: 600; }
.alloc-qty { color: #2563eb; font-weight: 600; }
.alloc-detail { font-size: 12px; color: #6b7280; margin-top: 6px; }
.alloc-actions { display: flex; gap: 6px; margin-top: 8px; }
.mini-btn { font-size: 12px; padding: 3px 10px; border: 1px solid #d1d5db; background: #fff; border-radius: 4px; cursor: pointer; color: #4b5563; }
.mini-btn.danger { color: #dc2626; border-color: #fecaca; }
.log-head { padding: 14px 22px 8px; font-weight: 600; border-top: 1px solid #e5e7eb; }
.log-list { max-height: 160px; overflow: auto; padding: 0 22px 16px; }
.log-item { font-size: 12px; color: #6b7280; padding: 4px 0; }

/* 弹窗 */
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); width: 440px; max-width: 92vw; background: #fff; border-radius: 12px; padding: 24px; z-index: 60; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.modal label { display: block; font-size: 13px; color: #374151; margin: 12px 0 5px; }
.modal input, .modal textarea { width: 100%; padding: 9px 11px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; font-family: inherit; }
.form-row { display: flex; gap: 12px; }
.form-row > div { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.user-list { max-height: 240px; overflow: auto; }
.user-item { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f0f1f3; font-size: 13px; }
.admin-add { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.admin-add input { width: auto; flex: 1; min-width: 90px; padding: 7px 9px; border: 1px solid #d1d5db; border-radius: 6px; }
