/* CRM_ERP_FOUNDATION_UI_V1 */
:root {
  --crm-primary: #2563eb;
  --crm-accent: #0f172a;
  --accent: var(--crm-primary);
  --ink: var(--crm-accent);
  --soft: color-mix(in srgb, var(--crm-primary) 12%, white);
}

.erp-brand-logo,
.login-card .logo img,
.sidebar .brand .logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: inherit;
}


/* CRM_TREE_NAVIGATION_STYLE_V102 */
.sidebar nav {
  display: block;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 3px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.22) transparent;
}
.sidebar nav::-webkit-scrollbar { width: 6px; }
.sidebar nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.2);
  border-radius: 999px;
}
.erp-nav-tree {
  display: grid;
  gap: 5px;
  padding-bottom: 10px;
}
.erp-nav-tree-group {
  border: 1px solid transparent;
  border-radius: 12px;
  overflow: hidden;
  transition: background .16s ease, border-color .16s ease;
}
.erp-nav-tree-group.open,
.erp-nav-tree-group.has-active-page {
  background: rgba(255,255,255,.045);
  border-color: rgba(255,255,255,.07);
}
.erp-nav-tree-toggle {
  width: 100%;
  min-height: 40px;
  padding: 8px 9px;
  border-radius: 11px;
  display: grid;
  grid-template-columns: 22px minmax(0,1fr) auto 18px;
  align-items: center;
  gap: 7px;
  color: #d5dbea;
  background: transparent;
  text-align: left;
}
.erp-nav-tree-toggle:hover {
  color: white;
  background: rgba(255,255,255,.08);
}
.erp-nav-tree-group.has-active-page > .erp-nav-tree-toggle {
  color: white;
}
.erp-nav-tree-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: #dce5ff;
  background: rgba(255,255,255,.075);
  font-size: 13px;
}
.erp-nav-tree-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .055em;
}
.erp-nav-tree-count {
  min-width: 20px;
  height: 19px;
  padding: 0 6px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #aeb9cf;
  background: rgba(255,255,255,.07);
  font-size: 10px;
  font-weight: 800;
}
.erp-nav-tree-chevron {
  display: inline-grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
  opacity: .65;
  transform: rotate(0deg);
  transition: transform .16s ease;
}
.erp-nav-tree-group.open .erp-nav-tree-chevron {
  transform: rotate(90deg);
}
.erp-nav-tree-children {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 2px 6px 7px 12px;
}
.erp-nav-tree-children[hidden] { display: none !important; }
.erp-nav-tree-children::before {
  content: '';
  position: absolute;
  left: 19px;
  top: 3px;
  bottom: 10px;
  width: 1px;
  background: rgba(255,255,255,.12);
}
.erp-nav-tree-item.nav-btn {
  position: relative;
  width: 100%;
  min-height: 34px;
  margin: 0;
  padding: 7px 9px 7px 18px;
  border-radius: 9px;
  display: grid;
  grid-template-columns: 10px minmax(0,1fr);
  align-items: center;
  gap: 7px;
  color: #aeb9cf;
  font-size: 12px;
  font-weight: 650;
}
.erp-nav-tree-item.nav-btn:hover {
  color: white;
  background: rgba(255,255,255,.075);
}
.erp-nav-tree-item.nav-btn.active {
  color: white;
  background: color-mix(in srgb, var(--crm-primary) 55%, rgba(255,255,255,.1));
  box-shadow: inset 3px 0 0 rgba(255,255,255,.8);
}
.erp-nav-tree-branch {
  position: relative;
  width: 10px;
  height: 10px;
}
.erp-nav-tree-branch::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 4px;
  width: 8px;
  height: 1px;
  background: rgba(255,255,255,.22);
}
.erp-nav-tree-item.active .erp-nav-tree-branch::before {
  background: rgba(255,255,255,.85);
}
.profile { flex: 0 0 auto; }

