/* ═══════════════════════════════════════════════════════════
   Jiatean ERP — Premium Design System v2
   Shared across all ERP pages via erp-shell.js injection.
═══════════════════════════════════════════════════════════ */

/* ── DESIGN TOKENS ── */
:root {
  /* Layout */
  --sb-w:    240px;
  --sb-col:   64px;
  --hdr-h:    60px;

  /* Brand */
  --c-pri:      #1e3a5f;
  --c-pri-h:    #254f82;
  --c-pri-rgb:  30,58,95;
  --c-acc:      #e67e22;
  --c-acc-h:    #d16c12;
  --c-acc-rgb:  230,126,34;

  /* Surfaces */
  --c-bg:       #f0f4f8;
  --c-surface:  #ffffff;
  --c-surface-2:#f8fafc;
  --c-surface-3:#f1f5f9;

  /* Text */
  --c-text:     #0f172a;
  --c-text-2:   #334155;
  --c-muted:    #64748b;
  --c-muted-2:  #94a3b8;

  /* Borders */
  --c-bdr:      #e2e8f0;
  --c-bdr-2:    #cbd5e1;

  /* Semantic */
  --c-ok:       #16a34a;
  --c-ok-bg:    #f0fdf4;
  --c-ok-bdr:   #bbf7d0;
  --c-warn:     #d97706;
  --c-warn-bg:  #fffbeb;
  --c-warn-bdr: #fde68a;
  --c-err:      #dc2626;
  --c-err-bg:   #fef2f2;
  --c-err-bdr:  #fecaca;
  --c-info:     #2563eb;
  --c-info-bg:  #eff6ff;
  --c-info-bdr: #bfdbfe;

  /* Sidebar (always dark) */
  --sb-bg:         #0f172a;
  --sb-bg-h:       rgba(255,255,255,.055);
  --sb-bg-active:  rgba(255,255,255,.1);
  --sb-text:       rgba(148,163,184,.82);
  --sb-text-h:     #e2e8f0;
  --sb-text-active:#f8fafc;
  --sb-bdr:        rgba(255,255,255,.065);
  --sb-section:    rgba(148,163,184,.35);

  /* Shadows */
  --sh-xs: 0 1px 2px rgba(0,0,0,.05);
  --sh-sm: 0 1px 4px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --sh-md: 0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.03);
  --sh-lg: 0 12px 40px rgba(0,0,0,.11), 0 4px 14px rgba(0,0,0,.05);
  --sh-focus: 0 0 0 3px rgba(var(--c-pri-rgb),.15);

  /* Shape */
  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* Motion */
  --t:      .18s ease;
  --t-slow: .28s cubic-bezier(.4,0,.2,1);
}

/* ── DARK MODE ── */
[data-theme="dark"] {
  --c-bg:       #0a0f1e;
  --c-surface:  #111827;
  --c-surface-2:#0f172a;
  --c-surface-3:#0a0f1e;
  --c-text:     #f1f5f9;
  --c-text-2:   #cbd5e1;
  --c-muted:    #94a3b8;
  --c-muted-2:  #64748b;
  --c-bdr:      #1e293b;
  --c-bdr-2:    #334155;
  --c-ok-bg:    rgba(22,163,74,.12);
  --c-ok-bdr:   rgba(22,163,74,.3);
  --c-warn-bg:  rgba(217,119,6,.12);
  --c-warn-bdr: rgba(217,119,6,.3);
  --c-err-bg:   rgba(220,38,38,.12);
  --c-err-bdr:  rgba(220,38,38,.3);
  --c-info-bg:  rgba(37,99,235,.12);
  --c-info-bdr: rgba(37,99,235,.3);
  --sh-sm: 0 1px 4px rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.25);
  --sh-md: 0 4px 16px rgba(0,0,0,.4),  0 2px 6px rgba(0,0,0,.2);
  --sh-lg: 0 12px 40px rgba(0,0,0,.5), 0 4px 14px rgba(0,0,0,.25);
}

