/* Monjez theme tokens — density from procurement-create-redesign.html mockup
 * Single source of truth for --monjez-* / --ui-* (do not duplicate hard sizes in layout <style>).
 * Dark-mode primary #3b82f6 is a deliberate brighter tint of brand #0062ff for contrast on dark surfaces.
 */
:root {
  --monjez-primary: #0062ff;
  --monjez-primary-dark: #0043b3;
  --monjez-primary-soft: #dbeafe;
  --monjez-secondary: #10b981;
  --monjez-bg: #f8fafc;
  --monjez-card-bg: #ffffff;
  --monjez-header-bg: #ffffff;
  --monjez-border: #e2e8f0;
  --monjez-border-strong: #cbd5e1;
  --monjez-text: #0f172a;
  --monjez-muted: #64748b;
  --monjez-scrollbar-track: #f1f5f9;
  --monjez-scrollbar-thumb: var(--monjez-primary);
  --monjez-scrollbar-thumb-hover: #0043b3;
  /* Redesign density: body 14px · controls 10px · cards 18px · heroes 24px */
  --ui-font-body: 14px;
  --ui-font-control: 13.5px;
  --ui-font-btn: 13px;
  --ui-font-btn-sm: 12.5px;
  --ui-font-label: 12px;
  --ui-font-hint: 12px;
  --ui-font-title: 15px;
  --ui-radius-sm: 9px;
  --ui-radius: 10px;
  --ui-radius-md: 12px;
  --ui-radius-lg: 18px;
  --ui-radius-xl: 24px;
  --ui-btn-h: 2.5rem;       /* 40px */
  --ui-btn-sm-h: 2.25rem;   /* 36px */
  --ui-input-h: 2.75rem;    /* 44px */
  --ui-icon-btn: 2.375rem;  /* 38px */
  --ui-nav-h: 2.625rem;     /* 42px */
  --ui-topbar-h: 3.875rem;  /* 62px */
  --ui-sidebar-w: 248px;
  --ui-space: 0.875rem;
  --ui-card-pad: 1.375rem;  /* 22px */
  --ui-content-pad-y: 1.625rem; /* 26px */
  --ui-content-pad-x: 1.75rem;  /* 28px */
  --ui-focus-ring: 0 0 0 3.5px color-mix(in srgb, var(--monjez-primary) 14%, transparent);
}

html.dark {
  --monjez-bg: #020617;
  --monjez-card-bg: #0f172a;
  --monjez-header-bg: #0f172a;
  --monjez-border: #1e293b;
  --monjez-border-strong: #334155;
  --monjez-text: #f1f5f9;
  --monjez-muted: #94a3b8;
  /* Deliberate dark-surface tint of brand #0062ff */
  --monjez-primary: #3b82f6;
  --monjez-primary-dark: #2563eb;
  --monjez-primary-soft: rgba(59, 130, 246, 0.25);
  --monjez-secondary: #34d399;
  --monjez-scrollbar-track: #020617;
  --monjez-scrollbar-thumb: var(--monjez-primary);
  --monjez-scrollbar-thumb-hover: #60a5fa;
  --ui-focus-ring: 0 0 0 3px var(--monjez-primary-soft);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--monjez-scrollbar-thumb) var(--monjez-scrollbar-track);
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: var(--monjez-scrollbar-track);
}

*::-webkit-scrollbar-thumb {
  background-color: var(--monjez-scrollbar-thumb);
  border: 2px solid var(--monjez-scrollbar-track);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
  background-color: var(--monjez-scrollbar-thumb-hover);
}

*::-webkit-scrollbar-corner {
  background: var(--monjez-scrollbar-track);
}

body {
  font-family: 'Inter', 'Noto Sans Arabic', sans-serif;
  background-color: var(--monjez-bg);
  color: var(--monjez-text);
  line-height: 1.55;
}

/* Cards — redesign .card (18px radius, 22px pad) */
.o-card, .monjez-card, .card-monjez {
  background: var(--monjez-card-bg);
  border: 1px solid var(--monjez-border);
  border-radius: var(--ui-radius-lg);
  padding: var(--ui-card-pad);
  box-shadow: 0 1px 2px rgba(14, 21, 38, 0.05);
}

/* Buttons — redesign .btn (10px radius, 40×16, 13px) */
.o-btn-primary, .monjez-btn-primary,
.btn-monjez-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background-color: var(--monjez-primary);
  color: white;
  font-weight: 700;
  font-size: var(--ui-font-btn);
  line-height: 1.2;
  border-radius: var(--ui-radius);
  padding: 0 16px;
  height: var(--ui-btn-h);
  min-height: var(--ui-btn-h);
  border: 1px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 6px 16px -6px rgba(0, 98, 255, 0.45);
  white-space: nowrap;
}

.o-btn-primary:hover, .monjez-btn-primary:hover,
.btn-monjez-primary:hover {
  background-color: var(--monjez-primary-dark);
}

.o-btn-primary:focus-visible, .monjez-btn-primary:focus-visible,
.btn-monjez-primary:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus-ring);
}

/* Secondary / teal CTA */
.o-btn-secondary, .monjez-btn-secondary,
.btn-monjez-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background-color: var(--monjez-secondary);
  color: white;
  font-weight: 700;
  font-size: var(--ui-font-btn);
  line-height: 1.2;
  border-radius: var(--ui-radius);
  padding: 0 16px;
  height: var(--ui-btn-h);
  min-height: var(--ui-btn-h);
  border: 1px solid transparent;
  transition: background-color 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.o-btn-secondary:hover, .monjez-btn-secondary:hover,
.btn-monjez-secondary:hover {
  filter: brightness(1.06);
}

/* Ghost / outline button */
.btn-monjez-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--monjez-card-bg);
  border: 1px solid var(--monjez-border-strong);
  color: var(--monjez-text);
  font-weight: 700;
  font-size: var(--ui-font-btn);
  line-height: 1.2;
  border-radius: var(--ui-radius);
  padding: 0 16px;
  height: var(--ui-btn-h);
  min-height: var(--ui-btn-h);
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.btn-monjez-outline:hover {
  border-color: var(--monjez-primary);
  color: var(--monjez-primary);
}

