/* Nextgenpipes ERP — classical plant UI (system fonts = fast) */
:root {
  --ngp-ink: #152238;
  --ngp-ink-soft: #3a4a5c;
  --ngp-accent: #1b5c45;
  --ngp-accent-hover: #154a38;
  --ngp-paper: #f3f5f7;
  --ngp-panel: #ffffff;
  --ngp-line: #cfd6de;
  --ngp-line-soft: #e4e8ed;
  --ngp-gold: #9a7b3c;
  --ngp-sidebar: #152238;
  --ngp-sidebar-w: 232px;
  --ngp-radius: 6px;
  --ngp-shadow: 0 1px 0 rgba(21, 34, 56, 0.06);
  --ngp-font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --ngp-display: var(--ngp-font);
  --ngp-mono: ui-monospace, "Cascadia Mono", "Consolas", monospace;
  /* Bootstrap primary → plant forest green (not default blue) */
  --bs-primary: #1b5c45;
  --bs-primary-rgb: 27, 92, 69;
  --bs-link-color: #1b5c45;
  --bs-link-hover-color: #154a38;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--ngp-paper);
  font-family: var(--ngp-font);
  font-size: 0.925rem;
  line-height: 1.45;
  color: var(--ngp-ink);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ngp-accent); }
a:hover { color: var(--ngp-accent-hover); }

/* —— Shell —— */
#app-shell {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
}

.sidebar {
  width: var(--ngp-sidebar-w);
  flex-shrink: 0;
  min-height: 100vh;
  background: var(--ngp-sidebar);
  color: #e8ecef;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid #0d1724;
  z-index: 1040;
  content-visibility: auto;
  scrollbar-width: thin;
  scrollbar-color: #3a4a5c transparent;
}

.sidebar .brand {
  padding: 1rem 1rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 0.5rem;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--ngp-sidebar);
}

.sidebar .brand .brand-logo {
  display: block;
  width: min(168px, 100%);
  height: auto;
  max-height: 72px;
  object-fit: contain;
  object-position: left center;
  margin: 0 0 0.55rem;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.96);
  padding: 4px 6px;
}

.sidebar .brand .brand-name {
  font-family: var(--ngp-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
  color: #fff;
}

.sidebar .brand .brand-sub {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 0.2rem;
}

.sidebar .nav-section {
  padding: 0.65rem 0.85rem 0.15rem;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.38);
}

.sidebar .nav {
  padding: 0 0.5rem 0.75rem;
  gap: 1px !important;
}

.sidebar .nav-link {
  color: rgba(255, 255, 255, 0.78);
  border-radius: var(--ngp-radius);
  padding: 0.38rem 0.65rem;
  font-size: 0.86rem;
  display: flex;
  align-items: center;
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: background 0.12s ease, color 0.12s ease;
}

.sidebar .nav-link i {
  width: 1.15rem;
  opacity: 0.75;
  font-size: 0.95rem;
}

.sidebar .nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.sidebar .nav-link.active {
  background: rgba(27, 92, 69, 0.35);
  color: #fff;
  border-left-color: var(--ngp-gold);
}

.sidebar .sidebar-foot {
  margin-top: auto;
  padding: 0.85rem 1rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(21, 34, 56, 0.45);
  z-index: 1035;
}

.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--ngp-paper);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: var(--ngp-panel);
  border-bottom: 1px solid var(--ngp-line);
  box-shadow: var(--ngp-shadow);
  min-height: 3.25rem;
  gap: 0.75rem;
}

.topbar h1 {
  font-family: var(--ngp-display);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0;
  color: var(--ngp-ink);
}

.topbar .btn-menu {
  display: none;
  border: 1px solid var(--ngp-line);
  background: #fff;
  color: var(--ngp-ink);
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: var(--ngp-radius);
  align-items: center;
  justify-content: center;
}

#global-search {
  width: min(220px, 36vw);
  border-radius: var(--ngp-radius);
  border-color: var(--ngp-line);
  font-size: 0.85rem;
}