/* ═══════════════════════════════════════════
   LAYOUT ROOT
═══════════════════════════════════════════ */
body.erp-page {
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  flex-direction: row !important;
  min-height: 100vh !important;
  background: var(--c-bg) !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  color: var(--c-text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════ */
#erp-sidebar {
  width: var(--sb-w);
  min-height: 100vh;
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: width var(--t-slow);
  overflow: hidden;
  box-shadow: 1px 0 0 var(--sb-bdr), 4px 0 24px rgba(0,0,0,.18);
}
body.erp-page.sb-col #erp-sidebar { width: var(--sb-col); }

/* Platform brand footer — "Powered by NexaConnect ERP" at sidebar bottom.
   Lives outside .esb-footer so it stays pinned below the user row.
   Subtle: small font, muted color, hover lifts to white. */
.esb-platform {
  display: block;
  padding: 8px 14px 10px;
  font-size: 10.5px;
  color: rgba(255,255,255,.35);
  text-decoration: none;
  text-align: center;
  border-top: 1px solid var(--sb-bdr);
  transition: color .12s;
  flex-shrink: 0;
  letter-spacing: .2px;
}
.esb-platform:hover { color: rgba(255,255,255,.7); }
.esb-platform strong { font-weight: 600; color: inherit; }
body.erp-page.sb-col .esb-platform {
  font-size: 0;
  padding: 6px 4px 8px;
}
body.erp-page.sb-col .esb-platform strong { font-size: 9px; }

/* Logo */
.esb-logo {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 14px;
  height: var(--hdr-h);
  border-bottom: 1px solid var(--sb-bdr);
  flex-shrink: 0;
  overflow: hidden;
  text-decoration: none;
  transition: background var(--t);
}
.esb-logo:hover { background: var(--sb-bg-h); }

.esb-mark {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--c-acc), var(--c-acc-h));
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(var(--c-acc-rgb),.4);
  letter-spacing: -.5px;
  overflow: hidden;
}
/* When a real company logo is set, drop the gradient + shadow and let the
   image fill the mark box. White-ish background so transparent PNGs still
   have contrast against the dark sidebar. */
.esb-mark.esb-mark-img {
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.18);
  padding: 2px;
}
.esb-mark.esb-mark-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.esb-logo-text { overflow: hidden; transition: opacity var(--t), max-width var(--t-slow); max-width: 160px; }
.esb-logo-text strong { display: block; color: #fff; font-size: 13px; font-weight: 700; white-space: nowrap; }
.esb-logo-text span   { display: block; color: var(--sb-section); font-size: 10px; white-space: nowrap; }
body.erp-page.sb-col .esb-logo-text { opacity: 0; max-width: 0; }

/* Nav */
.esb-nav { flex: 1; padding: 10px 0; overflow-y: auto; overflow-x: hidden; }
.esb-nav::-webkit-scrollbar { width: 3px; }
.esb-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 2px; }

.esb-section {
  padding: 14px 16px 5px;
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  color: var(--sb-section);
  white-space: nowrap; overflow: hidden;
  transition: opacity var(--t);
}
body.erp-page.sb-col .esb-section { opacity: 0; pointer-events: none; }

/* ── Collapsible sidebar groups ── */
.esb-section-btn {
  width: 100%;
  display: flex; align-items: center;
  padding: 14px 16px 5px;
  background: none; border: none; cursor: pointer;
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  color: var(--sb-section);
  white-space: nowrap; overflow: hidden;
  transition: color var(--t), opacity var(--t);
  font-family: inherit; line-height: 1;
}
.esb-section-btn:hover { color: var(--sb-text-h); }
.esb-section-lbl { flex: 1; text-align: left; }
.esb-chevron {
  display: flex; align-items: center; justify-content: center;
  opacity: .5; transition: opacity var(--t);
  flex-shrink: 0; margin-left: 4px;
}
.esb-chevron svg { width: 10px; height: 10px; stroke: currentColor; }
.esb-section-btn:hover .esb-chevron { opacity: .8; }
body.erp-page.sb-col .esb-section-btn { opacity: 0; pointer-events: none; height: 0; padding: 0; overflow: hidden; }
.esb-group-links {
  max-height: 2000px; overflow: hidden;
  transition: max-height var(--t-slow), opacity var(--t-slow);
  opacity: 1;
}
.esb-group.esb-group-col .esb-group-links { max-height: 0; opacity: 0; pointer-events: none; }
/* Always show links in icon-only sidebar mode */
body.erp-page.sb-col .esb-group.esb-group-col .esb-group-links {
  max-height: 2000px; opacity: 1; pointer-events: auto;
}