.btn-monjez-sm {
  padding: 0 12px;
  font-size: var(--ui-font-btn-sm);
  height: var(--ui-btn-sm-h);
  min-height: var(--ui-btn-sm-h);
  border-radius: var(--ui-radius-sm);
}

html {
  height: 100%;
}

body {
  height: 100%;
  overflow: hidden;
  margin: 0;
}

#appShell {
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
  font-size: var(--ui-font-body);
}

/* Redesign radius map — align Tailwind radius utilities to mockup tokens */
#appShell .rounded-3xl {
  border-radius: var(--ui-radius-xl) !important;
}

#appShell .rounded-2xl {
  border-radius: var(--ui-radius-lg) !important;
}

#appShell .rounded-xl {
  border-radius: var(--ui-radius-md) !important;
}

#appShell .rounded-lg,
#appShell .rounded-md,
#appShell .rounded-\[9px\],
#appShell .rounded-\[10px\] {
  border-radius: var(--ui-radius) !important;
}

#appShell .rounded-\[12px\] {
  border-radius: var(--ui-radius-md) !important;
}

#appShell .rounded-\[14px\],
#appShell .rounded-\[18px\] {
  border-radius: var(--ui-radius-lg) !important;
}

/* Shared form controls inside shell — redesign .input/.select (44px, 13.5px, 10px radius) */
#appShell input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]),
#appShell select,
#appShell textarea {
  border-radius: var(--ui-radius);
  font-size: var(--ui-font-control);
  min-height: var(--ui-input-h);
  padding: 10px 13px;
}

#appShell textarea {
  min-height: 74px;
}

/* iOS: prevent input zoom — controls ≥16px on small screens */
@media (max-width: 960px) {
  #appShell input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]),
  #appShell select,
  #appShell textarea {
    font-size: 16px;
  }
}

#appShell input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]):focus,
#appShell select:focus,
#appShell textarea:focus {
  outline: none;
  border-color: var(--monjez-primary);
  box-shadow: var(--ui-focus-ring);
}

/* Icon buttons / shell chrome — redesign .icon-btn 38×38 @ 10px */
#appShell .h-\[38px\].w-\[38px\],
#appShell .w-\[38px\].h-\[38px\] {
  width: var(--ui-icon-btn) !important;
  height: var(--ui-icon-btn) !important;
}

@media (min-width: 768px) {
  #appShell .min-h-\[40px\] {
    min-height: var(--ui-btn-h);
  }

  #appShell .min-h-\[44px\] {
    min-height: var(--ui-input-h);
  }

  #appShell .h-10 {
    height: var(--ui-btn-h);
  }

  #appShell .h-9 {
    height: var(--ui-btn-sm-h);
  }

  #appShell .h-8 {
    height: var(--ui-btn-sm-h);
  }

  /* Card / page padding aligned to redesign (22px / 26–28px) */
  #appShell .p-6 {
    padding: var(--ui-card-pad) !important;
  }

  #appShell .p-5 {
    padding: 1rem !important;
  }

  #appShell .p-8 {
    padding: var(--ui-content-pad-y) var(--ui-content-pad-x) !important;
  }

  #appShell .p-4 {
    padding: 0.875rem !important;
  }

  /* Cap oversized page titles to redesign page-title range (16–18px) */
  #appShell .text-2xl {
    font-size: 1.125rem !important; /* 18px */
    line-height: 1.25 !important;
    letter-spacing: -0.02em;
  }

  #appShell .text-xl {
    font-size: 1rem !important; /* 16px */
    line-height: 1.3 !important;
  }

  #appShell .text-lg {
    font-size: 0.9375rem !important; /* 15px — card titles */
    line-height: 1.35 !important;
  }

  #appShell .mb-8 {
    margin-bottom: 1.25rem !important;
  }

  #appShell .gap-6 {
    gap: 1rem !important;
  }
}

@media (min-width: 1024px) {
  #appShell {
    display: grid;
    align-items: stretch;
    grid-template-rows: minmax(0, 1fr);
  }

  #appShell > aside#sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
  }
}

#appShell > main {
  min-height: 0;
  max-height: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#appShell > main > footer {
  flex-shrink: 0;
}

#appShell > main > section {
  flex: 1 1 0;
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

/* Page content padding — redesign .page (26×28) */
#appShell > main > section.app-content {
  padding: 1rem;
}

@media (min-width: 768px) {
  #appShell > main > section.app-content {
    padding: var(--ui-content-pad-y) var(--ui-content-pad-x);
  }
}

/* Document show pages need more viewport for the sheet and less decorative chrome. */
#appShell > main > section:has(.fwo-show-layout) {
  padding: var(--ui-content-pad-y) var(--ui-content-pad-x) 1.5rem;
}

#appShell > main > section:has(.fwo-show-layout) > .relative.overflow-hidden.rounded-3xl.bg-slate-900 {
  border-radius: var(--ui-radius-xl);
  margin-bottom: 1.25rem;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.12);
}

#appShell > main > section:has(.fwo-show-layout) > .relative.overflow-hidden.rounded-3xl.bg-slate-900 > .relative {
  padding: 0.875rem 1.25rem;
  gap: 1rem;
}

#appShell > main > section:has(.fwo-show-layout) > .relative.overflow-hidden.rounded-3xl.bg-slate-900 .w-20.h-20 {
  width: 3rem;
  height: 3rem;
  border-radius: 0.75rem;
  font-size: 1.35rem;
}

#appShell > main > section:has(.fwo-show-layout) > .relative.overflow-hidden.rounded-3xl.bg-slate-900 h1 {
  font-size: 1.25rem;
  line-height: 1.25;
}

#appShell > main > section:has(.fwo-show-layout) > .relative.overflow-hidden.rounded-3xl.bg-slate-900 .mb-2 {
  margin-bottom: 0.25rem;
}

#appShell > main > section:has(.fwo-show-layout) > .relative.overflow-hidden.rounded-3xl.bg-slate-900 .gap-6 {
  gap: 0.85rem;
}

