/* ============================================================
   SDS ERP Demo v2 — Design System
   Royal Blue Light Theme (matches erp-demo v1)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ── CSS Tokens ── */
:root {
  /* Sidebar — Royal Blue (same as erp-demo v1) */
  --sidebar-bg:        #0d47a1;
  --sidebar-bg-h:      rgba(255,255,255,0.08);
  --sidebar-text:      rgba(255,255,255,0.85);
  --sidebar-text-h:    #ffffff;
  --sidebar-active-bg: rgba(255,255,255,0.18);
  --sidebar-active-bd: #ffffff;
  --sidebar-group-lbl: rgba(255,255,255,0.5);
  --sidebar-w:         220px;
  --sidebar-w-collapsed: 56px;

  /* Content widths — one scale for the whole app (see .main-inner / .ef-page).
     narrow = simple master-data forms · doc = transactional docs (view+edit
     share this so navigation never reflows) · full = list/dashboard tables. */
  --w-narrow: 720px;
  --w-doc:    1120px;
  --w-full:   1600px;

  /* Topbar — white */
  --topbar-bg:    #1976d2;
  --topbar-bd:    rgba(0,0,0,0.08);
  --topbar-h:     56px;

  /* Page — light gray */
  --page-bg:      #f5f7fa;
  --bg-page:      #f5f7fa;
  --card-bg:      #ffffff;
  --card-bg-2:    #f0f4f8;
  --card-bd:      #e0e0e0;

  /* Text — dark */
  --text-primary: #212121;
  --text-sec:     #424242;
  --text-muted:   #757575;

  /* Accent */
  --accent:       #1976d2;
  --accent-h:     #1256a3;
  --accent-dim:   #e3f2fd;

  /* Status colors */
  --c-green:   #2e7d32;
  --c-yellow:  #f57f17;
  --c-red:     #c62828;
  --c-orange:  #e65100;
  --c-blue:    #1565c0;
  --c-purple:  #6a1b9a;
  --c-gray:    #616161;

  /* Demo banner */
  --demo-banner-bg: #f59e0b;
  --demo-banner-fg: #1f1505;

  /* Spacing */
  --sp-xs: 4px;  --sp-sm: 8px;  --sp-md: 16px;
  --sp-lg: 24px; --sp-xl: 32px; --sp-2xl: 48px;

  /* Radius */
  --r-sm: 4px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px;

  /* Shadow */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.14);

  /* Border */
  --border: #e0e0e0;

  /* Font */
  --font-body: 'Inter','Noto Sans SC',sans-serif;
  --font-mono: 'IBM Plex Mono',monospace;
}

/* ── Reset ── */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body { font-family: var(--font-body); background: var(--page-bg); color: var(--text-primary); line-height: 1.6; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); }
img { max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
input,select,textarea { font-family: inherit; }
table { border-collapse: collapse; width: 100%; }

/* ── Demo Banner ── */
.demo-banner {
  background: var(--demo-banner-bg);
  color: var(--demo-banner-fg);
  text-align: center;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 1000;
}
.demo-banner button {
  background: rgba(0,0,0,0.15);
  color: inherit;
  border: 1px solid rgba(0,0,0,0.25);
  padding: 2px 10px;
  border-radius: var(--r-sm);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.2s;
}
.demo-banner button:hover { background: rgba(0,0,0,0.25); }

/* ── Layout ── */
.layout {
  display: flex;
  height: calc(100vh - 32px);
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.25s ease;
  position: relative;
  z-index: 100;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

.sidebar-logo {
  padding: 16px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}
.sidebar-logo img { width: 32px; height: 32px; }
.sidebar-logo-text { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.2; }
.sidebar-logo-sub { color: var(--sidebar-group-lbl); font-size: 10px; font-weight: 400; }

.sidebar-nav { flex: 1; padding: 8px 0; }

.nav-group-label.active { color: var(--accent); }
.nav-group-label {
  color: var(--sidebar-group-lbl);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 14px 4px;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 400;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  border-left: 3px solid transparent;
  text-decoration: none;
}
.nav-item:hover {
  background: var(--sidebar-bg-h);
  color: var(--sidebar-text-h);
  text-decoration: none;
}
.nav-item.active {
  background: var(--sidebar-active-bg);
  color: #fff;
  border-left-color: var(--sidebar-active-bd);
  font-weight: 500;
}
.nav-item i { width: 18px; text-align: center; font-size: 14px; flex-shrink: 0; opacity: 0.85; }
.nav-item.active i { opacity: 1; }
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 16px; padding: 0 5px;
  background: #fbbf24; color: #000;
  border-radius: 8px; font-size: 10px; font-weight: 700; line-height: 1;
  margin-left: 4px; vertical-align: middle;
}

/* ── Content area ── */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Topbar ── */
.topbar {
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-bd);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-burger {
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  font-size: 18px;
  padding: 4px;
  display: none;
}
.topbar-breadcrumb {
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.topbar-breadcrumb span { color: #ffffff; }
.topbar-spacer { flex: 1; }
.topbar-search {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--r-md);
  padding: 6px 12px;
  color: #ffffff;
  font-size: 13px;
  width: 200px;
  outline: none;
}
.topbar-search::placeholder { color: rgba(255,255,255,0.6); }
.topbar-search:focus { border-color: rgba(255,255,255,0.6); }
.topbar-icon-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  font-size: 16px;
  padding: 6px;
  border-radius: var(--r-md);
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.topbar-icon-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
.topbar-badge {
  position: absolute;
  top: 2px; right: 2px;
  width: 8px; height: 8px;
  background: #fbbf24;
  border-radius: 50%;
}
.topbar-lang {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--r-md);
  color: rgba(255,255,255,0.85);
  font-size: 12px;
  padding: 4px 8px;
  cursor: pointer;
}
.topbar-lang:hover { background: rgba(255,255,255,0.25); color: #fff; }
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--r-md);
  transition: background 0.15s;
}
.topbar-user:hover { background: rgba(255,255,255,0.15); }
.topbar-avatar {
  width: 32px; height: 32px;
  background: rgba(255,255,255,0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}
.topbar-username { font-size: 13px; font-weight: 500; color: rgba(255,255,255,0.9); }
.topbar-date { font-size: 12px; color: rgba(255,255,255,0.65); padding: 0 8px; white-space: nowrap; }
.topbar-divider { width: 1px; height: 20px; background: rgba(255,255,255,0.25); margin: 0 4px; flex-shrink: 0; }

/* ── Main ── */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  min-height: 0;
}
/* Constrain content width on wide monitors for readable row lengths.
   Default = full width for list/dashboard tables. View pages set $layout
   before including header.php to opt into the narrower document tiers, so a
   record's view and edit pages render at the same width (no reflow on nav).
   Left-aligned (margin-inline:0) so the width-capped block hugs the sidebar —
   keeps a small, consistent menu→content gap (just .main padding) instead of
   centering, which left a large empty band on wide screens. */
.main-inner { max-width: var(--w-full); margin-inline: 0; }
.main-inner.is-doc    { max-width: var(--w-doc); }
.main-inner.is-narrow { max-width: var(--w-narrow); }
.main::-webkit-scrollbar { width: 6px; }
.main::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 3px; }

/* ── Page Header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
/* Multi-row header built by renderPageHeader() (sales create/edit/view). Stacks
   .page-head-row / .page-meta-row / .page-proc vertically; raw .page-header pages
   (index/list/view across modules) keep the original title-left / actions-right row. */