.esb-link {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 14px;
  color: var(--sb-text);
  text-decoration: none;
  font-size: 12.5px; font-weight: 500;
  transition: all var(--t);
  white-space: nowrap; overflow: hidden;
  border-left: 2px solid transparent;
  position: relative;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  margin: 0 8px 1px 0;
}
.esb-link:hover {
  background: var(--sb-bg-h);
  color: var(--sb-text-h);
}
.esb-link.active {
  background: var(--sb-bg-active) !important;
  color: var(--sb-text-active) !important;
  border-left-color: var(--c-acc) !important;
  font-weight: 600;
}

/* SVG Icon */
.esb-icon {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  opacity: .75;
  transition: opacity var(--t);
}
.esb-link:hover .esb-icon  { opacity: .95; }
.esb-link.active .esb-icon { opacity: 1; }
.esb-icon svg {
  width: 16px; height: 16px;
  display: block;
  stroke: currentColor;
  fill: none;
}

.esb-label { flex: 1; transition: opacity var(--t), max-width var(--t-slow); max-width: 180px; white-space: nowrap; }
body.erp-page.sb-col .esb-label { opacity: 0; max-width: 0; }

.esb-badge {
  background: rgba(var(--c-acc-rgb),.9);
  color: #fff;
  border-radius: 10px; font-size: 10px; font-weight: 700;
  padding: 1px 6px; min-width: 18px; text-align: center;
  flex-shrink: 0; transition: opacity var(--t);
  line-height: 16px;
}
body.erp-page.sb-col .esb-badge { opacity: 0; width: 0; overflow: hidden; padding: 0; }

/* Tooltip when collapsed */
body.erp-page.sb-col .esb-link:hover::after {
  content: attr(data-label);
  position: absolute;
  left: calc(var(--sb-col) + 10px); top: 50%;
  transform: translateY(-50%);
  background: #1e293b; color: #f1f5f9;
  padding: 6px 11px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 500; white-space: nowrap;
  z-index: 500;
  box-shadow: var(--sh-lg);
  border: 1px solid #334155;
  pointer-events: none;
}

/* Footer */
.esb-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--sb-bdr);
  display: flex; align-items: center; gap: 10px;
  overflow: hidden; flex-shrink: 0;
}
.esb-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--c-acc), var(--c-acc-h));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 700; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(var(--c-acc-rgb),.35);
  overflow: hidden;
}
/* When a team_member.photoUrl is set, drop the gradient + let the image
   fill the circle. Tooltip surfaces the sales code. */
.esb-avatar.has-img {
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.18);
}
.esb-avatar.has-img img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.esb-user { overflow: hidden; transition: opacity var(--t), max-width var(--t-slow); max-width: 160px; }
.esb-user strong { display: block; font-size: 11.5px; font-weight: 600; color: #fff; white-space: nowrap; }
.esb-user span   { display: block; font-size: 10px; color: var(--sb-section); white-space: nowrap; }
body.erp-page.sb-col .esb-user { opacity: 0; max-width: 0; }

/* ═══════════════════════════════════════════
   MAIN WRAPPER
═══════════════════════════════════════════ */
#erp-main {
  margin-left: var(--sb-w);
  flex: 1; display: flex; flex-direction: column;
  min-height: 100vh; min-width: 0;
  transition: margin-left var(--t-slow);
}
body.erp-page.sb-col #erp-main { margin-left: var(--sb-col); }

/* ═══════════════════════════════════════════
   TOP HEADER
═══════════════════════════════════════════ */
#erp-header {
  height: var(--hdr-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-bdr);
  display: flex; align-items: center;
  padding: 0 20px; gap: 10px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--sh-sm);
  flex-shrink: 0;
  transition: background var(--t), border-color var(--t);
}

/* Toggle button */
.ehdr-toggle {
  background: none; border: none; cursor: pointer;
  width: 36px; height: 36px;
  color: var(--c-muted); border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t), color var(--t); flex-shrink: 0;
}
.ehdr-toggle:hover { background: var(--c-surface-3); color: var(--c-text); }
.ehdr-toggle svg { width: 18px; height: 18px; }

/* Title */
.ehdr-title {
  font-size: 14px; font-weight: 700; color: var(--c-text);
  white-space: nowrap; min-width: 0; letter-spacing: -.01em;
}