#appShell > main > section:has(.fwo-show-layout) > .relative.overflow-hidden.rounded-3xl.bg-slate-900 .h-12 {
  height: 2.5rem;
}

#appShell > main > section:has(.fwo-show-layout) > .relative.overflow-hidden.rounded-3xl.bg-slate-900 .px-6 {
  padding-left: 1rem;
  padding-right: 1rem;
}

#appShell > main > section:has(.fwo-show-layout) > .mb-6 {
  margin-bottom: 0.75rem;
}

#appShell > main > section:has(.fwo-show-layout) > .mb-6[class*="border-l-4"] {
  padding: 0.75rem 1rem;
  border-radius: 0 0.75rem 0.75rem 0;
}

/* CRM site profile — Leaflet map */
.crm-site-map.leaflet-container {
  z-index: 0;
  font-family: inherit;
}

.crm-site-location .leaflet-control-attribution {
  font-size: 10px;
}

/* Field stations — site detail OSM preview */
.field-site-map {
  height: 220px;
  width: 100%;
  z-index: 0;
  background: #e2e8f0;
}

.field-site-map.leaflet-container {
  z-index: 0;
  font-family: inherit;
}

.field-site-map .leaflet-control-attribution {
  font-size: 10px;
}

html.dark .field-site-map {
  background: #0f172a;
}

@media (min-width: 768px) {
  .field-site-map {
    height: 280px;
  }
}

/* Letter composer: fill main content below app + page headers */
main > section:has(.letter-maker-shell) {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.letter-maker-shell {
  --letter-workspace-h: calc(100vh - 10.5rem);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: none;
}

@media (min-width: 768px) {
  .letter-maker-shell {
    min-height: var(--letter-workspace-h);
    max-height: var(--letter-workspace-h);
  }
}

.letter-maker-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  min-height: 0;
}

@media (min-width: 768px) {
  .letter-maker-grid {
    flex: 1 1 0;
    flex-direction: row;
    align-items: stretch;
    overflow: hidden;
    gap: 1rem;
  }
}

.letter-maker-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  width: 100%;
}

@media (min-width: 768px) {
  .letter-maker-sidebar {
    flex: 0 0 280px;
    width: 280px;
    max-width: 280px;
  }
}

.letter-maker-sidebar__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.letter-maker-sidebar__footer {
  flex-shrink: 0;
  padding-top: 0.75rem;
  margin-top: 0.25rem;
  border-top: 1px solid rgb(226 232 240);
  background: rgb(248 250 252);
}

html.dark .letter-maker-sidebar__footer {
  border-top-color: rgb(30 41 59);
  background: rgb(15 23 42);
}

.letter-maker-editor {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 28rem;
  overflow: hidden;
}

@media (min-width: 768px) {
  .letter-maker-editor {
    flex: 1 1 0;
    min-height: 0;
    height: auto;
    align-self: stretch;
  }
}

.letter-composer-workspace {
  background: #cbd5e1;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.35) 1px, transparent 1px);
  background-size: 20px 20px;
  padding: 1.25rem;
}

html.dark .letter-composer-workspace {
  background: #334155;
}

.letter-maker-editor .letter-page-sheet {
  width: min(21cm, 100%);
}

.letter-page-sheet {
  position: relative;
  margin-left: auto;
  margin-right: auto;
  width: 21cm;
  min-height: 29.7cm;
  padding: 2cm;
  background: #fff;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.18);
  box-sizing: border-box;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

.letter-page-sheet.letter-signature-placing {
  cursor: crosshair;
}

.letter-signature-placement {
  position: absolute;
  z-index: 5;
  transform: translate(-50%, -50%);
  pointer-events: none;
  max-width: 38%;
}

.letter-signature-placement img {
  display: block;
  max-width: 100%;
  height: auto;
}

.letter-maker-sidebar .letter-signed-panel {
  max-width: 100%;
}

.letter-signed-panel-title {
  font-weight: 600;
  margin: 0 0 10px;
}

.letter-signed-hint,
.letter-signed-locked-msg {
  font-size: 0.875rem;
  color: #64748b;
  margin: 0 0 12px;
}

html.dark .letter-signed-hint,
html.dark .letter-signed-locked-msg {
  color: #94a3b8;
}

.letter-signed-method-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.letter-signed-method-tab span {
  display: block;
  padding: 8px 14px;
  min-height: 40px;
  font-size: 0.875rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  cursor: pointer;
  text-align: center;
}

html.dark .letter-signed-method-tab span {
  border-color: #475569;
}

.letter-signed-method-tab input:checked + span {
  background: #0062ff;
  border-color: #0062ff;
  color: #fff;
}

.letter-signed-open-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.875rem;
  color: #0062ff;
}

.letter-signed-method-panel.hidden {
  display: none;
}

.letter-signed-method-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.letter-signed-method-tab {
  position: relative;
  flex: 1;
  min-width: 140px;
  cursor: pointer;
}

.letter-signed-outcome-fieldset {
  border: 0;
  margin: 0 0 12px;
  padding: 0;
}

.letter-signed-outcome-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 6px;
}

.letter-signed-outcome-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
}

.letter-signed-label {
  display: block;
  font-size: 0.875rem;
  margin-bottom: 6px;
}

.letter-signed-file-input {
  display: block;
  width: 100%;
  margin-bottom: 10px;
  min-height: 40px;
}

.letter-signed-submit-btn {
  display: block;
  width: 100%;
  min-height: 40px;
  margin-top: 10px;
  padding: 8px 16px;
  border: 0;
  border-radius: 6px;
  background: #0062ff;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
}

.letter-signed-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.letter-signed-secondary-btn {
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  cursor: pointer;
  font-size: 13px;
}

.letter-signed-pad-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  margin-top: 10px;
}

.signature-pad-block .signature-canvas {
  display: block;
  width: 100%;
  height: 120px;
  border: 1px dashed #94a3b8;
  border-radius: 6px;
  background: #fff;
  touch-action: none;
}

.letter-signed-place-hint {
  font-size: 12px;
  color: #64748b;
  margin: 8px 0 0;
}

.letter-signed-place-hint.hidden {
  display: none;
}