.page-header.is-structured {
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: stretch;
  gap: 0;
}
.page-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.page-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.page-proc { margin-top: 6px; }
.page-meta-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; margin-top: 6px; }
.page-meta-row .page-sub { margin-top: 0; }
.page-meta-row .page-actions { margin-left: auto; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.page-actions.is-full { justify-content: flex-start; margin-top: 10px; }

/* ── Alert detail (mailbox-style view) ───────────────────────────────── */
.alert-mail { overflow: hidden; border-top: 3px solid var(--alert-accent, var(--accent)); }
.alert-mail.sev-info     { --alert-accent: var(--c-blue); }
.alert-mail.sev-warning  { --alert-accent: var(--c-orange); }
.alert-mail.sev-critical { --alert-accent: var(--c-red); }
.alert-row { display: flex; align-items: baseline; gap: 12px; padding: 9px 28px; font-size: 13px; border-bottom: 1px solid var(--card-bd); }
.alert-row:last-of-type { border-bottom: 0; }
.alert-row-label { width: 54px; flex-shrink: 0; font-size: 12px; color: var(--text-muted); }
.alert-row-val { flex: 1; min-width: 0; font-weight: 500; color: var(--text-primary); word-break: break-word; }
.alert-row-muted { color: var(--text-muted); font-style: italic; }
.alert-mail-body { padding: 28px; border-top: 1px solid var(--card-bd); font-size: 14px; line-height: 1.85; color: var(--text-primary); }
.alert-mail-ref { padding: 14px 28px; border-top: 1px solid var(--card-bd); background: var(--card-bg-2); }

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-bd);
  border-radius: var(--r-lg);
  /* No overflow:hidden — it clips searchable-select (.ss-panel) dropdowns that
     open past the card edge. .table-wrap self-clips; header corners rounded below. */
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--card-bd);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.card-body { padding: 20px; }
.card-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--card-bd);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Dashboard welcome bar ── */
.welcome-bar {
  background: linear-gradient(135deg, #0e47a1 0%, #1565d8 60%, #1e3a7a 100%);
  border-radius: var(--r-xl);
  padding: 20px 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #fff;
}
.welcome-bar h2 { font-size: 20px; font-weight: 700; margin-bottom: 2px; }
.welcome-bar p { font-size: 13px; color: rgba(255, 255, 255, 0.7); }
.welcome-actions { display: flex; gap: 8px; }

/* ── KPI Card ── */
.kpi-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: 16px; margin-bottom: 24px; }
.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--card-bd);
  border-radius: var(--r-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--kpi-color, var(--accent));
}
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--text-primary); margin: 4px 0; line-height: 1; }
.kpi-value.mono { font-family: var(--font-mono); }
.kpi-sub { font-size: 12px; color: var(--text-muted); }
.kpi-icon { position: absolute; right: 16px; top: 16px; font-size: 24px; opacity: 0.18; color: var(--kpi-color, var(--accent)); }
.kpi-trend { font-size: 12px; margin-top: 4px; }
.kpi-trend.up { color: var(--c-green); }
.kpi-trend.down { color: var(--c-red); }
/* Color modifiers (avoid inline --kpi-color) */
.kpi-card.kpi-blue   { --kpi-color: var(--c-blue); }
.kpi-card.kpi-green  { --kpi-color: var(--c-green); }
.kpi-card.kpi-purple { --kpi-color: var(--c-purple); }
.kpi-card.kpi-amber  { --kpi-color: var(--c-orange); }
.kpi-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
  font-family: inherit;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-h); border-color: var(--accent-h); color: #fff; }