.erp-grid-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.erp-grid-toolbar .erp-view-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.table-wrap.erp-grid-wrap {
  position: relative;
  overflow: auto;
  max-width: 100%;
}
.erp-resizable-table {
  table-layout: fixed;
  width: max-content;
  min-width: 100%;
}
.erp-resizable-table th,
.erp-resizable-table td {
  box-sizing: border-box;
  min-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.erp-resizable-table th {
  position: sticky;
  top: 0;
  z-index: 5;
  user-select: none;
}
.erp-resize-handle {
  position: absolute;
  top: 0;
  right: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  z-index: 10;
}
.erp-resize-handle:hover,
.erp-resize-handle.dragging {
  background: color-mix(in srgb, var(--crm-primary) 45%, transparent);
}
.erp-column-pinned {
  position: sticky !important;
  z-index: 7 !important;
  background: inherit;
  box-shadow: 1px 0 0 rgba(148, 163, 184, .35);
}
.erp-density-compact th,
.erp-density-compact td { padding-top: 5px !important; padding-bottom: 5px !important; }
.erp-density-spacious th,
.erp-density-spacious td { padding-top: 15px !important; padding-bottom: 15px !important; }

.erp-module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}
.erp-module-card {
  border: 1px solid rgba(148, 163, 184, .25);
  border-radius: 14px;
  padding: 16px;
  background: rgba(255,255,255,.03);
}
.erp-module-card h4 { margin: 0 0 6px; }
.erp-module-card p { margin: 0; }
.erp-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.erp-kpi {
  border: 1px solid rgba(148, 163, 184, .22);
  border-radius: 14px;
  padding: 15px;
}
.erp-kpi small { display:block; opacity:.65; }
.erp-kpi strong { display:block; font-size:24px; margin-top:6px; }