.letter-signed-preview-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(100%, 280px);
  margin-top: 10px;
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
  text-align: start;
}

.letter-signed-preview-thumb {
  width: 44px;
  height: 56px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  font-size: 13px;
  font-weight: 700;
}

.letter-signed-preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.letter-signed-preview-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.letter-signed-preview-hint {
  display: block;
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}

.letter-registry-table .letter-thread-head td {
  border-top-width: 2px;
}

.letter-registry-table .letter-thread-revision td {
  font-size: 0.8125rem;
}

.letter-editor-wrap {
  min-height: 22cm;
}

.letter-editor-wrap .ql-container {
  min-height: 22cm;
  border: 0 !important;
  font-family: 'Inter', 'Noto Sans Arabic', 'Segoe UI', sans-serif;
  font-size: 12pt;
  line-height: 1.65;
}

.letter-editor-wrap .ql-editor {
  min-height: 22cm;
  padding: 0 !important;
  line-height: 1.65;
}

.letter-editor-wrap .ql-editor[dir='rtl'] {
  text-align: right;
}

.letter-editor-wrap .ql-editor[dir='ltr'] {
  text-align: left;
}

.letter-page-sheet[dir='rtl'] .letter-editor-wrap .ql-editor {
  text-align: right;
}

.letter-page-sheet[dir='ltr'] .letter-editor-wrap .ql-editor {
  text-align: left;
}

/* Letter multi-page tab bar */
.letter-page-bar {
  min-height: 40px;
}

.letter-page-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  min-height: 32px;
  font-size: 0.8125rem;
  font-weight: 500;
  border: 1px solid rgb(203 213 225);
  border-radius: 6px;
  background: #fff;
  color: rgb(51 65 85);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.letter-page-tab:hover {
  background: rgb(241 245 249);
}

.letter-page-tab--active {
  background: #0062ff;
  border-color: #0062ff;
  color: #fff;
}

.letter-page-tab--active:hover {
  background: #0b6fce;
}

html.dark .letter-page-tab {
  border-color: rgb(71 85 105);
  background: rgb(30 41 59);
  color: rgb(203 213 225);
}

html.dark .letter-page-tab:hover {
  background: rgb(51 65 85);
}

html.dark .letter-page-tab--active {
  background: #0062ff;
  border-color: #0062ff;
  color: #fff;
}

.letter-page-tab__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}

.letter-page-tab__remove:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.12);
}

.letter-page-tab--active .letter-page-tab__remove:hover {
  background: rgba(255, 255, 255, 0.25);
}

.letter-page-add-btn {
  transition: background 0.15s;
}

.letter-quill-toolbar.ql-toolbar {
  border: 0;
  flex-wrap: wrap;
}

.letter-quill-toolbar.ql-toolbar.ql-snow {
  border-bottom: 1px solid rgb(226 232 240);
}

html.dark .letter-quill-toolbar.ql-toolbar.ql-snow {
  border-bottom-color: rgb(30 41 59);
}

.template-picker-preview {
  aspect-ratio: 210 / 297;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: rgb(100 116 139);
  font-size: 0.875rem;
}

.template-picker-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.letter-attachment-thumb {
  width: 52px;
  height: 68px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgb(203 213 225);
  border-radius: 6px;
  background: rgb(248 250 252);
  color: rgb(51 65 85);
  overflow: hidden;
  cursor: pointer;
}

.letter-attachment-thumb:hover,
.letter-attachment-card:hover {
  border-color: rgb(8 95 182);
}

html.dark .letter-attachment-thumb,
html.dark .letter-attachment-card {
  border-color: rgb(51 65 85);
  background: rgb(15 23 42);
  color: rgb(226 232 240);
}

.letter-attachment-thumb img,
.letter-attachment-thumb iframe {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 0;
  pointer-events: none;
}

.letter-attachment-thumb-icon {
  font-size: 1.4rem;
}

.letter-attachment-card {
  width: min(100%, 18rem);
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem;
  border: 1px solid rgb(203 213 225);
  border-radius: 8px;
  background: rgb(248 250 252);
  color: inherit;
  cursor: pointer;
}

.letter-attachment-card-preview {
  width: 44px;
  height: 56px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
  font-size: 1.15rem;
  color: rgb(51 65 85);
}

html.dark .letter-attachment-card-preview {
  background: rgb(2 6 23);
  color: rgb(226 232 240);
}

.letter-attachment-card-preview img,
.letter-attachment-card-preview iframe {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 0;
  pointer-events: none;
}

/* Approval inbox — single-request review modal */
.approval-inbox-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 60;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.approval-inbox-modal.is-open {
  display: flex;
}

.approval-inbox-modal[hidden]:not(.is-open) {
  display: none;
}

.approval-inbox-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  cursor: pointer;
}

.approval-inbox-modal-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 42rem);
  max-height: min(92vh, 900px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid rgb(226 232 240);
  border-radius: 1rem;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.2);
  overflow: hidden;
}

html.dark .approval-inbox-modal-panel {
  background: rgb(15 23 42);
  border-color: rgb(51 65 85);
}

.approval-inbox-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgb(226 232 240);
}

html.dark .approval-inbox-modal-header {
  border-bottom-color: rgb(51 65 85);
}

.approval-inbox-modal-body {
  padding: 16px 20px 20px;
  overflow-y: auto;
}

html.approval-inbox-modal-open {
  overflow: hidden;
}

#chat-approval-modal.approval-inbox-modal {
  z-index: 90;
}

.chat-approval-link {
  display: inline-flex;
  align-items: center;
  margin-top: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 0.65rem;
  font-weight: 700;
  font-size: 0.8125rem;
  background: rgb(0 98 255 / 0.12);
  color: #0052d6;
  text-decoration: none;
}

html.dark .chat-approval-link {
  background: rgb(0 98 255 / 0.22);
  color: #93c5fd;
}

.chat-approval-link:hover {
  background: rgb(0 98 255 / 0.2);
  text-decoration: none;
}

.letter-attachment-modal-body {
  height: min(78vh, 760px);
  display: grid;
  place-items: center;
  background: rgb(241 245 249);
}

