:root {
    --primary: #1a56db; --primary-dark: #1e429f; --secondary: #6875f5;
    --success: #0e9f6e; --warning: #c27803; --danger: #f05252;
    --bg: #f3f4f6; --card: #ffffff; --border: #e5e7eb;
    --text: #111827; --text-muted: #6b7280;
    --sidebar-w: 220px; --header-h: 60px;
  }
  
  /* 深色主题 */
  [data-theme="dark"] {
    --primary: #3b82f6; --primary-dark: #2563eb; --secondary: #8b5cf6;
    --success: #10b981; --warning: #f59e0b; --danger: #ef4444;
    --bg: #0f172a; --card: #1e293b; --border: #334155;
    --text: #f1f5f9; --text-muted: #94a3b8;
  }
  [data-theme="dark"] body { background: var(--bg); color: var(--text); }
  [data-theme="dark"] .header { background: #1e293b; border-color: #334155; }
  [data-theme="dark"] .sidebar { background: #1e293b; border-color: #334155; }
  [data-theme="dark"] .nav-item:hover { background: #334155; }
  [data-theme="dark"] .nav-item.active { background: #334155; }
  [data-theme="dark"] .kpi-card { background: #1e293b; border-color: #334155; }
  [data-theme="dark"] .card { background: #1e293b; border-color: #334155; }
  [data-theme="dark"] th { background: #334155; color: #e2e8f0; border-color: #475569; }
  [data-theme="dark"] td { border-color: #334155; color: #cbd5e1; }
  [data-theme="dark"] tr:hover td { background: #334155; }
  [data-theme="dark"] .modal { background: #1e293b; }
  [data-theme="dark"] .form-group input, 
  [data-theme="dark"] .form-group select, 
  [data-theme="dark"] .form-group textarea { 
    background: #0f172a; border-color: #475569; color: #e2e8f0; 
  }
  [data-theme="dark"] .btn-secondary { background: #334155; color: #e2e8f0; }
  [data-theme="dark"] .loading-overlay { background: rgba(15, 23, 42, 0.8); }
  [data-theme="dark"] .skeleton { background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%); }
  [data-theme="dark"] .login-card { background: #1e293b; }
  [data-theme="dark"] .login-logo h1 { color: #f1f5f9; }
  [data-theme="dark"] .page-title { color: #f1f5f9; }
  [data-theme="dark"] .kpi-value { color: #f1f5f9; }
  [data-theme="dark"] .card-title { color: #f1f5f9; }
  [data-theme="dark"] .theme-toggle { background: #334155; color: #fbbf24; }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); }
  input, select, textarea { font-family: inherit; }
  a { color: inherit; text-decoration: none; }

  /* ── LOGIN ── */
  #login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e3a8a 0%, #1a56db 50%, #6875f5 100%); }
  .login-card { background: white; border-radius: 16px; padding: 48px 40px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
  .login-logo { text-align: center; margin-bottom: 32px; }
  .login-logo .icon { width: 64px; height: 64px; background: linear-gradient(135deg, #1a56db, #6875f5); border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; font-size: 28px; margin-bottom: 12px; }
  .login-logo h1 { font-size: 22px; font-weight: 700; }
  .login-logo p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
  .form-group { margin-bottom: 18px; }
  .form-group label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
  .form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px 14px; border: 1.5px solid #d1d5db; border-radius: 8px; font-size: 15px; outline: none; transition: border-color 0.2s; }
  .form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); }
  .btn { padding: 9px 16px; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; transition: opacity 0.2s, transform 0.1s; display: inline-flex; align-items: center; gap: 6px; }
  .btn:hover { opacity: 0.9; transform: translateY(-1px); }
  .btn-primary { background: var(--primary); color: white; }
  .btn-success { background: var(--success); color: white; }
  .btn-danger { background: var(--danger); color: white; }
  .btn-secondary { background: #e5e7eb; color: #374151; }
  .btn-sm { padding: 5px 12px; font-size: 13px; }
  .btn-login { width: 100%; padding: 12px; background: linear-gradient(135deg, #1a56db, #6875f5); color: white; border: none; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 8px; transition: opacity 0.2s; }
  .btn-login:hover { opacity: 0.92; }
  .login-err { color: var(--danger); font-size: 13px; text-align: center; margin-top: 10px; display: none; }

  /* ── LAYOUT ── */
  #app { display: none; min-height: 100vh; }
  .header { position: fixed; top: 0; left: 0; right: 0; height: var(--header-h); background: white; border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 20px; z-index: 100; gap: 16px; }
  .header-brand { font-size: 16px; font-weight: 700; color: var(--primary); flex: 1; }
  .header-user { font-size: 13px; color: var(--text-muted); }
  .btn-logout { padding: 6px 14px; background: #fee2e2; color: #b91c1c; border: none; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background 0.2s; }
  .btn-logout:hover { background: #fecaca; }
  .hamburger { display: none; background: none; border: none; font-size: 22px; cursor: pointer; padding: 4px; }

  .sidebar { position: fixed; top: var(--header-h); left: 0; bottom: 0; width: var(--sidebar-w); background: white; border-right: 1px solid var(--border); overflow-y: auto; z-index: 90; transition: transform 0.25s; }
  .sidebar-nav { padding: 16px 12px; }
  .nav-section { font-size: 11px; font-weight: 700; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.05em; padding: 12px 8px 6px; }
  .nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; color: #374151; font-weight: 500; transition: background 0.15s, color 0.15s; margin-bottom: 2px; }
  .nav-item:hover { background: #eff6ff; color: var(--primary); }
  .nav-item.active { background: #eff6ff; color: var(--primary); font-weight: 700; }
  .nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }

  .main { margin-left: var(--sidebar-w); margin-top: var(--header-h); padding: 24px; min-height: calc(100vh - var(--header-h)); }

  /* ── CARDS ── */
  .page { display: none; }
  .page.active { display: block; }
  .page-title { font-size: 22px; font-weight: 700; margin-bottom: 20px; color: #111827; }
  .kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px; }
  .kpi-card { background: white; border-radius: 12px; padding: 18px; border: 1px solid var(--border); position: relative; overflow: hidden; }
  .kpi-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; }
  .kpi-card.blue::before { background: linear-gradient(90deg, #1a56db, #6875f5); }
  .kpi-card.green::before { background: linear-gradient(90deg, #0e9f6e, #31c48d); }
  .kpi-card.yellow::before { background: linear-gradient(90deg, #c27803, #fcd34d); }
  .kpi-card.red::before { background: linear-gradient(90deg, #f05252, #f98080); }
  .kpi-card.purple::before { background: linear-gradient(90deg, #7e3af2, #a78bfa); }
  .kpi-card.cyan::before { background: linear-gradient(90deg, #0694a2, #67e8f9); }
  .kpi-card.orange::before { background: linear-gradient(90deg, #d97706, #fb923c); }
  .kpi-card.teal::before { background: linear-gradient(90deg, #0f766e, #2dd4bf); }
  .kpi-card.indigo::before { background: linear-gradient(90deg, #4338ca, #818cf8); }
  .kpi-card.pink::before { background: linear-gradient(90deg, #db2777, #f472b6); }
  .kpi-card.lime::before { background: linear-gradient(90deg, #65a30d, #a3e635); }
  .kpi-card.amber::before { background: linear-gradient(90deg, #d97706, #fbbf24); }
  .kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 8px; }
  .kpi-value { font-size: 24px; font-weight: 700; color: #111827; }
  .kpi-sub { font-size: 11px; color: #9ca3af; margin-top: 4px; }

  .card { background: white; border-radius: 12px; border: 1px solid var(--border); overflow: hidden; margin-bottom: 20px; }
  .card-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
  .card-title { font-size: 15px; font-weight: 700; }
  .card-body { padding: 16px 18px; overflow-x: auto; }

  /* ── TABLE ── */
  table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 500px; }
  th { background: #f9fafb; padding: 10px 12px; text-align: left; font-weight: 600; color: #374151; border-bottom: 2px solid var(--border); white-space: nowrap; }
  td { padding: 10px 12px; border-bottom: 1px solid #f3f4f6; color: #374151; vertical-align: middle; }
  tr:hover td { background: #f9fafb; }
  .badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
  .badge-success { background: #d1fae5; color: #065f46; }
  .badge-warning { background: #fef3c7; color: #92400e; }
  .badge-danger { background: #fee2e2; color: #991b1b; }
  .badge-info { background: #dbeafe; color: #1e40af; }
  .badge-secondary { background: #f3f4f6; color: #6b7280; }
  .num { font-variant-numeric: tabular-nums; text-align: right; }
  .actions { display: flex; gap: 4px; }

  /* ── MODAL ── */
  .modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200; display: none; align-items: center; justify-content: center; padding: 20px; }
  .modal-overlay.show { display: flex; }
  .modal-overlay.show .modal { display: flex !important; flex-direction: column; }
  .modal { display: none; position: relative; background: white; border-radius: 12px; width: 100%; max-width: 900px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2); z-index: 1000; }
  .modal-header { padding: 12px 16px; border-bottom: 1px solid #e5e7eb; display: flex; align-items: center; justify-content: space-between; }
  .modal-title { font-size: 15px; font-weight: 600; }
  .modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: #6b7280; padding: 4px 8px; line-height: 1; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; border-top: 1px solid #e5e7eb; display: flex; justify-content: flex-end; gap: 8px; position: sticky; bottom: 0; background: var(--card); z-index: 3; }
  .modal-footer .btn { padding: 8px 16px; font-size: 13px; min-height: 36px; }
  .modal-body-split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

  
  /* ── 月度成本结算中心（优化版） ── */
  .settlement-new-month {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
  }
  .settlement-new-label {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    white-space: nowrap;
  }
  
  .settlement-new-body {
    display: flex;
    gap: 20px;
    padding: 20px 24px;
    min-height: 400px;
  }
  
  .settlement-new-section {
    flex: 1;
    display: flex;
    flex-direction: column;
  }
  
  .settlement-new-section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
  }
  
  /* 进度概览 */
  .settlement-new-progress {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 16px;
  }
  .settlement-new-progress-item {
    text-align: center;
    flex: 1;
  }
  .settlement-new-progress-num {
    font-size: 28px;
    font-weight: 700;
    color: #f97316;
  }
  .settlement-new-progress-done {
    color: #22c55e;
  }
  .settlement-new-progress-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
  }
  .settlement-new-progress-arrow {
    font-size: 20px;
    color: var(--text-muted);
  }
  .settlement-new-progress-total {
    font-size: 13px;
    color: var(--text-muted);
    padding: 6px 12px;
    background: var(--bg-secondary);
    border-radius: 20px;
  }
  
  /* 运费输入 */
  .settlement-new-input-group {
    margin-bottom: 16px;
  }
  .settlement-new-input-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
  }
  .settlement-new-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: #fffbeb;
    border: 1.5px solid #fde68a;
    border-radius: 8px;
  }
  .settlement-new-yen {
    font-size: 18px;
    color: #92400e;
  }
  .settlement-new-input-row input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px;
    outline: none;
    color: #92400e;
  }
  .settlement-new-preview {
    font-size: 12px;
    color: #92400e;
    margin-top: 6px;
  }
  
  /* 预览卡片 */
  .settlement-new-preview-card {
    padding: 14px 16px;
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border: 1px solid #86efac;
    border-radius: 10px;
    margin-bottom: 16px;
  }
  .settlement-new-preview-title {
    font-size: 12px;
    font-weight: 600;
    color: #166534;
    margin-bottom: 10px;
  }
  .settlement-new-preview-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #166534;
    padding: 4px 0;
  }
  .settlement-new-preview-divider {
    height: 1px;
    background: #86efac;
    margin: 8px 0;
  }
  .settlement-new-preview-result {
    font-weight: 600;
    font-size: 15px;
  }
  
  /* 其他成本 */
  .settlement-new-cost-list {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
  }
  .settlement-new-cost-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
  }
  .settlement-new-cost-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
  }
  .settlement-new-cost-item:last-child { border-bottom: none; }
  .settlement-new-cost-label {
    font-size: 13px;
    color: var(--text);
  }
  .settlement-new-cost-amount {
    font-size: 14px;
    font-weight: 600;
    color: #dc2626;
  }
  .settlement-new-cost-del {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    font-size: 16px;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
  }
  .settlement-new-cost-del:hover {
    background: #fee2e2;
    color: #ef4444;
  }
  .settlement-new-cost-total {
    padding: 10px 14px;
    background: var(--bg-secondary);
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    text-align: right;
    border-radius: 0 0 10px 10px;
    border: 1px solid var(--border);
    border-top: none;
  }
  
  /* 订单明细 */
  .settlement-new-orders-list {
    border: 1px solid var(--border);
    border-radius: 10px;
    max-height: 200px;
    overflow: auto;
  }
  .settlement-new-order-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
  }
  .settlement-new-order-item:last-child { border-bottom: none; }
  .settlement-new-order-item.pending { background: #fffbeb; }
  .settlement-new-order-item.done { background: #f0fdf4; }
  .settlement-new-order-no {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
  }
  .settlement-new-order-info {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
  }
  .settlement-new-order-amount {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    text-align: right;
  }
  .settlement-new-order-status {
    font-size: 11px;
    text-align: right;
    margin-top: 2px;
  }
  .settlement-new-order-status.status-pending { color: #f97316; }
  .settlement-new-order-status.status-done { color: #22c55e; }
  
  /* 历史记录 */
  .settlement-new-history {
    padding: 20px 24px;
  }
  .settlement-new-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 600;
  }
  .settlement-new-history-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 16px;
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg));
    border-radius: 10px;
    margin-bottom: 16px;
  }
  .settlement-new-history-stat {
    text-align: center;
  }
  .settlement-new-history-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
  }
  .settlement-new-history-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
  }
  .settlement-new-history-timeline {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .settlement-new-history-item {
    display: flex;
    gap: 16px;
    padding: 14px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
  }
  .settlement-new-history-month {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    min-width: 70px;
  }
  .settlement-new-history-details {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
  }
  .settlement-new-history-row {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text);
  }
  .settlement-new-history-icon { font-size: 14px; }
  .settlement-new-history-per {
    font-size: 11px;
    color: var(--text-muted);
  }
  
  /* 迷你弹窗 */
  .mini-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
  }
  .mini-modal {
    background: var(--bg);
    border-radius: 12px;
    width: 320px;
    max-width: 90vw;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  }
  .mini-modal-header {
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
  }
  .mini-modal-footer {
    padding: 12px 16px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid var(--border);
  }
  .mini-modal-footer .btn { padding: 8px 16px; }
  
  /* 按钮小尺寸 */
  .btn-sm { padding: 4px 10px; font-size: 12px; }
  .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .sales-line-items { border: 1px solid var(--border); border-radius: 8px; overflow: auto; max-height: 285px; background: #fff; }
  .sales-line-items table { min-width: 760px; table-layout: fixed; }
  .sales-line-items thead th { position: sticky; top: 0; z-index: 1; }
  .sales-line-items th { padding: 8px 8px; font-size: 12px; }
  .sales-line-items td { padding: 6px 8px; vertical-align: top; }
  .sales-line-items input,
  .sales-line-items select { width: 100%; padding: 7px 8px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; }
  .sales-line-items .so-product-input { margin-top: 5px; }
  .sales-line-items .so-remove-cell { text-align: center; }
  .modal-section-collapse { margin-top: 16px; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; }
  .modal-section-collapse summary { cursor: pointer; padding: 12px 16px; font-weight: 600; color: #374151; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .modal-section-collapse summary::-webkit-details-marker { display: none; }
  .modal-section-collapse summary::after { content: '展开'; font-size: 12px; color: var(--primary); font-weight: 600; }
  .modal-section-collapse[open] summary { border-bottom: 1px solid #e5e7eb; }
  .modal-section-collapse[open] summary::after { content: '收起'; }
  .modal-section-collapse .collapse-body { padding: 14px 16px 16px; }
  .modal-section-collapse .summary-hint { font-size: 12px; color: #6b7280; font-weight: 400; }

  /* ── TOAST ── */
  #toast { position: fixed; bottom: 24px; right: 24px; background: #111827; color: white; padding: 12px 20px; border-radius: 10px; font-size: 14px; font-weight: 500; z-index: 999; display: none; transition: opacity 0.3s, transform 0.3s; transform: translateY(20px); opacity: 0; }
  #toast.show { display: block; opacity: 1; transform: translateY(0); }
  #toast.success { background: var(--success); }
  #toast.error { background: var(--danger); }
  #toast.warning { background: var(--warning); color: #000; }
  #toast.info { background: var(--primary); }

  /* ── LOADING SPINNER ── */
  .loading-overlay { position: fixed; inset: 0; background: rgba(255,255,255,0.8); z-index: 1000; display: none; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
  .loading-overlay.show { display: flex; }
  .spinner { width: 48px; height: 48px; border: 4px solid #e5e7eb; border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
  .loading-text { margin-top: 16px; color: var(--text-muted); font-size: 14px; text-align: center; }
  .loading-container { display: flex; flex-direction: column; align-items: center; }

  /* ── BUTTON LOADING STATE ── */
  .btn.loading { position: relative; color: transparent !important; pointer-events: none; }
  .btn.loading::after { content: ''; position: absolute; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.8s linear infinite; left: 50%; top: 50%; margin-left: -8px; margin-top: -8px; }
  .btn-secondary.loading::after { border: 2px solid rgba(0,0,0,0.2); border-top-color: #374151; }
  .btn-icon { background: none; border: none; font-size: 18px; color: #9ca3af; cursor: pointer; padding: 2px 6px; line-height: 1; }
  .btn-icon:hover { color: #ef4444; }
  .btn-text { background: none; border: none; color: var(--primary); cursor: pointer; padding: 4px 8px; font-size: 13px; white-space: nowrap; }
  .btn-text:hover { text-decoration: underline; }
  .btn-text.text-red { color: #ef4444; }
  td.action-col { text-align: left; white-space: nowrap; vertical-align: middle; }
  td.action-col .btn, td.action-col .btn-text { margin-right: 4px; }

  /* ── SKELETON LOADING ── */
  .skeleton { background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 4px; }
  @keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
  .skeleton-text { height: 16px; margin-bottom: 8px; }
  .skeleton-title { height: 24px; width: 60%; margin-bottom: 16px; }

  /* ── HOVER EFFECTS ── */
  .nav-item { position: relative; overflow: hidden; }
  .nav-item::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--primary); transform: scaleY(0); transition: transform 0.2s; }
  .nav-item:hover::before, .nav-item.active::before { transform: scaleY(1); }
  .kpi-card { transition: transform 0.2s, box-shadow 0.2s; }
  .kpi-card:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(0,0,0,0.08); }
  table tr { transition: background 0.15s; }
  .btn { position: relative; overflow: hidden; }
  .btn::after { content: ''; position: absolute; inset: 0; background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%); transform: scale(0); opacity: 0; transition: transform 0.3s, opacity 0.3s; }
  .btn:active::after { transform: scale(2); opacity: 1; transition: 0s; }

  /* ── RESPONSIVE ── */
  @media (max-width: 768px) {
    .hamburger { display: block; }
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; padding: 16px; }
    .form-row { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .modal { max-width: 100%; border-radius: 12px; }
    
    /* 移动端优化 */
    .header-brand { font-size: 14px; }
    .header-user { display: none; }
    .btn { padding: 10px 14px; font-size: 15px; min-height: 44px; }
    .btn-sm { padding: 8px 12px; font-size: 14px; min-height: 40px; }
    .nav-item { padding: 12px 14px; font-size: 15px; }
    .page-title { font-size: 18px; margin-bottom: 16px; }
    .kpi-card { padding: 14px; }
    .kpi-value { font-size: 20px; }
    .kpi-label { font-size: 11px; }
    .card-header { padding: 12px 14px; flex-direction: column; align-items: flex-start; gap: 8px; }
    .card-body { padding: 12px 14px; }
    table { font-size: 12px; }
    th, td { padding: 8px 10px; }
    .form-group input, .form-group select, .form-group textarea { padding: 12px 14px; font-size: 16px; }
    .modal-body { padding: 16px; }
    .modal-footer { padding: 12px 16px; flex-direction: column; }
    .modal-footer .btn { width: 100%; justify-content: center; }
    
    /* 触摸友好的表格 */
    .card-body { -webkit-overflow-scrolling: touch; }
    
    /* 移动端卡片视图 */
    .mobile-card-view { display: block; }
    .mobile-card-view .card-item { 
      background: var(--card); 
      border: 1px solid var(--border); 
      border-radius: 12px; 
      padding: 14px; 
      margin-bottom: 12px; 
    }
    .mobile-card-view .card-item-header { 
      display: flex; 
      justify-content: space-between; 
      align-items: center; 
      margin-bottom: 10px; 
      font-weight: 600; 
    }
    .mobile-card-view .card-item-row { 
      display: flex; 
      justify-content: space-between; 
      padding: 6px 0; 
      border-bottom: 1px solid var(--border); 
      font-size: 13px; 
    }
    .mobile-card-view .card-item-row:last-child { border-bottom: none; }
    .mobile-card-view .card-item-label { color: var(--text-muted); }
    .mobile-card-view .card-item-value { font-weight: 500; }
    
    /* 移动端隐藏复杂表格，显示卡片 */
    @media (max-width: 640px) {
      .hide-mobile { display: none !important; }
      .show-mobile { display: block !important; }
    }
  }
  
  @media (max-width: 480px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .kpi-card { padding: 12px; }
    .kpi-value { font-size: 18px; }
    .kpi-label { font-size: 10px; }
    .login-card { padding: 32px 24px; margin: 16px; }
    .theme-toggle { font-size: 18px; padding: 4px; }
  }

  /* 打印样式 */
  @media print {
    body * { visibility: hidden; }
    .print-area, .print-area * { visibility: visible; }
    .print-area {
      position: absolute; left: 0; top: 0; width: 100%;
      background: white !important;
    }
    .no-print { display: none !important; }
    .print-table { width: 100%; border-collapse: collapse; font-size: 12px; }
    .print-table th { background: #f0f0f0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .print-table th, .print-table td { border: 1px solid #ddd; padding: 8px; text-align: left; }
    .print-table th.num, .print-table td.num { text-align: right; }
    .print-header { text-align: center; margin-bottom: 20px; }
    .print-header h1 { font-size: 20px; margin-bottom: 4px; }
    .print-header p { font-size: 12px; color: #666; }
    .print-info { display: flex; gap: 20px; margin-bottom: 16px; font-size: 12px; }
    .print-info span { white-space: nowrap; }
    .print-total { text-align: right; font-size: 14px; font-weight: bold; margin-top: 12px; padding-top: 12px; border-top: 2px solid #333; }
    .print-footer { margin-top: 30px; font-size: 11px; color: #888; }
    .print-section { margin: 12px 0; padding: 8px 0; border-bottom: 1px dashed #ddd; }
    .print-section-title { font-weight: bold; margin-bottom: 6px; }
  }
