/* ==========================================================================
   MaxFuzion Design System v2.0 — Core Brand Tokens & Compact Ergonomics
   Preserves official MaxFuzion Palette & Logo with Unified Compact Density
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Manrope:wght@600;700;800&family=Montserrat:wght@700;800;900&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  /* Official MaxFuzion Brand Palette (Preserved) */
  --mf-navy: #1E3A5F;
  --mf-navy-deep: #0F2138;
  --mf-ink: #0A1628;
  --mf-cyan: #00B4D8;
  --mf-cyan-dark: #0089A6;
  --mf-cyan-tint: rgba(0, 180, 216, 0.11);
  --mf-orange: #FF8C42;
  --mf-orange-hover: #F57B2C;
  --mf-orange-brand: #FF6B1A;
  --mf-orange-brand-light: #E05A0B;
  --mf-orange-tint: rgba(255, 140, 66, 0.12);

  /* Surfaces & Canvas (60-30-10 Discipline) */
  --mf-bg: #FFFFFF;
  --mf-bg-alt: #F5F7FA;
  --mf-bg-portal: #EFF3F8;
  --mf-bg-subtle: #E8EEF5;
  --mf-bg-hover: #F1F5F9;

  /* Text Hierarchy (WCAG AA Verified) */
  --mf-text: #1E293B;
  --mf-text-sec: #475569;
  --mf-text-muted: #64748B;
  --mf-text-on-dark: #CBD5E1;
  --mf-text-on-dark-muted: #94A3B8;

  /* Borders & Hairlines */
  --mf-border: #E2E8F0;
  --mf-border-portal: #DFE7F0;
  --mf-border-strong: #CBD5E1;
  --mf-border-dark: rgba(255, 255, 255, 0.12);

  /* Semantic Status (Always paired with explicit text labels) */
  --mf-ok: #059669;
  --mf-ok-bg: #ECFDF5;
  --mf-ok-border: #A7F3D0;
  --mf-warn: #B45309;
  --mf-warn-bg: #FFFBEB;
  --mf-warn-border: #FDE68A;
  --mf-err: #DC2626;
  --mf-err-bg: #FEF2F2;
  --mf-err-border: #FECACA;
  --mf-info: #0369A1;
  --mf-info-bg: #F0F9FF;
  --mf-info-border: #BAE6FD;

  /* Typography (Strict 2+1 Rule) */
  --font-display: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  /* Compact Geometry & Elevation (Single-Level Depth) */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 10px;
  --sh-card: 0 1px 2px rgba(10, 22, 40, 0.05);
  --sh-lift: 0 8px 22px rgba(10, 22, 40, 0.09);
  --sh-modal: 0 20px 44px -10px rgba(10, 22, 40, 0.28);

  /* Compact Layout Constants */
  --hdr-h: 56px;
  --hdr-h-scrolled: 52px;
  --wrap-max: 1220px;
  --ease-snappy: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--hdr-h) + 12px);
}

body {
  font-family: var(--font-sans);
  color: var(--mf-text);
  background: var(--mf-bg);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--mf-navy);
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

a {
  color: inherit;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--mf-cyan);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

.tabular {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: var(--font-mono);
}

/* Clean Unboxed Metadata Line (Zero-Pill Discipline) */
.mf-meta-line {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--mf-text-muted);
}

.mf-meta-line .sep {
  color: var(--mf-border-strong);
  user-select: none;
}

/* Unified MaxFuzion Brand Lockup (MF Mark + Geometric Typography) */
.mf-brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
}

.mf-brand-mark {
  width: 34px;
  height: 34px;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(10, 22, 40, 0.22));
  transition: width 160ms var(--ease-snappy), height 160ms var(--ease-snappy);
}

.mf-brand-word {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  line-height: 1;
}

.mf-brand-name {
  font-family: 'Montserrat', var(--font-display);
  font-weight: 900;
  font-size: 18.5px;
  line-height: 0.96;
  letter-spacing: 0.2em;
  margin-right: -0.2em;
  color: #FFFFFF;
  text-transform: uppercase;
  transition: color 160ms ease;
}

.mf-brand-tagline {
  font-family: 'Montserrat', var(--font-display);
  font-weight: 700;
  font-size: 6.95px;
  line-height: 1.1;
  letter-spacing: 0.08em;
  margin-right: -0.08em;
  color: var(--mf-orange-brand);
  text-transform: uppercase;
  margin-top: 3px;
  transition: color 160ms ease;
}

/* Compact Variant (46px Portal Topbar & Quiet Footer) */
.mf-brand-lockup--compact {
  gap: 8px;
}

.mf-brand-lockup--compact .mf-brand-mark {
  width: 28px;
  height: 28px;
}

.mf-brand-lockup--compact .mf-brand-name {
  font-size: 15.5px;
  letter-spacing: 0.2em;
  margin-right: -0.2em;
}

.mf-brand-lockup--compact .mf-brand-tagline {
  font-size: 5.82px;
  letter-spacing: 0.08em;
  margin-right: -0.08em;
  margin-top: 2.5px;
}

/* Large Variant (Portal Login Brand Panel) */
.mf-brand-lockup--lg {
  gap: 11px;
}

.mf-brand-lockup--lg .mf-brand-mark {
  width: 42px;
  height: 42px;
}

.mf-brand-lockup--lg .mf-brand-name {
  font-size: 22.5px;
  letter-spacing: 0.2em;
  margin-right: -0.2em;
}