html.dark .letter-attachment-modal-body {
  background: rgb(2 6 23);
}

.letter-attachment-modal-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.letter-attachment-modal-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.letter-attachment-modal-file {
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  color: rgb(71 85 105);
}

.letter-attachment-modal-file i {
  font-size: 3rem;
}

.document-template-canvas-shell {
  background: #cbd5e1;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.35) 1px, transparent 1px);
  background-size: 20px 20px;
  overflow: auto;
}

.document-template-sheet {
  background: white;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.24);
  line-height: 0;
  transform-origin: top center;
}

/* ── Page boot preloader ─────────────────────────────────────────── */
.page-preloader {
  --pl-brand: #0062ff;
  --pl-brand-deep: #0043b3;
  --pl-brand-soft: rgba(0, 98, 255, 0.14);
  --pl-ink: #1e2230;
  --pl-muted: #67738d;
  --pl-surface: #f6f7f9;
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1.35rem;
  background: var(--pl-surface);
  color: var(--pl-ink);
  opacity: 1;
  visibility: visible;
  transform: scale(1);
  filter: blur(0);
  transition:
    opacity 0.42s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.42s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.42s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.42s ease;
}

.dark .page-preloader {
  --pl-surface: #0a0c12;
  --pl-ink: #eceef2;
  --pl-muted: #8591a8;
  --pl-brand-soft: rgba(59, 130, 246, 0.18);
}

.page-preloader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(1.04);
  filter: blur(6px);
}

