:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --sidebar-width: 240px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

/* ===== Login ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #3b82f6 100%);
}

.login-container { width: 100%; max-width: 400px; padding: 20px; }

.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 40px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.login-header { text-align: center; margin-bottom: 32px; }

.login-logo {
  width: 56px; height: 56px;
  background: var(--primary);
  color: #fff;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
  margin-bottom: 16px;
}

.login-header h1 { font-size: 22px; margin-bottom: 4px; }
.login-header p { color: var(--text-muted); font-size: 13px; }

.login-form .form-group { margin-bottom: 20px; }
.login-form label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 13px; }
.login-form input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  transition: border-color .2s;
}
.login-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }

.login-hint { text-align: center; color: var(--text-muted); font-size: 12px; margin-top: 16px; }

/* ===== Layout ===== */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: #0f172a;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .3s;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 36px; height: 36px;
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-title { font-weight: 600; color: #f1f5f9; font-size: 15px; }

.sidebar-close {
  display: none;
  margin-left: auto;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 24px;
  cursor: pointer;
}

.sidebar-nav {
  flex: 1;
  min-height: 0;
  padding: 12px 8px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, .45) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, .45);
  border-radius: 3px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, .7);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: #94a3b8;
  text-decoration: none;
  margin-bottom: 4px;
  transition: background .2s, color .2s;
}

.nav-item:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-icon { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }

.nav-group { margin-bottom: 4px; }
.nav-group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius);
  background: none;
  color: #94a3b8;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: background .2s, color .2s;
}
.nav-group-title:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.nav-group.open > .nav-group-title { color: #e2e8f0; }
.nav-arrow { margin-left: auto; font-size: 11px; transition: transform .2s; }
.nav-group.open .nav-arrow { transform: rotate(90deg); }

.nav-sub { display: none; padding-left: 12px; margin-bottom: 4px; }
.nav-group.open .nav-sub { display: block; }
.nav-sub-item {
  padding: 8px 12px 8px 34px;
  font-size: 13px;
  margin-bottom: 2px;
}
.nav-leaf { margin-bottom: 8px; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 99;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 18px;
  cursor: pointer;
  color: var(--text);
}

.page-title { font-size: 18px; font-weight: 600; }

.content-area { padding: 20px 24px; }

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.search-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.search-bar input,
.search-bar select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  min-width: 120px;
}

.search-bar .combo-wrap {
  flex: 1;
  min-width: 160px;
  max-width: 280px;
}

.search-bar .combo-wrap input[type="text"] {
  width: 100%;
  box-sizing: border-box;
}

.search-bar input:focus,
.search-bar select:focus {
  outline: none;
  border-color: var(--primary);
}

/* ===== Table ===== */
.table-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

.data-table th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.data-table td.col-product-name {
  max-width: 11em;
  line-height: 1.45;
  vertical-align: top;
}

.data-table .cell-work-order-id {
  font-size: 16px;
  font-weight: 700;
  color: var(--text, #1e293b);
}

.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }

.empty-row { text-align: center; color: var(--text-muted); padding: 40px !important; }

.action-btns { display: flex; gap: 6px; }

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.pagination-info { color: var(--text-muted); font-size: 13px; margin-right: 8px; }

.page-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}

.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s, color .2s;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f8fafc; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }

.btn-ghost { background: transparent; color: #94a3b8; border: 1px solid rgba(255,255,255,.15); }
.btn-ghost:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }

/* ===== Modal ===== */
.modal { display: none; position: fixed; inset: 0; z-index: 200; }
.modal.open { display: flex; align-items: center; justify-content: center; }

.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }

.modal-dialog {
  position: relative;
  background: var(--surface);
  border-radius: 12px;
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 { font-size: 16px; }

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

/* ===== Form ===== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.full-width { grid-column: 1 / -1; }

.form-group label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.form-group label .required { color: var(--danger); }

.form-group input,
.form-group select,
.form-group textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.form-group textarea { resize: vertical; min-height: 60px; }

/* ===== Alert & Toast ===== */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}

.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1e293b;
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 300;
  opacity: 0;
  transition: transform .3s, opacity .3s;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.error { background: var(--danger); }

/* ===== Order Forms ===== */
.form-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.form-page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.order-form-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.order-header-grid { margin-bottom: 20px; }

.line-items-section { margin-top: 8px; }

.line-items-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.line-items-header h3 { font-size: 15px; }

.line-items-table select,
.line-items-table input {
  width: 100%;
  min-width: 80px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
}