.mf-brand-lockup--lg .mf-brand-tagline {
  font-size: 8.45px;
  letter-spacing: 0.08em;
  margin-right: -0.08em;
  margin-top: 3.5px;
}

/* Light Surface Variant (Scrolled Header / Mobile Login) */
.mf-brand-lockup--light .mf-brand-name {
  color: var(--mf-navy-deep);
}

.mf-brand-lockup--light .mf-brand-tagline {
  color: var(--mf-orange-brand-light);
}

/* Compact Shared Buttons */
.mf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 15px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: transform 150ms var(--ease-snappy), background-color 150ms var(--ease-snappy), border-color 150ms var(--ease-snappy), color 150ms var(--ease-snappy), opacity 150ms ease;
}

.mf-btn:hover {
  transform: translateY(-1px);
}

.mf-btn:active {
  transform: translateY(0);
}

.mf-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.mf-btn-primary {
  background: var(--mf-orange);
  color: #FFFFFF;
  border-color: var(--mf-orange);
}

.mf-btn-primary:hover {
  background: var(--mf-orange-hover);
  border-color: var(--mf-orange-hover);
}

.mf-btn-navy {
  background: var(--mf-navy);
  color: #FFFFFF;
  border-color: var(--mf-navy);
}

.mf-btn-navy:hover {
  background: var(--mf-navy-deep);
  border-color: var(--mf-navy-deep);
}

.mf-btn-cyan {
  background: var(--mf-cyan);
  color: #FFFFFF;
  border-color: var(--mf-cyan);
}

.mf-btn-cyan:hover {
  background: var(--mf-cyan-dark);
  border-color: var(--mf-cyan-dark);
}

.mf-btn-outline {
  background: #FFFFFF;
  color: var(--mf-navy);
  border-color: var(--mf-border-strong);
}

.mf-btn-outline:hover {
  background: var(--mf-bg-alt);
  border-color: var(--mf-navy);
}

.mf-btn-ghost-dark {
  background: rgba(255, 255, 255, 0.06);
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, 0.24);
}

.mf-btn-ghost-dark:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.55);
}

.mf-btn-sm {
  height: 30px;
  padding: 0 11px;
  font-size: 12px;
}

.mf-btn-xs {
  height: 26px;
  padding: 0 9px;
  font-size: 11.5px;
  border-radius: var(--r-xs);
}

/* Compact Toast Notification */
.mf-toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.mf-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  max-width: 380px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--mf-ink);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: var(--sh-modal);
  font-size: 12.5px;
  font-weight: 500;
  animation: mfToastIn 180ms var(--ease-snappy);
}

.mf-toast.ok {
  border-color: rgba(16, 185, 129, 0.55);
}

.mf-toast.err {
  border-color: rgba(239, 68, 68, 0.65);
}

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

/* Compact maxfuzion_desk Modal System (Shared by Website & Portal) */
.mf-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: rgba(10, 22, 40, 0.58);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.mf-modal-backdrop.open {
  display: flex;
}

.mf-modal {
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: #FFFFFF;
  border-radius: var(--r-md);
  border: 1px solid var(--mf-border-strong);
  box-shadow: var(--sh-modal);
  overflow: hidden;
  animation: mfModalPop 160ms var(--ease-snappy);
}

.mf-modal.mf-modal-sm {
  max-width: 480px;
}

@keyframes mfModalPop {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.mf-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 10px 16px;
  background: var(--mf-bg-alt);
  border-bottom: 1px solid var(--mf-border);
}

.mf-modal-title {
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 700;
  color: var(--mf-navy);
}

.mf-modal-close {
  width: 26px;
  height: 26px;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--mf-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

.mf-modal-close:hover {
  background: #FFFFFF;
  border-color: var(--mf-border);
  color: var(--mf-text);
}

.mf-modal-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 16px;
  background: #FFFFFF;
  border-bottom: 1px solid var(--mf-border);
}

.mf-modal-tab {
  position: relative;
  height: 34px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--mf-text-muted);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.mf-modal-tab:hover {
  color: var(--mf-navy);
}

.mf-modal-tab.active {
  color: var(--mf-navy);
}

.mf-modal-tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--mf-cyan);
}

.mf-modal-body {
  padding: 14px 16px;
  overflow-y: auto;
}

.mf-modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  background: var(--mf-bg-alt);
  border-top: 1px solid var(--mf-border);
}

/* Compact 2-Column Desk Form Grid */
.mf-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

.mf-form-grid .span-2 {
  grid-column: 1 / -1;
}

.mf-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mf-field label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--mf-text-sec);
}

.mf-field label .req {
  color: var(--mf-err);
  margin-left: 2px;
}

.mf-input,
.mf-select,
.mf-textarea {
  width: 100%;
  border: 1px solid var(--mf-border-strong);
  border-radius: var(--r-xs);
  background: #FFFFFF;
  color: var(--mf-text);
  font-size: 13px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.mf-input,
.mf-select {
  height: 32px;
  padding: 0 9px;
}

.mf-textarea {
  padding: 7px 9px;
  min-height: 76px;
  resize: vertical;
  line-height: 1.45;
}

.mf-input:focus,
.mf-select:focus,
.mf-textarea:focus {
  outline: none;
  border-color: var(--mf-cyan);
  box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.14);
}

.mf-field-err {
  font-size: 11px;
  color: var(--mf-err);
  min-height: 14px;
}

@media (max-width: 640px) {
  .mf-form-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