.page-preloader-ambient {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.page-preloader-glow {
  position: absolute;
  border-radius: 999px;
  filter: blur(48px);
  opacity: 0.55;
  animation: preloaderGlowDrift 5.5s ease-in-out infinite alternate;
}

.page-preloader-glow--a {
  width: min(52vw, 28rem);
  height: min(52vw, 28rem);
  top: 12%;
  left: 18%;
  background: radial-gradient(circle, rgba(0, 98, 255, 0.35) 0%, transparent 70%);
}

.page-preloader-glow--b {
  width: min(40vw, 20rem);
  height: min(40vw, 20rem);
  bottom: 10%;
  right: 12%;
  background: radial-gradient(circle, rgba(0, 79, 224, 0.22) 0%, transparent 70%);
  animation-delay: -2.2s;
  animation-duration: 7s;
}

.dark .page-preloader-glow--a {
  background: radial-gradient(circle, rgba(89, 139, 255, 0.28) 0%, transparent 70%);
}

.dark .page-preloader-glow--b {
  background: radial-gradient(circle, rgba(0, 98, 255, 0.2) 0%, transparent 70%);
}

.page-preloader-grid {
  position: absolute;
  inset: -20%;
  background-image:
    linear-gradient(rgba(0, 98, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 98, 255, 0.045) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse 55% 50% at 50% 48%, #000 20%, transparent 72%);
  -webkit-mask-image: radial-gradient(ellipse 55% 50% at 50% 48%, #000 20%, transparent 72%);
  animation: preloaderGridDrift 12s linear infinite;
  opacity: 0.9;
}

.dark .page-preloader-grid {
  background-image:
    linear-gradient(rgba(89, 139, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(89, 139, 255, 0.06) 1px, transparent 1px);
}

.page-preloader-stage {
  position: relative;
  z-index: 1;
  width: 5.5rem;
  height: 5.5rem;
  display: grid;
  place-items: center;
  animation: preloaderStageIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.page-preloader-orbit {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  border: 1.5px solid transparent;
  pointer-events: none;
}

.page-preloader-orbit--outer {
  border-top-color: var(--pl-brand, #0062ff);
  border-right-color: rgba(0, 98, 255, 0.18);
  animation: preloaderOrbitSpin 1.15s cubic-bezier(0.55, 0.05, 0.35, 0.95) infinite;
  box-shadow: 0 0 0 1px rgba(0, 98, 255, 0.04);
}

.page-preloader-orbit--inner {
  inset: 0.55rem;
  border-bottom-color: var(--pl-brand-deep, #0043b3);
  border-left-color: rgba(0, 98, 255, 0.22);
  animation: preloaderOrbitSpin 0.85s linear infinite reverse;
}

.page-preloader-pulse {
  position: absolute;
  inset: 0.95rem;
  border-radius: 999px;
  background: var(--pl-brand-soft, rgba(0, 98, 255, 0.14));
  animation: preloaderPulse 1.8s ease-in-out infinite;
}

.page-preloader-mark {
  position: relative;
  z-index: 1;
  width: 3.15rem;
  height: 3.15rem;
  display: grid;
  place-items: center;
  border-radius: 0.9rem;
  background: transparent;
  color: #fff;
  overflow: hidden;
  box-shadow:
    0 8px 28px -6px rgba(0, 98, 255, 0.45),
    0 0 0 4px rgba(0, 98, 255, 0.12);
  animation: preloaderMarkFloat 2.4s ease-in-out infinite;
}
.page-preloader-mark img {
  width: 100%;
  height: 100%;
  display: block;
}

.page-preloader-brand {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 0.7rem;
  animation: preloaderBrandIn 0.6s 0.12s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.page-preloader-text {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--pl-brand, #0062ff);
  padding-inline-start: 0.28em; /* optical balance for tracking */
}

.dark .page-preloader-text {
  color: #3b82f6;
}

.page-preloader-bar {
  width: 4.5rem;
  height: 3px;
  border-radius: 999px;
  background: rgba(0, 98, 255, 0.12);
  overflow: hidden;
}

.dark .page-preloader-bar {
  background: rgba(89, 139, 255, 0.16);
}

.page-preloader-bar > span {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pl-brand, #0062ff), #3b82f6, var(--pl-brand-deep, #0043b3));
  background-size: 200% 100%;
  animation: preloaderBarSweep 1.15s ease-in-out infinite;
}

/* Compact spinner used inside MonjezLoading action panel */
.page-preloader-ring {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  border: 2.5px solid rgba(0, 98, 255, 0.16);
  border-top-color: var(--pl-brand, #0062ff);
  animation: preloaderOrbitSpin 0.75s linear infinite;
}

/* Action-loader compact stage (no full-page ambient) */
.monjez-action-loader-panel .page-preloader-stage {
  width: 4.25rem;
  height: 4.25rem;
  animation: none;
}

.monjez-action-loader-panel .page-preloader-mark {
  width: 2.55rem;
  height: 2.55rem;
  font-size: 1.1rem;
  border-radius: 0.75rem;
}

.monjez-action-loader-panel .page-preloader-brand {
  animation: none;
  gap: 0.55rem;
}

.monjez-action-loader-panel .page-preloader-text {
  color: inherit;
  letter-spacing: 0.06em;
  font-weight: 700;
  text-transform: none;
  padding-inline-start: 0;
  font-size: 0.82rem;
}

.monjez-action-loader-panel .page-preloader-bar {
  width: 3.75rem;
}

@keyframes preloaderOrbitSpin {
  to { transform: rotate(360deg); }
}

@keyframes preloaderMarkFloat {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-5px) rotate(2deg); }
}

@keyframes preloaderPulse {
  0%, 100% { transform: scale(0.92); opacity: 0.55; }
  50% { transform: scale(1.08); opacity: 0.95; }
}

@keyframes preloaderGlowDrift {
  from { transform: translate3d(-4%, -2%, 0) scale(1); }
  to { transform: translate3d(4%, 3%, 0) scale(1.08); }
}

@keyframes preloaderGridDrift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-28px, -28px, 0); }
}

@keyframes preloaderBarSweep {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(280%); }
}

@keyframes preloaderStageIn {
  from { opacity: 0; transform: scale(0.72); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes preloaderBrandIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .page-preloader,
  .page-preloader-glow,
  .page-preloader-grid,
  .page-preloader-orbit,
  .page-preloader-pulse,
  .page-preloader-mark,
  .page-preloader-stage,
  .page-preloader-brand,
  .page-preloader-bar > span,
  .page-preloader-ring {
    transition: none !important;
    animation: none !important;
  }

  .page-preloader.is-hidden {
    transform: none;
    filter: none;
  }
}

.sidebar-collapsed #sidebar {
  width: 72px;
}

.sidebar-collapsed .menu-label,
.sidebar-collapsed .menu-caret,
.sidebar-collapsed .menu-children,
.sidebar-collapsed .brand-text {
  display: none;
}

.sidebar-collapsed .menu-item {
  justify-content: center;
}

.sidebar-collapsed .brand-mini {
  display: flex;
}

.brand-mini {
  display: none;
}

.menu-icon {
  width: 1.1rem;
  text-align: center;
}

.menu-caret {
  transition: transform 0.2s ease;
}

.menu-caret.open {
  transform: rotate(180deg);
}

/* Action overlay (save / slow POST) — Monjez v2 */
.monjez-action-loader {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: grid;
  place-items: center;
  pointer-events: auto;
}

.monjez-action-loader.is-hidden {
  display: none;
}

.monjez-action-loader-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

html.dark .monjez-action-loader-backdrop {
  background: rgba(2, 6, 23, 0.65);
}

.monjez-action-loader-panel {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 0.9rem;
  padding: 1.35rem 1.75rem 1.25rem;
  border-radius: 1rem;
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.18);
  min-width: 11rem;
  overflow: hidden;
}

html.dark .monjez-action-loader-panel {
  background: #0f172a;
  color: #e2e8f0;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
}

body.monjez-action-loading {
  overflow: hidden;
}

/* SweetAlert2 — Monjez v2 */
.swal2-container {
  z-index: 11000;
}

.swal2-popup {
  font-family: 'Inter', 'Noto Sans Arabic', sans-serif;
  border-radius: 0.75rem;
}

html.dark .swal2-popup {
  background: #0f172a;
  color: #e2e8f0;
}

html.dark .swal2-title,
html.dark .swal2-html-container {
  color: #e2e8f0;
}

.monjez-swal-confirm.swal2-styled {
  background-color: #0062ff !important;
  border-radius: 0.5rem;
  font-weight: 600;
}

.monjez-swal-deny.swal2-styled {
  background-color: #334155 !important;
  border-radius: 0.5rem;
  font-weight: 600;
}

.monjez-swal-cancel.swal2-styled {
  border-radius: 0.5rem;
  font-weight: 600;
}

@media print {
  #sidebar,
  #overlay,
  #openSidebar,
  #closeSidebar,
  #navBack,
  #toggleCollapse,
  #themeToggle,
  #languageToggle,
  #printSummary,
  #pagePreloader,
  header:not(.formal-doc-head),
  footer:not(.formal-doc-footer),
  .pr-no-print,
  .no-print {
    display: none !important;
  }

  #appShell {
    display: block !important;
  }

  main {
    width: 100% !important;
  }

  section.p-4,
  section[class*='p-4'] {
    padding: 0 !important;
  }

  .pr-print-only {
    display: block !important;
  }

  .pr-print-sheet {
    color: #000 !important;
    font-size: 11pt;
  }

  .pr-print-sheet table {
    width: 100%;
    border-collapse: collapse;
  }

  .pr-print-sheet th,
  .pr-print-sheet td {
    border: 1px solid #cbd5e1;
    padding: 4px 8px;
    vertical-align: top;
  }

  .pr-print-sheet thead th {
    background: #f1f5f9 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .print-summary {
    page-break-inside: avoid;
  }
}

/* —— Offline / connection modal (global) —— */
html.monjez-conn-blocked {
  overflow: hidden;
}

/* Product catalogue picker — force viewport centering (do not rely on Tailwind flex alone) */
#prodPickerModal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
#prodPickerModal:not(.hidden) {
  display: flex !important;
}

.monjez-conn-modal {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.monjez-conn-modal.hidden {
  display: none !important;
}

.monjez-conn-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}

.monjez-conn-modal__panel {
  position: relative;
  width: min(100%, 26rem);
  border-radius: 1rem;
  padding: 1.5rem 1.25rem 1.25rem;
  background: #fff;
  color: #0f172a;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
  text-align: center;
}

.dark .monjez-conn-modal__panel {
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #1e293b;
}

