/* Nile Build shared design contract.
 * Load after historical theme files and before page styles. Keep shell dimensions,
 * typography and component tokens here; page layouts belong to their own file.
 * !important bridges legacy theme rules until those files are retired safely.
 */
:root {
  --nl-navy: #202326;
  --nl-navy-2: #303438;
  --nl-gold: #d6b777;
  --nl-blue: #795718;
  --nl-blue-2: #634511;
  --nl-accent-soft: #fbf4e5;
  --nl-bg: #f5f5f3;
  --nl-surface: #fff;
  --nl-line: #e3e4df;
  --nl-text: #23292d;
  --nl-muted: #626c71;
  --nl-green: #16805a;
  --nl-amber: #996415;
  --nl-red: #b8333c;
  --nl-violet: #7455a4;
  --nl-cyan: #167c8f;
  --nl-radius: 14px;
  --nl-radius-sm: 9px;
  --nl-radius-lg: 14px;
  --nl-shadow: 0 3px 14px rgb(32 35 38 / 4%);
  --nl-shadow-hover: 0 6px 20px rgb(32 35 38 / 7%);
  --nl-page-max: 1600px;
  --nl-page-pad: clamp(12px, 1.7vw, 28px);
  --nl-gap: 16px;
  --nl-sidebar-width: 256px;
  --nl-control-height: 2.75rem;
  --nl-font: 'Cairo', Tahoma, Arial, sans-serif;
  --nl-text-caption: .8125rem;
  --nl-text-small: .875rem;
  --nl-text-body: clamp(.9375rem, .9rem + .2vw, 1rem);
  --nl-text-control: max(1rem, 16px);
  --nl-text-title: clamp(1.5rem, 1.25rem + 1vw, 2rem);
  --nl-text-page-heading: clamp(1.5rem, 1.35rem + .5vw, 1.75rem);
  --nl-text-section: 1.125rem;
  --nl-text-metric: clamp(1.125rem, 1rem + .4vw, 1.375rem);
  --nl-leading-body: 1.75;
  --nl-leading-heading: 1.5;
  --nl-weight-regular: 400;
  --nl-weight-medium: 600;
  --nl-weight-strong: 700;
  --erp-header-height: 4.75rem !important;
  /* Compatibility aliases let established components consume the same palette. */
  --navy: var(--nl-text); --blue: var(--nl-blue); --muted: var(--nl-muted);
  --line: var(--nl-line); --surface: var(--nl-surface); --bg: var(--nl-bg);
  --erp-ink: var(--nl-text); --erp-muted: var(--nl-muted); --erp-line: var(--nl-line);
  --erp-surface: var(--nl-surface); --erp-blue: var(--nl-blue); --erp-blue-soft: var(--nl-accent-soft);
  --flutter-primary: var(--nl-blue); --flutter-primary-strong: var(--nl-blue-2);
  --flutter-primary-soft: var(--nl-accent-soft); --flutter-text: var(--nl-text);
  --flutter-muted: var(--nl-muted); --flutter-border: var(--nl-line); --flutter-bg: var(--nl-bg);
}
html { font-size: 100% !important; }
html, body { background: var(--nl-bg) !important; color: var(--nl-text) !important; }
body.erp-ui-refresh.erp-sidebar-layout {
  min-inline-size: 0;
  font-family: var(--nl-font) !important;
  font-size: var(--nl-text-body) !important;
  line-height: var(--nl-leading-body) !important;
  font-weight: var(--nl-weight-regular) !important;
  background: var(--nl-bg) !important;
}
body.erp-ui-refresh.erp-sidebar-layout .erp-shell { display: block !important; min-block-size: 100dvh; background: transparent !important; }
body.erp-ui-refresh.erp-sidebar-layout .content {
  box-sizing: border-box !important;
  inline-size: 100% !important;
  width: 100% !important;
  min-inline-size: 0 !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 20px var(--nl-page-pad) 40px !important;
}
body.erp-ui-refresh.erp-sidebar-layout .content > * {
  min-inline-size: 0;
  max-inline-size: var(--nl-page-max);
  margin-inline: auto;
}
body.erp-ui-refresh.erp-sidebar-layout :is(h1, h2, h3, h4) { font-family: var(--nl-font) !important; letter-spacing: 0 !important; line-height: var(--nl-leading-heading) !important; font-weight: var(--nl-weight-strong) !important; }
body.erp-ui-refresh.erp-sidebar-layout :is(button, input, select, textarea) { font-family: var(--nl-font) !important; font-weight: var(--nl-weight-regular); line-height: var(--nl-leading-body); }
body.erp-ui-refresh.erp-sidebar-layout :is(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid var(--nl-blue) !important;
  outline-offset: 3px !important;
}

