/* ============================================================
   AP Suppliers ERP — Design System CSS
   Primary: #2563EB | Sidebar: 280px | Tables: 48px rows
   ============================================================ */

:root {
  --primary:        #2563EB;
  --primary-hover:  #1D4ED8;
  --primary-light:  #EFF6FF;
  --primary-border: #BFDBFE;
  --primary-muted:  #93C5FD;

  --surface:        #FFFFFF;
  --surface-alt:    #F9FAFB;
  --bg:             #F3F4F6;

  --text:           #111827;
  --text-secondary: #374151;
  --text-muted:     #6B7280;
  --text-light:     #9CA3AF;

  --border:         #E5E7EB;
  --border-dark:    #D1D5DB;

  --success:        #16A34A;
  --success-bg:     #DCFCE7;
  --success-text:   #14532D;

  --warning:        #D97706;
  --warning-bg:     #FEF3C7;
  --warning-text:   #92400E;

  --danger:         #DC2626;
  --danger-bg:      #FEE2E2;
  --danger-text:    #991B1B;

  --info:           #0284C7;
  --info-bg:        #E0F2FE;
  --info-text:      #0C4A6E;

  --shadow-sm:      0 1px 2px rgba(0,0,0,0.05);
  --shadow:         0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:      0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
  --shadow-lg:      0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);

  --radius-sm:      4px;
  --radius:         6px;
  --radius-lg:      8px;
  --radius-xl:      12px;
  --radius-pill:    999px;

  --sidebar-width:  220px;
  --header-height:  56px;
  --transition:     0.15s ease;
}

/* ─── RESET ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 13px; }

/* ─── HEADER ─────────────────────────────────────────────── */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background-color: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  z-index: 1000;
  box-shadow: var(--shadow-md);
}

.header-hamburger {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: background var(--transition);
  flex-shrink: 0;
}
.header-hamburger:hover { background: rgba(255,255,255,0.15); }

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.header-brand-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.header-search {
  flex: 1;
  max-width: 520px;
  margin: 0 auto;
}
.header-search-inner {
  position: relative;
  display: flex;
  align-items: center;
}
.header-search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}
.header-search input {
  width: 100%;
  height: 36px;
  padding: 0 16px 0 36px;
  border: none;
  border-radius: var(--radius-pill);
  background-color: #fff;
  color: var(--text);
  font-size: 13px;
  outline: none;
  box-shadow: none;
  transition: box-shadow var(--transition);
}
.header-search input::placeholder { color: var(--text-muted); }
.header-search input:focus { box-shadow: 0 0 0 3px rgba(255,255,255,0.3); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.header-action-btn {
  position: relative;
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.header-action-btn:hover { background: rgba(255,255,255,0.15); }
.header-action-btn .badge {
  position: absolute;
  top: 4px; right: 4px;
  width: 16px; height: 16px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--primary);
}

.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
  text-decoration: none;
  color: #fff;
}
.header-user:hover { background: rgba(255,255,255,0.15); }
.header-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}
.header-user-info { line-height: 1.2; }
.header-user-name { font-size: 13px; font-weight: 600; }
.header-user-role { font-size: 11px; color: rgba(255,255,255,0.75); }

/* ─── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0;
  top: var(--header-height);
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  background-color: #F9FAFB;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 999;
  transition: transform var(--transition), width var(--transition);
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 2px; }

.sidebar-menu {
  list-style: none;
  padding: 4px 0 12px;
}

/* Parent menu items */
.sidebar-menu-item {
  position: relative;
}

.sidebar-menu-item > a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  height: 36px;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--radius);
  margin: 1px 6px;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-menu-item > a i {
  font-size: 15px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color var(--transition);
}
.sidebar-menu-item > a .menu-chevron {
  margin-left: auto;
  font-size: 11px;
  transition: transform 0.2s ease;
  color: var(--text-light);
}

.sidebar-menu-item > a:hover {
  background-color: #EFF6FF;
  color: var(--primary);
}
.sidebar-menu-item > a:hover i { color: var(--primary); }

/* Active state */
.sidebar-menu-item.active > a {
  background-color: #DBEAFE;
  color: #2563EB;
  font-weight: 600;
}
.sidebar-menu-item.active > a i { color: #2563EB; }

/* Open (expanded) parent */
.sidebar-menu-item.open > a { color: var(--primary); }
.sidebar-menu-item.open > a i { color: var(--primary); }
.sidebar-menu-item.open > a .menu-chevron { transform: rotate(180deg); }

/* Submenu */
.sidebar-submenu {
  list-style: none;
  padding: 1px 0 3px;
  display: none;
}
.sidebar-menu-item.open .sidebar-submenu { display: block; }

/* Back to Dashboard link in settings sidebar */
.sidebar-link-back {
  color: var(--primary) !important;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px !important;
  padding-bottom: 6px !important;
}
.sidebar-link-back i { color: var(--primary) !important; }

.sidebar-submenu-item > a {
  display: flex;
  align-items: center;
  height: 30px;
  padding: 0 10px 0 34px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  border-radius: var(--radius);
  margin: 1px 6px;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.sidebar-submenu-item > a:hover {
  background-color: #EFF6FF;
  color: #2563EB;
}
.sidebar-submenu-item.active > a {
  background-color: #DBEAFE;
  color: #2563EB;
  font-weight: 600;
}

/* Sidebar section label */
.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-light);
  padding: 10px 16px 3px;
}

/* ─── OVERLAY (mobile) ───────────────────────────────────── */
#sidebarOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 998;
}
#sidebarOverlay.visible { display: block; }

/* ─── MAIN CONTENT ───────────────────────────────────────── */
.main-container {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  padding: 24px;
  min-height: calc(100vh - var(--header-height));
  transition: margin-left var(--transition);
  /* The page body must never scroll horizontally (wide tables get their own .table-responsive
     overflow-x:auto). Global [data-tooltip]::after tooltips are always laid out (opacity:0 at rest,
     not display:none) and, on right-edge elements of card layouts with no scroll wrapper (e.g. the
     Payment Methods cards' action icons), pushed the content past the viewport → a 28px page h-scroll.
     Clip the content area's X so those decorations can't create a page scrollbar. `clip` (not hidden)
     leaves overflow-y visible, so it adds no vertical scrollbar and doesn't trap sticky/popovers. */
  overflow-x: clip;
}

/* Sidebar collapsed state (desktop) */
.sidebar.collapsed {
  width: 64px;
}
.sidebar.collapsed .sidebar-menu-item > a span,
.sidebar.collapsed .sidebar-menu-item > a .menu-chevron,
.sidebar.collapsed .sidebar-submenu,
.sidebar.collapsed .sidebar-section-label { display: none; }
.sidebar.collapsed .sidebar-menu-item > a {
  justify-content: center;
  padding: 0;
}
.main-container.sidebar-collapsed { margin-left: 64px; }