.erp-light {
  display: inline-flex;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-right: 7px;
  box-shadow: 0 0 0 3px rgba(148,163,184,.12);
}
.erp-light.GREEN { background:#22c55e; }
.erp-light.YELLOW { background:#eab308; }
.erp-light.RED { background:#ef4444; }
.erp-light.GRAY { background:#94a3b8; }

.erp-debt-cell {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 115px;
  padding: 6px 9px;
  border-radius: 9px;
  font-variant-numeric: tabular-nums;
}
.erp-debt-cell.GREEN { background:rgba(34,197,94,.15); }
.erp-debt-cell.YELLOW { background:rgba(234,179,8,.17); }
.erp-debt-cell.RED { background:rgba(239,68,68,.18); }
.erp-debt-cell small { opacity:.72; }

.erp-brand-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, .25);
  margin-bottom: 16px;
}
.erp-brand-preview img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 14px;
  background: rgba(255,255,255,.06);
}
.erp-brand-color-row {
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:12px;
}
.erp-upload-row {
  display:grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap:12px;
}
.erp-upload-card {
  border:1px dashed rgba(148,163,184,.35);
  border-radius:12px;
  padding:12px;
}
.erp-upload-card input { max-width:100%; }

.erp-sla.BREACHED { color:#ef4444; font-weight:800; }
.erp-sla.WARNING { color:#eab308; font-weight:800; }
.erp-sla.ON_TRACK { color:#22c55e; font-weight:800; }

@media (max-width: 760px) {
  .erp-upload-row,
  .erp-brand-color-row { grid-template-columns: 1fr; }
}


/* CRM_ROLE_BASED_DASHBOARD_STYLE_V103 */
.erp-dashboard-hero {
  display:flex; align-items:flex-end; justify-content:space-between; gap:20px;
  padding:22px; margin-bottom:14px; border-radius:18px;
  color:white; background:linear-gradient(125deg, var(--crm-accent), color-mix(in srgb, var(--crm-primary) 72%, #111827));
  box-shadow:0 16px 40px rgba(15,23,42,.18);
}
.erp-dashboard-hero h2 { margin:7px 0 5px; font-size:clamp(22px,3vw,34px); }
.erp-dashboard-hero p { margin:0; opacity:.78; max-width:760px; }
.erp-dashboard-profile { display:inline-flex; padding:5px 9px; border-radius:999px; background:rgba(255,255,255,.14); font-size:11px; font-weight:850; letter-spacing:.08em; text-transform:uppercase; }
.erp-dashboard-meta { display:grid; gap:5px; text-align:right; white-space:nowrap; }
.erp-dashboard-meta small { opacity:.65; }
.erp-dashboard-actions { display:flex; gap:9px; overflow:auto; padding:1px 1px 12px; }
.erp-dashboard-action { min-width:max-content; display:flex; align-items:center; gap:8px; padding:9px 12px; border:1px solid var(--line); border-radius:12px; background:var(--surface); }
.erp-dashboard-action b { color:var(--crm-primary); font-size:18px; }
.erp-dashboard-metrics { display:grid; grid-template-columns:repeat(6,minmax(150px,1fr)); gap:11px; margin-bottom:12px; }
.erp-dashboard-metric { min-width:0; text-align:left; padding:15px; border:1px solid var(--line); border-radius:15px; background:var(--surface); }
.erp-dashboard-metric small,.erp-dashboard-metric span { display:block; color:var(--muted); }
.erp-dashboard-metric strong { display:block; margin:7px 0 2px; font-size:clamp(20px,2vw,27px); font-variant-numeric:tabular-nums; overflow:hidden; text-overflow:ellipsis; }
.erp-dashboard-metric.POSITIVE { box-shadow:inset 0 3px 0 #22c55e; }
.erp-dashboard-metric.WARNING { box-shadow:inset 0 3px 0 #eab308; }
.erp-dashboard-metric.DANGER { box-shadow:inset 0 3px 0 #ef4444; }
.erp-dashboard-alerts { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:13px; }
.erp-dashboard-alert { display:flex; align-items:center; gap:10px; padding:8px 11px; border-radius:999px; border:1px solid var(--line); background:var(--surface); }
.erp-dashboard-alert b { min-width:24px; padding:2px 7px; border-radius:999px; background:rgba(148,163,184,.18); }
.erp-dashboard-alert.DANGER { color:#b42318; border-color:rgba(239,68,68,.35); background:rgba(239,68,68,.07); }
.erp-dashboard-alert.WARNING { color:#8b5b00; border-color:rgba(234,179,8,.35); background:rgba(234,179,8,.08); }
.erp-dashboard-sections { display:grid; grid-template-columns:repeat(auto-fit,minmax(330px,1fr)); gap:13px; }
.erp-dashboard-section { margin:0; min-width:0; }
.erp-dashboard-worklist { display:grid; gap:6px; }
.erp-dashboard-workitem { width:100%; display:flex; align-items:center; justify-content:space-between; gap:14px; padding:11px 12px; border:1px solid var(--line); border-radius:12px; background:transparent; text-align:left; }
.erp-dashboard-workitem:hover { background:color-mix(in srgb,var(--crm-primary) 5%,transparent); }
.erp-dashboard-workitem.DANGER { border-left:4px solid #ef4444; }
.erp-dashboard-workitem.WARNING { border-left:4px solid #eab308; }
.erp-dashboard-work-main { min-width:0; display:grid; gap:3px; }
.erp-dashboard-work-main b,.erp-dashboard-work-main small { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.erp-dashboard-work-main small { color:var(--muted); }
.erp-dashboard-work-side { flex:0 0 auto; display:grid; gap:4px; text-align:right; }
.erp-dashboard-work-side em { font-style:normal; font-size:10px; font-weight:850; letter-spacing:.04em; }
.erp-dashboard-work-side small { color:var(--muted); }
.erp-dashboard-empty { margin:0; padding:18px; text-align:center; color:var(--muted); border:1px dashed var(--line); border-radius:12px; }
@media (max-width:1180px) { .erp-dashboard-metrics { grid-template-columns:repeat(3,minmax(150px,1fr)); } }
@media (max-width:760px) {
  .erp-dashboard-hero { align-items:flex-start; flex-direction:column; }
  .erp-dashboard-meta { text-align:left; white-space:normal; }
  .erp-dashboard-metrics { grid-template-columns:repeat(2,minmax(130px,1fr)); }
  .erp-dashboard-sections { grid-template-columns:1fr; }
}