#global-search:focus {
  border-color: var(--ngp-accent);
  box-shadow: 0 0 0 2px rgba(27, 92, 69, 0.15);
}

#global-search-panel {
  border-radius: var(--ngp-radius) !important;
  border-color: var(--ngp-line) !important;
  box-shadow: 0 8px 24px rgba(21, 34, 56, 0.12) !important;
}

.content {
  padding: 1rem 1.25rem 1.75rem;
  flex: 1;
}

/* —— Surfaces —— */
.kpi-card {
  background: var(--ngp-panel);
  border: 1px solid var(--ngp-line);
  border-radius: var(--ngp-radius);
  padding: 0.85rem 1rem;
  box-shadow: var(--ngp-shadow);
}

.kpi-card .text-muted {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ngp-ink-soft) !important;
}

.kpi-card .value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ngp-ink);
  font-variant-numeric: tabular-nums;
  font-family: var(--ngp-mono);
  letter-spacing: -0.02em;
  margin-top: 0.15rem;
}

.chart-box {
  background: var(--ngp-panel);
  border: 1px solid var(--ngp-line);
  border-radius: var(--ngp-radius);
  padding: 0.85rem;
  height: 280px;
  box-shadow: var(--ngp-shadow);
}

.alert-feed .alert-item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  background: var(--ngp-panel);
  border: 1px solid var(--ngp-line);
  border-radius: var(--ngp-radius);
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.4rem;
  text-decoration: none;
  color: inherit;
  border-left: 3px solid #7a8fa3;
}

.alert-feed .alert-item.danger { border-left-color: #9b2c2c; }
.alert-feed .alert-item.warning { border-left-color: var(--ngp-gold); }
.alert-feed .alert-item.info { border-left-color: var(--ngp-accent); }
.alert-feed .alert-item:hover { background: #f8fafb; }

.quick-actions .btn {
  min-width: 6.5rem;
  border-radius: var(--ngp-radius);
  font-size: 0.82rem;
}

/* —— Tables (ledger style) —— */
.table-responsive {
  background: var(--ngp-panel);
  border: 1px solid var(--ngp-line);
  border-radius: var(--ngp-radius);
  box-shadow: var(--ngp-shadow);
}

.table {
  margin-bottom: 0;
  --bs-table-hover-bg: #f0f4f2;
  font-size: 0.875rem;
}

.table thead th {
  font-size: 0.7rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ngp-ink-soft);
  background: #eef1f4;
  border-bottom: 1px solid var(--ngp-line) !important;
  white-space: nowrap;
  padding: 0.55rem 0.75rem;
  position: sticky;
  top: 0;
  z-index: 1;
}

.table tbody td {
  padding: 0.45rem 0.75rem;
  border-color: var(--ngp-line-soft);
  vertical-align: middle;
}

.table tbody tr:nth-child(even) {
  background: #fafbfc;
}

.table .btn-sm {
  padding: 0.15rem 0.45rem;
  font-size: 0.75rem;
  border-radius: var(--ngp-radius);
}

/* —— Forms / Bootstrap overrides —— */
.form-control,
.form-select {
  border-radius: var(--ngp-radius);
  border-color: var(--ngp-line);
  font-size: 0.9rem;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--ngp-accent);
  box-shadow: 0 0 0 2px rgba(27, 92, 69, 0.15);
}

.btn {
  border-radius: var(--ngp-radius);
  font-weight: 600;
}

.btn-primary {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--ngp-accent);
  --bs-btn-border-color: var(--ngp-accent);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--ngp-accent-hover);
  --bs-btn-hover-border-color: var(--ngp-accent-hover);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--ngp-accent-hover);
  --bs-btn-active-border-color: var(--ngp-accent-hover);
  --bs-btn-disabled-bg: var(--ngp-accent);
  --bs-btn-disabled-border-color: var(--ngp-accent);
}

.btn-outline-primary {
  --bs-btn-color: var(--ngp-accent);
  --bs-btn-border-color: var(--ngp-accent);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--ngp-accent);
  --bs-btn-hover-border-color: var(--ngp-accent);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--ngp-accent-hover);
  --bs-btn-active-border-color: var(--ngp-accent-hover);
}

