:root {
  --navy: #102a43;
  --navy-2: #173f5f;
  --teal: #078f87;
  --teal-dark: #087b75;
  --teal-soft: #e6f6f4;
  --orange: #e98734;
  --orange-soft: #fff2e5;
  --red: #d64d4d;
  --red-soft: #fff0f0;
  --green: #2f9b6d;
  --green-soft: #eaf8f0;
  --blue: #3f7dc0;
  --blue-soft: #eaf2fb;
  --bg: #f4f7f8;
  --card: #ffffff;
  --text: #243b53;
  --muted: #829ab1;
  --line: #e4edf1;
  --shadow: 0 8px 24px rgba(22, 51, 72, 0.06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: flex; }
.sidebar {
  width: 236px;
  color: #d9e7ee;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
}
.brand { height: 106px; display: grid; place-items: center; padding: 6px 12px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-logo { display: block; width: 100%; max-width: 204px; height: auto; object-fit: contain; }
.main-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-item { width: 100%; height: 42px; display: flex; align-items: center; gap: 12px; padding: 0 13px; border: 0; border-radius: 8px; background: transparent; color: #bfd1da; text-align: left; transition: .2s; }
.nav-item:hover { background: rgba(255,255,255,.06); color: white; }
.nav-item.active { background: var(--teal); color: white; box-shadow: 0 7px 18px rgba(0,0,0,.14); }
.nav-item i { width: 20px; color: inherit; font-size: 17px; font-style: normal; text-align: center; }
.nav-category { height: 52px; margin-top: 7px; }
.nav-category i { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: rgba(255,255,255,.08); font-size: 16px; }
.nav-category.active i { background: rgba(255,255,255,.17); }
.sidebar-footer { padding: 16px 20px 20px; color: #86a6b7; font-size: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.factory-state { margin-bottom: 8px; color: #b9e5d5; }
.pulse { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #55d99a; box-shadow: 0 0 0 4px rgba(85,217,154,.12); }

.main-area { width: calc(100% - 236px); margin-left: 236px; }
.topbar { height: 78px; display: flex; align-items: center; justify-content: space-between; padding: 0 30px; background: white; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; color: var(--navy); font-size: 21px; }
.topbar p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.search-box { width: 245px; height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: 20px; background: #f5f8fa; color: var(--muted); }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 12px; }
.icon-btn { position: relative; width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 18px; }
.icon-btn b { position: absolute; top: -2px; right: -1px; width: 15px; height: 15px; border-radius: 50%; background: var(--red); color: white; font-size: 9px; line-height: 15px; }
.user-profile { display: flex; align-items: center; gap: 9px; padding-left: 16px; border-left: 1px solid var(--line); }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--teal-soft); color: var(--teal-dark); font-weight: 700; }
.user-profile strong, .user-profile span { display: block; }
.user-profile strong { color: var(--navy); font-size: 13px; }
.user-profile span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.logout-btn { min-height: 34px; padding: 0 11px; }
.page-content { padding: 24px 30px 35px; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.metric-card, .panel, .quick-action { background: var(--card); border: 1px solid #edf2f4; border-radius: 12px; box-shadow: var(--shadow); }
.metric-card { min-height: 116px; padding: 18px; }
.metric-head { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
.metric-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; font-size: 17px; }
.metric-icon.teal { background: var(--teal-soft); color: var(--teal); }
.metric-icon.blue { background: var(--blue-soft); color: var(--blue); }
.metric-icon.orange { background: var(--orange-soft); color: var(--orange); }
.metric-icon.green { background: var(--green-soft); color: var(--green); }
.metric-value { margin-top: 7px; color: var(--navy); font-size: 25px; font-weight: 750; }
.metric-value small { margin-left: 3px; color: var(--muted); font-size: 12px; font-weight: 500; }
.metric-foot { margin-top: 5px; color: var(--muted); font-size: 11px; }
.trend-up { color: var(--green); }
.trend-down { color: var(--red); }

.dashboard-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; margin-top: 16px; }
.panel { overflow: hidden; }
.panel-head { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; color: var(--navy); font-size: 15px; }
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.panel-body { padding: 18px; }
.panel-link { border: 0; background: transparent; color: var(--teal); font-size: 12px; }

.chart { display: flex; align-items: flex-end; gap: 12px; height: 180px; padding-top: 10px; }
.chart-col { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; }
.chart-bar-wrap { width: 100%; height: 142px; display: flex; align-items: flex-end; justify-content: center; gap: 5px; border-bottom: 1px solid var(--line); }
.chart-bar { width: 12px; min-height: 6px; border-radius: 4px 4px 0 0; }
.chart-bar.plan { background: #dce8ec; }
.chart-bar.done { background: var(--teal); }
.chart-col span { color: var(--muted); font-size: 11px; }
.chart-legend { display: flex; gap: 16px; margin-top: 12px; color: var(--muted); font-size: 11px; }
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; }

.progress-list { display: grid; gap: 16px; }
.progress-top { display: flex; justify-content: space-between; margin-bottom: 7px; font-size: 12px; }
.progress-top strong { color: var(--navy); }
.progress-top span { color: var(--muted); }
.progress-track { height: 7px; overflow: hidden; border-radius: 8px; background: #edf2f4; }
.progress-track i { display: block; height: 100%; border-radius: inherit; background: var(--teal); }
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 16px; }
.quick-action { display: flex; align-items: center; gap: 12px; padding: 16px; border: 0; text-align: left; transition: .2s; }
.quick-action:hover { transform: translateY(-2px); border-color: #cde8e5; }
.quick-action i { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: var(--teal-soft); color: var(--teal); font-size: 19px; font-style: normal; }
.quick-action strong { display: block; color: var(--navy); font-size: 13px; }
.quick-action span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.module-nav-head { display: flex; align-items: center; gap: 15px; margin-bottom: 20px; padding: 18px 20px; border: 1px solid #dcebea; border-radius: 12px; background: linear-gradient(135deg,#f8fdfc,#eef9f7); }
.module-nav-icon { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 14px; background: var(--teal); color: white; font-size: 25px; box-shadow: 0 8px 18px rgba(7,143,135,.18); }
.module-nav-head h2 { margin: 0; color: var(--navy); font-size: 20px; }
.module-nav-head p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.module-nav-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(245px,1fr)); gap: 14px; }
.module-nav-card { min-height: 138px; display: flex; align-items: flex-start; gap: 13px; padding: 18px; border: 1px solid #e6eef1; border-radius: 11px; background: white; box-shadow: var(--shadow); text-align: left; transition: .2s; }
.module-nav-card:hover { transform: translateY(-3px); border-color: #b9e2df; box-shadow: 0 12px 26px rgba(22,51,72,.1); }
.module-nav-card i { width: 42px; height: 42px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 10px; background: var(--teal-soft); color: var(--teal-dark); font-size: 20px; font-style: normal; }
.module-nav-card strong { display: block; color: var(--navy); font-size: 14px; }
.module-nav-card span { display: block; min-height: 32px; margin-top: 7px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.module-nav-card b { display: block; margin-top: 10px; color: var(--teal); font-size: 11px; font-weight: 650; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 10px; }
.btn { min-height: 38px; padding: 0 15px; border: 1px solid var(--line); border-radius: 7px; background: white; color: var(--text); font-size: 12px; transition: .2s; }
.btn:hover { border-color: #b9d8d5; color: var(--teal-dark); }
.btn.primary { border-color: var(--teal); background: var(--teal); color: white; }
.btn.primary:hover { background: var(--teal-dark); }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn:disabled { cursor: not-allowed; opacity: .55; }
.filter-input, .filter-select { height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; outline: 0; background: white; color: var(--text); font-size: 12px; }
.filter-input { width: 210px; }
.filter-input:focus, .filter-select:focus { border-color: var(--teal); }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { padding: 13px 16px; background: #f8fafb; color: #70889a; font-size: 11px; font-weight: 650; text-align: left; }
td { padding: 14px 16px; border-top: 1px solid var(--line); color: #486581; font-size: 12px; }
td strong { color: var(--navy); }
.table-empty { padding: 45px 20px; color: var(--muted); text-align: center; }
.sku-cell { display: flex; align-items: center; gap: 9px; }
.sku-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; background: var(--teal-soft); color: var(--teal-dark); font-size: 11px; font-weight: 700; }
.sku-mark.product { background: var(--blue-soft); color: var(--blue); }
.badge { display: inline-block; padding: 4px 8px; border-radius: 12px; font-size: 11px; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.orange { background: var(--orange-soft); color: var(--orange); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.gray { background: #edf2f4; color: #718596; }
.stock-bar { width: 82px; height: 6px; display: inline-block; margin-left: 8px; overflow: hidden; border-radius: 4px; background: #edf2f4; vertical-align: middle; }
.stock-bar i { display: block; height: 100%; border-radius: 4px; background: var(--teal); }
.stock-bar.low i { background: var(--red); }
.color-stocks { display: flex; flex-wrap: wrap; gap: 4px; max-width: 270px; margin-top: 7px; }
.color-stock { padding: 3px 6px; border-radius: 10px; background: #f0f5f7; color: #668195; font-size: 10px; }
.color-stocks.muted { color: var(--muted); font-size: 10px; }
.action-link { margin-right: 10px; border: 0; background: transparent; color: var(--teal); font-size: 12px; }
.action-link.danger-link { color: var(--red); }
.doc-link { border: 0; background: transparent; color: var(--teal); font-size: 12px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.user-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--teal-soft); color: var(--teal-dark); font-size: 12px; font-weight: 700; }
.current-user-tag { display: inline-block; margin-left: 5px; padding: 2px 5px; border-radius: 8px; background: var(--blue-soft); color: var(--blue); font-size: 9px; font-weight: 500; }

.split-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.report-kpis { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.report-kpi { padding: 14px; border-radius: 9px; background: #f8fafb; }
.report-kpi span { color: var(--muted); font-size: 11px; }
.report-kpi strong { display: block; margin-top: 8px; color: var(--navy); font-size: 20px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(7, 27, 44, .42); }
.modal { width: min(640px, calc(100vw - 36px)); overflow: hidden; border-radius: 12px; background: white; box-shadow: 0 18px 60px rgba(0,0,0,.18); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; color: var(--navy); font-size: 16px; }
.modal-close { width: 30px; height: 30px; border: 0; border-radius: 50%; background: #f3f6f7; color: var(--muted); }
.modal-body { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; max-height: 64vh; overflow-y: auto; padding: 20px 22px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { display: block; margin-bottom: 7px; color: #607d8b; font-size: 12px; }
.form-field input, .form-field select, .form-field textarea { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 6px; outline: 0; color: var(--text); }
.form-field textarea { min-height: 68px; resize: vertical; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--teal); }
.form-field input[readonly] { background: #f5f8fa; color: var(--muted); cursor: not-allowed; }
.searchable-select { position: relative; min-width: 0; }
.searchable-select > input { width: 100%; }
.searchable-options { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30; display: none; max-height: 220px; overflow-y: auto; padding: 5px; border: 1px solid var(--line); border-radius: 7px; background: white; box-shadow: 0 10px 24px rgba(16,42,67,.15); }
.searchable-options.show { display: grid; }
.searchable-option { padding: 8px 9px; border: 0; border-radius: 5px; background: white; color: var(--text); text-align: left; font-size: 12px; }
.searchable-option:hover { background: var(--teal-soft); color: var(--teal-dark); }
.searchable-empty { padding: 8px 9px; color: var(--muted); font-size: 12px; }
.structure-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 7px; background: #f8fbfb; color: var(--muted); font-size: 12px; }
.structure-summary strong { margin-left: 4px; color: var(--navy); }
.structure-summary .btn { margin-left: auto; }
.structure-backdrop { z-index: 12; }
.structure-modal { width: min(1080px,calc(100vw - 36px)); }
.structure-body { max-height: calc(100vh - 180px); overflow-y: auto; padding: 18px 22px; background: #f8fafb; }
.structure-top { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 14px; }
.structure-top label { color: var(--muted); font-size: 12px; }
.structure-top input, .structure-line input, .structure-line select { width: 100%; min-width: 0; padding: 8px 9px; border: 1px solid var(--line); border-radius: 6px; background: white; color: var(--text); }
.structure-section { margin-bottom: 12px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.structure-section-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.structure-section-head h4 { margin: 0; color: var(--navy); font-size: 13px; }
.structure-lines { padding: 7px 12px; }
.structure-line { display: grid; grid-template-columns: minmax(180px,1fr) 110px 110px 28px; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid #eef2f3; color: var(--muted); font-size: 11px; }
.structure-line:has([data-line-color]) { grid-template-columns: 100px minmax(180px,1fr) 110px 110px 28px; }
.structure-line:last-child { border-bottom: 0; }
.structure-line strong { color: var(--teal-dark); text-align: right; }
.structure-line strong small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; font-weight: 500; }
.structure-empty { padding: 7px 0; color: var(--muted); font-size: 12px; }
.color-structure-list { display: grid; gap: 8px; padding: 10px 12px; }
.color-structure-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: #f8fbfb; }
.color-structure-card strong { display: block; color: var(--navy); font-size: 13px; }
.color-structure-card span { display: block; margin-top: 4px; color: var(--teal-dark); font-size: 11px; }
.color-structure-detail { display: grid; gap: 8px; padding: 10px 12px; color: var(--muted); font-size: 12px; }
.color-structure-detail p { margin: 0; color: var(--teal-dark); }
.color-structure-detail h5 { margin: 0 0 5px; color: var(--navy); font-size: 12px; }
.color-structure-detail ul { margin: 0; padding-left: 18px; line-height: 1.8; }
.color-structure-backdrop { z-index: 14; }
.color-structure-modal { width: min(920px,calc(100vw - 36px)); }
.production-modal { width: min(980px,calc(100vw - 36px)); }
.production-info { padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #f8fbfb; }
.production-info-empty { color: var(--muted); font-size: 12px; }
.production-info-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 9px; margin-bottom: 10px; }
.production-info-grid span { padding: 9px; border-radius: 6px; background: white; color: var(--muted); font-size: 11px; }
.production-info-grid strong { display: block; margin-top: 4px; color: var(--navy); font-size: 13px; }
.production-info-sections { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; }
.production-info-sections section { padding: 9px; border-radius: 6px; background: white; }
.production-info-sections h4 { margin: 0 0 6px; color: var(--navy); font-size: 12px; }
.production-info-sections ul { margin: 0; padding-left: 16px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.production-detail { display: grid; gap: 14px; max-height: calc(100vh - 190px); overflow-y: auto; padding: 18px 22px; background: #f8fafb; }
.production-detail-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.production-detail-grid span { padding: 11px; border: 1px solid var(--line); border-radius: 7px; background: white; color: var(--muted); font-size: 11px; }
.production-detail-grid strong { display: block; margin-top: 5px; color: var(--navy); font-size: 12px; line-height: 1.45; }
.settings-grid { display: grid; grid-template-columns: repeat(2,minmax(260px,1fr)); gap: 14px; }
.settings-card { display: grid; gap: 12px; align-content: start; padding: 18px; }
.settings-card h3 { margin: 0; color: var(--navy); font-size: 16px; }
.settings-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.backup-file-meta { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; margin-bottom: 16px; }
.backup-file-meta span { display: grid; gap: 5px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #f8fbfb; color: var(--muted); font-size: 12px; }
.backup-file-meta strong { color: var(--navy); font-size: 14px; word-break: break-all; }
.danger-zone { border-color: #ffd3d3; background: #fffafa; }
.inner-panel { padding: 14px; }
.receipt-panel-head { align-items: flex-start; padding-top: 12px; padding-bottom: 12px; }
.receipt-worker-picker { display: grid; grid-template-columns: minmax(260px,420px) auto; align-items: start; gap: 8px; }
.receipt-worker-picker input { width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: 6px; outline: 0; color: var(--text); }
.receipt-worker-picker input:focus { border-color: var(--teal); }
.receipt-worker-search { position: relative; }
.receipt-worker-options { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 5px); display: none; max-height: 230px; overflow-y: auto; gap: 5px; padding: 7px; border: 1px solid var(--line); border-radius: 7px; background: #f8fbfb; box-shadow: 0 12px 24px rgba(22,51,72,.14); }
.receipt-worker-options.show { display: grid; }
.receipt-worker-options button { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 9px; border: 1px solid transparent; border-radius: 6px; background: white; color: var(--navy); font-size: 12px; text-align: left; cursor: pointer; }
.receipt-worker-options button:hover { border-color: #b9e2df; color: var(--teal-dark); }
.receipt-worker-options small, .receipt-worker-options span { color: var(--muted); font-size: 11px; }
.receipt-scan-grid { display: grid; grid-template-columns: minmax(360px,1fr) auto repeat(3,minmax(130px,170px)); gap: 10px; align-items: end; }
.receipt-scan-grid label { min-width: 0; color: #607d8b; font-size: 12px; }
.receipt-scan-grid input { width: 100%; height: 38px; margin-top: 7px; padding: 0 11px; border: 1px solid var(--line); border-radius: 6px; outline: 0; color: var(--text); }
.receipt-scan-grid input:focus { border-color: var(--teal); }
.receipt-scan-grid input:disabled { background: #f5f8fa; color: var(--muted); }
.receipt-trace-field { grid-column: 1 / span 1; }
.receipt-trace-add { min-width: 108px; }
.receipt-scan-grid label:nth-of-type(n+2) { grid-row: 2; }
.trace-code-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.trace-code-chip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; border-radius: 999px; background: #edf7f6; color: var(--teal-dark); font-size: 12px; font-weight: 700; }
.trace-code-chip button { border: 0; background: transparent; color: #e15858; font-size: 16px; cursor: pointer; }
.trace-label-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin-top: 14px; }
.trace-label { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.trace-label img { width: 120px; height: 120px; }
.trace-label strong { color: var(--navy); font-size: 12px; letter-spacing: 1px; }
.dispatch-modal { width: min(1120px,calc(100vw - 36px)); }
.dispatch-body { display: grid; gap: 15px; max-height: calc(100vh - 180px); overflow-y: auto; padding: 18px 22px; background: #f8fafb; }
.dispatch-top { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; }
.dispatch-zone, .dispatch-detail-zone { padding: 13px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.dispatch-zone-head, .dispatch-person-head, .dispatch-task-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dispatch-zone-head { margin-bottom: 12px; }
.dispatch-zone-head h4, .dispatch-detail-zone h4 { margin: 0; color: var(--navy); font-size: 14px; }
.dispatch-zone-head p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.dispatch-person { margin-top: 10px; padding: 12px; border: 1px solid #dcebea; border-radius: 8px; background: #f8fbfb; }
.dispatch-person-head > div:first-child { display: grid; grid-template-columns: 100px minmax(220px,360px); align-items: center; gap: 10px; }
.dispatch-person-head > div:last-child { display: flex; gap: 7px; }
.dispatch-person-head strong { color: var(--navy); font-size: 12px; }
.dispatch-tasks { display: grid; gap: 8px; margin-top: 10px; }
.dispatch-task { display: grid; grid-template-columns: repeat(3,minmax(150px,1fr)); gap: 9px; padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: white; }
.dispatch-task-title { grid-column: 1 / -1; padding-bottom: 7px; border-bottom: 1px solid #edf2f3; }
.dispatch-task-title strong { color: var(--teal-dark); font-size: 12px; }
.dispatch-task label { min-width: 0; color: var(--muted); font-size: 11px; }
.dispatch-task input, .dispatch-task select, .dispatch-task textarea { width: 100%; min-width: 0; margin-top: 6px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 6px; background: white; color: var(--text); }
.dispatch-task textarea { min-height: 60px; resize: vertical; }
.dispatch-task label small { display: block; margin-top: 4px; color: var(--teal-dark); }
.dispatch-task .dispatch-wide { grid-column: 1 / -1; }
.dispatch-detail-zone p { color: var(--muted); font-size: 12px; }
.dispatch-detail-person { margin-top: 10px; padding: 11px; border-radius: 7px; background: #f8fbfb; }
.dispatch-detail-person strong { color: var(--navy); font-size: 13px; }
.dispatch-detail-person ol { margin: 7px 0 0; padding-left: 20px; color: var(--muted); font-size: 12px; line-height: 1.8; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 18px; }
.logged-out .app-shell { visibility: hidden; }
.login-screen { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg,#102a43 0%,#173f5f 48%,#087b75 100%); }
.login-card { width: min(420px,100%); padding: 30px; border-radius: 16px; background: white; box-shadow: 0 24px 70px rgba(0,0,0,.28); }
.login-brand { display: flex; align-items: center; gap: 12px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.login-logo { width: 112px; height: 56px; object-fit: contain; border-radius: 9px; background: white; }
.login-brand h1 { margin: 0; color: var(--navy); font-size: 21px; }
.login-brand p, .login-welcome p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.login-welcome { padding: 22px 0 16px; }
.login-welcome h2 { margin: 0; color: var(--navy); font-size: 19px; }
.login-card label { display: block; margin-bottom: 14px; color: #607d8b; font-size: 12px; }
.login-card input { width: 100%; margin-top: 7px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 7px; outline: 0; color: var(--text); }
.login-card input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.login-submit { width: 100%; min-height: 42px; margin-top: 4px; }
.login-hint { margin-top: 15px; padding: 10px; border-radius: 7px; background: #f5f8fa; color: var(--muted); font-size: 11px; text-align: center; }
.login-error { margin-bottom: 14px; padding: 10px 12px; border-radius: 7px; background: var(--red-soft); color: var(--red); font-size: 12px; }
.permission-modal { width: min(920px, calc(100vw - 36px)); }
.permission-modal .modal-head p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.permission-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 22px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.permission-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; max-height: 62vh; overflow-y: auto; padding: 18px 22px; background: #f8fafb; }
.permission-group { padding: 13px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.permission-group h4 { margin: 0 0 9px; color: var(--navy); font-size: 13px; }
.permission-item { display: flex; align-items: flex-start; gap: 7px; padding: 5px 0; color: #55758a; font-size: 11px; line-height: 1.35; }
.permission-item input { accent-color: var(--teal); }
.sales-modal { width: min(980px, calc(100vw - 36px)); max-height: calc(100vh - 36px); overflow-y: auto; }
.preview-modal { width: min(920px, calc(100vw - 36px)); max-height: calc(100vh - 36px); }
.print-preview { margin: 18px 22px; padding: 28px; overflow-y: auto; max-height: calc(100vh - 180px); border: 1px solid #dce4e8; background: white; color: #123; box-shadow: inset 0 0 0 1px #f7f8f9; font-family: Arial,"Microsoft YaHei",sans-serif; }
.print-preview h1 { margin: 0 0 18px; color: #123; font-size: 22px; text-align: center; }
.print-preview p { margin: 6px 0; font-size: 13px; }
.print-preview .meta { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; margin: 18px 0; }
.print-preview table { width: 100%; margin-top: 16px; border-collapse: collapse; white-space: normal; }
.print-preview th, .print-preview td { padding: 9px; border: 1px solid #999; color: #123; font-size: 13px; }
.print-preview th { background: #f3f5f6; }
.print-preview .foot { margin-top: 20px; text-align: right; }
.sales-form-top { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 14px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.customer-shipping { display: flex; flex-wrap: wrap; gap: 18px; padding: 10px 22px; border-bottom: 1px solid var(--line); background: #fbfcfd; color: var(--muted); font-size: 11px; }
.customer-shipping strong { margin-left: 5px; color: var(--navy); font-weight: 650; }
.sales-lines-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 22px 8px; color: var(--navy); }
.sales-columns { display: grid; grid-template-columns: 150px 82px minmax(320px,1fr) 138px 112px; gap: 10px; padding: 0 32px 7px; color: var(--muted); font-size: 10px; }
.sales-lines { display: grid; gap: 8px; max-height: 310px; overflow-y: auto; padding: 0 22px 14px; }
.sales-line { display: grid; grid-template-columns: 150px 82px minmax(320px,1fr) 138px 112px 28px; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; }
.sales-line select, .sales-line input { width: 100%; min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 5px; background: white; color: var(--text); font-size: 12px; }
.sales-line span { color: var(--muted); font-size: 11px; }
.sales-line strong { color: var(--teal-dark); font-size: 12px; }
.piece-work-columns { grid-template-columns: 96px 220px 92px 104px; }
.piece-work-line { grid-template-columns: 96px 220px 92px 104px 26px; }
.piece-work-line [data-piece-qty] { display: none; }
.piece-work-line .piece-mode-select[style*="hidden"] { pointer-events: none; }
.piece-work-line .line-remove { align-self: start; margin-top: 5px; }
.piece-work-line [data-piece-amount] { align-self: start; margin-top: 8px; }
.sale-colors { display: flex; flex-wrap: wrap; gap: 6px; }
.sale-color { display: flex; align-items: center; gap: 6px; padding: 5px 7px; border-radius: 6px; background: var(--teal-soft); color: var(--teal-dark); font-size: 11px; }
.sale-color span, .detail-color { color: var(--teal-dark); }
.sale-color small, .detail-color small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; }
.sale-color input { width: 68px; padding: 5px 6px; background: white; }
.sale-color .stock-error { display: none; color: var(--red); font-size: 10px; font-style: normal; }
.sale-color.has-error { background: var(--red-soft); }
.sale-color.has-error .stock-error { display: block; }
.sale-color input.input-error { border-color: var(--red); color: var(--red); }
.line-price-input { color: var(--navy) !important; font-weight: 650; }
.line-price, .line-qty { color: var(--navy) !important; font-weight: 650; }
.no-stock { color: var(--red) !important; }
.sale-detail-line { grid-template-columns: 150px 100px minmax(320px,1fr) 155px 120px; }
.detail-color { min-width: 64px; padding: 6px 8px; border-radius: 6px; background: var(--teal-soft); font-size: 11px; }
.sales-form-top strong { display: block; margin-top: 6px; color: var(--navy); font-size: 13px; }
.sales-form-top small { color: var(--muted); font-size: 11px; }
.line-remove { width: 26px; height: 26px; border: 0; border-radius: 50%; background: var(--red-soft); color: var(--red); }
.sales-summary { display: flex; justify-content: flex-end; gap: 24px; padding: 14px 22px; background: #f8fbfb; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.sales-summary strong { display: block; margin-top: 5px; color: var(--navy); font-size: 16px; }
.ledger-metrics { grid-template-columns: repeat(3,1fr); margin-bottom: 16px; }
.ledger-toolbar { justify-content: flex-start; }
.statement-toolbar { justify-content: flex-start; }
.statement-metrics { margin-bottom: 16px; }
.wage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.wage-full { grid-column: 1 / -1; }
.wage-grid .panel-head > div:last-child { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.wage-form-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #f8fbfb; }
.wage-form-grid input, .wage-form-grid select { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; background: white; color: var(--text); }
.wage-slip-page + .wage-slip-page { margin-top: 28px; padding-top: 24px; border-top: 2px dashed #999; }
.warehouse-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(300px,1fr)); gap: 14px; }
.pick-card { padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: white; box-shadow: var(--shadow); }
.pick-card.needs-reprint { border: 2px solid var(--red); background: var(--red-soft); animation: pick-alert 1.2s ease-in-out infinite alternate; }
.pick-card-head, .pick-card-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pick-card-head strong, .pick-card-head span { display: block; }
.pick-card-head strong { color: var(--navy); font-size: 13px; }
.pick-card-head span, .pick-card p { margin-top: 5px; color: var(--muted); font-size: 11px; }
.pick-card h3 { margin: 15px 0 5px; color: var(--navy); font-size: 15px; }
.pick-card-actions { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.pick-card-actions select { min-width: 120px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: white; color: var(--text); font-size: 12px; }
.sales-order-board { display: grid; grid-template-columns: repeat(auto-fill,minmax(300px,1fr)); gap: 14px; }
.sales-order-card { padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: white; box-shadow: var(--shadow); text-align: left; transition: .2s; }
.sales-order-card:hover { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(22,51,72,.12); }
.sales-order-card h3 { margin: 15px 0 7px; color: var(--navy); font-size: 15px; }
.sales-order-card p { margin: 6px 0; color: var(--muted); font-size: 11px; }
.sales-order-card p strong, .sales-order-card p b { color: var(--navy); }
.sales-order-card.due-yellow { border: 2px solid #e7bd42; background: #fffbea; }
.sales-order-card.due-orange { border: 2px solid var(--orange); background: var(--orange-soft); }
.sales-order-card.due-red { border: 2px solid var(--red); background: var(--red-soft); animation: pick-alert 1.2s ease-in-out infinite alternate; }
.order-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 13px; padding-top: 11px; border-top: 1px solid var(--line); color: var(--teal); font-size: 11px; }
.order-card-foot b { color: var(--muted); font-weight: 500; }
.option-master-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap: 16px; }
.option-list { padding: 8px 16px; }
.option-row, .inline-option-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.option-row:last-child, .inline-option-row:last-child { border-bottom: 0; }
.managed-select { display: flex; gap: 7px; }
.managed-select select, .managed-select input { min-width: 0; flex: 1; }
.managed-select .btn { flex: 0 0 auto; }
.option-manager-backdrop { z-index: 12; }
.option-manager-modal { width: min(560px,calc(100vw - 36px)); }
.inline-option-add { display: flex; gap: 8px; margin-bottom: 10px; }
.inline-option-add input, .inline-option-row input { flex: 1; min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; background: white; color: var(--text); }
@keyframes pick-alert { from { box-shadow: 0 0 0 rgba(214,77,77,.1); } to { box-shadow: 0 0 0 4px rgba(214,77,77,.16); } }
.toast-root { position: fixed; right: 24px; bottom: 24px; z-index: 20; display: grid; gap: 10px; }
.toast { min-width: 250px; padding: 13px 16px; border-left: 4px solid var(--green); border-radius: 7px; background: white; box-shadow: 0 10px 32px rgba(16,42,67,.14); color: var(--navy); font-size: 12px; animation: toast-in .2s ease-out; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 1100px) {
  .sidebar { width: 76px; }
  .brand { height: 78px; padding: 5px; }
  .brand-logo { width: 66px; max-width: 100%; height: auto; }
  .brand > div:last-child, .nav-item span, .sidebar-footer { display: none; }
  .nav-item { justify-content: center; }
  .main-area { width: calc(100% - 76px); margin-left: 76px; }
  .metrics { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 760px) {
  .topbar { padding: 0 18px; }
  .search-box, .user-profile > div:last-child { display: none; }
  .logout-btn { padding: 0 8px; font-size: 10px; }
  .page-content { padding: 18px; }
  .dashboard-grid, .split-grid { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: repeat(2,1fr); }
  .toolbar { align-items: flex-start; flex-direction: column; }
  .sales-form-top { grid-template-columns: 1fr; }
  .sales-line, .sale-detail-line { grid-template-columns: 1fr; }
  .sales-columns { display: none; }
  .sales-summary { flex-direction: column; gap: 8px; }
  .permission-grid { grid-template-columns: 1fr; }
  .option-master-grid { grid-template-columns: 1fr; }
  .structure-top { grid-template-columns: 1fr; }
  .structure-line, .structure-line:has([data-line-color]) { grid-template-columns: 1fr; }
  .production-info-grid, .production-info-sections { grid-template-columns: 1fr; }
  .production-detail-grid { grid-template-columns: 1fr; }
  .dispatch-top, .dispatch-task { grid-template-columns: 1fr; }
  .dispatch-person-head, .dispatch-zone-head { align-items: flex-start; flex-direction: column; }
  .dispatch-person-head > div:first-child { width: 100%; grid-template-columns: 1fr; }
  .dispatch-task .dispatch-wide { grid-column: auto; }
  .wage-grid, .wage-full, .wage-form-grid { grid-template-columns: 1fr; grid-column: auto; }
}