/* The company mark is the original uploaded image, contained without cropping. */
body.erp-ui-refresh.erp-sidebar-layout .erp-header { background: var(--nl-navy) !important; color: #fff !important; border-color: var(--nl-navy-2) !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
/* Keep actions in the shared grid/sidebar flow instead of the legacy fixed top bar. */
body.erp-ui-refresh.erp-sidebar-layout .erp-header .header-actions { position: static !important; inset: auto !important; background: transparent !important; border: 0 !important; box-shadow: none !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
body.erp-ui-refresh.erp-sidebar-layout .erp-header .top-brand { display: flex !important; align-items: center !important; gap: 12px !important; max-width: none !important; color: #fff !important; }
body.erp-ui-refresh.erp-sidebar-layout .erp-header .brand-logo {
  display: block;
  inline-size: 52px;
  block-size: 52px;
  flex: 0 0 52px;
  object-fit: contain;
  border: 1px solid rgb(214 183 119 / 40%);
  border-radius: 10px;
  background: #111315;
}
body.erp-ui-refresh.erp-sidebar-layout .erp-header .brand-copy { display: block !important; min-width: 0; }
body.erp-ui-refresh.erp-sidebar-layout .erp-header .top-brand strong { display: block; color: #fff !important; font-size: var(--nl-text-control) !important; font-weight: var(--nl-weight-strong); }
body.erp-ui-refresh.erp-sidebar-layout .erp-header .top-brand small { display: block; color: #d6c7a8 !important; font-size: var(--nl-text-caption) !important; }
body.erp-ui-refresh.erp-sidebar-layout .erp-header :is(.top-navigation .top-nav-link, .nav-group > summary) {
  min-inline-size: 0 !important;
  min-block-size: var(--nl-control-height) !important;
  color: #eaece9 !important;
  font-size: var(--nl-text-small) !important;
  font-weight: var(--nl-weight-medium) !important;
  border-radius: var(--nl-radius-sm) !important;
  background: transparent !important;
  box-shadow: none !important;
}
body.erp-ui-refresh.erp-sidebar-layout .erp-header :is(.top-nav-link.active, .top-nav-link:hover, .nav-group.active > summary, .nav-group[open] > summary, .nav-group > summary:hover) {
  background: var(--nl-gold) !important;
  color: #202326 !important;
  box-shadow: none !important;
}
body.erp-ui-refresh.erp-sidebar-layout .erp-header :is(.nav-dropdown, .user-dropdown, .global-search-results) { background: #fff !important; color: var(--nl-text) !important; border: 1px solid var(--nl-line) !important; border-radius: var(--nl-radius-sm) !important; }
body.erp-ui-refresh.erp-sidebar-layout .erp-header .nav-dropdown h3 { color: var(--nl-muted) !important; font-size: var(--nl-text-caption) !important; }
body.erp-ui-refresh.erp-sidebar-layout .erp-header .nav-dropdown a { color: var(--nl-text) !important; font-size: var(--nl-text-small) !important; font-weight: var(--nl-weight-medium) !important; }
body.erp-ui-refresh.erp-sidebar-layout .erp-header .nav-dropdown :is(a:hover, a.active) { background: var(--nl-accent-soft) !important; color: var(--nl-blue) !important; }
body.erp-ui-refresh.erp-sidebar-layout .erp-header :is(.icon-button, .language-action, .user-menu-summary, .user-logout-button) { border: 1px solid #676358 !important; background: #303438 !important; color: #fff !important; border-radius: var(--nl-radius-sm) !important; min-height: 40px !important; }
body.erp-ui-refresh.erp-sidebar-layout .erp-header .user-copy b { color: #fff !important; }
body.erp-ui-refresh.erp-sidebar-layout .erp-header .user-copy small { color: #cccfc9 !important; }
body.erp-ui-refresh.erp-sidebar-layout .erp-header .user-avatar { background: #e4d4b5 !important; color: #382d18 !important; }
body.erp-ui-refresh.erp-sidebar-layout .erp-header .user-logout-button:hover { background: #fff !important; color: var(--nl-red) !important; }
body.erp-ui-refresh.erp-sidebar-layout .erp-header :is(a, button, summary):focus-visible { outline-color: var(--nl-gold) !important; }
/* Keep the closed search control bounded inside the action flex row. */
body.erp-ui-refresh.erp-sidebar-layout .erp-header .global-search { position: relative !important; flex: 0 0 var(--nl-control-height) !important; width: var(--nl-control-height) !important; min-width: 0 !important; height: var(--nl-control-height) !important; margin: 0 !important; }
body.erp-ui-refresh.erp-sidebar-layout .erp-header .global-search-panel { min-height: var(--nl-control-height) !important; height: auto !important; color: var(--nl-text); background: #fff !important; overflow: visible !important; }
body.erp-ui-refresh.erp-sidebar-layout .erp-header .global-search-panel input { padding: 0 !important; font-size: var(--nl-text-control) !important; line-height: var(--nl-leading-body) !important; min-height: 0 !important; box-shadow: none !important; border: 0 !important; background: transparent !important; color: var(--nl-text) !important; }

/* One visible ordered menu serves desktop and the mobile drawer. */
body.erp-ui-refresh.erp-sidebar-layout .erp-header .nav-section { display: grid !important; grid-template-columns: minmax(0, 1fr) !important; gap: 3px !important; margin: 0 !important; padding: 8px 0 !important; min-inline-size: 0 !important; }
body.erp-ui-refresh.erp-sidebar-layout .erp-header .nav-section + .nav-section { border-block-start: 1px solid #494a43; }
body.erp-ui-refresh.erp-sidebar-layout .erp-header .nav-section-title { margin: 0 !important; padding: 8px 12px 5px !important; color: #d6c7a8 !important; font-size: var(--nl-text-caption) !important; font-weight: var(--nl-weight-medium) !important; line-height: var(--nl-leading-body) !important; }
body.erp-ui-refresh.erp-sidebar-layout .erp-header .nav-section .top-nav-link { display: flex !important; align-items: center !important; position: relative !important; min-inline-size: 0 !important; max-inline-size: 100%; text-align: start; overflow-wrap: break-word; }
body.erp-ui-refresh.erp-sidebar-layout .erp-header .nav-section .top-nav-link::after { display: none !important; }
body.erp-ui-refresh.erp-sidebar-layout .secondary-navigation { max-inline-size: 100%; margin-inline: 0 !important; gap: 6px !important; padding: 8px !important; background: var(--nl-surface) !important; border-color: var(--nl-line) !important; border-radius: var(--nl-radius-sm) !important; }
body.erp-ui-refresh.erp-sidebar-layout .secondary-navigation a { display: inline-flex; align-items: center; min-block-size: var(--nl-control-height) !important; padding: 8px 12px !important; font-size: var(--nl-text-small) !important; font-weight: var(--nl-weight-medium) !important; line-height: var(--nl-leading-body); color: var(--nl-text) !important; }
body.erp-ui-refresh.erp-sidebar-layout .secondary-navigation :is(a.active, a:hover) { color: var(--nl-blue) !important; background: var(--nl-accent-soft) !important; box-shadow: none !important; }

/* Desktop: the sidebar occupies exactly the space reserved by the content. */
@media (min-width: 1101px) {
  body.erp-ui-refresh.erp-sidebar-layout .erp-header {
    position: fixed !important;
    inset: auto !important;
    inset-block: 0 !important;
    inset-inline-start: 0 !important;
    inset-inline-end: auto !important;
    width: var(--nl-sidebar-width) !important;
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    box-shadow: none !important;
    z-index: 100 !important;
  }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .header-primary { display: flex !important; flex-direction: column !important; align-items: stretch !important; height: auto !important; min-height: 100% !important; padding: 18px 12px !important; gap: 16px !important; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .top-brand { order: 0 !important; padding: 0 4px 16px !important; border-bottom: 1px solid #494a43 !important; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .top-navigation { position: static !important; display: flex !important; flex-direction: column !important; align-items: stretch !important; width: 100% !important; height: auto !important; flex: 1 0 auto !important; order: 1 !important; gap: 5px !important; overflow: visible !important; transform: none !important; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header :is(.top-navigation .top-nav-link, .nav-group > summary) { width: 100% !important; height: auto !important; justify-content: flex-start !important; white-space: normal !important; padding: 10px 12px !important; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .nav-group { display: block !important; height: auto !important; width: 100% !important; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .nav-dropdown { position: static !important; width: 100% !important; max-width: 100% !important; margin: 6px 0 !important; box-shadow: none !important; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .nav-mega-menu { grid-template-columns: 1fr !important; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .header-actions { display: flex !important; flex-direction: row !important; flex-wrap: wrap !important; height: auto !important; width: 100% !important; min-width: 0 !important; margin: auto 0 0 !important; order: 2 !important; gap: 8px !important; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .user-menu { flex-direction: column; align-items: stretch; width: 100% !important; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .user-copy { display: block !important; max-width: 155px; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .user-logout-button { width: 100%; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .global-search.is-open .global-search-panel { position: fixed !important; top: 16px !important; inset-inline-start: calc(var(--nl-sidebar-width) + 12px) !important; inset-inline-end: auto !important; width: min(420px, calc(100vw - var(--nl-sidebar-width) - 40px)) !important; transform: none !important; }
  body.erp-ui-refresh.erp-sidebar-layout .content { margin-inline-start: var(--nl-sidebar-width) !important; width: calc(100% - var(--nl-sidebar-width)) !important; inline-size: calc(100% - var(--nl-sidebar-width)) !important; }
  body.erp-ui-refresh.erp-sidebar-layout .nav-menu-button { display: none !important; }
  body.erp-ui-refresh.erp-sidebar-layout .secondary-navigation { top: 12px !important; }
}

/* Shared surface, heading, control and table scale. */
body.erp-ui-refresh.erp-sidebar-layout :is(.panel, .card, .metric-card, .focus-card, .dashboard-card, .workspace-card, .module-stat, .project-card) { min-inline-size: 0 !important; background: var(--nl-surface) !important; border: 1px solid var(--nl-line) !important; border-radius: var(--nl-radius) !important; box-shadow: var(--nl-shadow) !important; }
body.erp-ui-refresh.erp-sidebar-layout :is(.page-heading, .project-hero.panel) { margin-block: 0 18px !important; padding: 20px 24px !important; min-height: 0 !important; border-radius: var(--nl-radius) !important; }
body.erp-ui-refresh.erp-sidebar-layout .page-heading:not(.dashboard-heading) { background: #fff !important; border: 1px solid var(--nl-line) !important; }
body.erp-ui-refresh.erp-sidebar-layout :is(.page-heading h1, .project-hero h1) { font-size: var(--nl-text-title) !important; font-weight: var(--nl-weight-strong) !important; margin-block: 4px 8px !important; }
body.erp-ui-refresh.erp-sidebar-layout .page-heading p { font-size: var(--nl-text-small) !important; }
/* Neutral shared page header overrides the old dark-hero selectors at the
 * same specificity. Keep the intentional dashboard identity and project hero. */
body.erp-ui-refresh.erp-sidebar-layout .page-heading { display: flex !important; flex-direction: row !important; flex-wrap: wrap !important; align-items: center !important; justify-content: space-between !important; gap: 16px 24px !important; box-sizing: border-box !important; text-align: start !important; }
body.erp-ui-refresh.erp-sidebar-layout .page-heading > * { min-inline-size: 0 !important; max-inline-size: 100% !important; }
body.erp-ui-refresh.erp-sidebar-layout .page-heading > div:first-child:not(.heading-actions) { flex: 1 1 min(100%, 28rem); }
body.erp-ui-refresh.erp-sidebar-layout .page-heading:not(.dashboard-heading) { position: relative !important; overflow: visible !important; min-block-size: 0 !important; color: var(--nl-text) !important; background: var(--nl-surface) !important; background-image: none !important; box-shadow: var(--nl-shadow) !important; }
body.erp-ui-refresh.erp-sidebar-layout .page-heading:not(.dashboard-heading)::before,
body.erp-ui-refresh.erp-sidebar-layout .page-heading:not(.dashboard-heading)::after { content: none !important; display: none !important; }
body.erp-ui-refresh.erp-sidebar-layout .page-heading:not(.dashboard-heading) h1 { margin: 4px 0 8px !important; padding: 0 !important; font-size: var(--nl-text-page-heading) !important; color: var(--nl-text) !important; background: transparent !important; box-shadow: none !important; text-shadow: none !important; opacity: 1 !important; overflow-wrap: break-word; }
body.erp-ui-refresh.erp-sidebar-layout .page-heading:not(.dashboard-heading) h1::before,
body.erp-ui-refresh.erp-sidebar-layout .page-heading:not(.dashboard-heading) h1::after { content: none !important; display: none !important; }
body.erp-ui-refresh.erp-sidebar-layout .page-heading:not(.dashboard-heading) p { margin: 0 !important; padding: 0 !important; max-inline-size: 72ch !important; color: var(--nl-muted) !important; font-size: var(--nl-text-small) !important; line-height: var(--nl-leading-body) !important; background: transparent !important; opacity: 1 !important; overflow-wrap: break-word; }
body.erp-ui-refresh.erp-sidebar-layout .page-heading:not(.dashboard-heading) :is(.breadcrumb, .eyebrow) { display: inline-block; margin: 0 0 2px !important; padding: 0 !important; font-size: var(--nl-text-caption) !important; color: var(--nl-blue) !important; background: transparent !important; opacity: 1 !important; }
body.erp-ui-refresh.erp-sidebar-layout .page-heading :is(.heading-actions, .governed-actions, .lifecycle-actions) { display: flex !important; flex-wrap: wrap !important; align-items: center !important; gap: 8px !important; min-inline-size: 0 !important; margin: 0 !important; padding: 0 !important; }
body.erp-ui-refresh.erp-sidebar-layout .page-heading :is(.primary-button, .secondary-button) { display: inline-flex !important; align-items: center !important; justify-content: center !important; gap: 6px; max-inline-size: 100%; margin: 0 !important; text-align: center; }
body.erp-ui-refresh.erp-sidebar-layout .page-heading:not(.dashboard-heading) .primary-button { background: var(--nl-blue) !important; border-color: var(--nl-blue) !important; color: #fff !important; }
body.erp-ui-refresh.erp-sidebar-layout .page-heading:not(.dashboard-heading) .primary-button:hover { background: var(--nl-blue-2) !important; border-color: var(--nl-blue-2) !important; }
body.erp-ui-refresh.erp-sidebar-layout .page-heading:not(.dashboard-heading) .secondary-button { background: var(--nl-surface) !important; border-color: #cbd0ca !important; color: var(--nl-text) !important; }
body.erp-ui-refresh.erp-sidebar-layout .page-heading:not(.dashboard-heading) .secondary-button:hover { background: var(--nl-accent-soft) !important; border-color: #ae925e !important; }
body.erp-ui-refresh.erp-sidebar-layout .dashboard-heading { color: #fff !important; background: linear-gradient(115deg, var(--nl-navy), var(--nl-navy-2)) !important; }
body.erp-ui-refresh.erp-sidebar-layout .dashboard-heading :is(h1, p) { color: #fff !important; }
body.erp-ui-refresh.erp-sidebar-layout .dashboard-heading .eyebrow { color: var(--nl-gold) !important; }
body.erp-ui-refresh.erp-sidebar-layout :is(.panel h2, .panel h3) { color: var(--nl-text) !important; font-size: var(--nl-text-section) !important; }
body.erp-ui-refresh.erp-sidebar-layout :is(.eyebrow, .breadcrumb) { color: var(--nl-blue) !important; font-size: var(--nl-text-caption) !important; }
body.erp-ui-refresh.erp-sidebar-layout :is(.panel > header, .section-heading) { padding: 16px 18px !important; gap: 12px; }
body.erp-ui-refresh.erp-sidebar-layout :is(.primary-button, .secondary-button, .btn) { min-width: 0 !important; min-height: var(--nl-control-height) !important; border-radius: var(--nl-radius-sm) !important; padding: 9px 16px !important; font-size: var(--nl-text-small) !important; font-weight: var(--nl-weight-strong) !important; line-height: 1.5; white-space: normal !important; box-shadow: none !important; transform: none !important; }
body.erp-ui-refresh.erp-sidebar-layout .primary-button { background: var(--nl-blue) !important; border: 1px solid var(--nl-blue) !important; color: #fff !important; }
body.erp-ui-refresh.erp-sidebar-layout .primary-button:hover { background: var(--nl-blue-2) !important; border-color: var(--nl-blue-2) !important; }
body.erp-ui-refresh.erp-sidebar-layout .secondary-button { background: #fff !important; border: 1px solid #cbd0ca !important; color: var(--nl-text) !important; }
body.erp-ui-refresh.erp-sidebar-layout .secondary-button:hover { background: var(--nl-accent-soft) !important; border-color: #ae925e !important; }
body.erp-ui-refresh.erp-sidebar-layout :is(.field, .form-field) { min-width: 0 !important; min-inline-size: 0 !important; }
body.erp-ui-refresh.erp-sidebar-layout :is(.field label, .form-field label) { font-size: var(--nl-text-small) !important; font-weight: var(--nl-weight-medium) !important; color: #47524f !important; }
body.erp-ui-refresh.erp-sidebar-layout :is(input:where(:not([type='checkbox']):not([type='radio']):not([type='hidden']):not([type='range']):not([type='color'])), select, textarea) { min-height: var(--nl-control-height) !important; max-width: 100%; border: 1px solid #cbd0ca !important; background: #fff !important; border-radius: var(--nl-radius-sm) !important; color: var(--nl-text) !important; font-size: var(--nl-text-control) !important; padding: 9px 12px; }
body.erp-ui-refresh.erp-sidebar-layout :is(input[type='checkbox'], input[type='radio']) { min-height: 0 !important; min-width: 0 !important; height: 1.25rem !important; width: 1.25rem !important; flex: 0 0 1.25rem; padding: 0 !important; margin: 0 !important; accent-color: var(--nl-blue); }
/* Keep the native control compact while its whole caption remains clickable. */
body.erp-ui-refresh.erp-sidebar-layout label:has(> :is(input[type='checkbox'], input[type='radio'])) { display: flex !important; align-items: center !important; gap: 8px !important; min-block-size: var(--nl-control-height); }
body.erp-ui-refresh.erp-sidebar-layout :is(input, select, textarea):focus { border-color: var(--nl-blue) !important; box-shadow: 0 0 0 3px rgb(121 87 24 / 12%) !important; }
body.erp-ui-refresh.erp-sidebar-layout :is(input, select, textarea):disabled { background: #f0f1ed !important; color: #616962 !important; cursor: not-allowed; }
body.erp-ui-refresh.erp-sidebar-layout :is(input, select, textarea)[aria-invalid='true'] { border-color: var(--nl-red) !important; }
body.erp-ui-refresh.erp-sidebar-layout form.panel { padding: 20px !important; }
body.erp-ui-refresh.erp-sidebar-layout :is(.form-grid, .detail-grid, .filters-grid) { display: grid !important; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)) !important; gap: 16px !important; align-items: start; }
body.erp-ui-refresh.erp-sidebar-layout :is(.form-grid > label, .detail-grid > label, .module-toolbar > label, .module-toolbar form > label, .filters-grid > .field) { display: grid; align-content: start; gap: 6px; min-width: 0; font-size: var(--nl-text-small); font-weight: var(--nl-weight-medium); color: #47524f; }
body.erp-ui-refresh.erp-sidebar-layout :is(.form-grid, .detail-grid, .filters-grid) > * { min-width: 0; }
body.erp-ui-refresh.erp-sidebar-layout :is(.form-grid, .detail-grid, .filters-grid, .module-toolbar) :is(input:not([type='checkbox']):not([type='radio']), select, textarea) { width: 100%; min-width: 0; box-sizing: border-box; }
body.erp-ui-refresh.erp-sidebar-layout :is(.form-grid, .detail-grid) textarea { min-height: 96px !important; resize: vertical; }
body.erp-ui-refresh.erp-sidebar-layout :is(.form-grid, .detail-grid, .filters-grid) :is(.wide, .full-width) { grid-column: 1 / -1; }
body.erp-ui-refresh.erp-sidebar-layout :is(.form-grid, .detail-grid, .filters-grid, .module-toolbar) small { font-size: var(--nl-text-caption) !important; line-height: 1.65; font-weight: var(--nl-weight-regular); color: var(--nl-muted); }
/* Historical detail cards use label/value divs instead of form labels. */
body.erp-ui-refresh.erp-sidebar-layout .detail-grid > div { display: grid; align-content: start; gap: 6px; overflow-wrap: anywhere; }
body.erp-ui-refresh.erp-sidebar-layout .detail-form > :is(button, .form-actions) { margin-block-start: 16px; }
body.erp-ui-refresh.erp-sidebar-layout .filters-grid > button { align-self: end; }
body.erp-ui-refresh.erp-sidebar-layout .module-toolbar { padding: 16px !important; }
body.erp-ui-refresh.erp-sidebar-layout :is(form.module-toolbar, .module-toolbar form) { display: grid !important; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)) !important; align-items: end !important; gap: 12px !important; }
/* Data-entry grids can reuse toolbar padding without bottom-aligning short
 * fields against a tall fieldset, as in the account dimensions form. */
body.erp-ui-refresh.erp-sidebar-layout form.form-grid.module-toolbar { align-items: start !important; }
body.erp-ui-refresh.erp-sidebar-layout :is(.table-scroll, .table-wrap, .records-panel) { min-inline-size: 0; max-inline-size: 100%; overflow-x: auto !important; overscroll-behavior-inline: contain; }
body.erp-ui-refresh.erp-sidebar-layout table { width: 100% !important; border-collapse: separate !important; border-spacing: 0 !important; background: #fff !important; font-variant-numeric: tabular-nums; }
body.erp-ui-refresh.erp-sidebar-layout table th { font-size: var(--nl-text-small) !important; font-weight: var(--nl-weight-strong) !important; color: #505b58 !important; background: #f4f5f1 !important; padding: 12px !important; border-bottom: 1px solid var(--nl-line) !important; text-align: start; }
body.erp-ui-refresh.erp-sidebar-layout table td { font-size: var(--nl-text-small) !important; line-height: 1.6 !important; padding: 12px !important; color: var(--nl-text) !important; border-bottom: 1px solid #ebede7 !important; text-align: start; }
body.erp-ui-refresh.erp-sidebar-layout table tbody tr:hover { background: #fafbf8 !important; }
body.erp-ui-refresh.erp-sidebar-layout :is(.count-badge, .panel-badge) { background: var(--nl-accent-soft) !important; color: var(--nl-blue) !important; }

/* Common text roles also cover established modules with older fixed-pixel rules. */
body.erp-ui-refresh.erp-sidebar-layout :is(label, .field label, .form-field label) { font-size: var(--nl-text-small) !important; font-weight: var(--nl-weight-medium) !important; line-height: var(--nl-leading-body); }
body.erp-ui-refresh.erp-sidebar-layout :is(small, .help-text, .form-help, .pagination-meta, .project-card > p, .activity-feed-item time) { font-size: var(--nl-text-caption) !important; line-height: var(--nl-leading-body); }
body.erp-ui-refresh.erp-sidebar-layout .activity-feed-item strong { font-size: var(--nl-text-small) !important; line-height: var(--nl-leading-body); }
body.erp-ui-refresh.erp-sidebar-layout :is(.count-badge, .panel-badge, .status-badge, .status-pill, .state-chip, .type-chip, .project-code, .project-status) { font-size: var(--nl-text-caption) !important; font-weight: var(--nl-weight-medium) !important; line-height: var(--nl-leading-body); }
body.erp-ui-refresh.erp-sidebar-layout .content :is(strong, b) { font-weight: var(--nl-weight-strong) !important; }
body.erp-ui-refresh.erp-sidebar-layout :is(.metric-card, .module-stat, .focus-card) strong { font-size: var(--nl-text-metric) !important; line-height: var(--nl-leading-heading); }
body.erp-ui-refresh.erp-sidebar-layout :is(.metric-card, .module-stat, .focus-card) :is(small, span) { font-size: var(--nl-text-caption) !important; line-height: var(--nl-leading-body); white-space: normal !important; }
body.erp-ui-refresh.erp-sidebar-layout .erp-header .user-copy b { font-size: var(--nl-text-small) !important; font-weight: var(--nl-weight-medium) !important; }
body.erp-ui-refresh.erp-sidebar-layout .erp-header .user-copy small { font-size: var(--nl-text-caption) !important; }
body.erp-ui-refresh.erp-sidebar-layout .erp-header .user-logout-button { font-size: var(--nl-text-small) !important; font-weight: var(--nl-weight-medium) !important; line-height: var(--nl-leading-body); }

/* At <=1100px use the existing JS menu toggle; no competing horizontal nav. */
@media (max-width: 1100px) {
  body.erp-ui-refresh.erp-sidebar-layout .erp-header { position: sticky !important; inset: auto !important; top: 0 !important; width: 100% !important; height: auto !important; min-height: var(--erp-header-height) !important; overflow: visible !important; z-index: 120 !important; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .header-primary { display: grid !important; grid-template-columns: 44px minmax(0, 1fr) auto !important; align-items: center !important; gap: 10px !important; height: auto !important; min-height: var(--erp-header-height) !important; padding: 10px var(--nl-page-pad) !important; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .top-brand { grid-column: 2; grid-row: 1; order: 0 !important; margin: 0 !important; padding: 0 !important; border: 0 !important; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .nav-menu-button { display: inline-grid !important; position: relative; z-index: 140; grid-column: 1; grid-row: 1; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .header-actions { grid-column: 3; grid-row: 1; display: flex !important; height: auto !important; min-width: 0 !important; width: auto !important; flex-wrap: nowrap !important; gap: 6px !important; padding: 0 !important; margin: 0 !important; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .user-menu { width: auto !important; height: auto !important; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .user-menu-summary { display: none !important; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .top-navigation { position: fixed !important; top: 0 !important; bottom: 0 !important; inset-inline-start: 0 !important; inset-inline-end: auto !important; width: min(86vw, 340px) !important; height: 100vh !important; height: 100dvh !important; display: block !important; padding: calc(var(--erp-header-height) + 12px) 14px 24px !important; background: var(--nl-navy) !important; overflow-x: hidden !important; overflow-y: auto !important; transform: translateX(calc(-110% * var(--drawer-direction, 1))) !important; visibility: hidden !important; z-index: 130 !important; }
  body.erp-ui-refresh.erp-sidebar-layout.nav-open .erp-header .top-navigation { transform: none !important; visibility: visible !important; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header :is(.top-nav-link, .nav-group > summary) { display: flex !important; justify-content: flex-start !important; width: 100% !important; height: auto !important; padding: 10px 12px !important; white-space: normal !important; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .nav-group { display: block !important; height: auto !important; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header :is(.nav-dropdown, .nav-mega-menu) { position: static !important; display: block !important; width: 100% !important; max-width: 100% !important; margin: 6px 0 !important; box-shadow: none !important; }
  body.erp-ui-refresh.erp-sidebar-layout .nav-overlay { position: fixed; inset: 0; z-index: 110; background: rgb(20 24 26 / 42%); }
  body.erp-ui-refresh.erp-sidebar-layout.nav-open .nav-overlay { display: block !important; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .global-search.is-open .global-search-panel { position: fixed !important; top: calc(var(--erp-header-height) + 8px) !important; inset-inline: 12px !important; width: auto !important; transform: none !important; z-index: 150 !important; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .global-search-results { width: 100% !important; inset-inline: 0 !important; }
  body.erp-ui-refresh.erp-sidebar-layout .content { padding-block-start: 16px !important; }
}
@media (max-width: 560px) {
  :root { --erp-header-height: 8rem !important; --nl-gap: 12px; --nl-page-pad: 12px; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .header-primary { grid-template-columns: 44px minmax(0, 1fr) !important; gap: 8px 12px !important; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .header-actions { grid-column: 1 / -1; grid-row: 2; justify-content: flex-end; }
  body.erp-ui-refresh.erp-sidebar-layout .erp-header .language-action { display: inline-grid !important; }
  body.erp-ui-refresh.erp-sidebar-layout :is(.page-heading, .project-hero.panel) { padding: 16px !important; }
  body.erp-ui-refresh.erp-sidebar-layout :is(form.module-toolbar, .module-toolbar form) { grid-template-columns: minmax(0, 1fr) !important; }
  body.erp-ui-refresh.erp-sidebar-layout .page-heading { align-items: flex-start !important; gap: 12px !important; }
  body.erp-ui-refresh.erp-sidebar-layout .page-heading :is(.heading-actions, .governed-actions, .lifecycle-actions) { inline-size: 100% !important; }
  body.erp-ui-refresh.erp-sidebar-layout .page-heading .heading-actions > :is(a, button, form) { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) {
  body.erp-ui-refresh.erp-sidebar-layout :is(.content, .erp-header, .top-navigation, .panel, .project-card, .primary-button, .secondary-button) { transition: none !important; transform: none !important; }
}
@media print {
  body.erp-ui-refresh.erp-sidebar-layout .erp-header, body.erp-ui-refresh.erp-sidebar-layout .nav-overlay { display: none !important; }
  body.erp-ui-refresh.erp-sidebar-layout .content { width: 100% !important; inline-size: 100% !important; margin: 0 !important; padding: 0 !important; }
  body.erp-ui-refresh.erp-sidebar-layout :is(.panel, .card) { box-shadow: none !important; break-inside: avoid; }
}

/* Public sign-in page shares identity and tokens without loading the ERP shell. */
body.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding: clamp(16px, 4vw, 40px);
  display: grid;
  place-items: center;
  font-family: var(--nl-font) !important;
  font-size: var(--nl-text-body);
  font-weight: var(--nl-weight-regular);
  line-height: var(--nl-leading-body);
  color: var(--nl-text) !important;
  background: linear-gradient(145deg, #eeeae0, #f8f8f5 62%) !important;
}
.login-page .login-card { width: min(440px, 100%); min-width: 0; padding: clamp(24px, 5vw, 36px); background: #fff; border: 1px solid var(--nl-line); border-top: 4px solid var(--nl-gold); border-radius: 18px; box-shadow: 0 16px 48px rgb(32 35 38 / 10%); }
.login-page .login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.login-page .nile-build-logo { display: block; width: 76px; height: 76px; flex: 0 0 76px; object-fit: contain; border-radius: 12px; border: 1px solid #c3ad80; background: #111315; }
.login-page .login-brand :is(strong, h1) { color: var(--nl-text); font-size: var(--nl-text-title); }
.login-page .login-brand :is(small, p) { color: var(--nl-muted); font-size: var(--nl-text-caption); }
.login-page :is(button, input, select) { font-family: var(--nl-font); font-size: var(--nl-text-control); }
.login-page label { font-size: var(--nl-text-small); color: #47524f; }
.login-page input:not([type='checkbox']):not([type='hidden']) { width: 100%; min-height: var(--nl-control-height); padding: 10px 12px; border: 1px solid #cbd0ca; border-radius: var(--nl-radius-sm); background: #fff; color: var(--nl-text); }
.login-page :is(.primary-button, button[type='submit']) { min-height: var(--nl-control-height); border: 1px solid var(--nl-blue); border-radius: var(--nl-radius-sm); background: var(--nl-blue); color: #fff; box-shadow: none; }
.login-page :is(button, input, a):focus-visible { outline: 3px solid var(--nl-blue); outline-offset: 3px; }


/* Sign-in copy follows the same scale; browser zoom remains available. */
.login-page :is(.login-copy h1, .login-brand h1) { font-size: var(--nl-text-title); line-height: var(--nl-leading-heading); font-weight: var(--nl-weight-strong); }
.login-page :is(.login-copy p, .remember) { font-size: var(--nl-text-body); line-height: var(--nl-leading-body); }
.login-page :is(.login-help, .form-error, .eyebrow, small) { font-size: var(--nl-text-caption); line-height: var(--nl-leading-body); }
.login-page :is(label, .field label) { font-size: var(--nl-text-small); font-weight: var(--nl-weight-medium); }

/* Narrative report scope uses body typography instead of numeric KPI emphasis. */
body.erp-ui-refresh .module-stat .report-summary-note {
  margin: 8px 0 0;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

/* Calendar triggers belong to the date field, not the toolbar action layout. */
body.erp-ui-refresh.erp-sidebar-layout .erp-date-field > .erp-date-calendar {
  min-width: 0 !important;
  min-height: 44px !important;
  width: 100%;
  max-width: 100%;
  padding: 4px;
  box-sizing: border-box;
}

/* Captions remain above access controls without stretching action buttons. */
body.erp-ui-refresh.erp-sidebar-layout :is(.access-action-form, .permission-save) { align-items: end; }
body.erp-ui-refresh.erp-sidebar-layout :is(.access-action-form, .permission-save) > label.field { display: grid; gap: 6px; min-width: 0; margin-bottom: 0 !important; font-size: var(--nl-text-small); }
body.erp-ui-refresh.erp-sidebar-layout :is(.access-action-form, .permission-save) > label.field :is(input, select) { width: 100%; box-sizing: border-box; }

/* Detail captions and compact document states share the same readable scale. */
body.erp-ui-refresh.erp-sidebar-layout :is(.contract-profile-grid dt, .governed-meta dt, .details-list dt, .contract-state, .governed-state, .record-code) { font-size: var(--nl-text-caption) !important; line-height: var(--nl-leading-body); }

/* Keep complete financial explanations readable within the table scroller. */
body.erp-ui-refresh.erp-sidebar-layout .contractor-statement-table td.statement-detail { min-width: 260px !important; width: 30%; vertical-align: top; }

/* Stack contractor form captions consistently, including the rating grid. */
body.erp-ui-refresh.erp-sidebar-layout .contractor-field-label { display: grid; gap: 6px; min-width: 0; }
body.erp-ui-refresh.erp-sidebar-layout .contractor-field-label :is(input, select) { width: 100%; box-sizing: border-box; }

/* Keep legacy report resource captions visible for saved and new rows. */
body.erp-ui-refresh.erp-sidebar-layout .phase2b-report-form .resource-field {
    display: grid;
    gap: 7px;
    min-width: 0;
    font-weight: 700;
}
body.erp-ui-refresh.erp-sidebar-layout .phase2b-report-form .resource-row {
    align-items: end;
}
body.erp-ui-refresh.erp-sidebar-layout .phase2b-report-form .resource-field-wide {
    grid-column: 1 / -1;
}
body.erp-ui-refresh.erp-sidebar-layout .phase2b-report-form [data-resource-empty][hidden] {
    display: none !important;
}
/* Wide fields in governed repeaters use the same full-row span as form grids. */
body.erp-ui-refresh.erp-sidebar-layout .governed-repeat-row > .governed-field.wide {
    grid-column: 1 / -1;
}

/* Public error pages: external styles respect style-src self. */
.access-error .error-code { display: block; font-size: 3rem; font-weight: 700; color: var(--nl-blue); line-height: 1.4; }
.access-error .error-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-block-start: 24px; }
.access-error .error-actions a { display: inline-flex; align-items: center; justify-content: center; padding: 10px 16px; min-block-size: 44px; text-decoration: none; overflow-wrap: anywhere; }