.monjez-conn-modal__icon {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 0.75rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #fee2e2;
  color: #dc2626;
  font-size: 1.25rem;
}

.dark .monjez-conn-modal__icon {
  background: rgba(220, 38, 38, 0.2);
  color: #f87171;
}

.monjez-conn-modal__title {
  font-size: 1.125rem;
  font-weight: 800;
  margin: 0 0 0.5rem;
}

.monjez-conn-modal__body {
  font-size: 0.9rem;
  line-height: 1.45;
  color: #64748b;
  margin: 0 0 1rem;
}

.dark .monjez-conn-modal__body {
  color: #94a3b8;
}

.monjez-conn-modal__status {
  font-size: 0.8rem;
  margin: 0 0 1rem;
  color: #475569;
}

.dark .monjez-conn-modal__status {
  color: #94a3b8;
}

#monjezConnStatusText[data-tone="ok"] { color: #059669; }
#monjezConnStatusText[data-tone="bad"] { color: #dc2626; }
#monjezConnStatusText[data-tone="warn"] { color: #d97706; }

.monjez-conn-modal__retry {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 0.75rem;
  background: #2563eb;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.monjez-conn-modal__retry:hover {
  background: #1d4ed8;
}

/* ---- Financial custody wallet (portal) ---- */
.fc-wallet {
  max-width: 520px;
  margin-inline: auto;
}
.fc-wallet-hero {
  border-radius: 22px;
  padding: 1.35rem 1.4rem 1.5rem;
  background: linear-gradient(145deg, #0062ff 0%, #0047b8 55%, #003a96 100%);
  color: #fff;
  box-shadow: 0 12px 32px rgba(0, 98, 255, 0.28);
  position: relative;
  overflow: hidden;
}
.fc-wallet-hero::after {
  content: '';
  position: absolute;
  inset: auto -20% -40% auto;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  pointer-events: none;
}
.fc-wallet-hero__label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.8;
}
.fc-wallet-hero__balance {
  font-size: 2.15rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  margin-top: 0.35rem;
}
.fc-wallet-hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-top: 1rem;
  font-size: 0.8rem;
  opacity: 0.9;
}
.fc-wallet-hero__meta strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.fc-expense-card {
  border-radius: 18px;
  border: 1px solid #e2e8f0;
  background: #fff;
  padding: 1.15rem 1.15rem 1.25rem;
}
html.dark .fc-expense-card {
  border-color: #1e293b;
  background: #0f172a;
}
.fc-amount-wrap {
  position: relative;
}
.fc-amount-wrap input {
  font-size: 1.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding-inline-end: 3.5rem;
  height: 3.25rem;
  min-height: 52px;
  border-radius: 14px;
}
.fc-amount-wrap .fc-currency-tag {
  position: absolute;
  inset-inline-end: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  font-weight: 700;
  color: #64748b;
  pointer-events: none;
}
.fc-dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 16px;
  background: #f8fafc;
  padding: 1.1rem;
  min-height: 140px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  outline: none;
}
html.dark .fc-dropzone {
  border-color: #334155;
  background: #020617;
}
.fc-dropzone:hover,
.fc-dropzone:focus-visible {
  border-color: #0062ff;
  box-shadow: 0 0 0 3px rgba(0, 98, 255, 0.12);
}
.fc-dropzone.is-dragover {
  border-color: #0062ff;
  background: rgba(0, 98, 255, 0.06);
  box-shadow: 0 0 0 3px rgba(0, 98, 255, 0.18);
}
.fc-dropzone.is-full {
  cursor: default;
}
.fc-dropzone__hint {
  text-align: center;
  padding: 0.75rem 0.5rem;
}
.fc-dropzone__hint i {
  font-size: 1.6rem;
  color: #0062ff;
  margin-bottom: 0.4rem;
}
.fc-pending-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
}
.fc-pending-add-tile {
  width: 96px;
  height: 96px;
  border-radius: 12px;
  border: 2px dashed #94a3b8;
  background: transparent;
  color: #0062ff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}
.fc-pending-add-tile i { font-size: 1.25rem; }
.fc-pending-add-tile:hover {
  border-color: #0062ff;
  background: rgba(0, 98, 255, 0.06);
}
html.dark .fc-pending-add-tile {
  border-color: #475569;
  color: #60a5fa;
}
.fc-add-more-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  margin-top: 0.75rem;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #0f172a;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}
.fc-add-more-btn:hover {
  border-color: #0062ff;
  color: #0062ff;
  background: rgba(0, 98, 255, 0.04);
}
html.dark .fc-add-more-btn {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}
.fc-add-more-btn.hidden { display: none !important; }
.fc-pending-thumb {
  position: relative;
  width: 96px;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  border: 1px solid #e2e8f0;
  cursor: pointer;
}
html.dark .fc-pending-thumb {
  background: #1e293b;
  border-color: #334155;
}
.fc-pending-thumb__img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  display: block;
}
.fc-pending-thumb__icon {
  width: 96px;
  height: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  color: #e11d48;
  font-size: 0.7rem;
  font-weight: 600;
}
.fc-pending-thumb__icon i { font-size: 1.5rem; }
.fc-pending-thumb__name {
  font-size: 0.65rem;
  padding: 0.25rem 0.35rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  color: #64748b;
}
.fc-pending-thumb__remove {
  position: absolute;
  top: 4px;
  inset-inline-end: 4px;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 0;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 2;
}
.fc-pending-thumb__remove:hover { background: #dc2626; }
.fc-thumb-btn {
  display: block;
  width: 64px;
  height: 64px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  background: #f1f5f9;
  padding: 0;
  cursor: pointer;
  position: relative;
}
html.dark .fc-thumb-btn {
  border-color: #334155;
  background: #1e293b;
}
.fc-thumb-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.fc-thumb-btn__icon {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: #64748b;
  font-size: 1.15rem;
}
.fc-edit-thumb {
  position: relative;
  display: inline-block;
}
.fc-edit-thumb__remove {
  position: absolute;
  top: -6px;
  inset-inline-end: -6px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  font-size: 0.75rem;
}
.fc-edit-thumb__remove:hover { background: #b91c1c; }
.fc-dropzone--compact {
  min-height: 0;
  padding: 0.35rem 0.5rem;
}
.fc-line-card {
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  background: #fff;
  padding: 0.9rem 1rem;
}
html.dark .fc-line-card {
  border-color: #1e293b;
  background: #0f172a;
}
.fc-lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.fc-lightbox.hidden { display: none !important; }
.fc-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.78);
}
.fc-lightbox__dialog {
  position: relative;
  width: min(96vw, 920px);
  max-height: 92vh;
  background: #0b1220;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
}
.fc-lightbox__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #111827;
  color: #f8fafc;
}
.fc-lightbox__title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 55vw;
}
.fc-lightbox__actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}
.fc-lightbox__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 38px;
  padding: 0 0.85rem;
  border-radius: 9px;
  background: #0062ff;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  border: 0;
  cursor: pointer;
}
.fc-lightbox__btn--ghost {
  background: transparent;
  color: #e2e8f0;
  min-width: 38px;
  justify-content: center;
  padding: 0;
}
.fc-lightbox__btn--ghost:hover { background: rgba(255,255,255,0.08); }
.fc-lightbox__body {
  flex: 1;
  min-height: 240px;
  max-height: calc(92vh - 56px);
  display: grid;
  place-items: center;
  background: #020617;
  padding: 0.75rem;
}
.fc-lightbox__img {
  max-width: 100%;
  max-height: calc(92vh - 80px);
  object-fit: contain;
  border-radius: 8px;
}
.fc-lightbox__frame {
  width: 100%;
  height: calc(92vh - 80px);
  border: 0;
  background: #fff;
}
.fc-lightbox__file {
  text-align: center;
  color: #e2e8f0;
  padding: 2rem;
}