.btn-secondary { background: var(--card-bg-2); color: var(--text-primary); border-color: var(--card-bd); }
.btn-secondary:hover { background: #e0e0e0; border-color: #bdbdbd; }
.btn-danger { background: transparent; color: var(--c-red); border-color: var(--c-red); }
.btn-danger:hover { background: var(--c-red); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-sec); border-color: transparent; }
.btn-ghost:hover { background: var(--card-bg); color: var(--text-primary); }
.btn-success { background: var(--c-green); color: #fff; border-color: var(--c-green); }
.btn-success:hover { filter: brightness(1.1); }
.btn-warning { background: var(--c-amber, #f59e0b); color: #fff; border-color: var(--c-amber, #f59e0b); }
.btn-warning:hover { filter: brightness(1.05); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 15px; }
.btn-icon { padding: 7px; width: 34px; height: 34px; justify-content: center; }
.btn-icon.btn-sm { width: 28px; height: 28px; padding: 4px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Status Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-draft      { background: #f5f5f5;  color: #616161; border: 1px solid #e0e0e0; }
.badge-confirmed  { background: #e8f5e9;  color: #2e7d32; border: 1px solid #c8e6c9; }
.badge-in_production { background: #f3e5f5; color: #6a1b9a; border: 1px solid #e1bee7; }
.badge-ready      { background: #fff8e1;  color: #f57f17; border: 1px solid #ffe082; }
.badge-delivered  { background: #e3f2fd;  color: #1565c0; border: 1px solid #90caf9; }
.badge-cancelled  { background: #ffebee;  color: #c62828; border: 1px solid #ffcdd2; }
.badge-pending    { background: #f5f5f5;  color: #616161; border: 1px solid #e0e0e0; }
.badge-pending_approval { background: #fff8e1; color: #e65100; border: 1px solid #ffe082; }
.badge-approved   { background: #e8f5e9;  color: #2e7d32; border: 1px solid #c8e6c9; }
.badge-rejected   { background: #ffebee;  color: #c62828; border: 1px solid #ffcdd2; }
.badge-in_progress { background: #fff8e1;  color: #f57f17; border: 1px solid #ffe082; }
.badge-completed  { background: #e8f5e9;  color: #2e7d32; border: 1px solid #c8e6c9; }
.badge-qc_failed  { background: #ffebee;  color: #c62828; border: 1px solid #ffcdd2; }
.badge-qc_check   { background: #e3f2fd;  color: #1565c0; border: 1px solid #90caf9; }
.badge-paid       { background: #e8f5e9;  color: #2e7d32; border: 1px solid #c8e6c9; }
.badge-partial    { background: #fff8e1;  color: #f57f17; border: 1px solid #ffe082; }
.badge-overdue    { background: #ffebee;  color: #c62828; border: 1px solid #ffcdd2; }
.badge-unpaid     { background: rgba(239,68,68,0.10); color: #ef4444; border: 1px solid rgba(239,68,68,0.25); }
.badge-issued     { background: #e3f2fd;  color: #1565c0; border: 1px solid #90caf9; }
.badge-returned   { background: #f5f5f5;  color: #616161; border: 1px solid #e0e0e0; }
.badge-active     { background: #e8f5e9;  color: #2e7d32; border: 1px solid #c8e6c9; }
.badge-inactive   { background: #f5f5f5;  color: #616161; border: 1px solid #e0e0e0; }
.badge-low        { background: #fff8e1;  color: #f57f17; border: 1px solid #ffe082; }
.badge-critical   { background: #ffebee;  color: #c62828; border: 1px solid #ffcdd2; }
.badge-info       { background: #e3f2fd;  color: #1565c0; border: 1px solid #90caf9; }
.badge-warning    { background: #fff8e1;  color: #f57f17; border: 1px solid #ffe082; }

/* ── Status Tabs ── */
.status-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--card-bd);
  margin-bottom: 20px;
  overflow-x: auto;
  flex-shrink: 0;
}
.status-tabs::-webkit-scrollbar { height: 2px; }
.tab-item, .status-tab {
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
  margin-bottom: -1px;
}
.tab-item:hover, .status-tab:hover { color: var(--text-primary); text-decoration: none; }
.tab-item.active, .status-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }
.tab-count {
  background: var(--card-bg-2);
  color: var(--text-muted);
  font-size: 11px;
  padding: 0 5px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.tab-item.active .tab-count, .status-tab.active .tab-count { background: var(--accent-dim); color: var(--accent); }

/* ── Data Table ── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-lg);
  border: 1px solid var(--card-bd);
}
.data-table {
  background: var(--card-bg);
  font-size: 13px;
}
.data-table thead tr {
  background: var(--card-bg-2);
  border-bottom: 1px solid var(--card-bd);
}
.data-table th {
  padding: 10px 16px;
  text-align: left;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
/* Alignment utilities must beat `.data-table th` (0,1,1) on header/footer cells. */
.data-table th.text-right { text-align: right; }
.data-table th.text-center { text-align: center; }
.data-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--card-bd);
  color: var(--text-primary);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: #fafafa; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .mono { font-family: var(--font-mono); font-size: 12px; color: var(--accent); }
.data-table .actions { display: flex; gap: 4px; }
.data-table td.actions {
  display: table-cell;
  white-space: nowrap;
}
.data-table td.actions > * {
  display: inline-flex;
  vertical-align: middle;
}
.data-table td.actions > * + * {
  margin-left: 4px;
}
/* col-status: center the cell AND give every badge a uniform min-width with a
   centered label, so badges of different text lengths (生产中 vs 部分付款) form an
   equal-width block — both edges line up, eliminating the jagged column boundary. */
.data-table th.col-status,
.data-table td.col-status { text-align: center; white-space: nowrap; }
.data-table td.col-status .badge {
  min-width: 84px;
  justify-content: center;
}
/* col-actions: shrink to fit content so it never expands unnecessarily */
.data-table th.col-actions,
.data-table td.col-actions { white-space: nowrap; width: 1%; }
.table-wrap-embedded {
  border: 0;
  border-radius: 0;
}
.row-clickable { cursor: pointer; }
.row-total {
  background: var(--card-bg-2);
  border-top: 2px solid var(--card-bd);
  font-weight: 700;
}
.row-overdue { background: rgba(239, 68, 68, 0.04); }
.cell-muted { color: var(--text-muted); font-size: 12px; }
.cell-subtle { color: var(--text-sec); font-size: 12px; }
.cell-small { font-size: 13px; }
.cell-mono { font-family: var(--font-mono); font-size: 12px; }
.cell-right { text-align: right; }
.cell-strong { font-weight: 600; }
.cell-total { font-weight: 700; }
.cell-positive { color: var(--c-green); }
.cell-negative { color: var(--c-red); }
.cell-accent { color: var(--accent); }
.cell-empty {
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
}
.cell-half { width: 50%; }
.cell-wide { width: 60%; }
.color-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--accent);
}

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sec);
  margin-bottom: 6px;
}
.form-label .req { color: var(--c-red); margin-left: 2px; }
.form-control {
  display: block;
  width: 100%;
  background: var(--card-bg-2);
  border: 1px solid var(--card-bd);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled { opacity: 0.5; cursor: not-allowed; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238892a4' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }
select.form-control option { background: #ffffff; color: #212121; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.form-row { display: grid; gap: 16px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.input-group { display: flex; }
.input-group .form-control { border-radius: 0; }
.input-group .form-control:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.input-group .form-control:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; }
.input-prefix,.input-suffix {
  background: var(--card-bg);
  border: 1px solid var(--card-bd);
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  white-space: nowrap;
}
.input-prefix { border-radius: var(--r-md) 0 0 var(--r-md); border-right: none; }
.input-suffix { border-radius: 0 var(--r-md) var(--r-md) 0; border-left: none; }
.checkbox-group { display: flex; flex-direction: column; gap: 8px; }
.checkbox-item { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checkbox-item input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.checkbox-item label { font-size: 13px; color: var(--text-primary); cursor: pointer; }
.checkbox-row { display: flex; flex-wrap: wrap; gap: 12px; }

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  border: 1px solid;
}
.alert i { flex-shrink: 0; margin-top: 1px; }
.alert-success { background: #e8f5e9; border-color: #c8e6c9; color: #2e7d32; }
.alert-error   { background: #ffebee; border-color: #ffcdd2; color: #c62828; }
.alert-warning { background: #fff8e1; border-color: #ffe082; color: #f57f17; }
.alert-info    { background: #e3f2fd; border-color: #90caf9; color: #1565c0; }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state i { font-size: 40px; opacity: 0.3; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 14px; margin-bottom: 16px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--card-bg);
  border: 1px solid var(--card-bd);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-lg { max-width: 800px; }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--card-bd);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 18px; padding: 2px; cursor: pointer; }
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--card-bd); display: flex; justify-content: flex-end; gap: 8px; }

/* ── Pagination ── */
.pagination { display: flex; align-items: center; gap: 4px; justify-content: center; margin-top: 20px; }
.page-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--card-bg);
  border: 1px solid var(--card-bd);
  border-radius: var(--r-md);
  color: var(--text-sec);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Detail Grid ── */
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.detail-card { background: var(--card-bg); border: 1px solid var(--card-bd); border-radius: var(--r-lg); padding: 16px 20px; }

/* KPI summary cards (inventory overview etc.) */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--card-bd); border-radius: var(--r-lg); padding: 16px 18px; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 600; margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.stat-value.mono { font-family: var(--font-mono); }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.detail-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; margin-bottom: 4px; }
.detail-value { font-size: 14px; color: var(--text-primary); font-weight: 500; line-height: 1.4; }
.detail-value.large { font-size: 16px; font-weight: 700; }
.detail-value.mono { font-family: var(--font-mono); font-size: 14px; color: var(--accent); }

/* ── Customer-request product items (triage) ── */
.cr-item { border: 1px solid var(--card-bd); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; }
.cr-item:last-child { margin-bottom: 0; }
.cr-item-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.cr-item-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.cr-item-qty { font-family: var(--font-mono); font-size: 13px; color: var(--accent); }
.cr-item-notes { font-size: 13px; color: var(--text-secondary); margin: 4px 0 10px; white-space: pre-line; }
.cr-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.cr-thumb { width: 76px; height: 76px; border-radius: 8px; overflow: hidden; border: 1px solid var(--card-bd);
  display: flex; align-items: center; justify-content: center; background: var(--page-bg); }
.cr-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cr-thumb i { font-size: 28px; color: var(--text-muted); }
.cr-thumb.is-approved { outline: 2px solid var(--c-green); outline-offset: 1px; }
/* FEAT-01 · SO line-item cards (订单明细) — follows feat01 design demo */
.so-lines { display: flex; flex-direction: column; gap: 12px; }
.so-line { border: 1px solid var(--card-bd); border-radius: var(--r-md); padding: 14px 16px; background: var(--card-bg); }
.so-line-head { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.so-line-no { width: 24px; height: 24px; border-radius: 50%; background: var(--card-bg-2); color: var(--text-sec);
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.so-line-title { flex: 1; min-width: 200px; }
.so-line-name { font-weight: 700; font-size: 14.5px; color: var(--text-primary); }
.so-line-meta { font-size: 12px; color: var(--text-muted); }
.so-line-uid { display: inline-block; margin-top: 5px; font-size: 10.5px; color: var(--text-muted);
  border: 1px dashed var(--card-bd); border-radius: var(--r-sm); padding: 1px 7px; font-family: 'IBM Plex Mono','Consolas',monospace; }
.so-line-money { text-align: right; white-space: nowrap; }
.so-line-money .sub { font-size: 11.5px; color: var(--text-muted); }
.so-line-money .amt { font-weight: 700; font-size: 15px; color: var(--text-primary); font-family: 'IBM Plex Mono','Consolas',monospace; }
.so-line-assets-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 12px; }
@media (max-width: 720px) { .so-line-assets-grid { grid-template-columns: 1fr; } }
.asset-box { border: 1px solid var(--card-bd); border-radius: var(--r-md); padding: 11px 12px; background: var(--page-bg); }
.asset-box-title { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em;
  display: flex; align-items: center; gap: 6px; margin-bottom: 9px; }
.asset-box-title i { color: var(--c-blue); }
.asset-box .cr-thumbs { margin-bottom: 0; }
.asset-box .inline-form { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.asset-tmpl-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.asset-empty { font-size: 13px; color: var(--text-muted); }
.so-line-totals { display: flex; justify-content: flex-end; gap: 28px; margin-top: 4px; padding: 14px 16px 2px;
  border-top: 2px solid var(--card-bd); font-size: 14px; }
.so-line-totals .lbl { color: var(--text-muted); margin-right: 8px; }
.so-line-totals .val { font-weight: 700; font-family: 'IBM Plex Mono','Consolas',monospace; }
/* Bulk "notify all designers" action — bottom of the 订单明细 card. */
.so-design-notify { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 14px; }
/* Merged SO line card: editable top row reuses the old line-items columns
   (product · qty · unit · price · remove); resets .line-item border/padding. */
.so-line .so-line-editrow { display: grid; gap: 8px; align-items: center;
  grid-template-columns: 2fr 1fr 80px 1fr 40px; border-top: 0; padding: 0; }
@media (max-width: 720px) { .so-line .so-line-editrow { grid-template-columns: 1fr; } }
/* 5-step guided flow: section status badge (right-aligned in the flex header) + locked区. */
.ef-section .step-badge, .card-header .step-badge { margin-left: auto; }
.step-badge i { margin-right: 4px; }
.is-locked { opacity: .55; }
.is-locked .ef-body, .is-locked .card-body { pointer-events: none; }
/* 录入引导紧凑分段进度条 (steprail) — separate from the production .prog-* timeline. */
.steprail-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-size: 13px; }
.steprail-title { display: flex; align-items: center; gap: 7px; font-weight: 600; color: var(--text-primary); }
.steprail-title i { color: var(--accent); }
.steprail-count { color: var(--text-muted); font-weight: 500; }
.steprail-track { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.steprail-seg { display: flex; flex-direction: column; align-items: center; gap: 7px; }
.steprail-bar { width: 100%; height: 6px; border-radius: 3px; background: var(--card-bd); }
.steprail-dot { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; background: var(--card-bg); border: 2px solid var(--card-bd); color: var(--text-muted); }
.steprail-label { font-size: 11.5px; line-height: 1.25; text-align: center; color: var(--text-muted); }
.steprail-seg.done .steprail-bar { background: var(--c-green); }
.steprail-seg.done .steprail-dot { border-color: var(--c-green); color: var(--c-green); }
.steprail-seg.done .steprail-label { color: var(--text-primary); }
.steprail-seg.now .steprail-bar { background: var(--accent); }
.steprail-seg.now .steprail-dot { border-color: var(--accent); color: var(--accent); }
.steprail-seg.now .steprail-label { color: var(--accent); font-weight: 600; }
.steprail-next { margin-top: 12px; font-size: 12.5px; font-weight: 500; color: var(--accent); }
@media (max-width: 480px) { .steprail-label { display: none; } }
.ef-sel-sm { padding: 4px 8px; font-size: 12.5px; max-width: 160px; }
.mono-uid { font-size: 11px; color: var(--text-muted); }
.ef-in-sm { max-width: 220px; font-size: 12.5px; padding: 4px 6px; }
.cr-map { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cr-map label { font-size: 12px; color: var(--text-muted); }

/* Align an element that sits between .card-header and .card-body with the
   body content (which uses padding: 20px). Used by the 订单明细 banners + picker. */
.card-inset { margin-left: 20px; margin-right: 20px; }

/* ── Inline production-process picker (sales view 订单明细) ── */
.proc-picker {
  border: 1px solid var(--card-bd);
  border-radius: var(--r-lg);
  background: var(--card-bg);
  overflow: hidden;
}
.proc-picker-head {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 11px 16px;
  background: var(--card-bg-2);
  border-bottom: 1px solid var(--card-bd);
}
.proc-picker-head > i { color: var(--accent); font-size: 14px; }
.proc-picker-title { font-size: 13px; font-weight: 600; color: var(--text-sec); }
.proc-picker-hint  { font-size: 12px; color: var(--text-muted); margin-left: auto; }
.proc-picker-grid,
.proc-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}
/* Panel variant (view 订单明细) pads inside its border; .proc-options (create/edit
   forms) sits flush in the ef-card body, so no extra padding. */
.proc-picker-grid { padding: 16px; }
.proc-option {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 10px 13px;
  border: 1px solid var(--card-bd);
  border-radius: var(--r-md);
  background: var(--card-bg);
  cursor: pointer; user-select: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.proc-option:hover { border-color: var(--accent); background: var(--accent-dim); }
.proc-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.proc-option input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.proc-option-ic {
  flex-shrink: 0; width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--card-bg-2); color: var(--text-muted);
  font-size: 13px; transition: all .15s;
}
.proc-option-lbl { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.proc-option-tick { margin-left: auto; font-size: 12px; color: var(--accent); opacity: 0; transition: opacity .15s; }
.proc-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.proc-option:has(input:checked) .proc-option-ic { background: var(--accent); color: #fff; }
.proc-option:has(input:checked) .proc-option-tick { opacity: 1; }
.proc-picker-foot {
  display: flex; justify-content: flex-end;
  padding: 12px 16px;
  background: var(--card-bg-2);
  border-top: 1px solid var(--card-bd);
}

/* ── Sales-order image gallery (reuses .cr-thumbs/.cr-thumb look) ── */
.so-thumb-wrap { position: relative; display: inline-flex; flex-direction: column; align-items: center; }
.so-thumb-rm {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; padding: 0;
  border: 0; border-radius: 50%; cursor: pointer; line-height: 1; font-size: 11px;
  background: rgba(0,0,0,.6); color: #fff; display: flex; align-items: center; justify-content: center;
}
.so-thumb-rm:hover { background: var(--c-red, #ef4444); }
.so-thumb-src { font-size: 10px; color: var(--text-muted); margin-top: 3px; }
.so-thumb-wrap .cr-thumb { cursor: pointer; }
/* Image lightbox (click a thumbnail to preview large) */
.so-img-lightbox .modal { max-width: 92vw; }
.so-img-lightbox .modal-body { text-align: center; }
.so-img-lightbox .modal-body img { max-width: 100%; max-height: 78vh; border-radius: 8px; }

/* ── 9-Stage Progress Bar ── */
/* P10/P11: 单据号统一样式（高优先级） */
.doc-no,
a .doc-no,
a.doc-no,
.data-table td a .doc-no,
td > a.doc-no,
.mono.doc-no {
  font-weight: 700 !important;
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
}
.data-table td a:hover .doc-no,
.data-table td a.doc-no:hover { text-decoration: underline; text-underline-offset: 3px; }

/* P12 T1: Severity & Role badges */
.badge-severity-red    { background: rgba(239,68,68,0.10);  color: #ef4444; border: 1px solid rgba(239,68,68,0.25); }
.badge-severity-amber  { background: rgba(245,158,11,0.10); color: #f59e0b; border: 1px solid rgba(245,158,11,0.25); }
.badge-severity-blue   { background: rgba(59,130,246,0.10); color: var(--accent); border: 1px solid rgba(59,130,246,0.25); }
.badge-severity-gray   { background: var(--card-bg-2);      color: var(--text-muted); border: 1px solid var(--card-bd); }
.badge-role { padding: 2px 10px; font-weight: 500; }
.badge-role-admin      { background: rgba(239,68,68,0.10);  color: #ef4444; border: 1px solid rgba(239,68,68,0.25); }
.badge-role-manager    { background: rgba(59,130,246,0.10); color: var(--accent); border: 1px solid rgba(59,130,246,0.25); }
.badge-role-sales      { background: rgba(124,58,237,0.10); color: #8b5cf6; border: 1px solid rgba(124,58,237,0.25); }
.badge-role-purchasing { background: rgba(245,158,11,0.10); color: #f59e0b; border: 1px solid rgba(245,158,11,0.25); }
.badge-role-production { background: rgba(34,197,94,0.10);  color: #22c55e; border: 1px solid rgba(34,197,94,0.25); }
.badge-role-qc         { background: rgba(20,184,166,0.10); color: #14b8a6; border: 1px solid rgba(20,184,166,0.25); }
.badge-role-warehouse  { background: var(--card-bg-2);      color: var(--text-sec); border: 1px solid var(--card-bd); }
.badge-role-accounts   { background: rgba(59,130,246,0.10); color: var(--accent); border: 1px solid rgba(59,130,246,0.25); }
.badge-role-staff      { background: var(--card-bg-2);      color: var(--text-muted); border: 1px solid var(--card-bd); }
.badge-received { background: rgba(34,197,94,0.10); color: #22c55e; border: 1px solid rgba(34,197,94,0.25); }
.badge-sent     { background: rgba(59,130,246,0.10); color: var(--accent); border: 1px solid rgba(59,130,246,0.25); }
.badge-partial  { background: rgba(245,158,11,0.10); color: #f59e0b; border: 1px solid rgba(245,158,11,0.25); }

/* P11 T1: Dashboard welcome bar */
.welcome-title { color: #ffffff; font-size: 22px; font-weight: 600; margin: 0; }
.welcome-name { color: #ffffff; font-weight: 700; }

/* P11 T2: 工序图标可读性 — proc-icon (sales/index 列) */
/* Process chips (text pills) — sales list 生产工序 column */
.proc-chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.proc-chip {
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1.4;
}
.proc-chip-transfer   { background: #faeeda; color: #854f0b; }
.proc-chip-laser      { background: #fcebeb; color: #a32d2d; }
.proc-chip-sew        { background: #e1f5ee; color: #0f6e56; }
.proc-chip-printing   { background: #eef2ff; color: #4338ca; }
.proc-chip-embroidery { background: #fce7f3; color: #be185d; }
.proc-chip-heatpress  { background: #ffedd5; color: #c2410c; }
.proc-chip-adhoc      { background: #e2e8f0; color: #475569; }
.proc-chip-none       { background: #f1efea; color: #888780; }

/* ── Sales view: production progress timeline ── */
.prog-timeline { display: grid; grid-template-columns: repeat(5, 1fr); position: relative; padding: 8px 0 6px; margin: 8px 0 4px; }
.prog-node { display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; z-index: 2; }
.prog-circle { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 15px; background: var(--card-bg); flex-shrink: 0; transition: all .2s ease; }
.prog-circle.done { background: #0f6e56; color: #fff; }
.prog-circle.now { background: #185fa5; color: #fff; box-shadow: 0 0 0 4px rgba(24,95,165,.18); }
.prog-circle.future { background: var(--card-bg); color: #b4b2a9; border: 1.5px solid var(--card-bd); }
.prog-label { font-size: 13px; font-weight: 500; margin-top: 2px; }
.prog-label.done { color: var(--text-primary); }
.prog-label.now { color: #185fa5; }
.prog-label.future { color: var(--text-muted); }
.prog-sub { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); white-space: nowrap; }
.prog-status-tag { font-size: 10px; padding: 2px 8px; border-radius: 4px; font-weight: 500; background: #e6f1fb; color: #185fa5; white-space: nowrap; }
.prog-bar { position: absolute; top: 23px; height: 2px; z-index: 1; }
.prog-bar-1 { left: 10%; right: 70%; } .prog-bar-2 { left: 30%; right: 50%; }
.prog-bar-3 { left: 50%; right: 30%; } .prog-bar-4 { left: 70%; right: 10%; }
.prog-bar.done { background: #0f6e56; } .prog-bar.future { background: #e2e2dd; }
@media (max-width: 768px) {
  .prog-timeline { grid-template-columns: 1fr; gap: 14px; }
  .prog-node { flex-direction: row; justify-content: flex-start; gap: 12px; }
  .prog-bar { display: none; }
}

/* Related-record rows (sales view) */
.stage-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--card-bg-2); border-radius: var(--r-md); font-size: 13px; cursor: pointer; transition: background .15s; margin-bottom: 6px; }
.stage-row:last-child { margin-bottom: 0; }
.stage-row:hover { background: var(--accent-dim); }
.stage-row .stage-lbl { color: var(--text-muted); font-size: 12px; margin-right: 8px; }

/* Production-gate banner (sales view) */
.gate-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-radius: var(--r-lg); margin-bottom: 16px; font-size: 14px; }
.gate-banner .gate-msg { display: flex; align-items: center; gap: 10px; }
.gate-banner.warn { background: rgba(245,158,11,.1); border-left: 4px solid #f59e0b; color: #92400e; }
.gate-banner.ok { background: rgba(34,197,94,.1); border-left: 4px solid #22c55e; color: #15803d; }
.gate-banner.info { background: rgba(59,130,246,.1); border-left: 4px solid #3b82f6; color: #1e40af; }
.gate-banner.locked { background: rgba(245,158,11,.08); color: #92400e; }
.gate-banner.unlocked { background: rgba(34,197,94,.08); color: #166534; }
.track-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.proc-icons { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.proc-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 4px;
  font-size: 11px; font-weight: 700;
  border: 1px solid var(--card-bd);
  background: transparent;
  color: var(--text-muted);
  transition: all 0.15s ease;
}
.proc-icon.on { color: #fff; border-color: transparent; }
.proc-icon.transfer.on { background: #f59e0b; }
.proc-icon.laser.on    { background: var(--c-red, #ef4444); }
.proc-icon.sewing.on   { background: #14b8a6; }
.proc-icon.printing.on   { background: #6366f1; }
.proc-icon.embroidery.on { background: #ec4899; }
.proc-icon.heat_press.on { background: #f97316; }
.proc-icon.adhoc.on      { background: #64748b; }

.pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0 12px;
}
.pipeline-stage { flex-shrink: 0; min-width: 120px; }
@media (max-width: 768px) {
  .pipeline-stage { flex: 0 0 auto !important; min-width: 90px !important; }
}
.pipeline::-webkit-scrollbar { height: 3px; }
.pipeline-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 80px;
  position: relative;
  cursor: pointer;
}
.pipeline-stage:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 16px;
  left: calc(50% + 16px);
  right: calc(-50% + 16px);
  height: 2px;
  background: var(--card-bd);
}
.pipeline-stage.done::after { background: var(--c-green); }
.pipeline-stage.active::after { background: var(--accent); }
.pipeline-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--card-bg-2);
  border: 2px solid var(--card-bd);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  color: var(--text-muted);
  transition: all 0.2s;
  z-index: 1;
}
.pipeline-stage.done .pipeline-dot { background: var(--c-green); border-color: var(--c-green); color: #fff; }
.pipeline-stage.active .pipeline-dot { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 0 0 4px var(--accent-dim); }
.pipeline-stage.skipped .pipeline-dot { opacity: 0.3; }
.pipeline-label { font-size: 11px; color: var(--text-muted); margin-top: 6px; text-align: center; white-space: nowrap; }
.pipeline-stage.done .pipeline-label { color: var(--c-green); }
.pipeline-stage.active .pipeline-label { color: var(--accent); font-weight: 600; }
.pipeline-count { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

/* ── Process Icons (SO requirements) ── */
.proc-icons { display: flex; gap: 4px; }
.proc-icon {
  width: 20px; height: 20px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  opacity: 0.25;
}
.proc-icon.on { opacity: 1; }
.proc-icon.transfer  { background: #fff8e1; color: #f57f17; }
.proc-icon.laser     { background: #ffebee; color: #c62828; }
.proc-icon.sewing    { background: #e8f5e9; color: #2e7d32; }
.proc-icon.printing   { background: #eef2ff; color: #6366f1; }
.proc-icon.embroidery { background: #fce7f3; color: #ec4899; }
.proc-icon.heat_press { background: #ffedd5; color: #f97316; }
.proc-icon.adhoc      { background: #e2e8f0; color: #64748b; }

/* ── Grid layouts ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ── Section spacing ── */
.section { margin-bottom: 24px; }
.section-title { font-size: 14px; font-weight: 600; color: var(--text-sec); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.section-title i { color: var(--accent); }

/* ── Timeline ── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item { display: flex; gap: 12px; padding: 10px 0; border-left: 2px solid var(--card-bd); margin-left: 8px; padding-left: 16px; position: relative; }
.timeline-item::before { content: ''; position: absolute; left: -5px; top: 16px; width: 8px; height: 8px; border-radius: 50%; background: var(--card-bd); }
.timeline-item:last-child { border-left-color: transparent; }
.timeline-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }
.timeline-content { font-size: 13px; color: var(--text-sec); }

/* ── Search bar ── */
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.search-bar .ef-sel { width: auto; }
.ef-inline-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }

/* ── Searchable select (entity dropdowns) ── */
.ss-wrap { position: relative; width: 100%; }
.ss-native { display: none !important; }
.ss-trigger {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; min-height: 38px; padding: 8px 12px;
  background: var(--card-bg); border: 1px solid var(--card-bd);
  border-radius: var(--r-md); font-size: 14px; color: var(--text-primary);
  cursor: pointer; user-select: none; box-sizing: border-box; line-height: 1.4;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ss-trigger:focus, .ss-trigger.open {
  border-color: var(--accent); outline: none;
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.ss-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: inherit; }
.ss-label.ss-placeholder { color: var(--text-muted); }
.ss-arrow { flex-shrink: 0; margin-left: 8px; font-size: 11px; color: var(--text-muted); transition: transform 0.2s ease; }
.ss-trigger.open .ss-arrow { transform: rotate(180deg); }
.ss-panel {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 300;
  background: var(--card-bg); border: 1px solid var(--card-bd);
  border-radius: var(--r-lg); box-shadow: 0 8px 24px rgba(0,0,0,0.12); overflow: hidden;
}
.ss-hidden { display: none !important; }
.ss-search-wrap {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid var(--card-bd); background: var(--card-bg); color: var(--text-muted);
}
.ss-input { flex: 1; border: none; background: transparent; outline: none; font-size: 13px; color: var(--text-primary); font-family: inherit; padding: 0; min-width: 0; }
.ss-input::placeholder { color: var(--text-muted); }
.ss-list { list-style: none; margin: 0; padding: 4px 0; max-height: 220px; overflow-y: auto; }
.ss-list li { padding: 8px 12px; cursor: pointer; font-size: 13px; color: var(--text-primary); line-height: 1.4; transition: background 0.1s; }
.ss-list li:hover, .ss-list li.ss-active { background: var(--accent-dim); }
.ss-add-option { border-left: 3px solid #f59e0b; color: #92400e; background: #fef9ee; font-weight: 500; }
.ss-add-option:hover, .ss-add-option.ss-active { background: #fef3c7; }
.ss-highlight { background: var(--accent-dim); border-radius: 2px; font-style: normal; }
.ss-empty { color: var(--text-muted); font-size: 12px; padding: 12px; text-align: center; cursor: default; }
.ss-empty:hover { background: transparent; }
.ss-list::-webkit-scrollbar { width: 4px; }
.ss-list::-webkit-scrollbar-thumb { background: var(--card-bd); border-radius: 2px; }
.search-input { flex: 1; min-width: 200px; max-width: 340px; }

/* ── Factory filter wrapper (search-bar context) ── */
.factory-filter-wrap { position: relative; display: inline-flex; align-items: stretch; }
.factory-filter-wrap .ss-wrap { width: auto; min-width: 180px; max-width: 260px; }
.factory-filter-wrap .ss-trigger { padding-left: 30px; }
.factory-filter-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 12px; color: var(--text-muted); pointer-events: none; z-index: 2;
  transition: color 0.15s;
}
.factory-filter-wrap.is-active .factory-filter-icon { color: var(--accent); }
.factory-filter-wrap.is-active .ss-trigger {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.factory-filter-wrap.is-active .ss-label { color: var(--accent); font-weight: 500; }
.factory-filter-wrap.is-active .ss-arrow { color: var(--accent); }

/* ── Dynamic rows (line items) ── */
.line-items { border: 1px solid var(--card-bd); border-radius: var(--r-md); overflow: hidden; }
.line-items-header { display: grid; gap: 8px; padding: 8px 12px; background: var(--card-bg-2); font-size: 11px; color: var(--text-muted); text-transform: uppercase; font-weight: 600; }
.line-item { display: grid; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--card-bd); align-items: center; }
.line-item .form-control { margin: 0; }
/* FEAT-02: fabric on-hand hint under the line-item product select */
.line-stock { margin-top: 4px; }
.line-stock:empty { display: none; }
/* FEAT-02: 卖布料/生产 tab — hide the 生产工序 panel in fabric-sale mode */
#proc-body.hidden { display: none; }
.line-items-footer { padding: 10px 12px; border-top: 1px solid var(--card-bd); background: var(--card-bg-2); display: flex; justify-content: space-between; align-items: center; }

/* SO line-item column layout: product | qty | unit | unit_price | remove */
.line-items.li-cols-so .line-items-header,
.line-items.li-cols-so .line-item { grid-template-columns: 2fr 1fr 80px 1fr 40px; }
@media (max-width: 720px) {
  .line-items.li-cols-so .line-items-header,
  .line-items.li-cols-so .line-item { grid-template-columns: 1fr; }
}

/* Work-order 工序明细 column layout: type | assignee | qty | deadline | remove */
.line-items.li-cols-wo .line-items-header,
.line-items.li-cols-wo .line-item { grid-template-columns: 1.3fr 1.3fr 1fr 1fr 40px; }
@media (max-width: 720px) {
  .line-items.li-cols-wo .line-items-header,
  .line-items.li-cols-wo .line-item { grid-template-columns: 1fr; }
}

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--card-bd); margin: 20px 0; }

/* ── Chart container ── */
.chart-container { position: relative; height: 260px; }

/* ── Floating action button ── */
.fab-container { position: fixed; bottom: 28px; right: 28px; z-index: 200; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.fab-main { width: 52px; height: 52px; border-radius: 50%; background: var(--accent); border: none; color: #fff; font-size: 22px; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-lg); cursor: pointer; transition: all 0.2s; }
.fab-main:hover { background: var(--accent-h); transform: scale(1.05); }
.fab-actions { display: none; flex-direction: column; gap: 6px; align-items: flex-end; }
.fab-actions.open { display: flex; }
.fab-action { display: flex; align-items: center; gap: 8px; cursor: pointer; text-decoration: none; }
.fab-action-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--card-bg); border: 1px solid var(--card-bd); color: var(--text-primary); font-size: 16px; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm); transition: all 0.15s; }
.fab-action-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.fab-action-label { background: var(--card-bg); color: var(--text-primary); padding: 4px 10px; border-radius: var(--r-md); font-size: 12px; box-shadow: var(--shadow-sm); white-space: nowrap; }

/* ── Responsive ── */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1023px) {
  .sidebar { width: var(--sidebar-w-collapsed); }
  .sidebar-logo-text,.sidebar-logo-sub,.nav-group-label,.nav-item span { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .nav-item i { width: auto; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row-3 { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 767px) {
  .layout { height: auto; overflow: visible; flex-direction: column; }
  .sidebar { display: none; width: 0; min-width: 0; }
  .sidebar.open { display: flex; position: fixed; inset: 0; width: var(--sidebar-w) !important; z-index: 500; }
  .topbar-burger { display: block; }
  .main { padding: 16px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .grid-2,.grid-3,.grid-4 { grid-template-columns: 1fr; }
  .form-row-2,.form-row-3 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .topbar-search { display: none; }
  .page-header { flex-direction: column; }
  .page-head-row { flex-direction: column; }
  .welcome-bar { flex-direction: column; align-items: flex-start; }
  .welcome-actions { flex-wrap: wrap; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .pipeline-stage { min-width: 60px; }
  .pipeline-label { font-size: 9px; }
}

/* ═══════════════════════════════════════════════
   主题化 Modal (app.alert/confirm/prompt)
   ═══════════════════════════════════════════════ */
.app-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  animation: appModalFadeIn 200ms ease;
  padding: 20px;
}
.app-modal-overlay.app-modal-closing { animation: appModalFadeOut 200ms ease forwards; }
.app-modal {
  background: var(--card-bg, #181c25);
  border: 1px solid var(--card-bd, rgba(255,255,255,0.13));
  border-radius: var(--r-lg, 16px);
  width: 100%; max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  animation: appModalSlideUp 250ms cubic-bezier(0.16,1,0.3,1);
  overflow: hidden;
}
.app-modal-header {
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--card-bd, rgba(255,255,255,0.07));
  display: flex; align-items: center; gap: 10px;
}
.app-modal-header h3 { margin: 0; font-size: 16px; font-weight: 600; color: var(--text-primary, #212121); }
.app-modal-header i { font-size: 18px; }
.app-modal-body {
  padding: 18px 24px;
  color: var(--text-sec, #b0b8cc);
  font-size: 14px; line-height: 1.6; min-height: 40px;
}
.app-modal-body p { margin: 0 0 8px; }
.app-modal-body p:last-child { margin-bottom: 0; }
.app-modal-input {
  width: 100%; margin-top: 12px;
  padding: 10px 12px;
  background: var(--card-bg-2, #1e2332);
  border: 1px solid var(--card-bd, rgba(255,255,255,0.13));
  border-radius: 6px;
  color: var(--text-primary, #212121);
  font-size: 14px; font-family: inherit;
  transition: border-color 150ms, box-shadow 150ms;
}
.app-modal-input:focus {
  outline: none;
  border-color: var(--accent, #4f8ef7);
  box-shadow: 0 0 0 3px rgba(79,142,247,0.15);
}
.app-modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 24px 20px;
  background: var(--card-bg-2, #1e2332);
  border-top: 1px solid var(--card-bd, rgba(255,255,255,0.07));
}
.btn-success { background: var(--c-green, #22c55e); color: #fff; border-color: var(--c-green, #22c55e); }
.btn-success:hover { background: #16a34a; }
.btn-danger { background: var(--c-red, #ef4444); color: #fff; border-color: var(--c-red, #ef4444); }
.btn-danger:hover { background: #dc2626; }
@keyframes appModalFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes appModalFadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes appModalSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Toast */
.app-toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 20px; border-radius: 10px;
  font-size: 14px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 10000; opacity: 0;
  transition: opacity 250ms, transform 250ms;
  max-width: 90vw;
}
.app-toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }
.app-toast-success { background: var(--c-green, #22c55e); color: #fff; }
.app-toast-error   { background: var(--c-red, #ef4444); color: #fff; }
.app-toast-info    { background: var(--accent, #4f8ef7); color: #fff; }
.app-toast-warning { background: var(--c-amber, #f59e0b); color: #1f1505; }

@media (max-width: 480px) {
  .app-modal { max-width: 100%; }
  .app-modal-header, .app-modal-body, .app-modal-footer { padding-left: 18px; padding-right: 18px; }
}

/* ═══════════════════════════════════════════════
   打印样式优化 (P8)
   ═══════════════════════════════════════════════ */
.print-container { display: none; }

@media print {
  /* 隐藏屏幕 UI */
  .demo-banner, .sidebar, .topbar, .page-header, .page-actions,
  .print-actions, .modal-overlay, .app-modal-overlay, .app-toast-container,
  nav, footer, .btn { display: none !important; }

  body { background: #fff !important; color: #000 !important; font-size: 12pt; line-height: 1.4; margin: 0; padding: 0; }
  .layout, .content, .main { display: block !important; margin: 0 !important; padding: 0 !important; background: #fff !important; }

  /* 仅显示打印容器 */
  .print-container { display: block !important; width: 100% !important; max-width: none !important;
    margin: 0 !important; padding: 15mm 12mm !important; background: #fff !important; color: #000 !important;
    box-shadow: none !important; border: none !important; }

  .print-header { margin-bottom: 14pt; }
  .print-header h1 { font-size: 20pt; font-weight: bold; margin: 0 0 4pt; color: #000; }
  .print-doc-no { font-size: 14pt; font-weight: bold; font-family: monospace; }

  .print-container table { width: 100% !important; border-collapse: collapse !important; page-break-inside: avoid; margin-bottom: 12pt; }
  .print-container table th, .print-container table td { border: 1px solid #333 !important; padding: 6pt 8pt !important; color: #000 !important; background: #fff !important; font-size: 11pt; }
  .print-container table th { font-weight: bold; background: #f0f0f0 !important; }
  .print-container .info-table td { border: none !important; padding: 4pt 8pt !important; }

  .print-container .amount-total { font-size: 14pt !important; font-weight: bold !important; color: #000 !important; }
  .barcode-container { text-align: center; margin: 12pt 0; page-break-inside: avoid; }

  .signature-area { margin-top: 36pt; page-break-inside: avoid; }
  .signature-box { display: inline-block; width: 30%; margin-right: 3%; text-align: center; vertical-align: top; }
  .signature-line { border-top: 1px solid #000; margin-top: 28pt; padding-top: 4pt; font-size: 10pt; }

  .print-footer { margin-top: 30pt; font-size: 9pt; color: #555; border-top: 1px solid #ccc; padding-top: 8pt; text-align: center; }

  p, h1, h2, h3, h4, h5, h6 { orphans: 3; widows: 3; }
  .page-break { page-break-before: always; }

  /* 草稿水印 */
  body.status-draft .print-container::before { content: "草   稿"; position: fixed; top: 40%; left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg); font-size: 100pt; font-weight: bold;
    color: rgba(0,0,0,0.08); z-index: 9999; pointer-events: none; white-space: nowrap; }
}

/* ============================================
   Dashboard Chart Card — Donut (本周生产工单状态)
   Added: 2026-05-07
   ============================================ */
.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.chart-card-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm, 8px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.card-icon-blue {
  background: var(--blue-bg, rgba(79,142,247,0.12));
  color: var(--accent, #4f8ef7);
}
.card-sub {
  font-size: 12px;
  color: var(--muted, #94a3b8);
  margin-top: 2px;
}

/* Auto-filled field (米数↔kg 换算建议) */
.field-auto-filled {
  background: var(--blue-bg, rgba(79,142,247,0.12)) !important;
  border-color: var(--accent, #4f8ef7) !important;
}
.field-auto-filled:focus {
  background: var(--surface2, #fff) !important;
}
.density-hint { font-size: 11px; color: var(--accent); margin-top: 4px; }
.diff-hint { display:block; font-size:11px; margin-top:4px; font-weight:600; }

/* Segmented toggle */
.seg-toggle {
  display: inline-flex;
  background: var(--surface2, rgba(255,255,255,0.04));
  border: 1px solid var(--border, rgba(255,255,255,0.07));
  border-radius: var(--r-sm, 6px);
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}
.seg-btn {
  border: none;
  background: transparent;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 4px;
  color: var(--muted, #94a3b8);
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 500;
}
.seg-btn.active {
  background: var(--surface3, rgba(255,255,255,0.08));
  color: var(--text-primary, #212121);
}
.seg-btn:not(.active):hover {
  color: var(--text-primary, #212121);
}
.seg-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Donut layout */
.donut-wrap {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 28px;
  align-items: center;
  padding: 16px 20px !important;
}
.donut-chart-area {
  position: relative;
  width: 200px;
  height: 200px;
}
.donut-chart-area canvas {
  width: 100% !important;
  height: 100% !important;
}
.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
}
.donut-center-label {
  font-size: 11px;
  color: var(--muted, #94a3b8);
  letter-spacing: 0.5px;
  font-weight: 500;
}
.donut-center-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary, #212121);
  line-height: 1;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.donut-center-trend {
  font-size: 11px;
  color: var(--muted, #94a3b8);
  margin-top: 6px;
}

/* Legend rows */
.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--r-sm, 8px);
  border-left: 3px solid;
  transition: transform 0.15s ease;
}
.legend-row:hover {
  transform: translateX(2px);
}
.legend-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
.legend-value-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.legend-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary, #212121);
  font-variant-numeric: tabular-nums;
}
.legend-pct {
  font-size: 11px;
  color: var(--muted, #94a3b8);
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Status color variants */
.legend-pending {
  background: rgba(148, 163, 184, 0.08);
  border-left-color: #94a3b8;
}
.legend-pending .legend-dot { background: #94a3b8; }

.legend-progress {
  background: var(--blue-bg, rgba(79, 142, 247, 0.10));
  border-left-color: var(--accent, #4f8ef7);
}
.legend-progress .legend-dot { background: var(--accent, #4f8ef7); }

.legend-done {
  background: var(--green-bg, rgba(34, 197, 94, 0.10));
  border-left-color: var(--green, #22c55e);
}
.legend-done .legend-dot { background: var(--green, #22c55e); }

.legend-fail {
  background: var(--red-bg, rgba(239, 68, 68, 0.10));
  border-left-color: var(--red, #ef4444);
}
.legend-fail .legend-dot { background: var(--red, #ef4444); }

/* Chart card footer */
.chart-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px !important;
  border-top: 1px solid var(--border, rgba(255,255,255,0.07));
}
.footer-alert {
  font-size: 12px;
  color: var(--muted, #94a3b8);
  display: flex;
  align-items: center;
  gap: 6px;
}
.footer-alert i {
  color: var(--amber, #f59e0b);
}
.footer-link {
  font-size: 12px;
  color: var(--accent, #4f8ef7);
  text-decoration: none;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: gap 0.15s ease;
}
.footer-link:hover { gap: 8px; }

/* Empty state */
.donut-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 32px 16px;
  color: var(--muted, #94a3b8);
  font-size: 13px;
}

/* Responsive */
@media (max-width: 768px) {
  .donut-wrap {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .donut-chart-area {
    margin: 0 auto;
  }
}

/* ── Spacing utilities (added MIG-01 Gate B fix) ── */
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.text-right { text-align: right; }

/* ── Section heading (report sub-tables) ── */
.section-heading { font-size: 15px; font-weight: 600; color: var(--text-primary); margin: 0 0 10px; }

/* ── Reports center cards (MIG-28) ── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.report-card { text-decoration: none; color: inherit; transition: box-shadow .15s, transform .15s; }
.report-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); transform: translateY(-2px); }
.report-card-icon { font-size: 28px; color: var(--accent); margin-bottom: 12px; }
.report-card-title { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.report-card-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.report-card-link { font-size: 13px; font-weight: 600; color: var(--accent); }

/* ── Extra-small button (table action cells) ── */
.btn-xs { padding: 2px 8px; font-size: 11px; }
.btn-icon.btn-xs { width: 24px; height: 24px; padding: 2px; }

/* ── Inline form (replaces style="display:inline") ── */
.inline-form { display: inline; }

/* ── Alert list (replaces style="margin:0;padding-left:16px") ── */
.alert .alert-list { margin: 0; padding-left: 16px; }

/* ── Totals display (replaces inline font-size/color on #totals-display) ── */
.totals-display { font-size: 13px; color: var(--text-sec); }

/* ── Print: sales order (Option A — token-based) ── */
.print-doc-title { font-size: 20px; font-weight: 700; margin: 16px 0 4px; color: var(--text-primary); }
.print-doc-meta  { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.print-doc-note  { font-size: 13px; margin-top: 16px; }

@media print {
  .print-doc-title { font-size: 20pt; font-weight: 700; margin: 0 0 4pt; }
  .print-doc-meta  { font-size: 13pt; margin-bottom: 16pt; }
  .print-doc-note  { font-size: 11pt; margin-top: 12pt; }
}

/* ── Audit listing + force-edit support (Phase 1) ───────────────────── */
.filter-bar { background: var(--card-bg); border: 1px solid var(--card-bd); border-radius: var(--r-lg, 12px); padding: 12px 16px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.filter-group { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.filter-group-grow { flex: 1 1 200px; }
.filter-label { font-size: 12px; color: var(--text-muted); }
.filter-actions { display: flex; gap: 6px; }
.empty-cell { text-align: center; color: var(--text-muted); padding: 20px; }
.badge-danger { background: #fde2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.audit-diff-reason { padding: 10px 12px; background: var(--card-bg-2, rgba(0,0,0,.03)); border-radius: var(--r-md, 8px); margin-bottom: 12px; font-size: 13px; }
.audit-diff-table { margin-bottom: 12px; }
.audit-diff-table th, .audit-diff-table td { padding: 6px 10px; font-size: 12px; }
.audit-diff-cascade { padding: 10px 12px; background: #fef3c7; border-radius: var(--r-md, 8px); }
.audit-diff-cascade ul { margin: 4px 0 0 16px; padding: 0; font-size: 12px; }
.audit-diff-cascade li { margin: 2px 0; font-family: var(--font-mono); }
/* Force-edit banner (appears at top of locked-but-unlockable edit pages) */
.force-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px;
                background: #fff8e1; border: 1px solid #ffe082; color: #92400e;
                border-radius: var(--r-md, 8px); padding: 10px 14px; margin-bottom: 16px; }
.force-banner .fb-msg { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.force-banner .fb-msg i { color: #f59e0b; font-size: 16px; }
.force-banner.force-unlocked { background: #fef3c7; border-color: #fbbf24; }
.force-banner.force-unlocked .force-edit-btn { display: none; }
.force-banner.force-unlocked .fb-msg-locked { display: none; }
.force-banner .fb-msg-unlocked { display: none; }
.force-banner.force-unlocked .fb-msg-unlocked { display: inline; font-weight: 600; color: #92400e; }
/* Cascade re-open notice (appears on view.php of records with non-null force_note) */
.force-note-banner { background: #fef3c7; border: 1px solid #fcd34d; color: #92400e;
                     border-radius: var(--r-md, 8px); padding: 10px 14px; margin-bottom: 16px;
                     display: flex; align-items: center; gap: 8px; font-size: 13px; }

/* ═══════════════════════════════════════════════
   Designer-system additions (ui-ux-pro-max pass)
   ═══════════════════════════════════════════════ */

/* ── Supplementary invoice badge ("追加款") ── */
.badge-supplement { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* ── Large document-number heading (view page h1 area) ── */
/* Use on .page-title when the document number IS the title */
.page-title.doc-heading {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ── Record-count display near search bars ── */
/* <span class="record-count">共 <strong>N</strong> 条</span> */
.record-count {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.record-count strong { color: var(--text-primary); font-weight: 600; }

/* ── Currency badge (render currency code as a soft badge) ── */
/* <span class="badge badge-currency">RMB</span> */
.badge-currency { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; font-family: var(--font-mono); }

/* ── Table cell: name + sub-name (bilingual name cells) ── */
.cell-name { font-weight: 500; }
.cell-name-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* ── Table: two-line header (column label + unit hint) ── */
.th-unit { font-size: 10px; font-weight: 400; color: var(--text-muted); text-transform: none; letter-spacing: 0; display: block; margin-top: 1px; }

/* ── Hover: all .row-clickable rows must show pointer ── */
/* Already set on .row-clickable; this reinforces it for data-table rows with onclick */
.data-table tbody tr[onclick] { cursor: pointer; }

/* ── View page: info strip (doc-no + status inline) ── */
.page-doc-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.page-doc-strip .doc-no { font-size: 20px; font-weight: 700; letter-spacing: 0.01em; }

/* ── Detail card: icon accent row ── */
.detail-card-icon {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  margin-bottom: 10px;
}
.detail-card-icon.blue   { background: var(--accent-dim); color: var(--accent); }
.detail-card-icon.green  { background: #e8f5e9; color: var(--c-green); }
.detail-card-icon.amber  { background: #fff8e1; color: var(--c-yellow); }
.detail-card-icon.purple { background: #f3e5f5; color: var(--c-purple); }

/* ── KPI card: red variant ── */
.kpi-card.kpi-red { --kpi-color: var(--c-red); }

/* ── Progress bar: "now" active segment ── */
.prog-bar.now { background: var(--accent); }

/* ── Search bar: result feedback row ── */
.search-result-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  min-height: 20px;
}

/* ── Table: action column — no wrap, shrink to fit ── */
/* Already on .col-actions; alias for modules that use class="actions-col" */
.data-table th.actions-col,
.data-table td.actions-col { white-space: nowrap; width: 1%; }

/* ── Soft section divider with label ── */
.section-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.section-divider::before, .section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--card-bd);
}
.section-divider::before { display: none; }
.force-note-banner i { color: #d97706; font-size: 16px; }
