/* ═══════════════════════════════════════════════════════════════════════════
   EKTIMO AI PLATFORM — DESIGN SYSTEM
   Single source of truth for all UI. Partials must not ship <style> blocks.
   Layers: 1 Tokens · 2 Base · 3 Layout · 4 Components · 5 Modules · 6 Responsive
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 1. DESIGN TOKENS ──────────────────────────────────────────────────────── */
:root {
  /* Brand */
  --navy:        #1F3864;
  --navy2:       #2a4a7f;
  --navy3:       #16294a;
  --teal:        #0A9396;
  --orange:      #E8610A;
  --orange-dark: #d4560a;

  /* Semantic */
  --green:  #16a34a;
  --red:    #dc2626;
  --amber:  #d97706;
  --info:   #2563eb;

  /* Semantic tints (bg / fg pairs — use together, always) */
  --success-bg: #ecfdf5;  --success-fg: #065f46;  --success-bd: #6ee7b7;
  --danger-bg:  #fee2e2;  --danger-fg:  #991b1b;  --danger-bd:  #fca5a5;
  --warning-bg: #fef3c7;  --warning-fg: #92400e;  --warning-bd: #fcd34d;
  --info-bg:    #dbeafe;  --info-fg:    #1e40af;  --info-bd:    #93c5fd;
  --neutral-bg: #f3f4f6;  --neutral-fg: #4b5563;
  --brand-bg:   #fef3ed;  --brand-fg:   #9a3412;

  /* Surfaces & text */
  --bg:     #f0f4f8;
  --bg2:    #e4ecf4;
  --white:  #fff;
  --text:   #1a2533;
  --text2:  #4a5568;
  --text3:  #64748b;
  --border: #d0dce8;

  /* Elevation */
  --sh-sm: 0 1px 3px rgba(13,33,55,.08);
  --sh:    0 2px 12px rgba(13,33,55,.08);
  --sh-lg: 0 8px 32px rgba(13,33,55,.16);
  --sh-xl: 0 20px 60px rgba(13,33,55,.28);

  /* Radii */
  --r:    12px;
  --rs:   8px;
  --r-xs: 6px;
  --r-pill: 999px;

  /* Type scale */
  --fs-xs:  11px;
  --fs-sm:  12px;
  --fs-md:  13px;
  --fs-lg:  14px;
  --fs-xl:  16px;
  --fs-2xl: 20px;
  --fs-3xl: 26px;

  /* Spacing scale (4px base) */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px;  --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;

  /* Motion */
  --t-fast: .15s ease;
  --t-med:  .25s ease;

  /* Fonts */
  --font:      'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;

  /* Focus ring */
  --ring: 0 0 0 3px rgba(232,97,10,.30);
}

/* ── 2. BASE ───────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Keyboard focus visible everywhere, never on mouse click */
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-xs); }

::selection { background: rgba(232,97,10,.2); }

/* Subtle entrance for HTMX-swapped content */
#content.htmx-added, #content > .htmx-added { animation: fadeUp .2s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── 3. LAYOUT ─────────────────────────────────────────────────────────────── */

/* Sidebar */
.sb {
  position: fixed; left: 0; top: 0; bottom: 0; width: 240px;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy3) 100%);
  display: flex; flex-direction: column; z-index: 100;
  box-shadow: 4px 0 24px rgba(0,0,0,.18);
}
.sb-logo { padding: 20px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.1); text-align: center; }
.sb-logo h1 { color: #fff; font-size: var(--fs-xl); font-weight: 700; line-height: 1.2; }
.sb-logo p { color: rgba(255,255,255,.55); font-size: var(--fs-xs); margin-top: 2px; }
.sb-badge {
  background: var(--orange); color: #fff; font-size: 10px; font-weight: 700;
  letter-spacing: 1.5px; padding: 3px 8px; border-radius: 4px;
  display: inline-block; margin-bottom: 6px;
}
.nav-sec { padding: var(--sp-3) 10px 6px; }
.nav-lbl {
  color: rgba(255,255,255,.55); font-size: 10px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase; padding: 0 8px; margin-bottom: var(--sp-1);
}
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 9px; padding: 9px 10px;
  border-radius: var(--rs); cursor: pointer; transition: background var(--t-fast), color var(--t-fast);
  color: rgba(255,255,255,.7); font-size: var(--fs-md); font-weight: 500;
  margin-bottom: 1px; user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item:focus-visible { box-shadow: inset var(--ring); }
.nav-item.active {
  background: rgba(255,255,255,.14); color: #fff;
}
.nav-item.active::before {
  content: ''; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 3px;
  background: var(--orange); border-radius: 0 3px 3px 0;
}
.sb-footer { margin-top: auto; padding: var(--sp-3); border-top: 1px solid rgba(255,255,255,.1); }
.sb-logo-img { height: 28px; width: auto; display: block; margin: 0 auto 8px; }

/* Main area + topbar */
.main { margin-left: 240px; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  background: #fff; padding: var(--sp-3) 26px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50;
  box-shadow: var(--sh-sm);
}
.topbar-title { font-size: var(--fs-xl); font-weight: 700; color: var(--navy); }
.topbar-sub { font-size: var(--fs-sm); color: var(--text3); margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-user {
  display: inline-flex; align-items: center; gap: 8px; background: #fff;
  border: 1.5px solid var(--border); border-radius: var(--rs); padding: 6px 13px;
  white-space: nowrap; box-shadow: var(--sh-sm);
}
.topbar-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--fs-xs); font-weight: 800; flex-shrink: 0; line-height: 1;
}
.topbar-name { font-size: var(--fs-md); font-weight: 600; color: var(--navy); }
.topbar-badge {
  display: inline-block; font-size: 10px; padding: 2px 8px; border-radius: var(--r-pill);
  font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
}
.topbar-sep { width: 1px; height: 20px; background: var(--border); flex-shrink: 0; }
.sign-out-btn {
  display: inline-flex; align-items: center; gap: 5px; background: #fff;
  border: 1.5px solid var(--border); color: var(--text2); font-family: var(--font);
  font-size: var(--fs-sm); font-weight: 600; padding: 7px 13px; border-radius: var(--rs);
  cursor: pointer; transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.sign-out-btn:hover { background: #fff5f5; border-color: var(--red); color: var(--red); }
.user-info { display: flex; align-items: center; gap: 8px; }

.content { padding: 22px 26px; flex: 1; }
.page { display: none; } .page.active { display: block; }
#content.is-loading { opacity: .5; pointer-events: none; transition: opacity var(--t-fast); }

/* Top progress bar (HTMX activity) */
.progress-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 1500;
  background: linear-gradient(90deg, var(--orange), var(--teal));
  transform: scaleX(0); transform-origin: left;
  transition: transform .3s ease, opacity .3s ease; opacity: 0; pointer-events: none;
}
.progress-bar.on  { opacity: 1; transform: scaleX(.7); transition: transform 6s cubic-bezier(.1,.6,.2,1), opacity .2s; }
.progress-bar.off { opacity: 0; transform: scaleX(1); }

/* ── 4. COMPONENTS ─────────────────────────────────────────────────────────── */

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--rs); font-family: var(--font);
  font-size: var(--fs-md); font-weight: 600; cursor: pointer; border: none;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast),
              box-shadow var(--t-fast), transform var(--t-fast);
  text-decoration: none; line-height: 1.3; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy);   color: #fff; } .btn-primary:hover { background: var(--navy2); }