/* ─── SIDEBAR SETTINGS FOOTER (gear link) ────────────────── */
.sidebar-settings-footer {
  padding: 8px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.sidebar-settings-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.sidebar-settings-link i {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.sidebar-settings-link:hover {
  background: #EFF6FF;
  color: var(--primary);
}
/* Collapsed: hide label, center the gear inside the 64px rail */
.sidebar.collapsed .sidebar-settings-footer { padding: 8px 0; }
.sidebar.collapsed .sidebar-settings-link span { display: none; }
.sidebar.collapsed .sidebar-settings-link {
  justify-content: center;
  gap: 0;
  padding: 10px 0;
}

/* ─── PAGE HEADER ────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}
.page-header-left { flex: 1; min-width: 0; }
.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.page-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.page-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

/* ─── BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 16px;
  height: 36px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}
.btn i { font-size: 14px; }

.btn-primary {
  background-color: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background-color: var(--primary-hover); border-color: var(--primary-hover); }

.btn-secondary {
  background-color: var(--surface);
  color: var(--text-secondary);
  border-color: var(--border-dark);
}
.btn-secondary:hover { background-color: var(--surface-alt); border-color: var(--border-dark); }

.btn-danger {
  background-color: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background-color: #B91C1C; }

/* Green primary CTA (Confirm & Invoice, Accept quote, Mark Delivered, Collect Payment).
   The POS + app layouts load only bootstrap-icons — NOT Bootstrap's button CSS — and the
   prototype's green .btn-success (from full Bootstrap 5.3) was never ported here, so every
   .btn-success rendered as a greyed default button that read as disabled. This restores the
   intended green success button using the --success token. (QA 2026-09-18) */
.btn-success {
  background-color: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-success:hover { background-color: #15803D; border-color: #15803D; }

/* Disabled buttons read as clearly inactive across every variant (mirrors Bootstrap). */
.btn:disabled, .btn.disabled { opacity: .6; cursor: not-allowed; }

.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background-color: var(--surface-alt); }

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  padding: 0;
  height: auto;
  font-weight: 500;
}
.btn-link:hover { text-decoration: underline; }

.btn-sm { height: 30px; padding: 0 12px; font-size: 12px; }
.btn-lg { height: 42px; padding: 0 20px; font-size: 14px; }
.btn-icon-only {
  width: 32px; height: 32px; padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 15px;
}
.btn-icon-only:hover { background: var(--surface-alt); color: var(--primary); border-color: var(--primary-border); }

/* ─── FILTER / TOOLBAR BAR ───────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar-search {
  position: relative;
  flex: 1;
  max-width: 320px;
}
.toolbar-search i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
}
.toolbar-search input {
  width: 100%;
  height: 34px;
  padding: 0 12px 0 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.toolbar-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.toolbar-spacer { flex: 1; }

/* Legacy filter-bar compat */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.filter-input, .filter-select {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  min-width: 160px;
  outline: none;
}
.filter-input:focus, .filter-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* ─── CARDS ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Card header bar (legacy) */
.card-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

/* ─── KPI CARDS ──────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kpi-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.kpi-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 15px;
}
.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.kpi-change { font-size: 12px; color: var(--text-muted); }
.kpi-change.up { color: var(--success); }
.kpi-change.down { color: var(--danger); }

/* ─── TABLES ─────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead {
  background-color: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}

th {
  padding: 0 16px;
  height: 40px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0 16px;
  height: 48px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr { transition: background var(--transition); }
tbody tr:hover { background-color: #F0F9FF; }
tbody tr:last-child td { border-bottom: none; }

/* The global `th`/`td` rules above (padding: 0 16px; fixed heights) are meant for the app's data
   tables, but bare element selectors also leak into the daterangepicker's calendar cells — inflating
   each day cell so the 7-column month table overflows its calendar column and the two months collide
   ("Custom Range" layout break). Neutralise the leak for calendar cells only; the vendor CSS sizes
   them itself. Scoped to .daterangepicker so real data tables are untouched. */
.daterangepicker th,
.daterangepicker td { padding: 0; height: auto; }

/* Alternating rows */
tbody tr:nth-child(even) { background-color: var(--surface-alt); }
tbody tr:nth-child(even):hover { background-color: #F0F9FF; }

.table-link {
  color: var(--primary);
  font-weight: 500;
  text-decoration: none;
}
.table-link:hover { text-decoration: underline; }

/* Contact stacked cell */
.contact-cell { line-height: 1.4; }
.contact-name { font-weight: 600; color: var(--text); font-size: 13px; }
.contact-phone { font-size: 12px; color: var(--text-muted); }
.contact-email { font-size: 12px; color: var(--text-muted); }

/* ─── STATUS BADGES ──────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-active   { background: var(--success-bg); color: var(--success-text); }
.badge-active::before   { background: var(--success); }
.badge-inactive { background: var(--danger-bg);  color: var(--danger-text); }
.badge-inactive::before { background: var(--danger); }
.badge-pending  { background: var(--warning-bg); color: var(--warning-text); }
.badge-pending::before  { background: var(--warning); }
.badge-draft    { background: #F3F4F6; color: var(--text-muted); }
.badge-draft::before    { background: var(--text-light); }
.badge-confirmed { background: var(--success-bg); color: var(--success-text); }
.badge-confirmed::before { background: var(--success); }
.badge-paid     { background: var(--success-bg); color: var(--success-text); }
.badge-paid::before     { background: var(--success); }
.badge-partial  { background: var(--warning-bg); color: var(--warning-text); }
.badge-partial::before  { background: var(--warning); }
.badge-overdue  { background: var(--danger-bg);  color: var(--danger-text); }
.badge-overdue::before  { background: var(--danger); }
.badge-cancelled { background: #F3F4F6; color: var(--text-muted); }
.badge-cancelled::before { background: var(--text-light); }

/* Legacy chip compat */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 600; }
.chip-active   { background: var(--success-bg); color: var(--success-text); }
.chip-inactive { background: var(--danger-bg);  color: var(--danger-text); }
.chip-pending  { background: var(--warning-bg); color: var(--warning-text); }
.chip-partial  { background: var(--warning-bg); color: var(--warning-text); }
.chip-draft    { background: #F3F4F6; color: var(--text-muted); }
.chip-confirmed, .chip-paid, .chip-processed { background: var(--success-bg); color: var(--success-text); }
/* Delivered — the post-confirmed Proof-of-Delivery milestone; blue reads as "completed / final",
   deliberately distinct from the green "confirmed" so the new state is unmistakable. */
.chip-delivered { background: var(--info-bg); color: var(--info-text); }
.chip-overdue, .chip-rejected { background: var(--danger-bg); color: var(--danger-text); }

/* Credit available color coding */
.credit-good   { color: var(--success); font-weight: 600; }
.credit-low    { color: var(--warning); font-weight: 600; }
.credit-none   { color: var(--danger);  font-weight: 600; }

/* Row dot indicator */
.row-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}
.row-dot.active   { background: var(--success); }
.row-dot.inactive { background: var(--danger); }

/* ─── FORMS ──────────────────────────────────────────────── */
.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  overflow: hidden;
}
.form-section-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  gap: 10px;
}
.form-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.form-section-body { padding: 20px; }

.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.form-label .required { color: var(--danger); margin-left: 2px; }

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-textarea {
  height: auto;
  min-height: 80px;
  padding: 10px 12px;
  resize: vertical;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-light); }
