/* ===== CSS Variables ===== */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #16a34a;
  --warning: #f59e0b;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
}

/* ===== Reset ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: var(--gray-800); background: var(--gray-50); }
a { color: var(--primary); text-decoration: none; }

/* ===== Layout ===== */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: 180px; background: var(--gray-900); color: #fff; padding: 0; flex-shrink: 0; display: flex; flex-direction: column; }
.sidebar-brand { padding: 16px 14px; font-size: 16px; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-nav { flex: 1; padding: 8px 0; }
.sidebar-nav a { display: flex; align-items: center; padding: 10px 14px; color: rgba(255,255,255,0.7); font-size: 13px; transition: all 0.15s; border-left: 3px solid transparent; }
.sidebar-nav a:hover { color: #fff; background: rgba(255,255,255,0.08); }
.sidebar-nav a.active { color: #fff; background: rgba(37,99,235,0.25); border-left-color: var(--primary); font-weight: 500; }
.sidebar-user { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,0.1); font-size: 13px; color: rgba(255,255,255,0.6); }
.sidebar-user .user-name { color: #fff; font-weight: 500; }
.main-content { flex: 1; padding: 20px 24px; overflow-y: auto; }

/* ===== Viewpoint Bar (管理员视角切换) ===== */
.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.viewpoint-bar { padding: 12px 24px 0 24px; display: flex; gap: 12px; flex-wrap: wrap; }
.vp-card-wrap { position: relative; }
.viewpoint-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; border-radius: 10px; cursor: pointer;
  background: #fff; border: 1.5px solid #e8ecf0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: all 0.18s ease; user-select: none;
}
.viewpoint-card:hover { border-color: #b0c4de; box-shadow: 0 2px 8px rgba(0,0,0,0.08); transform: translateY(-1px); }
.viewpoint-card:active { transform: translateY(0); }
.viewpoint-icon { font-size: 20px; }
.viewpoint-title { font-size: 14px; font-weight: 600; color: #333; }
.viewpoint-desc { font-size: 11px; color: #999; }
.viewpoint-arrow { margin-left: 4px; font-size: 12px; color: #bbb; transition: transform 0.2s; }

.viewpoint-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 100;
  background: #fff; border: 1px solid #e8ecf0; border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1); min-width: 220px;
  max-height: 260px; overflow-y: auto;
}

.viewpoint-active { animation: vpSlideIn 0.2s ease; }
@keyframes vpSlideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.viewpoint-exit:hover { filter: brightness(0.9); }

/* ===== Login Page ===== */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%); }
.login-card { background: #fff; border-radius: 12px; padding: 40px; width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-card h1 { font-size: 24px; margin-bottom: 8px; color: var(--gray-900); }
.login-card p { color: var(--gray-500); margin-bottom: 24px; font-size: 14px; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-700); margin-bottom: 4px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--gray-300); border-radius: var(--radius);
  font-size: 14px; transition: border-color 0.15s; outline: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-group textarea { resize: vertical; min-height: 60px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 8px 16px; border-radius: var(--radius); font-size: 14px; font-weight: 500; border: none; cursor: pointer; transition: all 0.15s; gap: 6px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-outline-danger { background: #fff; color: var(--danger); border: 1px solid var(--danger); }
.btn-outline-danger:hover { background: var(--danger); color: #fff; }
.btn-outline { background: #fff; color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-outline:hover { background: var(--gray-50); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-lg { padding: 10px 24px; font-size: 16px; }

/* ===== Tables ===== */
.table-wrapper { overflow-x: auto; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
table { min-width: 100%; border-collapse: collapse; font-size: 14px; table-layout: fixed; }
th { background: var(--gray-50); padding: 10px 12px; text-align: left; font-weight: 600; color: var(--gray-600); font-size: 13px; border-bottom: 1px solid var(--gray-200); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--gray-100); }
tr:hover td { background: var(--gray-50); }

/* ===== Cards ===== */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 16px; font-weight: 600; }

/* ===== Badges ===== */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 500; }
.badge-pending_purchase { background: #fef3c7; color: #92400e; }
.badge-pending_sales { background: #fff7ed; color: #c2410c; }
.badge-pending_admin { background: #dbeafe; color: #1e40af; }
.badge-priced { background: #d1fae5; color: #065f46; }
.badge-price_adjusted { background: #ede9fe; color: #5b21b6; }
.badge-rejected { background: #fee2e2; color: #991b1b; }

.status-label { font-size: 12px; }
.status-pending_purchase { color: #92400e; }
.status-pending_admin { color: #1e40af; }
.status-priced { color: #065f46; }
.status-price_adjusted { color: #5b21b6; }
.status-rejected { color: #991b1b; }

/* ===== Tax Toggle ===== */
.tax-toggle { display: inline-flex; border: 1px solid var(--gray-300); border-radius: var(--radius); overflow: hidden; }
.tax-toggle button { padding: 4px 12px; font-size: 13px; border: none; background: #fff; cursor: pointer; transition: all 0.15s; }
.tax-toggle button.active { background: var(--primary); color: #fff; }

/* ===== Local Tax Switch (form internal) ===== */
.tax-switch { display: inline-flex; border: 1px solid var(--gray-300); border-radius: var(--radius); overflow: hidden; vertical-align: middle; margin-left: 6px; }
.tax-btn { padding: 2px 8px; font-size: 12px; border: none; background: #fff; cursor: pointer; transition: all 0.15s; color: var(--gray-600); }
.tax-btn.active { background: var(--primary); color: #fff; }

/* ===== Supplier Row ===== */
.supplier-row { background: var(--gray-50); border-radius: var(--radius); padding: 8px; }

/* ===== Stat Warning ===== */
.stat-warning { border: 1px solid var(--warning); }
.stat-warning .stat-value { color: var(--warning); }

/* ===== Page Header ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-title { font-size: 20px; font-weight: 700; }

/* ===== Stats ===== */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--gray-900); }
.stat-card .stat-label { font-size: 13px; color: var(--gray-500); margin-top: 4px; }

/* ===== Quick Links (工作台快捷卡片) ===== */
.quick-links { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.quick-link { display: flex; flex-direction: column; align-items: center; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 20px; min-width: 120px; text-decoration: none; transition: all 0.15s; cursor: pointer; border: 2px solid transparent; }
.quick-link:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.ql-value { font-size: 24px; font-weight: 700; color: var(--gray-900); }
.ql-label { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

/* ===== 列可见性 ===== */
.col-hidden { display: none !important; }
.col-settings-overlay {
  position: fixed; inset: 0; z-index: 1100; background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center;
}
.col-settings-popup {
  background: #fff; border-radius: 10px; padding: 20px 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25); min-width: 240px; max-height: 80vh; overflow-y: auto;
}
.col-settings-popup h3 { font-size: 15px; margin-bottom: 12px; }
.col-settings-popup label { display: block; padding: 5px 0; cursor: pointer; font-size: 14px; user-select: none; }
.col-settings-popup label:hover { color: var(--primary); }
.col-settings-popup input[type="checkbox"] { margin-right: 6px; }
.col-settings-popup .form-actions { margin-top: 16px; display: flex; gap: 8px; justify-content: flex-end; }

.resizable-th { user-select: none; }
.col-resizer:hover { background: var(--primary) !important; opacity: 0.5; }

/* ===== Modal ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; overflow: auto; display: flex; align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: 12px; padding: 24px; width: 90%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3); position: relative; }
.modal-wide { max-width: 780px; }
.modal h2 { font-size: 18px; margin-bottom: 16px; cursor: move; user-select: none; display: flex; justify-content: space-between; align-items: center; }
.modal-close-btn { cursor: pointer; font-size: 22px; line-height: 1; color: var(--gray-400); transition: color 0.15s; padding: 0 2px; }
.modal-close-btn:hover { color: var(--gray-700); }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* 操作按钮区域（桌面端和移动端通用） */
.modal-sticky-footer {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ===== Price Info Box ===== */
.price-compare { background: var(--gray-50); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.price-compare h4 { font-size: 14px; color: var(--gray-600); margin-bottom: 8px; }
.price-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.price-row .label { color: var(--gray-500); }
.price-up { color: var(--danger); font-weight: 600; }
.price-down { color: var(--success); font-weight: 600; }

/* ===== Logs ===== */
.log-timeline { border-left: 2px solid var(--gray-200); padding-left: 16px; margin: 12px 0; }
.log-item { position: relative; padding: 8px 0; font-size: 13px; }
.log-item::before { content: ''; position: absolute; left: -21px; top: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--gray-300); }
.log-item .log-time { color: var(--gray-400); font-size: 12px; }
.log-item .log-user { font-weight: 500; }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 40px; color: var(--gray-400); }
.empty-state p { margin-top: 8px; font-size: 14px; }

/* ===== Toast ===== */
.toast { position: fixed; top: 20px; right: 20px; padding: 12px 20px; border-radius: var(--radius); color: #fff; font-size: 14px; z-index: 2000; animation: slideIn 0.3s; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== Date Input ===== */
/* date input 用 text 类型模拟 placeholder，焦点时切回 date */
input[type="text"].date-placeholder {
  color: var(--gray-400);
  cursor: text;
}

/* ===== Nav Badge（类手机APP角标：红色背景+白色数字，紧凑） ===== */
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: #ef4444; color: #fff; font-size: 10px; font-weight: 700; margin-left: 6px; line-height: 18px; flex-shrink: 0; }
.sidebar-nav a { position: relative; }

/* ===== Spreadsheet Table (货期管理表格模式) ===== */
.ssheet { width: 100%; border-collapse: collapse; font-size: 13px; background: #c7edcc; }
.ssheet th { background: #a8d8ad; padding: 10px 6px; text-align: left; font-weight: 600; color: var(--gray-700); font-size: 12px; border: 1px solid var(--gray-200); white-space: nowrap; position: sticky; top: 0; z-index: 5; }
.ssheet td { padding: 0; border: 1px solid var(--gray-200); vertical-align: middle; min-width: 60px; background: #c7edcc; }
.ssheet tr:nth-child(even) td { background: #badfce; }
.ssheet tr:hover td { background: #b5e0ba; }
.ssheet .col-sep { background: #9ecc8a; border-left: 2px solid var(--primary); }
.ssheet .col-sep + th { background: #9ecc8a; }

/* inline cell input */
.ssheet .cell-input {
  width: 100%; padding: 8px 6px; border: none; outline: none; font-size: 13px;
  background: transparent; font-family: inherit;
}
.ssheet .cell-input:focus { background: #eff6ff; box-shadow: inset 0 0 0 2px var(--primary); }
.ssheet .cell-input.cell-selected { background: #dbeafe; box-shadow: inset 0 0 0 2px var(--primary); }
.ssheet .cell-input:read-only { color: var(--gray-800); cursor: default; }
.ssheet .cell-input:read-only:focus { background: transparent; box-shadow: none; }
.ssheet .cell-input[type="date"] { font-size: 12px; }
.ssheet .cell-input[type="number"] { text-align: right; }

/* computed cell (交期区间) */
.ssheet .cell-computed { padding: 8px 6px; font-size: 13px; color: var(--primary); white-space: nowrap; }
.ssheet .cell-readonly { padding: 8px 6px; font-size: 13px; color: var(--gray-600); background: #bce0c1; white-space: nowrap; }

/* status cell */
.ssheet .cell-status { padding: 8px 6px; font-size: 12px; white-space: nowrap; }

/* supplier delivery cell */
.ssheet .supplier-date-cell {
  position: relative; min-width: 120px;
}
.ssheet .supplier-date-cell .split-btn {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; border-radius: 3px; border: 1px solid var(--gray-300);
  background: var(--gray-100); cursor: pointer; font-size: 10px; display: flex;
  align-items: center; justify-content: center; color: var(--gray-500);
}
.ssheet .supplier-date-cell .split-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* update log cell */
.update-log { font-size: 11px; line-height: 1.5; padding: 4px 6px; }
.update-log .delay { color: var(--danger); }
.update-log .early { color: var(--success); }

/* batch popover */
.batch-popover {
  position: absolute; z-index: 100; background: #fff; border: 1px solid var(--gray-300);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); padding: 12px; min-width: 320px;
  font-size: 13px;
}
.batch-popover h4 { font-size: 13px; margin-bottom: 8px; color: var(--gray-700); }
.batch-row-flex { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.batch-row-flex input { padding: 4px 6px; border: 1px solid var(--gray-300); border-radius: 4px; font-size: 12px; }
.batch-row-flex input:focus { border-color: var(--primary); outline: none; }

/* batch inline display (分批交期行内可视) */
.batch-cell { padding: 4px 6px !important; }
.batch-inline { font-size: 12px; line-height: 1.6; display: flex; align-items: center; gap: 4px; }
.batch-remarks { color: var(--gray-400); font-size: 11px; }
.btn-tiny {
  background: none; color: var(--primary); border: 1px solid var(--primary); border-radius: 3px;
  padding: 1px 6px; font-size: 11px; cursor: pointer; white-space: nowrap; margin-top: 2px;
}
.btn-tiny:hover { background: var(--primary); color: #fff; }

/* update records cell (更新交期累积记录) */
.update-cell { padding: 4px 6px !important; min-width: 140px; }
.update-record {
  font-size: 11px; line-height: 1.7; padding: 1px 0;
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
}
.update-date { font-weight: 500; }
.update-first {
  background: #dbeafe; color: #1d4ed8; padding: 0 4px; border-radius: 2px; font-size: 10px;
}
.update-diff { font-size: 10px; font-weight: 500; }
.update-delayed .update-date, .update-delayed .update-diff { color: var(--danger); }
.update-early .update-diff { color: var(--success); }
.update-time { color: var(--gray-400); font-size: 10px; margin-left: auto; }

/* status variants for delivery */
.status-pending { background: #fef3c7; color: #92400e; padding: 2px 8px; border-radius: 4px; font-size: 11px; }
.status-active { background: #dbeafe; color: #1d4ed8; padding: 2px 8px; border-radius: 4px; font-size: 11px; }
.status-done { background: #dcfce7; color: #166534; padding: 2px 8px; border-radius: 4px; font-size: 11px; }
.status-closed { background: var(--gray-100); color: var(--gray-500); padding: 2px 8px; border-radius: 4px; font-size: 11px; }

/* new row (bottom sticky) */
.ssheet .new-row td { background: #a8d8ad; border-color: var(--gray-300); }
.ssheet .new-row .cell-input:focus { background: #96cc9c; box-shadow: inset 0 0 0 2px var(--success); }

/* paste hint row */
.paste-row td { padding: 4px; }
.paste-row textarea {
  width: 100%; padding: 6px; border: 1px dashed var(--gray-300); border-radius: 4px;
  font-size: 12px; resize: vertical; min-height: 60px; outline: none; font-family: inherit;
}
.paste-row textarea:focus { border-color: var(--primary); }

/* submit row button */
.btn-submit-row {
  background: var(--success); color: #fff; border: none; border-radius: 4px;
  padding: 3px 10px; font-size: 12px; cursor: pointer; white-space: nowrap;
}
.btn-submit-row:hover { background: #15803d; }
.btn-submit-row:disabled { background: var(--gray-300); cursor: not-allowed; }

.btn-update-row {
  background: var(--warning); color: #fff; border: none; border-radius: 4px;
  padding: 3px 10px; font-size: 12px; cursor: pointer; white-space: nowrap;
}
.btn-update-row:hover { background: #d97706; }

.btn-split-row {
  background: none; color: var(--primary); border: 1px solid var(--primary); border-radius: 4px;
  padding: 2px 8px; font-size: 11px; cursor: pointer; white-space: nowrap;
}
.btn-split-row:hover { background: var(--primary); color: #fff; }

/* compact update display (更新交期紧凑模式) */
.update-compact {
  font-size: 12px; line-height: 1.6; display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
}
.batch-label {
  color: var(--gray-500); font-size: 11px; white-space: nowrap; margin-right: 2px;
}
.batch-qty-display {
  color: var(--gray-600); font-size: 11px; font-weight: 500;
}
.change-entry {
  font-size: 11px; padding: 0 3px; border-radius: 2px; white-space: nowrap;
}
.change-delayed {
  color: var(--danger); background: rgba(239,68,68,0.08);
}
.change-early {
  color: var(--success); background: rgba(34,197,94,0.08);
}
.change-chain {
  font-size: 11px; color: var(--gray-500);
}
.update-note {
  color: var(--gray-500); font-size: 11px; padding-left: 4px;
}
.update-global-remark {
  font-size: 11px; color: var(--warning); padding: 2px 0; border-top: 1px dashed var(--gray-200);
  margin-top: 2px; font-style: italic;
}

/* 货期管理筛选栏 */
.delivery-filter-bar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
}
.delivery-search-input {
  width: 260px !important;
  height: 36px;
  font-size: 14px;
  padding: 0 12px;
  border-radius: 6px;
}
.delivery-status-tabs {
  display: flex; flex-wrap: nowrap; gap: 6px;
}
.delivery-status-tabs .delivery-status-btn {
  padding: 6px 16px;
  font-size: 14px;
  border-radius: 6px;
  height: 36px;
  font-weight: 500;
  position: relative;
}
/* Tab 内嵌角标 */
.tab-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: #ef4444; color: #fff; font-size: 10px; font-weight: 700; margin-left: 4px; line-height: 18px; flex-shrink: 0; }

/* 货期更新高亮 */
.row-updated td { background: #fffbeb !important; }
.row-updated td:first-child { border-left: 3px solid #f59e0b !important; }
.cell-updated { border-left: 3px solid #f59e0b !important; background: #fef3c7 !important; }
.update-tag { display: inline-block; background: #f59e0b; color: #fff; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 3px; margin-right: 4px; vertical-align: middle; line-height: 1.4; }
.update-tag.tag-new { background: #3b82f6; }

/* 试算工具 */
.trial-tool-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.trial-tool-col {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 8px 4px;
  text-align: center;
}
.tt-label { font-size: 10px; color: var(--gray-400); margin-bottom: 2px; }
.tt-arrow { margin: 4px 0; color: var(--gray-300); font-size: 12px; }
.tt-result { font-size: 18px; font-weight: 700; color: var(--primary); }

/* 历史报价/售价 */
.hist-price-row {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.hist-price-row + .hist-price-row { margin-top: 4px; }
.hist-price-cell {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

/* ===== Responsive ===== */
/* 平板适配 */
@media (max-width: 1024px) {
  .sidebar { width: 160px; }
  .main-content { padding: 16px; }
}

/* 手机适配 — 管理员专用 */
@media (max-width: 768px) {
  /* 布局 */
  .app-layout { flex-direction: column; }
  .sidebar {
    width: 100%; flex-direction: row; overflow-x: auto; align-items: center;
    position: sticky; top: 0; z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  }
  .sidebar-brand { padding: 10px 16px; font-size: 14px; white-space: nowrap; border-bottom: none; border-right: 1px solid rgba(255,255,255,0.1); }
  .sidebar-nav { display: flex; padding: 0; gap: 0; }
  .sidebar-nav a { padding: 10px 14px; white-space: nowrap; border-left: none !important; border-bottom: 3px solid transparent; font-size: 13px; }
  .sidebar-nav a.active { border-bottom-color: var(--primary); border-left: none !important; background: rgba(37,99,235,0.2); }
  .sidebar-user { display: none; }
  .main-content { padding: 12px 8px; min-height: calc(100vh - 52px); }

  /* 页面标题 */
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-title { font-size: 18px; }
  .page-header > div { flex-wrap: wrap; width: 100%; }
  .page-header > div .btn { flex: 1; min-width: 0; }

  /* 统计卡片 */
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card .stat-value { font-size: 22px; }

  /* 快捷链接 */
  .quick-links { gap: 8px; }
  .quick-link { padding: 8px 14px; min-width: 90px; }
  .ql-value { font-size: 20px; }
  .ql-label { font-size: 11px; }

  /* 表单 */
  .form-row { flex-direction: column; gap: 0; }

  /* 按钮增大触屏区域 */
  .btn { min-height: 40px; padding: 8px 14px; }
  .btn-sm { min-height: 34px; padding: 6px 10px; }

  /* 表格 */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -8px; border-radius: 0; }
  th, td { padding: 8px 6px; font-size: 12px; }
  th { font-size: 11px; }

  /* 搜索/筛选栏堆叠 */
  .card div[style*="flex-wrap:wrap"] { flex-direction: column; align-items: stretch; }
  .card input[type="text"], .card select, .card input[type="date"] { width: 100% !important; }

  /* 输入框iOS防缩放 */
  input[type="text"], input[type="search"], select, input[type="number"] {
    max-width: 100%; font-size: 16px !important;
  }

  /* 弹窗 — 移动端全屏 */
  .modal-overlay { align-items: flex-end; }
  .modal {
    width: 100% !important; max-width: 100% !important;
    max-height: 88vh; border-radius: 12px 12px 0 0;
    padding: 16px 12px; position: relative !important;
    left: auto !important; top: auto !important; margin: 0;
  }
  .modal-wide { max-width: 100% !important; }
  .modal h2 { cursor: default; font-size: 16px; margin-bottom: 12px; }
  .modal-footer { flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; min-width: 100px; }

  /* 试算工具grid改为单列 */
  .modal [style*="grid-template-columns: 1fr 1fr"],
  .modal [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* 供应商选择表格 — 卡片式布局（移动端） */
  .modal table { display: block; }
  .modal table thead { display: none; }
  .modal table tbody { display: block; width: 100%; min-width: 0; }
  .modal table tbody tr {
    display: block; background: var(--gray-50); border-radius: var(--radius);
    padding: 10px; margin-bottom: 8px; border: 1px solid var(--gray-200);
  }
  .modal table tbody tr:hover td { background: transparent; }
  .modal table tbody td {
    display: flex; justify-content: space-between; align-items: center;
    padding: 4px 0; border-bottom: 1px solid var(--gray-100); font-size: 13px;
  }
  .modal table tbody td:last-child { border-bottom: none; }
  .modal table tbody td::before {
    content: attr(data-label); font-weight: 500; color: var(--gray-500);
    font-size: 12px; flex-shrink: 0; margin-right: 8px;
  }
  /* 选定列（radio）放到卡片顶部，和供应商名同行 */
  .modal table tbody td[data-label="选定"] {
    border-bottom: 1px solid var(--gray-200); padding-bottom: 6px; margin-bottom: 4px;
  }
  .modal table tbody td[data-label="选定"]::before { display: none; }

  /* 移动端底部固定操作栏 */
  .modal-sticky-footer {
    position: sticky; bottom: 0; left: 0; right: 0;
    background: #fff; padding: 12px 0 0;
    border-top: 1px solid var(--gray-200);
    z-index: 10;
  }
  .modal-sticky-footer .btn { flex: 1; min-height: 38px; font-size: 13px; padding: 6px 8px; }

  /* Toast */
  .toast { top: auto; bottom: 80px; right: 12px; left: 12px; text-align: center; }

  /* 货期管理 */
  .ssheet { font-size: 12px; }
  .ssheet th { padding: 6px 4px; font-size: 11px; }
  .ssheet .cell-input { padding: 4px; font-size: 12px; }
  .delivery-search-input { width: 100% !important; }
  .delivery-status-tabs { flex-wrap: wrap; gap: 4px !important; }
  .delivery-status-tabs .delivery-status-btn { padding: 4px 10px; font-size: 12px; height: 30px; }
  .filter-bar { flex-direction: column; gap: 8px !important; }

  /* 批次弹窗 */
  .batch-popover { min-width: 280px; left: 0 !important; }

  /* 货期表格容器 */
  .ssheet-container { margin: 0 -8px; }

  /* 试算工具 — 手机端压缩 */
  .trial-tool-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 4px;
  }
  .trial-tool-col {
    padding: 4px 2px;
  }
  .trial-tool-col input {
    font-size: 13px !important;
    padding: 2px 1px !important;
  }
  .tt-result { font-size: 14px !important; }
  .tt-label { font-size: 9px !important; margin-bottom: 1px !important; }
  .tt-arrow { margin: 2px 0 !important; font-size: 10px !important; }

  /* 历史价格 — 手机端2列网格，标签价格同行 */
  .hist-price-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 4px 8px;
    margin-top: 6px;
  }
  .hist-price-cell {
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