.btn-orange  { background: var(--orange); color: #fff; } .btn-orange:hover  { background: var(--orange-dark); }
.btn-green   { background: var(--green);  color: #fff; } .btn-green:hover   { background: #15803d; }
.btn-red     { background: var(--red);    color: #fff; } .btn-red:hover     { background: #b91c1c; }
.btn-teal    { background: var(--teal);   color: #fff; } .btn-teal:hover    { background: #087f82; }
.btn-outline { background: #fff; color: var(--navy); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--navy); }
.btn-sm { padding: 5px 10px; font-size: var(--fs-sm); }
/* HTMX-aware loading state: any button that fired a request dims + shows busy cursor */
.btn.htmx-request { opacity: .65; pointer-events: none; cursor: progress; }

/* Cards */
.card {
  background: #fff; border-radius: var(--r); box-shadow: var(--sh);
  border: 1px solid var(--border); overflow: hidden;
}
.card-header {
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: var(--fs-lg); font-weight: 700; color: var(--navy); display: flex; align-items: center; gap: 7px; }
.card-body { padding: var(--sp-4); }
.sec-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-3); }
.sec-title { font-size: var(--fs-lg); font-weight: 700; color: var(--navy); }

/* Stat / KPI cards — ONE component. wf-stat / um-stat / mrj-stat are aliases. */
.stats-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: var(--sp-3); margin-bottom: 22px; }
.stat-card, .wf-stat, .um-stat {
  background: #fff; border-radius: var(--r); padding: var(--sp-4) 18px;
  box-shadow: var(--sh-sm); border: 1px solid var(--border); border-top: 3px solid var(--navy);
  transition: box-shadow var(--t-fast), transform var(--t-fast);
}
.stat-card:hover, .wf-stat:hover, .um-stat:hover { box-shadow: var(--sh); transform: translateY(-1px); }
.stat-card.navy   { border-top-color: var(--navy); }
.stat-card.teal   { border-top-color: var(--teal); }
.stat-card.green,  .wf-stat.green,  .um-stat.green  { border-top-color: var(--green); }
.stat-card.orange, .wf-stat.orange, .um-stat.orange { border-top-color: var(--orange); }
.stat-card.red,    .wf-stat.red,    .um-stat.red    { border-top-color: var(--red); }
.wf-stat.amber { border-top-color: var(--amber); }
.wf-stat { border-top-color: var(--orange); padding: 10px 14px; border-radius: var(--rs); }
.stat-lbl, .wf-stat-lbl, .um-stat-lbl, .mrj-stat-lbl {
  font-size: var(--fs-xs); font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: .6px;
}
.stat-val  { font-size: var(--fs-3xl); font-weight: 700; color: var(--navy); margin: 5px 0 2px; line-height: 1; }
.um-stat-val { font-size: 24px; font-weight: 700; color: var(--navy); margin-top: 4px; line-height: 1; }
.wf-stat-val { font-size: 22px; font-weight: 700; color: var(--navy); margin-top: 4px; font-family: var(--font-mono); }
.stat-sub  { font-size: var(--fs-xs); color: var(--text3); }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-size: var(--fs-xs); font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: .6px; padding: 9px 12px;
  background: var(--bg); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1;
}
.tbl td { padding: 11px 12px; font-size: var(--fs-md); border-bottom: 1px solid var(--bg2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background var(--t-fast); }
.tbl tr:hover td { background: var(--bg); }
.tbl tr[hx-get]:hover td, .tbl tr[onclick]:hover td { cursor: pointer; }
.mono { font-family: var(--font-mono); }
.id-cell { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--orange); font-weight: 600; }
.id-cell.navy { color: var(--navy); }

/* Badges — unified pill system */
.bdg {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px;
  border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; line-height: 1.4;
  white-space: nowrap;
}
.bdg-field     { background: var(--warning-bg); color: var(--warning-fg); }
.bdg-lab       { background: #cfe2ff; color: #0a4199; }
.bdg-qa        { background: #d1ecf1; color: #0c5460; }
.bdg-reporting { background: #e8d5f5; color: #5b2d8e; }
.bdg-delivered { background: var(--success-bg); color: var(--success-fg); }
.bdg-high      { background: var(--danger-bg); color: var(--danger-fg); }
.bdg-nc        { background: var(--danger-bg); color: var(--danger-fg); font-weight: 700; }
.bdg-pass      { background: var(--success-bg); color: var(--success-fg); }
.bdg-info      { background: var(--info-bg); color: var(--info-fg); }
.bdg-sent      { background: var(--success-bg); color: var(--success-fg); }
.bdg-draft     { background: var(--neutral-bg); color: var(--neutral-fg); }
.bdg-pending   { background: var(--info-bg); color: var(--info-fg); }
.bdg-pending-detail { background: var(--warning-bg); color: var(--warning-fg); }
.bdg-pending-sanity { background: var(--info-bg); color: var(--info-fg); }
.badge-yellow { background: var(--warning-bg); color: var(--warning-fg); }
.badge-blue   { background: var(--info-bg); color: var(--info-fg); }
.badge-grey   { background: var(--neutral-bg); color: var(--neutral-fg); }
/* Role badges (audit trail, user mgmt) */
.bdg-role-administrator { background: var(--danger-bg);  color: var(--danger-fg); }
.bdg-role-signatory     { background: #f8d7da; color: #6f0a14; }
.bdg-role-reporting     { background: #e8d5f5; color: #5b2d8e; }
.bdg-role-consultant    { background: var(--warning-bg); color: var(--warning-fg); }
.bdg-role-technician    { background: #d1ecf1; color: #0c5460; }
.bdg-role-lab           { background: #cfe2ff; color: #0a4199; }
.bdg-role-accounts      { background: var(--success-bg); color: var(--success-fg); }
.bdg-role-ops_manager   { background: #fde8c8; color: #7a3e00; }
.bdg-role-admin_office  { background: #e2d5f8; color: #3d1a8a; }
.bdg-role-default       { background: var(--neutral-bg); color: var(--neutral-fg); }
/* Login-role chips (legacy) */
.role-admin{background:var(--danger-bg);color:var(--danger-fg)} .role-field{background:var(--warning-bg);color:var(--warning-fg)}
.role-lab{background:#cfe2ff;color:#0a4199} .role-qa{background:#d1ecf1;color:#0c5460}
.role-reporting{background:#e8d5f5;color:#5b2d8e} .role-finance{background:var(--success-bg);color:var(--success-fg)}
.role-administrator{background:var(--danger-bg);color:var(--danger-fg)} .role-signatory{background:#d1ecf1;color:#0c5460}
.role-consultant{background:var(--warning-bg);color:var(--warning-fg)} .role-accounts{background:var(--success-bg);color:var(--success-fg)}

/* Banners (server-rendered feedback) */
.banner, .um-banner, .wf-msg {
  padding: 10px 14px; border-radius: var(--rs); font-size: var(--fs-md); font-weight: 500;
  display: flex; align-items: center; gap: 8px; border: 1px solid; margin-bottom: var(--sp-3);
  animation: fadeUp .2s ease;
}
.banner.ok,  .um-banner.ok,  .wf-msg { background: var(--success-bg); color: var(--success-fg); border-color: var(--success-bd); }
.banner.err, .um-banner.err { background: var(--danger-bg); color: var(--danger-fg); border-color: var(--danger-bd); }

/* Toasts */
.toast-stack {
  position: fixed; top: 20px; right: 20px; z-index: 2000;
  display: flex; flex-direction: column; gap: 12px; pointer-events: none;
  max-width: 460px;
}
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 12px;
  min-width: 360px; max-width: 460px; padding: 16px 18px;
  background: #fff; border: 1px solid var(--border); border-left: 5px solid var(--info);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(13,33,55,.18);
  color: var(--text);
  animation: toastIn .25s cubic-bezier(.2,.9,.3,1.2);
}
.toast-ico { flex-shrink: 0; display: flex; align-items: center; justify-content: center; margin-top: 1px; color: var(--info); }
.toast-ico i, .toast-ico svg { width: 20px; height: 20px; }
.toast-body { flex: 1; min-width: 0; }
.toast.success { border-left-color: var(--green); } .toast.success .toast-ico { color: var(--green); }
.toast.error   { border-left-color: var(--red);   } .toast.error   .toast-ico { color: var(--red); }
.toast.warning { border-left-color: var(--amber); } .toast.warning .toast-ico { color: var(--amber); }
.toast .toast-title { font-weight: 700; color: var(--navy); font-size: 14px; }
.toast .toast-msg { font-size: 13px; color: var(--text2); margin-top: 3px; line-height: 1.5; }
.toast .toast-x {
  margin-left: auto; background: none; border: none; cursor: pointer; color: var(--text3);
  font-size: 18px; line-height: 1; padding: 0 2px; flex-shrink: 0;
}
.toast .toast-x:hover { color: var(--text); }
.toast.out { animation: toastOut .2s ease forwards; }
@keyframes toastIn  { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(24px); } }

/* Skeleton loaders */
.skeleton-page { display: flex; flex-direction: column; gap: var(--sp-4); }
.sk-row { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--sp-3); }
.sk {
  position: relative; overflow: hidden; background: var(--bg2); border-radius: var(--rs);
}
.sk::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.65), transparent);
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.sk-stat  { height: 76px; }
.sk-bar   { height: 40px; }
.sk-table { height: 320px; border-radius: var(--r); }

/* WFM Sync Now panel — a floating checklist, not a full-page modal, so the
   rest of the page stays usable while a sync runs. Shared by the Financial
   Dashboard's full sync and the WFM Job Tracker's jobs-only sync (see
   app-ui.js wfmRenderSyncPanel). Fixed top-right, above the page content,
   same positioning family as .toast-stack. Row states (pending/active/done)
   are toggled by JS via class, never inline style. */
.wfm-sync-panel {
  position: fixed; top: 84px; right: 20px; z-index: 1500;
  width: 380px; max-width: calc(100vw - 40px);
  background: #fff; border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--sh-lg); overflow: hidden;
  animation: toastIn .25s cubic-bezier(.2,.9,.3,1.2);
}
.wfm-sync-panel-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.wfm-sync-panel-title { font-size: var(--fs-md); font-weight: 700; color: var(--navy); }
.wfm-sync-panel-close {
  background: none; border: none; cursor: pointer; color: var(--text3);
  font-size: 18px; line-height: 1; padding: 0 2px;
}
.wfm-sync-panel-close:hover { color: var(--text); }

.wfm-sync-steps { list-style: none; margin: 0; padding: var(--sp-2) 0; max-height: 360px; overflow-y: auto; }
.wfm-sync-step {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4); font-size: var(--fs-md);
}
.wfm-sync-step-icon {
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; flex-shrink: 0; border-radius: var(--r-pill);
}
.wfm-sync-step-icon svg, .wfm-sync-step-icon i { width: 15px; height: 15px; }

.wfm-sync-step.pending { color: var(--text3); }
.wfm-sync-step.pending .wfm-sync-step-icon { background: var(--bg2); color: var(--text3); }

.wfm-sync-step.active { color: var(--text); font-weight: 600; }
.wfm-sync-step.active .wfm-sync-step-icon { background: var(--info-bg); color: var(--info); }
.wfm-sync-step.active .wfm-sync-step-icon svg { animation: spin 1s linear infinite; }

.wfm-sync-step.done { color: var(--text2); }
.wfm-sync-step.done .wfm-sync-step-icon { background: var(--success-bg); color: var(--green); }

.wfm-sync-step.step-error { color: var(--red); font-weight: 600; }
.wfm-sync-step.step-error .wfm-sync-step-icon { background: var(--danger-bg); color: var(--red); }

.wfm-sync-panel-summary {
  padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--border);
  font-size: var(--fs-md); color: var(--text2); background: var(--bg);
}
.wfm-sync-panel-summary .wfm-sync-summary-headline {
  font-weight: 700; font-size: var(--fs-lg); margin-bottom: 4px;
}
.wfm-sync-panel-summary.done  .wfm-sync-summary-headline { color: var(--green); }
.wfm-sync-panel-summary.error .wfm-sync-summary-headline { color: var(--red); }
.wfm-sync-panel-summary.warn  .wfm-sync-summary-headline { color: var(--warning-fg); }

/* Empty states */
.empty-state { text-align: center; padding: 44px 20px; color: var(--text3); }
.empty-state .es-icon {
  width: 52px; height: 52px; border-radius: 50%; background: var(--bg);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 12px; color: var(--text3);
}
.empty-state .es-icon svg { width: 24px; height: 24px; }
.empty-state h4 { font-size: var(--fs-lg); font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.empty-state p { font-size: var(--fs-sm); color: var(--text3); margin-bottom: 12px; }

/* Modals — ONE animated system. All three backdrop classes share it. */
.modal-ov, .wjm-backdrop, .um-modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(13,33,55,.6);
  z-index: 200; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-ov.show, .wjm-backdrop.show, .um-modal-backdrop.show { display: flex; animation: ovIn .15s ease; }
.wjm-backdrop { z-index: 1100; } .um-modal-backdrop { z-index: 1000; }
/* Scroll + pad the user-modal backdrop and top-align it, so on a short viewport
   (e.g. DevTools open) the modal never hugs the edges and its footer (action
   buttons) always stays reachable. */
.um-modal-backdrop { align-items: flex-start; overflow-y: auto; padding: 24px 12px; }
.modal, .wjm-modal, .um-modal {
  background: #fff; border-radius: var(--r); box-shadow: var(--sh-xl);
  max-width: 95vw; max-height: 90vh; overflow-y: auto;
  animation: popIn .18s cubic-bezier(.2,.9,.3,1.1);
}
.modal { width: 820px; }
.wjm-modal { width: 640px; max-width: 94vw; border-radius: 10px; }
.um-modal { width: 420px; max-width: 92vw; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; }
@keyframes ovIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(.96) translateY(6px); } to { opacity: 1; transform: none; } }
.modal-hdr {
  background: linear-gradient(135deg, var(--navy), var(--navy2)); color: #fff;
  padding: var(--sp-4) var(--sp-5); display: flex; align-items: flex-start; justify-content: space-between;
}
.modal-close {
  background: rgba(255,255,255,.1); border: none; color: rgba(255,255,255,.8);
  cursor: pointer; font-size: 15px; line-height: 1; width: 28px; height: 28px;
  border-radius: var(--r-xs); display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--t-fast), color var(--t-fast);
}
.modal-close:hover { background: rgba(255,255,255,.2); color: #fff; }
.modal-body { padding: var(--sp-5); }

/* Pagination — ONE component. wf-pgbtn / um-pgbtn are aliases. */
.wf-pager, .pgr {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: var(--sp-3); padding: 8px 4px; flex-wrap: wrap; gap: 8px;
}
.wf-pager-info, .um-pager-info, .pgr-info { font-size: var(--fs-sm); color: var(--text3); }
.um-pager {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4) var(--sp-4); border-top: 1px solid var(--border);
  background: var(--bg); flex-wrap: wrap; gap: 10px;
}
.um-pager-ctrl { display: flex; gap: 4px; align-items: center; }
.wf-pgbtn, .um-pgbtn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 30px; padding: 0 10px;
  border: 1px solid var(--border); background: #fff; color: var(--navy);
  font-size: var(--fs-sm); font-weight: 600; border-radius: var(--r-xs); cursor: pointer;
  text-decoration: none; font-family: var(--font-mono); transition: border-color var(--t-fast), color var(--t-fast);
}
.wf-pgbtn:hover:not(.active):not(.disabled), .um-pgbtn:hover:not(.active):not(.disabled) { border-color: var(--orange); color: var(--orange); }
.wf-pgbtn.active, .um-pgbtn.active { background: var(--orange); color: #fff; border-color: var(--orange); cursor: default; }
.wf-pgbtn.disabled, .um-pgbtn.disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }
.um-pgdots { padding: 0 4px; color: var(--text3); font-size: var(--fs-md); user-select: none; }

/* Forms */
.api-input, .textarea, .login-input {
  width: 100%; padding: 8px 11px; border: 1.5px solid var(--border); border-radius: var(--rs);
  font-family: var(--font); font-size: var(--fs-md); color: var(--text);
  background: #fff; outline: none; transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.api-input { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--navy); margin-top: 6px; }
.textarea { resize: vertical; }
.api-input:focus, .textarea:focus, .login-input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(232,97,10,.12); }
.api-setup {
  background: var(--warning-bg); border: 1.5px solid var(--warning-bd); border-radius: var(--rs);
  padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-4); display: flex; align-items: flex-start; gap: 10px;
}
.field-lbl {
  font-size: 10px; font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: .5px;
}
.field-lbl.block { display: block; margin-bottom: 4px; }
.txt-input {
  width: 100%; box-sizing: border-box; padding: 7px 10px;
  border: 1.5px solid var(--border); border-radius: var(--rs);
  font-size: var(--fs-sm); color: var(--navy); background: #fff;
  outline: none; font-family: inherit; transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.txt-input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(232,97,10,.12); }
.text-xs { font-size: var(--fs-xs); color: var(--text3); }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: var(--sp-4); }
.tab {
  padding: 8px 16px; font-size: var(--fs-md); font-weight: 600; color: var(--text3);
  cursor: pointer; border-bottom: 2.5px solid transparent; margin-bottom: -2px; transition: color var(--t-fast), border-color var(--t-fast);
}
.tab:hover { color: var(--navy); } .tab.active { color: var(--orange); border-bottom-color: var(--orange); }
.tab-content { display: none; } .tab-content.active { display: block; }

/* Alerts & step lists */
.alert-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 11px 13px;
  border-radius: var(--rs); border: 1px solid; margin-bottom: var(--sp-2);
}
.a-warn { background: var(--warning-bg); border-color: var(--warning-bd); }
.a-info { background: var(--info-bg); border-color: var(--info-bd); }
.a-ok   { background: var(--success-bg); border-color: var(--success-bd); }
.a-red  { background: var(--danger-bg); border-color: var(--danger-bd); }
.alert-text strong { font-size: var(--fs-md); color: var(--navy); }
.alert-text p { font-size: var(--fs-sm); color: var(--text2); margin-top: 2px; }
.step-item { display: flex; gap: var(--sp-3); margin-bottom: 14px; }
.step-num {
  width: 26px; height: 26px; border-radius: 50%; background: var(--orange); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-sm); font-weight: 700; flex-shrink: 0;
}
.step-content strong { font-size: var(--fs-md); color: var(--navy); font-weight: 700; }
.step-content p { font-size: var(--fs-sm); color: var(--text2); margin-top: 2px; line-height: 1.5; }