.form-input[readonly] { background: var(--surface-alt); color: var(--text-muted); cursor: default; }

.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.form-input.error, .form-select.error { border-color: var(--danger); }

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.form-row.grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-row.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Checkbox / radio */
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 16px; height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}
.form-check-label { font-size: 13px; color: var(--text); }

/* Form footer (save/cancel) */
.form-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-top: 8px;
}
.form-footer .btn-danger { margin-left: auto; }

/* ─── STEP SECTIONS ──────────────────────────────────────── */
.step-section { margin-bottom: 20px; }
.step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}
.step-number {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.step-title { font-size: 15px; font-weight: 600; color: var(--text); }

/* ─── TABS ───────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
}
.tab-item {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
  user-select: none;
}
.tab-item:hover { color: var(--text); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ─── MODALS ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}
.modal-overlay.active { display: flex; }

/* Legacy .modal compat */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}
.modal.active { display: flex; }

/* SweetAlert2 confirm/alert must sit ABOVE our own overlays. Its default container z-index (1060) is
   below .modal-overlay/.modal (2000), so a swalConfirm fired from inside an open modal — e.g. the
   Document Numbering "Reset to 001" button, which lives in the edit modal — rendered BEHIND the modal
   (user can't see/reach it). Raise it above every app layer: modals (2000), dropdowns/panels (3000/4000)
   and toasts (9999). Global so this can never recur on any modal+swal combination across the app.
   !important guards against the CDN stylesheet's same-specificity rule winning on load order. */
.swal2-container { z-index: 10050 !important; }

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 24px;
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
}
.modal-content.modal-lg { max-width: 720px; }
.modal-content.modal-sm { max-width: 380px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 600; color: var(--text); }
.modal-close {
  background: none; border: none;
  font-size: 20px; color: var(--text-muted);
  cursor: pointer; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  transition: background var(--transition);
}
.modal-close:hover { background: var(--surface-alt); color: var(--text); }
.modal-body { margin-bottom: 20px; }
.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ─── INFO / ALERT BARS ──────────────────────────────────── */
.info-bar {
  background: var(--info-bg);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  color: var(--info-text);
}
.info-bar-item { display: flex; flex-direction: column; gap: 2px; }
.info-bar-label { font-size: 11px; color: var(--info); font-weight: 500; text-transform: uppercase; letter-spacing: 0.4px; }
.info-bar-value { font-weight: 600; color: var(--text); font-size: 14px; }

/* ─── CHART CONTAINERS ───────────────────────────────────── */
.chart-container { position: relative; height: 280px; margin-bottom: 16px; }
.chart-sm        { height: 200px; }

/* ─── GRID LAYOUTS ───────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* Dashboard 2-col layout */
.dash-row {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 16px;
  margin-bottom: 16px;
}
.dash-row-equal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ─── EMPTY STATE ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty-state-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state-text { font-size: 13px; }

/* ─── LINE ITEMS TABLE ───────────────────────────────────── */
.line-items-table td { vertical-align: middle; padding: 8px 12px; height: 44px; }
.line-items-table .form-input,
.line-items-table .form-select { height: 34px; }

/* ─── TOAST NOTIFICATIONS ────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  min-width: 280px;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: slideUp 0.25s ease;
}
.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-msg { flex: 1; font-size: 13px; color: var(--text); }
.toast-close {
  background: none; border: none;
  font-size: 16px; color: var(--text-muted);
  cursor: pointer; padding: 0; line-height: 1;
}

/* ─── VIEW PAGE (Detail) ─────────────────────────────────── */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.view-title-block { display: flex; align-items: center; gap: 12px; }
.view-title { font-size: 22px; font-weight: 700; color: var(--text); }
.view-actions { display: flex; gap: 8px; align-items: center; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 24px;
}
.detail-item { display: flex; flex-direction: column; gap: 2px; }
.detail-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.detail-value { font-size: 13px; color: var(--text); }

/* ─── UTILITIES ──────────────────────────────────────────── */
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.text-muted   { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-600       { font-weight: 600; }
.fw-700       { font-weight: 700; }
.fs-12        { font-size: 12px; }
.fs-13        { font-size: 13px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.ml-auto { margin-left: auto; }
/* ─── DROPDOWN MENU ──────────────────────────────────────── */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.06);
  z-index: 1200;
  min-width: 190px;
  padding: 4px 0;
  animation: dropIn 0.12s ease;
}
@keyframes dropIn {
  from { opacity:0; transform:translateY(-4px); }
  to   { opacity:1; transform:translateY(0); }
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition);
  white-space: nowrap;
}
.dropdown-item:hover {
  background: var(--surface-alt);
  color: var(--primary);
}
.dropdown-item i {
  font-size: 14px;
  flex-shrink: 0;
  width: 16px;
  text-align: center;
  color: var(--text-muted);
}
.dropdown-item:hover i { color: var(--primary); }
.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.hidden { display: none !important; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

/* ─── RESPONSIVE TABLE SCROLL ────────────────────────────── */
/* Both .table-scroll and Bootstrap-style .table-responsive work */
.table-responsive,
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
}
.table-scroll::-webkit-scrollbar {
  height: 5px;
}
.table-scroll::-webkit-scrollbar-track {
  background: var(--surface-alt);
  border-radius: 3px;
}
.table-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.table-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
.table-responsive table,
.table-scroll table {
  min-width: 800px;
}

/* ─── LOGIN PAGE ─────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  background: var(--surface);
}
.login-brand-panel {
  width: 420px;
  background: linear-gradient(160deg, var(--primary) 0%, #1E40AF 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: #fff;
  flex-shrink: 0;
}
.login-form-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: var(--surface-alt);
}
.login-form-box {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px;
  box-shadow: var(--shadow-md);
}

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-row { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .main-container { margin-left: 0; }
}

@media (max-width: 768px) {
  :root { --header-height: 52px; }
  .main-container { padding: 16px; }
  .form-row,
  .form-row.grid-3,
  .form-row.grid-4,
  .grid-2,
  .grid-3,
  .grid-4 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .filter-bar { flex-direction: column; }
  .filter-input, .filter-select { min-width: 100%; }
  .login-brand-panel { display: none; }
}

/* ─── GLOBAL TOOLTIP SYSTEM ──────────────────────────────── */
[data-tooltip] {
  position: relative;
  cursor: help;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1F2937;
  color: #F9FAFB;
  font-size: 12px;
  line-height: 1.4;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: pre-wrap;
  max-width: 240px;
  width: max-content;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s, transform .15s;
  transform: translateX(-50%) translateY(4px);
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
[data-tooltip]::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: #1F2937;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 9999;
}
[data-tooltip]:hover::after,
[data-tooltip]:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Right-edge tooltip spill guard (see feedback_tooltip_overflow_x_auto_scrollbar).
   The centered [data-tooltip]::after is LAID OUT even at rest (opacity:0, not display:none). On the
   last column of a scrollable table — the right-aligned ACTION icons on every list page — that centered
   pseudo extends past the table's right edge and, because .table-responsive is overflow-x:auto, adds a
   phantom horizontal scrollbar even when the real columns fit. Anchor last-column tooltips to the
   element's own right edge so they open LEFTWARD (into the table) and never create scroll. Applies to
   every list table's action column at once — the fix belongs in the shared layer, not per page. */