.line-items-section .table-wrap { overflow: visible; }
.line-items-table td:first-child {
  min-width: 280px;
  overflow: visible;
}
.line-items-table .combo-wrap { min-width: 240px; }
.line-items-table .combo-dropdown { z-index: 300; }

.text-right { text-align: right; }

/* ===== Status Badges ===== */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.status-badge.draft { background: #fef3c7; color: #92400e; }
.status-badge.approved { background: #dcfce7; color: #166534; }
.status-badge.inbound { background: #dbeafe; color: #1e40af; }
.status-badge.outbound { background: #fee2e2; color: #991b1b; }

/* ===== Stock ===== */
.low-stock { background: #fef2f2 !important; }
.low-stock:hover { background: #fee2e2 !important; }
.pending-purchase { background: #fff7ed !important; }
.pending-purchase:hover { background: #ffedd5 !important; }
.status-badge.pending { background: #fed7aa; color: #c2410c; }

/* ===== Customer Order Items ===== */
.order-items-container { display: flex; flex-direction: column; gap: 16px; margin-top: 12px; }
.order-item-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  background: #fafafa;
}
.order-item-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}
.order-item-num { font-weight: 600; color: var(--primary); }
.order-item-grid { margin-bottom: 8px; }
.fabric-mode-section {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 8px 0 12px;
  padding: 8px 12px;
  background: #f0f4ff;
  border-radius: 6px;
}
.fabric-mode-section label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.fabric-mode-label { font-weight: 600; margin-right: 4px; }
.image-upload-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 8px; }
.image-upload-box { display: flex; flex-direction: column; gap: 8px; }
.line-img-preview { max-width: 120px; max-height: 120px; border-radius: 4px; border: 1px solid var(--border); }

.multi-img-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
  min-height: 40px;
}
.multi-img-item {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
  cursor: grab;
}
.multi-img-item.dragging { opacity: 0.55; }
.multi-img-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}
.multi-img-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(185, 28, 28, 0.9);
  color: #fff;
  font-size: 14px;
  line-height: 22px;
  cursor: pointer;
  padding: 0;
}
.multi-img-ord {
  position: absolute;
  left: 4px;
  bottom: 4px;
  background: rgba(15, 23, 42, 0.65);
  color: #fff;
  font-size: 11px;
  border-radius: 4px;
  padding: 1px 5px;
}
.multi-img-empty {
  color: #94a3b8;
  font-size: 13px;
  padding: 12px 0;
}
.multi-img-file { display: none; }
.multi-img-add { align-self: flex-start; }

.hx-img-viewer {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10050;
}
.hx-img-viewer.open { display: block; }
.hx-img-viewer-mask {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.82);
}
.hx-img-viewer-stage {
  position: absolute;
  inset: 56px 24px 72px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
}
.hx-img-viewer-img {
  max-width: 90%;
  max-height: 90%;
  transform-origin: center center;
  transition: transform 0.05s linear;
  user-select: none;
  pointer-events: none;
}
.hx-img-viewer-toolbar {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: rgba(15, 23, 42, 0.9);
  padding: 8px 12px;
  border-radius: 999px;
}
.hx-img-viewer-toolbar button {
  border: 1px solid rgba(255,255,255,0.25);
  background: transparent;
  color: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
}
.hx-img-viewer-hint {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.75);
  font-size: 12px;
}

@media (max-width: 720px) {
  .image-upload-row { grid-template-columns: 1fr; }
}
.order-total-bar {
  text-align: right;
  padding: 12px 16px;
  margin-top: 12px;
  background: #f0f4ff;
  border-radius: 6px;
  font-size: 1.1rem;
}
.order-total-bar #totalAmount { color: var(--primary); font-size: 1.2rem; margin-left: 8px; }

.section-title { margin: 20px 0 10px; font-size: 1rem; color: var(--text); }
.order-detail-section { display: flex; flex-direction: column; gap: 16px; }
.order-detail-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  background: #fafafa;
}
.order-detail-block h4 { margin: 0 0 10px; font-size: 15px; color: var(--primary); }
.detail-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-muted);
}
.detail-summary strong { color: var(--text); }
.detail-subsection { margin: 12px 0; }
.detail-subtitle {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--text);
}
.detail-field { margin: 10px 0; }
.detail-field label {
  display: block;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.detail-field .value {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.5;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.detail-empty { color: var(--text-muted); font-size: 13px; margin: 8px 0; }
.fabric-sub-table { margin-top: 4px; font-size: 13px; }
.detail-images {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
}
.detail-image-item { display: flex; flex-direction: column; gap: 6px; }
.detail-image-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.detail-image-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.detail-image-item img,
.detail-image-grid img {
  width: 96px;
  height: 96px;
  border-radius: 6px;
  border: 1px solid var(--border);
  object-fit: cover;
  background: #fff;
  cursor: zoom-in;
}

/* ===== Combobox ===== */
.combo-wrap { position: relative; }
.combo-dropdown {
  display: none;
  position: absolute;
  z-index: 100;
  left: 0;
  right: 0;
  top: 100%;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 6px;
  padding: 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.combo-dropdown.open { display: block; }
.combo-dropdown li {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9rem;
}
.combo-dropdown li:hover, .combo-dropdown li.active { background: #eff6ff; }
.combo-dropdown li.combo-new { color: var(--primary); font-weight: 600; border-top: 1px dashed var(--border); }

/* ===== Multi Fabric Rows ===== */
.item-fabrics-section {
  margin: 12px 0;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-x: auto;
}
.item-fabrics-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.item-fabrics-header label { font-weight: 600; }
.item-fabrics-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: -4px 0 8px;
}
.fabric-list-head,
.fabric-row {
  display: grid;
  grid-template-columns: minmax(160px, 2fr) minmax(72px, 1fr) minmax(88px, 1fr) minmax(88px, 1fr) minmax(88px, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 620px;
}
.fabric-list-head {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding-bottom: 6px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.fabric-list-head span {
  white-space: nowrap;
}
.fabric-row {
  padding: 8px 0;
  border-bottom: 1px dashed #eee;
}
.fabric-row:last-child { border-bottom: none; }
.fabric-row .form-group { gap: 0; min-width: 0; }
.fabric-row .combo-wrap { min-width: 0; }
.fabric-row .fabric-name-input { width: 100%; }
.fabric-row .btn-remove-fabric { align-self: center; white-space: nowrap; }

/* ===== Product Price Tiers (阶梯价格) ===== */
.product-tiers-section {
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.tier-list-head,
.product-tier-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 8px;
  align-items: end;
}
.tier-list-head {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding-bottom: 6px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.product-tier-row {
  padding: 8px 0;
  border-bottom: 1px dashed #eee;
}
.product-tier-row:last-child { border-bottom: none; }
.line-tier-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}
.line-tier-hint.is-error { color: #dc2626; }
.line-tier-hint.is-match { color: #059669; }

/* ===== Product Fabric Rows (产品档案) ===== */
.product-fabrics-section {
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.product-fabric-row {
  display: grid;
  grid-template-columns: 2fr 1.2fr 1.2fr auto;
  gap: 8px;
  align-items: end;
  padding: 8px 0;
  border-bottom: 1px dashed #eee;
}
.product-fabric-row:last-child { border-bottom: none; }
.usage-unit-inner {
  display: flex;
  align-items: center;
  gap: 6px;
}
.usage-unit-inner input { flex: 1; min-width: 0; }
.fabric-unit-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  padding: 8px 0;
}
.cell-multiline {
  max-width: 180px;
  white-space: normal;
  line-height: 1.4;
  font-size: 12px;
}
@media (max-width: 900px) {
  .product-fabric-row { grid-template-columns: 1fr 1fr; }
}

.text-danger { color: var(--danger); font-weight: 600; }
.text-success { color: #16a34a; }

.clickable-row { cursor: pointer; }

.modal-lg { max-width: 720px; }

.modal-lg .modal-footer {
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
}

.inbound-link-section {
  margin-top: 20px;
  padding: 12px 16px;
  background: var(--primary-light);
  border-radius: var(--radius);
  font-size: 13px;
}

.inbound-link-section a { color: var(--primary); font-weight: 600; }

.fabric-summary-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.fabric-summary-section h3 { font-size: 15px; margin-bottom: 12px; }

.fabric-warning {
  padding: 8px 12px;
  margin-bottom: 8px;
  background: #fef3c7;
  color: #92400e;
  border-radius: var(--radius);
  font-size: 13px;
}

.fabric-warning.error { background: #fef2f2; color: var(--danger); }

.status-badge.production { background: #f3e8ff; color: #7c3aed; }

.upload-section { margin-bottom: 20px; }

.upload-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
}

.upload-card h3 { font-size: 15px; margin-bottom: 6px; }
.upload-hint { color: var(--text-muted); font-size: 13px; margin-bottom: 16px; }
.upload-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.upload-result { margin-top: 12px; font-size: 13px; color: #166534; }

.unmatched-row { background: #fffbeb !important; }
.unmatched-row:hover { background: #fef3c7 !important; }

.cell-wrap { max-width: 200px; white-space: normal; word-break: break-all; }

.match-select {
  min-width: 140px;
  padding: 4px 6px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.batch-result {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.batch-result ul { margin-top: 8px; padding-left: 20px; }
.batch-result li { margin-bottom: 4px; color: var(--danger); }

.report-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.report-tab { padding: 8px 14px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); cursor: pointer; font-size: 13px; color: var(--text-muted); }
.report-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.report-panel { display: none; }
.report-panel.active { display: block; }

.overview-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.overview-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.overview-card h4 { font-size: 14px; color: var(--text-muted); margin-bottom: 8px; }
.overview-amount { font-size: 24px; font-weight: 700; color: var(--primary); }
.overview-sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.overview-total { background: var(--primary-light); }
.overview-total .overview-amount { color: #1e40af; }

.chart-wrap { margin-bottom: 20px; }
.chart-title { font-size: 14px; margin-bottom: 12px; color: var(--text-muted); }
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-item { display: grid; grid-template-columns: 80px 1fr 80px; gap: 10px; align-items: center; font-size: 13px; }
.bar-label { color: var(--text-muted); }
.bar-track { background: #e2e8f0; border-radius: 4px; height: 22px; overflow: hidden; }
.bar-fill { background: var(--primary); height: 100%; border-radius: 4px; min-width: 2px; }
.bar-value { text-align: right; font-weight: 600; }

.stocktake-table input.actual-input { width: 90px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 4px; }

.form-actions-extra { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.status-select { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); }

.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.dash-grid-3 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.dash-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.dash-card h4 { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; font-weight: 500; }
.dash-value { font-size: 26px; font-weight: 700; color: var(--primary); }
.dash-card-sm .dash-value { font-size: 32px; }
.text-warning { color: #d97706; }
.dashboard-section { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.dashboard-section h3 { font-size: 16px; margin-bottom: 16px; }
.section-subtitle { font-size: 14px; margin-bottom: 10px; color: var(--text-muted); }
.dashboard-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.trend-chart { display: flex; flex-direction: column; gap: 8px; }
.trend-row { display: grid; grid-template-columns: 50px 1fr 90px; gap: 10px; align-items: center; font-size: 13px; }
.trend-label { color: var(--text-muted); }
.trend-track { background: #e2e8f0; border-radius: 4px; height: 20px; overflow: hidden; }
.trend-fill { background: var(--primary); height: 100%; border-radius: 4px; }
.trend-val { text-align: right; font-weight: 600; font-size: 12px; }

@media (max-width: 768px) {
  .dashboard-two-col { grid-template-columns: 1fr; }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .sidebar-overlay.open { display: block; }

  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }

  .content-area { padding: 16px; }

  .toolbar { flex-direction: column; }
  .search-bar { width: 100%; }
  .search-bar input,
  .search-bar select { flex: 1; min-width: 0; }

  .form-grid { grid-template-columns: 1fr; }
  .form-group.full-width { grid-column: 1; }

  .modal-dialog { width: 95%; max-height: 85vh; }
}

/* ===== RBAC ===== */
.sidebar-user {
  padding: 8px 12px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 8px;
}
.sidebar-user-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
}
.sidebar-user-role {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  color: #93c5fd;
  background: rgba(37,99,235,.25);
  padding: 1px 6px;
  border-radius: 4px;
}

.rbac-perm-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 16px;
  min-height: 520px;
}
.rbac-user-list, .rbac-perm-panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.rbac-panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.rbac-user-items { list-style: none; }
.rbac-user-item {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 6px;
}
.rbac-user-item:hover { background: #f8fafc; }
.rbac-user-item.active {
  background: var(--primary-light);
  border-color: #bfdbfe;
}
.rbac-user-item strong { display: block; font-size: 14px; }
.rbac-user-item span { font-size: 12px; color: var(--text-muted); }

.rbac-perm-tree { max-height: 600px; overflow-y: auto; }
.rbac-perm-group { margin-bottom: 14px; }
.rbac-check-parent {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  cursor: pointer;
}
.rbac-check-children {
  padding-left: 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rbac-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  padding: 4px 0;
}

@media (max-width: 768px) {
  .rbac-perm-layout { grid-template-columns: 1fr; }
}