/* Utility */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.mt-4 { margin-top: var(--sp-4); } .mb-4 { margin-bottom: var(--sp-4); }
.text-sm { font-size: var(--fs-sm); color: var(--text3); }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: var(--sp-3); }
.info-item label { font-size: 10px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .5px; }
.info-item p { font-size: var(--fs-md); color: var(--navy); font-weight: 500; margin-top: 1px; }

/* ── 5. MODULES ────────────────────────────────────────────────────────────── */

/* 5a. Login */
.login-page {
  position: fixed; inset: 0; background: url('/static/cover_bg.jpg') center center / cover no-repeat;
  z-index: 600; display: flex; align-items: center; justify-content: center; flex-direction: column;
}
.login-page::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(4,30,55,.82) 0%, rgba(13,34,71,.75) 60%, rgba(26,58,110,.7) 100%);
}
.login-card {
  background: #fff; border-radius: 16px; padding: 36px 40px; width: 420px; max-width: 95vw;
  box-shadow: 0 24px 64px rgba(0,0,0,.45); position: relative; z-index: 1;
  animation: popIn .25s ease;
}
.login-logo { text-align: center; margin-bottom: var(--sp-6); }
.login-logo-img {
  background: var(--navy); padding: 9px 16px; border-radius: 8px;
  height: 45px; width: auto; display: inline-block; margin-bottom: 10px;
}
.login-logo h2 { font-size: var(--fs-2xl); font-weight: 700; color: var(--navy); }
.login-logo p { font-size: var(--fs-sm); color: var(--text3); margin-top: 3px; }
.login-field { margin-bottom: 14px; }
.login-field label {
  display: block; font-size: var(--fs-sm); font-weight: 700; color: var(--navy);
  margin-bottom: 5px; text-transform: uppercase; letter-spacing: .5px;
}
.login-input { padding: 10px 12px; font-size: var(--fs-lg); color: var(--navy); }
.login-btn {
  width: 100%; padding: 11px; background: var(--navy); color: #fff; border: none;
  border-radius: var(--rs); font-family: var(--font); font-size: var(--fs-lg); font-weight: 700;
  cursor: pointer; transition: background var(--t-fast); margin-top: 4px;
}
.login-btn:hover { background: var(--navy2); }
.login-err { color: var(--red); font-size: var(--fs-sm); font-weight: 600; margin-top: 8px; text-align: center; min-height: 18px; }

