/* =========================================================
   ERP — Responsive System
   Breakpoints:
   xs < 576
   sm 576
   md 768
   lg 1024
   xl 1440
   2xl 1920
   ultra 2560+
   ========================================================= */

:root {
  --app-primary-blue: #0B3A67;
  --app-deep-navy: #06243F;
  --app-accent-gold: #C89B3C;
  --app-bg: #F4F6F9;
  --app-text: #1F2933;

  --app-gutter: 16px;
  --app-safe-top: env(safe-area-inset-top, 0px);
  --app-safe-right: env(safe-area-inset-right, 0px);
  --app-safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-safe-left: env(safe-area-inset-left, 0px);

  /* Default container cap (mobile-first). */
  --app-container-max: 100%;

  /* Responsive type scale (mobile-first) */
  --app-font-body: clamp(14px, 0.45vw + 12px, 18px);
  --app-font-small: clamp(12px, 0.35vw + 10px, 14px);
  --app-font-h1: clamp(20px, 4vw, 36px);
  --app-font-h2: clamp(18px, 3vw, 28px);
  --app-font-h3: clamp(16px, 2.3vw, 22px);
}

@media (min-width: 576px)  { :root { --app-container-max: 540px;  } }
@media (min-width: 768px)  { :root { --app-container-max: 720px;  } }
@media (min-width: 1024px) { :root { --app-container-max: 960px;  } }
@media (min-width: 1440px) { :root { --app-container-max: 1200px; } }
@media (min-width: 1920px) { :root { --app-container-max: 1400px; } }
@media (min-width: 2560px) { :root { --app-container-max: 1600px; } }

/* Keep Bootstrap containers aligned with our enterprise breakpoints. */
.container {
  max-width: min(var(--app-container-max), 100%);
  padding-left: calc(var(--app-gutter) + var(--app-safe-left));
  padding-right: calc(var(--app-gutter) + var(--app-safe-right));
}

/* Navigation (public): larger, responsive tap targets. */
.custom-nav {
  padding-top: clamp(10px, 1.2vw, 16px);
  padding-bottom: clamp(10px, 1.2vw, 16px);
}
.custom-nav-item {
  font-size: clamp(15px, 0.55vw + 13px, 20px);
  padding: clamp(10px, 0.9vw, 14px) clamp(14px, 1.2vw, 22px);
  border-radius: 10px;
  line-height: 1.15;
}

/* Global responsive typography (overrides fixed px sizes from legacy CSS). */
html { font-size: var(--app-font-body); }
body { font-size: 1rem; line-height: 1.45; }
h1 { font-size: var(--app-font-h1); line-height: 1.1; }
h2 { font-size: var(--app-font-h2); line-height: 1.15; }
h3 { font-size: var(--app-font-h3); line-height: 1.2; }
p, li, a, button, input, select, textarea { font-size: 1rem; }
small, .small { font-size: var(--app-font-small); }

/* Media elements must never overflow viewport. */
img, video, canvas, svg { max-width: 100%; height: auto; }

/* Tables (CRITIQUE): always horizontally scrollable on small screens. */
.wrapper-table {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border-radius: 12px;
}
.wrapper-table > table {
  min-width: 600px;
  width: 100%;
}
.wrapper-table th,
.wrapper-table td {
  white-space: nowrap;
}

/* Sticky header helper (opt-in by adding .table-sticky in templates if needed). */
.wrapper-table.table-sticky thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff;
}

/* Footer container must remain aligned with global container system. */
.footer-modern .container { max-width: min(var(--app-container-max), 100%) !important; }

/* =========================================================
   Section system (public site)
   - section controls background & rhythm
   - .container controls horizontal alignment
   ========================================================= */
