/* Group ERP Social Gradient V4: shared tokens and shell-level components. */
:root {
  color-scheme: light;
  --erp-bg: #F8F9FB;
  --erp-surface: #ffffff;
  --erp-surface-soft: #F3F4F6;
  --erp-primary: #6D28D9;
  --erp-primary-hover: #5B21B6;
  --erp-primary-soft: #F3E8FF;
  --erp-primary-border: #D8B4FE;
  --erp-accent-magenta: #A21CAF;
  --erp-accent-rose: #E1306C;
  --erp-text-primary: #111827;
  --erp-text-secondary: #667085;
  --erp-ink: var(--erp-text-primary);
  --erp-muted: var(--erp-text-secondary);
  --erp-border: #E5E7EB;
  --erp-focus-ring: #C4B5FD;
  --erp-focus-outline: var(--erp-primary);
  --erp-success: #157A70;
  --erp-danger: #B84A56;
  --erp-warning: #9B6B26;
  --erp-info: #175CD3;
  --erp-success-soft: #EAF6F4;
  --erp-danger-soft: #FFF0F2;
  --erp-warning-soft: #FFF4DE;
  --erp-info-soft: #EFF8FF;
  --erp-neutral-soft: #F3F4F6;
  --erp-chart-primary: #6D28D9;
  --erp-chart-magenta: #A21CAF;
  --erp-chart-rose: #D62961;
  --erp-chart-amber: #C58617;
  --erp-chart-neutral: #667085;
  --erp-chart-slate: #344054;
  /* Compatibility aliases for existing chart styles; workflow status tokens stay semantic. */
  --erp-teal: var(--erp-chart-magenta);
  --erp-periwinkle: var(--erp-chart-rose);
  --erp-gold: var(--erp-chart-amber);
  --erp-gradient-brand: linear-gradient(115deg, #FF7A00 0%, #FF0169 35%, #D300C5 68%, #7638FA 100%);
  --erp-gradient-primary: linear-gradient(120deg, #6D28D9 0%, #A21CAF 100%);
  --erp-chat-outgoing-gradient: linear-gradient(135deg, #7551CE 0%, #9C52C9 100%);
  --erp-chat-focus-gradient: linear-gradient(120deg, #7638FA 0%, #A21CAF 52%, #D62961 100%);
  --erp-chat-background: linear-gradient(180deg, #FFFFFF 0%, #FCF9FF 55%, #FFF9FC 100%);
  --erp-chat-incoming: #F1F2F5;
  --erp-chat-incoming-text: #111827;
  --erp-chat-selected: #F3E8FF;
  --erp-sidebar-width: 232px;
  --erp-sidebar-compact-width: 67px;
  --erp-radius-sm: 8px;
  --erp-radius-md: 10px;
  --erp-radius-lg: 12px;
  --erp-shadow-menu: 0 12px 32px rgba(17, 24, 39, .12);
  --control-height: 36px;
  --layout-gap: 18px;
  --card-radius: 12px;

  /* Keep the established module styles on the same semantic palette. */
  --ink: var(--erp-ink);
  --muted: var(--erp-muted);
  --line: var(--erp-border);
  --paper: var(--erp-surface);
  --bg: var(--erp-bg);
  --blue: var(--erp-primary);
  --nav: var(--erp-surface);
  --green: var(--erp-success);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  color: var(--erp-ink);
  background: var(--erp-bg);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  text-rendering: optimizeLegibility;
}

body,
button,
input,
select,
textarea {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}

a {
  color: var(--erp-primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--erp-primary-hover);
}

button,
.button,
input,
select,
textarea,
summary,
a {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--erp-focus-outline);
  outline-offset: 2px;
}

.icon-definitions {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.sr-only,
.skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link:focus {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  width: auto;
  height: auto;
  clip: auto;
  padding: 10px 14px;
  border-radius: var(--erp-radius-sm);
  color: #fff;
  background: var(--erp-primary-hover);
}

.app-shell {
  min-height: 100vh;
  background: var(--erp-bg);
}

.sidebar {
  display: flex;
  height: 100vh;
  min-height: 0;
  flex-direction: column;
  z-index: 50;
  width: var(--erp-sidebar-width);
  padding: 18px 14px 14px;
  border-right: 1px solid var(--erp-border);
  background: var(--erp-surface);
  color: var(--erp-ink);
  overflow: visible;
  box-shadow: 3px 0 16px rgba(32, 43, 67, .025);
  transition: width .18s ease, transform .18s ease;
}

.sidebar-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 0 5px 0 4px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0;
  color: var(--erp-ink);
  letter-spacing: 0;
}

.brand:hover {
  color: var(--erp-ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border-radius: 11px;
  color: #fff;
  background: var(--erp-gradient-primary);
  box-shadow: none;
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -.08em;
  line-height: 1;
  padding-right: 2px;
}

.brand-copy {
  display: grid;
  gap: 0;
  color: var(--erp-muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .16em;
  line-height: 1.15;
}

.brand-copy strong {
  color: var(--erp-ink);
  font-size: 16px;
  letter-spacing: .04em;
  line-height: 1.2;
}

.workspace-label {
  margin: 23px 8px 9px;
  color: var(--erp-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.sidebar .sidebar-nav {
  display: grid;
  flex: 1 1 auto;
  gap: 3px;
  min-width: 0;
  min-height: 0;
  align-content: start;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
  z-index: 2;
}

.sidebar .home-link,
.sidebar .nav-group-trigger,
.sidebar .nav-link {
  display: flex;
  min-width: 0;
  min-height: 40px;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  color: var(--erp-ink);
  background: transparent;
  font-size: 13px;
  font-weight: 550;
  line-height: 1.3;
  text-align: left;
  text-decoration: none;
  transition: color .18s ease, background-color .18s ease;
}

.sidebar .home-link,
.sidebar .nav-group-trigger {
  width: 100%;
}

.sidebar .home-link:hover,
.sidebar .nav-group-trigger:hover,
.sidebar .nav-link:hover {
  color: var(--erp-primary-hover);
  background: var(--erp-surface-soft);
  text-decoration: none;
}

.sidebar .home-link.is-active,
.sidebar .nav-link.is-active {
  color: var(--erp-primary-hover);
  background: var(--erp-primary-soft);
  font-weight: 650;
}

.sidebar .nav-group {
  position: relative;
  min-width: 0;
}

.sidebar .nav-group-trigger {
  list-style: none;
  cursor: pointer;
}

.sidebar .nav-group-trigger::-webkit-details-marker {
  display: none;
}

.sidebar .nav-group-trigger::marker {
  content: "";
}

.sidebar .nav-group[open]:not(.is-active-group) > .nav-group-trigger {
  color: var(--erp-ink);
  background: var(--erp-surface-soft);
  font-weight: 600;
}

.sidebar .nav-group.is-active-group > .nav-group-trigger {
  color: var(--erp-primary-hover);
  background: var(--erp-primary-soft);
  font-weight: 650;
}

.sidebar .home-link:focus-visible,
.sidebar .nav-group-trigger:focus-visible,
.sidebar .nav-link:focus-visible {
  outline: 2px solid var(--erp-focus-outline);
  outline-offset: 2px;
}

.nav-icon {
  display: block;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-chevron {
  display: block;
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .16s ease;
}

.sidebar .nav-chevron {
  margin-left: auto;
}

.sidebar .nav-group[open]:not(.is-closing) > .nav-group-trigger .nav-chevron,
.user-menu[open] .user-menu-trigger > .nav-chevron {
  transform: rotate(180deg);
}

.sidebar .nav-submenu {
  display: grid;
  gap: 3px;
  min-width: 0;
  margin: 3px 0 6px 18px;
  padding: 4px 0 4px 7px;
  border-left: 1px solid var(--erp-border);
  background: transparent;
}

.sidebar .nav-group:not([open]) > .nav-submenu { display: none; }
.sidebar .nav-group[open] > .nav-submenu { display: grid; }

.sidebar .nav-link {
  position: relative;
  justify-content: flex-start;
  min-height: 36px;
  gap: 9px;
  padding: 7px 9px;
  color: var(--erp-muted);
  font-size: 13px;
  font-weight: 500;
  white-space: normal;
}

.sidebar .nav-link.is-active {
  color: var(--erp-primary-hover);
  background: var(--erp-primary-soft);
  font-weight: 650;
}

.sidebar .nav-link.is-active::before {
  position: absolute;
  top: 7px;
  bottom: 7px;
  left: 2px;
  width: 3px;
  border-radius: 3px;
  background: var(--erp-primary);
  content: "";
}

.sidebar .nav-label {
  flex: 1 1 auto;
  min-width: 0;
}

.sidebar .nav-link .nav-icon {
  width: 16px;
  height: 16px;
  flex-basis: 16px;
}

.sidebar .nav-link .nav-badge {
  flex: 0 0 auto;
  margin-left: auto;
}

.nav-badge,
.notification-count {
  display: inline-flex;
  min-width: 19px;
  height: 19px;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border-radius: 999px;
  color: var(--erp-primary-hover);
  background: var(--erp-primary-soft);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.sidebar .nav-link.is-active:hover {
  color: var(--erp-primary-hover);
  background: var(--erp-primary-soft);
}

.sidebar-account {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin-top: auto;
  padding: 13px 5px 3px;
  border-top: 1px solid var(--erp-border);
}

.account-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border: 1px solid var(--erp-border);
  border-radius: 11px;
  color: var(--erp-primary-hover);
  background: var(--erp-primary-soft);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.account-copy {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.account-copy strong {
  overflow: hidden;
  color: var(--erp-ink);
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-copy small {
  color: var(--erp-muted);
  font-size: 10.5px;
}

.app-main {
  min-width: 0;
  min-height: 100vh;
  margin-left: var(--erp-sidebar-width);
  transition: margin-left .18s ease;
}

.app-shell.sidebar-is-compact .sidebar {
  width: var(--erp-sidebar-compact-width);
  padding-right: 10px;
  padding-left: 10px;
}

.app-shell.sidebar-is-compact .app-main {
  margin-left: var(--erp-sidebar-compact-width);
}

.sidebar-is-compact .brand-copy,
.sidebar-is-compact .workspace-label,
.sidebar-is-compact .nav-label,
.sidebar-is-compact .sidebar .nav-chevron,
.sidebar-is-compact .nav-badge,
.sidebar-is-compact .account-copy {
  display: none;
}

.sidebar-is-compact .sidebar-brand-row {
  justify-content: center;
  padding: 0;
}

.sidebar-is-compact .brand {
  justify-content: center;
}

.sidebar-is-compact .home-link,
.sidebar-is-compact .nav-group-trigger,
.sidebar-is-compact .nav-link {
  justify-content: center;
  padding-right: 0;
  padding-left: 0;
}

.sidebar-is-compact .nav-submenu {
  margin-left: 0;
  padding-left: 0;
  border-left: 0;
}

.sidebar-is-compact .sidebar-account {
  justify-content: center;
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px clamp(18px, 2.5vw, 38px);
  border-bottom: 1px solid var(--erp-border);
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 2px 10px rgba(32, 43, 67, .025);
}

.topbar-leading,
.topbar-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.topbar-leading {
  flex: 1 1 auto;
}

.topbar-actions {
  flex: 0 1 auto;
  justify-content: flex-end;
}

.breadcrumb {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
  margin: 0;
  color: var(--erp-muted);
  font-size: 12px;
}

.breadcrumb a {
  flex: 0 0 auto;
  color: var(--erp-muted);
  font-weight: 600;
}

.breadcrumb > span[aria-current="page"] {
  overflow: hidden;
  color: var(--erp-ink);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar .global-search {
  position: relative;
  display: flex;
  width: clamp(230px, 25vw, 390px);
  min-width: 190px;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.global-search .search-icon {
  position: absolute;
  left: 12px;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--erp-muted);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.global-search input {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 8px 12px 8px 37px;
  border-color: var(--erp-border);
  border-radius: 9px;
  background: var(--erp-surface-soft);
  font-size: 12px;
}

.global-search input:focus {
  border-color: var(--erp-primary);
  background: #fff;
}

.global-search button {
  min-height: 36px;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
}

.organization-switcher {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
  margin: 0;
}

.organization-switcher select {
  width: 165px;
  min-width: 120px;
  min-height: 36px;
  padding: 7px 27px 7px 9px;
  border-color: var(--erp-border);
  border-radius: 8px;
  color: var(--erp-ink);
  background: #fff;
  font-size: 11px;
  font-weight: 550;
}

.organization-switcher > .erp-select {
  width: 165px;
  min-width: 120px;
}

.erp-select {
  position: relative;
  display: block;
  min-width: 0;
}

.erp-select-native[hidden] { display: none; }

.erp-select-trigger {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 36px;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--erp-border);
  border-radius: 9px;
  color: var(--erp-ink);
  background: var(--erp-surface);
  font-size: 13px;
  font-weight: 550;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  transition: border-color .16s ease, background-color .16s ease, box-shadow .16s ease;
}

.erp-select-trigger:hover:not(:disabled),
.erp-select[data-open="true"] .erp-select-trigger {
  border-color: var(--erp-primary-border);
  background: #fcfaff;
}

.erp-select-trigger:focus-visible,
.erp-select-search:focus-visible,
.erp-select-option:focus-visible {
  border-color: var(--erp-primary);
  outline: 2px solid var(--erp-focus-outline);
  outline-offset: 2px;
}

.erp-select-trigger:disabled {
  color: var(--erp-muted);
  background: var(--erp-surface-soft);
  cursor: not-allowed;
}

.erp-select-value {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.erp-select-trigger.is-placeholder .erp-select-value { color: var(--erp-muted); }
.erp-select-chevron { width: 14px; height: 14px; flex: 0 0 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .16s ease; }
.erp-select[data-open="true"] .erp-select-chevron { transform: rotate(180deg); }
.erp-select--inline { display: inline-block; width: auto; }
.erp-select--inline .erp-select-trigger { min-height: 36px; white-space: nowrap; }

.erp-select--status .erp-select-trigger { gap: 7px; padding-inline: 9px; }
.erp-select--status[data-status="open"] .erp-select-trigger { border-color: #B2DDFF; color: var(--erp-info); background: var(--erp-info-soft); }
.erp-select--status[data-status="pending"] .erp-select-trigger { border-color: #F2D59A; color: var(--erp-warning); background: var(--erp-warning-soft); }
.erp-select--status[data-status="closed"] .erp-select-trigger { border-color: #B7DED8; color: var(--erp-success); background: var(--erp-success-soft); }
.erp-select--status[data-status="open"] .erp-select-chevron,
.erp-select--status[data-status="pending"] .erp-select-chevron,
.erp-select--status[data-status="closed"] .erp-select-chevron { color: var(--erp-muted); }

.erp-status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--erp-muted);
}

.erp-select--status[data-status="open"] .erp-status-dot,
.erp-select-option[data-status="open"] .erp-status-dot { background: var(--erp-info); }
.erp-select--status[data-status="pending"] .erp-status-dot,
.erp-select-option[data-status="pending"] .erp-status-dot { background: var(--erp-warning); }
.erp-select--status[data-status="closed"] .erp-status-dot,
.erp-select-option[data-status="closed"] .erp-status-dot { background: var(--erp-success); }

.erp-select-spinner {
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: erp-select-spin .7s linear infinite;
}

@keyframes erp-select-spin { to { transform: rotate(360deg); } }

.erp-select-menu {
  position: fixed;
  z-index: 1600;
  inset: auto;
  display: none;
  flex-direction: column;
  gap: 4px;
  max-width: calc(100vw - 16px);
  margin: 0;
  padding: 5px;
  overflow: hidden;
  border: 1px solid var(--erp-border);
  border-radius: 11px;
  color: var(--erp-ink);
  background: var(--erp-surface);
  box-shadow: var(--erp-shadow-menu);
}

.erp-select-menu:popover-open { display: flex; animation: erp-dropdown-in .14s ease both; }
.erp-select-menu[data-open="true"] { display: flex; animation: erp-dropdown-in .14s ease both; }

@keyframes erp-dropdown-in { from { opacity: 0; translate: 0 -4px; } to { opacity: 1; translate: 0 0; } }

.erp-select-search {
  width: 100%;
  min-height: 34px;
  flex: 0 0 auto;
  padding: 7px 9px;
  border: 1px solid var(--erp-border);
  border-radius: 7px;
  color: var(--erp-ink);
  background: #fff;
  font-size: 13px;
}

.erp-select-list {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.erp-select-option {
  display: flex;
  width: 100%;
  min-height: 36px;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border: 0;
  border-radius: 7px;
  color: var(--erp-ink);
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}

.erp-select-option:hover:not(:disabled),
.erp-select-option[aria-selected="true"] { background: var(--erp-primary-soft); }
.erp-select--status .erp-select-option[data-status="open"]:hover:not(:disabled) { color: var(--erp-info); background: var(--erp-info-soft); }
.erp-select--status .erp-select-option[data-status="pending"]:hover:not(:disabled) { color: var(--erp-warning); background: var(--erp-warning-soft); }
.erp-select--status .erp-select-option[data-status="closed"]:hover:not(:disabled) { color: var(--erp-success); background: var(--erp-success-soft); }
.erp-select--status .erp-select-option[aria-selected="true"][data-status="open"] { color: var(--erp-info); background: var(--erp-info-soft); }
.erp-select--status .erp-select-option[aria-selected="true"][data-status="pending"] { color: var(--erp-warning); background: var(--erp-warning-soft); }
.erp-select--status .erp-select-option[aria-selected="true"][data-status="closed"] { color: var(--erp-success); background: var(--erp-success-soft); }
.erp-select-option:disabled { color: var(--erp-muted); cursor: not-allowed; }
.erp-select-option-label { min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.erp-select-option-check { width: 14px; flex: 0 0 14px; color: var(--erp-primary); font-size: 13px; text-align: center; }
.erp-select--status .erp-select-option[data-status="open"] .erp-select-option-check { color: var(--erp-info); }
.erp-select--status .erp-select-option[data-status="pending"] .erp-select-option-check { color: var(--erp-warning); }
.erp-select--status .erp-select-option[data-status="closed"] .erp-select-option-check { color: var(--erp-success); }
.erp-select-empty { margin: 0; padding: 12px 9px; color: var(--erp-muted); font-size: 12px; text-align: center; }
.erp-select-error { display: block; margin-top: 4px; color: var(--erp-danger); font-size: 11px; }
.erp-select-error[hidden] { display: none; }
.erp-select.has-error .erp-select-trigger { border-color: var(--erp-danger); }
.erp-select[aria-busy="true"] .erp-select-trigger { cursor: wait; }

.organization-switcher > button {
  min-height: 36px;
  padding: 7px 9px;
  border-radius: 8px;
  font-size: 11px;
}

.icon-button {
  position: relative;
  display: inline-grid;
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--erp-muted);
  background: transparent;
  box-shadow: none;
  font-size: 20px;
  line-height: 1;
  text-decoration: none;
}

.icon-button:hover {
  border-color: var(--erp-border);
  color: var(--erp-primary-hover);
  background: var(--erp-surface-soft);
  filter: none;
  text-decoration: none;
}

.notification-count {
  position: absolute;
  top: -3px;
  right: -4px;
  min-width: 17px;
  height: 17px;
  border: 2px solid #fff;
  color: #fff;
  background: var(--erp-danger);
  font-size: 9px;
}

.notification-link {
  flex: 0 0 38px;
}

.menu-glyph {
  display: grid;
  width: 18px;
  gap: 4px;
}

.menu-glyph i {
  display: block;
  height: 1.7px;
  border-radius: 2px;
  background: currentColor;
}

.collapse-glyph {
  font-size: 27px;
  font-weight: 400;
  line-height: .8;
}

.sidebar-toggle,
.sidebar-close {
  display: none;
}

.quick-actions {
  position: relative;
}

.quick-actions-trigger {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid var(--erp-border);
  border-radius: 9px;
  color: var(--erp-primary);
  background: var(--erp-surface-soft);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  list-style: none;
  white-space: nowrap;
}

.quick-actions-trigger::-webkit-details-marker {
  display: none;
}

.quick-actions-trigger::marker { content: ""; }

.quick-actions-trigger .nav-icon {
  width: 16px;
  height: 16px;
}

.quick-actions-trigger:hover {
  border-color: var(--erp-primary);
  background: var(--erp-primary-soft);
}

.erp-menu-panel {
  position: absolute;
  z-index: 60;
  top: calc(100% + 9px);
  right: 0;
  min-width: 220px;
  padding: 7px;
  border: 1px solid var(--erp-border);
  border-radius: 11px;
  background: #fff;
  box-shadow: var(--erp-shadow-menu);
}

.quick-actions-item,
.user-menu-panel > a,
.user-logout {
  display: flex;
  width: 100%;
  min-height: 38px;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  color: #4e5c73;
  background: transparent;
  font-size: 12px;
  font-weight: 550;
  text-align: left;
  text-decoration: none;
}

.quick-actions-item:hover,
.user-menu-panel > a:hover,
.user-logout:hover {
  color: var(--erp-primary-hover);
  background: #f4f6fc;
  text-decoration: none;
}

.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 8px;
  padding: 3px 0 3px 7px;
  color: var(--erp-ink);
  cursor: pointer;
  list-style: none;
}

.user-menu-trigger::-webkit-details-marker {
  display: none;
}

.user-menu-trigger::marker { content: ""; }

.user-menu-trigger .account-avatar {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
}

.user-menu-name {
  max-width: 145px;
  overflow: hidden;
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-trigger .nav-chevron {
  margin-left: 0;
  color: var(--erp-muted);
}

.user-menu-panel {
  min-width: 220px;
}

.user-menu-panel .nav-icon { width: 16px; height: 16px; flex: 0 0 16px; }

.user-menu-summary {
  display: grid;
  gap: 2px;
  padding: 9px 10px 11px;
  border-bottom: 1px solid var(--erp-border);
}

.user-menu-summary strong {
  color: var(--erp-ink);
  font-size: 12px;
}

.user-menu-summary small {
  color: var(--erp-muted);
  font-size: 11px;
}

.user-menu-panel form {
  margin: 2px 0 0;
  padding-top: 2px;
  border-top: 1px solid var(--erp-border);
}

.user-logout {
  color: var(--erp-danger);
  cursor: pointer;
}

.page {
  width: min(100%, 1680px);
  min-height: calc(100vh - 116px);
  margin: 0 auto;
  padding: 25px clamp(18px, 2.5vw, 38px) 34px;
}

.inbox-page-shell {
  width: 100%;
  max-width: none;
}

.page-footer {
  padding: 13px 20px 18px;
  color: #8995a8;
  font-size: 10.5px;
  text-align: center;
}

.page-heading,
.heading,
.orders-heading,
.customer-page-heading {
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

h1,
.page-heading h1,
.heading h1,
.orders-heading h1,
.customer-page-heading h1 {
  color: var(--erp-ink);
  font-size: clamp(24px, 2vw, 28px);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.25;
  text-wrap: balance;
}

h2 {
  color: var(--erp-ink);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -.015em;
  line-height: 1.35;
}

h3 {
  color: var(--erp-ink);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.4;
}

.subtitle,
.muted {
  color: var(--erp-muted);
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--erp-primary-hover);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
}

.card,
.metric,
.dashboard-panel,
.marketing-panel,
.marketing-kpi,
.orders-summary-card,
.control-room-panel {
  min-width: 0;
  border: 1px solid var(--erp-border);
  border-radius: var(--erp-radius-lg);
  background: var(--erp-surface);
  box-shadow: 0 3px 12px rgba(32, 43, 67, .025);
}

.card {
  padding: 20px;
}

.table-card,
.table-wrap,
.order-table-wrap,
.customer-table-card,
.pipeline-table-wrap,
.dashboard-table-wrap {
  max-width: 100%;
  overflow: auto;
  overscroll-behavior-inline: contain;
  border-radius: var(--erp-radius-md);
}

table {
  min-width: 100%;
  color: var(--erp-ink);
}

table th {
  color: #64738c;
  background: #f7f9fc;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .015em;
  text-transform: none;
  white-space: nowrap;
}

table th,
table td {
  padding: 11px 14px;
  border-color: var(--erp-border);
}

tbody tr:hover {
  background: var(--erp-surface-soft);
}

.filters,
.filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  align-items: end;
  gap: 12px;
}

.filters > label,
.filter-bar label {
  min-width: 0;
}

.filters label span,
.filter-bar label span {
  margin-bottom: 5px;
  color: var(--erp-muted);
  font-size: 11.5px;
  font-weight: 600;
}

button,
.button {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--erp-primary);
  border-radius: var(--erp-radius-sm);
  color: #fff;
  background: var(--erp-primary);
  box-shadow: none;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1.3;
  text-decoration: none;
  transition: background-color .14s ease, border-color .14s ease, color .14s ease, transform .14s ease;
}

button:hover,
.button:hover {
  border-color: var(--erp-primary-hover);
  color: #fff;
  background: var(--erp-primary-hover);
  filter: none;
  box-shadow: 0 2px 5px rgba(76, 29, 149, .14);
  transform: translateY(-1px);
  text-decoration: none;
}

button:active,
.button:active {
  box-shadow: none;
  transform: translateY(1px) scale(.99);
}

button[type="submit"]:not(.secondary):active,
button.primary:not(.secondary):active,
.button:not(.secondary):active,
.primary-button:active,
.primary-action:active,
.global-search button:active,
.organization-switcher > button:active {
  border-color: #4C1D95;
  background: #4C1D95;
}

button:disabled,
button[disabled] {
  cursor: not-allowed;
  opacity: .58;
}

button:disabled:hover,
button[disabled]:hover,
.button[aria-disabled="true"]:hover {
  border-color: var(--erp-border);
  color: var(--erp-ink);
  background: var(--erp-surface);
  box-shadow: none;
  transform: none;
}
button[type="submit"]:disabled:hover:not(.secondary),
button.primary:disabled:hover:not(.secondary),
.button[aria-disabled="true"]:hover:not(.secondary),
.primary-button[aria-disabled="true"]:hover,
.primary-action[aria-disabled="true"]:hover {
  border-color: var(--erp-primary);
  color: #fff;
  background: var(--erp-primary);
}

.secondary,
button.secondary,
.button.secondary,
a.secondary {
  border-color: var(--erp-border);
  color: #485873;
  background: #fff;
}

.secondary:hover,
button.secondary:hover,
.button.secondary:hover,
a.secondary:hover {
  border-color: #cdd6e5;
  color: var(--erp-primary-hover);
  background: #f7f9ff;
}

.link-button,
.button-link {
  border: 0;
  color: var(--erp-primary-hover);
  background: transparent;
  box-shadow: none;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select,
textarea {
  min-width: 0;
  min-height: var(--control-height);
  padding: 9px 10px;
  border: 1px solid #d7deea;
  border-radius: var(--erp-radius-sm);
  color: var(--erp-ink);
  background: #fff;
  font-size: 13px;
}

input::placeholder,
textarea::placeholder {
  color: #98a3b5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--erp-primary);
  outline: 2px solid var(--erp-focus-outline);
  outline-offset: 0;
}

textarea {
  min-height: 96px;
}

.badge,
.status-badge,
.order-status,
.stage-marker {
  border-color: #dbe4f2;
  color: #50617d;
  background: #f9faf9;
  font-size: 11px;
  font-weight: 600;
}

.notice {
  margin-bottom: 16px;
  padding: 11px 14px;
  border: 1px solid #d6e3ff;
  border-radius: var(--erp-radius-sm);
  color: #344a83;
  background: #eff3ff;
}

.notice.success {
  border-color: #c5e5dc;
  color: #126659;
  background: #eef8f5;
}

.notice.error,
.errorlist {
  border-color: #f0cbd0;
  color: #9c3644;
  background: #fff3f4;
}

.errorlist {
  padding: 8px 12px;
  border-radius: 7px;
}

.empty,
.dashboard-empty,
.marketing-empty,
.target-empty {
  color: var(--erp-muted);
}

.empty {
  padding: 38px 24px;
}

.pagination {
  gap: 10px;
  color: var(--erp-muted);
  font-size: 12px;
}

.form-stack,
.page form.card {
  gap: 14px;
}

.form-stack fieldset,
.page form.card fieldset {
  border-color: var(--erp-border);
  border-radius: var(--erp-radius-sm);
}

.form-stack fieldset legend {
  color: #586882;
  font-size: 12px;
  font-weight: 650;
}

.modal,
.create-drawer-shell {
  border: 1px solid var(--erp-border);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(32, 43, 67, .2);
}

.modal::backdrop,
.create-drawer-shell::backdrop {
  background: rgba(25, 37, 60, .4);
}

.drawer {
  box-shadow: -12px 0 35px rgba(32, 43, 67, .14);
}

.kanban-column {
  border: 1px solid var(--erp-border);
  border-radius: var(--erp-radius-md);
  background: #eff3f9;
}

.kanban-card {
  border-color: var(--erp-border);
  border-radius: var(--erp-radius-sm);
  box-shadow: 0 2px 7px rgba(32, 43, 67, .035);
}

.sales-dashboard,
.marketing-dashboard {
  display: grid;
  gap: 18px;
}

.sales-dashboard .dashboard-panels {
  height: auto;
}

.dashboard-heading h1,
.marketing-heading h1 {
  margin-bottom: 4px;
  font-size: clamp(25px, 2vw, 29px);
}

.dashboard-heading .subtitle,
.marketing-heading .subtitle {
  margin: 4px 0 0;
  font-size: 13px;
}

.dashboard-toolbar,
.marketing-filters {
  border-color: var(--erp-border);
  border-radius: var(--erp-radius-md);
  background: #fff;
  box-shadow: none;
}

.sales-metric,
.marketing-kpi {
  min-width: 0;
  border: 1px solid var(--erp-border);
  border-radius: var(--erp-radius-md);
  background: #fff !important;
  box-shadow: 0 3px 12px rgba(32, 43, 67, .025);
}

.sales-metric > strong,
.marketing-kpi strong,
.metric strong {
  color: var(--erp-ink);
  font-variant-numeric: tabular-nums;
}

.sales-metric-top,
.marketing-kpi > span,
.metric > span {
  color: #62718b;
}

.metric-icon {
  border-radius: 10px;
  color: var(--erp-primary-hover);
  background: var(--erp-primary-soft);
}

.dashboard-panels,
.marketing-panel-grid {
  gap: 16px;
}

.operations-panels {
  grid-template-columns: minmax(0, 1fr);
}

.operations-summary-panel {
  min-height: 0;
}

.finance-access-note {
  margin: -5px 0 14px;
  color: var(--erp-muted);
  font-size: 12px;
}

.operations-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 165px), 1fr));
  gap: 10px;
}

.operations-summary-card {
  display: grid;
  min-width: 0;
  min-height: 112px;
  align-content: start;
  gap: 5px;
  padding: 14px;
  border: 1px solid var(--erp-border);
  border-radius: 10px;
  color: var(--erp-ink);
  background: #fbfcfe;
  text-decoration: none;
  transition: border-color .14s ease, background-color .14s ease, transform .14s ease;
}

.operations-summary-card:hover {
  transform: translateY(-1px);
  border-color: #ccd6f8;
  color: var(--erp-ink);
  background: var(--erp-surface-soft);
  text-decoration: none;
}

.operations-summary-card > span {
  color: #64738c;
  font-size: 11.5px;
  font-weight: 600;
}

.operations-summary-card > strong {
  color: var(--erp-ink);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.025em;
  line-height: 1.2;
}

.operations-summary-card > small {
  color: var(--erp-muted);
  font-size: 10.5px;
}

.operations-summary-card.is-attention > strong {
  color: var(--erp-danger);
}

.dashboard-panel,
.marketing-panel {
  padding: 19px;
  border-radius: var(--erp-radius-lg);
}

.panel-heading,
.marketing-panel-heading {
  margin-bottom: 14px;
}

.panel-heading h2,
.marketing-panel-heading h2 {
  margin: 2px 0 4px;
  font-size: 16px;
}

.panel-heading p,
.marketing-panel-heading p {
  color: var(--erp-muted);
  font-size: 11.5px;
}

.revenue-bar {
  border-radius: 5px 5px 2px 2px;
  background: var(--erp-primary);
}

.source-track span,
.target-track span {
  background: var(--erp-teal);
}

.pipeline-summary > div {
  border: 1px solid var(--erp-border);
  border-radius: 9px;
  background: var(--erp-surface-soft);
}

.task-status-dot.is-today,
.activity-icon {
  color: var(--erp-primary-hover);
  background: var(--erp-primary-soft);
}

.task-status-dot.is-overdue,
.priority-urgent,
.priority-high,
.status-cancelled {
  color: var(--erp-danger);
  background: #fff0f1;
}

.status-completed,
.status-closed,
.status-delivered {
  color: var(--erp-success);
  background: #eaf7f3;
}

.source-segment-0,
.source-legend-0 {
  --source-color: var(--erp-primary);
  background-color: var(--erp-primary);
}

.source-segment-1,
.source-legend-1 {
  --source-color: var(--erp-teal);
  background-color: var(--erp-teal);
}

.source-segment-2,
.source-legend-2 {
  --source-color: var(--erp-periwinkle);
  background-color: var(--erp-periwinkle);
}

.source-segment-3,
.source-legend-3 {
  --source-color: var(--erp-gold);
  background-color: var(--erp-gold);
}

.source-segment-4,
.source-legend-4 {
  --source-color: #6f8c9f;
  background-color: #6f8c9f;
}

.finance-locked {
  border-color: var(--erp-border);
  color: var(--erp-muted);
  background: var(--erp-surface-soft);
}

.sales-metrics {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 165px), 1fr));
}

/* Keep Inbox and legacy Zalo pages on the shared light surfaces. */
.zi-page[data-zalo-inbox],
.zi-page,
.zi-marketing-page {
  color: var(--erp-ink);
}

/* Give the Inbox workspace a definite flex height so its list and chat can scroll. */
body.inbox-shell .page.inbox-page-shell {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body.inbox-shell .page.inbox-page-shell > .zi-page[data-zalo-inbox] {
  flex: 1 1 0;
  min-height: 0;
}

.zi-workspace,
.zi-list-pane,
.zi-chat-pane,
.zi-customer-pane,
.zi-list-pane > header,
.zi-chat-header,
.zi-composer {
  border-color: var(--erp-border);
  background-color: #fff;
}

.zi-workspace {
  box-shadow: none;
}

.zi-avatar {
  border-radius: 50%;
  color: var(--erp-primary);
  background: var(--erp-primary-soft);
}

body.inbox-shell > .app-main {
  display: flex;
  flex-direction: column;
  width: auto;
  height: 100vh;
  height: 100dvh;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

body.inbox-shell .topbar,
body.inbox-shell .breadcrumb {
  display: flex;
}

body.inbox-shell .topbar {
  flex: 0 0 auto;
}

body.inbox-shell > .app-main > .page-footer {
  display: none;
}

body.inbox-shell .collapse-toggle {
  display: none;
}

body.inbox-shell .page.inbox-page-shell {
  flex: 1 1 auto;
  width: 100%;
  max-width: none;
  min-width: 0;
  min-height: 0;
  height: auto;
  margin: 0;
  padding: 10px 12px 12px;
  overflow: hidden;
}

.auth-shell {
  min-height: 100vh;
  background: var(--erp-bg);
}

.auth-main {
  display: grid;
  min-height: 100svh;
  align-content: center;
  justify-items: center;
  margin: 0;
  padding: 28px 18px;
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  text-decoration: none;
}

.auth-page {
  width: min(100%, 480px);
  min-height: 0;
  padding: 0;
}

.auth-card {
  width: 100%;
  max-width: none;
  padding: clamp(24px, 4vw, 36px);
  border-radius: 14px;
  box-shadow: 0 12px 34px rgba(32, 43, 67, .07);
}

.auth-card h1 {
  margin-bottom: 10px;
  font-size: 24px;
}

.auth-card form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.auth-main .page-footer {
  color: #8995a8;
}

@media (max-width: 1150px) {
  .topbar {
    gap: 12px;
  }

  .topbar-leading,
  .topbar-actions {
    gap: 8px;
  }

  .topbar .global-search {
    width: clamp(190px, 24vw, 280px);
  }

  .organization-switcher select {
    width: 145px;
  }

  .organization-switcher > .erp-select { width: 145px; }

  .user-menu-name {
    max-width: 95px;
  }

  .page {
    padding-right: 22px;
    padding-left: 22px;
  }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(290px, calc(100vw - 56px));
    height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
    transform: translateX(-105%);
    box-shadow: 10px 0 30px rgba(32, 43, 67, .14);
  }

  .app-shell.is-nav-open::after {
    position: fixed;
    z-index: 40;
    inset: 0;
    content: "";
    background: rgba(32, 43, 67, .32);
  }

  .app-shell.is-nav-open .sidebar {
    transform: translateX(0);
  }

  .app-main,
  .app-shell.sidebar-is-compact .app-main {
    margin-left: 0;
  }

  .sidebar-toggle,
  .sidebar-close {
    display: inline-grid;
  }

  .collapse-toggle {
    display: none;
  }

  .sidebar-close {
    width: 34px;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
    border: 1px solid var(--erp-border);
    color: var(--erp-muted);
    background: #fff;
    font-size: 21px;
  }

  .topbar {
    min-height: 64px;
  }

  .dashboard-panels,
  .marketing-panel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    height: auto;
  }

  .dashboard-panels-primary,
  .dashboard-panels-secondary {
    min-height: 0;
  }
}

@media (max-width: 640px) {
  html {
    min-width: 320px;
  }

  .topbar {
    min-height: 0;
    flex-wrap: wrap;
    gap: 7px 10px;
    padding: 9px 13px 10px;
  }

  .topbar-leading {
    width: 100%;
    flex: 1 1 100%;
  }

  .topbar-actions {
    width: 100%;
    flex: 1 1 100%;
    flex-wrap: wrap;
    gap: 6px;
  }

  .breadcrumb {
    font-size: 11px;
  }

  .topbar .global-search {
    width: auto;
    min-width: 0;
    flex: 1 1 100%;
    gap: 5px;
  }

  .global-search input {
    height: 36px;
    padding-left: 32px;
    font-size: 11px;
  }

  .global-search .search-icon {
    left: 10px;
    width: 15px;
    height: 15px;
  }

  .global-search button {
    min-height: 36px;
    padding: 7px 9px;
    font-size: 11px;
  }

  .organization-switcher {
    flex: 1 1 auto;
    order: 1;
  }

  .organization-switcher select {
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
  }

  .organization-switcher > .erp-select { width: 100%; min-width: 0; flex: 1 1 auto; }

  .notification-link,
  .quick-actions,
  .user-menu {
    order: 2;
  }

  .user-menu-trigger {
    gap: 3px;
    padding-left: 2px;
  }

  .user-menu-name {
    display: none;
  }

  .quick-actions-trigger {
    width: 36px;
    min-width: 36px;
    justify-content: center;
    padding: 6px;
  }

  .quick-actions-trigger > span {
    display: none;
  }

  .quick-actions-trigger .nav-icon {
    width: 17px;
    height: 17px;
  }

  .page {
    min-height: calc(100vh - 126px);
    padding: 18px 14px 26px;
  }

  .page-heading,
  .heading,
  .orders-heading,
  .customer-page-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  .heading .actions,
  .page-heading .actions,
  .orders-heading .actions,
  .customer-page-actions {
    width: 100%;
  }

  .card,
  .dashboard-panel,
  .marketing-panel {
    padding: 15px;
  }

  .table-card {
    padding: 0;
  }

  table th,
  table td {
    padding: 9px 10px;
  }

  .filters,
  .filter-bar {
    grid-template-columns: minmax(0, 1fr);
  }

  .sales-metrics,
  .marketing-kpis,
  .dashboard-panels,
  .marketing-panel-grid,
  .task-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    height: auto;
  }

  .dashboard-panels-primary > *,
  .dashboard-panels-secondary > *,
  .marketing-primary-panels > * {
    grid-column: 1 / -1;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-heading-meta {
    width: 100%;
    justify-content: space-between;
  }

  .dashboard-toolbar,
  .marketing-filters {
    padding: 12px;
  }

  .dashboard-date-filter {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-date-filter button,
  .marketing-filters button {
    justify-self: start;
  }

  .modal {
    width: calc(100% - 20px);
    max-width: none;
  }

  .modal-header,
  .modal form {
    padding-right: 16px;
    padding-left: 16px;
  }
}

@media (max-width: 390px) {
  .topbar-actions {
    gap: 4px;
  }

  .icon-button,
  .notification-link {
    width: 34px;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
    flex-basis: 34px;
  }

  .sales-metrics,
  .marketing-kpis,
  .metrics,
  .task-tabs {
    grid-template-columns: minmax(0, 1fr);
  }

  .dashboard-date-filter {
    grid-template-columns: minmax(0, 1fr);
  }

  .dashboard-range,
  .marketing-range {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}


html { scroll-behavior: auto; }
body, button, input, select, textarea {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}
body, body.app-shell, body.auth-shell { background: var(--erp-bg); color: var(--erp-ink); font-size: 13px; -webkit-font-smoothing: antialiased; }
a { color: var(--erp-primary); }
a:hover { color: var(--erp-primary-hover); }
:focus-visible { outline: 2px solid var(--erp-focus-outline); outline-offset: 2px; }

.sidebar {
  background: var(--erp-surface);
  color: var(--erp-ink);
  border-right: 1px solid var(--erp-border);
  box-shadow: none;
}
.sidebar-brand-row { min-height: 33px; justify-content: flex-start; padding: 0 13px; margin-bottom: 25px; }
.brand { gap: 10px; }
.brand-mark {
  width: 33px; height: 33px; flex-basis: 33px; border-radius: 9px;
  background: var(--erp-primary); color: #fff; box-shadow: none;
  font-size: 17px; letter-spacing: -.08em;
}
.brand-copy { color: var(--erp-muted); font-size: 9px; letter-spacing: .12em; }
.brand-copy strong { color: var(--erp-ink); font-size: 15px; letter-spacing: .025em; }
.workspace-label { margin: 0 7px 15px; color: var(--erp-muted); font-size: 10px; letter-spacing: .095em; }
.nav-badge, .notification-count { color: var(--erp-primary); background: var(--erp-primary-soft); border-radius: 6px; }
.sidebar-account { padding: 17px 11px 2px; border-top-color: var(--erp-border); }
.account-avatar { border-color: var(--erp-primary-soft); color: var(--erp-primary); background: var(--erp-primary-soft); border-radius: 9px; }
.account-copy strong { color: var(--erp-ink); }
.account-copy small { color: var(--erp-muted); }

.topbar {
  min-height: 67px; padding: 0 clamp(20px, 2.7vw, 36px); gap: 16px;
  background: var(--erp-surface); border-bottom: 1px solid var(--erp-border); box-shadow: none;
}
.breadcrumb { color: var(--erp-muted); }
.breadcrumb > span[aria-current="page"] { color: var(--erp-ink); }
.topbar .global-search { width: min(310px, 30vw); }
.global-search input {
  height: 36px; min-height: 36px; border-color: var(--erp-border);
  border-radius: 8px; background: var(--erp-surface); color: var(--erp-ink);
}
.global-search input:focus { border-color: var(--erp-primary); outline: 2px solid var(--erp-focus-outline); }
.global-search button, .organization-switcher > button { min-height: 36px; border-radius: 8px; }
.organization-switcher select { height: 36px; min-height: 36px; border-color: var(--erp-border); border-radius: 8px; }
.icon-button { color: var(--erp-muted); border-radius: 7px; }
.icon-button:hover { color: var(--erp-primary); background: var(--erp-primary-soft); }
.quick-actions-trigger, .user-menu-trigger { min-height: 36px; border-radius: 8px; }
.user-menu-trigger { color: var(--erp-ink); }
.user-menu-panel { border-color: var(--erp-border); box-shadow: var(--erp-shadow-menu); }

.page {
  width: min(100%, 1670px); min-height: calc(100vh - 116px);
  padding: 28px clamp(20px, 2.7vw, 36px) 40px;
}
.page-footer { color: var(--erp-muted); font-size: 11px; }
h1, .page-heading h1, .heading h1, .orders-heading h1, .customer-page-heading h1 {
  color: var(--erp-ink); font-size: clamp(24px, 2vw, 28px); font-weight: 700;
  letter-spacing: -.025em; line-height: 1.25; opacity: 1;
}
h2 { color: var(--erp-ink); font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
h3 { color: var(--erp-ink); font-size: 14px; font-weight: 600; }
.subtitle, .muted { color: var(--erp-muted); }
.eyebrow { color: var(--erp-primary); font-size: 10px; letter-spacing: .07em; }

.card, .metric, .dashboard-panel, .marketing-panel, .marketing-kpi,
.orders-summary-card, .control-room-panel, .zi-settings-card, .zi-settings-endpoint {
  border-color: var(--erp-border); border-radius: 12px; box-shadow: none;
}
.card { background: var(--erp-surface); }
.table-card, .table-wrap, .order-table-wrap, .customer-table-card,
.pipeline-table-wrap, .dashboard-table-wrap, .tablepanel {
  border-color: var(--erp-border); border-radius: 9px; background: var(--erp-surface);
}
button, .button, input, select, textarea { border-radius: 8px; }
button, .button { min-height: 36px; font-size: 12px; font-weight: 600; }
button:not(.primary):not(.secondary):not(.button):not(.icon-button):not(.sidebar-toggle):not(.sidebar-close):not(.collapse-toggle):not(.user-logout):not(.erp-select-trigger):not(.erp-select-option) {
  border-color: var(--erp-border); background: var(--erp-surface); color: var(--erp-ink);
}
button[type="submit"]:not(.secondary), button.primary:not(.secondary), .button:not(.secondary), .primary-button, .primary-action,
.global-search button, .organization-switcher > button {
  border-color: var(--erp-primary); background: var(--erp-primary); color: #fff;
}
button[type="submit"]:not(.secondary):hover, button.primary:not(.secondary):hover, .button:not(.secondary):hover,
.primary-button:hover, .primary-action:hover, .global-search button:hover,
.organization-switcher > button:hover {
  border-color: var(--erp-primary-hover); background: var(--erp-primary-hover); color: #fff;
}
.secondary, button.secondary, .button.secondary, a.secondary {
  border-color: var(--erp-border); color: var(--erp-primary); background: var(--erp-surface);
}
button:not([type="submit"]):not(.primary):not(.secondary):not(.icon-button):not(.erp-select-trigger):not(.erp-select-option):hover { border-color: var(--erp-primary-border); color: var(--erp-primary); background: var(--erp-primary-soft); }
.secondary:hover, button.secondary:hover, .button.secondary:hover, a.secondary:hover {
  border-color: var(--erp-primary-border); color: var(--erp-primary-hover); background: var(--erp-primary-soft);
}
.link-button, .button-link, .panel-link, .record-link { color: var(--erp-primary); }
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not(.erp-select-search), select, textarea {
  min-height: 36px; padding: 8px 10px; border-color: var(--erp-border);
  border-radius: 8px; color: var(--erp-ink); background: var(--erp-surface); font-size: 12px;
}
input::placeholder, textarea::placeholder { color: var(--erp-muted); opacity: .82; }
input:focus, select:focus, textarea:focus {
  border-color: var(--erp-primary); outline: 2px solid var(--erp-focus-outline);
}
table th { color: var(--erp-muted); background: var(--erp-surface-soft); font-size: 11px; font-weight: 600; }
table td { color: var(--erp-ink); border-color: var(--erp-border); }
tbody tr:hover { background: var(--erp-surface-soft); }
.badge, .tag { border-color: var(--erp-border); background: var(--erp-neutral-soft); color: var(--erp-muted); }
.badge.success, .tag.green, .status-success { border-color: #CDE8E4; background: var(--erp-success-soft); color: var(--erp-success); }
.badge.error, .tag.red, .status-error { border-color: #F0CDD2; background: var(--erp-danger-soft); color: var(--erp-danger); }
.badge.warning, .tag.amber, .status-warning { border-color: #F3DFBA; background: var(--erp-warning-soft); color: #80551C; }
.erp-list-page { display: grid; gap: 16px; min-width: 0; }
.erp-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; min-width: 0; }
.erp-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.erp-kpi-grid > article { min-width: 0; padding: 14px 16px; border: 1px solid var(--erp-border); border-radius: 12px; background: var(--erp-surface); }
.erp-kpi-grid > article > span { display: block; color: var(--erp-muted); font-size: 12px; }
.erp-kpi-grid > article > strong { display: block; margin-top: 5px; color: var(--erp-ink); font-size: 22px; font-variant-numeric: tabular-nums; }
.erp-quick-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.erp-list-toolbar { min-width: 0; }
.erp-data-table { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; border: 1px solid var(--erp-border); border-radius: 9px; background: var(--erp-surface); }
.erp-data-table table { width: 100%; min-width: 100%; }
.erp-status-badge { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--erp-border); border-radius: 999px; padding: 3px 8px; background: var(--erp-neutral-soft); color: var(--erp-muted); font-size: 11px; line-height: 1.35; }
.erp-row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.erp-pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.erp-empty-state { padding: 28px 16px; color: var(--erp-muted); text-align: center; }
.erp-empty-state strong { display: block; margin-bottom: 5px; color: var(--erp-ink); }
.erp-loading-state { padding: 18px; color: var(--erp-muted); }
.erp-list-page .table-wrap,
.erp-list-page .table-card,
.erp-list-page .customer-table-card,
.erp-list-page .lead-data-table { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
@media (prefers-reduced-motion: reduce) {
  button, .button { transition: none !important; }
  button:hover, .button:hover, button:active, .button:active { transform: none; }
}
.notice { border-color: var(--erp-primary-border); background: var(--erp-primary-soft); color: var(--erp-ink); }
.notice.error { border-color: #F0CDD2; background: var(--erp-danger-soft); color: var(--erp-danger); }
.notice.success { border-color: #CDE8E4; background: var(--erp-success-soft); color: var(--erp-success); }

.sales-dashboard { gap: 16px; }
.dashboard-heading { align-items: flex-end; margin-bottom: 0; }
.dashboard-heading h1 { font-size: clamp(24px, 2vw, 28px); letter-spacing: -.025em; }
.dashboard-heading .subtitle { margin: 6px 0 0; }
.dashboard-heading-meta { display: flex; align-items: center; gap: 12px; }
.dashboard-today { color: var(--erp-muted); font-size: 12px; }
.dashboard-toolbar {
  min-height: 62px; padding: 10px 14px; border-color: var(--erp-border);
  border-radius: 12px; background: var(--erp-surface);
}
.period-tabs a { color: var(--erp-muted); border-radius: 8px; }
.period-tabs a[aria-current="page"] { background: var(--erp-primary-soft); color: var(--erp-primary); }
.sales-metrics { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.sales-metric {
  min-height: 112px; padding: 15px 16px; border: 1px solid var(--erp-border);
  border-radius: 12px; background: var(--erp-surface); box-shadow: none;
}
.sales-metric-top { color: var(--erp-muted); font-size: 12px; }
.metric-icon { background: var(--erp-primary-soft); color: var(--erp-primary); }
.tone-violet .metric-icon { background: var(--erp-primary-soft); color: var(--erp-primary); }
.tone-green .metric-icon { background: #EAF6F4; color: var(--erp-success); }
.tone-orange .metric-icon { background: #FFF4E4; color: #9B6B26; }
.tone-red .metric-icon { background: #FFF0F2; color: var(--erp-danger); }
.sales-metric > strong { color: var(--erp-ink); font-size: clamp(24px, 2vw, 30px); }
.metric-hint { color: var(--erp-muted); font-size: 11px; }
.dashboard-panels { gap: 14px; }
.dashboard-panels-primary { grid-template-columns: minmax(0, 1.52fr) minmax(295px, .86fr); height: auto; }
.dashboard-panels-secondary { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); height: auto; }
.dashboard-panel { padding: 18px 20px; background: var(--erp-surface); }
.panel-heading h2 { color: var(--erp-ink); font-size: 16px; }
.panel-heading p { color: var(--erp-muted); }
.dashboard-visualizations { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.revenue-chart, .lead-trend-chart {
  border-color: var(--erp-border);
  background: repeating-linear-gradient(to bottom, transparent 0, transparent 38px, var(--erp-surface-soft) 39px, var(--erp-surface-soft) 40px);
}
.revenue-bar, .revenue-bar::after { background: var(--erp-primary); }
.revenue-bar::after { background: var(--erp-ink); }
.revenue-bar-previous { background: var(--erp-chart-neutral); }
.chart-legend i, .legend-current { background: var(--erp-primary); }
.legend-previous { background: var(--erp-chart-neutral); }
.lead-source-donut { border-color: var(--erp-surface); }
.lead-trend-item > i { background: var(--erp-chart-primary); }
.funnel-track, .status-track, .source-track, .target-track { background: var(--erp-surface-soft); }
.funnel-track > i { background: var(--erp-chart-primary); }
.status-track > i { background: var(--erp-chart-neutral); }
.status-track[data-status="DRAFT"] > i { background: var(--erp-chart-neutral); }
.status-track[data-status="CREDIT_CHECK"] > i,
.status-track[data-status="IN_PROGRESS"] > i,
.status-track[data-status="PENDING"] > i { background: var(--erp-warning); }
.status-track[data-status="CONFIRMED"] > i,
.status-track[data-status="ALLOCATED"] > i,
.status-track[data-status="DISPATCHED"] > i,
.status-track[data-status="PACKING"] > i,
.status-track[data-status="SHIPPED"] > i { background: var(--erp-info); }
.status-track[data-status="DELIVERED"] > i,
.status-track[data-status="COMPLETED"] > i { background: var(--erp-success); }
.status-track[data-status="CANCELLED"] > i,
.status-track[data-status="VOID"] > i { background: var(--erp-danger); }
.source-track > span { background: var(--erp-teal); }
.target-track > span { background: var(--erp-primary); }
.pipeline-table th, .orders-table th { color: var(--erp-muted); background: var(--erp-surface-soft); }
.pipeline-table td, .orders-table td { border-color: var(--erp-border); color: var(--erp-ink); }
.pipeline-table-wrap, .orders-panel .dashboard-table-wrap { border-color: var(--erp-border); }
.panel-link:hover { color: var(--erp-primary-hover); }
.dashboard-task-list a { color: var(--erp-primary); }
.kanban-column { border: 1px solid var(--erp-border); border-radius: 10px; background: var(--erp-surface-soft); }
.kanban-card { border-color: var(--erp-border); border-radius: 9px; background: var(--erp-surface); }
.operations-summary-card, .operations-summary-panel { border-color: var(--erp-border); border-radius: 12px; box-shadow: none; }
.operations-summary-card:hover { border-color: var(--erp-primary-border); background: var(--erp-surface-soft); }
.finance-access-note, .finance-locked { color: var(--erp-muted); background: var(--erp-surface-soft); border-color: var(--erp-border); }

.zi-page[data-zalo-inbox] { color: var(--erp-ink); }
.zi-heading .eyebrow, .zi-panel-section .eyebrow { color: var(--erp-primary); }
.zi-heading h1, .zi-chat-heading-copy strong, .zi-panel-section h2 { color: var(--erp-ink); }
.zi-heading p, .zi-chat-heading-copy small, .zi-owner-label, .zi-panel-section dt,
.zi-reply-participants span, .zi-conversation-copy small, .zi-preview, .zi-pagination { color: var(--erp-muted); }
.zi-workspace { border-color: var(--erp-border); border-radius: 12px; background: var(--erp-surface); box-shadow: none; }
.zi-list-pane, .zi-customer-pane, .zi-panel-section { border-color: var(--erp-border); }
.zi-list-pane > header, .zi-chat-header, .zi-customer-tabs { border-color: var(--erp-border); background: var(--erp-surface); }
.zi-conversation { border-color: var(--erp-border); }
.zi-conversation:hover { background: var(--erp-surface-soft); }
.zi-conversation.is-selected { background: var(--erp-chat-selected); box-shadow: inset 3px 0 var(--erp-primary); }
.zi-avatar { background: var(--erp-primary-soft); color: var(--erp-primary); box-shadow: none; }
.zi-conversation-copy strong, .zi-panel-section dd, .zi-reply-participants strong, .zi-bubble p { color: var(--erp-ink); }
.zi-unread { background: var(--erp-primary); }
.zi-pagination a, .zi-panel-section a, .zi-attachment-download { color: var(--erp-primary); }
.zi-messages { background: var(--erp-chat-background); }
.zi-bubble { border-color: var(--erp-border); border-radius: 18px; background: var(--erp-chat-incoming); color: var(--erp-chat-incoming-text); box-shadow: none; }
.zi-bubble p { color: var(--erp-chat-incoming-text); }
.zi-message.is-OUTBOUND .zi-bubble { border-color: transparent; border-radius: 18px 18px 6px 18px; background: var(--erp-chat-outgoing-gradient); color: #FFFFFF; }
.zi-message.is-OUTBOUND .zi-bubble p,
.zi-message.is-OUTBOUND .zi-bubble footer,
.zi-message.is-OUTBOUND .zi-message-source,
.zi-message.is-OUTBOUND .zi-message-sender { color: #FFFFFF; }
.zi-message.is-OUTBOUND .zi-attachment-download { color: #FFFFFF; text-decoration: underline; text-underline-offset: 2px; }
.zi-date-separator { color: var(--erp-muted); }
.zi-composer {
  position: relative;
  isolation: isolate;
  border: 1px solid var(--erp-border);
  border-radius: 22px;
  background: var(--erp-surface);
  box-shadow: none;
  transition: border-color 180ms ease;
}
.zi-composer::before {
  position: absolute;
  z-index: 1;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  background: var(--erp-chat-focus-gradient);
  content: "";
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}
.zi-composer:focus-within { border-color: transparent; box-shadow: none; }
.zi-composer:focus-within::before { opacity: 1; }
.zi-composer > textarea, .zi-composer > .zi-composer-footer { position: relative; z-index: 2; }
.zi-composer textarea { border: 0; border-radius: 0; background: transparent; color: var(--erp-ink); }
.zi-composer textarea:focus, .zi-composer textarea:focus-visible { border: 0; outline: none; box-shadow: none; }
.zi-composer .zi-file-action:focus-within { outline: 2px solid var(--erp-focus-outline); outline-offset: 2px; }
.zi-composer .button { border-color: var(--erp-primary); background: var(--erp-primary); color: #FFFFFF; transition: background-color 180ms ease, border-color 180ms ease; }
.zi-composer .button:hover { border-color: var(--erp-primary-hover); background: var(--erp-primary-hover); }
.zi-customer-tabs [role="tab"][aria-selected="true"] { background: var(--erp-primary-soft); color: var(--erp-primary); }
.zi-profile-toggle, .zi-status-form select, .zi-sync-media, .zi-icon-button, .zi-record-action, .zi-load-older {
  border-color: var(--erp-border); border-radius: 8px; color: var(--erp-primary);
}
.zi-profile-toggle:hover, .zi-sync-media:hover, .zi-record-action:hover { border-color: var(--erp-primary-border); background: var(--erp-primary-soft); }
.zi-settings-state { border-color: #F3DFBA; background: var(--erp-warning-soft); color: #80551C; }
.zi-toolbar, .zi-search, .zi-filter-drawer > summary { border-color: var(--erp-border); border-radius: 8px; }
.zi-search { background: var(--erp-surface); }
.zi-filter-count.is-active { background: var(--erp-primary-soft); color: var(--erp-primary); }
.zi-quick-filters a { border-color: var(--erp-border); border-radius: 8px; color: var(--erp-muted); }
.zi-quick-filters a:hover { border-color: var(--erp-border); background: var(--erp-surface-soft); }
.zi-quick-filters a[aria-current="page"] { border-color: var(--erp-primary-border); background: var(--erp-primary-soft); color: var(--erp-primary); }

.marketing-period-tabs a[aria-current="page"] { border-color: var(--erp-primary-border); background: var(--erp-primary-soft); color: var(--erp-primary); }
.marketing-kpi.tone-blue { border-top-color: var(--erp-primary); }
.marketing-kpi.tone-violet { border-top-color: var(--erp-primary); }
.marketing-kpi.tone-green { border-top-color: var(--erp-success); }
.marketing-kpi.tone-orange { border-top-color: var(--erp-gold); }
.marketing-insight { background: var(--erp-primary-soft); color: var(--erp-ink); }
.source-segment-0, .source-legend-0 { background: var(--erp-primary); }
.source-segment-1, .source-legend-1 { background: var(--erp-teal); }
.source-segment-2, .source-legend-2 { background: var(--erp-periwinkle); }
.source-segment-3, .source-legend-3 { background: var(--erp-gold); color: var(--erp-ink); }
.source-segment-4, .source-legend-4 { background: var(--erp-chart-neutral); }
.source-segment-5, .source-legend-5 { background: var(--erp-chart-slate); }
.zi-marketing-page .zi-marketing-filters, .zi-marketing-kpi, .zi-marketing-panel {
  border-color: var(--erp-border); border-radius: 12px; box-shadow: none;
}
.zi-marketing-kpi strong, .zi-marketing-panel h2 { color: var(--erp-ink); }
.zi-marketing-kpi:hover { border-color: var(--erp-primary-border); }
.zi-marketing-kpi span, .zi-marketing-kpi small { color: var(--erp-muted); }
.zi-marketing-panel header { border-color: var(--erp-border); }
.target-label { color: var(--erp-muted); }
.target-track > span { background: var(--erp-primary); }
.source-row { margin: 6px 18px; }
.source-panel .dashboard-empty { margin: 6px 18px; }
.pipeline-table-wrap { max-height: 300px; margin: 0 18px 18px; }

@media (max-width: 1180px) {
  .sales-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sales-metric:nth-child(3n) { border-right: 0; }
}
@media (max-width: 900px) {
  .page { width: 100%; min-height: calc(100vh - 60px); padding: 22px 18px 32px; }
  .dashboard-panels-primary, .dashboard-panels-secondary, .dashboard-visualizations { grid-template-columns: 1fr; height: auto; }
  .dashboard-panel { min-height: 0; }
  .revenue-chart { height: 210px; }
  .zi-workspace { border-radius: 10px; }
}
@media (max-width: 600px) {
  .page { padding: 18px 14px 28px; }
  .sales-dashboard { gap: 12px; }
  .dashboard-heading { align-items: flex-start; }
  .dashboard-toolbar { align-items: stretch; }
  .sales-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sales-metric { padding: 14px; }
  .dashboard-visualizations .dashboard-panel { min-height: 0; }
  .revenue-summary { max-width: 48%; }
  .source-panel .donut-chart-layout { grid-template-columns: 90px minmax(0, 1fr); padding-right: 12px; padding-left: 12px; }
  .source-panel .lead-source-donut { width: 84px; }
  .source-panel .lead-source-donut:before { inset: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Keep the public authentication screens compact and make their submit action primary. */
body.auth-shell .auth-page {
  width: min(100%, 480px);
  max-width: 480px;
  min-height: 0;
  padding: 0;
}
.auth-card {
  width: 100%;
  border: 1px solid var(--erp-border);
  border-radius: 12px;
  background: var(--erp-surface);
  box-shadow: 0 12px 34px rgba(32, 43, 67, .07);
}
.auth-card input[type="submit"]:not(.secondary) {
  min-height: 40px;
  border: 1px solid var(--erp-primary);
  border-radius: 8px;
  background: var(--erp-primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.auth-card input[type="submit"]:not(.secondary):hover {
  border-color: var(--erp-primary-hover);
  background: var(--erp-primary-hover);
}
@media (max-width: 600px) {
  body.auth-shell .auth-main { padding: 22px 16px; }
  body.auth-shell .auth-page { width: 100%; }
  .auth-card { padding: 24px; }
}

/* Compact, database-independent response pages for Django's 400/403/404/500 handlers. */
.erp-error-document { min-width: 320px; min-height: 100vh; margin: 0; background: var(--erp-bg); }
.erp-error-shell { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.erp-error-card {
  width: min(100%, 520px);
  padding: 32px;
  border: 1px solid var(--erp-border);
  border-radius: 14px;
  background: var(--erp-surface);
  box-shadow: 0 12px 34px rgba(32, 43, 67, .06);
}
.erp-error-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--erp-ink); text-decoration: none; }
.erp-error-brand:hover { color: var(--erp-ink); text-decoration: none; }
.erp-error-brand-mark { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 9px; background: var(--erp-primary); color: #fff; font-size: 17px; font-weight: 700; }
.erp-error-brand-copy { display: grid; gap: 1px; font-size: 9px; letter-spacing: .12em; line-height: 1.2; }
.erp-error-brand-copy strong { color: var(--erp-ink); font-size: 14px; letter-spacing: .03em; }
.erp-error-status { display: inline-flex; margin-top: 32px; padding: 5px 9px; border: 1px solid var(--erp-primary-border); border-radius: 999px; background: var(--erp-primary-soft); color: var(--erp-primary); font-size: 12px; font-weight: 700; }
.erp-error-card h1 { margin: 14px 0 8px; color: var(--erp-ink); font-size: clamp(23px, 5vw, 28px); line-height: 1.25; }
.erp-error-card p { margin: 0; color: var(--erp-muted); font-size: 14px; }
.erp-error-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.erp-error-actions .button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; padding: 9px 15px; border-radius: 8px; background: var(--erp-primary); color: #fff; font-size: 13px; font-weight: 650; text-decoration: none; }
.erp-error-actions .button:hover { background: var(--erp-primary-hover); color: #fff; }
.erp-error-note { display: block; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--erp-border); color: var(--erp-muted); font-size: 12px; }
@media (max-width: 480px) {
  .erp-error-shell { padding: 16px; }
  .erp-error-card { padding: 24px; border-radius: 12px; }
}

/* Shared sidebar states: disclosure follows its open attribute, never hover alone. */
.nav-flyout-title {
  display: none;
  padding: 7px 9px 5px;
  color: var(--erp-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
}

.app-shell.sidebar-is-compact .sidebar .nav-group[open] > .nav-submenu {
  position: fixed;
  z-index: 80;
  top: var(--nav-flyout-top, 12px);
  left: var(--erp-sidebar-compact-width);
  display: grid;
  width: min(250px, calc(100vw - var(--erp-sidebar-compact-width) - 12px));
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  gap: 3px;
  overflow: auto;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--erp-border);
  border-radius: 10px;
  background: var(--erp-surface);
  box-shadow: var(--erp-shadow-menu);
}

.app-shell.sidebar-is-compact .sidebar .nav-group[open] > .nav-submenu .nav-flyout-title { display: block; }
.app-shell.sidebar-is-compact .sidebar .nav-submenu .nav-link { justify-content: flex-start; gap: 9px; padding: 7px 9px; }
.app-shell.sidebar-is-compact .sidebar .nav-submenu .nav-label { display: inline; }
.app-shell.sidebar-is-compact .sidebar .nav-submenu .nav-badge { display: inline-flex; margin-left: auto; }

@media (max-width: 900px) {
  .sidebar {
    width: min(290px, calc(100vw - 56px));
    height: 100vh;
    height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .sidebar .sidebar-nav {
    flex: 0 0 auto;
    min-height: auto;
    overflow: visible;
    white-space: normal;
  }

  .sidebar .home-link,
  .sidebar .nav-group-trigger,
  .sidebar .nav-link {
    min-height: 44px;
  }

  .sidebar .nav-submenu { margin-left: 16px; }

  .sidebar-close,
  .sidebar-toggle {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar .nav-group-trigger,
  .nav-chevron,
  .erp-select-chevron,
  .erp-select-spinner,
  .erp-select-menu,
  .sidebar,
  .app-main {
    transition-duration: .01ms;
  }
}
.notification-menu { position: relative; order: 2; flex: 0 0 38px; }
.global-search { position: relative; }
.global-search input { padding-right: 34px; }
.global-search .search-clear { position: absolute; right: 49px; top: 50%; display: grid; width: 26px; min-width: 26px; height: 26px; min-height: 26px; place-items: center; padding: 0; border: 0; border-radius: 50%; color: var(--erp-muted); background: transparent; font-size: 19px; line-height: 1; transform: translateY(-50%); }
.global-search .search-clear:hover { color: var(--erp-primary); background: var(--erp-primary-soft); filter: none; }
.global-search .search-clear[hidden] { display: none; }
.notification-menu > summary { list-style: none; cursor: pointer; }
.notification-menu > summary::-webkit-details-marker { display: none; }
.notification-menu > summary::marker { content: ""; }
.notification-menu[open] > summary { color: var(--erp-primary); background: var(--erp-primary-soft); }
.notification-popover { position: absolute; z-index: 100; top: calc(100% + 10px); right: 0; width: min(410px, calc(100vw - 24px)); max-height: min(76vh, 620px); overflow: hidden; border: 1px solid var(--erp-border); border-radius: 12px; background: var(--erp-surface); box-shadow: var(--erp-shadow-menu); }
.notification-popover > header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--erp-border); }
.notification-popover > header > div { display: grid; gap: 2px; }
.notification-popover > header strong { color: var(--erp-ink); font-size: 14px; }
.notification-popover > header span,.notification-popover > header a { color: var(--erp-muted); font-size: 11px; }
.notification-popover > header a { color: var(--erp-primary); font-weight: 650; white-space: nowrap; }
.notification-preview-list { max-height: min(66vh, 540px); overflow: auto; overscroll-behavior: contain; }
.notification-preview-item { display: grid; grid-template-columns: 32px minmax(0,1fr) 8px; gap: 10px; padding: 13px 15px; border-bottom: 1px solid var(--erp-border); }
.notification-preview-item:last-child { border-bottom: 0; }
.notification-preview-item.is-unread { background: #faf9ff; }
.notification-preview-icon { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 9px; background: var(--erp-surface-soft); color: var(--erp-muted); }
.notification-preview-icon .nav-icon { width: 16px; height: 16px; }
.notification-preview-copy { min-width: 0; }
.notification-preview-copy > strong { display: block; color: var(--erp-ink); font-size: 12px; line-height: 1.4; }
.notification-preview-copy > p { display: -webkit-box; margin: 3px 0; overflow: hidden; color: var(--erp-muted); font-size: 11px; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.notification-preview-copy > small { display: block; color: var(--erp-muted); font-size: 10px; }
.notification-preview-link,.notification-mark-read { display: inline-block; margin: 6px 10px 0 0; padding: 0; border: 0; color: var(--erp-primary); background: transparent; font-size: 11px; font-weight: 650; text-decoration: none; cursor: pointer; }
.notification-mark-read:hover,.notification-preview-link:hover { text-decoration: underline; }
.notification-unread-dot { width: 7px; height: 7px; align-self: center; border-radius: 50%; background: var(--erp-primary); }
.notification-preview-item:not(.is-unread) .notification-unread-dot { visibility: hidden; }
.notification-preview-empty { margin: 0; padding: 24px 15px; color: var(--erp-muted); text-align: center; font-size: 12px; }
.notification-inline-error { margin: 5px 0 0; color: var(--erp-danger); font-size: 11px; }
.notification-center { max-width: 1060px; margin: 0 auto; }
.notification-center-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 22px; }
.notification-center-heading h1 { margin-bottom: 7px; color: var(--erp-ink); font-size: 26px; }
.notification-center-heading .subtitle { margin: 0; }
.notification-filters { display: flex; gap: 5px; margin-bottom: 14px; padding: 4px; border-bottom: 1px solid var(--erp-border); }
.notification-filters a { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 8px 8px 0 0; color: var(--erp-muted); font-size: 12px; text-decoration: none; }
.notification-filters a[aria-current="page"] { color: var(--erp-primary); background: var(--erp-primary-soft); font-weight: 700; }
.notification-filters a span { padding: 1px 6px; border-radius: 10px; background: var(--erp-surface-soft); font-size: 10px; }
.notification-center-list { overflow: hidden; border: 1px solid var(--erp-border); border-radius: 12px; background: var(--erp-surface); }
.notification-center-row { display: grid; grid-template-columns: 36px minmax(0,1fr) auto; gap: 13px; align-items: start; padding: 16px; border-bottom: 1px solid var(--erp-border); }
.notification-center-row:last-child { border-bottom: 0; }
.notification-center-row.is-unread { background: #faf9ff; }
.notification-center-copy h2 { margin: 0 0 4px; color: var(--erp-ink); font-size: 14px; line-height: 1.4; }
.notification-center-row:not(.is-unread) h2 { font-weight: 600; }
.notification-center-copy p { margin: 0 0 6px; color: var(--erp-text-secondary); font-size: 13px; overflow-wrap: anywhere; }
.notification-center-copy small { color: var(--erp-muted); font-size: 11px; }
.notification-center-copy > a { display: block; width: fit-content; margin-top: 6px; color: var(--erp-primary); font-size: 12px; font-weight: 650; }
.notification-center-actions { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.notification-read-label { color: var(--erp-muted); font-size: 11px; }
.notification-center-empty { display: grid; justify-items: center; padding: 64px 20px; border: 1px dashed var(--erp-border); border-radius: 12px; background: var(--erp-surface); text-align: center; }
.notification-empty-icon { display: grid; width: 44px; height: 44px; place-items: center; margin-bottom: 14px; border-radius: 14px; background: var(--erp-primary-soft); color: var(--erp-primary); }
.notification-empty-icon .nav-icon { width: 20px; height: 20px; }
.notification-center-empty strong { color: var(--erp-ink); font-size: 14px; }
.notification-center-empty p { margin: 6px 0 0; color: var(--erp-muted); font-size: 12px; }
.notification-pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 15px 2px; color: var(--erp-muted); font-size: 12px; }
.notification-pagination > div { display: flex; gap: 8px; }
.notification-pagination a { padding: 7px 11px; border: 1px solid var(--erp-border); border-radius: 8px; color: var(--erp-primary); text-decoration: none; }
.pipeline-configuration-page { max-width: 1180px; margin: 0 auto; }
.pipeline-configuration-page > .card { padding: 20px 22px; border-radius: 12px; }
.pipeline-configuration-page > .card > h2,.pipeline-configuration-page .section-heading h2 { margin-bottom: 14px; color: var(--erp-ink); font-size: 16px; }
.pipeline-configuration-page .filters { align-items: end; margin: 0; }
.pipeline-configuration-page .filters > label { max-width: 570px; }
.pipeline-configuration-page form.form-grid { align-items: start; gap: 16px 20px; }
.pipeline-configuration-page form.form-grid > label { display: grid; align-content: start; gap: 6px; color: var(--erp-text-primary); font-size: 12px; font-weight: 600; }
.pipeline-configuration-page form.form-grid > label input,.pipeline-configuration-page form.form-grid > label select,.pipeline-configuration-page form.form-grid > label textarea { min-width: 0; }
.pipeline-configuration-page .table-wrap { overflow-x: auto; }
.pipeline-configuration-page .section-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.pipeline-configuration-page .empty { padding: 38px 22px; border: 1px dashed var(--erp-border); border-radius: 12px; background: var(--erp-surface); }
.navigation-drawer-open { overflow: hidden; }
@media (max-width: 640px) {
  .notification-popover { position: fixed; top: 58px; right: 10px; width: calc(100vw - 20px); max-height: calc(100dvh - 76px); }
  .notification-preview-list { max-height: calc(100dvh - 140px); }
  .notification-center-heading { align-items: flex-start; flex-direction: column; gap: 12px; }
  .notification-center-heading h1 { font-size: 23px; }
  .notification-center-row { grid-template-columns: 32px minmax(0,1fr); gap: 10px; padding: 13px 11px; }
  .notification-center-actions { grid-column: 2; justify-content: flex-start; }
  .pipeline-configuration-page > .card { padding: 16px; }
  .pipeline-configuration-page form.form-grid { grid-template-columns: minmax(0,1fr); }
}
.sidebar-collapse-icon { display: block; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .18s ease; }
.app-shell.sidebar-is-compact .sidebar-collapse-icon { transform: rotate(180deg); }
.inbox-shell .collapse-toggle { display: inline-grid; }
@media (max-width: 900px) {
  .inbox-shell .collapse-toggle { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar-collapse-icon { transition: none; }
}
.context-help-link { display: inline-flex; width: auto; min-width: 38px; gap: 6px; padding: 0 9px; font-size: 12px; }
.context-help-link .nav-icon { width: 18px; height: 18px; }
@media (max-width: 640px) {
  .context-help-link > span { display: none; }
}