.table-responsive td:last-child [data-tooltip]::after,
.table-scroll td:last-child [data-tooltip]::after {
  left: auto; right: 0; transform: translateY(4px);
}
.table-responsive td:last-child [data-tooltip]:hover::after,
.table-scroll td:last-child [data-tooltip]:hover::after {
  transform: translateY(0);
}
.table-responsive td:last-child [data-tooltip]::before,
.table-scroll td:last-child [data-tooltip]::before {
  left: auto; right: 12px; transform: none;
}

/* Tooltip info icon helper */
.tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background: #E5E7EB;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  color: #6B7280;
  cursor: help;
  margin-left: 4px;
  vertical-align: middle;
  font-style: normal;
  line-height: 1;
  flex-shrink: 0;
  transition: background .15s;
  user-select: none;
}
.tip:hover { background: #D1D5DB; color: #374151; }

/* ─── INSTRUCTION / HELP BANNERS ────────────────────────── */
.help-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.6;
}
.help-banner i { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.help-banner.info    { background: #EFF6FF; border: 1px solid #BFDBFE; color: #1E3A8A; }
.help-banner.info i  { color: #2563EB; }
.help-banner.success { background: #F0FDF4; border: 1px solid #BBF7D0; color: #14532D; }
.help-banner.success i { color: #16A34A; }
.help-banner.warning { background: #FFFBEB; border: 1px solid #FDE68A; color: #78350F; }
.help-banner.warning i { color: #D97706; }
.help-banner.tip-banner { background: #F5F3FF; border: 1px solid #DDD6FE; color: #3B0764; }
.help-banner.tip-banner i { color: #7C3AED; }
.help-banner strong { font-weight: 600; }
/* Dismiss button for banners */
.help-banner-dismiss {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  opacity: .6;
  font-size: 16px;
  padding: 0;
  flex-shrink: 0;
  line-height: 1;
}
.help-banner-dismiss:hover { opacity: 1; }

/* ─── FIELD INSTRUCTION TEXT ─────────────────────────────── */
.field-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.4;
}
.field-hint.warning { color: var(--warning); }
.field-hint.danger  { color: var(--danger); }
.field-hint.success { color: var(--success); }

/* ─── INLINE REQUIRED / OPTIONAL LABELS ─────────────────── */
.req { color: var(--danger); margin-left: 2px; }
.opt { color: var(--text-muted); font-size: 11px; margin-left: 4px; font-weight: 400; }

/* ─── PAGE SUBTITLE ──────────────────────────────────────── */
.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 2px 0 0;
  font-weight: 400;
}

/* ─── STEP INDICATOR ────────────────────────────────────── */
.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  margin-right: 8px;
}
.step-badge.done { background: var(--success); }

/* ============================================================
   BOOTSTRAP-STYLE UTILITY CLASSES
   Use these in HTML instead of inline style="..." attributes.
   Naming convention matches Bootstrap 5 utilities.
   ============================================================ */

/* ─── Display ───────────────────────────────────────────── */
.d-none          { display: none !important; }
.d-inline        { display: inline !important; }
.d-inline-block  { display: inline-block !important; }
.d-block         { display: block !important; }
.d-grid          { display: grid !important; }
.d-flex          { display: flex !important; }
.d-inline-flex   { display: inline-flex !important; }

/* ─── Flex direction / wrap ─────────────────────────────── */
.flex-row        { flex-direction: row !important; }
.flex-column     { flex-direction: column !important; }
.flex-wrap       { flex-wrap: wrap !important; }
.flex-nowrap     { flex-wrap: nowrap !important; }
.flex-grow-0     { flex-grow: 0 !important; }
.flex-grow-1     { flex-grow: 1 !important; }
.flex-shrink-0   { flex-shrink: 0 !important; }
.flex-shrink-1   { flex-shrink: 1 !important; }
.flex-fill       { flex: 1 1 auto !important; }

/* ─── Justify content ───────────────────────────────────── */
.justify-content-start   { justify-content: flex-start !important; }
.justify-content-end     { justify-content: flex-end !important; }
.justify-content-center  { justify-content: center !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-around  { justify-content: space-around !important; }
.justify-content-evenly  { justify-content: space-evenly !important; }

/* ─── Align items ───────────────────────────────────────── */
.align-items-start    { align-items: flex-start !important; }
.align-items-end      { align-items: flex-end !important; }
.align-items-center   { align-items: center !important; }
.align-items-baseline { align-items: baseline !important; }
.align-items-stretch  { align-items: stretch !important; }

/* ─── Align self ────────────────────────────────────────── */
.align-self-start   { align-self: flex-start !important; }
.align-self-end     { align-self: flex-end !important; }
.align-self-center  { align-self: center !important; }
.align-self-stretch { align-self: stretch !important; }

/* ─── Gap (for flex/grid) ───────────────────────────────── */
.gap-0 { gap: 0 !important; }
.gap-1 { gap: 0.25rem !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }
.gap-4 { gap: 1.5rem !important; }
.gap-5 { gap: 3rem !important; }

/* ─── Margin ────────────────────────────────────────────── */
.m-0 { margin: 0 !important; }
.m-1 { margin: 0.25rem !important; }
.m-2 { margin: 0.5rem !important; }
.m-3 { margin: 1rem !important; }
.m-4 { margin: 1.5rem !important; }
.m-5 { margin: 3rem !important; }
.m-auto { margin: auto !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mt-5 { margin-top: 3rem !important; }
.mt-auto { margin-top: auto !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-5 { margin-bottom: 3rem !important; }
.mb-auto { margin-bottom: auto !important; }

.ms-0 { margin-left: 0 !important; }
.ms-1 { margin-left: 0.25rem !important; }
.ms-2 { margin-left: 0.5rem !important; }
.ms-3 { margin-left: 1rem !important; }
.ms-4 { margin-left: 1.5rem !important; }
.ms-5 { margin-left: 3rem !important; }
.ms-auto { margin-left: auto !important; }

.me-0 { margin-right: 0 !important; }
.me-1 { margin-right: 0.25rem !important; }
.me-2 { margin-right: 0.5rem !important; }
.me-3 { margin-right: 1rem !important; }
.me-4 { margin-right: 1.5rem !important; }
.me-5 { margin-right: 3rem !important; }
.me-auto { margin-right: auto !important; }

.mx-0 { margin-left: 0 !important; margin-right: 0 !important; }
.mx-1 { margin-left: 0.25rem !important; margin-right: 0.25rem !important; }
.mx-2 { margin-left: 0.5rem !important; margin-right: 0.5rem !important; }
.mx-3 { margin-left: 1rem !important; margin-right: 1rem !important; }
.mx-4 { margin-left: 1.5rem !important; margin-right: 1.5rem !important; }
.mx-5 { margin-left: 3rem !important; margin-right: 3rem !important; }
.mx-auto { margin-left: auto !important; margin-right: auto !important; }

.my-0 { margin-top: 0 !important; margin-bottom: 0 !important; }
.my-1 { margin-top: 0.25rem !important; margin-bottom: 0.25rem !important; }
.my-2 { margin-top: 0.5rem !important; margin-bottom: 0.5rem !important; }
.my-3 { margin-top: 1rem !important; margin-bottom: 1rem !important; }
.my-4 { margin-top: 1.5rem !important; margin-bottom: 1.5rem !important; }
.my-5 { margin-top: 3rem !important; margin-bottom: 3rem !important; }

/* ─── Padding ───────────────────────────────────────────── */
.p-0 { padding: 0 !important; }
.p-1 { padding: 0.25rem !important; }
.p-2 { padding: 0.5rem !important; }
.p-3 { padding: 1rem !important; }
.p-4 { padding: 1.5rem !important; }
.p-5 { padding: 3rem !important; }

.pt-0 { padding-top: 0 !important; }
.pt-1 { padding-top: 0.25rem !important; }
.pt-2 { padding-top: 0.5rem !important; }
.pt-3 { padding-top: 1rem !important; }
.pt-4 { padding-top: 1.5rem !important; }
.pt-5 { padding-top: 3rem !important; }

.pb-0 { padding-bottom: 0 !important; }
.pb-1 { padding-bottom: 0.25rem !important; }
.pb-2 { padding-bottom: 0.5rem !important; }
.pb-3 { padding-bottom: 1rem !important; }
.pb-4 { padding-bottom: 1.5rem !important; }
.pb-5 { padding-bottom: 3rem !important; }

.ps-0 { padding-left: 0 !important; }
.ps-1 { padding-left: 0.25rem !important; }
.ps-2 { padding-left: 0.5rem !important; }
.ps-3 { padding-left: 1rem !important; }
.ps-4 { padding-left: 1.5rem !important; }
.ps-5 { padding-left: 3rem !important; }

.pe-0 { padding-right: 0 !important; }
.pe-1 { padding-right: 0.25rem !important; }
.pe-2 { padding-right: 0.5rem !important; }
.pe-3 { padding-right: 1rem !important; }
.pe-4 { padding-right: 1.5rem !important; }
.pe-5 { padding-right: 3rem !important; }

.px-0 { padding-left: 0 !important; padding-right: 0 !important; }
.px-1 { padding-left: 0.25rem !important; padding-right: 0.25rem !important; }
.px-2 { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
.px-3 { padding-left: 1rem !important; padding-right: 1rem !important; }
.px-4 { padding-left: 1.5rem !important; padding-right: 1.5rem !important; }
.px-5 { padding-left: 3rem !important; padding-right: 3rem !important; }

.py-0 { padding-top: 0 !important; padding-bottom: 0 !important; }
.py-1 { padding-top: 0.25rem !important; padding-bottom: 0.25rem !important; }
.py-2 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
.py-3 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
.py-4 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }
.py-5 { padding-top: 3rem !important; padding-bottom: 3rem !important; }

/* ─── Text alignment / weight / color ───────────────────── */
.text-start   { text-align: left !important; }
.text-center  { text-align: center !important; }
.text-end     { text-align: right !important; }
.text-nowrap  { white-space: nowrap !important; }
.text-wrap    { white-space: normal !important; }
.text-truncate { overflow: hidden !important; text-overflow: ellipsis !important; white-space: nowrap !important; }
.text-uppercase { text-transform: uppercase !important; }
.text-lowercase { text-transform: lowercase !important; }
.text-capitalize{ text-transform: capitalize !important; }
.text-decoration-none { text-decoration: none !important; }
.text-decoration-underline { text-decoration: underline !important; }

.text-muted     { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-primary   { color: var(--primary) !important; }
.text-success   { color: var(--success) !important; }
.text-warning   { color: var(--warning) !important; }
.text-danger    { color: var(--danger) !important; }
.text-info      { color: var(--info) !important; }
.text-white     { color: #fff !important; }
.text-dark      { color: var(--text) !important; }

.fw-normal      { font-weight: 400 !important; }
.fw-medium      { font-weight: 500 !important; }
.fw-semibold    { font-weight: 600 !important; }
.fw-bold        { font-weight: 700 !important; }

.fs-xs          { font-size: 11px !important; }
.fs-sm          { font-size: 12px !important; }
.fs-md          { font-size: 13px !important; }
.fs-lg          { font-size: 15px !important; }
.fs-xl          { font-size: 17px !important; }
.fs-xxl         { font-size: 20px !important; }

.lh-1           { line-height: 1 !important; }
.lh-sm          { line-height: 1.25 !important; }
.lh-base        { line-height: 1.5 !important; }
.lh-lg          { line-height: 1.75 !important; }

/* ─── Background colors ─────────────────────────────────── */
.bg-white     { background-color: #fff !important; }
.bg-light     { background-color: var(--surface-alt) !important; }
.bg-body      { background-color: var(--bg) !important; }
.bg-primary   { background-color: var(--primary) !important; color: #fff !important; }
.bg-primary-light { background-color: var(--primary-light) !important; }
.bg-success   { background-color: var(--success) !important; color: #fff !important; }
.bg-success-light { background-color: var(--success-bg) !important; }
.bg-warning   { background-color: var(--warning) !important; color: #fff !important; }
.bg-warning-light { background-color: var(--warning-bg) !important; }
.bg-danger    { background-color: var(--danger) !important; color: #fff !important; }
.bg-danger-light { background-color: var(--danger-bg) !important; }
.bg-info      { background-color: var(--info) !important; color: #fff !important; }
.bg-info-light { background-color: var(--info-bg) !important; }
.bg-transparent { background-color: transparent !important; }

/* ─── Borders ───────────────────────────────────────────── */
.border         { border: 1px solid var(--border) !important; }
.border-0       { border: 0 !important; }
.border-top     { border-top: 1px solid var(--border) !important; }
.border-end     { border-right: 1px solid var(--border) !important; }
.border-bottom  { border-bottom: 1px solid var(--border) !important; }
.border-start   { border-left: 1px solid var(--border) !important; }
.border-primary { border-color: var(--primary) !important; }
.border-success { border-color: var(--success) !important; }
.border-warning { border-color: var(--warning) !important; }
.border-danger  { border-color: var(--danger) !important; }

.rounded        { border-radius: var(--radius) !important; }
.rounded-sm     { border-radius: var(--radius-sm) !important; }
.rounded-lg     { border-radius: var(--radius-lg) !important; }
.rounded-xl     { border-radius: var(--radius-xl) !important; }
.rounded-pill   { border-radius: var(--radius-pill) !important; }
.rounded-circle { border-radius: 50% !important; }
.rounded-0      { border-radius: 0 !important; }

/* ─── Sizing ────────────────────────────────────────────── */
.w-25   { width: 25% !important; }
.w-50   { width: 50% !important; }
.w-75   { width: 75% !important; }
.w-100  { width: 100% !important; }
.w-auto { width: auto !important; }
.h-25   { height: 25% !important; }
.h-50   { height: 50% !important; }
.h-75   { height: 75% !important; }
.h-100  { height: 100% !important; }
.h-auto { height: auto !important; }
.mw-100 { max-width: 100% !important; }
.mh-100 { max-height: 100% !important; }
.min-w-0 { min-width: 0 !important; }

/* ─── Position ──────────────────────────────────────────── */
.position-static   { position: static !important; }
.position-relative { position: relative !important; }
.position-absolute { position: absolute !important; }
.position-fixed    { position: fixed !important; }
.position-sticky   { position: sticky !important; }

.top-0    { top: 0 !important; }
.bottom-0 { bottom: 0 !important; }
.start-0  { left: 0 !important; }
.end-0    { right: 0 !important; }

/* ─── Overflow ──────────────────────────────────────────── */
.overflow-auto    { overflow: auto !important; }
.overflow-hidden  { overflow: hidden !important; }
.overflow-visible { overflow: visible !important; }
.overflow-scroll  { overflow: scroll !important; }
.overflow-x-auto  { overflow-x: auto !important; }
.overflow-y-auto  { overflow-y: auto !important; }

/* ─── Shadow ────────────────────────────────────────────── */
.shadow-none { box-shadow: none !important; }
.shadow-sm   { box-shadow: var(--shadow-sm) !important; }
.shadow      { box-shadow: var(--shadow) !important; }
.shadow-md   { box-shadow: var(--shadow-md) !important; }
.shadow-lg   { box-shadow: var(--shadow-lg) !important; }

/* ─── Cursor / interaction ──────────────────────────────── */
.cursor-pointer { cursor: pointer !important; }
.cursor-default { cursor: default !important; }
.cursor-not-allowed { cursor: not-allowed !important; }
.user-select-none { user-select: none !important; }

/* ─── Grid helpers ──────────────────────────────────────── */
.grid-cols-1 { display: grid !important; grid-template-columns: 1fr !important; }
.grid-cols-2 { display: grid !important; grid-template-columns: repeat(2, 1fr) !important; }
.grid-cols-3 { display: grid !important; grid-template-columns: repeat(3, 1fr) !important; }
.grid-cols-4 { display: grid !important; grid-template-columns: repeat(4, 1fr) !important; }
.grid-cols-5 { display: grid !important; grid-template-columns: repeat(5, 1fr) !important; }
.grid-cols-6 { display: grid !important; grid-template-columns: repeat(6, 1fr) !important; }

/* ─── Responsive overrides ──────────────────────────────── */
@media (max-width: 1024px) {
  .grid-cols-md-1 { grid-template-columns: 1fr !important; }
  .grid-cols-md-2 { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 768px) {
  .grid-cols-sm-1 { grid-template-columns: 1fr !important; }
  .d-sm-none      { display: none !important; }
  .d-sm-block     { display: block !important; }
  .d-sm-flex      { display: flex !important; }
  .flex-sm-column { flex-direction: column !important; }
}

/* ============================================================
   COMMON COMPONENT PATTERNS (extracted from inline <style> blocks)
   ============================================================ */

/* ─── Help banner (info / warning / tip variants) ──────── */
.help-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--info-bg);
  background: var(--info-bg);
  color: var(--info-text);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 20px;
}
.help-banner > i:first-child { font-size: 17px; flex-shrink: 0; margin-top: 1px; }
.help-banner.info    { background: #EFF6FF; border-color: #BFDBFE; color: #1E3A8A; }
.help-banner.info > i:first-child { color: #2B5CE6; }
.help-banner.warning { background: var(--warning-bg); border-color: #FDE68A; color: var(--warning-text); }
.help-banner.warning > i:first-child { color: var(--warning); }
.help-banner.tip     { background: #F0FDF4; border-color: #BBF7D0; color: #14532D; }
.help-banner.tip > i:first-child { color: var(--success); }
.help-banner-dismiss {
  margin-left: auto;
  background: none;
  border: none;
  color: inherit;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.6;
  flex-shrink: 0;
}
.help-banner-dismiss:hover { opacity: 1; }

/* ─── Toggle switch (small) ─────────────────────────────── */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #CBD5E1; border-radius: 20px; transition: 0.2s;
}
.switch .slider::before {
  position: absolute; content: ""; height: 14px; width: 14px;
  left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: 0.2s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(16px); }

/* ─── Section card (titled card block used in settings) ── */
.section-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  overflow: hidden;
}
.section-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.section-card-head i { color: var(--primary); font-size: 15px; }
.section-card-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}
.section-card-body { padding: 20px; }

/* ─── Form grid (3-col responsive) ──────────────────────── */
.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (max-width: 768px) {
  .form-grid-3, .form-grid-2 { grid-template-columns: 1fr; }
}

/* ============================================================
   APP HEADER (extracted from inline styles in header.php)
   ============================================================ */
.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  min-width: 196px;
  padding-right: 16px;
  border-right: 1px solid rgba(255,255,255,0.12);
}
.app-brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(255,255,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.22);
}
.app-brand-logo i { font-size: 15px; color: #fff; }
.app-brand-logo--img { background: #fff; border-color: rgba(255,255,255,0.35); overflow: hidden; }
.app-brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  padding: 0;
  transform: scale(1.75);
}
.app-brand-link { text-decoration: none; color: #fff; }
.app-brand-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.2px;
  line-height: 1.15;
}
.app-brand-sub {
  font-size: 10px;
  opacity: 0.6;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  font-weight: 500;
}

.app-hamburger {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  border-radius: 4px;
  margin: 0 4px;
  opacity: 0.85;
}
.app-hamburger:hover { opacity: 1; background: rgba(255,255,255,0.1); }
.app-hamburger i { font-size: 20px; }

.app-search {
  flex: 1;
  max-width: 420px;
  position: relative;
}
.app-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #9CA3AF;
  font-size: 13px;
  pointer-events: none;
}
.app-search-input {
  width: 100%;
  padding: 8px 14px 8px 34px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  background: #fff;
  color: #111827;
  font-size: 13px;
  outline: none;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.app-search-input:focus {
  box-shadow: 0 0 0 3px rgba(255,255,255,0.35);
  border-color: rgba(255,255,255,0.6);
}

/* Global search results dropdown (Dashboard build 11, Phase 4) */
.app-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border, #E5E7EB);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  max-height: 420px;
  overflow-y: auto;
  z-index: 1200;
  padding: 6px 0;
}
.app-search-results[hidden] { display: none; }
.app-search-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted, #9CA3AF);
  padding: 8px 14px 4px;
}
.app-search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  color: var(--text, #111827);
  text-decoration: none;
  font-size: 13px;
}
.app-search-item:hover,
.app-search-item.active { background: var(--surface-alt, #F3F4F6); }
.app-search-item i { color: var(--text-muted, #9CA3AF); font-size: 14px; flex-shrink: 0; }
.app-search-item .label { font-weight: 500; }
.app-search-item .sub { margin-left: auto; font-size: 11px; color: var(--text-muted, #9CA3AF); font-family: monospace; }
.app-search-empty {
  padding: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted, #9CA3AF);
}

.app-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
}

.app-icon-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 7px 8px;
  border-radius: 6px;
  text-decoration: none;
  opacity: 0.85;
  transition: opacity 0.2s, background 0.2s;
  position: relative;
  display: inline-flex;
  align-items: center;
}
.app-icon-btn:hover { opacity: 1; background: rgba(255,255,255,0.1); }
.app-icon-btn i { font-size: 17px; }

.app-notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  background: #EF4444;
  border-radius: 20px;
  border: 1.5px solid #2B5CE6;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

.app-header-divider {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.15);
  margin: 0 8px;
}

.app-user-menu {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 6px;
  transition: background 0.2s;
}
.app-user-menu:hover { background: rgba(255,255,255,0.1); }
.app-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,0.3);
}
.app-user-text { line-height: 1.25; }
.app-user-name { font-size: 13px; font-weight: 600; }
.app-user-role { font-size: 10.5px; opacity: 0.65; }
.app-user-caret { font-size: 10px; opacity: 0.6; }

.app-signout {
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 7px 8px;
  border-radius: 6px;
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 0.2s, background 0.2s;
}
.app-signout:hover { opacity: 1; background: rgba(255,255,255,0.1); }
.app-signout i { font-size: 16px; }

/* ============================================================
   TOOLTIPS / FIELD HELPERS / DROPDOWNS / TOAST / NOTIF PANEL
   (moved from inline <style> block in header.php)
   ============================================================ */

/* ── Tooltips ─────────────────────────────────────── */
[data-tip]         { position: relative; }
[data-tip]::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  border: 6px solid transparent;
  border-top-color: #111827;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 1010;
}
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: #111827;
  color: #F9FAFB;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: 0.01em;
  padding: 8px 12px;
  border-radius: 8px;
  white-space: normal;
  width: max-content;
  max-width: 260px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.22), 0 2px 6px rgba(0,0,0,0.12);
  z-index: 1010;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
[data-tip]:hover::before,
[data-tip]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }
[data-tip][data-tip-dir="right"]::after  { left: calc(100% + 12px); bottom: auto; top: 50%; transform: translateY(-50%) translateX(6px); width: max-content; max-width: 260px; }
[data-tip][data-tip-dir="right"]::before { left: calc(100% + 6px); bottom: auto; top: 50%; transform: translateY(-50%) rotate(90deg) translateX(4px); border-top-color: #111827; }
[data-tip][data-tip-dir="right"]:hover::after  { transform: translateY(-50%) translateX(0); }
[data-tip][data-tip-dir="right"]:hover::before { transform: translateY(-50%) rotate(90deg) translateX(0); }

/* ── Required field star ────────────────────────── */
.req-star { color: #DC2626; margin-left: 2px; }
.form-label .req-star { font-size: 12px; }

.field-hint {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.45;
}
.field-hint i { font-size: 12px; flex-shrink: 0; margin-top: 1px; }

input[required]:invalid:not(:focus),
select[required]:invalid:not(:focus),
textarea[required]:invalid:not(:focus) { border-left: 3px solid #FECACA; }

/* ── Help icon button ───────────────────────────── */
.help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary-light);
  border: 1px solid rgba(43,92,230,0.25);
  cursor: default;
  font-size: 10px;
  font-weight: 700;
  font-style: normal;
  color: var(--primary);
  margin-left: 5px;
  vertical-align: middle;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  flex-shrink: 0;
  line-height: 1;
  user-select: none;
}
.help-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Dropdown menus ─────────────────────────────── */
.erp-dropdown { position: relative; display: inline-block; }
.erp-dropdown-menu,
.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.13), 0 2px 6px rgba(0,0,0,0.07);
  z-index: 3000;
  min-width: 195px;
  padding: 4px 0;
}
.erp-dropdown-menu.open,
.dropdown-menu.open { display: block; }
.erp-dropdown-item,
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 15px;
  font-size: 13px;
  color: #111827;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s;
}
.erp-dropdown-item:hover,
.dropdown-item:hover { background: #F1F5F9; color: #2B5CE6; }
.erp-dropdown-item i,
.dropdown-item i {
  font-size: 14px;
  width: 16px;
  text-align: center;
  color: #9CA3AF;
  flex-shrink: 0;
}
.erp-dropdown-item:hover i,
.dropdown-item:hover i { color: #2B5CE6; }
.erp-dropdown-sep,
.dropdown-divider { height: 1px; background: #E2E8F0; margin: 4px 0; }

/* ── Topbar user dropdown (Change Password / Sign Out) ── */
.app-user-dropdown { min-width: 210px; }
.app-user-logout-form { margin: 0; }
.app-user-logout-form .erp-dropdown-item {
  width: 100%;
  border: none;
  background: none;
  font-family: inherit;
  text-align: left;
}
.app-user-caret { transition: transform 0.18s; }
#userWrap:has(.erp-dropdown-menu.open) .app-user-caret { transform: rotate(180deg); }

/* ── Toast notification ─────────────────────────── */
#erpToastWrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.erp-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  font-size: 13px;
  color: var(--text);
  animation: toastIn 0.2s ease;
  max-width: 320px;
  pointer-events: auto;
}
.erp-toast.success { border-left: 4px solid #16A34A; }
.erp-toast.error   { border-left: 4px solid #DC2626; }
.erp-toast.info    { border-left: 4px solid #2B5CE6; }
.erp-toast.warn    { border-left: 4px solid #D97706; }
.erp-toast .toast-icon { font-size: 16px; flex-shrink: 0; }
.erp-toast.success .toast-icon { color: #16A34A; }
.erp-toast.error   .toast-icon { color: #DC2626; }
.erp-toast.info    .toast-icon { color: #2B5CE6; }
.erp-toast.warn    .toast-icon { color: #D97706; }
.erp-toast .toast-msg  { flex: 1; }
.erp-toast .toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  padding: 0;
  flex-shrink: 0;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Notification panel ─────────────────────────── */
.notif-panel {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: -60px;
  width: 380px;
  max-height: 520px;
  background: #fff;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
  z-index: 4000;
  overflow: hidden;
  flex-direction: column;
}
.notif-panel.open { display: flex; }
.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #E2E8F0;
}
.notif-head-title { font-size: 15px; font-weight: 700; color: #111827; }
.notif-mark-btn {
  background: none;
  border: none;
  font-size: 12px;
  color: #2B5CE6;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}
.notif-mark-btn:hover { background: #EEF2FF; }
.notif-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 12px 0;
  border-bottom: 1px solid #E2E8F0;
}
.notif-tab {
  background: none;
  border: none;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #6B7280;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  border-radius: 6px 6px 0 0;
}
.notif-tab:hover { color: #111827; background: #F9FAFB; }
.notif-tab.active { color: #2B5CE6; border-bottom-color: #2B5CE6; }
.notif-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  background: #EF4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 20px;
  padding: 0 5px;
  margin-left: 4px;
}
.notif-list { flex: 1; overflow-y: auto; max-height: 340px; }
.notif-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #F1F5F9;
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
}
.notif-item:hover { background: #F8FAFC; }
.notif-item.unread { background: #F0F4FF; }
.notif-item.unread::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #2B5CE6;
  border-radius: 0 3px 3px 0;
}
.notif-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.notif-icon.blue   { background: #EEF2FF; color: #2B5CE6; }
.notif-icon.green  { background: #DCFCE7; color: #16A34A; }
.notif-icon.orange { background: #FEF3C7; color: #D97706; }
.notif-icon.red    { background: #FEE2E2; color: #DC2626; }
.notif-icon.gray   { background: #F3F4F6; color: #6B7280; }
.notif-body  { flex: 1; min-width: 0; }
.notif-title {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notif-desc {
  font-size: 12px;
  color: #6B7280;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.notif-time {
  font-size: 11px;
  color: #9CA3AF;
  margin-top: 3px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 3px;
}
.notif-empty { padding: 40px 16px; text-align: center; color: #9CA3AF; font-size: 13px; }
.notif-empty i { font-size: 32px; display: block; margin-bottom: 8px; opacity: 0.4; }
.notif-empty-action { margin-top: 10px; }
.notif-footer { border-top: 1px solid #E2E8F0; padding: 10px; text-align: center; }
.notif-footer-link {
  font-size: 13px;
  font-weight: 600;
  color: #2B5CE6;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 6px;
  transition: background 0.15s;
}
.notif-footer-link:hover { background: #EEF2FF; }

/* ============================================================
   INLINE FIELD VALIDATION
   Shown against the field itself (not in a toast or alert).
   Usage: call window.showFieldError(id, msg) / clearFieldError(id)
   Or place <div class="invalid-feedback"> after the input and
   toggle .is-invalid on the input/select/textarea.
   ============================================================ */
.form-input.is-invalid,
.form-select.is-invalid,
.form-textarea.is-invalid,
textarea.form-input.is-invalid,
input.is-invalid,
select.is-invalid,
textarea.is-invalid {
  border-color: #DC2626 !important;
  background-color: #FEF2F2;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}
.form-input.is-invalid:focus,
.form-select.is-invalid:focus,
.form-textarea.is-invalid:focus,
input.is-invalid:focus,
select.is-invalid:focus,
textarea.is-invalid:focus {
  border-color: #DC2626 !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18);
  outline: none;
}

.invalid-feedback {
  display: none;
  width: 100%;
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.4;
  color: #DC2626;
}
.invalid-feedback::before {
  content: "\F33A"; /* bi-exclamation-circle-fill */
  font-family: "bootstrap-icons";
  font-weight: normal;
  margin-right: 4px;
  vertical-align: middle;
}
.form-group.has-error .invalid-feedback,
.invalid-feedback.d-block,
.is-invalid ~ .invalid-feedback,
.is-invalid + .invalid-feedback {
  display: block;
}

/* Valid state (optional, for post-validation success indicator) */
.form-input.is-valid,
.form-select.is-valid,
.form-textarea.is-valid {
  border-color: #16A34A !important;
}
.valid-feedback {
  display: none;
  width: 100%;
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.4;
  color: #16A34A;
}
.is-valid ~ .valid-feedback,
.is-valid + .valid-feedback { display: block; }
.step-badge.disabled { background: var(--border); color: var(--text-muted); }

/* ── Numbered pagination (global — pagination.app view; STANDING RULE, never simple prev/next) ── */
.aps-pagination {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; width: 100%;
}
.aps-pagination-info { font-size: 13px; color: var(--text-muted); }
.aps-pagination-info strong { color: var(--text); font-weight: 600; }
.aps-pagination-list {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
  list-style: none; margin: 0; padding: 0;
}
.aps-page-item > a,
.aps-page-item > span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius, 6px);
  font-size: 13px; line-height: 1; color: var(--text); text-decoration: none;
  background: #fff; transition: all .15s ease; user-select: none;
}
.aps-page-item > a:hover {
  border-color: var(--primary); color: var(--primary);
  background: var(--primary-light, #EEF2FF);
}
.aps-page-item.active > span {
  background: var(--primary); border-color: var(--primary);
  color: #fff; font-weight: 600; cursor: default;
}
.aps-page-item.disabled > span {
  color: var(--text-muted); background: var(--surface-alt);
  cursor: not-allowed; opacity: .65;
}
@media (max-width: 640px) {
  .aps-pagination { justify-content: center; }
  .aps-pagination-info { width: 100%; text-align: center; }
}

/* ── Sales list filter panel (shared) ────────────────────────────────────────────────────────────
   Every Sales list screen (orders, invoices, quotes, shipments, backorders, counter) uses the same
   `#filterPanel.sales-filter-panel` markup. The horizontal-row layout previously lived ONLY in
   orders.css, so every OTHER page's filter fell back to a vertical block stack (and rendered
   expanded by default). Defined here once so all of them — and any future list — get it for free.
   common.js toggles #filterPanel via inline display + the rule-37c auto-expand, so `display:none`
   here is just the collapsed default it overrides. */
.sales-filter-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 14px; display: none; }
.sales-filter-panel.active { display: block; }
.sales-filter-grid { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.sales-filter-group { flex: 1 1 150px; min-width: 140px; margin: 0; }
.sales-filter-actions { display: flex; align-items: flex-end; gap: 8px; margin-left: auto; padding-top: 22px; }

/* Sales document line-grid: the "Add Product / Non-Inventory / Service / Charge" button row */
.sd-line-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
/* Freight input in the sales document totals panel */
.sd-freight-input { width: 110px; text-align: right; padding: 2px 6px; font-size: 13px; }
/* Sales order credit indicator */
.sd-credit { display: flex; gap: 18px; align-items: center; margin-top: 6px; padding: 6px 10px; border-radius: 6px; background: #f8fafc; border: 1px solid var(--border); font-size: 12px; }
.sd-credit .sd-credit-bad { color: var(--danger, #DC2626); font-weight: 700; }

/* Sales order Billing/Shipping address cards */
.sd-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sd-addr-card { border: 1px solid var(--border); border-radius: 8px; padding: 12px; background: #fff; }
.sd-addr-head { display: flex; align-items: center; justify-content: space-between; }
.sd-addr-card .sd-same { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; margin: 0; cursor: pointer; }
.sd-addr-preview { margin-top: 8px; font-size: 12px; color: var(--muted); white-space: pre-line; min-height: 16px; }
@media (max-width: 760px) { .sd-grid-2 { grid-template-columns: 1fr; } }

/* ── Act-as-company banner (platform Super Admin acting inside a company) ───────── */
.pf-acting-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 20px;
    background: #1E293B;
    color: #E2E8F0;
    font-size: 13px;
}
.pf-acting-banner .pf-acting-label { display: inline-flex; align-items: center; gap: 6px; }
.pf-acting-banner strong { color: #fff; }
.pf-acting-banner .pf-acting-spacer { flex: 1; }
.pf-acting-banner form { margin: 0; }
.pf-acting-exit {
    background: transparent;
    border: 1px solid #475569;
    color: #E2E8F0;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}
.pf-acting-exit:hover { background: #334155; }

/* ============================================================
   MASTER-DATA LIFECYCLE — archived ("Deleted") rows
   Dimmed row styling for soft-deleted records shown in the opt-in
   "Deleted" list view (two-tier lifecycle). Restore-only rows.
   ============================================================ */
.aps-row-archived {
    opacity: 0.6;
}
.aps-row-archived td {
    font-style: italic;
    color: #64748B;
}
