/* ===== Password policy widget (FlashPassword) ========================= */
.fp-panel { margin-top: .4rem; }
.fp-strength { display: flex; align-items: center; gap: .5rem; margin-bottom: .35rem; }
.fp-bar { display: flex; gap: 3px; flex: 0 0 120px; }
.fp-bar span { height: 5px; flex: 1; border-radius: 3px; background: var(--fl-border, #e5e7eb); transition: background .2s; }
.fp-bar.s1 span:nth-child(-n+1),
.fp-bar.s2 span:nth-child(-n+2),
.fp-bar.s3 span:nth-child(-n+3),
.fp-bar.s4 span:nth-child(-n+4) { background: currentColor; }
.fp-bar.s1 { color: #dc2626; } .fp-bar.s2 { color: #f59e0b; }
.fp-bar.s3 { color: #2563eb; } .fp-bar.s4 { color: #16a34a; }
.fp-strength-label { font-size: .72rem; font-weight: 600; color: var(--fl-text-muted, #6b7280); }
.fp-rules { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .05rem .8rem; }
@media (max-width: 575.98px) { .fp-rules { grid-template-columns: 1fr; } }
.fp-rule { font-size: .72rem; line-height: 1.5; display: flex; align-items: center; gap: .3rem; }
.fp-rule i { font-size: .72rem; }
.fp-rule.ok { color: #16a34a; }
.fp-rule.no { color: var(--fl-text-muted, #6b7280); }

/* ===== Toast notifications (bold gradient, top-center) ================
   Double-size gradient cards with a translucent icon chip. Slide/fade uses
   translateY + opacity ONLY — no scale() — so text never rasterizes blurry
   on scaled displays (the old scale(.98) animation caused the fuzz). */
.flash-toast-stack {
    position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 2050;
    display: flex; flex-direction: column; align-items: center; gap: .55rem;
    max-width: calc(100vw - 2rem); width: auto;
    pointer-events: none;
}
@media (max-width: 575.98px) {
    .flash-toast-stack { width: calc(100vw - 1.5rem); }
}

.flash-toast {
    --tsh: rgba(15, 23, 42, .30);                    /* per-type shadow tint */
    position: relative; overflow: hidden;
    display: flex; align-items: center; gap: .9rem;
    padding: 1.15rem 2.5rem 1.15rem 1.4rem;
    width: max-content; min-width: 340px; max-width: min(520px, calc(100vw - 2rem));
    color: #fff;
    border: none; border-radius: 14px;
    box-shadow: 0 12px 30px var(--tsh);
    pointer-events: auto;
    opacity: 0;
    transform: translateY(-16px);
    transition: transform 220ms cubic-bezier(.2, .8, .2, 1), opacity 180ms ease;
}
.flash-toast.show { opacity: 1; transform: translateY(0); }
[dir="rtl"] .flash-toast { padding: 1.15rem 1.4rem 1.15rem 2.5rem; }
@media (max-width: 575.98px) { .flash-toast { width: 100%; min-width: 0; } }

.flash-toast.success { background: linear-gradient(135deg, #059669, #16a34a); --tsh: rgba(22, 163, 74, .38); }
.flash-toast.danger  { background: linear-gradient(135deg, #dc2626, #e11d48); --tsh: rgba(220, 38, 38, .38); }
.flash-toast.warning { background: linear-gradient(135deg, #d97706, #f59e0b); --tsh: rgba(217, 119, 6, .38); }
.flash-toast.info    { background: linear-gradient(135deg, #0284c7, #0891b2); --tsh: rgba(8, 145, 178, .38); }

/* Translucent icon chip */
.flash-toast-icon {
    flex: 0 0 auto; width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 11px; font-size: 1.3rem; line-height: 1;
    color: #fff; background: rgba(255, 255, 255, .2);
}

.flash-toast-body { flex: 1; min-width: 0; font-size: 1.06rem; line-height: 1.45; word-break: break-word; }
.flash-toast-title { font-weight: 600; margin-bottom: .08rem; }
.flash-toast-msg { color: #fff; font-weight: 500; }
.flash-toast-title + .flash-toast-msg { color: rgba(255, 255, 255, .88); font-weight: 400; }

.flash-toast-close {
    position: absolute; top: 50%; transform: translateY(-50%); inset-inline-end: .55rem;
    border: 0; background: transparent; color: rgba(255, 255, 255, .75);
    width: 30px; height: 30px; padding: 0; font-size: 1.15rem; cursor: pointer;
    line-height: 1; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    transition: color 150ms ease, background 150ms ease;
}
.flash-toast-close:hover { color: #fff; background: rgba(255, 255, 255, .18); }

/* Progress bar for auto-dismiss timing — pauses while hovered */
.flash-toast-progress {
    position: absolute; left: 0; bottom: 0; height: 3px; width: 100%;
    background: rgba(255, 255, 255, .55);
    transform-origin: left center;
    animation: flashToastShrink linear forwards;
}
[dir="rtl"] .flash-toast-progress { transform-origin: right center; }
.flash-toast:hover .flash-toast-progress { animation-play-state: paused; }
@keyframes flashToastShrink { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* Dark theme: deepen the shadow so the gradient still lifts off the page */
html[data-theme="dark"] .flash-toast { box-shadow: 0 14px 34px rgba(0, 0, 0, .55); }

/* ==============================================================
   FLASH ERP — design system
   --------------------------------------------------------------
   How to use in new forms:

     <h1 class="h4 mb-0">Form Title</h1>          ← consistent heading
     <div class="card flash-card">…</div>         ← consistent card surface
     <div class="ug-stat">…</div>                 ← stat tile pattern (see UserGroup.cshtml)
     class="form-control form-control-sm"         ← Bootstrap controls auto-theme
     class="table table-sm align-middle"          ← tables inherit theme

   All colours come from the tokens below. To rebrand, change
   --fl-brand-* and --fl-surface-* only.
   ============================================================== */

/* ─── Tokens — LIGHT ───────────────────────────────────────── */
:root {
  /* Brand */
  --fl-brand:           #0a4d8c;
  --fl-brand-hover:     #08406f;
  --fl-brand-soft:      rgba(10, 77, 140, .08);
  --fl-accent:          #00a3ff;

  /* Surfaces */
  --fl-bg:              #f4f6fa;
  --fl-surface:         #ffffff;
  --fl-surface-alt:     #f8fafc;
  --fl-border:          #e2e8f0;
  --fl-border-strong:   #cbd5e1;
  --fl-divider:         #eef2f7;

  /* Grid surfaces — a little darker than white so rows/header read as a grid */
  --fl-grid-row:        #f3f6fb;   /* body rows */
  --fl-grid-row-alt:    #e9eef6;   /* striped alt */
  --fl-grid-head:       #dfe6f0;   /* header (darker than rows) */

  /* Text */
  --fl-text:            #1e293b;
  --fl-text-muted:      #64748b;
  --fl-text-subtle:     #94a3b8;
  --fl-text-on-brand:   #ffffff;
  --fl-label:           #475569;   /* form captions — stronger than -muted (~7:1) */

  /* Sidebar/header */
  --fl-sidebar-bg:      #0f1c2e;
  --fl-sidebar-fg:      #cdd6e0;
  --fl-sidebar-hover:   rgba(255,255,255,.08);
  --fl-sidebar-active:  rgba(0,163,255,.18);
  --fl-header-bg:       #ffffff;
  --fl-header-fg:       #1e293b;
  --fl-header-border:   #e2e8f0;

  /* States */
  --fl-success:         #10b981;
  --fl-warning:         #f59e0b;
  --fl-danger:          #ef4444;
  --fl-info:            #3b82f6;

  /* Geometry */
  --fl-radius:          .55rem;
  --fl-radius-lg:       .85rem;
  --fl-radius-sm:       .35rem;
  --fl-shadow-sm:       0 1px 2px rgba(15, 23, 42, .06);
  --fl-shadow:          0 6px 18px rgba(15, 23, 42, .08);
  --fl-shadow-lg:       0 24px 48px rgba(15, 23, 42, .14);

  /* Spacing scale (4px base) — use these instead of ad-hoc rems */
  --fl-space-1:         .25rem;
  --fl-space-2:         .5rem;
  --fl-space-3:         .75rem;
  --fl-space-4:         1rem;
  --fl-space-5:         1.5rem;
  --fl-space-6:         2rem;

  /* Density tokens (Comfortable default; overridden by [data-density="compact"]).
     Drive table cell padding, control sizing and base UI font from one place. */
  --fl-cell-pad-y:      .45rem;
  --fl-cell-pad-x:      .6rem;
  --fl-control-pad-y:   .375rem;
  --fl-control-pad-x:   .65rem;
  --fl-ui-font:         .9rem;
  --fl-row-gap:         .5rem;

  /* Layout */
  --fl-sidebar-w:       260px;
  --fl-header-h:        60px;
  --fl-transition:      180ms ease;

  /* Bootstrap overrides (so .btn-primary, .text-primary etc. match brand) */
  --bs-primary:                 var(--fl-brand);
  --bs-primary-rgb:             10, 77, 140;
  --bs-link-color:              var(--fl-brand);
  --bs-link-color-rgb:          10, 77, 140;
  --bs-link-hover-color:        var(--fl-brand-hover);
  --bs-link-hover-color-rgb:    8, 64, 111;
  --bs-body-bg:                 var(--fl-bg);
  --bs-body-color:              var(--fl-text);
  --bs-border-color:            var(--fl-border);
  --bs-border-color-translucent: var(--fl-border);
  --bs-tertiary-bg:             var(--fl-surface-alt);
  --bs-secondary-bg:            var(--fl-divider);
}

/* ─── Tokens — DARK ────────────────────────────────────────── */
html[data-theme="dark"] {
  --fl-brand:           #3b82f6;   /* brighter for contrast */
  --fl-brand-hover:     #2563eb;
  --fl-brand-soft:      rgba(59, 130, 246, .15);
  --fl-accent:          #60a5fa;

  --fl-bg:              #0b1424;
  --fl-surface:         #131d31;
  --fl-surface-alt:     #182338;
  --fl-border:          #233149;
  --fl-border-strong:   #324363;
  --fl-divider:         #1c283f;

  /* Grid surfaces (dark) */
  --fl-grid-row:        #162236;
  --fl-grid-row-alt:    #1b2942;
  --fl-grid-head:       #20304c;

  --fl-text:            #e2e8f0;
  --fl-text-muted:      #94a3b8;
  --fl-text-subtle:     #64748b;
  --fl-text-on-brand:   #ffffff;
  --fl-label:           #cbd5e1;   /* form captions — brighter than -muted in dark */

  --fl-sidebar-bg:      #07101f;
  --fl-sidebar-fg:      #cbd5e1;
  --fl-sidebar-hover:   rgba(255,255,255,.06);
  --fl-sidebar-active:  rgba(59, 130, 246, .22);
  --fl-header-bg:       #0f1a2e;
  --fl-header-fg:       #e2e8f0;
  --fl-header-border:   #1c283f;

  --fl-success:         #34d399;
  --fl-warning:         #fbbf24;
  --fl-danger:          #f87171;
  --fl-info:            #60a5fa;

  --fl-shadow-sm:       0 1px 2px rgba(0, 0, 0, .35);
  --fl-shadow:          0 6px 18px rgba(0, 0, 0, .45);
  --fl-shadow-lg:       0 24px 48px rgba(0, 0, 0, .55);

  --bs-primary:                 var(--fl-brand);
  --bs-primary-rgb:             59, 130, 246;
  --bs-link-color:              var(--fl-brand);
  --bs-link-color-rgb:          59, 130, 246;
  --bs-link-hover-color:        var(--fl-accent);
  --bs-body-bg:                 var(--fl-bg);
  --bs-body-color:              var(--fl-text);
  --bs-border-color:            var(--fl-border);
  --bs-border-color-translucent: var(--fl-border);
  --bs-tertiary-bg:             var(--fl-surface-alt);
  --bs-secondary-bg:            var(--fl-divider);
}

/* ─── Tokens — FLASH (orange + pale gray) ─────────────────── */
html[data-theme="flash"] {
  /* Brand — energetic orange */
  --fl-brand:           #ea580c;   /* orange-600 */
  --fl-brand-hover:     #c2410c;   /* orange-700 */
  --fl-brand-soft:      rgba(234, 88, 12, .10);
  --fl-accent:          #f59e0b;   /* amber-500 */

  /* Surfaces — warm pale gray */
  --fl-bg:              #f5f5f4;   /* stone-100 */
  --fl-surface:         #ffffff;
  --fl-surface-alt:     #fafaf9;   /* stone-50 */
  --fl-border:          #e7e5e4;   /* stone-200 */
  --fl-border-strong:   #d6d3d1;   /* stone-300 */
  --fl-divider:         #f1f0ef;

  /* Grid surfaces (flash — warm gray, darker than white) */
  --fl-grid-row:        #f5f4f2;
  --fl-grid-row-alt:    #ecebe8;
  --fl-grid-head:       #e6e3df;

  /* Text */
  --fl-text:            #292524;   /* stone-800 */
  --fl-text-muted:      #78716c;   /* stone-500 */
  --fl-text-subtle:     #a8a29e;   /* stone-400 */
  --fl-text-on-brand:   #ffffff;

  /* Sidebar — warm dark (stone-900) so orange highlights pop */
  --fl-sidebar-bg:      #1c1917;   /* stone-900 */
  --fl-sidebar-fg:      #d6d3d1;   /* stone-300 */
  --fl-sidebar-hover:   rgba(255,255,255,.06);
  --fl-sidebar-active:  rgba(234, 88, 12, .25);
  --fl-header-bg:       #ffffff;
  --fl-header-fg:       #292524;
  --fl-header-border:   #e7e5e4;

  /* Supporting state colours that harmonise with orange */
  --fl-success:         #16a34a;   /* green-600 */
  --fl-warning:         #eab308;   /* yellow-500 */
  --fl-danger:          #dc2626;   /* red-600 */
  --fl-info:            #0891b2;   /* cyan-600 */

  --fl-shadow-sm:       0 1px 2px rgba(28, 25, 23, .06);
  --fl-shadow:          0 6px 18px rgba(28, 25, 23, .08);
  --fl-shadow-lg:       0 24px 48px rgba(28, 25, 23, .14);

  /* Bootstrap variable bindings */
  --bs-primary:                  var(--fl-brand);
  --bs-primary-rgb:              234, 88, 12;
  --bs-link-color:               var(--fl-brand);
  --bs-link-color-rgb:           234, 88, 12;
  --bs-link-hover-color:         var(--fl-brand-hover);
  --bs-link-hover-color-rgb:     194, 65, 12;
  --bs-body-bg:                  var(--fl-bg);
  --bs-body-color:               var(--fl-text);
  --bs-border-color:             var(--fl-border);
  --bs-border-color-translucent: var(--fl-border);
  --bs-tertiary-bg:              var(--fl-surface-alt);
  --bs-secondary-bg:             var(--fl-divider);
}

html[data-theme="forest"] {
  /* Brand — emerald green with a warm orange accent (from the reference UI) */
  --fl-brand:           #10a37f;   /* emerald */
  --fl-brand-hover:     #0c8568;
  --fl-brand-soft:      rgba(16, 163, 127, .10);
  --fl-accent:          #f5a623;   /* warm amber accent */

  /* Surfaces — faint green-tinted gray with white cards */
  --fl-bg:              #eef3f1;
  --fl-surface:         #ffffff;
  --fl-surface-alt:     #f6faf8;
  --fl-border:          #e2e8e5;
  --fl-border-strong:   #cdd8d2;
  --fl-divider:         #eef3f0;

  /* Grid surfaces (cool green-gray, darker than white) */
  --fl-grid-row:        #f3f7f5;
  --fl-grid-row-alt:    #e9f0ec;
  --fl-grid-head:       #e1ebe6;

  /* Text — dark slate-green */
  --fl-text:            #1c2b27;
  --fl-text-muted:      #5f6f6a;
  --fl-text-subtle:     #93a39d;
  --fl-text-on-brand:   #ffffff;

  /* Sidebar — light/white with a solid emerald active pill (matches the design) */
  --fl-sidebar-bg:      #ffffff;
  --fl-sidebar-fg:      #44544e;
  --fl-sidebar-hover:   rgba(16, 163, 127, .10);
  --fl-sidebar-active:  #10a37f;
  --fl-header-bg:       #ffffff;
  --fl-header-fg:       #1c2b27;
  --fl-header-border:   #e2e8e5;

  /* Supporting state colours that harmonise with emerald */
  --fl-success:         #15803d;   /* green-700 */
  --fl-warning:         #d97706;   /* amber-600 */
  --fl-danger:          #dc2626;   /* red-600 */
  --fl-info:            #0e7490;   /* cyan-700 */

  --fl-shadow-sm:       0 1px 2px rgba(6, 46, 36, .06);
  --fl-shadow:          0 6px 18px rgba(6, 46, 36, .08);
  --fl-shadow-lg:       0 24px 48px rgba(6, 46, 36, .14);

  /* Bootstrap variable bindings */
  --bs-primary:                  var(--fl-brand);
  --bs-primary-rgb:              16, 163, 127;
  --bs-link-color:               var(--fl-brand);
  --bs-link-color-rgb:           16, 163, 127;
  --bs-link-hover-color:         var(--fl-brand-hover);
  --bs-link-hover-color-rgb:     12, 133, 104;
  --bs-body-bg:                  var(--fl-bg);
  --bs-body-color:               var(--fl-text);
  --bs-border-color:             var(--fl-border);
  --bs-border-color-translucent: var(--fl-border);
  --bs-tertiary-bg:              var(--fl-surface-alt);
  --bs-secondary-bg:             var(--fl-divider);
}

/* ─── Base ────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { height: 100%; }
body.flash-shell {
  margin: 0;
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--fl-bg);
  color: var(--fl-text);
  font-size: .92rem;
}
::selection { background: var(--fl-brand-soft); color: inherit; }

/* Scrollbar polish — works on Chromium/WebKit, gracefully falls back elsewhere */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--fl-border-strong); border-radius: 6px; border: 2px solid var(--fl-bg); }
::-webkit-scrollbar-thumb:hover { background: var(--fl-text-subtle); }
::-webkit-scrollbar-track { background: transparent; }

/* ─── Layout shell ────────────────────────────────────────── */
.flash-app  { display: flex; flex-direction: column; min-height: 100vh; }
.flash-body { display: flex; flex: 1; min-height: 0; }
.flash-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--fl-bg); }
.flash-footer {
  padding: .75rem 1rem;
  border-top: 1px solid var(--fl-border);
  margin-top: auto;
  color: var(--fl-text-muted);
}

/* ─── Header ──────────────────────────────────────────────── */
.flash-header {
  height: var(--fl-header-h);
  background: var(--fl-header-bg);
  color: var(--fl-header-fg);
  box-shadow: var(--fl-shadow-sm);
  border-bottom: 1px solid var(--fl-header-border);
  position: sticky; top: 0;
  z-index: 1040;
}
/* header menus (theme, menu-position, language, user…) always above the nav */
.flash-header .dropdown-menu { z-index: 1060; }
.flash-header-inner {
  display: flex; align-items: center;
  height: 100%; padding: 0 1rem;
  gap: .5rem;
}
.flash-brand { display: flex; align-items: center; text-decoration: none; color: inherit; font-weight: 600; }
.flash-brand-mark {
  background: linear-gradient(135deg, var(--fl-brand), var(--fl-accent));
  color: #fff;
  width: 34px; height: 34px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; margin-right: .5rem;
}
[dir="rtl"] .flash-brand-mark { margin-right: 0; margin-left: .5rem; }
.flash-brand-mark.lg { width: 54px; height: 54px; font-size: 1.5rem; }

/* Image-based brand logo (preferred). Falls back to the gradient mark
   automatically when wwwroot/images/flash-erp-logo.png is missing
   (browser hides the img via the onerror handler). */
.flash-brand-logo {
    width: 34px; height: 34px;
    object-fit: contain;
    margin-right: .5rem;
    display: inline-block;
    flex-shrink: 0;
}
[dir="rtl"] .flash-brand-logo { margin-right: 0; margin-left: .5rem; }
.flash-brand-logo.lg { width: 84px; height: 84px; margin-bottom: .5rem; }
.flash-brand-logo.xl { width: 120px; height: 120px; margin-bottom: .75rem; }
.flash-auth-brand .flash-brand-logo { display: block; margin-left: auto; margin-right: auto; }
.flash-brand-text-lg { font-size: 1.6rem; font-weight: 700; margin: .5rem 0 0; }
.flash-tenant { font-size: .9rem; color: var(--fl-text-muted); margin-left: 1rem; }
[dir="rtl"] .flash-tenant { margin-left: 0; margin-right: 1rem; }
.flash-header-spacer { flex: 1; }
.flash-header-actions { display: flex; align-items: center; gap: .25rem; }
.btn-icon {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; border: none; background: transparent;
  color: var(--fl-header-fg);
  transition: background var(--fl-transition), color var(--fl-transition);
}
.btn-icon:hover { background: var(--fl-brand-soft); color: var(--fl-brand); }
.flash-badge { font-size: .55rem; padding: .25em .4em; }
.flash-user-button {
  display: inline-flex; align-items: center;
  background: transparent; border: none; color: var(--fl-header-fg);
}
.flash-avatar {
  width: 34px; height: 34px;
  background: var(--fl-brand); color: #fff;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600;
}

/* ─── Sidebar ─────────────────────────────────────────────── */
/* ── App full-screen / focus mode (persists across pages) ──
   Hides the header + sidebar to maximise the working area. A floating
   button restores it. Native browser fullscreen can't survive a page
   navigation, so this app-level mode is what actually persists. */
.flash-app.app-fs .flash-header { display: none; }
.flash-app.app-fs .flash-sidebar { display: none; }
.flash-fs-exit { display: none; position: fixed; top: .5rem; inset-inline-end: .6rem; z-index: 3000;
  width: 34px; height: 34px; align-items: center; justify-content: center;
  border-radius: 8px; border: 1px solid var(--fl-border, #e5e7eb);
  background: var(--fl-surface, #fff); color: var(--fl-text, #1e293b);
  box-shadow: 0 4px 14px rgba(0,0,0,.18); cursor: pointer; }
.flash-fs-exit:hover { background: var(--fl-surface-alt, #f1f5f9); }
.flash-app.app-fs .flash-fs-exit { display: inline-flex; }

.flash-sidebar {
  width: var(--fl-sidebar-w);
  background: var(--fl-sidebar-bg);
  color: var(--fl-sidebar-fg);
  flex-shrink: 0;
  height: calc(100vh - var(--fl-header-h));
  position: sticky; top: var(--fl-header-h);
  transition: transform var(--fl-transition);
  z-index: 1020;
  border-right: 1px solid rgba(255,255,255,.04);
}
[dir="rtl"] .flash-sidebar { border-right: 0; border-left: 1px solid rgba(255,255,255,.04); }
.flash-sidebar-scroll { height: 100%; overflow-y: auto; padding-bottom: 1.5rem; }
.flash-sidebar-header {
  padding: 1rem 1.25rem .5rem;
  color: #9aa6b5;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.flash-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 .5rem; }
.flash-nav-link, .flash-nav-group-toggle {
  display: flex; align-items: center;
  color: var(--fl-sidebar-fg);
  background: transparent; border: none;
  padding: .55rem .75rem;
  border-radius: 7px;
  text-decoration: none; font-size: .9rem;
  width: 100%; text-align: inherit;
  transition: background var(--fl-transition), color var(--fl-transition);
}
.flash-nav-link:hover, .flash-nav-group-toggle:hover { background: var(--fl-sidebar-hover); color: #fff; }
.flash-nav-link.active { background: var(--fl-sidebar-active); color: #fff; }
/* Forest uses a light/white sidebar — keep hover text dark/brand (active stays
   white on its solid emerald pill). */
html[data-theme="forest"] .flash-nav-link:hover,
html[data-theme="forest"] .flash-nav-group-toggle:hover { color: var(--fl-brand); }
.flash-nav-icon { width: 22px; margin-right: .65rem; text-align: center; }
[dir="rtl"] .flash-nav-icon { margin-right: 0; margin-left: .65rem; }
.flash-nav-group { display: flex; flex-direction: column; }
.flash-nav-group-toggle { justify-content: flex-start; }
.flash-nav-chevron { margin-left: auto; transition: transform var(--fl-transition); font-size: .7rem; opacity: .6; }
[dir="rtl"] .flash-nav-chevron { margin-left: 0; margin-right: auto; }
.flash-nav-group-toggle[aria-expanded="true"] .flash-nav-chevron { transform: rotate(180deg); }
.flash-nav-group-items { display: flex; flex-direction: column; gap: 2px; padding: 4px 0 4px 1.25rem; }
[dir="rtl"] .flash-nav-group-items { padding-left: 0; padding-right: 1.25rem; }
.flash-nav-sublink { font-size: .83rem; opacity: .88; }
.flash-sidebar-backdrop {
  display: none;
  position: fixed; inset: var(--fl-header-h) 0 0 0;
  background: rgba(0,0,0,.5);
  /* Above grid chrome (column-picker 1055, filter popover 1080) but just
     below the sidebar (1090) so the dim overlay covers the grid. */
  z-index: 1086;
}

/* ─── Cards (use .card.flash-card) ────────────────────────── */
.flash-card {
  background: var(--fl-surface);
  border: 1px solid var(--fl-border);
  border-radius: var(--fl-radius);
  box-shadow: var(--fl-shadow-sm);
  color: var(--fl-text);
}
.flash-card .card-header {
  background: var(--fl-surface);
  border-bottom: 1px solid var(--fl-border);
  font-weight: 600;
  color: var(--fl-text);
}
.flash-card .card-footer {
  background: var(--fl-surface);
  border-top: 1px solid var(--fl-border);
}
/* Transaction pages (.fl-txn): tint every panel header with a light, on-theme
   brand wash so each panel is clearly distinguished from its body. */
.fl-txn .flash-card > .card-header {
  background: var(--fl-brand-soft, rgba(10,77,140,.08));
}

/* Stat tile */
.flash-stat {
  background: var(--fl-surface);
  border: 1px solid var(--fl-border);
  border-radius: var(--fl-radius);
  box-shadow: var(--fl-shadow-sm);
  transition: transform var(--fl-transition), box-shadow var(--fl-transition);
}
.flash-stat:hover { transform: translateY(-2px); box-shadow: var(--fl-shadow); }
.flash-stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
}
.flash-stat-label { font-size: .72rem; text-transform: uppercase; color: var(--fl-text-muted); letter-spacing: .05em; }
.flash-stat-value { font-size: 1.4rem; font-weight: 700; color: var(--fl-text); }

/* ─── Bootstrap component overrides ───────────────────────── */

/* Tables that work in both themes (replaces hardcoded .table-light headers) */
.table {
  --bs-table-bg:           var(--fl-grid-row);
  --bs-table-color:        var(--fl-text);
  --bs-table-striped-bg:   var(--fl-grid-row-alt);
  --bs-table-striped-color: var(--fl-text);
  --bs-table-hover-bg:     var(--fl-brand-soft);
  --bs-table-hover-color:  var(--fl-text);
  --bs-table-border-color: var(--fl-border);
}

/* ── Grid comfort: a touch taller rows + a standard ~14px SaaS body size with
   relaxed line-height, so every grid (incl. FlashGrid + .table-sm) reads calm
   and easy on the eyes. One place → applies app-wide. ──────────────────── */
.table {
  font-size: .875rem;          /* ~14px — comfortable SaaS table size */
  line-height: 1.5;
}
.table > :not(caption) > * > * {
  padding: .6rem .7rem;        /* roomier rows than Bootstrap's cramped default */
  vertical-align: middle;
}
/* .table-sm stays a little tighter than the default, but still comfortable
   (Bootstrap ships .25rem here — far too dense). Overrides Bootstrap by
   matching specificity + later source order. */
.table-sm > :not(caption) > * > * { padding: .5rem .6rem; }
/* Headers: slightly smaller + quietly spaced so data rows lead the eye. */
.table > thead > tr > th { font-size: .8rem; letter-spacing: .01em; }
.table > thead, .table > thead.table-light {
  --bs-table-bg:    var(--fl-grid-head);
  --bs-table-color: var(--fl-text);
  color: var(--fl-text);
}
.table > thead > tr > th {
  font-weight: 600;
  border-bottom: 1px solid var(--fl-border-strong);
  background: var(--fl-grid-head) !important;
  color: var(--fl-text) !important;
}
.table-bordered > :not(caption) > * > * { border-color: var(--fl-border); }
tr.table-active, .table-active > * {
  --bs-table-bg-state: var(--fl-brand-soft);
  color: var(--fl-text) !important;
}

/* Forms */
.form-control, .form-select {
  background-color: var(--fl-surface);
  border-color: var(--fl-border);
  color: var(--fl-text);
}
.form-control:focus, .form-select:focus {
  background-color: var(--fl-surface);
  border-color: var(--fl-brand);
  color: var(--fl-text);
  box-shadow: 0 0 0 .2rem var(--fl-brand-soft);
}
.form-control::placeholder { color: var(--fl-text-subtle); }
.form-control[readonly] { background-color: var(--fl-surface-alt); }
.input-group-text {
  background: var(--fl-surface-alt);
  border-color: var(--fl-border);
  color: var(--fl-text-muted);
}
.form-label { color: var(--fl-text); }
.form-text { color: var(--fl-text-muted); }
.form-check-input {
  background-color: var(--fl-surface);
  border-color: var(--fl-border-strong);
}
.form-check-input:checked {
  background-color: var(--fl-brand);
  border-color: var(--fl-brand);
}
.form-check-input:focus { box-shadow: 0 0 0 .2rem var(--fl-brand-soft); }

/* Buttons */
.btn-primary {
  --bs-btn-bg:         var(--fl-brand);
  --bs-btn-border-color: var(--fl-brand);
  --bs-btn-hover-bg:   var(--fl-brand-hover);
  --bs-btn-hover-border-color: var(--fl-brand-hover);
  --bs-btn-active-bg:  var(--fl-brand-hover);
  --bs-btn-active-border-color: var(--fl-brand-hover);
}
.btn-outline-primary {
  --bs-btn-color:      var(--fl-brand);
  --bs-btn-border-color: var(--fl-brand);
  --bs-btn-hover-bg:   var(--fl-brand);
  --bs-btn-hover-border-color: var(--fl-brand);
  --bs-btn-hover-color: #fff;
}

/* Dropdown */
.dropdown-menu {
  background: var(--fl-surface);
  border: 1px solid var(--fl-border);
  box-shadow: var(--fl-shadow);
  color: var(--fl-text);
}
.dropdown-item { color: var(--fl-text); }
.dropdown-item:hover, .dropdown-item:focus {
  background: var(--fl-brand-soft);
  color: var(--fl-text);
}
.dropdown-divider { border-color: var(--fl-divider); }

/* Tabs */
.nav-tabs {
  --bs-nav-tabs-border-color: var(--fl-border);
  --bs-nav-tabs-link-active-bg: var(--fl-surface);
  --bs-nav-tabs-link-active-color: var(--fl-brand);
  --bs-nav-tabs-link-active-border-color: var(--fl-border) var(--fl-border) var(--fl-surface);
  --bs-nav-link-color: var(--fl-text-muted);
  --bs-nav-link-hover-color: var(--fl-brand);
}

/* Alerts — keep accent borders but match surface */
.alert {
  border-left-width: 4px;
}
.alert-success { background: rgba(16,185,129,.10); color: var(--fl-text); border-color: var(--fl-success); border-left-color: var(--fl-success); }
.alert-warning { background: rgba(245,158,11,.10); color: var(--fl-text); border-color: var(--fl-warning); border-left-color: var(--fl-warning); }
.alert-danger  { background: rgba(239,68,68,.10);  color: var(--fl-text); border-color: var(--fl-danger);  border-left-color: var(--fl-danger); }
.alert-info    { background: rgba(59,130,246,.10); color: var(--fl-text); border-color: var(--fl-info);    border-left-color: var(--fl-info); }

/* Badges */
.bg-light { background-color: var(--fl-surface-alt) !important; color: var(--fl-text) !important; }
.text-dark { color: var(--fl-text) !important; }
.text-muted { color: var(--fl-text-muted) !important; }

/* Subtle/translucent backgrounds used in stat-icon styles */
.bg-primary-subtle { background-color: var(--fl-brand-soft) !important; }
.bg-success-subtle { background-color: rgba(16,185,129,.15) !important; }
.bg-warning-subtle { background-color: rgba(245,158,11,.15) !important; }
.bg-danger-subtle  { background-color: rgba(239,68,68,.15) !important; }
.bg-info-subtle    { background-color: rgba(59,130,246,.15) !important; }
.text-primary { color: var(--fl-brand) !important; }
.text-success { color: var(--fl-success) !important; }
.text-warning { color: var(--fl-warning) !important; }
.text-danger  { color: var(--fl-danger) !important; }
.text-info    { color: var(--fl-info) !important; }

/* Modals */
.modal-content {
  background: var(--fl-surface);
  border: 1px solid var(--fl-border);
  color: var(--fl-text);
}
.modal-header, .modal-footer { border-color: var(--fl-border); }

/* Close button — visible in dark mode */
html[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

/* ─── Auth / Tenant landing ───────────────────────────────── */
/* Background follows the active theme cookie (data-theme on <html>).
   The default rule uses the current theme's brand tokens, so the page
   re-skins automatically when the user switches Light / Dark / Flash. */
.flash-auth-body {
  margin: 0;
  min-height: 100vh;
  color: var(--fl-text);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Segoe UI', Roboto, sans-serif;
  /* Pale "stage" with two soft brand/accent glows in opposite corners so the
     page reads premium (not flat) while the card still pops. Theme-aware. */
  background:
    radial-gradient(38% 50% at 8% 12%,  rgba(10,77,140,.13), transparent 60%),
    radial-gradient(44% 56% at 92% 88%, rgba(0,163,255,.13), transparent 60%),
    linear-gradient(135deg, #eef1f6 0%, #e3e8f0 100%);
  transition: background .35s ease;
}
/* Dark: stay dark (a light-gray page would glare at night). */
html[data-theme="dark"] .flash-auth-body {
  background:
    radial-gradient(40% 52% at 10% 10%, rgba(59,130,246,.18), transparent 60%),
    radial-gradient(46% 56% at 90% 90%, rgba(34,211,238,.12), transparent 62%),
    linear-gradient(135deg, #0b1424 0%, #0f1c2e 100%);
}
/* Flash: warm stone-gray with orange/amber glows. */
html[data-theme="flash"] .flash-auth-body {
  background:
    radial-gradient(38% 50% at 8% 12%,  rgba(234,88,12,.13), transparent 60%),
    radial-gradient(44% 56% at 92% 88%, rgba(245,158,11,.14), transparent 60%),
    linear-gradient(135deg, #f5f4f2 0%, #eae7e3 100%);
}
/* Forest: cool green stage with emerald + amber glows. */
html[data-theme="forest"] .flash-auth-body {
  background:
    radial-gradient(38% 50% at 8% 12%,  rgba(16,163,127,.14), transparent 60%),
    radial-gradient(44% 56% at 92% 88%, rgba(245,166,35,.13), transparent 60%),
    linear-gradient(135deg, #eef3f1 0%, #e1ebe6 100%);
}
.flash-auth-shell { width: 100%; padding: 1rem; }
.flash-auth-card {
  background: var(--fl-surface);
  color: var(--fl-text);
  max-width: 420px; margin: 0 auto;
  padding: 2rem 1.75rem;
  border-radius: 14px;
  box-shadow: 0 30px 60px rgba(0,0,0,.4);
  animation: flashFadeUp 320ms ease;
}
.flash-auth-brand { text-align: center; margin-bottom: 1.5rem; }
.flash-auth-brand .flash-brand-mark { margin: 0 auto .75rem; }
.flash-auth-form { display: flex; flex-direction: column; }
.flash-btn-login { background: var(--fl-brand); border-color: var(--fl-brand); }
.flash-btn-login:hover { background: var(--fl-brand-hover); border-color: var(--fl-brand-hover); }
.flash-auth-footer { text-align: center; margin-top: 1.25rem; }
@keyframes flashFadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Split-screen login (brand panel + form) ─────────────────────────── */
.flash-auth-split {
  display: grid; grid-template-columns: 1.05fr .95fr;
  width: 100%; max-width: 940px; margin: 0 auto; min-height: 560px;
  border-radius: 18px; overflow: hidden;
  background: var(--fl-surface); color: var(--fl-text);
  border: 1px solid var(--fl-border);
  box-shadow: 0 24px 60px -24px rgba(15,23,42,.30), 0 4px 12px rgba(15,23,42,.06);
  animation: flashFadeUp 320ms ease;
}
html[data-theme="dark"] .flash-auth-split { box-shadow: 0 30px 70px -24px rgba(0,0,0,.6); }
/* Brand aside — gradient drawn from the dashboard palette accents */
.flash-auth-aside {
  position: relative; overflow: hidden; color: #fff;
  padding: 2.8rem 2.4rem; display: flex; flex-direction: column; gap: 1.25rem;
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(255,255,255,.22), transparent 55%),
    linear-gradient(150deg, var(--fl-brand) 0%, var(--fl-accent) 100%);
}
html[data-theme="dark"]  .flash-auth-aside { background:
    radial-gradient(120% 80% at 100% 0%, rgba(255,255,255,.14), transparent 55%),
    linear-gradient(150deg, #1366c4 0%, #0a4d8c 55%, #0b2238 100%); }
html[data-theme="flash"] .flash-auth-aside { background:
    radial-gradient(120% 80% at 100% 0%, rgba(255,255,255,.20), transparent 55%),
    linear-gradient(150deg, #fb923c 0%, #ea580c 50%, #9a3412 100%); }
/* faint dot-grid texture + soft floating orbs for depth */
.flash-auth-aside::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: radial-gradient(rgba(255,255,255,.14) 1px, transparent 1.4px);
  background-size: 18px 18px;
  -webkit-mask-image: radial-gradient(120% 100% at 100% 0%, #000, transparent 70%);
          mask-image: radial-gradient(120% 100% at 100% 0%, #000, transparent 70%);
}
.flash-auth-aside::after {
  content: ""; position: absolute; width: 220px; height: 220px; border-radius: 50%;
  bottom: -70px; inset-inline-start: -60px; pointer-events: none;
  background: radial-gradient(circle, rgba(255,255,255,.18), transparent 70%);
}
/* decorative ERP line-art, anchored bottom-end of the brand panel */
.aside-art { position: absolute; bottom: 0; inset-inline-end: 0; width: 78%; max-width: 380px;
  opacity: .16; pointer-events: none; user-select: none; }
[dir="rtl"] .aside-art { transform: scaleX(-1); }
.aside-logo {
  width: 72px; height: 72px; border-radius: 18px; position: relative;
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35);
  box-shadow: 0 10px 30px -8px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.4);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 800;
}
.aside-logo img { width: 100%; height: 100%; object-fit: contain; border-radius: 18px; padding: 7px; }
.flash-auth-aside h2 { position: relative; font-size: 1.85rem; font-weight: 800; margin: .15rem 0 0; letter-spacing: -.01em; }
.aside-tag { position: relative; font-size: .92rem; line-height: 1.5; opacity: .9; max-width: 34ch; margin: .35rem 0 0; }
.aside-feats { position: relative; list-style: none; padding: 0; margin: .5rem 0 0; display: flex; flex-direction: column; gap: .85rem; }
.aside-feats li { display: flex; align-items: center; gap: .7rem; font-size: .9rem; font-weight: 500;
  opacity: 0; transform: translateY(6px); animation: flashFadeUp .5s ease forwards; }
.aside-feats li:nth-child(1){ animation-delay: .10s } .aside-feats li:nth-child(2){ animation-delay: .18s }
.aside-feats li:nth-child(3){ animation-delay: .26s } .aside-feats li:nth-child(4){ animation-delay: .34s }
.aside-feats .bi { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 9px; font-size: .95rem;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.22); }
.aside-foot { position: relative; margin-top: auto; font-size: .72rem; opacity: .8;
  padding-top: 1rem; border-top: 1px solid rgba(255,255,255,.18); }
/* Form side */
.flash-auth-main { position: relative; padding: 2.8rem 2.4rem; display: flex; flex-direction: column; justify-content: center; }
.auth-main-inner { width: 100%; max-width: 360px; margin: 0 auto; }
.auth-lang { position: absolute; top: 1rem; inset-inline-end: 1rem; z-index: 2; }
.auth-welcome { font-size: 1.55rem; font-weight: 800; letter-spacing: -.01em; margin: 0; }
.auth-sub { color: var(--fl-text-muted); font-size: .86rem; margin: .25rem 0 1.6rem; }
/* refined inputs */
.flash-auth-main .form-label { font-size: .8rem; font-weight: 600; color: var(--fl-text); margin-bottom: .3rem; }
.flash-auth-main .input-group-text { background: var(--fl-surface-alt); border-color: var(--fl-border); color: var(--fl-text-muted); }
.flash-auth-main .form-control { border-color: var(--fl-border); }
.flash-auth-main .input-group:focus-within .input-group-text { color: var(--fl-brand); border-color: var(--fl-brand); }
.flash-auth-main .form-control:focus { border-color: var(--fl-brand);
  box-shadow: 0 0 0 .2rem var(--fl-brand-soft); }
/* login button — gradient + lift */
.flash-btn-login { margin-top: .25rem; font-weight: 600; border: 0; color: #fff;
  background: linear-gradient(135deg, var(--fl-brand), var(--fl-accent));
  box-shadow: 0 10px 24px -10px var(--fl-brand); transition: transform .15s ease, box-shadow .15s ease, filter .15s ease; }
.flash-btn-login:hover { color: #fff; transform: translateY(-1px); filter: brightness(1.05);
  box-shadow: 0 14px 28px -10px var(--fl-brand); }
.flash-btn-login:active { transform: translateY(0); }
.auth-secure { display: flex; align-items: center; justify-content: center; gap: .35rem;
  margin-top: 1.1rem; font-size: .72rem; color: var(--fl-text-subtle); }

@media (max-width: 767.98px) {
  .flash-auth-split { grid-template-columns: 1fr; max-width: 440px; min-height: 0; }
  /* collapse the brand panel to a compact header on phones */
  .flash-auth-aside { padding: 1.6rem 1.5rem; gap: .6rem; flex-direction: row; align-items: center; }
  .flash-auth-aside .aside-tag, .flash-auth-aside .aside-feats, .flash-auth-aside .aside-foot { display: none; }
  .flash-auth-aside h2 { font-size: 1.35rem; }
  .aside-logo { width: 52px; height: 52px; font-size: 1.5rem; }
  .flash-auth-main { padding: 1.75rem 1.5rem; }
  .auth-lang { position: static; align-self: flex-end; margin-bottom: .5rem; }
}

.flash-tenant-landing { width: 100%; display: flex; justify-content: center; padding: 1rem; }
.flash-tenant-card {
  background: var(--fl-surface);
  color: var(--fl-text);
  width: 100%; max-width: 460px;
  border-radius: 18px; overflow: hidden;
  box-shadow: 0 30px 60px rgba(0,0,0,.4);
  animation: flashFadeUp 320ms ease;
}
.flash-tenant-hero {
  background: var(--hero, linear-gradient(135deg, var(--fl-brand), var(--fl-accent)));
  color: #fff;
  padding: 2rem 1.5rem;
  text-align: center;
}
.flash-tenant-mark {
  width: 72px; height: 72px;
  margin: 0 auto .75rem;
  border-radius: 18px;
  background: rgba(255,255,255,.15);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 2rem;
  backdrop-filter: blur(2px);
}
.flash-tenant-code { font-size: 2.4rem; font-weight: 800; letter-spacing: .12em; }
.flash-tenant-body { padding: 1.5rem 1.75rem 1.75rem; text-align: center; }
.flash-tenant-title { font-size: 1.5rem; font-weight: 700; margin-bottom: .25rem; }
.flash-tenant-tagline { margin-bottom: 1rem; color: var(--fl-text-muted); }
.flash-tenant-features {
  list-style: none; padding: 0; margin: 1rem 0;
  text-align: start; font-size: .95rem;
}
.flash-tenant-features li {
  padding: .35rem 0;
  border-bottom: 1px solid var(--fl-divider);
}
.flash-tenant-features li:last-child { border-bottom: none; }

/* ─── Page header utility for new forms ───────────────────── */
.flash-page-header h1 { font-weight: 700; }

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .flash-sidebar {
    position: fixed;
    top: var(--fl-header-h); left: 0; bottom: 0;
    transform: translateX(-110%);
    box-shadow: var(--fl-shadow);
    /* Above the grid's sticky thead (1020), column-picker (1055) and
       filter popover (1080) so the open menu is never covered by grid
       chrome on mobile. */
    z-index: 1090;
  }
  [dir="rtl"] .flash-sidebar { left: auto; right: 0; transform: translateX(110%); }
  .flash-shell.sidebar-open .flash-sidebar { transform: translateX(0); }
  .flash-shell.sidebar-open .flash-sidebar-backdrop { display: block; }
}
@media (min-width: 992px) {
  /* In side-nav mode the hamburger becomes the desktop COLLAPSE toggle
     (hidden only in top-nav mode where there's no side rail to collapse). */
  html[data-nav="side"] .sidebar-toggle { display: inline-flex; }
  /* Collapsed: hide the side rail; .flash-main (flex:1) fills the width. */
  html[data-nav="side"] .flash-app.nav-collapsed .flash-sidebar { display: none; }

  /* ── Menu position: TOP (data-nav="top") — horizontal nav bar ────── */
  html[data-nav="top"] .flash-body { display: block; }
  html[data-nav="top"] .sidebar-toggle { display: none; }
  html[data-nav="top"] .flash-sidebar {
    width: 100%; height: auto; flex-shrink: 0;
    position: sticky; top: var(--fl-header-h); z-index: 1025;
    border-right: 0; border-bottom: 1px solid rgba(255,255,255,.06);
  }
  [dir="rtl"] html[data-nav="top"] .flash-sidebar { border-left: 0; }
  html[data-nav="top"] .flash-sidebar-scroll { height: auto; overflow: visible; padding: 0; }
  html[data-nav="top"] .flash-sidebar-header { display: none; }
  html[data-nav="top"] .flash-nav {
    flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: 2px; padding: .3rem .75rem;
  }
  html[data-nav="top"] .flash-nav-link,
  html[data-nav="top"] .flash-nav-group-toggle {
    width: auto; white-space: nowrap; padding: .4rem .7rem;
  }
  html[data-nav="top"] .flash-nav-group { position: relative; }
  html[data-nav="top"] .flash-nav-chevron { margin-left: .35rem; }
  [dir="rtl"] html[data-nav="top"] .flash-nav-chevron { margin-left: 0; margin-right: .35rem; }
  /* a group's items float as a dropdown panel under its toggle */
  html[data-nav="top"] .flash-nav-group > .collapse,
  html[data-nav="top"] .flash-nav-group > .collapsing {
    position: absolute; top: 100%; inset-inline-start: 0;
    min-width: 240px; max-height: 72vh; overflow-y: auto;
    background: var(--fl-sidebar-bg);
    border: 1px solid rgba(255,255,255,.08); border-radius: 10px;
    box-shadow: 0 16px 34px rgba(0,0,0,.4); z-index: 1035; margin-top: 4px;
  }
  html[data-nav="top"] .flash-nav-group-items { padding: .35rem; }
}
@media (max-width: 575.98px) {
  .flash-stat-value { font-size: 1.15rem; }
  .flash-header-inner { padding: 0 .5rem; }
}

/* ───────────────────────────────────────────────────────────
   Legacy alias variables — kept so existing pages that still
   reference --flash-* continue to work. New code should use
   --fl-* tokens above.
   ─────────────────────────────────────────────────────────── */
:root {
  --flash-primary: var(--fl-brand);
  --flash-primary-hover: var(--fl-brand-hover);
  --flash-accent: var(--fl-accent);
  --flash-sidebar-bg: var(--fl-sidebar-bg);
  --flash-sidebar-fg: var(--fl-sidebar-fg);
  --flash-sidebar-hover: var(--fl-sidebar-hover);
  --flash-header-bg: var(--fl-header-bg);
  --flash-header-fg: var(--fl-header-fg);
  --flash-body-bg: var(--fl-bg);
  --flash-card-bg: var(--fl-surface);
  --flash-card-border: var(--fl-border);
  --flash-text: var(--fl-text);
  --flash-text-muted: var(--fl-text-muted);
  --flash-radius: var(--fl-radius);
  --flash-shadow-sm: var(--fl-shadow-sm);
  --flash-shadow: var(--fl-shadow);
  --flash-sidebar-w: var(--fl-sidebar-w);
  --flash-header-h: var(--fl-header-h);
  --flash-transition: var(--fl-transition);
}

/* ── FlashGrid — sort · show/hide · reorder · resize ────────
   All classes are prefixed fg- to avoid collisions.
   ─────────────────────────────────────────────────────────── */
.fg-th {
    position: relative;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
}
.fg-grip {
    cursor: grab;
    color: #adb5bd;
    opacity: .5;
    font-size: .8rem;
    flex-shrink: 0;
    transition: opacity .15s, color .15s;
    line-height: 1;
}
.fg-grip:hover  { opacity: 1; color: var(--fl-brand, #0d6efd); }
.fg-grip:active { cursor: grabbing; }
.fg-lbl  { overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.fg-lbl.fg-s { cursor: pointer; }
.fg-lbl.fg-s:hover { color: var(--fl-brand, #0d6efd); }
.fg-th-sortable { cursor: pointer; }
.fg-th-sortable:hover .fg-lbl { color: var(--fl-brand, #0d6efd); }
/* Arabic cell content — a legible Arabic font, a touch larger, comfortable line
   height, right-aligned. Applied automatically to cells containing Arabic text. */
.fg-ar {
    font-family: "Noto Naskh Arabic", "Segoe UI", "Tahoma", "Dubai", "Geeza Pro", "Arial", sans-serif;
    font-size: 1.08em;
    line-height: 1.7;
    text-align: right;
}
/* keep numeric-aligned cells right-aligned (already are) and don't fight truncation */
.fg-ar.text-truncate { direction: rtl; }

/* Numeric FlashGrid columns (cellClass "num") — centre BOTH header and values,
   overriding any left/right alignment the column's cellClass would otherwise apply. */
td.fg-num, tfoot.fg-foot td.fg-num { text-align: center !important; }
.fg-th.fg-num > div { justify-content: center; }
.fg-th.fg-num .fg-lbl { flex-grow: 0; text-align: center; }

/* Master editor — keep ALL action buttons grouped together on the right.
   Two selectors so it works whether the buttons sit in a .card-footer (most
   masters) or an in-body <div> (Account, Branch, …). The :has() rule is a
   separate statement so older engines that ignore it still keep the footer one.
   Drops the old ms-auto left/right split so the buttons stay together. */
[id$="-editor-card"] .card-footer {
    display: flex; flex-wrap: wrap; gap: .25rem; justify-content: flex-end; align-items: center;
}
[id$="-editor-card"] :has(> [id$="-btn-save"]) {
    display: flex; flex-wrap: wrap; gap: .25rem; justify-content: flex-end; align-items: center;
}
[id$="-editor-card"] .ms-auto { margin-left: 0 !important; }
/* Fixed visual order regardless of markup order: New · Save · Edit · Delete. */
[id$="-editor-card"] [id$="-btn-add"]    { order: 1; }
[id$="-editor-card"] [id$="-btn-save"]   { order: 2; }
[id$="-editor-card"] [id$="-btn-edit"]   { order: 3; }
[id$="-editor-card"] [id$="-btn-delete"] { order: 4; }

/* Brand-accented entry panel — a 3px brand rail on the leading edge + a soft
   brand wash on the header, so every master's editor reads as one system
   (first applied to the Account master; this globalises it to every current and
   future editor card). Page-level #id rules still win where a page needs to
   opt out, e.g. Customer/Supplier drop the border on their mobile full-screen
   editor. */
[id$="-editor-card"] { border-inline-start: 3px solid var(--fl-brand, #0a4d8c); }
[id$="-editor-card"] > .card-header { background: var(--fl-brand-soft, rgba(10, 77, 140, .08)); }

/* Cancelled-document banner — a bold red bar pinned at the top of the page when
   the opened transaction is STATUS='Cancel', so a void document is impossible to
   miss. Injected/removed by FlashUI.cancelledBanner(). */
.fl-cancel-banner {
    display: flex; align-items: center; justify-content: center; gap: .55rem;
    margin: 0 0 .7rem; padding: .55rem 1rem;
    font-weight: 800; letter-spacing: .18em; text-transform: uppercase; font-size: 1rem;
    color: #fff; border-radius: 10px; border: 2px solid #7f1d1d;
    background: repeating-linear-gradient(45deg, #dc2626, #dc2626 14px, #b91c1c 14px, #b91c1c 28px);
    box-shadow: 0 6px 18px rgba(220, 38, 38, .40);
    animation: flCancelPulse 1.8s ease-in-out infinite;
}
.fl-cancel-banner .bi { font-size: 1.3rem; letter-spacing: 0; }
@keyframes flCancelPulse { 0%, 100% { opacity: 1; } 50% { opacity: .74; } }
/* An editor showing a cancelled doc gets a red rail instead of the brand one. */
[id$="-editor-card"].fl-cancelled { border-inline-start-color: #dc2626; }
[id$="-editor-card"].fl-cancelled > .card-header { background: rgba(220, 38, 38, .10); }
@media print {
    .fl-cancel-banner { animation: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

.fg-ico  { font-size: .65rem; flex-shrink: 0; vertical-align: middle; }
.fg-rz {
    position: absolute;
    right: 0; top: 0; bottom: 0;
    width: 5px;
    cursor: col-resize;
    z-index: 1;
    border-radius: 0 2px 2px 0;
    transition: background .15s;
}
.fg-rz:hover,
.fg-rz-on { background: rgba(var(--bs-primary-rgb, 13, 110, 253), .35); }
.fg-drag  { opacity: .3; }
.fg-over  { outline: 2px solid var(--fl-brand, #0d6efd); outline-offset: -2px; }

/* Column picker — custom body-appended popover (repositions on scroll, never
   closes on scroll / scrollbar click). Scrolls internally when the list is long. */
.fg-pick-pop {
    position: fixed; z-index: 2000; min-width: 200px;
    max-height: min(60vh, 380px); overflow-y: auto; overscroll-behavior: contain;
    background: var(--fl-surface); color: var(--fl-text);
    border: 1px solid var(--fl-border); border-radius: 8px; padding: .35rem;
    box-shadow: 0 10px 30px -8px rgba(15,23,42,.35);
}
.fg-pick-item { display: flex; align-items: center; gap: .5rem; cursor: pointer;
    font-size: .82rem; padding: .3rem .5rem; border-radius: 6px; margin: 0; }
.fg-pick-item:hover { background: var(--fl-surface-alt); }
.fg-pick-item .form-check-input { cursor: pointer; flex-shrink: 0; }
.fg-pick-div { border-top: 1px solid var(--fl-divider); margin: .3rem 0; }
.fg-pick-reset { width: 100%; text-align: start; background: none; border: 0; cursor: pointer;
    color: var(--fl-danger); font-size: .82rem; padding: .3rem .5rem; border-radius: 6px; }
.fg-pick-reset:hover { background: var(--fl-surface-alt); }

/* Header funnel icon */
.fg-flt-ico {
    cursor: pointer;
    opacity: .55;
    font-size: .8rem;
    flex-shrink: 0;
    color: var(--fl-text-muted, #6c757d);
    transition: opacity .15s, color .15s, transform .1s;
    padding: 2px 3px;
    border-radius: 3px;
}
.fg-flt-ico:hover      { opacity: 1; background: rgba(var(--bs-primary-rgb, 13, 110, 253), .12); color: var(--fl-brand, #0d6efd); }
.fg-flt-ico.fg-flt-active { opacity: 1; color: var(--fl-brand, #0d6efd); }

/* Filter row in thead */
.fg-flt-row > th {
    background: var(--fl-surface-alt, #f8f9fa);
    padding: 3px 6px;
    border-top: 1px solid var(--fl-border, #e5e7eb);
    font-weight: 400;
}
.fg-flt-cell {
    display: flex; align-items: center; gap: .25rem;
    border: 1px solid var(--fl-border, #d1d5db);
    border-radius: 4px;
    background: #fff;
    padding: .15rem .4rem;
    font-size: .75rem;
    cursor: pointer;
    color: var(--fl-text-muted, #6c757d);
    transition: border-color .15s, background .15s;
    min-height: 24px;
}
.fg-flt-cell:hover { border-color: var(--fl-brand, #0d6efd); background: #fff; color: var(--fl-text, #212529); }
.fg-flt-cell-on    { border-color: var(--fl-brand, #0d6efd); background: rgba(var(--bs-primary-rgb, 13, 110, 253), .08); color: var(--fl-brand, #0d6efd); font-weight: 600; }
.fg-flt-cell-lbl   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
html[data-theme="dark"] .fg-flt-cell { background: #1f2937; color: #cbd5e1; border-color: #374151; }
html[data-theme="dark"] .fg-flt-cell-on { background: rgba(59,130,246,.18); color: #93c5fd; }

/* Filter popover (attached to <body> — must be above everything else).
   Fixed so it follows the column on scroll instead of being dismissed. */
.fg-flt-pop {
    position: fixed;
    z-index: 1080;
    width: 260px;
    max-width: calc(100vw - 16px);
    background: #fff;
    border: 1px solid var(--fl-border, #d1d5db);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    font-size: .82rem;
}
html[data-theme="dark"] .fg-flt-pop { background: #1f2937; border-color: #374151; color: #e5e7eb; }
.fg-flt-pop-hd   { border-bottom: 1px solid var(--fl-border, #e5e7eb); }
.fg-flt-pop-body { max-height: 240px; overflow-y: auto; padding: .25rem 0; }
.fg-flt-pop-ft   { border-top: 1px solid var(--fl-border, #e5e7eb); background: var(--fl-surface-alt, #f8f9fa); border-radius: 0 0 6px 6px; }
html[data-theme="dark"] .fg-flt-pop-hd,
html[data-theme="dark"] .fg-flt-pop-ft { border-color: #374151; background: #111827; }
.fg-flt-item {
    cursor: pointer; padding: .15rem .55rem; margin: 0;
    transition: background .1s;
}
.fg-flt-item:hover { background: rgba(var(--bs-primary-rgb, 13, 110, 253), .08); }
.fg-flt-item-lbl  { font-size: .8rem; line-height: 1.3; }
.fg-flt-item-cnt  { font-size: .65rem; font-weight: 400; }
.fg-flt-all-wrap  { padding-bottom: .15rem; }

/* ── Standard grid toolbar ──────────────────────────────────
   <div class="fg-toolbar"> sits in the grid card-header.
   Layout: title • spacer • search • filter • export group • cols
   ─────────────────────────────────────────────────────────── */
.fg-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}
.fg-toolbar-title {
    display: inline-flex; align-items: center; gap: .35rem;
    font-size: .82rem; font-weight: 600;
    margin-right: auto;
}
.fg-toolbar-actions {
    display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
}
.fg-toolbar-search { width: 220px; max-width: 100%; }
.fg-toolbar-search .input-group-text { padding-left: .55rem; padding-right: .35rem; }
.fg-toolbar-search input { font-size: .82rem; }
.fg-toolbar .btn-group .btn { padding: .2rem .5rem; }
.fg-toolbar .btn          { font-size: .8rem; }
@media (max-width: 575.98px) {
    .fg-toolbar-search { width: 100%; order: 99; }
}

/* ── Print: show only the grid data ─────────────────────────
   Hides the full layout shell so the print button on each
   master-data page outputs only the data grid.
   ─────────────────────────────────────────────────────────── */
@media print {
    .flash-header,
    .flash-sidebar,
    .flash-sidebar-backdrop,
    .flash-footer,
    .flash-toast-stack { display: none !important; }

    .flash-body  { display: block !important; }
    .flash-main  { overflow: visible !important; }

    body,
    .flash-shell,
    .flash-app,
    .flash-body,
    .flash-main,
    .container-fluid { background: #fff !important; }
}

/* ── FlashCustomFields — dynamic custom-field renderer ──────────────
   All classes are prefixed fcf- to avoid collisions.
   ─────────────────────────────────────────────────────────────────── */
.fcf-section {
    margin-top: .75rem;
    border-top: 1px dashed var(--fl-border, #e5e7eb);
    padding-top: .5rem;
}
.fcf-section:first-child { margin-top: .25rem; border-top: none; padding-top: 0; }
.fcf-section-header {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--fl-brand, #0d6efd);
    font-weight: 600;
    margin-bottom: .4rem;
    display: flex; align-items: center;
}
.fcf-section-header-default { color: var(--fl-text-muted, #6c757d); }

.fcf-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: .55rem .85rem;
}
@media (max-width: 991.98px) { .fcf-grid { grid-template-columns: repeat(6, 1fr); } }
@media (max-width: 575.98px) { .fcf-grid { grid-template-columns: 1fr; } .fcf-field { grid-column: span 1 !important; } }

.fcf-field { display: flex; flex-direction: column; min-width: 0; }
.fcf-label  { font-size: .7rem; margin-bottom: .2rem; text-transform: uppercase;
              letter-spacing: .04em; color: var(--fl-text-muted, #6c757d); line-height: 1.1; min-height: 1.1rem; }
.fcf-req    { color: var(--bs-danger); margin-left: 2px; }
.fcf-input  { font-size: .85rem; }
.fcf-help   { font-size: .7rem; margin-top: .15rem; color: var(--fl-text-muted, #6c757d); }
.fcf-switch { padding-top: .35rem; }

/* ── FlashCustomFields v2 — compact, collapsible ──────────────────── */
.fcf-block {
    margin-top: .55rem;
    border: 1px solid var(--fl-border, #e5e7eb);
    border-radius: 6px;
    background: var(--fl-surface, #fff);
    overflow: hidden;
}
.fcf-toggle {
    display: flex; align-items: center; width: 100%;
    background: var(--fl-surface-alt, #f8f9fa);
    border: none;
    padding: .35rem .6rem;
    font-size: .75rem;
    color: var(--fl-text, #212529);
    cursor: pointer;
    text-align: left;
    transition: background .12s;
    gap: .35rem;
}
.fcf-toggle:hover { background: rgba(var(--bs-primary-rgb, 13, 110, 253), .06); }
.fcf-toggle i.bi { color: var(--fl-text-muted, #6c757d); transition: transform .12s; }
.fcf-toggle-lbl { font-weight: 600; letter-spacing: .02em; }
.fcf-toggle-lbl i { margin-right: .25rem; color: var(--fl-brand, #0d6efd); }
.fcf-toggle-cnt {
    background: var(--fl-brand, #0d6efd); color: #fff;
    font-size: .65rem; font-weight: 600;
    padding: .05rem .35rem; border-radius: 8px; margin-left: auto;
}

.fcf-body { padding: .5rem .65rem .55rem; }
.fcf-block.fcf-collapsed .fcf-body { display: none; }

.fcf-subhead {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--fl-brand, #0d6efd); font-weight: 600;
    margin-top: .4rem; margin-bottom: .3rem;
}
.fcf-subhead:first-child { margin-top: 0; }

.fcf-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: .45rem .7rem;
}
@media (max-width: 991.98px) { .fcf-grid { grid-template-columns: repeat(6, 1fr); } }
@media (max-width: 575.98px) { .fcf-grid { grid-template-columns: 1fr; } .fcf-field { grid-column: span 1 !important; } }

.fcf-field  { display: flex; flex-direction: column; min-width: 0; }
.fcf-label  { font-size: .68rem; margin-bottom: .15rem; text-transform: uppercase;
              letter-spacing: .03em; color: var(--fl-text-muted, #6c757d); line-height: 1.1; }
.fcf-req    { color: var(--bs-danger); margin-left: 2px; }
.fcf-input  { font-size: .82rem; padding: .25rem .45rem; }
.fcf-help   { font-size: .65rem; margin-top: .12rem; color: var(--fl-text-muted, #6c757d); }
.fcf-switch { padding-top: .15rem; }

html[data-theme="dark"] .fcf-block { background: #1f2937; border-color: #374151; }
html[data-theme="dark"] .fcf-toggle { background: #111827; color: #e5e7eb; }

/* ===================================================================== *
   FlashActionBar — configurable "⋯" action menu on transaction pages
   (flash-actionbar.js). Theme-aware via the --fl-* variables.
 * ===================================================================== */
.fab-more { position: relative; }
.fab-more > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  width: 31px; height: 31px; border: 1px solid var(--fl-border, #dee2e6); border-radius: .375rem;
  background: var(--fl-surface, #fff); color: var(--fl-text); font-weight: 800; letter-spacing: 1px; line-height: 1;
}
.fab-more > summary::-webkit-details-marker { display: none; }
.fab-more > summary:hover { background: var(--fl-surface-alt, #f8fafc); }
.fab-more[open] > summary { background: var(--fl-brand-soft, rgba(10,77,140,.08)); border-color: var(--fl-brand, #0a4d8c); color: var(--fl-brand, #0a4d8c); }
.fab-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 1100; min-width: 220px;
  background: var(--fl-surface, #fff); border: 1px solid var(--fl-border, #dee2e6); border-radius: .5rem;
  box-shadow: 0 12px 30px -8px rgba(15,23,42,.3); padding: .3rem;
}
[dir="rtl"] .fab-panel { right: auto; left: 0; }
/* a .btn moved into the menu renders as a menu row; moving back restores it */
.fab-panel .btn.fab-in-menu, .fab-item {
  display: flex; align-items: center; gap: .55rem; width: 100%; text-align: left;
  padding: .45rem .6rem; border: 0; background: transparent; border-radius: .35rem;
  font-size: .82rem; font-weight: 600; color: var(--fl-text); cursor: pointer; white-space: nowrap;
}
.fab-panel .btn.fab-in-menu:hover, .fab-item:hover { background: var(--fl-surface-alt, #f8fafc); }
.fab-panel .fab-in-menu i, .fab-item i { color: var(--fl-text-muted); flex: 0 0 auto; }
.fab-panel .btn-group.fab-in-menu { display: flex; padding: .3rem .4rem; background: transparent; border: 0; width: 100%; }
.fab-sep { border-top: 1px solid var(--fl-divider, #eef2f7); margin: .3rem 0; }
.fab-cfg-title { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--fl-text-muted); font-weight: 700; padding: .3rem .4rem .35rem; }
.fab-cfg-row { display: flex; align-items: center; gap: .5rem; padding: .3rem .45rem; font-size: .82rem; color: var(--fl-text); cursor: pointer; border-radius: .35rem; margin: 0; }
.fab-cfg-row:hover { background: var(--fl-surface-alt, #f8fafc); }
.fab-cfg-row .form-check-input { margin: 0; flex: 0 0 auto; }
.fab-cfg-foot { display: flex; justify-content: space-between; gap: .5rem; padding: .45rem .3rem .15rem; }

/* ===================================================================== *
   FlashCombo — searchable <select> (type-to-filter combobox)
 * ===================================================================== */
.fc-combo { position: relative; }
.fc-input { cursor: text; }
/* a caret hint on the right, like a native select */
.fc-combo::after { content: ''; position: absolute; top: 50%; inset-inline-end: .6rem; width: .5rem; height: .5rem;
    transform: translateY(-70%) rotate(45deg); border-right: 1.5px solid var(--fl-text-muted, #6c757d);
    border-bottom: 1.5px solid var(--fl-text-muted, #6c757d); pointer-events: none; opacity: .7; }
.fc-combo .fc-input { padding-inline-end: 1.4rem; }
.fc-drop { position: absolute; z-index: 1086; top: 100%; inset-inline: 0; margin-top: 2px;
    background: var(--fl-surface, #fff); border: 1px solid var(--fl-border, #d1d5db); border-radius: .35rem;
    max-height: 280px; overflow-y: auto; box-shadow: 0 6px 16px rgba(0, 0, 0, .18); }
.fc-opt { padding: .35rem .6rem; cursor: pointer; font-size: .8rem; border-bottom: 1px solid var(--fl-border-light, #f1f3f5);
    color: var(--fl-text, #212529); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-opt:last-child { border-bottom: 0; }
.fc-opt:hover, .fc-opt.active { background: var(--fl-surface-alt, #eef2f7); }
.fc-opt.sel { font-weight: 600; color: var(--fl-brand, #0d6efd); }
.fc-opt.fc-empty { color: var(--fl-text-muted, #6c757d); cursor: default; }
html[data-theme="dark"] .fc-drop, html[data-theme="dark"] .fc-opt { background: #1f2630; color: var(--fl-border); border-color: #343a40; }
html[data-theme="dark"] .fc-opt:hover, html[data-theme="dark"] .fc-opt.active { background: #2b3744; color: #fff; }

/* ===================================================================== *
   FlashCustomerPopup — modal iframe hosting the Customer master editor
   (flash-custpopup.js). Above the mobile sidebar (1090).
 * ===================================================================== */
.fcp-overlay { position: fixed; inset: 0; z-index: 1100; background: rgba(10, 18, 34, .45);
               backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
               display: flex; align-items: center; justify-content: center; padding: 16px;
               animation: fcpFade .18s ease; }
.fcp-overlay.fcp-out { opacity: 0; transition: opacity .15s ease; }
.fcp-dialog { width: min(1080px, 96vw); height: auto; max-height: 92vh;
              background: var(--fl-surface, #fff); border: 1px solid var(--fl-border, #e5e7eb);
              border-radius: 16px; box-shadow: 0 24px 70px rgba(2, 8, 20, .4);
              display: flex; flex-direction: column; overflow: hidden;
              animation: fcpUp .22s cubic-bezier(.2, .9, .3, 1.15); }
.fcp-head { display: flex; align-items: center; gap: .6rem; padding: .65rem 1rem; flex: 0 0 auto;
            border-bottom: 1px solid var(--fl-border, #e5e7eb);
            background: var(--fl-brand-soft, rgba(10, 77, 140, .07)); }
.fcp-ico { width: 32px; height: 32px; border-radius: 10px; flex: 0 0 auto;
           background: var(--fl-brand, #0a4d8c); color: #fff; font-size: 1rem;
           display: inline-flex; align-items: center; justify-content: center; }
.fcp-title { font-weight: 700; font-size: .95rem; color: var(--fl-text, #1e293b); }
.fcp-close { margin-inline-start: auto; }
/* Height is set by flash-custpopup.js to match the iframe's content (no dead
   space below the editor); the transition smooths custom-field expand/collapse. */
.fcp-frame { flex: 0 1 auto; border: 0; width: 100%; height: 340px; min-height: 120px;
             background: var(--fl-surface, #fff); transition: height .18s ease; }
@keyframes fcpFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fcpUp { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
@media (max-width: 575.98px) {
    .fcp-overlay { padding: 0; }
    .fcp-dialog { width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0; }
    .fcp-frame { flex: 1 1 auto; height: auto !important; }   /* fullscreen — ignore JS sizing */
}
html[data-theme="dark"] .fcp-overlay { background: rgba(0, 0, 0, .55); }

/* ===================================================================== *
   Dashboard widget polish (shared by login dashboard + designer)
 * ===================================================================== */
/* Colourful KPI cards — flash-dash.js injects the gradient bg + accent inline */
.dw-body:has(> .dw-kpi) { padding: 0; }
.dw-kpi { gap: .3rem; text-align: center; padding: .5rem .6rem; }
.dw-kpi-v { font-family: var(--bs-font-monospace); font-weight: 800; line-height: 1;
            letter-spacing: -.5px; font-size: clamp(1.35rem, 4.5vw, 2.1rem); }
.dw-kpi-l { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
            color: var(--fl-text-muted, #6c757d); margin-top: .1rem; }

/* Dashboard widget tables — same comfortable density as the app grids */
.dw-tbl { width: 100%; font-size: .85rem; line-height: 1.5; border-collapse: collapse; }
.dw-tbl th, .dw-tbl td { padding: .5rem .6rem; vertical-align: middle; }
.dw-tbl th { font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .02em;
             color: var(--fl-text-muted); border-bottom: 1px solid var(--fl-border); }
/* Zebra + hover for widget tables */
.dw-tbl tbody tr:nth-child(even) td { background: rgba(2, 6, 23, .025); }
.dw-tbl tbody tr:hover td { background: rgba(79, 70, 229, .08);
    background: color-mix(in srgb, var(--dash-accent, #4f46e5) 9%, transparent); }
html[data-theme="dark"] .dw-tbl tbody tr:nth-child(even) td { background: rgba(148, 163, 184, .06); }

/* ===================================================================== *
   Shared UX toolkit — grid states, status pills, row actions,
   command palette (flash-cmdk.js), form busy spinner
 * ===================================================================== */

/* ---- FlashGrid: skeleton loading rows ---- */
.fg-skel-row td { padding: .5rem .55rem !important; }
.fg-skel { display:block; height:.7rem; border-radius:.35rem;
    background:linear-gradient(90deg, var(--fl-surface-alt,#eef1f5) 25%, var(--fl-border,#e2e6ec) 37%, var(--fl-surface-alt,#eef1f5) 63%);
    background-size:400% 100%; animation:flShimmer 1.2s ease infinite; }
@keyframes flShimmer { 0%{background-position:100% 0} 100%{background-position:-100% 0} }
html[data-theme="dark"] .fg-skel { background:linear-gradient(90deg,#283242 25%,#374151 37%,#283242 63%); background-size:400% 100%; }

/* ---- FlashGrid: empty state ---- */
.fg-empty-cell { padding:0 !important; }
.fg-empty { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:.4rem; padding:2.2rem 1rem; color:var(--fl-text-muted,#6b7280); }
.fg-empty-ic { font-size:2rem; opacity:.5; }
.fg-empty-t  { font-size:.9rem; font-weight:500; }

/* ---- FlashGrid: info bar (count + active-filter chips) ---- */
.fg-infobar { display:flex; flex-wrap:wrap; align-items:center; gap:.4rem; margin:.15rem 0 .5rem; min-height:1.5rem; font-size:.78rem; }
.fg-info-count { color:var(--fl-text-muted,#6b7280); }
.fg-chip { display:inline-flex; align-items:center; gap:.3rem; padding:.1rem .25rem .1rem .5rem; border-radius:999px;
    background:var(--fl-brand-soft,#e7f0fb); color:var(--fl-brand,#0a4d8c); font-weight:500; }
.fg-chip button { border:0; background:transparent; color:inherit; font-size:1rem; line-height:1; cursor:pointer; padding:0 .25rem; opacity:.7; }
.fg-chip button:hover { opacity:1; }
.fg-chip-clear { border:0; background:transparent; color:var(--fl-danger,#dc2626); font-size:.76rem; cursor:pointer; text-decoration:underline; }

/* ---- Status pills (FlashGrid.pill / .fl-pill) ---- */
.fl-pill { display:inline-block; padding:.12rem .55rem; border-radius:999px; font-size:.72rem; font-weight:600; line-height:1.4; white-space:nowrap; }
.fl-pill-success { background:rgba(22,163,74,.14);  color:#15803d; }
.fl-pill-warning { background:rgba(245,158,11,.16); color:#b45309; }
.fl-pill-danger  { background:rgba(220,38,38,.14);  color:#b91c1c; }
.fl-pill-info    { background:rgba(8,145,178,.14);  color:#0e7490; }
.fl-pill-primary { background:var(--fl-brand-soft,#e7f0fb); color:var(--fl-brand,#0a4d8c); }
.fl-pill-neutral { background:rgba(100,116,139,.16); color:#475569; }
html[data-theme="dark"] .fl-pill-success { color:#4ade80; } html[data-theme="dark"] .fl-pill-warning { color:#fbbf24; }
html[data-theme="dark"] .fl-pill-danger  { color:#f87171; } html[data-theme="dark"] .fl-pill-info    { color:#22d3ee; }
html[data-theme="dark"] .fl-pill-neutral { color:#cbd5e1; }

/* ---- Row hover actions (reveal edit/delete on row hover) ---- */
.fl-row-actions { display:inline-flex; gap:.15rem; opacity:0; transition:opacity .12s ease; }
tr:hover .fl-row-actions, tr.table-primary .fl-row-actions { opacity:1; }
@media (hover:none) { .fl-row-actions { opacity:1; } }   /* always visible on touch */
.fl-row-actions .btn { --bs-btn-padding-y:.05rem; --bs-btn-padding-x:.35rem; font-size:.78rem; }

/* ---- Command palette (flash-cmdk.js) ---- */
.fl-cmdk { position:fixed; inset:0; z-index:2100; display:none; padding-top:12vh;
    background:rgba(15,23,42,.45); backdrop-filter:blur(2px); }
.fl-cmdk.show { display:block; }
.fl-cmdk-box { width:min(620px,92vw); margin:0 auto; background:var(--fl-surface,#fff);
    border:1px solid var(--fl-border,#e5e7eb); border-radius:14px; overflow:hidden;
    box-shadow:0 24px 60px -12px rgba(15,23,42,.45); animation:flCmdkIn .12s ease; }
@keyframes flCmdkIn { from{ transform:translateY(-8px); opacity:.6 } to{ transform:none; opacity:1 } }
.fl-cmdk-head { display:flex; align-items:center; gap:.6rem; padding:.7rem .9rem; border-bottom:1px solid var(--fl-border,#e5e7eb); }
.fl-cmdk-head .bi-search { color:var(--fl-text-muted,#6b7280); font-size:1.05rem; }
.fl-cmdk-input { flex:1; border:0; outline:0; background:transparent; font-size:1rem; color:var(--fl-text,#1f2937); }
.fl-cmdk-esc { font-size:.68rem; color:var(--fl-text-muted,#6b7280); border:1px solid var(--fl-border,#e5e7eb); border-radius:.35rem; padding:.05rem .35rem; }
.fl-cmdk-list { max-height:50vh; overflow:auto; padding:.35rem; }
.fl-cmdk-item { display:flex; align-items:center; gap:.6rem; padding:.5rem .65rem; border-radius:9px;
    color:var(--fl-text,#1f2937); text-decoration:none; cursor:pointer; }
.fl-cmdk-item .bi { color:var(--fl-brand,#0a4d8c); width:1.1rem; text-align:center; flex:0 0 auto; }
.fl-cmdk-item.active { background:var(--fl-brand-soft,#e7f0fb); }
.fl-cmdk-lbl { flex:1; font-size:.9rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.fl-cmdk-grp { font-size:.7rem; color:var(--fl-text-muted,#6b7280); background:var(--fl-surface-alt,#f3f4f6); border-radius:999px; padding:.05rem .5rem; flex:0 0 auto; }
.fl-cmdk-empty { padding:1.5rem; text-align:center; color:var(--fl-text-muted,#6b7280); font-size:.88rem; }
.fl-cmdk-foot { display:flex; gap:1rem; padding:.45rem .9rem; border-top:1px solid var(--fl-border,#e5e7eb);
    font-size:.7rem; color:var(--fl-text-muted,#6b7280); }
.fl-cmdk-foot kbd { background:var(--fl-surface-alt,#f3f4f6); border:1px solid var(--fl-border,#e5e7eb); border-radius:.3rem; padding:0 .3rem; color:inherit; }
html[data-theme="dark"] .fl-cmdk-box { background:#1f2937; border-color:#374151; }
html[data-theme="dark"] .fl-cmdk-item { color:#e5e7eb; }

/* ---- Header search trigger (opens the command palette) ---- */
.flash-cmdk-trigger { display:inline-flex; align-items:center; gap:.45rem; height:34px; padding:0 .6rem;
    border:1px solid var(--fl-header-border, rgba(255,255,255,.25)); border-radius:8px;
    background:rgba(255,255,255,.10); color:var(--fl-header-fg,#fff); font-size:.82rem; cursor:pointer;
    min-width:180px; transition:background .15s ease; }
.flash-cmdk-trigger:hover { background:rgba(255,255,255,.18); }
.flash-cmdk-trigger span { opacity:.85; }
.flash-cmdk-trigger kbd { margin-inline-start:auto; font-size:.66rem; background:rgba(255,255,255,.18);
    border-radius:.3rem; padding:.05rem .35rem; color:inherit; }

/* ============================================================
   Processing / loading indicator — animated FLASH logo GIF.
   Use via the .fl-proc utility or window.FlashProcessing (flash-processing.js).
   ============================================================ */
:root { --fl-proc-img: url('/images/processing-logo.gif'); }
.fl-proc { display:inline-block; vertical-align:middle; background:var(--fl-proc-img) center/contain no-repeat; }
.fl-proc-xs { width:16px;  height:16px; }
.fl-proc-sm { width:22px;  height:22px; }
.fl-proc-md { width:42px;  height:42px; }
.fl-proc-lg { width:72px;  height:72px; }
.fl-proc-xl { width:120px; height:120px; }
/* inside a button: scale to the text size */
.btn .fl-proc { width:1.15em; height:1.15em; }

.fl-proc-overlay {
    position:absolute; inset:0; z-index:1200;
    display:flex; flex-direction:column; align-items:center; justify-content:center; gap:.55rem;
    background:rgba(255,255,255,.72); backdrop-filter:blur(1.5px); -webkit-backdrop-filter:blur(1.5px);
    border-radius:inherit;
}
.fl-proc-overlay.fl-proc-fixed { position:fixed; }
.fl-proc-overlay .fl-proc { width:84px; height:84px; }
.fl-proc-overlay .fl-proc-text { font-size:.85rem; font-weight:600; color:var(--fl-text-muted,#6c757d); letter-spacing:.02em; }
[data-bs-theme="dark"] .fl-proc-overlay { background:rgba(18,22,28,.72); }

/* ═══════════════════════════════════════════════════════════════════
   PHASE 0 — UI foundations: density, accessibility, motion
   ═══════════════════════════════════════════════════════════════════ */

/* Density: drive table-cell padding from the token so Comfortable/Compact
   apply everywhere a .table is used (FlashGrid, line grids, reports). */
.table > :not(caption) > * > * {
  padding: var(--fl-cell-pad-y) var(--fl-cell-pad-x);
}

/* COMPACT — tighter rows, controls and base font for power users. */
html[data-density="compact"] {
  --fl-cell-pad-y:    .2rem;
  --fl-cell-pad-x:    .45rem;
  --fl-control-pad-y: .2rem;
  --fl-control-pad-x: .5rem;
  --fl-ui-font:       .82rem;
  --fl-row-gap:       .35rem;
}
html[data-density="compact"] .form-control,
html[data-density="compact"] .form-select,
html[data-density="compact"] .form-control-sm,
html[data-density="compact"] .form-select-sm {
  padding-top: var(--fl-control-pad-y);
  padding-bottom: var(--fl-control-pad-y);
  font-size: var(--fl-ui-font);
  min-height: calc(1.2em + (2 * var(--fl-control-pad-y)) + 2px);
}
html[data-density="compact"] .btn-sm { padding: var(--fl-control-pad-y) var(--fl-control-pad-x); }
html[data-density="compact"] .container-fluid.py-3 { padding-top: .5rem !important; padding-bottom: .5rem !important; }
html[data-density="compact"] .card-body { padding: .65rem .75rem; }
html[data-density="compact"] .flash-nav-link,
html[data-density="compact"] .flash-nav-group-toggle { padding: .4rem .6rem; font-size: .85rem; }

/* ── Compact mode: re-size MASTER editor fields by control type ───────────────
   Scope: any [id$="-editor-card"] EXCEPT the Item master (#it-editor-card), so
   transaction forms and Item are untouched. Even-family spans (2 / 4 / 10) keep
   every field edge on a shared column line → controls stay aligned across rows
   and never straddle. Tune any field with .fl-narrow / .fl-mid / .fl-wide.
   See docs/UI_FORM_GUIDE.md → "Density (Comfortable / Compact)". ───────────── */
html[data-density="compact"] [id$="-editor-card"]:not(#it-editor-card) .fl-form-grid .fl-field { grid-column: span 2; }                       /* number / date / dropdown / short text */
html[data-density="compact"] [id$="-editor-card"]:not(#it-editor-card) .fl-form-grid .fl-field:has(input[maxlength="250"]) { grid-column: span 4; }  /* names / longer text */
/* Full-row + explicit overrides use !important: the :has(maxlength) heuristic above
   is MORE specific than [id$="-rem"]/.fl-* and would otherwise win. */
html[data-density="compact"] [id$="-editor-card"]:not(#it-editor-card) .fl-form-grid .fl-field:has(textarea),
html[data-density="compact"] [id$="-editor-card"]:not(#it-editor-card) .fl-form-grid .fl-field:has([id$="-rem"]),
html[data-density="compact"] [id$="-editor-card"]:not(#it-editor-card) .fl-form-grid .fl-field.fl-wide   { grid-column: span 10 !important; }  /* remarks / notes / address → own full row */
html[data-density="compact"] [id$="-editor-card"]:not(#it-editor-card) .fl-form-grid .fl-field.fl-narrow { grid-column: span 2 !important; }
html[data-density="compact"] [id$="-editor-card"]:not(#it-editor-card) .fl-form-grid .fl-field.fl-mid    { grid-column: span 4 !important; }
/* Uniform responsive collapse (no ragged mix): 2-per-row on tablets, 1 on phones.
   !important so these beat the more-specific desktop :has() rules above. */
@media (max-width: 767.98px) {
  html[data-density="compact"] [id$="-editor-card"]:not(#it-editor-card) .fl-form-grid .fl-field { grid-column: span 5 !important; }
  html[data-density="compact"] [id$="-editor-card"]:not(#it-editor-card) .fl-form-grid .fl-field:has(textarea),
  html[data-density="compact"] [id$="-editor-card"]:not(#it-editor-card) .fl-form-grid .fl-field:has([id$="-rem"]),
  html[data-density="compact"] [id$="-editor-card"]:not(#it-editor-card) .fl-form-grid .fl-field.fl-wide { grid-column: span 10 !important; }
}
@media (max-width: 575.98px) {
  html[data-density="compact"] [id$="-editor-card"]:not(#it-editor-card) .fl-form-grid .fl-field { grid-column: span 10 !important; }
}

/* Accessibility: clear keyboard focus ring (only on keyboard nav, not mouse). */
:focus-visible {
  outline: 2px solid var(--fl-brand);
  outline-offset: 2px;
  border-radius: var(--fl-radius-sm);
}
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
.dropdown-item:focus-visible,
.flash-nav-link:focus-visible,
.flash-nav-group-toggle:focus-visible {
  outline: 2px solid var(--fl-brand);
  outline-offset: 1px;
}
/* Don't double up: mouse focus keeps Bootstrap's shadow, keyboard adds the ring. */
.btn:focus:not(:focus-visible),
.form-control:focus:not(:focus-visible) { outline: none; }

/* Respect users who prefer less motion (also calms the processing spinner). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   PHASE 1 — Shared components (form grid · states · skeletons)
   Use on any page; no per-page CSS needed.
   ═══════════════════════════════════════════════════════════════════ */

/* ---- Form grid: 10-col, density-aware gap, stacks on phones ----
   THE RULE: 10 equal columns. Each control spans whole columns (fl-c1..fl-c10);
   every row must total 10 and controls must not overlap (see docs/UI_FORM_GUIDE). */
.fl-form-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: var(--fl-row-gap) .8rem;
  align-items: end;
}
.fl-field { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.fl-field > label {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .02em;
  color: var(--fl-label); font-weight: 600; margin: 0;
}
.fl-field > label .req { color: var(--fl-danger); margin-inline-start: 2px; }

/* ── Form captions — ONE source of truth, app-wide ─────────────────────────
   Every field/filter <label> caption reads at one consistent strength on every
   page, so individual pages never need to set label colour/weight again.
   • !important: page <style> blocks load AFTER this file (_Layout), so they'd
     otherwise win — this guarantees the central style applies everywhere.
   • Only colour + weight are enforced; pages keep their own font-size (dense
     transaction grids stay compact).
   • Targets <label> ELEMENTS only, so decorative *-stat-label / *-cell-label
     DIVS are untouched; checkbox/switch/button text is excluded.
   • The .req asterisk keeps its own colour (set directly on the child span). */
.flash-main label:not(.form-check-label):not(.btn):not(.btn-check):not(.form-label-static) {
  color: var(--fl-label) !important;
  font-weight: 600 !important;
}
.fl-c1{grid-column:span 1}.fl-c2{grid-column:span 2}.fl-c3{grid-column:span 3}
.fl-c4{grid-column:span 4}.fl-c5{grid-column:span 5}.fl-c6{grid-column:span 6}
.fl-c7{grid-column:span 7}.fl-c8{grid-column:span 8}.fl-c9{grid-column:span 9}
.fl-c10{grid-column:span 10}
/* Tablet: collapse to a 2-up grid; phone: single column. Spans only apply ≥992px. */
@media (max-width: 991.98px){
  .fl-form-grid{ grid-template-columns: repeat(2, minmax(0,1fr)); }
  .fl-form-grid > [class*="fl-c"]{ grid-column: span 1; }
}
@media (max-width: 575.98px){
  .fl-form-grid{ grid-template-columns: 1fr; }
  .fl-form-grid > [class*="fl-c"]{ grid-column: 1 / -1 !important; }
}

/* ---- Empty / no-results / no-permission state ---- */
.fl-empty { text-align: center; color: var(--fl-text-muted); padding: 2rem 1rem; }
.fl-empty .fl-empty-ico, .fl-empty > i { font-size: 2rem; opacity: .5; display: block; margin-bottom: .4rem; }
.fl-empty .fl-empty-title { font-weight: 600; color: var(--fl-text); }
.fl-empty .fl-empty-hint { font-size: .85rem; margin-top: .15rem; }
.fl-empty .fl-empty-action { margin-top: .7rem; }

/* ---- Generic skeleton shimmer (use anywhere, not just grids) ---- */
.fl-skel {
  position: relative; overflow: hidden;
  background: var(--fl-divider);
  border-radius: var(--fl-radius-sm);
  min-height: 1em;
}
.fl-skel::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent);
  animation: flSkel 1.2s infinite;
}
[data-bs-theme="dark"] .fl-skel::after {
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.08), transparent);
}
.fl-skel-text { height: .8em; margin: .3rem 0; }
.fl-skel-text.w-60 { width: 60%; } .fl-skel-text.w-40 { width: 40%; } .fl-skel-text.w-80 { width: 80%; }
@keyframes flSkel { 100% { transform: translateX(100%); } }

/* ═══════════════════════════════════════════════════════════════════
   PHASE 2 — FlashGrid polish (sticky col · totals) + keyboard legend
   ═══════════════════════════════════════════════════════════════════ */

/* ---- Sticky first column (opt-in: stickyFirst:true) ---- */
.fg-sticky-first > thead > tr > th:first-child,
.fg-sticky-first > tbody > tr > td:first-child,
.fg-sticky-first > tfoot > tr > td:first-child {
  position: sticky; left: 0; z-index: 2;
  box-shadow: 1px 0 0 var(--fl-border);
}
.fg-sticky-first > thead > tr > th:first-child { background: var(--fl-grid-head); z-index: 3; }
.fg-sticky-first > tbody > tr > td:first-child { background: var(--fl-grid-row); }
.fg-sticky-first > tbody > tr.table-primary > td:first-child { background: var(--fl-brand-soft); }
.fg-sticky-first > tfoot > tr > td:first-child { background: var(--fl-grid-head); }

/* ---- Column totals footer (opt-in: col.total) ---- */
.table > tfoot.fg-foot > tr > td {
  position: sticky; bottom: 0;
  background: var(--fl-grid-head);
  font-weight: 600;
  border-top: 2px solid var(--fl-border-strong);
}
.fg-foot-label { color: var(--fl-text-muted); text-transform: uppercase; font-size: .7rem; letter-spacing: .04em; }

/* ---- Keyboard-shortcut legend ("?" overlay) ---- */
.fl-keys-overlay {
  position: fixed; inset: 0; z-index: 2100;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.fl-keys-modal { width: min(460px, 100%); max-height: 85vh; overflow: auto; border: 1px solid var(--fl-border); background: var(--fl-surface); }
.fl-keys-hd { display: flex; align-items: center; gap: .4rem; font-weight: 600; padding: .7rem .9rem; border-bottom: 1px solid var(--fl-border); }
.fl-keys-body { padding: .35rem .9rem; }
.fl-keys-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 1px solid var(--fl-divider); }
.fl-keys-row:last-child { border-bottom: 0; }
.fl-keys-desc { font-size: .85rem; color: var(--fl-text); }
.fl-keys-combo { display: flex; align-items: center; gap: .2rem; flex-shrink: 0; }
.fl-keys-plus { font-size: .7rem; color: var(--fl-text-subtle); }
.fl-keys-ft { padding: .5rem .9rem; border-top: 1px solid var(--fl-border); }
.fl-keys-combo kbd, .fl-keys-ft kbd {
  background: var(--fl-surface-alt); color: var(--fl-text);
  border: 1px solid var(--fl-border-strong); border-bottom-width: 2px; border-radius: 4px;
  padding: .08rem .4rem; font-size: .72rem; font-family: var(--bs-font-monospace); line-height: 1.4;
}

/* ---- Grid fills the viewport when the collapsible editor is hidden ----
   The grid's .table-responsive normally has an inline max-height (e.g. 520px).
   When the editor card ([id$="-editor-card"]) is [hidden], let the list grow to
   use the freed vertical space; it snaps back to its inline height on open. */
[id$="-editor-card"][hidden] ~ .card .fg-toolbar + .table-responsive {
  max-height: calc(100vh - var(--fl-header-h) - 9.5rem) !important;
  min-height: 240px;
}

/* ============================================================================
   System dashboard widgets — Daily Quote / My Notices / My Notes (.fhw-*).
   Rendered inside dashboard tiles (.dw-body provides the vertical scrollbar).
   Theme-aware via the --fl-* tokens.
   ============================================================================ */
.fhw-quote {
  min-height: 100%; border-radius: 10px; padding: .85rem 1rem; color: #fff; position: relative;
  background: linear-gradient(120deg, var(--dash-accent, #4f46e5), var(--dash-accent-2, #06b6d4));
  display: flex; flex-direction: column; justify-content: center;
}
.fhw-q-ic { font-size: 1.4rem; opacity: .85; margin-bottom: .25rem; }
.fhw-q-text { font-size: 1rem; font-weight: 600; line-height: 1.5; }
.fhw-q-author { font-size: .8rem; opacity: .85; margin-top: .4rem; }
.fhw-q-kind { position: absolute; top: .45rem; right: .6rem; font-size: .58rem; text-transform: uppercase; letter-spacing: .08em; opacity: .8; }

.fhw-notices { display: flex; flex-direction: column; gap: .5rem; }
.fhw-ntc { border: 1px solid var(--fl-border, #e5e7eb); border-radius: 8px; padding: .5rem .65rem; background: var(--fl-surface, #fff); }
.fhw-ntc.high { border-color: #f59e0b; background: rgba(245, 158, 11, .06); }
.fhw-ntc-title { font-weight: 600; font-size: .85rem; display: flex; align-items: center; gap: .35rem; }
.fhw-ntc-meta { font-size: .68rem; color: var(--fl-text-muted); margin: .1rem 0 .3rem; }
.fhw-ntc-body { font-size: .82rem; white-space: pre-wrap; word-break: break-word; }
.fhw-ntc-act { text-align: right; margin-top: .35rem; }
.fhw-badge-high { font-size: .58rem; background: #f59e0b; color: #fff; padding: .03rem .35rem; border-radius: 8px; }
.fhw-ntc-ack { margin-top: .45rem; }
.fhw-ack-remark { width: 100%; border: 1px solid var(--fl-border, #d1d5db); border-radius: 6px; padding: .25rem .5rem; font-size: .8rem; resize: vertical; min-height: 32px; background: var(--fl-surface, #fff); color: inherit; }
.fhw-ack-row { display: flex; align-items: center; gap: .5rem; margin-top: .35rem; }
.fhw-ack-err { color: #b91c1c; font-size: .72rem; flex: 1; }

.fhw-notes { display: flex; flex-direction: column; height: 100%; }
.fhw-notes-add { display: flex; gap: .4rem; margin-bottom: .4rem; }
.fhw-notes-add .fhw-note-input { flex: 1; border: 1px solid var(--fl-border, #d1d5db); border-radius: 6px; padding: .25rem .5rem; font-size: .82rem; background: var(--fl-surface, #fff); color: inherit; }
.fhw-notes-list { list-style: none; margin: 0; padding: 0; }
.fhw-note { display: flex; align-items: center; gap: .5rem; padding: .28rem .35rem; border-radius: 6px; font-size: .83rem; }
.fhw-note:hover { background: var(--fl-surface-alt, #f6f8fb); }
.fhw-note.done .fhw-note-text { text-decoration: line-through; color: var(--fl-text-muted); }
.fhw-note-text { flex: 1; min-width: 0; word-break: break-word; }
.fhw-note-x { color: #b91c1c; cursor: pointer; opacity: .55; }
.fhw-note-x:hover { opacity: 1; }
.fhw-notes-empty { color: var(--fl-text-muted); font-size: .8rem; padding: .4rem .35rem; list-style: none; }
html[data-theme="dark"] .fhw-ntc { background: #1f2937; border-color: #374151; }

/* AR/AP aging dashboard tile */
.fhw-aging { display: flex; flex-direction: column; gap: .45rem; height: 100%; }
.fhw-ag-total { display: flex; flex-direction: column; }
.fhw-ag-total .l { font-size: .6rem; text-transform: uppercase; letter-spacing: .04em; color: var(--fl-text-muted); }
.fhw-ag-total .v { font-size: 1.35rem; font-weight: 800; font-family: var(--bs-font-monospace); color: var(--dash-accent, #0d6efd); line-height: 1.1; }
.fhw-ag-buckets { display: flex; flex-wrap: wrap; gap: .3rem; }
.fhw-ag-buckets .chip { font-size: .64rem; padding: .1rem .4rem; border-radius: 999px; background: var(--fl-surface-alt, #f1f5f9); border: 1px solid var(--fl-border, #e5e7eb); white-space: nowrap; }
.fhw-ag-buckets .chip.a { color: #a16207; } .fhw-ag-buckets .chip.b { color: #c2410c; } .fhw-ag-buckets .chip.d { color: #b91c1c; font-weight: 700; }
.fhw-ag-list { flex: 1; overflow: auto; min-height: 0; }
.fhw-ag-list .r { display: flex; justify-content: space-between; gap: .5rem; padding: .18rem .1rem; border-bottom: 1px solid var(--fl-border-light, #f1f3f5); font-size: .78rem; }
.fhw-ag-list .r .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fhw-ag-list .r .t { font-family: var(--bs-font-monospace); font-weight: 600; }

/* ── Business Pulse (SQL-driven KPI hero) ── */
.fhw-pulse { display: flex; flex-direction: column; gap: .55rem; height: 100%; min-height: 0; }
.fhw-pl-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem; }
.fhw-pl-tile { position: relative; border: 1px solid var(--fl-border, #e5e7eb); border-radius: .55rem;
  padding: .5rem .6rem .35rem; background: linear-gradient(135deg, color-mix(in srgb, var(--pl, #6366f1) 12%, transparent), transparent);
  border-top: 3px solid var(--pl, #6366f1); overflow: hidden; }
.fhw-pl-top { display: flex; align-items: center; gap: .35rem; margin-bottom: .15rem; }
.fhw-pl-ic { color: var(--pl, #6366f1); font-size: .9rem; display: inline-flex; }
.fhw-pl-title { font-size: .66rem; text-transform: uppercase; letter-spacing: .03em; color: var(--fl-text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fhw-pl-err { color: #b91c1c; margin-inline-start: auto; font-size: .8rem; }
.fhw-pl-val { font-size: 1.5rem; font-weight: 800; font-family: var(--bs-font-monospace); line-height: 1.05;
  color: var(--fl-text); }
.fhw-pl-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: .4rem; margin-top: .2rem; height: 36px; }
.fhw-pl-delta { font-size: .68rem; font-weight: 700; display: inline-flex; align-items: center; white-space: nowrap; }
.fhw-pl-delta.up { color: #15803d; } .fhw-pl-delta.dn { color: #b91c1c; }
.fhw-pl-spark { width: 130px; max-width: 60%; height: 36px; flex: 0 0 auto; margin-inline-start: auto; }
/* live activity feed */
.fhw-pl-feed { flex: 1; min-height: 0; overflow: auto; border-top: 1px solid var(--fl-border-light, #f1f3f5); padding-top: .35rem; }
.fhw-pl-feed-h { font-size: .64rem; text-transform: uppercase; letter-spacing: .04em; color: var(--fl-text-muted);
  display: flex; align-items: center; gap: .4rem; margin-bottom: .25rem; }
.fhw-pl-live { display: inline-flex; align-items: center; gap: .25rem; color: #15803d; font-weight: 700; }
.fhw-pl-live .dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 0 rgba(34,197,94,.6);
  animation: fhw-pulse-dot 1.6s infinite; }
@keyframes fhw-pulse-dot { 0% { box-shadow: 0 0 0 0 rgba(34,197,94,.55); } 70% { box-shadow: 0 0 0 7px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }
.fhw-pl-feed-row { display: grid; grid-template-columns: auto 1fr auto; gap: .5rem; align-items: baseline;
  padding: .16rem .1rem; border-bottom: 1px solid var(--fl-border-light, #f1f3f5); font-size: .76rem; }
.fhw-pl-feed-row .w { color: var(--fl-text-muted); font-size: .68rem; white-space: nowrap; }
.fhw-pl-feed-row .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fhw-pl-feed-row .a { font-family: var(--bs-font-monospace); font-weight: 600; white-space: nowrap; }
@media print { .fhw-pl-live .dot { animation: none; } }

/* ── utility dashboard widgets (FX / prayer / clock / calc / units / links / translate) ── */
.fhw-fx, .fhw-unit, .fhw-tr { display: flex; flex-direction: column; gap: .4rem; }
.fhw-fx-row, .fhw-unit-row { display: flex; gap: .4rem; align-items: stretch; }
.fhw-fx input, .fhw-fx select, .fhw-unit input, .fhw-unit select, .fhw-tr select, .fhw-tr textarea {
    border: 1px solid var(--fl-border, #d1d5db); border-radius: 6px; padding: .25rem .45rem; font-size: .82rem; background: var(--fl-surface, #fff); color: inherit; }
.fhw-fx-amt, .fhw-unit-amt { flex: 1; min-width: 0; }
.fhw-fx-from, .fhw-fx-to, .fhw-unit-from, .fhw-unit-to { width: 86px; }
.fhw-fx-out, .fhw-unit-out { flex: 1; display: flex; align-items: center; font-family: var(--bs-font-monospace); font-weight: 800; font-size: 1.05rem; color: var(--dash-accent, #0d6efd); padding-left: .15rem; min-width: 0; overflow: hidden; }
.fhw-fx-swap { align-self: center; border: none; background: transparent; color: var(--fl-text-muted); cursor: pointer; font-size: .9rem; }
.fhw-fx-rate { font-size: .68rem; color: var(--fl-text-muted); text-align: center; }

.fhw-pray { display: flex; flex-direction: column; gap: .15rem; }
.fhw-pray-head { font-size: .72rem; font-weight: 600; color: var(--fl-text-muted); display: flex; align-items: center; gap: .3rem; margin-bottom: .25rem; }
.fhw-pray-cfg { margin-left: auto; cursor: pointer; opacity: .6; } .fhw-pray-cfg:hover { opacity: 1; }
.fhw-pray-row { display: flex; justify-content: space-between; font-size: .82rem; padding: .2rem .45rem; border-radius: 6px; }
.fhw-pray-row span:last-child { font-family: var(--bs-font-monospace); }
.fhw-pray-row.next { background: color-mix(in srgb, var(--dash-accent, #0d6efd) 14%, transparent); font-weight: 700; color: var(--dash-accent, #0d6efd); }

.fhw-clocks { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; }
.fhw-clock { text-align: center; border: 1px solid var(--fl-border-light, #eef1f4); border-radius: 8px; padding: .35rem .2rem; }
.fhw-clock .l { font-size: .62rem; text-transform: uppercase; letter-spacing: .03em; color: var(--fl-text-muted); }
.fhw-clock .t { font-size: 1rem; font-weight: 800; font-family: var(--bs-font-monospace); }
.fhw-clock .d { font-size: .6rem; color: var(--fl-text-muted); }

.fhw-calc { display: flex; flex-direction: column; gap: .4rem; height: 100%; }
.fhw-calc-disp { text-align: right; font-family: var(--bs-font-monospace); font-size: 1.3rem; font-weight: 700; border: 1px solid var(--fl-border, #d1d5db); border-radius: 6px; padding: .3rem .5rem; background: var(--fl-surface-alt, #f8fafc); color: inherit; }
.fhw-calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .3rem; flex: 1; }
.fhw-calc-k { border: 1px solid var(--fl-border, #e5e7eb); border-radius: 7px; background: var(--fl-surface, #fff); color: inherit; font-size: .95rem; font-weight: 600; cursor: pointer; min-height: 30px; }
.fhw-calc-k:hover { background: var(--fl-surface-alt, #f1f5f9); }
.fhw-calc-k.op { color: var(--dash-accent, #0d6efd); } .fhw-calc-k.eq { background: var(--dash-accent, #0d6efd); color: #fff; border-color: transparent; }

.fhw-unit-cat { width: 100%; }
.fhw-links { display: flex; flex-direction: column; gap: .4rem; height: 100%; }
.fhw-links-list { display: flex; flex-direction: column; gap: .25rem; overflow: auto; flex: 1; min-height: 0; }
.fhw-link { display: flex; align-items: center; gap: .4rem; padding: .25rem .4rem; border-radius: 6px; font-size: .83rem; text-decoration: none; color: inherit; }
.fhw-link:hover { background: var(--fl-surface-alt, #f1f5f9); }
.fhw-link span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fhw-link-x { color: #b91c1c; opacity: .55; } .fhw-link-x:hover { opacity: 1; }
.fhw-links-add { display: flex; gap: .3rem; }
.fhw-links-add input { flex: 1; min-width: 0; border: 1px solid var(--fl-border, #d1d5db); border-radius: 6px; padding: .2rem .4rem; font-size: .78rem; background: var(--fl-surface, #fff); color: inherit; }
.fhw-link-label { max-width: 38%; }

.fhw-tr-out { border: 1px solid var(--fl-border-light, #eef1f4); border-radius: 6px; padding: .4rem .5rem; font-size: .86rem; min-height: 2rem; background: var(--fl-surface-alt, #f8fafc); word-break: break-word; }
html[data-theme="dark"] .fhw-clock, html[data-theme="dark"] .fhw-calc-k { background: #1f2937; border-color: #374151; }
html[data-theme="dark"] .fhw-calc-disp, html[data-theme="dark"] .fhw-tr-out { background: #111827; }

/* Unread-notices login modal */
.fhw-ov { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); backdrop-filter: blur(2px); z-index: 1200; display: none; align-items: center; justify-content: center; padding: 1rem; }
.fhw-ov.open { display: flex; }
.fhw-dialog { background: var(--fl-surface); color: var(--fl-text); border-radius: 16px; max-width: 560px; width: 100%; max-height: 86vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 40px 90px -28px rgba(0, 0, 0, .6); animation: flashFadeUp 260ms ease; }
/* gradient header matches the login brand panel (palette tokens) */
.fhw-dialog-head { padding: .9rem 1.15rem; background: linear-gradient(135deg, var(--fl-brand), var(--fl-accent)); color: #fff; font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.fhw-dialog-head .bi { font-size: 1.05rem; }
.fhw-ov-x { background: transparent; border: 0; color: rgba(255,255,255,.85); cursor: pointer;
  line-height: 1; padding: .15rem .4rem; border-radius: 6px; display: inline-flex; align-items: center; }
.fhw-ov-x:hover { background: rgba(255,255,255,.22); color: #fff; }
.fhw-ov-x .bi { font-size: .95rem; }
.fhw-dialog-body { padding: .85rem 1.15rem; overflow: auto; display: flex; flex-direction: column; gap: .55rem; background: var(--fl-bg); }
.fhw-dialog-foot { padding: .65rem 1.15rem; border-top: 1px solid var(--fl-divider); display: flex; align-items: center; gap: .5rem; }

/* Token aliases — views referenced these before they were defined; alias them
   to real tokens so dark/flash themes resolve instead of the light fallbacks. */
:root, html[data-theme="dark"], html[data-theme="flash"] {
  --fl-border-light: var(--fl-divider);
  --fl-brand-tint:   var(--fl-brand-soft);
  --fl-card-bg:      var(--fl-surface);
}

/* ─── Unified page header + breadcrumb (_PageHeader.cshtml) ───────────── */
.fl-pagehead { margin-bottom: .75rem; }
.fl-crumb { font-size: .78rem; display: flex; align-items: center; gap: .35rem;
  color: var(--fl-text-subtle); margin-bottom: .4rem; flex-wrap: wrap; }
.fl-crumb a { color: var(--fl-text-muted); text-decoration: none; display: inline-flex; align-items: center; gap: .25rem; }
.fl-crumb a:hover { color: var(--fl-brand); }
.fl-crumb .bi-chevron-right { font-size: .62rem; opacity: .7; }
.fl-crumb .cur { color: var(--fl-brand); font-weight: 600; }
.fl-ph-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.fl-ph-icon { width: 34px; height: 34px; border-radius: var(--fl-radius);
  background: var(--fl-brand-soft); color: var(--fl-brand);
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.05rem; flex: 0 0 auto; }
.fl-ph-title { font-size: 1.05rem; font-weight: 700; margin: 0; color: var(--fl-text); letter-spacing: .01em; }
.fl-ph-hint { margin-inline-start: auto; font-size: .74rem; color: var(--fl-text-subtle); }
.fl-ph-actions { margin-inline-start: auto; display: flex; gap: .4rem; align-items: center; }
.fl-ph-actions + .fl-ph-hint { margin-inline-start: 0; }
@media (max-width: 575.98px) { .fl-ph-hint { display: none; } }
@media print { .fl-pagehead { display: none !important; } }

/* ─── Consistent card/panel chrome (use instead of bespoke borders) ───── */
.fl-panel { background: var(--fl-surface); border: 1px solid var(--fl-border);
  border-radius: var(--fl-radius); box-shadow: var(--fl-shadow-sm); }
.fl-panel > h6, .fl-panel-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em;
  color: var(--fl-text-muted); padding: .5rem .6rem; margin: 0; border-bottom: 1px solid var(--fl-divider); }

/* ─── Skeleton variants (list/tile placeholders while data loads) ─────── */
.fl-skel-wrap { padding: .5rem .6rem; }
.fl-skel-block { height: 100%; min-height: 80px; border-radius: .45rem; }
.fl-skel-tile { padding: .55rem .6rem; height: 100%; display: flex; flex-direction: column; gap: .45rem; }
.fl-skel-tile .fl-skel-block { flex: 1 1 auto; }

/* ─── FlashGrid indeterminate loading bar (auto-shown during skeleton) ──── */
.fg-progress { height: 3px; background: var(--fl-brand-soft); overflow: hidden;
  border-radius: 2px; margin-bottom: .4rem; display: none; }
.fg-progress.on { display: block; }
.fg-progress > div { height: 100%; width: 40%; background: var(--fl-brand);
  border-radius: 2px; animation: fg-ind 1.1s infinite ease-in-out; }
@keyframes fg-ind { 0% { margin-left: -42%; } 100% { margin-left: 102%; } }
@media print { .fg-progress { display: none !important; } }

/* ============================================================================
   FlashItemPicker — shared item-selection dropdown (flash-itempicker.js)
   Body-appended, fixed-position menu themed with the app's CSS variables.
   ============================================================================ */
.fip-wrap { position: relative; display: block; }
.fip-wrap > .form-control { padding-right: 1.9rem; }
.fip-caret {
  position: absolute; top: 0; right: 0; height: 100%; width: 1.8rem;
  display: flex; align-items: center; justify-content: center;
  border: 0; background: transparent; padding: 0; cursor: pointer;
  color: var(--fl-text-muted);
}
.fip-caret:hover { color: var(--fl-brand, #0d6efd); }
.fip-caret i { font-size: .8rem; transition: transform .15s ease; }
.fip-wrap.open .fip-caret i { transform: rotate(180deg); }
.fip-menu {
  position: fixed; z-index: 1085; display: none;
  max-height: 340px; overflow-y: auto;
  background: var(--fl-surface, #fff);
  border: 1px solid var(--fl-border, #d1d5db);
  border-radius: var(--fl-radius, 6px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
}
.fip-menu.open { display: block; }
.fip-item {
  padding: .34rem .55rem; cursor: pointer; font-size: .78rem;
  border-bottom: 1px solid var(--fl-border-light, #f1f3f5);
}
.fip-item:last-child { border-bottom: 0; }
.fip-item:hover { background: var(--fl-brand-soft, #e7f0fb); }
/* keyboard-selected / active row — strong, app-brand highlight */
.fip-item.active { background: var(--fl-brand, #0a4d8c); box-shadow: inset 3px 0 0 rgba(0,0,0,.25); }
.fip-item.active .fip-c, .fip-item.active .fip-n, .fip-item.active .fip-p,
.fip-item.active .fip-s, .fip-item.active .fip-meta { color: #fff !important; }
.fip-item.active .fip-u { color: #fff !important; background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.35); }
.fip-row1 { display: grid; grid-template-columns: 104px 1fr auto auto; gap: .45rem; align-items: center; }
.fip-c { font-family: var(--bs-font-monospace); font-weight: 600; color: var(--fl-brand, #0d6efd);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fip-n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--fl-text, inherit); }
.fip-u { font-size: .66rem; font-weight: 600; text-transform: uppercase; letter-spacing: .02em;
  color: var(--fl-text-muted); background: var(--fl-surface-alt, #eef2f7);
  border: 1px solid var(--fl-border, #d1d5db); border-radius: 999px; padding: .02rem .4rem; white-space: nowrap; }
.fip-p { text-align: right; font-family: var(--bs-font-monospace); color: var(--fl-text-muted); white-space: nowrap; }
.fip-s { color: var(--fl-success, #16a34a); font-weight: 600; }
.fip-s.zero { color: var(--fl-danger, #b91c1c); }
.fip-meta { font-size: .7rem; color: var(--fl-text-muted); margin-top: .1rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fip-empty { padding: .7rem .55rem; color: var(--fl-text-muted); font-size: .78rem; text-align: center; }
@media (max-width: 575.98px) {
  .fip-row1 { grid-template-columns: 1fr auto auto; }
  .fip-c { grid-column: 1 / -1; }           /* barcode/code on its own line on phones */
}
@media print { .fip-menu { display: none !important; } }