.btn-success {
  --bs-btn-bg: var(--ngp-accent);
  --bs-btn-border-color: var(--ngp-accent);
  --bs-btn-hover-bg: var(--ngp-accent-hover);
  --bs-btn-hover-border-color: var(--ngp-accent-hover);
  --bs-btn-active-bg: var(--ngp-accent-hover);
  --bs-btn-active-border-color: var(--ngp-accent-hover);
}

.btn-outline-success {
  --bs-btn-color: var(--ngp-accent);
  --bs-btn-border-color: var(--ngp-accent);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--ngp-accent);
  --bs-btn-hover-border-color: var(--ngp-accent);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--ngp-accent-hover);
  --bs-btn-active-border-color: var(--ngp-accent-hover);
}

/* Outline button text only: Bootstrap's defaults are below 4.5:1 on the page
   background. Borders and hover fills keep their Bootstrap colours. */
.btn-outline-secondary { --bs-btn-color: #5a6268; }
.btn-outline-info { --bs-btn-color: #0a6b80; }
.btn-outline-warning { --bs-btn-color: #8a5a00; }
.btn-outline-danger {
  --bs-btn-color: #b42318;
  --bs-btn-border-color: #b42318;
  /* Filled hover/active use the same deeper red as .btn-danger, with white text (6.6:1 and darker). */
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #b42318;
  --bs-btn-hover-border-color: #b42318;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: #9a1e14;
  --bs-btn-active-border-color: #9a1e14;
}

/* Inline code text: Bootstrap's pink is below 4.5:1 on the page background. */
code { color: #ab296a; }

.text-bg-primary {
  background-color: rgba(var(--bs-primary-rgb), 1) !important;
  color: #fff !important;
}

.badge.text-bg-primary {
  background-color: var(--ngp-accent) !important;
}

.text-primary {
  color: var(--ngp-accent) !important;
}

.bg-primary {
  background-color: var(--ngp-accent) !important;
}

.border-primary {
  border-color: var(--ngp-accent) !important;
}

.kpi-card.kpi-tone-success { border-left: 3px solid var(--ngp-accent); }
.kpi-card.kpi-tone-warning { border-left: 3px solid var(--ngp-gold); }
.kpi-card.kpi-tone-danger { border-left: 3px solid #9b2c2c; }
.kpi-card.kpi-tone-secondary { border-left: 3px solid var(--ngp-line); }

.kpi-card .kpi-sub {
  font-size: 0.75rem;
  letter-spacing: normal;
  text-transform: none;
  color: var(--ngp-ink-soft) !important;
  margin-top: 0.2rem;
}

.nav-tabs {
  border-bottom-color: var(--ngp-line);
}

.nav-tabs .nav-link {
  border-radius: var(--ngp-radius) var(--ngp-radius) 0 0;
  color: var(--ngp-ink-soft);
  font-size: 0.88rem;
  padding: 0.45rem 0.9rem;
}

.nav-tabs .nav-link.active {
  color: var(--ngp-ink);
  font-weight: 650;
  border-color: var(--ngp-line) var(--ngp-line) #fff;
}

.modal-content {
  border-radius: var(--ngp-radius);
  border-color: var(--ngp-line);
}

.modal-header {
  border-bottom-color: var(--ngp-line);
  background: #eef1f4;
  padding: 0.75rem 1rem;
}

.modal-title {
  font-family: var(--ngp-display);
  font-size: 1.05rem;
}

.modal-body { padding: 1rem; }

.h6 {
  font-family: var(--ngp-display);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: var(--ngp-ink);
}

/* —— Login / landing —— */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background:
    linear-gradient(180deg, #101c2e 0%, #152238 45%, #1a3a32 100%);
}

.login-card {
  width: min(400px, 100%);
  background: var(--ngp-panel);
  border: 1px solid var(--ngp-line);
  border-radius: var(--ngp-radius);
  padding: 1.75rem 1.85rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

.login-card h1 {
  font-family: var(--ngp-display);
  font-weight: 700;
  color: var(--ngp-ink);
}

.login-card .eyebrow {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ngp-ink-soft);
}

.login-card .login-logo {
  display: block;
  width: min(220px, 70%);
  height: auto;
  margin: 0 auto 1rem;
  object-fit: contain;
}

.landing-hero .landing-logo {
  display: block;
  width: min(280px, 70vw);
  height: auto;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.96);
  padding: 0.5rem 0.75rem;
  border-radius: 3px;
}

.landing-hero {
  min-height: 100vh;
  color: #fff;
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, #101c2e 0%, #152238 50%, #1b5c45 100%);
  display: flex;
  align-items: center;
  padding: clamp(1.5rem, 4vw, 3rem);
}

.landing-hero h1 {
  font-family: var(--ngp-display);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.landing-hero .hero-pipe {
  position: absolute;
  right: -10%;
  bottom: -25%;
  width: 55%;
  height: 70%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05) 45%, rgba(255, 255, 255, 0.1));
  border-radius: 40% 60% 50% 50%;
  transform: rotate(-18deg);
  pointer-events: none;
}

#ngp-toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 2000;
  min-width: 220px;
  max-width: min(360px, 92vw);
  display: none;
  background: var(--ngp-ink);
  color: #fff;
  padding: 0.7rem 0.95rem;
  border-radius: var(--ngp-radius);
  border-left: 3px solid var(--ngp-gold);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  font-size: 0.88rem;
}

#ngp-toast.show { display: block; }

/* —— Print —— */
@media print {
  @page { size: A4 portrait; margin: 8mm; }
  /* Shell uses min-height:100vh for screen chrome — that stretches print to a mostly blank page. */
  html, body,
  #app-shell,
  .sidebar,
  .main-area,
  .content,
  .login-wrap {
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
  }
  #app-shell {
    display: block !important;
    align-items: stretch !important;
  }
  .main-area {
    display: block !important;
    flex: none !important;
  }
  .sidebar,
  .topbar,
  .btn,
  #global-search,
  #ngp-toast,
  .quick-actions,
  .sidebar-backdrop,
  .btn-menu { display: none !important; }
  .main-area, .content { width: 100% !important; max-width: 100% !important; margin: 0 !important; padding: 0 !important; }
  .table-responsive {
    border: none !important;
    box-shadow: none !important;
    overflow: visible !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
  }
  table { width: 100% !important; height: auto !important; }
}

/* —— Responsive —— */
@media (max-width: 992px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.2);
  }

  body.nav-open .sidebar { transform: translateX(0); }

  body.nav-open .sidebar-backdrop {
    display: block;
  }

  .topbar .btn-menu { display: inline-flex; }

  .chart-box { height: 240px; }

  .content { padding: 0.85rem 0.9rem 1.25rem; }

  .kpi-card .value { font-size: 1.2rem; }
}