/* 5b. Loading overlay (AI generation) */
.loading-ov {
  display: none; position: fixed; inset: 0; background: rgba(13,33,55,.78);
  z-index: 999; align-items: center; justify-content: center; flex-direction: column; gap: var(--sp-4);
  backdrop-filter: blur(2px);
}
.loading-ov.show, .loading-ov.htmx-request { display: flex; }
.spinner {
  width: 44px; height: 44px; border: 4px solid rgba(255,255,255,.2);
  border-top-color: var(--orange); border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.um-btn-spin {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
  vertical-align: middle; margin-right: 4px;
}
.loading-text { color: #fff; font-size: 15px; font-weight: 600; }
.loading-sub { color: rgba(255,255,255,.6); font-size: var(--fs-sm); }

/* 5b-boot. Global boot splash — covers the blank paint on load/hard-refresh.
   Visible by default; JS adds .hide to fade it out once the app (or login) is ready. */
.boot-loader {
  position: fixed; inset: 0; z-index: 100000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; background: var(--navy);
  opacity: 1; transition: opacity .45s ease;
}
.boot-loader.hide { opacity: 0; pointer-events: none; }
.boot-brand { text-align: center; }
/* White logo mark needs no pill here — the splash background is already navy. */
.boot-logo-img { height: 32px; width: auto; display: block; margin: 0 auto 6px; }
.boot-subtitle {
  color: rgba(255,255,255,.6); font-size: 12px; font-weight: 600;
  margin-top: 4px; text-transform: uppercase; letter-spacing: 2px;
}
.boot-spinner { width: 38px; height: 38px; }
.boot-hint { color: rgba(255,255,255,.55); font-size: 13px; }

/* 5c. Financial Assistant query-result table — dark header, content width
   (few-column results don't sprawl), zebra rows, hover. Shared by both the
   sidebar (wfm_chat) and full-page (wfm_chat_page) result renderers. */
.wfm-result-wrap {
  overflow-x: auto; max-height: 440px; overflow-y: auto; margin-top: 10px;
  border: 1px solid var(--border); border-radius: 8px;
}
.wfm-result-tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }
.wfm-result-tbl thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--navy); color: #fff;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  padding: 10px 18px; text-align: left; white-space: nowrap;
}
.wfm-result-tbl thead th.num { text-align: right; }
.wfm-result-tbl tbody td {
  padding: 8px 18px; font-size: 12px; color: var(--text);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.wfm-result-tbl tbody td.num { text-align: right; font-family: 'DM Mono', monospace; }
.wfm-result-tbl tbody tr:nth-child(even) { background: var(--bg2); }
.wfm-result-tbl tbody tr:hover { background: var(--brand-bg, #fff3e9); }
.wfm-result-tbl tbody tr:last-child td { border-bottom: none; }

/* 5c. Report generator — file drops */
.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.file-drop {
  border: 2px dashed var(--border); border-radius: var(--r); padding: var(--sp-5);
  text-align: center; cursor: pointer; transition: border-color var(--t-med), background var(--t-med), transform var(--t-fast);
  background: var(--bg);
}
.file-drop:hover, .file-drop.drag { border-color: var(--orange); background: var(--brand-bg); }
.file-drop.drag { transform: scale(1.01); }
.file-drop.loaded { border-color: var(--green); background: var(--success-bg); border-style: solid; }
.file-drop h4 { font-size: var(--fs-md); font-weight: 700; color: var(--navy); margin: 8px 0 4px; }
.file-drop p { font-size: var(--fs-xs); color: var(--text3); }
.file-drop .icon { font-size: 28px; margin-bottom: 4px; display: flex; justify-content: center; align-items: center; color: var(--text3); }
.file-drop .icon svg { width: 32px; height: 32px; opacity: .55; }
.file-loaded-name { font-size: var(--fs-sm); color: var(--green); font-weight: 600; margin-top: 4px; }
.file-status-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.file-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px;
  border-radius: var(--r-xs); font-size: var(--fs-sm); font-weight: 600;
  background: var(--bg); border: 1px solid var(--border);
}
.file-chip.loaded  { background: var(--success-bg); border-color: var(--green); color: var(--success-fg); }
.file-chip.missing { background: var(--danger-bg); border-color: var(--red); color: var(--danger-fg); }

/* 5d. Pipeline / stage tracker */
.pipeline { display: flex; align-items: flex-start; padding: 18px 0 6px; overflow-x: auto; }
.stage-wrap { display: flex; align-items: center; flex: 1; min-width: 0; }
.stage { display: flex; flex-direction: column; align-items: center; flex: 1; }
.stage-dot {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-md); font-weight: 700; margin-bottom: 6px; border: 2.5px solid; transition: all .3s;
}
.stage-dot.done     { background: var(--green); border-color: var(--green); color: #fff; }
.stage-dot.active   { background: var(--orange); border-color: var(--orange); color: #fff; animation: pulse 2s infinite; }
.stage-dot.pending  { background: #fff; border-color: var(--border); color: var(--text3); }
.stage-dot.rejected { background: var(--red); border-color: var(--red); color: #fff; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(232,97,10,.4); } 50% { box-shadow: 0 0 0 8px rgba(232,97,10,0); } }
.stage-name { font-size: 10px; font-weight: 600; color: var(--navy); text-align: center; }
.stage-person, .stage-date { font-size: 9px; color: var(--text3); text-align: center; margin-top: 1px; }
.stage-line { flex: 1; height: 2px; margin-top: -26px; }
.stage-line.done { background: var(--green); }
.stage-line.active { background: linear-gradient(to right, var(--green), var(--border)); }
.stage-line.pending { background: var(--border); }
.stage-line.rejected { background: var(--red); }

/* 5e. Report output / approval */
.report-output { background: #fff; border-radius: var(--r); border: 1px solid var(--border); overflow: hidden; margin-top: var(--sp-4); display: none; }
.report-output.show { display: block; }
.compliance-banner { padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.compliance-banner.nc { background: linear-gradient(135deg, #7a1f1f, var(--red)); }
.compliance-banner.ok { background: linear-gradient(135deg, #14532d, var(--green)); }
.compliance-banner h4 { font-size: var(--fs-lg); font-weight: 700; color: #fff; }
.compliance-banner p { font-size: var(--fs-sm); color: rgba(255,255,255,.8); margin-top: 2px; }
.approval-bar { padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); background: linear-gradient(135deg, var(--navy), var(--navy2)); }
.approval-bar.approved { background: linear-gradient(135deg, #14532d, var(--green)); }
.approval-bar.rejected { background: linear-gradient(135deg, #7a1f1f, var(--red)); }
.approval-bar h4 { font-size: var(--fs-md); font-weight: 700; color: #fff; }
.approval-bar p { font-size: var(--fs-xs); color: rgba(255,255,255,.75); margin-top: 2px; }
.report-topbar { background: var(--navy); color: #fff; padding: var(--sp-3) var(--sp-5); display: flex; align-items: center; justify-content: space-between; }
.report-topbar h3 { font-size: var(--fs-lg); font-weight: 700; }
.report-topbar p { font-size: var(--fs-xs); opacity: .6; margin-top: 2px; }
.report-body { padding: var(--sp-6); }
.report-sec h4 {
  font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: var(--orange); margin-bottom: 6px; padding-bottom: 5px; border-bottom: 1px solid var(--bg2);
}
.report-sec p { font-size: var(--fs-md); line-height: 1.75; color: var(--text2); margin-bottom: var(--sp-4); }

/* 5f. Data tables (report results) */
.data-tbl { width: 100%; border-collapse: collapse; table-layout: fixed; }
.data-tbl colgroup col.col-param { width: 22%; } .data-tbl colgroup col.col-unit { width: 7%; }
.data-tbl colgroup col.col-method { width: 17%; } .data-tbl colgroup col.col-limit { width: 11%; }
.data-tbl colgroup col.col-t1 { width: 8%; } .data-tbl colgroup col.col-t2 { width: 8%; }
.data-tbl colgroup col.col-avg { width: 9%; } .data-tbl colgroup col.col-status { width: 12%; }
.data-tbl th {
  text-align: left; font-size: 10px; font-weight: 700; color: var(--text3); text-transform: uppercase;
  letter-spacing: .5px; padding: 9px 12px; background: var(--bg); border-bottom: 2px solid var(--border); white-space: nowrap;
}
.data-tbl td { padding: 10px 12px; font-size: var(--fs-sm); border-bottom: 1px solid var(--bg2); vertical-align: middle; }
.data-tbl tr:last-child td { border-bottom: none; }
.data-tbl tr:hover td { background: var(--bg2); }
.data-tbl th.c, .data-tbl td.c { text-align: center; }
.data-tbl td.method { font-size: var(--fs-xs); color: var(--text2); }
.nc-cell { color: var(--red); font-weight: 700; background: var(--danger-bg); }
.pass-cell { color: var(--green); font-weight: 700; }
.info-cell { color: var(--navy); font-weight: 600; }

/* 5g. Dashboard — My Reporting Jobs */
.mrj-card { background: #fff; border: 1px solid var(--border); border-radius: var(--r); padding: var(--sp-4) 18px; margin-bottom: var(--sp-4); border-top: 3px solid var(--orange); box-shadow: var(--sh-sm); }
.mrj-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-3); }
.mrj-title { font-size: var(--fs-lg); font-weight: 700; color: var(--navy); display: flex; align-items: center; gap: 8px; }
.mrj-sub { font-size: var(--fs-xs); color: var(--text3); }
.mrj-stats { display: flex; gap: 14px; margin-bottom: var(--sp-3); }
.mrj-stat { padding: 8px 14px; background: var(--bg); border-radius: var(--r-xs); }
.mrj-stat-val { font-size: 18px; font-weight: 700; color: var(--navy); font-family: var(--font-mono); }
.mrj-stat.red .mrj-stat-val { color: var(--red); }
.mrj-stat.amber .mrj-stat-val { color: var(--amber); }
.mrj-list { display: flex; flex-direction: column; gap: 6px; }
.mrj-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: var(--bg); border-radius: var(--r-xs); cursor: pointer; transition: background var(--t-fast);
}
.mrj-row:hover { background: var(--brand-bg); }
.mrj-row.past-due { background: var(--danger-bg); }
.mrj-row.past-due:hover { background: #fecaca; }
.mrj-jobid { font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 700; color: var(--orange); min-width: 90px; }
.mrj-client { font-size: var(--fs-sm); font-weight: 600; color: var(--navy); flex: 1; }
.mrj-region { font-size: 10px; padding: 2px 8px; background: #fff; border-radius: 10px; font-family: var(--font-mono); }
.mrj-due { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text3); }
.mrj-due.past { color: var(--danger-fg); font-weight: 700; }
.mrj-empty { font-size: var(--fs-sm); color: var(--text3); padding: 14px; text-align: center; font-style: italic; }
.mrj-cta { display: flex; gap: 8px; margin-top: 10px; align-items: center; flex-wrap: wrap; }

/* 5h. Workflow tracker */
.wf-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.wf-title { font-size: var(--fs-xl); font-weight: 700; color: var(--navy); }
.wf-sub { font-size: var(--fs-sm); color: var(--text3); margin-top: 2px; }
.wf-sync-col { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.wf-filters {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 14px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--rs); margin-bottom: var(--sp-3);
  box-shadow: var(--sh-sm);
}
.wf-chip {
  padding: 6px 12px; border-radius: var(--r-pill); background: var(--bg); border: 1px solid var(--border);
  font-size: var(--fs-xs); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--navy);
  white-space: nowrap; transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.wf-chip.active { background: var(--orange); color: #fff; border-color: var(--orange); }
.wf-chip:hover:not(.active) { border-color: var(--orange); color: var(--orange); }
.wf-flt-lbl { font-size: 10px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .5px; }
.wf-flt-sel { padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--r-xs); font-size: var(--fs-sm); background: #fff; font-family: var(--font); }
.wf-flt-spacer { flex: 1; }
.wf-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin-bottom: var(--sp-3); }
.wf-row { cursor: pointer; transition: background var(--t-fast); }
.wf-row:hover { background: var(--brand-bg); }
.wf-row.past-due { background: var(--danger-bg); } .wf-row.past-due:hover { background: #fecaca; }
.wf-row.due-soon { background: var(--warning-bg); } .wf-row.due-soon:hover { background: #fde68a; }
.wf-job-id { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--orange); font-weight: 700; }
.wf-due { font-family: var(--font-mono); font-size: var(--fs-xs); }
.wf-due.past { color: var(--danger-fg); font-weight: 700; }
.wf-due.soon { color: var(--warning-fg); font-weight: 700; }
.wf-region-pill { display: inline-block; padding: 2px 8px; background: var(--bg); border-radius: 10px; font-size: 10px; font-weight: 700; color: var(--navy); font-family: var(--font-mono); }
.wf-status-pill {
  display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 700;
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wf-status-pill.s4 { background: var(--brand-bg); color: var(--brand-fg); }
.wf-status-pill.s3 { background: #e0e7ff; color: #3730a3; }
.wf-status-pill.s2 { background: var(--info-bg); color: var(--info-fg); }
.wf-status-pill.s5 { background: var(--success-bg); color: var(--success-fg); }
.wf-status-pill.s1, .wf-status-pill.s0 { background: var(--neutral-bg); color: var(--neutral-fg); }
.wf-priority-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.wf-priority-badge.urgent { background: var(--danger-bg); color: var(--danger-fg); }
.wf-priority-badge.high   { background: var(--warning-bg); color: var(--warning-fg); }
.wf-priority-badge.normal { background: var(--success-bg); color: var(--success-fg); }
.wf-assignee-cell select { width: 100%; padding: 4px 6px; font-size: var(--fs-xs); border: 1px solid var(--border); border-radius: 4px; background: #fff; font-family: var(--font); }
.wf-comment-badge { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-xs); color: var(--text3); padding: 2px 6px; background: var(--bg); border-radius: 10px; }
.wf-comment-badge.has { color: var(--orange); background: var(--brand-bg); font-weight: 700; }
.wf-empty { text-align: center; color: var(--text3); padding: var(--sp-8); font-size: var(--fs-md); }

/* 5i. Workflow job modal */
.wjm-modal-head { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.wjm-modal-title { display: flex; align-items: center; gap: 10px; }
.wjm-modal-id { font-family: var(--font-mono); font-size: 15px; font-weight: 700; color: var(--orange); }
.wjm-modal-region { padding: 2px 8px; background: var(--bg); border-radius: 10px; font-size: 10px; font-weight: 700; color: var(--navy); font-family: var(--font-mono); }
.wjm-modal-body { padding: var(--sp-4) var(--sp-5); }
.wjm-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin-bottom: 14px; }
.wjm-field { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; background: var(--bg); border-radius: var(--r-xs); }
.wjm-field-lbl { font-size: 9px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .5px; }
.wjm-field-val { font-size: var(--fs-sm); color: var(--navy); font-weight: 600; }
.wjm-field-val.mono { font-family: var(--font-mono); font-size: var(--fs-xs); }
.wjm-status-pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 700; background: var(--brand-bg); color: var(--brand-fg); }
.wjm-section-hdr {
  font-size: var(--fs-xs); font-weight: 700; color: var(--text3); text-transform: uppercase;
  letter-spacing: .5px; margin: 14px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.wjm-assignee-row { display: flex; gap: 8px; align-items: center; }
.wjm-select { flex: 1; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--r-xs); font-size: var(--fs-sm); background: #fff; font-family: var(--font); }
.wjm-comments { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px; }
.wjm-comments-empty { font-size: var(--fs-sm); color: var(--text3); text-align: center; padding: var(--sp-5); font-style: italic; }
.wjm-comment { background: var(--bg); border-radius: var(--r-xs); padding: 8px 10px; }
.wjm-comment-head { display: flex; gap: 6px; align-items: baseline; font-size: var(--fs-xs); margin-bottom: 4px; }
.wjm-comment-author { font-weight: 700; color: var(--navy); }
.wjm-comment-handle { color: var(--text3); font-family: var(--font-mono); }
.wjm-comment-time { color: var(--text3); margin-left: auto; font-size: 10px; font-family: var(--font-mono); }
.wjm-comment-body { font-size: var(--fs-sm); color: var(--text2); white-space: pre-wrap; line-height: 1.4; }
.wjm-comment-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.wjm-comment-form textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r-xs);
  font-size: var(--fs-sm); resize: vertical; min-height: 60px; font-family: inherit;
}
.wjm-comment-form textarea:focus { outline: none; border-color: var(--orange); }
.wjm-comment-form button { align-self: flex-end; }
/* Pipeline steps inside job modal */
.wjm-pipeline { display: flex; align-items: center; margin: 14px 0; }
.wjm-step { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 0 0 auto; }
.wjm-step-circle {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-sm); font-weight: 700; border: 2px solid var(--border); background: #fff; color: var(--text3); transition: all .2s;
}
.wjm-step-circle.done   { background: var(--green); border-color: var(--green); color: #fff; }
.wjm-step-circle.active { background: var(--orange); border-color: var(--orange); color: #fff; }
.wjm-step-label { font-size: 10px; font-weight: 600; color: var(--text3); text-align: center; max-width: 70px; line-height: 1.2; }
.wjm-step-label.done   { color: var(--green); }
.wjm-step-label.active { color: var(--orange); }
.wjm-step-line { flex: 1; height: 2px; background: var(--border); margin: 0 4px; margin-bottom: 14px; }
.wjm-step-line.done { background: var(--green); }

/* 5j. User management */
.um-wrap { display: flex; flex-direction: column; gap: 18px; }
.um-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--sp-3); }
.um-card-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.um-card-title { font-size: var(--fs-lg); font-weight: 700; color: var(--navy); display: flex; align-items: center; gap: 8px; }
.um-card-sub { font-size: var(--fs-xs); color: var(--text3); }
.um-form { padding: 18px; display: grid; grid-template-columns: repeat(5,1fr) auto; gap: var(--sp-3); align-items: end; }
.um-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.um-field label { font-size: 10px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .5px; }
.um-field input, .um-field select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--rs);
  font-size: var(--fs-md); font-family: inherit; background: #fff; transition: border-color var(--t-fast);
}
.um-field input:focus, .um-field select:focus { outline: none; border-color: var(--orange); }
.um-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--navy); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--fs-sm); font-weight: 700; margin-right: 10px; vertical-align: middle;
}
.um-user-cell { display: flex; align-items: center; }
.um-user-meta { display: flex; flex-direction: column; line-height: 1.3; }
.um-user-name { font-weight: 600; font-size: var(--fs-md); color: var(--text); }
.um-user-handle { font-size: var(--fs-xs); color: var(--text3); }
.um-role-select {
  padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--r-xs); font-size: var(--fs-sm);
  font-family: inherit; background: #fff; min-width: 140px; cursor: pointer; transition: border-color var(--t-fast);
}
.um-role-select:hover { border-color: var(--navy); }
.um-role-select:focus { outline: none; border-color: var(--orange); }
.um-pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: var(--r-pill); font-size: 10px; font-weight: 700; letter-spacing: .4px; }
.um-pill.on  { background: var(--success-bg); color: var(--success-fg); }
.um-pill.off { background: var(--danger-bg); color: var(--danger-fg); }
.um-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.um-actions { display: inline-flex; gap: 6px; justify-content: flex-end; }
.um-iconbtn {
  display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px;
  padding: 0; border: 1px solid var(--border); border-radius: var(--r-xs); background: #fff;
  cursor: pointer; color: var(--text2); transition: all var(--t-fast);
}
.um-iconbtn:hover { transform: translateY(-1px); box-shadow: var(--sh-sm); }
.um-iconbtn.warn:hover   { background: var(--warning-bg); color: var(--warning-fg); border-color: var(--warning-bd); }
.um-iconbtn.ok:hover     { background: var(--success-bg); color: var(--success-fg); border-color: var(--success-bd); }
.um-iconbtn.info:hover   { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-bd); }
.um-iconbtn.danger:hover { background: var(--danger-bg); color: var(--danger-fg); border-color: var(--danger-bd); }
.um-iconbtn svg { width: 14px; height: 14px; }
.um-row.disabled { opacity: .55; }
.um-time { font-size: var(--fs-xs); color: var(--text3); font-variant-numeric: tabular-nums; }
.um-empty { text-align: center; color: var(--text3); padding: var(--sp-8); font-size: var(--fs-md); }
.um-modal-head { padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.um-modal-title { font-size: 15px; font-weight: 700; color: var(--navy); display: flex; align-items: center; gap: 8px; }
.um-modal-close { background: none; border: none; cursor: pointer; color: var(--text3); padding: 4px; border-radius: 4px; display: inline-flex; }
.um-modal-close:hover { background: var(--bg); color: var(--text); }
.um-modal-body { padding: var(--sp-5); overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.um-modal-sub { font-size: var(--fs-sm); color: var(--text3); margin-bottom: 14px; line-height: 1.5; }
.um-modal-sub strong { color: var(--navy); font-weight: 700; }
.um-modal-field { display: flex; flex-direction: column; gap: 6px; }
.um-modal-field label { font-size: 10px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .5px; }
.um-modal-field input { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--rs); font-size: var(--fs-lg); font-family: inherit; }
.um-modal-field input:focus { outline: none; border-color: var(--orange); }
.um-modal-hint { font-size: var(--fs-xs); color: var(--text3); margin-top: 4px; }
.um-modal-err { font-size: var(--fs-sm); color: var(--red); margin-top: 6px; min-height: 16px; }
.um-modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--bg); flex-shrink: 0; }
.um-role-diff { display: flex; align-items: center; gap: var(--sp-3); margin-top: 14px; }
.um-role-box { flex: 1; background: var(--bg); border: 1px solid var(--border); border-radius: var(--rs); padding: var(--sp-3) 14px; text-align: center; }
.um-role-box.new { background: var(--brand-bg); border-color: #fbb273; }
.um-role-box-lbl { font-size: 10px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.um-role-box-val { font-size: var(--fs-md); font-weight: 700; color: var(--navy); font-family: var(--font-mono); }
.um-role-box.new .um-role-box-val { color: var(--orange); }
.um-role-arrow { color: var(--text3); flex-shrink: 0; }

/* 5k. Audit trail */
.audit-tbl td, .audit-tbl th { padding: 9px 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-tbl tr:nth-child(even) td { background: #fafbfc; }
.audit-action { font-size: var(--fs-sm); font-weight: 600; }
.audit-action.create  { color: var(--teal); }
.audit-action.approve { color: var(--green); }
.audit-action.reject  { color: var(--red); }
.audit-action.update  { color: var(--orange); }
.audit-action.other   { color: var(--text2); font-weight: 400; }

/* 5l. Storage / history widgets */
.history-bar { display: flex; align-items: flex-end; gap: 2px; height: 60px; padding: 8px 0; }
.h-bar { background: var(--teal); border-radius: 2px 2px 0 0; min-width: 6px; transition: all .3s; position: relative; }
.h-bar.over { background: var(--red); }
.h-bar:hover .h-tooltip { display: block; }
.h-tooltip {
  display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: #333; color: #fff; font-size: 10px; padding: 3px 6px; border-radius: 4px; white-space: nowrap; z-index: 10;
}
.storage-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.storage-tab {
  padding: 7px 12px; border-radius: var(--r-pill); border: 1px solid var(--border); background: #fff;
  color: var(--navy); font-family: var(--font); font-size: var(--fs-sm); font-weight: 700; cursor: pointer;
  transition: all var(--t-fast); text-transform: capitalize;
}
.storage-tab:hover { border-color: var(--orange); color: var(--orange); }
.storage-tab.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.storage-row { border: 1px solid var(--border); border-radius: var(--rs); background: var(--bg); margin-bottom: var(--sp-3); overflow: hidden; }
.storage-row-top { padding: var(--sp-3) 14px; background: #fff; border-bottom: 1px solid var(--border); }
.storage-id { font-family: var(--font-mono); font-size: var(--fs-sm); font-weight: 600; color: var(--navy); }
.storage-summary { font-size: var(--fs-sm); color: var(--text3); margin-top: 4px; }
.storage-payload {
  margin: 0; padding: 14px; background: #0f172a; color: #dbe7f5; font-family: var(--font-mono);
  font-size: var(--fs-xs); line-height: 1.6; white-space: pre-wrap; word-break: break-word;
  max-height: 360px; overflow: auto;
}

/* Lucide icon helpers */
i[data-lucide] { display: inline-block; line-height: 0; vertical-align: middle; }
i[data-lucide] svg { display: block; }

/* ── 5m. Phase 3/4 additions ───────────────────────────────────────────────── */

/* Sortable table headers */
.tbl thead th { cursor: pointer; user-select: none; }
.tbl thead th[data-nosort] { cursor: default; }
.tbl thead th:not([data-nosort]):hover { color: var(--navy); }
.tbl thead th[data-sort]::after {
  content: ''; display: inline-block; margin-left: 5px;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  vertical-align: middle; opacity: .8;
}
.tbl thead th[data-sort="asc"]::after  { border-bottom: 5px solid var(--orange); }
.tbl thead th[data-sort="desc"]::after { border-top: 5px solid var(--orange); }

/* Tables get horizontal scroll when too wide; sticky header still works */
.card:has(> .tbl), .card:has(> table) { overflow-x: auto; }

/* Breadcrumb topbar */
.crumbs { display: flex; align-items: center; gap: 6px; }
.crumb-root { font-size: var(--fs-sm); color: var(--text3); font-weight: 600; }
.crumb-sep { color: var(--text3); opacity: .6; display: inline-flex; }
.crumb-sep svg { width: 12px; height: 12px; }

/* Sidebar collapse (desktop toggle mirrors the <900px responsive state) */
.sb-toggle {
  background: rgba(255,255,255,.08); border: none; color: rgba(255,255,255,.7);
  width: 100%; padding: 7px; border-radius: var(--r-xs); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--font); font-size: var(--fs-xs); font-weight: 600;
  transition: background var(--t-fast), color var(--t-fast); margin-bottom: 8px;
}
.sb-toggle:hover { background: rgba(255,255,255,.15); color: #fff; }
body.sb-collapsed .sb { width: 60px; }
body.sb-collapsed .sb-logo h1, body.sb-collapsed .sb-logo p,
body.sb-collapsed .nav-lbl, body.sb-collapsed .sb-logo-img,
body.sb-collapsed .sb-toggle span { display: none; }
body.sb-collapsed .main { margin-left: 60px; }
body.sb-collapsed .nav-item span { display: none; }
body.sb-collapsed .nav-item:hover span {
  display: block; position: absolute; left: 52px; top: 50%; transform: translateY(-50%);
  background: var(--navy3); color: #fff; padding: 5px 10px; border-radius: var(--r-xs);
  font-size: var(--fs-sm); white-space: nowrap; box-shadow: var(--sh-lg); z-index: 300;
}
.sb, .main { transition: width .2s ease, margin-left .2s ease; }

/* Login: show-password toggle + error shake */
.login-pw-wrap { position: relative; }
.login-pw-wrap .login-input { padding-right: 38px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--text3);
  padding: 6px; border-radius: var(--r-xs); display: inline-flex;
}
.pw-toggle:hover { color: var(--navy); }
.login-card.shake { animation: shake .35s ease; }
@keyframes shake {
  20% { transform: translateX(-8px); } 40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); } 80% { transform: translateX(3px); }
}

/* Content fade-out while old content is being swapped away */
#content.htmx-swapping { opacity: 0; transition: opacity .12s ease; }

/* Dashboard 14-day reports chart */
.dash-chart-wrap { padding: 4px 16px 0; }
.dash-chart-bars {
  display: flex; align-items: flex-end; gap: 5px;
  height: 168px; padding: 0; position: relative;
}
.dash-chart-grid {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: space-between;
  pointer-events: none; z-index: 0;
}
.dash-grid-line { width: 100%; border-top: 1px dashed rgba(100,116,139,.12); }
.dash-bar-col {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 3px; min-width: 0;
  height: 100%; justify-content: flex-end;
  position: relative; z-index: 1;
}
.dash-bar-val {
  font-size: 9px; font-weight: 700; color: var(--teal);
  line-height: 1; min-height: 11px;
  opacity: 0; transition: opacity .15s;
}
.dash-bar-col:hover .dash-bar-val { opacity: 1; }
.dash-bar-val.dash-bar-val-today { color: var(--orange); }
.dash-bar {
  width: 100%; max-width: 40px;
  background: linear-gradient(180deg, var(--teal) 0%, #076e70 100%);
  border-radius: 4px 4px 0 0; min-height: 3px;
  position: relative; transition: filter .15s, transform .15s;
  cursor: default;
}
.dash-bar:hover { filter: brightness(1.18); transform: scaleY(1.025); transform-origin: bottom; }
.dash-bar.today {
  background: linear-gradient(180deg, var(--orange) 0%, var(--orange-dark) 100%);
  box-shadow: 0 2px 10px rgba(232,97,10,.28);
}
.dash-bar.zero {
  background: #e8edf3; border-radius: 3px 3px 0 0; min-height: 3px;
}
.dash-bar.zero:hover { filter: none; transform: none; }
.dash-bar .h-tooltip { display: none; }
.dash-bar:hover .h-tooltip { display: block; bottom: calc(100% + 6px); }
.dash-bar-lbl {
  font-size: 9px; color: var(--text3); font-family: var(--font-mono);
  white-space: nowrap; letter-spacing: -.2px; line-height: 1.2;
}
.dash-bar-lbl.dash-lbl-today { color: var(--orange); font-weight: 700; }

/* Chart summary strip */
.dash-chart-summary {
  display: flex; align-items: center; gap: 0;
  padding: 11px 18px 13px;
  border-top: 1px solid var(--border);
  margin-top: 14px;
  background: #fafbfc;
  border-radius: 0 0 var(--r) var(--r);
}
.dash-sum-item { display: flex; flex-direction: column; gap: 2px; padding: 0 16px 0 0; }
.dash-sum-lbl {
  font-size: 10px; color: var(--text3);
  text-transform: uppercase; letter-spacing: .5px; font-weight: 600;
}
.dash-sum-val { font-size: 15px; font-weight: 700; color: var(--navy); }
.dash-sum-divider { width: 1px; height: 28px; background: var(--border); margin-right: 16px; flex-shrink: 0; }

/* ── 6. RESPONSIVE & PRINT ─────────────────────────────────────────────────── */
/* Mobile-only controls — hidden on desktop/tablet; shown in the ≤600 block.
   (Distinct from the existing .sb-toggle desktop collapse button.) */
.nav-hamburger { display: none; }
.sb-backdrop { display: none; }

@media (max-width: 1100px) {
  .um-form { grid-template-columns: repeat(2,1fr); }
  .um-stats { grid-template-columns: repeat(2,1fr); }
  .stats-grid { grid-template-columns: repeat(3,1fr); }
}
@media (max-width: 900px) {
  .sb { width: 60px; }
  .sb-logo h1, .sb-logo p, .nav-lbl, .sb-logo-img { display: none; }
  .main { margin-left: 60px; }
  .stats-grid, .wf-stats { grid-template-columns: 1fr 1fr; }
  .content { padding: 14px; }
  .upload-grid, .grid-2, .wjm-fields { grid-template-columns: 1fr; }
  /* Collapsed sidebar: hide label inline, show as tooltip on hover */
  .nav-item span { display: none; }
  .nav-item:hover span {
    display: block; position: absolute; left: 52px; top: 50%; transform: translateY(-50%);
    background: var(--navy3); color: #fff; padding: 5px 10px; border-radius: var(--r-xs);
    font-size: var(--fs-sm); white-space: nowrap; box-shadow: var(--sh-lg); z-index: 300;
  }
  .card { overflow-x: auto; }
}

/* ── Phone (≤600px): off-canvas sidebar + single-column, no-cutoff layout.
   Additive — desktop/tablet rules above are untouched. ei-class overrides
   (grids, chart width) live in extracted.css since it loads after this file. */
@media (max-width: 600px) {
  /* Sidebar slides in over the content; hidden by default. */
  .sb {
    width: 240px;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  body.nav-open .sb { transform: translateX(0); }
  .main { margin-left: 0; }

  /* The desktop "Collapse sidebar" state (body.sb-collapsed, persisted in
     localStorage) is meaningless on phones — neutralize its higher-specificity
     rules so the off-canvas menu is always full-width with labels, and the
     content never keeps the 60px rail indent. */
  body.sb-collapsed .main { margin-left: 0; }
  body.sb-collapsed .sb { width: 240px; }
  body.sb-collapsed .sb-logo h1, body.sb-collapsed .sb-logo p,
  body.sb-collapsed .nav-lbl, body.sb-collapsed .sb-logo-img { display: block; }
  body.sb-collapsed .nav-item span { display: inline; }
  /* The in-sidebar desktop collapse button has no meaning off-canvas. */
  .sb .sb-toggle { display: none; }

  /* Show full nav labels in the slide-in panel (override the ≤900 icon rail). */
  .sb-logo h1, .sb-logo p, .nav-lbl, .sb-logo-img { display: block; }
  .nav-item span,
  .nav-item:hover span {
    display: inline; position: static; transform: none; left: auto; top: auto;
    background: none; box-shadow: none; padding: 0; white-space: normal;
  }

  /* Hamburger (in the topbar) + tap-to-close backdrop. */
  .nav-hamburger {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; margin-right: 10px; flex-shrink: 0;
    background: none; border: 1px solid var(--border);
    border-radius: var(--r-xs); color: var(--navy); cursor: pointer;
  }
  .sb-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 99; }
  body.nav-open .sb-backdrop { display: block; }

  /* Topbar: wrap and shed the long subtitle / user chip to save width. */
  .topbar { flex-wrap: wrap; gap: 8px; padding: 12px 14px; }
  .topbar-sub, .topbar-user { display: none; }
  .topbar-right { flex-wrap: wrap; }
  .content { padding: 12px; }

  /* Stack every native multi-column grid to a single column. */
  .stats-grid, .wf-stats, .um-form, .um-stats, .grid-2, .upload-grid,
  .wjm-fields { grid-template-columns: 1fr; }

  /* Wide tables scroll inside their card — never cut off. */
  .card { overflow-x: auto; }

  /* Modals near full-screen. !important overrides any leftover inline width. */
  .modal, .um-modal, .wjm-modal, .login-card {
    width: 96vw !important; max-width: 96vw !important; max-height: 92vh;
  }

  /* Action rows wrap instead of overflowing. */
  .approval-bar { flex-wrap: wrap; }

  /* No sideways page scroll — any residual wide element scrolls in its card. */
  html, body { overflow-x: hidden; }

  /* Media never exceeds the frame. */
  img, canvas, svg, video { max-width: 100%; }

  /* Tab rows (e.g. Quotes/Jobs/Leads/Acknowledged) scroll instead of wrapping
     awkwardly or overflowing on narrow frames. */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab { white-space: nowrap; flex-shrink: 0; }

  /* 16px inputs stop iOS Safari's auto-zoom on focus (mobile-only). */
  input, select, textarea { font-size: 16px; }

  /* Compact topbar action buttons so both fit at 320px. */
  .sign-out-btn { padding: 6px 8px; font-size: var(--fs-xs); }

  /* Sidebar never wider than the smallest frames. */
  .sb { max-width: 84vw; }

  /* Chat history dropdown (inline 340px) fits the frame. */
  #wfmChatHistPanel { width: 90vw !important; max-width: 340px; }

  /* Always-visible scrollbars on ANY scrollable element — mobile browsers use
     hidden overlay scrollbars, so without this there's no hint that a table
     (flag matrices, permissions matrix, chat results…) continues sideways.
     Universal so it also covers wrappers with their own overflow styles. */
  *::-webkit-scrollbar { height: 8px; width: 8px; }
  *::-webkit-scrollbar-thumb { background: var(--text3); border-radius: 4px; }
  *::-webkit-scrollbar-track { background: var(--bg2); border-radius: 4px; }
  /* Firefox equivalent. */
  * { scrollbar-width: thin; scrollbar-color: var(--text3) var(--bg2); }
  .card, .ei-overflow-x, .wfm-result-wrap, .tabs {
    -webkit-overflow-scrolling: touch;
  }
}
@media print {
  .sb, .topbar, .btn, .upload-grid, .api-setup, .approval-bar, .toast-stack, .progress-bar { display: none !important; }
  .main { margin-left: 0; }
}

/* ── Form validation (error-only, Bootstrap-style) ───────────────────────────── */
input.is-invalid, select.is-invalid, textarea.is-invalid {
  border-color: var(--red) !important;
}
input.is-invalid, textarea.is-invalid {
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23dc2626'%3e%3cpath d='M8 0a8 8 0 100 16A8 8 0 008 0zM7 4a1 1 0 112 0v5a1 1 0 11-2 0V4zm1 9.5a1.25 1.25 0 110-2.5 1.25 1.25 0 010 2.5z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px 16px;
}
input.is-invalid:focus, select.is-invalid:focus, textarea.is-invalid:focus {
  border-color: var(--red) !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .12);
}
.invalid-feedback {
  display: none;
  color: var(--red);
  font-size: var(--fs-sm);
}
.is-invalid ~ .invalid-feedback { display: block; }
/* Rich-text (Quill) editor can't take the input styling above — give the
   editor container the same red border when its body is invalid. */
#tplEditor.is-invalid { border: 1px solid var(--red) !important; border-radius: 4px; }
/* Password fields with a show/hide toggle: keep the red border but drop the
   inline icon so it doesn't collide with the eye button. */
.login-pw-wrap input.is-invalid { background-image: none; }
/* Quill's stock link tooltip hardcodes a 170px URL input (quill.snow.css) —
   long URLs scroll inside it and read as cut off. Widened here (not in the
   vendored file) so a future Quill upgrade won't clobber it. `!important`
   because styles.css loads before quill.snow.css in index.html — equal
   specificity would otherwise let the later, vendored rule win. */
.ql-snow .ql-tooltip input[type=text] { width: 320px !important; max-width: 60vw; }
.ql-snow .ql-tooltip a.ql-preview { max-width: 320px !important; }

#wfmAckLogTable .sec-hdr{ padding: 0 15px 15px 15px; border-bottom: 1px solid var(--border);}