/* Search */
.ehdr-search { flex: 1; max-width: 300px; position: relative; }
.ehdr-search input {
  width: 100%; padding: 8px 12px 8px 36px;
  border: 1.5px solid var(--c-bdr); border-radius: var(--r-xl);
  font-size: 12.5px; background: var(--c-surface-3); color: var(--c-text);
  outline: none; font-family: inherit; box-sizing: border-box;
  transition: border-color var(--t), background var(--t), box-shadow var(--t);
}
.ehdr-search input:focus {
  border-color: var(--c-pri);
  background: var(--c-surface);
  box-shadow: var(--sh-focus);
}
.ehdr-search input::placeholder { color: var(--c-muted-2); }
.ehdr-search-ic {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--c-muted-2); pointer-events: none;
  display: flex; align-items: center;
}
.ehdr-search-ic svg { width: 14px; height: 14px; }

/* ── Global search dropdown ── */
.ehdr-search-dd {
  position: absolute; top: calc(100% + 6px); left: 0;
  width: max(380px, 100%);
  background: var(--c-surface);
  border: 1px solid var(--c-bdr);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
  max-height: 480px;
  overflow: auto;
  z-index: 60;
  display: none;
}
.ehdr-search-dd.open { display: block; }
.ehdr-search-dd-empty,
.ehdr-search-dd-loading {
  padding: 22px 16px;
  text-align: center;
  color: var(--c-muted);
  font-size: 12px;
}
.ehdr-search-dd-hdr {
  padding: 8px 12px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--c-muted);
  background: var(--c-surface-2);
  border-bottom: 1px solid var(--c-bdr);
  position: sticky; top: 0; z-index: 1;
}
.ehdr-search-dd-hdr .ehdr-search-dd-count { float: right; font-weight: 600; opacity: .7; }
.ehdr-search-dd-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px;
  border-bottom: 1px solid var(--c-bdr-soft, #f1f5f9);
  cursor: pointer;
  text-decoration: none;
  color: var(--c-text);
  transition: background var(--t);
}
.ehdr-search-dd-item:hover,
.ehdr-search-dd-item.kb-active { background: var(--c-surface-2); }
.ehdr-search-dd-item:last-child { border-bottom: 0; }
.ehdr-search-dd-thumb {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: 6px; background: var(--c-surface-3);
  border: 1px solid var(--c-bdr);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--c-muted-2);
  overflow: hidden;
}
.ehdr-search-dd-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ehdr-search-dd-body { flex: 1; min-width: 0; }
.ehdr-search-dd-title {
  font-size: 12.5px; font-weight: 600; color: var(--c-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ehdr-search-dd-sub {
  font-size: 10.5px; color: var(--c-muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ehdr-search-dd-badge {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  padding: 2px 6px; border-radius: 9px; flex-shrink: 0;
  align-self: center;
  background: #e2e8f0; color: #475569;
}
.ehdr-search-dd-badge.b-product     { background: #dbeafe; color: #1d4ed8; }
.ehdr-search-dd-badge.b-certificate { background: #fef3c7; color: #92400e; }
.ehdr-search-dd-badge.b-document    { background: #ede9fe; color: #6b21a8; }
.ehdr-search-dd-badge.b-customer    { background: #dcfce7; color: #15803d; }
.ehdr-search-dd-badge.b-supplier    { background: #ffedd5; color: #9a3412; }
.ehdr-search-dd-foot {
  padding: 8px 12px;
  font-size: 10.5px;
  color: var(--c-muted);
  border-top: 1px solid var(--c-bdr);
  background: var(--c-surface-2);
  display: flex; justify-content: space-between;
}
.ehdr-search-dd-foot kbd {
  font-size: 9.5px; padding: 1px 5px; border-radius: 3px;
  background: var(--c-surface-3); border: 1px solid var(--c-bdr);
  font-family: inherit;
}

.ehdr-spacer { flex: 1; }
.ehdr-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.ehdr-sep { width: 1px; height: 20px; background: var(--c-bdr); margin: 0 4px; }

/* Action buttons */
.ehdr-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 13px;
  border: 1.5px solid var(--c-bdr); border-radius: var(--r-sm);
  background: var(--c-surface); color: var(--c-text-2);
  font-size: 11.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  text-decoration: none; font-family: inherit;
  transition: all var(--t); letter-spacing: -.01em;
}
.ehdr-btn svg { width: 14px; height: 14px; }
.ehdr-btn:hover { background: var(--c-surface-3); border-color: var(--c-bdr-2); color: var(--c-text); }
.ehdr-btn.pri {
  background: var(--c-pri); color: #fff; border-color: var(--c-pri);
  box-shadow: 0 1px 3px rgba(var(--c-pri-rgb),.25);
}
.ehdr-btn.pri:hover { background: var(--c-pri-h); border-color: var(--c-pri-h); }
.ehdr-btn.acc {
  background: var(--c-acc); color: #fff; border-color: var(--c-acc);
  box-shadow: 0 1px 3px rgba(var(--c-acc-rgb),.3);
}
.ehdr-btn.acc:hover { background: var(--c-acc-h); }

/* Icon-only buttons */
.ehdr-ic-btn {
  background: none; border: none; cursor: pointer;
  width: 36px; height: 36px;
  color: var(--c-muted); border-radius: var(--r-sm);
  position: relative; transition: all var(--t);
  display: flex; align-items: center; justify-content: center;
}
.ehdr-ic-btn:hover { background: var(--c-surface-3); color: var(--c-text); }
.ehdr-ic-btn svg { width: 18px; height: 18px; }

.ehdr-dot {
  position: absolute; top: 6px; right: 6px;
  width: 6px; height: 6px;
  background: var(--c-err); border-radius: 50%;
  border: 1.5px solid var(--c-surface);
}

/* Sync status label shown alongside the cloud icon button */
.ehdr-sync-btn { width: auto; min-width: 36px; padding: 0 8px; gap: 5px; }
.ehdr-sync-label {
  font-size: 10px; font-weight: 700; white-space: nowrap;
  letter-spacing: .15px; transition: color .2s;
}
.ehdr-sync-label.sl-pending { color: var(--c-warn, #d97706); }
.ehdr-sync-label.sl-syncing { color: var(--c-pri,  #2563eb); }
.ehdr-sync-label.sl-synced  { color: var(--c-ok,   #16a34a); }
.ehdr-sync-label.sl-failed  { color: var(--c-err,  #dc2626); }

.ehdr-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--c-pri), var(--c-pri-h));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700;
  cursor: pointer; border: 2px solid var(--c-bdr); flex-shrink: 0;
  transition: border-color var(--t), box-shadow var(--t);
}
.ehdr-avatar:hover { border-color: var(--c-pri); box-shadow: 0 0 0 3px rgba(var(--c-pri-rgb),.12); }

/* Content */
#erp-content { flex: 1; overflow-x: clip; }

/* ── Suppress old nav containers ── */
body.erp-page #erpNav,
body.erp-page .erp-nav { display: none !important; }

/* ── Remove old page topbars — replaced entirely by the shell header ── */
body.erp-page .topbar { display: none !important; }

/* ── Sub-action toolbar (invoice editor action bar, etc.) ── */
body.erp-page .toolbar {
  background: var(--c-surface) !important;
  background-image: none !important;
  border-bottom: 1px solid var(--c-bdr) !important;
  box-shadow: var(--sh-sm) !important;
  padding: 9px 20px !important;
  top: var(--hdr-h) !important;
  z-index: 90 !important;
}
body.erp-page .toolbar > h2 { display: none !important; }
/* Suppress hover lift on most toolbar buttons — but allow workflow buttons (.wf-btn) their own styles */
body.erp-page .toolbar button:not(.wf-btn):hover { transform: none !important; }
body.erp-page .toolbar .wf-btn:hover { transform: translateY(-1px) !important; }

/* ── Hide invoice editor toolbar buttons replaced by the new workflow button set ── */
body.erp-page .toolbar .btn-pdf,
body.erp-page .toolbar .btn-excel,
body.erp-page .toolbar .btn-manager { display: none !important; }

/* ═══════════════════════════════════════════
   DASHBOARD
═══════════════════════════════════════════ */
.erp-dash { padding: 24px 26px; }
.erp-dash-hdr { margin-bottom: 22px; }
.erp-dash-hdr h2 {
  font-size: 20px; font-weight: 800; color: var(--c-text);
  margin: 0 0 4px; letter-spacing: -.02em;
}
.erp-dash-hdr p { font-size: 13px; color: var(--c-muted); margin: 0; }

/* ── Stat cards ── */
.erp-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px; margin-bottom: 24px;
}
.erp-sc {
  background: var(--c-surface); border-radius: var(--r);
  padding: 18px 20px;
  border: 1px solid var(--c-bdr);
  box-shadow: var(--sh-sm);
  display: flex; align-items: flex-start; gap: 14px;
  cursor: default; transition: box-shadow var(--t), transform var(--t), border-color var(--t);
  text-decoration: none; color: inherit;
  position: relative; overflow: hidden;
}
.erp-sc::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: transparent;
  transition: background var(--t);
}
.erp-sc:hover {
  box-shadow: var(--sh-md);
  transform: translateY(-2px);
  border-color: var(--c-bdr-2);
}
.erp-sc:hover::before { background: var(--c-acc); }

.erp-sc-icon {
  width: 46px; height: 46px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.erp-sc-icon svg { width: 22px; height: 22px; }
.erp-sc-icon.blue   { background: #eff6ff; color: #1d4ed8; }
.erp-sc-icon.green  { background: #f0fdf4; color: #15803d; }
.erp-sc-icon.amber  { background: #fffbeb; color: #b45309; }
.erp-sc-icon.purple { background: #faf5ff; color: #7e22ce; }
.erp-sc-icon.red    { background: #fef2f2; color: #dc2626; }
.erp-sc-icon.teal   { background: #f0fdfa; color: #0f766e; }
.erp-sc-icon.orange { background: #fff7ed; color: #c2410c; }
.erp-sc-icon.indigo { background: #eef2ff; color: #4338ca; }
.erp-sc-icon.rose   { background: #fff1f2; color: #be123c; }

.erp-sc-body { flex: 1; min-width: 0; }
.erp-sc-lbl {
  font-size: 10px; font-weight: 700; color: var(--c-muted);
  text-transform: uppercase; letter-spacing: .07em; margin-bottom: 6px;
}
.erp-sc-val {
  font-size: 28px; font-weight: 800; color: var(--c-text);
  line-height: 1; letter-spacing: -.03em;
}
.erp-sc-sub { font-size: 11px; color: var(--c-muted); margin-top: 5px; }

/* ── Dashboard grid ── */
.erp-dash-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 18px;
}
.erp-dash-left, .erp-dash-right { display: flex; flex-direction: column; gap: 18px; }

/* ── Widget card ── */
.erp-widget {
  background: var(--c-surface); border-radius: var(--r);
  border: 1px solid var(--c-bdr); box-shadow: var(--sh-sm);
  overflow: hidden;
  transition: box-shadow var(--t);
}
.erp-widget:hover { box-shadow: var(--sh-md); }
.erp-widget-hdr {
  padding: 14px 18px 13px;
  border-bottom: 1px solid var(--c-bdr);
  display: flex; align-items: center; gap: 8px;
}
.erp-widget-title {
  font-size: 13px; font-weight: 700; color: var(--c-text);
  flex: 1; letter-spacing: -.01em;
}
.erp-widget-link {
  font-size: 11.5px; color: var(--c-info); text-decoration: none; font-weight: 600;
  padding: 3px 8px; border-radius: var(--r-sm);
  transition: background var(--t);
}
.erp-widget-link:hover { background: var(--c-info-bg); text-decoration: none; }
.erp-widget-body { padding: 14px 18px; }

/* ── Activity feed ── */
.erp-activity { list-style: none; margin: 0; padding: 0; }
.erp-activity li {
  display: flex; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--c-surface-3);
}
.erp-activity li:last-child { border-bottom: none; }
.erp-act-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--c-info); flex-shrink: 0; margin-top: 5px;
  box-shadow: 0 0 0 3px var(--c-info-bg);
}
.erp-act-body { flex: 1; }
.erp-act-text { font-size: 12px; color: var(--c-text-2); line-height: 1.45; }
.erp-act-time { font-size: 10.5px; color: var(--c-muted-2); margin-top: 2px; }
.erp-act-empty { font-size: 12px; color: var(--c-muted); text-align: center; padding: 20px 0; }

/* ── Quick actions ── */
.erp-qa { display: flex; flex-direction: column; gap: 6px; }
.erp-qa-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--c-bdr); background: var(--c-surface);
  color: var(--c-text); font-size: 12.5px; font-weight: 500;
  cursor: pointer; text-decoration: none;
  transition: all var(--t);
}
.erp-qa-item:hover {
  background: var(--c-surface-3); border-color: var(--c-bdr-2);
  transform: translateX(3px);
  box-shadow: var(--sh-xs);
}
.erp-qa-icon {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
}
.erp-qa-icon.blue   { background: var(--c-info-bg); color: var(--c-info); }
.erp-qa-icon.green  { background: var(--c-ok-bg);   color: var(--c-ok); }
.erp-qa-icon.amber  { background: var(--c-warn-bg); color: var(--c-warn); }
.erp-qa-icon.purple { background: #faf5ff; color: #7e22ce; }
.erp-qa-icon.teal   { background: #f0fdfa; color: #0f766e; }
.erp-qa-txt strong { display: block; font-size: 12.5px; font-weight: 600; }
.erp-qa-txt span   { font-size: 11px; color: var(--c-muted); }
.erp-qa-arrow {
  margin-left: auto; color: var(--c-muted-2);
  font-size: 14px; transition: transform var(--t);
}
.erp-qa-item:hover .erp-qa-arrow { transform: translateX(2px); }

/* ── Production pills ── */
.erp-prod-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.erp-prod-pill {
  text-align: center; padding: 12px 6px;
  border-radius: var(--r-sm); background: var(--c-surface-3);
  border: 1px solid var(--c-bdr);
  transition: all var(--t);
}
.erp-prod-pill:hover { border-color: var(--c-bdr-2); }
.erp-prod-n { font-size: 24px; font-weight: 800; color: var(--c-text); letter-spacing: -.03em; }
.erp-prod-l { font-size: 9px; font-weight: 700; color: var(--c-muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 2px; }

/* ── Revenue bar chart ── */
.erp-chart { height: 120px; display: flex; align-items: flex-end; gap: 6px; }
.erp-bar {
  flex: 1; border-radius: 4px 4px 0 0;
  background: var(--c-pri); opacity: .35; min-height: 4px;
  transition: opacity var(--t), transform var(--t);
}
.erp-bar:hover { opacity: .7; transform: scaleY(1.02); transform-origin: bottom; }
.erp-bar.cur { background: var(--c-acc); opacity: .85; }
.erp-chart-lbls { display: flex; gap: 6px; margin-top: 5px; }
.erp-chart-lbls span { flex: 1; text-align: center; font-size: 9.5px; color: var(--c-muted); }

/* ── Invoice status table ── */
.erp-inv-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.erp-inv-table th {
  text-align: left; font-size: 10px; font-weight: 700;
  color: var(--c-muted); text-transform: uppercase; letter-spacing: .07em;
  padding: 0 0 10px; border-bottom: 1px solid var(--c-bdr);
}
.erp-inv-table td {
  padding: 10px 0; border-bottom: 1px solid var(--c-surface-3);
  vertical-align: middle; color: var(--c-text-2);
}
.erp-inv-table tr { transition: background var(--t); }
.erp-inv-table tr:hover td { background: var(--c-surface-2); cursor: pointer; }
.erp-inv-table tr:last-child td { border-bottom: none; }
.erp-inv-table td:last-child { text-align: right; }

/* ── Status badges ── */
.erp-status {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  white-space: nowrap;
}
.erp-status::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0;
}
.erp-status.draft {
  background: var(--c-surface-3); color: var(--c-muted);
  border: 1px solid var(--c-bdr);
}
.erp-status.draft::before { background: var(--c-muted-2); }
.erp-status.sent {
  background: var(--c-warn-bg); color: var(--c-warn);
  border: 1px solid var(--c-warn-bdr);
}
.erp-status.sent::before { background: var(--c-warn); }
.erp-status.confirmed {
  background: var(--c-ok-bg); color: var(--c-ok);
  border: 1px solid var(--c-ok-bdr);
}
.erp-status.confirmed::before { background: var(--c-ok); }
.erp-status.follow-up {
  background: var(--c-err-bg); color: var(--c-err);
  border: 1px solid var(--c-err-bdr);
}
.erp-status.follow-up::before { background: var(--c-err); }
.erp-status.production {
  background: var(--c-info-bg); color: var(--c-info);
  border: 1px solid var(--c-info-bdr);
}
.erp-status.production::before { background: var(--c-info); }
.erp-status.completed {
  background: #f0fdf4; color: #065f46;
  border: 1px solid #bbf7d0;
}
.erp-status.completed::before { background: #065f46; }
.erp-status.lost {
  background: var(--c-surface-3); color: var(--c-muted-2);
  border: 1px solid var(--c-bdr);
}
.erp-status.lost::before { background: var(--c-muted-2); }

/* ── Toast notifications (ERP.ui.toast) ── */
#erpToast {
  position: fixed !important;
  top: calc(var(--hdr-h) + 14px) !important;
  right: 20px !important;
  left: auto !important;
  bottom: auto !important;
  z-index: 9999 !important;
  min-width: 280px; max-width: 380px;
  border-radius: var(--r-sm) !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  padding: 12px 16px !important;
  line-height: 1.4 !important;
  box-shadow: var(--sh-lg) !important;
  border: 1px solid transparent !important;
  animation: toastIn .22s cubic-bezier(.4,0,.2,1) !important;
}
#erpToast.t-success {
  background: var(--c-ok-bg) !important;
  color: var(--c-ok) !important;
  border-color: var(--c-ok-bdr) !important;
}
#erpToast.t-error {
  background: var(--c-err-bg) !important;
  color: var(--c-err) !important;
  border-color: var(--c-err-bdr) !important;
}
#erpToast.t-warn {
  background: var(--c-warn-bg) !important;
  color: var(--c-warn) !important;
  border-color: var(--c-warn-bdr) !important;
}
#erpToast.t-info {
  background: var(--c-info-bg) !important;
  color: var(--c-info) !important;
  border-color: var(--c-info-bdr) !important;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Section headings inside dash ── */
.erp-sec-title {
  font-size: 12px; font-weight: 700; color: var(--c-muted);
  text-transform: uppercase; letter-spacing: .07em;
  margin: 0 0 12px; display: flex; align-items: center; gap: 8px;
}
.erp-sec-title::after {
  content: ''; flex: 1; height: 1px; background: var(--c-bdr);
}

/* ── Generic table (for non-dashboard pages) ── */
.erp-table-wrap { overflow-x: auto; border-radius: var(--r); border: 1px solid var(--c-bdr); box-shadow: var(--sh-sm); }
.erp-table {
  width: 100%; border-collapse: collapse; font-size: 12.5px;
  background: var(--c-surface);
}
.erp-table thead tr { background: var(--c-surface-2); }
.erp-table thead th {
  padding: 11px 14px; font-size: 10px; font-weight: 700;
  color: var(--c-muted); text-align: left; white-space: nowrap;
  text-transform: uppercase; letter-spacing: .07em;
  border-bottom: 1px solid var(--c-bdr);
}
.erp-table tbody tr { border-bottom: 1px solid var(--c-bdr); transition: background var(--t); }
.erp-table tbody tr:last-child { border-bottom: none; }
.erp-table tbody tr:hover { background: var(--c-surface-2); }
.erp-table td { padding: 11px 14px; color: var(--c-text-2); vertical-align: middle; }

/* ── Dark mode transition ── */
body, #erp-header, #erp-content, .erp-widget, .erp-sc, .erp-qa-item {
  transition: background-color var(--t), border-color var(--t), color var(--t);
}

/* ═══════════════════════════════════════════
   MOBILE OVERLAY + RESPONSIVE
═══════════════════════════════════════════ */
.erp-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.48); z-index: 190;
  backdrop-filter: blur(2px);
}
@media (max-width: 900px) {
  #erp-sidebar {
    transform: translateX(-100%);
    width: var(--sb-w) !important;
    transition: transform var(--t-slow);
  }
  body.erp-page.sb-open #erp-sidebar { transform: translateX(0); }
  body.erp-page.sb-open .erp-overlay { display: block; }
  #erp-main { margin-left: 0 !important; }
  .ehdr-search { display: none; }
  .erp-stats { grid-template-columns: repeat(2, 1fr); }
  .ehdr-btn:not(.pri) { display: none; }
  .erp-dash { padding: 16px; }
}
@media (max-width: 600px) {
  .erp-stats { grid-template-columns: 1fr 1fr; }
  .erp-dash-grid { grid-template-columns: 1fr; }
}
@media (min-width: 901px) and (max-width: 1100px) {
  .erp-dash-grid { grid-template-columns: 1fr; }
}