.app-section {
  padding-top: clamp(18px, 3vw, 42px);
  padding-bottom: clamp(18px, 3vw, 42px);
}
.app-section--light { background: #ffffff; }
.app-section--neutral { background: var(--app-bg); }
.app-section--dark { background: linear-gradient(180deg, #0a1d33, #00132a); color: #fff; }
.app-section--dark h1,
.app-section--dark h2,
.app-section--dark h3,
.app-section--dark p,
.app-section--dark li { color: #fff; }

/* Override legacy "page-bg forces white text" rules inside light/neutral sections. */
body.page-bg .app-section--light,
body.page-bg .app-section--neutral {
  color: var(--app-text);
}
body.page-bg .app-section--light h1,
body.page-bg .app-section--light h2,
body.page-bg .app-section--light h3,
body.page-bg .app-section--light h4,
body.page-bg .app-section--light p,
body.page-bg .app-section--light li,
body.page-bg .app-section--light a,
body.page-bg .app-section--neutral h1,
body.page-bg .app-section--neutral h2,
body.page-bg .app-section--neutral h3,
body.page-bg .app-section--neutral h4,
body.page-bg .app-section--neutral p,
body.page-bg .app-section--neutral li,
body.page-bg .app-section--neutral a {
  color: var(--app-text) !important;
}
body.page-bg .app-section--light a,
body.page-bg .app-section--neutral a {
  color: var(--app-primary-blue) !important;
}

.app-hero {
  position: relative;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  padding-top: clamp(44px, 6vw, 96px);
  padding-bottom: clamp(44px, 6vw, 96px);
}
.app-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.35));
  pointer-events: none;
}
.app-hero > .container { position: relative; z-index: 1; }

.app-grid {
  display: grid;
  gap: clamp(12px, 2vw, 20px);
}
.app-grid--services {
  grid-template-columns: 1fr;
}
@media (min-width: 577px) {
  .app-grid--services { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* If odd count on 2 columns, make last card span full width */
  .app-grid--services > :nth-last-child(1):nth-child(2n+1) { grid-column: 1 / -1; }
}
@media (min-width: 1400px) {
  .app-grid--services { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  /* If remainder is 1 on 3 columns (…1), last spans full width */
  .app-grid--services > :nth-last-child(1):nth-child(3n+1) { grid-column: 1 / -1; }
  /* If remainder is 2 on 3 columns (…2), split last row: penultimate spans 2 cols, last takes last col */
  .app-grid--services > :nth-last-child(2):nth-child(3n+1) { grid-column: 1 / span 2; }
  .app-grid--services > :nth-last-child(1):nth-child(3n+2) { grid-column: 3 / span 1; }
}

/* =========================================================
   Services cards (public): harmonize photo + text contrast
   - legacy styles live in style.css; we override here (loaded after)
   ========================================================= */
.app-grid--services .svc-card {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  min-height: clamp(260px, 22vw, 340px);
  border: 1px solid rgba(6, 36, 63, 0.14);
  box-shadow: 0 14px 34px rgba(6, 36, 63, 0.14);
}

.app-grid--services .svc-card::before {
  content: "";
  position: absolute;
  inset: 0;
  /* Neutral, predictable overlay across all photos (readability + brand harmony). */
  background:
    linear-gradient(180deg, rgba(11, 58, 103, 0.25) 0%, rgba(6, 36, 63, 0.82) 100%),
    radial-gradient(1200px 420px at 20% 10%, rgba(200, 155, 60, 0.18), transparent 55%);
  pointer-events: none;
}

.app-grid--services .svc-card-content {
  position: relative;
  z-index: 1;
  padding: clamp(14px, 1.4vw, 18px);
}

.app-grid--services .svc-card .svc-card-content h4,
.app-grid--services .svc-card .svc-card-content p {
  color: rgba(255, 255, 255, 0.98) !important;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.app-grid--services .svc-card .svc-card-content h4 {
  font-weight: 800;
  letter-spacing: 0.2px;
  margin-bottom: 6px;
}

.app-grid--services .svc-card .svc-card-content p {
  margin-bottom: 0;
  opacity: 0.95;
}

/* Details panel: avoid white box clash with photos; keep contrast stable */
.app-grid--services .svc-card .svc-details {
  background: rgba(6, 36, 63, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.app-grid--services .svc-card .svc-details * {
  color: rgba(255, 255, 255, 0.96) !important;
}
.app-grid--services .svc-card .svc-details a {
  color: #ffffff !important;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Prevent ultra-wide stretching of long text blocks. */
.app-prose {
  max-width: 75ch;
}

/* Common width utilities (avoid inline max-width). */
.app-narrow { max-width: 640px; margin-left: auto; margin-right: auto; }
.app-medium { max-width: 920px; margin-left: auto; margin-right: auto; }
.app-wide { max-width: 1100px; margin-left: auto; margin-right: auto; }

/* ERP shell sizing (dashboard + modules rendered server-side). */
.app-erp-shell {
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
  padding-top: clamp(12px, 2vw, 22px);
  padding-bottom: clamp(12px, 2vw, 22px);
  padding-left: calc(clamp(12px, 2vw, 22px) + var(--app-safe-left));
  padding-right: calc(clamp(12px, 2vw, 22px) + var(--app-safe-right));
}
.app-erp-mount {
  position: relative;
  /* Fill the viewport height on all screens */
  min-height: calc(100vh - var(--app-safe-top) - var(--app-safe-bottom));
  display: grid;
}
.app-erp-body {
  width: 100%;
  min-height: inherit;
}

/* Loader card (no external deps). */
.app-erp-boot {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
}
.app-erp-card {
  width: min(620px, 92vw);
  border-radius: 18px;
  background: #fff;
  border: 1px solid rgba(6,36,63,.14);
  box-shadow: 0 18px 42px rgba(6,36,63,.16);
  padding: 16px;
}
.app-erp-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.app-erp-logo {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, rgba(11,58,103,.10), rgba(6,36,63,.06));
  border: 1px solid rgba(6,36,63,.12);
}
.app-erp-logo img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  display: block;
}
.app-erp-title {
  font-weight: 900;
  letter-spacing: .3px;
}
.app-erp-sub {
  margin-top: 6px;
  color: rgba(31,41,51,.70);
}
.app-erp-spin {
  margin-top: 14px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 3px solid rgba(6,36,63,.12);
  border-top-color: rgba(11,58,103,.9);
  animation: app-spin 900ms linear infinite;
}
@keyframes app-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

