* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #2563eb; --primary-dark: #1d4ed8; --primary-light: #eff6ff;
  --bg: #f1f5f9; --card: #ffffff; --text: #1e293b; --muted: #64748b; --line: #e2e8f0;
  --green: #16a34a; --orange: #ea580c; --red: #dc2626; --purple: #7c3aed;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* 登录 */
.auth-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #3b82f6 100%); padding: 20px; }
.auth-card { background: #fff; width: 100%; max-width: 420px; border-radius: 16px; padding: 36px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.auth-brand h1 { font-size: 22px; font-weight: 600; }
.auth-brand p { font-size: 12px; color: var(--muted); margin-top: 2px; }
.brand-mark { width: 46px; height: 46px; border-radius: 11px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.auth-card .field { margin-bottom: 16px; }
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; }
.code-row .btn { flex-shrink: 0; }
.hint { color: #94a3b8; font-weight: 400; font-size: 11px; }
.btn-block { width: 100%; padding: 11px; font-size: 14px; margin-top: 6px; }
.auth-tip { font-size: 11px; color: #94a3b8; text-align: center; margin-top: 16px; line-height: 1.6; }
.auth-error { color: var(--red); font-size: 12px; min-height: 18px; margin-top: -6px; margin-bottom: 6px; }
.auth-loading { text-align: center; padding: 40px 0; color: var(--muted); }

/* 布局 */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 220px; flex-shrink: 0; background: #0f172a; color: #cbd5e1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px; border-bottom: 1px solid #1e293b; }
.brand-text { display: flex; flex-direction: column; }
.brand-text strong { color: #f8fafc; font-size: 15px; }
.brand-text span { font-size: 11px; color: #64748b; }
.nav { padding: 12px; flex: 1; overflow-y: auto; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 11px 14px; margin-bottom: 4px; border: 0; border-radius: 8px; background: transparent; color: #94a3b8; font-size: 14px; cursor: pointer; text-align: left; }
.nav-item:hover { background: #1e293b; color: #e2e8f0; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-badge { margin-left: auto; background: #ef4444; color: #fff; font-size: 11px; font-weight: 600; min-width: 19px; height: 19px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; }
.form-section-title { font-size: 12px; font-weight: 600; color: var(--primary); margin: 4px 0 10px; padding-left: 8px; border-left: 3px solid var(--primary); }
.sidebar-foot { padding: 16px 20px; border-top: 1px solid #1e293b; font-size: 12px; }
.foot-user { display: flex; align-items: center; gap: 7px; color: #e2e8f0; margin-bottom: 6px; font-size: 13px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; flex-shrink: 0; }
.foot-count { color: #64748b; font-size: 11px; margin-bottom: 10px; }
.logout-btn { width: 100%; padding: 7px; border-radius: 6px; border: 1px solid #334155; background: transparent; color: #94a3b8; cursor: pointer; font-size: 12px; }
.logout-btn:hover { background: #1e293b; color: #f8fafc; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 64px; background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; flex-shrink: 0; }
.topbar-title { font-size: 17px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.save-hint { font-size: 12px; color: var(--muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 600; }
.content { padding: 24px 28px; flex: 1; }
.view { display: none; }
.view.active { display: block; }

/* 通用控件 */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.search-wrap { position: relative; display: flex; align-items: center; }
.search-wrap svg { position: absolute; left: 11px; color: #94a3b8; }
.search-wrap input { padding-left: 34px; width: 250px; }
input, select, textarea { border: 1px solid var(--line); border-radius: 7px; padding: 8px 11px; background: #fff; color: var(--text); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.sel { min-width: 120px; cursor: pointer; }
input[type=date] { min-width: 138px; }
.toolbar-spacer { flex: 1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 7px; border: 1px solid transparent; font-size: 13px; cursor: pointer; white-space: nowrap; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; border-color: var(--line); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #e2e8f0; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.summary-strip { display: flex; align-items: center; gap: 16px; background: var(--primary-light); border: 1px solid #dbeafe; border-radius: 9px; padding: 10px 16px; margin-bottom: 14px; font-size: 13px; color: #1e40af; }
.strip-item b { color: var(--primary-dark); }
.strip-sep { width: 1px; height: 16px; background: #bfdbfe; }
.money { font-variant-numeric: tabular-nums; }
#scopeHint { color: #1e40af; font-size: 12px; font-weight: 500; }

.table-card { background: var(--card); border-radius: 11px; box-shadow: var(--shadow); overflow: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table th { background: #f8fafc; text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid #f1f5f9; font-size: 13px; vertical-align: middle; }
.table tbody tr:hover { background: #f8fafc; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.col-expand { width: 36px; }
.col-ops { width: 130px; text-align: right; }
.expand-btn { width: 22px; height: 22px; border: 0; background: #f1f5f9; border-radius: 5px; cursor: pointer; color: var(--muted); font-size: 12px; }
.customer-cell { font-weight: 500; }
.order-no { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--primary); }
.owner-tag { font-size: 11px; color: var(--muted); background: #f1f5f9; padding: 2px 7px; border-radius: 4px; }
.detail-row td { background: #f8fafc; padding: 0 14px 12px 50px; }
.detail-inner { border-left: 2px solid var(--primary); padding-left: 14px; }
.detail-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.detail-table th { background: transparent; border-bottom: 1px dashed var(--line); padding: 6px 8px; color: var(--muted); font-size: 11px; }
.detail-table td { padding: 6px 8px; border-bottom: 1px dashed #f1f5f9; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 500; }
.badge-待确认 { background: #fef3c7; color: #b45309; }
.badge-生产中 { background: #dbeafe; color: #1d4ed8; }
.badge-已发货 { background: #ede9fe; color: #6d28d9; }
.badge-已完成 { background: #dcfce7; color: #15803d; }
.badge-已取消 { background: #f1f5f9; color: #64748b; }
.badge-admin { background: #fef3c7; color: #b45309; }
.badge-member { background: #f1f5f9; color: #64748b; }
.op-btn { border: 0; background: transparent; color: var(--primary); cursor: pointer; font-size: 12px; padding: 3px 5px; }
.op-btn:hover { text-decoration: underline; }
.op-btn.del { color: var(--red); }
.op-btn.reject-op { color: #d97706; }
.empty-state { text-align: center; padding: 60px 20px; color: #94a3b8; }
.empty-state p { margin-top: 12px; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; font-size: 12px; color: var(--muted); }
.table-scroll { overflow-x: auto; }
.table.compact td, .table.compact th { padding: 9px 14px; }

.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 18px; }
.kpi-card { background: var(--card); border-radius: 11px; box-shadow: var(--shadow); padding: 18px 20px; display: flex; flex-direction: column; }
.kpi-label { font-size: 13px; color: var(--muted); }
.kpi-value { font-size: 26px; font-weight: 600; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 11px; color: #94a3b8; }
.chart-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 18px; }
.panel { background: var(--card); border-radius: 11px; box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; }
.panel-head h3 { font-size: 15px; font-weight: 600; }
.panel-head span { font-size: 11px; color: #94a3b8; }
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.bar-label { width: 62px; flex-shrink: 0; color: var(--muted); text-align: right; }
.bar-track { flex: 1; background: #f1f5f9; border-radius: 5px; height: 22px; position: relative; overflow: hidden; }
.bar-fill { height: 100%; background: #2563eb; border-radius: 5px; min-width: 2px; }
.bar-value { position: absolute; right: 8px; top: 3px; font-size: 11px; color: #1e40af; font-weight: 500; }
.status-chart { display: flex; flex-direction: column; gap: 12px; }
.status-row { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.status-name { width: 62px; color: var(--muted); }
.status-track { flex: 1; height: 20px; background: #f1f5f9; border-radius: 5px; overflow: hidden; }
.status-fill { height: 100%; border-radius: 5px; }
.status-count { width: 30px; text-align: right; font-weight: 600; }

.data-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.data-card { background: var(--card); border-radius: 11px; box-shadow: var(--shadow); padding: 22px; }
.data-icon { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.data-icon.blue { background: #dbeafe; color: var(--primary); }
.data-icon.green { background: #dcfce7; color: var(--green); }
.data-icon.amber { background: #fef3c7; color: #d97706; }
.data-icon.purple { background: #ede9fe; color: var(--purple); }
.data-card h3 { font-size: 15px; margin-bottom: 6px; }
.data-card p { font-size: 12px; color: var(--muted); line-height: 1.6; margin-bottom: 16px; min-height: 38px; }

.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: flex-start; justify-content: center; padding: 30px 16px; z-index: 100; overflow-y: auto; }
.modal { background: var(--card); border-radius: 13px; width: 100%; max-width: 860px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal.small { max-width: 460px; }
.modal.wide { max-width: 1180px; }
.modal-head { padding: 18px 24px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { font-size: 17px; font-weight: 600; }
.modal-close { border: 0; background: transparent; font-size: 22px; color: var(--muted); cursor: pointer; line-height: 1; }
.modal-body { padding: 22px 24px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 16px; margin-bottom: 20px; }
.form-grid.two { grid-template-columns: repeat(2, 1fr); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea { width: 100%; }
.field.full { grid-column: 1 / -1; }
.items-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.items-head h3 { font-size: 14px; font-weight: 600; }
.memory-tip { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; font-size: 12px; line-height: 1.6; padding: 9px 12px; border-radius: 8px; margin-bottom: 16px; }
.items-scroll { overflow-x: auto; }
.items-table { width: 100%; min-width: 1120px; border-collapse: collapse; }
.items-table th { font-size: 11px; color: var(--muted); text-align: left; padding: 6px 4px; font-weight: 500; }
.items-table td { padding: 5px 4px; }
.items-table input { width: 100%; padding: 7px 8px; font-size: 12px; }
.items-table .col-customer { width: 14%; }
.items-table .col-code { width: 13%; }
.items-table .col-brand { width: 10%; }
.items-table .col-pkg { width: 10%; }
.items-table .col-batch { width: 11%; }
.items-table .col-qty { width: 8%; }
.items-table .col-price { width: 10%; }
.items-table .col-amt { width: 11%; text-align: right; padding-right: 8px; font-variant-numeric: tabular-nums; }
.items-table .col-note { width: 17%; }
.items-table .col-del { width: 4%; }
.row-del { border: 0; background: transparent; color: var(--red); cursor: pointer; font-size: 16px; }
.items-total { text-align: right; margin-top: 12px; font-size: 14px; font-weight: 600; color: var(--primary); }
.map-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.map-field { display: flex; flex-direction: column; gap: 4px; }
.map-field label { font-size: 12px; font-weight: 500; }
.preview-box { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 16px; overflow-x: auto; font-size: 11px; }
.preview-box table { border-collapse: collapse; }
.preview-box th, .preview-box td { border: 1px solid var(--line); padding: 4px 8px; white-space: nowrap; }
.toast-root { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1e293b; color: #fff; padding: 11px 18px; border-radius: 8px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: slidein .2s ease; max-width: 360px; }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
@keyframes slidein { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@media (max-width: 900px) {
  .sidebar { width: 64px; }
  .brand-text, .nav-item span, .sidebar-foot { display: none; }
  .nav-item { justify-content: center; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-row, .data-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
}