/* ---- Financial custody receipt scanner ---- */
.fc-scanner {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background: #020617;
}
.fc-scanner.hidden { display: none !important; }
.fc-scanner__panel {
  width: min(100vw, 560px);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #0b1220;
  color: #f8fafc;
}
.fc-scanner__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: #111827;
}
.fc-scanner__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}
.fc-scanner__icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #e2e8f0;
  cursor: pointer;
}
.fc-scanner__icon-btn:hover { background: rgba(255,255,255,0.08); }
.fc-scanner__stage {
  position: relative;
  flex: 1;
  min-height: 240px;
  background: #000;
  overflow: hidden;
}
.fc-scanner__video,
.fc-scanner__preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.fc-scanner__preview--contain,
.fc-scanner__preview.fc-scanner__preview--contain {
  object-fit: contain;
  background: #000;
}
.fc-scanner__guide {
  position: absolute;
  inset: 12% 10%;
  border: 2px dashed rgba(255,255,255,0.75);
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(2, 6, 23, 0.35);
  pointer-events: none;
}
.fc-scanner__crop {
  position: absolute;
  z-index: 2;
  border: 2px solid #f59e0b;
  box-shadow: 0 0 0 9999px rgba(2, 6, 23, 0.5);
  touch-action: none;
  cursor: move;
  box-sizing: border-box;
}
.fc-scanner__crop.hidden { display: none !important; }
.fc-scanner__handle {
  position: absolute;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 4px;
  background: #f59e0b;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  touch-action: none;
  z-index: 3;
}
.fc-scanner__handle::after {
  content: '';
  position: absolute;
  inset: -14px;
}
.fc-scanner__handle[data-handle="nw"] { left: 0; top: 0; cursor: nwse-resize; }
.fc-scanner__handle[data-handle="n"]  { left: 50%; top: 0; cursor: ns-resize; }
.fc-scanner__handle[data-handle="ne"] { left: 100%; top: 0; cursor: nesw-resize; }
.fc-scanner__handle[data-handle="e"]  { left: 100%; top: 50%; cursor: ew-resize; }
.fc-scanner__handle[data-handle="se"] { left: 100%; top: 100%; cursor: nwse-resize; }
.fc-scanner__handle[data-handle="s"]  { left: 50%; top: 100%; cursor: ns-resize; }
.fc-scanner__handle[data-handle="sw"] { left: 0; top: 100%; cursor: nesw-resize; }
.fc-scanner__handle[data-handle="w"]  { left: 0; top: 50%; cursor: ew-resize; }
.fc-scanner__busy {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: rgba(2, 6, 23, 0.65);
  z-index: 4;
  text-align: center;
  padding: 1rem;
  font-size: 0.9rem;
  font-weight: 600;
}
.fc-scanner__busy.hidden,
.fc-scanner__video.hidden,
.fc-scanner__preview.hidden,
.fc-scanner__guide.hidden,
.fc-scanner__actions.hidden {
  display: none !important;
}
.fc-scanner__actions .fc-scanner__btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 0 0.5rem;
  font-size: 0.85rem;
}
.fc-scanner__spinner {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 3px solid rgba(255,255,255,0.25);
  border-top-color: #0062ff;
  animation: fc-spin 0.8s linear infinite;
}
@keyframes fc-spin { to { transform: rotate(360deg); } }
.fc-scanner__status {
  margin: 0;
  padding: 0.65rem 1rem 0.25rem;
  font-size: 0.8rem;
  color: #94a3b8;
  min-height: 1.5rem;
}
.fc-scanner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  padding: 0.75rem 1rem calc(0.9rem + env(safe-area-inset-bottom, 0px));
}
.fc-scanner__fallback {
  padding: 0.5rem 1rem 0;
}
.fc-scanner__fallback.hidden { display: none !important; }
.fc-scanner__fallback .fc-scanner__btn { width: 100%; }
.fc-scanner__btn {
  flex: 1;
  min-height: 48px;
  border-radius: 14px;
  border: 0;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}
.fc-scanner__btn--primary {
  background: #0062ff;
  color: #fff;
}
.fc-scanner__btn--primary:hover { background: #0052d6; }
.fc-scanner__btn--ghost {
  background: #1e293b;
  color: #e2e8f0;
}
.fc-scanner__btn--ghost:hover { background: #334155; }
.fc-ocr-badge:not(.hidden) {
  display: block;
}
