/* ============================================================================
   Rustam ERP — custom-erp.css
   ----------------------------------------------------------------------------
   Elegant, desktop-first ERP theme layered on top of the locally vendored
   Bootstrap 5. Built for 13"–15.6"+ laptop/desktop screens.

   Palette: deep navy-charcoal surfaces + a warm gold primary accent, with
   teal reserved for secondary/success states — a deliberately "premium ERP"
   look rather than a flat dark dashboard.

   Theming: every colour used anywhere in this file comes from a CSS custom
   property declared in :root below. A future theme switcher only needs to
   override this variable block (e.g. via a `[data-theme="..."]` attribute
   on <html> — already wired up in includes/app_head.php) — no other file
   needs to change. Not implemented yet by request, but the architecture is
   ready for it.
   ============================================================================ */

:root {
  /* ---- brand palette -------------------------------------------------- */
  --erp-primary:       #141b2d;   /* header / sidebar base */
  --erp-primary-soft:  #1e2740;   /* header / sidebar gradient end */
  --erp-primary-3:     #283355;   /* hover surfaces on dark backgrounds */
  --erp-accent:         #c9a227;  /* warm gold — primary interactive accent */
  --erp-accent-dark:    #a8841c;
  --erp-accent-soft:    #f4e8bf;
  --erp-teal:           #0d9488;  /* secondary accent / success-adjacent */
  --erp-teal-dark:      #0b766d;

  /* ---- surfaces --------------------------------------------------------*/
  --erp-bg:             #f2f3f7;
  --erp-card-bg:        #ffffff;
  --erp-border:         #e3e6ee;
  --erp-border-strong:  #d3d8e4;
  --erp-text:           #1f2530;
  --erp-text-muted:     #6b7280;

  /* ---- layout metrics (desktop-first: 13"–15.6"+) ---------------------*/
  --erp-sidebar-width:      248px;
  --erp-sidebar-rail-width: 68px;
  --erp-header-height:      58px;
  --erp-subheader-height:   38px;

  --erp-radius-lg: 12px;
  --erp-radius-md: 8px;
  --erp-shadow-soft:  0 1px 3px rgba(15, 23, 42, .07), 0 1px 2px rgba(15, 23, 42, .06);
  --erp-shadow-hover: 0 12px 28px rgba(15, 23, 42, .14);

  --erp-ok:     #16a34a;
  --erp-danger: #dc2626;
  --erp-warn:   #d97706;

  /* Force light-themed native form controls regardless of the OS/browser
     dark-mode preference — the #1 cause of "white text on white dropdown"
     bug reports, since Windows/Chrome auto-dark-themes <select>/<option>
     when no explicit color-scheme is declared. */
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { height: 100%; overflow-x: hidden; }
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body {
  font-family: 'Segoe UI', 'Inter', system-ui, -apple-system, Roboto, Arial, sans-serif;
  background-color: var(--erp-bg);
  color: var(--erp-text);
  font-size: 13.5px;
  /* Desktop/laptop-first (this app targets 13"-15.6"+ screens), but NO hard
     min-width on body — that forced the *whole page* to scroll horizontally
     whenever the viewport was narrower than it (e.g. resizing devtools).
     Individual wide elements (tables) handle their own horizontal scroll
     via .table-responsive below instead. */
}

a { text-decoration: none; }
code { font-size: .82em; }

/* ---------------------------------------------------------- scrollbars --
   Scrollbars are functionally present everywhere but never visually shown,
   per spec — content still scrolls normally with mouse wheel / trackpad /
   keyboard, only the visual bar itself is suppressed. */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* ============================================================================
   HEADER — 3 zones: brand/toggle/home (left) · company+user (center) ·
   status/settings/logout/avatar (right)
   ============================================================================ */
.erp-navbar {
  height: var(--erp-header-height);
  flex: 0 0 auto;
  background: linear-gradient(120deg, var(--erp-primary), var(--erp-primary-soft));
  color: #e7e9f0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 1rem;
  z-index: 1040;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
}

.navbar-zone { display: flex; align-items: center; gap: .4rem; }
.navbar-zone-left { justify-content: flex-start; }
.navbar-zone-center { justify-content: center; gap: .6rem; }
.navbar-zone-right { justify-content: flex-end; }
.navbar-zone-sep { color: #4b5674; }

/* Company (top) / user (bottom) stacked block, right-aligned in the header */
.nav-location-stack {
  display: flex; flex-direction: column; align-items: flex-end;
  margin-right: .5rem; line-height: 1.25;
}
.nav-location-top { font-size: .74rem; color: #f7f8fb; font-weight: 600; }
.nav-location-bottom { font-size: .68rem; color: #a8adc2; }
.nav-location-top i, .nav-location-bottom i { color: var(--erp-accent); margin-right: .3rem; }

.erp-navbar .nav-chip {
  display: flex; align-items: center; gap: .4rem;
  padding: .32rem .65rem;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  font-size: .74rem;
  color: #d5d9e6;
  white-space: nowrap;
}
.erp-navbar .nav-chip i { color: var(--erp-accent); }
.erp-navbar .nav-chip strong { color: #f7f8fb; font-weight: 600; }

/* Internet status: a Wi-Fi icon (no "Online" text) that changes colour and
   gets a subtle fade-pulse while actively re-checking the connection.
   Green = connected, Orange = slow (<1 Mbps-equivalent), Red = offline. */
.nav-chip-net { padding: .32rem .55rem; }
.js-net-status-icon { font-size: .95rem; transition: color .25s; }
.js-net-status-icon.net-status-ok     { color: var(--erp-ok); }
.js-net-status-icon.net-status-warn   { color: var(--erp-warn); }
/* Offline is always red — deliberately !important so no future theme
   variable can ever accidentally soften this signal. */
.js-net-status-icon.net-status-danger { color: #dc2626 !important; }
.js-net-status-icon.is-checking { animation: erpNetFade 1.1s ease-in-out infinite; }
@keyframes erpNetFade {
  0%, 100% { opacity: 1; transform: translateY(0); }
  50%      { opacity: .45; transform: translateY(-1px); }
}

.erp-navbar .icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: #d5d9e6;
  border: none; background: transparent;
  transition: .15s;
  flex-shrink: 0;
}
.erp-navbar .icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
/* Logout is a destructive/exit action — always shown in red, not just on hover. */
.erp-navbar .icon-btn-danger { color: #f28b82; }
.erp-navbar .icon-btn-danger:hover { background: rgba(220,38,38,.18); color: #fecaca; }

.erp-navbar .brand-logo {
  display: flex; align-items: center; gap: .55rem;
  font-weight: 700; color: #fff; font-size: .98rem;
}
.erp-navbar .brand-logo .brand-badge {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--erp-accent), var(--erp-accent-dark));
  display: flex; align-items: center; justify-content: center;
  color: #241c04; font-size: .95rem;
  box-shadow: 0 2px 8px rgba(201,162,39,.35);
}
.erp-navbar .brand-text { letter-spacing: .01em; }
.erp-navbar .brand-text small { display: block; font-weight: 400; font-size: .6rem; color: #8b93ad; letter-spacing: .04em; }

/* Avatar button (initial letter fallback when no profile image) */
.user-avatar-btn {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.06);
  padding: 0; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.user-avatar-btn img { width: 100%; height: 100%; object-fit: cover; }
.user-avatar-btn .user-avatar-initial {
  font-weight: 700; font-size: .82rem; color: var(--erp-accent);
}
.user-avatar-btn:hover { border-color: var(--erp-accent); }

/* ============================================================================
   SUB-HEADER  — thin, clickable breadcrumb path, lives INSIDE the content
   column only (not spanning over the sidebar).
   ============================================================================ */
.erp-subheader {
  height: var(--erp-subheader-height);
  background: transparent;
  border-bottom: 1px solid var(--erp-border);
  display: flex;
  align-items: center;
  font-size: .76rem;
  margin: 0 0 1rem;
}
.erp-subheader a { color: var(--erp-text-muted); }
.erp-subheader a:hover { color: var(--erp-accent-dark); }
.erp-subheader .crumb-sep { margin: 0 .4rem; color: #c6cad6; }
.erp-subheader .crumb-active { color: var(--erp-accent-dark); font-weight: 600; }

/* ============================================================================
   LAYOUT SHELL — SIDEBAR NAVIGATION
   ============================================================================ */
.erp-wrapper {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

.erp-sidebar {
  width: var(--erp-sidebar-width);
  background: linear-gradient(180deg, var(--erp-primary), var(--erp-primary-soft));
  color: #f2f3f7;
  flex: 0 0 auto;
  height: 100%;
  overflow-y: auto;
  transition: width .2s ease;
  padding-top: .5rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.25) transparent;
}
.erp-sidebar::-webkit-scrollbar { width: 5px; height: 5px; display: block; }
.erp-sidebar::-webkit-scrollbar-track { background: transparent; }
.erp-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.25); border-radius: 4px; }
.erp-sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.4); }

.sidebar-brand {
  padding: .85rem 1.25rem .6rem;
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #8b93ad;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: .5rem;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-menu { list-style: none; padding: 0 .65rem 1rem; margin: 0; }

.sidebar-menu .nav-link {
  color: #ffffff;
  padding: .58rem .8rem;
  border-radius: var(--erp-radius-md);
  display: flex;
  align-items: center;
  gap: .7rem;
  font-weight: 500;
  font-size: .85rem;
  margin-bottom: .18rem;
  transition: all .15s ease;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-seq {
  width: 20px; 
  height: 20px; 
  flex-shrink: 0; 
  border-radius: 50%;
  background: rgba(255,255,255,.08); 
  color: #b4bad0;
  display: flex; 
  align-items: center; 
  justify-content: center;
  font-size: .68rem; 
  font-weight: 700;
}

.sidebar-menu .nav-link .link-label { 
  overflow: hidden; 
  text-overflow: ellipsis; 
}

.sidebar-group-label {
  padding: .9rem .8rem .3rem; 
  margin-top: .2rem;
  font-size: .68rem; 
  font-weight: 700; 
  letter-spacing: .06em; 
  text-transform: uppercase;
  color: #7d84a0; 
  border-top: 1px solid rgba(255,255,255,.06);
}

.sidebar-menu .nav-link:hover { color: #fff; background-color: var(--erp-primary-3); }
.sidebar-menu .nav-link:hover .sidebar-seq { color: #fff; }

.sidebar-menu .nav-link.active {
  color: #241c04;
  background: linear-gradient(120deg, var(--erp-accent), var(--erp-accent-dark));
  box-shadow: 0 4px 14px rgba(201,162,39,.35);
  font-weight: 700;
}
.sidebar-menu .nav-link.active .sidebar-seq { 
  background: rgba(36,28,4,.18); 
  color: #241c04; 
}
.sidebar-menu .nav-link.active i { color: #241c04; }

/* ---- EXPANDED MODE DISPLAY RULES ---- */
/* Hide Icon in expanded mode; show sequence and page name */
.erp-sidebar .sidebar-menu .nav-link i { 
  display: none !important; 
}
.erp-sidebar .sidebar-seq,
.erp-sidebar .link-label { 
  display: flex; 
}

/* ---- COLLAPSED MODE DISPLAY RULES (Desktop) ---- */
body.sidebar-collapsed .erp-sidebar { 
  width: var(--erp-sidebar-rail-width); 
}
body.sidebar-collapsed .sidebar-brand,
body.sidebar-collapsed .sidebar-group-label,
body.sidebar-collapsed .sidebar-seq,
body.sidebar-collapsed .link-label { 
  display: none !important; 
}

/* Show Icon ONLY in collapsed mode */
body.sidebar-collapsed .sidebar-menu .nav-link i { 
  display: inline-block !important;
  width: auto; 
  font-size: 1.02rem; 
  margin: 0 auto;
}

body.sidebar-collapsed .sidebar-menu .nav-link { 
  justify-content: center; 
  padding: .62rem 0; 
}

.erp-content {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  height: calc(100vh - var(--erp-header-height));
  max-height: none;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background-color: var(--erp-bg);
  padding: 1.1rem 1.5rem 0;
  row-gap: 0.3rem;
}
.erp-content-full { width: 100%; }

/* ============================================================================
   CARDS / SURFACES
   ============================================================================ */
.card-modern,
.card-surface {
  border: 1px solid var(--erp-border);
  border-radius: var(--erp-radius-lg);
  box-shadow: var(--erp-shadow-soft);
  background: var(--erp-card-bg);
}
.card-surface-header {
  padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--erp-border);
  font-weight: 600;
  font-size: .89rem;
  display: flex; align-items: center; justify-content: space-between;
}
.card-surface-body { padding: 1.1rem; }

/* ---- module tiles (compact, scales to many modules) ------------------- */
.module-tile-grid { --tile-min: 148px; }
.module-tile {
  display: block;
  border-radius: var(--erp-radius-lg);
  padding: .9rem .85rem;
  background: linear-gradient(150deg, var(--erp-primary-soft), var(--erp-primary));
  color: #fff;
  box-shadow: var(--erp-shadow-soft);
  transition: .16s ease;
  height: 100%;
  border: 1px solid transparent;
  min-height: 110px;
}
.module-tile:hover { transform: translateY(-3px); box-shadow: var(--erp-shadow-hover); color: #fff; border-color: rgba(201,162,39,.4); }
.module-tile .tile-icon {
  width: 34px; height: 34px; border-radius: 8px;
  background: rgba(255,255,255,.12);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; margin-bottom: .55rem; color: var(--erp-accent);
}
.module-tile .tile-name { font-weight: 700; font-size: .84rem; line-height: 1.25; }
.module-tile .tile-desc { font-size: .68rem; opacity: .78; margin-top: .2rem; line-height: 1.3; }

/* ---- KPI cards ---------------------------------------------------------*/
.kpi-card {
  border-radius: var(--erp-radius-lg);
  padding: 1.1rem 1.3rem;
  background: var(--erp-card-bg);
  border: 1px solid var(--erp-border);
  box-shadow: var(--erp-shadow-soft);
  height: 100%;
}
.kpi-card .kpi-value { font-size: 1.55rem; font-weight: 700; color: var(--erp-primary); line-height: 1.2; }
.kpi-card .kpi-label { color: var(--erp-text-muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; margin-top: .1rem; }
.kpi-card .kpi-icon {
  width: 46px; height: 46px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  background: var(--erp-accent-soft); color: var(--erp-accent-dark);
  flex-shrink: 0;
}

/* ============================================================================
   TABLES — fixed/sticky header while the body scrolls within its own frame
   ============================================================================ */
.table-responsive {
  max-height: calc(100vh - 340px);
  min-height: 160px;
  overflow-y: auto;
  overflow-x: auto;
  max-width: 100%;
  border: 1px solid var(--erp-border);
  border-radius: var(--erp-radius-md);
  /* Thin, visible scrollbar on BOTH axes whenever content overflows the
     table's own bounded height/width — not hidden. Content still scrolls
     normally via trackpad/mouse wheel/keyboard either way; this only
     controls whether the bar itself is visible. */
  scrollbar-width: thin;
}
.table-responsive::-webkit-scrollbar { width: 7px; height: 7px; }
.table-responsive::-webkit-scrollbar-track { background: transparent; }
.table-responsive::-webkit-scrollbar-thumb { background: var(--erp-border); border-radius: 4px; }
.table-responsive::-webkit-scrollbar-thumb:hover { background: #b9bfcf; }
.table-responsive::-webkit-scrollbar-corner { background: transparent; }
.table-modern { margin-bottom: 0; font-size: .82rem; width: max-content; min-width: 100%; }
.table-modern thead th {
  background-color: #eef0f6;
  color: #46506b;
  font-weight: 600;
  font-size: .71rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--erp-border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}
.table-modern td, .table-modern th { vertical-align: middle; }
.table-modern tbody tr:hover > td { background-color: #efe6c8; } /* targets <td> directly (not just the <tr>'s own background) so every cell — including any with its own inner elements — paints consistently across the full row */

/* Frozen columns (first N, per RustamERP.initFrozenColumns) — pinned while
   scrolling horizontally. Each cell needs an explicit background (sticky
   cells sit above scrolled-past content, so transparency would show it
   bleeding through) that matches whatever that row's current state is:
   plain body rows, the hover state, and the sticky header. */
.js-frozen-cols-table .js-frozen-col {
  position: sticky;
  z-index: 1;
  background-color: #fff;
}
.js-frozen-cols-table thead .js-frozen-col {
  z-index: 3; /* above both the regular sticky thead (2) and frozen body cells (1) at the corner intersection */
  background-color: #eef0f6; /* matches .table-modern thead th */
}
.js-frozen-cols-table tbody tr:hover .js-frozen-col {
  background-color: #e6d6a0 !important; /* !important guarantees this wins over the base .js-frozen-col white background above, regardless of rule order — frozen + scrolled cells now highlight as one continuous colour across the entire row */
}
.js-frozen-cols-table .js-frozen-col-last {
  border-right: 2px solid var(--erp-border); /* visual seam marking where the frozen region ends */
}
.table-modern code {
  background: #eef0f6; color: #4a5170;
  padding: .1rem .35rem; border-radius: 4px; font-size: .78em;
}

.table-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap; margin-bottom: .85rem;
}
/* Table toolbar search state. The JS intentionally uses a class rather than
   inline display so pagination/frozen-column code can safely re-measure rows. */
.table-toolbar .table-search { max-width: 260px; }
.js-search-hidden { display: none !important; }
.table-toolbar .table-actions .btn { margin-left: .35rem; }

/* ============================================================================
   STATUS PILLS — uniform transaction status across the software
   ============================================================================ */
.status-pill {
  display: inline-flex; align-items: center; gap: .32rem;
  padding: .24rem .65rem;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.status-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-pill.active     { background: #dcfce7; color: #15803d; }
.status-pill.inactive   { background: #fee2e2; color: #b91c1c; }
.status-pill.pending    { background: #fef3c7; color: #92400e; }
.status-pill.confirmed  { background: #dbeafe; color: #1d4ed8; }
.status-pill.cancelled  { background: #ede9fe; color: #6d28d9; }

/* ============================================================================
   UNIFORM ICON ACTION BUTTONS (icons only — no bare letters anywhere)
   ============================================================================ */
.icon-action {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--erp-radius-md);
  font-size: .82rem;
  border: 1px solid transparent;
  transition: .15s;
  margin-right: .3rem;
}
.icon-action:last-child { margin-right: 0; }
.icon-action[disabled], .icon-action.is-off { opacity: .35; pointer-events: none; }

.icon-action.act-a { background: #dcfce7; color: #15803d; border-color: #bbf7d0; } /* Activate */
.icon-action.act-b { background: #fee2e2; color: #b91c1c; border-color: #fecaca; } /* Block / Deactivate */
/* Single unified status-toggle icon (point 16): one button per row whose
   look reflects the CURRENT state — full green when Active, faded grey
   (never a red "disabled" look) when Inactive — and is always clickable,
   flipping to the opposite state on click. */
.icon-action.act-toggle.is-active   { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.icon-action.act-toggle.is-inactive { background: #f1f5f9; color: #94a3b8; border-color: #e2e8f0; }
.icon-action.act-log { background: #eef2ff; color: #4338ca; border-color: #e0e7ff; } /* View activity log */

/* Global activity-log modal timeline */
.activity-timeline { list-style: none; margin: 0; padding: 0; }
.activity-timeline-item { display: flex; gap: .75rem; padding: .75rem 0; border-bottom: 1px solid var(--erp-border); }
.activity-timeline-item:last-child { border-bottom: none; }
.activity-timeline-icon {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--erp-accent-soft); color: var(--erp-accent-dark); font-size: .8rem;
}
.activity-timeline-meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .2rem; }
.activity-timeline-details { font-size: .8rem; color: var(--erp-text-muted); }
.activity-timeline-body { flex: 1; min-width: 0; }
.activity-timeline-body table.table-sm td, .activity-timeline-body table.table-sm th { padding: .4rem .5rem; font-size: .78rem; }
.js-activity-log-body { max-height: 60vh; overflow-y: auto; }
.icon-action.act-v { background: #e0e7ff; color: #4338ca; border-color: #c7d2fe; } /* View */
.icon-action.act-c { background: #ede9fe; color: #6d28d9; border-color: #ddd6fe; } /* Cancel */
.icon-action.act-d { background: #fee2e2; color: #b91c1c; border-color: #fecaca; } /* Delete (soft, rare) */
.icon-action.act-u { background: var(--erp-accent-soft); color: var(--erp-accent-dark); border-color: #ecd98f; } /* Update */
.icon-action.act-p { background: #fef3c7; color: #92400e; border-color: #fde68a; } /* Process / Reset */
.icon-action:hover { filter: brightness(.95); }

/* Full-size uniform icon buttons for primary form actions (Submit/Update/Delete/Generate) */
.btn-icon-uniform {
  min-width: 108px;
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  font-weight: 600; font-size: .82rem;
  padding: .5rem 1rem;
  border-radius: var(--erp-radius-md);
}

/* ============================================================================
   BUTTONS
   ============================================================================ */
.btn-brand {
  background: linear-gradient(120deg, var(--erp-accent), var(--erp-accent-dark));
  border: none; color: #241c04; font-weight: 700;
}
.btn-brand:hover { color: #241c04; filter: brightness(1.05); }
.btn-outline-brand {
  border: 1px solid var(--erp-accent-dark); color: var(--erp-accent-dark);
  font-weight: 600; background: #fff;
}
.btn-outline-brand:hover { background: var(--erp-accent-dark); color: #fff; }

/* ============================================================================
   FORMS  (compact fields, inline refresh / add / info buttons, validation)
   ============================================================================ */
.form-label { font-weight: 600; font-size: .78rem; color: #1e2538; margin-bottom: .25rem; }
.form-control, .form-select {
  font-size: .83rem;
  /* padding: .42rem .65rem; */
  border-radius: var(--erp-radius-md);
  border-color: var(--erp-border-strong);
  background-color: #fff;
  color: var(--erp-text);
}
.form-control:focus, .form-select:focus {
  border-color: var(--erp-accent);
  box-shadow: 0 0 0 .18rem rgba(201,162,39,.2);
}
.form-text { font-size: .71rem; }

/* Force light-themed native <select>/<option> everywhere, overriding any
   OS/browser dark-mode auto-styling that would otherwise render white text
   on a white background. */
select, select option,
.select2-container, .select2-dropdown,
.select2-results__option, .select2-search__field {
  background-color: #fff !important;
  color: var(--erp-text) !important;
}
.select2-results__option--highlighted[aria-selected] {
  background-color: var(--erp-accent) !important;
  color: #241c04 !important;
}
.select2-container .select2-selection--single {
  height: 38px !important; padding-top: 4px;
  border-color: var(--erp-border-strong) !important;
}
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 36px !important; }
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default .select2-selection--single:focus { border-color: var(--erp-accent) !important; }
.select2-dropdown { border-color: var(--erp-border-strong) !important; z-index: 2000; }

/* Instant field-level validation feedback (both our own engine and
   jQuery Validate render into the same visual style, so it's consistent
   regardless of which one is active on a given form). */
.form-control.is-valid, .form-select.is-valid { border-color: var(--erp-ok); background-image: none; }
.form-control.is-invalid, .form-select.is-invalid,
.form-control.error, .form-select.error { border-color: var(--erp-danger) !important; background-image: none; }

/* The above targets the real <select>/<input> element directly, but
   Select2 hides that element and renders its own container next to it —
   so an invalid Select2 field showed the error message (now fixed above)
   but never actually turned red, since .is-invalid never reached anything
   visible. Same red border, same target element (Select2 always inserts
   its container as the very next sibling of the select it replaced). */
select.is-invalid + .select2-container .select2-selection,
select.error + .select2-container .select2-selection {
  border-color: var(--erp-danger) !important;
}
select.is-valid + .select2-container .select2-selection {
  border-color: var(--erp-ok);
}

.field-feedback,
label.error {
  display: block;
  font-size: .72rem;
  font-weight: 500;
  color: var(--erp-danger) !important;
  margin-top: .3rem;
  padding-left: .1rem;
  background: none !important;
}
.field-feedback:empty { display: none; }
.field-feedback::before,
label.error::before {
  content: '\f06a'; /* fa-circle-exclamation */
  font-family: 'Font Awesome 6 Free', 'Font Awesome 7 Free';
  font-weight: 900;
  margin-right: .35rem;
}

/* Field cluster: input + refresh/add/info mini buttons */
.field-with-tools { display: flex; gap: .3rem; align-items: stretch; }
.field-with-tools .form-control, .field-with-tools .form-select { flex: 1 1 auto; }
.field-tool-btn {
  width: 36px; flex: 0 0 36px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--erp-border-strong);
  border-radius: var(--erp-radius-md);
  background: #f7f8fb; color: var(--erp-text-muted);
  transition: .15s;
}
.field-tool-btn:hover { background: var(--erp-accent); color: #241c04; border-color: var(--erp-accent); }

/* Larger, clearer checkboxes across the app (rights matrix, toggles) */
.form-check-input {
  width: 1.15em; height: 1.15em;
  border-color: var(--erp-border-strong);
  cursor: pointer;
}
.form-check-input:checked { background-color: var(--erp-accent-dark); border-color: var(--erp-accent-dark); }
.form-check-input:focus { box-shadow: 0 0 0 .16rem rgba(201,162,39,.25); }

/* ============================================================================
   MODALS
   ============================================================================ */
.modal-content { border-radius: var(--erp-radius-lg); border: none; }
.modal-header { border-bottom: 1px solid var(--erp-border); padding: .9rem 1.1rem; }
.modal-footer { border-top: 1px solid var(--erp-border); padding: .8rem 1.1rem; }
.modal-title { font-size: .95rem; }
/* Bounded to the viewport so a long form scrolls WITHIN the modal rather
   than pushing the footer buttons off-screen — thin, visible scrollbar
   (not hidden) when content is actually taller than this. */
.modal-body {
  max-height: 72vh;
  overflow-y: auto;
  scrollbar-width: thin;
}
.modal-body::-webkit-scrollbar { width: 7px; }
.modal-body::-webkit-scrollbar-track { background: transparent; }
.modal-body::-webkit-scrollbar-thumb { background: var(--erp-border); border-radius: 4px; }
.modal-body::-webkit-scrollbar-thumb:hover { background: #b9bfcf; }

/* ============================================================================
   UPLOAD HINT BLOCK
   ============================================================================ */
.upload-hint {
  font-size: .7rem; color: var(--erp-text-muted);
  background: #f7f8fb; border: 1px dashed var(--erp-border-strong);
  border-radius: var(--erp-radius-md);
  padding: .5rem .7rem; margin-top: .35rem;
}

/* ============================================================================
   LOGIN
   ============================================================================ */
.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at top left, var(--erp-primary-soft), var(--erp-primary) 65%);
  padding: 1rem;
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--erp-card-bg);
  border-radius: var(--erp-radius-lg);
  box-shadow: 0 25px 60px rgba(0,0,0,.35);
  overflow: hidden;
}
.login-card .login-head {
  background: linear-gradient(120deg, var(--erp-accent), var(--erp-accent-dark));
  color: #241c04; padding: 1.5rem 1.75rem;
}
.login-card .login-head h1 { font-size: 1.25rem; font-weight: 800; margin: 0; }
.login-card .login-head p { margin: .15rem 0 0; font-size: .78rem; opacity: .85; }
.login-card .login-body { padding: 1.75rem; }

/* ============================================================================
   ERROR PAGES
   ============================================================================ */
.error-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--erp-bg); text-align: center; padding: 2rem;
}
.error-shell .error-code { font-size: 4.5rem; font-weight: 800; color: var(--erp-primary-soft); line-height: 1; }

/* ============================================================================
   MISC UTILITIES
   ============================================================================ */
.text-brand { color: var(--erp-accent-dark); }
.text-accent { color: var(--erp-teal); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.rounded-lg { border-radius: var(--erp-radius-lg) !important; }

/* ============================================================================
   FOOTER — Full-width edge alignment within .erp-content padding
   ============================================================================ */
.erp-footer {
  margin-top: auto; /* short pages push the footer to the viewport bottom */
  margin-left: -1.5rem;
  margin-right: -1.5rem;
  width: auto;
  box-sizing: border-box;
  flex: 0 0 auto;
  padding: .8rem 1.5rem;
  font-size: .72rem;
  color: var(--erp-text-muted);
  background: var(--erp-card-bg);
  border-top: 1px solid var(--erp-border);
}

.erp-footer-version { 
  opacity: .7; 
}

/* Root dashboard/profile pages using standalone footer.php */
.erp-footer-root {
  margin-left: -1.5rem;
  margin-right: -1.5rem;
  width: auto;
}

/* Responsive side-margin adjustments to match .erp-content padding */
@media (max-width: 1279px) {
  .erp-footer,
  .erp-footer-root {
    margin-left: -1.15rem;
    margin-right: -1.15rem;
    padding-left: 1.15rem;
    padding-right: 1.15rem;
  }
}

@media (max-width: 991.98px) {
  .erp-footer,
  .erp-footer-root {
    margin-left: -1rem;
    margin-right: -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

@media (max-width: 575.98px) {
  .erp-footer,
  .erp-footer-root {
    margin-left: -0.75rem;
    margin-right: -0.75rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}

/* Password strength meter (RustamERP.initPasswordStrengthMeter) */
.password-strength-meter { margin-top: .4rem; display: flex; align-items: center; gap: .5rem; }
.password-strength-track { flex: 1 1 auto; height: 5px; border-radius: 3px; background: var(--erp-border); overflow: hidden; }
.password-strength-fill { height: 100%; width: 0; border-radius: 3px; transition: width .25s ease, background-color .25s ease; }
.password-strength-fill.is-weak   { background: var(--erp-danger); }
.password-strength-fill.is-normal { background: var(--erp-warn); }
.password-strength-fill.is-strong { background: var(--erp-ok); }
.password-strength-label { font-size: .68rem; font-weight: 700; min-width: 48px; text-align: right; }

/* Tooltips restyled to match the elegant palette */
.tooltip .tooltip-inner {
  background: var(--erp-primary); color: #f2f3f7;
  font-size: .72rem; padding: .35rem .6rem; border-radius: 6px;
}
.tooltip.bs-tooltip-end .tooltip-arrow::before,
.tooltip .tooltip-arrow::before { border-right-color: var(--erp-primary); }

/* ============================================================================
   THEME POPOVER — opens near the Settings icon (positioned via JS), not
   centered like a modal.
   ============================================================================ */
.theme-popover {
  position: fixed;
  z-index: 1080;
  width: 280px;
  background: var(--erp-card-bg);
  border-radius: var(--erp-radius-lg);
  box-shadow: var(--erp-shadow-hover);
  border: 1px solid var(--erp-border);
  overflow: hidden;
}
.theme-popover-header {
  display: flex; align-items: center;
  padding: .7rem .9rem;
  background: linear-gradient(120deg, var(--erp-primary), var(--erp-primary-soft));
  color: #fff; font-weight: 600; font-size: .85rem;
}
.theme-popover-header .btn-close { font-size: .65rem; }
.theme-popover-body { padding: .75rem; display: flex; flex-direction: column; gap: .5rem; max-height: 360px; overflow-y: auto; }

.theme-swatch-card {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .6rem;
  border-radius: var(--erp-radius-md);
  border: 1.5px solid var(--erp-border);
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: .15s;
}
.theme-swatch-card:hover { border-color: var(--sw-accent, var(--erp-accent)); }
.theme-swatch-card.is-selected { border-color: var(--sw-accent, var(--erp-accent)); background: #fafaf5; }
.theme-swatch-preview {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--sw-primary, #141b2d), var(--sw-accent, #c9a227));
}
.theme-swatch-name { font-size: .8rem; font-weight: 600; flex: 1; }
.theme-swatch-check { color: var(--sw-accent, var(--erp-accent)); }

/* Responsive layout for desktop, tablet and mobile. */
@media (max-width: 1279px) {
  :root { --erp-sidebar-width: 216px; }
  .erp-content { padding: 1rem 1.15rem 0; }
  .erp-footer { margin-left: -1.15rem; width: calc(100% + 2.3rem); padding-left: 1.15rem; padding-right: 1.15rem; }
  .erp-footer-root {
    margin-left: -1.15rem;
    width: calc(100% + 2.3rem);
  }
}

/* ============================================================================
   DATEPICKER — no explicit z-index existed before, so the popup could
   render behind sticky table headers/frozen columns or modal content
   depending on default stacking. Set higher than everything else in the
   app (modals top out at 1080, select2 at 2000).
   ============================================================================ */
.ui-datepicker { z-index: 3000 !important; }

/* Out-of-range days (before min-date / after max-date) — solid red, not
   just faded, so "you can't pick this" reads as a clear stop rather than
   a vague greyed-out state. */
.ui-datepicker td.ui-state-disabled > span {
  background: #ff0000;
  color: #fff;
}
.ui-state-disabled,
.ui-widget-content .ui-state-disabled,
.ui-widget-header .ui-state-disabled {
  opacity: 1;
}
/* ============================================================================
   Profile image/signature picker
   ============================================================================ */
.profile-upload-card .card-surface-header .badge {
  font-size: .68rem;
  font-weight: 700;
  border: 1px solid var(--erp-border);
}
.profile-file-picker {
  position: relative;
  width: 100%;
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  border: 1px dashed var(--erp-border-strong);
  background: var(--erp-bg);
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.profile-file-picker:hover,
.profile-file-picker:focus-within {
  border-color: var(--erp-accent-dark);
  box-shadow: 0 0 0 .2rem rgba(214, 170, 45, .12);
  transform: translateY(-1px);
}
.profile-file-picker-avatar {
  min-height: 150px;
  border-radius: 1rem;
}
.profile-file-picker-sign {
  min-height: 125px;
  border-radius: 1rem;
}
.profile-file-input {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.profile-preview-frame {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--erp-border);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .08);
}
.profile-file-picker-avatar .profile-preview-frame {
  width: 92px;
  height: 92px;
  border-radius: 50%;
}
.profile-file-picker-sign .profile-preview-frame {
  width: min(100%, 210px);
  height: 92px;
  border-radius: .75rem;
}
.profile-preview-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.profile-file-picker-avatar .profile-preview-image {
  object-fit: cover;
}
.profile-preview-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--erp-text-muted);
  font-size: 1.7rem;
  background: linear-gradient(135deg, #f8fafc, #eef2f7);
}
.profile-camera-badge {
  position: absolute;
  z-index: 4;
  right: calc(50% - 52px);
  bottom: calc(50% - 52px);
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--erp-accent-dark);
  color: #fff;
  border: 3px solid #fff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, .18);
  pointer-events: none;
}
.profile-file-picker-sign .profile-camera-badge {
  right: calc(50% - 112px);
  bottom: 10px;
}
.profile-file-name {
  margin-top: .65rem;
  font-size: .76rem;
  font-weight: 600;
  color: var(--erp-text-muted);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-file-error {
  margin-top: .65rem;
  margin-bottom: 0;
  padding: .55rem .7rem;
  font-size: .76rem;
}

/* ============================================================================
   Rights Summary — reference-document grid + View modal
   ============================================================================ */
/* ============================================================================
   Rights Summary — reference-document grid + View modal (Theme-Aware)
   ============================================================================ */

/* Group & Subgroup Row Headings (Dynamic Primary & Soft Surfaces) */
.table-group-row td {
  background-color: var(--erp-primary) !important;
  color: #ffffff !important;
  font-weight: 700;
  border-color: var(--erp-primary-3) !important;
}

.table-subgroup-row td {
  background-color: var(--erp-primary-soft) !important;
  color: #ffffff !important;
  font-weight: 700;
  border-color: var(--erp-primary-3) !important;
}

/* Row-update flash — briefly highlights the specific row a save just
   touched after an AJAX table refresh, so the change is visible without
   forcing the page to scroll anywhere. Reusable by any get_ajax table:
   just add [data-row-pk] to each <tr> and toggle .row-just-updated. */
@keyframes rowJustUpdatedFlash {
  0%   { background-color: var(--erp-accent-soft, #fff3cd); }
  100% { background-color: transparent; }
}
tr.row-just-updated td {
  animation: rowJustUpdatedFlash 2.2s ease-out;
}

/* Modal Metadata Wrapper */
.rights-summary-meta {
  border: 1px solid var(--erp-border);
  border-radius: var(--erp-radius-md);
  background: var(--erp-card-bg);
  overflow: hidden;
}

.rights-summary-meta-row {
  display: grid;
  grid-template-columns: 180px 18px minmax(0, 1fr);
  gap: .45rem;
  align-items: start;
  padding: .55rem .75rem;
  border-bottom: 1px solid var(--erp-border);
  font-size: .82rem;
  min-height: 38px;
}

.rights-summary-meta-row:last-child {
  border-bottom: 0;
}

.rights-summary-meta-label {
  font-weight: 700;
  color: var(--erp-text);
}

.rights-summary-meta-separator {
  color: var(--erp-text-muted);
  font-weight: 700;
}

.rights-summary-meta-value {
  color: var(--erp-text);
  font-weight: 500;
  overflow-wrap: anywhere;
}

/* Section Titles */
.rights-summary-section-title {
  font-weight: 800;
  color: var(--erp-accent-dark);
  font-size: .88rem;
  margin-bottom: .2rem;
}

/* Modal Tables */
.rights-summary-modal-table th,
.rights-summary-modal-table td {
  white-space: nowrap;
}

.rights-summary-modal-table td:nth-child(5) {
  white-space: normal;
  min-width: 160px;
}

.rights-summary-modal-table thead th {
  color: var(--erp-text) !important;
  background-color: var(--erp-bg) !important;
  border-bottom: 1px solid var(--erp-border-strong) !important;
  opacity: 1 !important;
  visibility: visible !important;
  text-indent: 0 !important;
}

.rights-summary-modal-table .js-remove-user-right {
  white-space: nowrap;
}

/* Detail Cards Layout */
.rights-summary-view-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem;
}

.rights-summary-view-detail {
  border: 1px solid var(--erp-border);
  border-radius: var(--erp-radius-sm, 6px);
  padding: .7rem .8rem;
  background: var(--erp-card-bg);
}

.rights-summary-view-detail-label {
  display: block;
  margin-bottom: .2rem;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .035em;
  color: var(--erp-text-muted);
}

.rights-summary-view-detail-value {
  display: block;
  color: var(--erp-text);
  overflow-wrap: anywhere;
}

/* Responsive Overrides */
@media (max-width: 767.98px) {
  .rights-summary-view-details {
    grid-template-columns: 1fr;
  }
  .rights-summary-meta-row {
    grid-template-columns: 125px 14px minmax(0, 1fr);
  }
  .rights-summary-modal-table {
    font-size: .74rem;
  }
}
@media (max-width: 767.98px) {
  .rights-summary-view-details { grid-template-columns: 1fr; }
}
@media (max-width: 767.98px) {
  .rights-summary-meta-row { grid-template-columns: 125px 14px minmax(0, 1fr); }
  .rights-summary-modal-table { font-size: .74rem; }
  .profile-camera-badge { right: 10px; bottom: 10px; }
  .profile-file-picker-sign .profile-camera-badge { right: 10px; bottom: 10px; }
}


/* Global feedback must appear at the top of the viewport. */
.growl, .growl-notice, .growl-error, .growl-warning, #growls {
  z-index: 20000 !important;
}
#growls { top: 18px !important; right: 18px !important; bottom: auto !important; }
.modal-dialog.js-modal-top { margin-top: 1.25rem; }
@media (min-width: 576px) { .modal-dialog.js-modal-top { margin-top: 1.5rem; } }

/* USM compact pagination — keeps AJAX-loaded tables aligned with the ERP UI. */
.usm-pagination-wrap {
  min-height: 42px;
}
.usm-pagination .page-link {
  min-width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .25rem .55rem;
  border-radius: .4rem !important;
  margin-left: .2rem;
  font-size: .76rem;
  font-weight: 600;
}
.usm-pagination .page-item:first-child .page-link,
.usm-pagination .page-item:last-child .page-link {
  min-width: 34px;
}
.usm-pagination-ellipsis {
  border-color: transparent !important;
  background: transparent !important;
}
@media (max-width: 575.98px) {
  .usm-pagination-wrap {
    align-items: flex-start !important;
  }
  .usm-pagination-wrap nav {
    width: 100%;
  }
  .usm-pagination {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}


/* Tablet / mobile sidebar drawer */
.erp-sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
  .erp-wrapper { position: relative; min-width: 0; }
  .erp-sidebar {
    position: fixed;
    left: 0;
    top: var(--erp-header-height);
    bottom: 0;
    z-index: 1040;
    width: min(82vw, 300px);
    height: auto;
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: 10px 0 28px rgba(0,0,0,.22);
  }
  .erp-sidebar.open, body.sidebar-mobile-open .erp-sidebar { transform: translateX(0); }
  .erp-sidebar-backdrop {
    position: fixed; inset: var(--erp-header-height) 0 0 0;
    z-index: 1035; background: rgba(0,0,0,.35);
  }
  body.sidebar-mobile-open .erp-sidebar-backdrop { display: block; }
  .erp-content { width: 100%; height: calc(100vh - var(--erp-header-height)); max-height: none; padding: 1rem 1rem 0; }
  .erp-footer { margin-left: -1rem; width: calc(100% + 2rem); padding-left: 1rem; padding-right: 1rem; }
  .erp-footer-root {
    margin-left: -1rem;
    width: calc(100% + 2rem);
  }
  .nav-location-stack { display: none; }
  .brand-text { display: none !important; }
}
@media (max-width: 575.98px) {
  .erp-navbar { padding: 0 .45rem; }
  .navbar-zone-right { gap: .2rem; }
  .nav-chip-net, .js-theme-toggle { display: none !important; }
  .erp-content { padding: .75rem .75rem 0; }
  .erp-footer { margin-left: -.75rem; width: calc(100% + 1.5rem); padding-left: .75rem; padding-right: .75rem; }
  .erp-footer-root {
    margin-left: -.75rem;
    width: calc(100% + 1.5rem);
  }
  /* Table toolbar (search + Excel/Pdf/Print) stacks full-width instead of
     squeezing controls onto one narrow row. */
  .table-toolbar { flex-direction: column; align-items: stretch; }
  .table-toolbar .table-search { max-width: none; width: 100%; margin-right: 0; margin-bottom: .5rem; }
  .table-toolbar .table-actions { width: 100%; display: flex; }
  .table-toolbar .table-actions .btn { flex: 1 1 0; margin-left: 0; margin-right: .35rem; }
  .table-toolbar .table-actions .btn:last-child { margin-right: 0; }
}