@media (max-width: 576px) {
  .topbar {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
    flex-wrap: wrap;
  }

  .topbar h1 { font-size: 1.05rem; }

  #global-search { width: 100%; max-width: none; order: 3; flex: 1 1 100%; }

  .quick-actions .btn { min-width: 0; flex: 1 1 auto; }

  .table { font-size: 0.8rem; }

  .login-card { padding: 1.35rem 1.25rem; }
}

/* Helpful list states: static copy stays quiet; only loading/errors announce. */
.empty-state { display: flex; align-items: flex-start; gap: 1rem; padding: clamp(1rem, 3vw, 1.5rem); margin: .5rem 0; border: 1px dashed #b8c5cf; border-radius: 8px; background: #f7faf9; color: #263b45; white-space: normal; max-width: 100%; }
.empty-state-icon { width: 2.75rem; height: 2.75rem; flex: 0 0 2.75rem; color: #376a59; }
.empty-state-copy { min-width: 0; overflow-wrap: anywhere; }
.empty-state h3 { font: 600 1rem/1.4 var(--ngp-font); margin: 0 0 .35rem; color: #152238; }
.empty-state p { font-size: .875rem; line-height: 1.5; margin: 0; max-width: 52ch; }
.empty-state-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .85rem; }
.empty-state-actions :is(a, button) { white-space: normal; min-height: 2.75rem; max-width: 100%; }
.empty-state-actions :is(a, button):focus-visible { outline: 3px solid #1b5c45; outline-offset: 2px; }
.empty-state-error, .empty-state-permission { border-color: #b77a67; background: #fff8f5; }
.state-skeleton { width: min(20rem, 55vw); margin-top: .75rem; }
.state-skeleton span { display: block; height: .5rem; margin: .4rem 0; border-radius: 4px; background: #dce5e2; }
.state-skeleton span:last-child { width: 65%; }
@media (max-width: 400px) { .empty-state { flex-direction: column; gap: .5rem; } }

/* Shared navigation: the grid track and sidebar width move together. */
#app-shell {
  --ngp-nav-size: 15.5rem;
  display: grid;
  grid-template-columns: var(--ngp-nav-size) minmax(0, 1fr);
  align-items: start;
  transition: grid-template-columns 200ms ease;
}
body.nav-collapsed #app-shell { --ngp-nav-size: 4.5rem; }
#app-sidebar {
  width: var(--ngp-nav-size);
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  content-visibility: visible;
  transition: width 200ms ease, transform 200ms ease;
}
.sidebar .brand { flex-shrink: 0; position: static; }
.sidebar-links { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.sidebar-links .nav { list-style: none; margin: 0; }
.sidebar-links .nav-section { margin: 0; line-height: 1.4; color: #aab8c8; }
.sidebar-links .nav-link { min-height: 2.75rem; gap: .65rem; overflow-wrap: anywhere; line-height: 1.3; }
.sidebar-links .nav-link i { flex: 0 0 1.2rem; text-align: center; }
.nav-symbol { width: 1.25rem; height: 1.25rem; flex: 0 0 1.25rem; display: inline-block; vertical-align: middle; }
.sidebar-links .nav-link[aria-current="page"] { background: #275a4f; color: #fff; border-left-color: #e3bf71; font-weight: 600; }
.sidebar .sidebar-foot { flex-shrink: 0; padding: .75rem; }
.sidebar-user { overflow-wrap: anywhere; color: #c7d3df; }
.main-area { min-width: 0; min-height: 100vh; width: 100%; }
.main-area .content { min-width: 0; max-width: 100%; }
.topbar { flex-wrap: wrap; }
.topbar > div { min-width: 0; max-width: 100%; }
.topbar > div:first-child { flex: 1 1 12rem; }
.topbar h1 { min-width: 0; }
.topbar .btn-menu { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .4rem .65rem; width: auto; height: auto; white-space: nowrap; color: #152238; font-size: .85rem; font-weight: 600; min-width: 2.75rem; min-height: 2.75rem; flex-shrink: 0; cursor: pointer; }
.nav-close { border: 1px solid #8da4ba; color: white; background: #21364b; border-radius: 4px; min-width: 2.75rem; min-height: 2.75rem; font-size: 1.5rem; position: absolute; right: .5rem; top: .5rem; z-index: 3; }
.nav-close[hidden], #nav-tooltip[hidden] { display: none; }
.sidebar :is(a, button):focus-visible, .btn-menu:focus-visible { outline: 3px solid #ffd77e; outline-offset: -3px; box-shadow: none; }
.btn-menu:focus-visible { outline-color: #1b5c45; outline-offset: 2px; }
.shell-skip { position: fixed; top: .25rem; left: .5rem; transform: translateY(-180%); z-index: 1100; background: white; color: #152238; padding: .75rem; border: 2px solid #1b5c45; }
.shell-skip:focus { transform: none; }
#nav-tooltip { position: fixed; z-index: 1060; pointer-events: none; padding: .5rem .75rem; border-radius: 4px; background: #152238; color: white; box-shadow: 0 3px 10px #0004; max-width: min(20rem, calc(100vw - 6rem)); overflow-wrap: anywhere; }
body.nav-collapsed .sidebar :is(.brand-name, .brand-sub, .sidebar-user, .nav-label) { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
body.nav-collapsed .sidebar .brand { padding: .75rem .5rem; }
body.nav-collapsed .sidebar .brand-logo { margin: 0; padding: 2px; }
body.nav-collapsed .sidebar .nav-section { height: 1px; margin: .35rem .75rem; padding: 0; overflow: hidden; color: transparent; border-top: 1px solid #8da4ba55; }
body.nav-collapsed .sidebar .nav-link { justify-content: center; padding: .5rem; gap: 0; }
@media (max-width: 992px) {
  #app-shell { grid-template-columns: minmax(0, 1fr); }
  #app-sidebar { --ngp-nav-size: min(19rem, calc(100vw - 3rem)); position: fixed; width: var(--ngp-nav-size); visibility: hidden; pointer-events: none; transform: translateX(-105%); transition: transform 200ms ease, visibility 0s 200ms; }
  body.nav-open #app-sidebar { visibility: visible; pointer-events: auto; transform: translateX(0); transition-delay: 0s; }
  body.nav-open { overflow: hidden; }
  body.nav-open .sidebar-backdrop { display: block; }
  #app-sidebar .brand { padding-right: 3.75rem; }
}
@media print {
  #app-shell { display: block !important; }
  #nav-tooltip, .shell-skip, .nav-close { display: none !important; }
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* Keep dialog chrome on the content, never on the full-screen overlay. */
.modal:has(> .modal-dialog) {
  top: 0; left: 0; transform: none;
  width: 100%; height: 100%; max-width: none; max-height: none;
  background: transparent; border-radius: 0; box-shadow: none;
}
.modal-content { border-radius: 10px; box-shadow: 0 16px 48px rgba(21,34,56,.18); }
.modal-body { overflow-wrap: anywhere; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: .5rem 1rem; }
.topbar > div { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.topbar h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button, input, select, textarea { font-family: inherit; }
.kpi-card .value { overflow-wrap: anywhere; }
@media (max-width: 575.98px) {
  .topbar { flex-wrap: wrap; }
  .modal-dialog { margin: .5rem; }
}

/* Workflow navigation uses restrained motion and bright, readable module accents. */
.workflow-nav-group { --nav-color: #8ecfff; --nav-rgb: 142,207,255; margin: .2rem .35rem; border-radius: 10px; }
.nav-tone-sky { --nav-color:#8ecfff; --nav-rgb:142,207,255; }
.nav-tone-mint { --nav-color:#78e0b0; --nav-rgb:120,224,176; }
.nav-tone-amber { --nav-color:#ffda80; --nav-rgb:255,218,128; }
.nav-tone-cyan { --nav-color:#79e0ec; --nav-rgb:121,224,236; }
.nav-tone-violet { --nav-color:#c6b5ff; --nav-rgb:198,181,255; }
.nav-tone-lime { --nav-color:#c7e996; --nav-rgb:199,233,150; }
.nav-tone-orange { --nav-color:#ffbb94; --nav-rgb:255,187,148; }
.nav-tone-rose { --nav-color:#ffb3cb; --nav-rgb:255,179,203; }
.sidebar-links .workflow-nav-group .nav-section { height:auto; margin:0; padding:0; border:0; overflow:visible; letter-spacing:normal; text-transform:none; }
.nav-group-toggle { display:flex; align-items:center; gap:.65rem; width:100%; min-height:2.9rem; padding:.65rem .7rem; border:1px solid transparent; border-radius:9px; color:var(--nav-color); background:rgba(var(--nav-rgb),.055); text-align:left; font:600 .83rem/1.3 var(--ngp-font); cursor:pointer; transition:background 140ms ease, border-color 140ms ease; }
.nav-group-toggle:hover, .nav-group-toggle:focus-visible, .is-open .nav-group-toggle { background:rgba(var(--nav-rgb),.16); border-color:rgba(var(--nav-rgb),.4); }
.workflow-nav-group.has-active-page .nav-group-toggle { background:rgba(var(--nav-rgb),.23); border-color:var(--nav-color); box-shadow:inset 3px 0 var(--nav-color); color:#fff; }
.nav-group-toggle .nav-label { flex:1 1 auto; }
.nav-chevron { margin-left:auto; font-size:1rem; transition:transform 140ms ease; }
.is-open .nav-chevron { transform:rotate(180deg); }
.sidebar-links .nav-subtabs { margin:.25rem 0 .5rem .85rem; padding:.1rem .35rem .15rem .5rem; gap:.2rem !important; border-left:1px solid rgba(var(--nav-rgb),.4); animation:nav-reveal 150ms ease both; }
.sidebar-links .nav-subtabs[hidden] { display:none !important; }
.sidebar-links .nav-subtabs .nav-link { color:#eaf2fc; background:rgba(var(--nav-rgb),.055); border-left:3px solid transparent; padding:.5rem .6rem; font-size:.8rem; min-height:2.65rem; }
.sidebar-links .nav-subtabs .nav-symbol { color:var(--nav-color); width:1.05rem; height:1.05rem; flex-basis:1.05rem; }
.sidebar-links .nav-subtabs .nav-link:hover { background:rgba(var(--nav-rgb),.16); border-left-color:var(--nav-color); }
.sidebar-links .nav-subtabs .nav-link[aria-current="page"] { background:rgba(var(--nav-rgb),.23); border-left-color:var(--nav-color); color:#fff; font-weight:700; box-shadow:inset 0 0 0 1px rgba(var(--nav-rgb),.35); }
.nav-workflow-label { margin:.25rem .8rem .55rem; color:#b4c9db; font-size:.66rem; text-transform:uppercase; letter-spacing:.12em; }
body.nav-collapsed .sidebar .workflow-nav-group .nav-section { height:auto; margin:0; border:0; }
body.nav-collapsed .nav-group-toggle { justify-content:center; padding:.65rem .4rem; gap:0; }
body.nav-collapsed .nav-chevron { display:none; }
body.nav-collapsed .sidebar .nav-subtabs { display:none !important; }
.topbar-brand { display:flex; align-items:center; flex-shrink:0; padding:.15rem .3rem; border:1px solid #d9e7e3; border-radius:6px; background:#fff; }
.topbar-brand img { width:52px; height:31px; object-fit:contain; }
#workflow-help { display:flex; flex-wrap:wrap; gap:.55rem; padding:.55rem .7rem !important; background:linear-gradient(120deg,#f2faf7,#f3f8ff) !important; border-color:#d5e5df !important; }
#workflow-help details { flex:1 1 18rem; min-width:0; color:#213b47; border:1px solid #c7ded5; border-radius:7px; background:#fff; }
#workflow-help summary { padding:.6rem .8rem; cursor:pointer; color:#245844; font-size:.85rem; }
#workflow-help summary:focus-visible { outline:3px solid #22785a; outline-offset:2px; }
#workflow-help details[open] > :not(summary) { margin:.6rem 1rem; }
#workflow-help details[open] > ol { padding-left:1.3rem; }
#setup-progress { color:#526772; font-size:.76rem; }
@keyframes nav-reveal { from { opacity:0; transform:translateY(-3px); } to { opacity:1; transform:none; } }
@media (max-width:575.98px) { .topbar-brand img { width:40px; height:25px; } #workflow-help { gap:.4rem; } }
@media print { #workflow-help { display:none !important; } }

/* Wrapped-label forms (<label>Text<input></label>): each label sits above its control in a responsive grid,
   instead of running together on one line. Used by returns, packing and receipt review. */
/* A field wrapped in its label keeps a small gap under the label text. */
label.d-block > .form-control, label.d-block > .form-select { margin-top: .25rem; }
.ngp-form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem 1rem; align-items: end; }
.ngp-form-grid > h2, .ngp-form-grid > h3, .ngp-form-grid > p, .ngp-form-grid > .ngp-full { grid-column: 1 / -1; margin-bottom: 0; }
.ngp-form-grid > label, label.ngp-field { display: flex; flex-direction: column; gap: .25rem; font-size: .875rem; font-weight: 500; }
.ngp-form-grid > button { justify-self: start; }
label.ngp-field { max-width: 480px; }
