/*
 * Mavela Modern UI layer
 * Shared accessibility, responsiveness, navigation and presentation upgrades.
 */
:root {
  --mavela-radius-xs: 8px;
  --mavela-radius-sm: 12px;
  --mavela-radius-md: 18px;
  --mavela-focus: #2f80ed;
  --mavela-surface: rgba(255, 255, 255, 0.96);
  --mavela-border: rgba(23, 49, 34, 0.14);
  --mavela-elevation: 0 16px 42px rgba(10, 47, 30, 0.10);
  --mavela-elevation-hover: 0 20px 48px rgba(10, 47, 30, 0.14);
}

html {
  scroll-behavior: smooth;
  text-rendering: optimizeLegibility;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.mavela-large-type {
  font-size: 112.5%;
}

::selection {
  color: #fff;
  background: var(--brand-navy, var(--brand, #1d6a33));
}

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--mavela-focus) 72%, white);
  outline-offset: 3px;
}

:where(button, input, select, textarea) {
  font: inherit;
}

:where(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea) {
  min-height: 44px;
  border-radius: var(--mavela-radius-xs);
}

:where(button, .btn, [class*="button"], [class*="-btn"]) {
  min-height: 42px;
  touch-action: manipulation;
}

:where(button, .btn, [class*="-btn"]):not(:disabled) {
  transition: transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

:where(button, .btn, [class*="-btn"]):not(:disabled):active {
  transform: translateY(1px);
}

:where(button, input, select, textarea):disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.mavela-skip-link {
  position: fixed;
  z-index: 10000;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  color: #fff;
  background: #123b25;
  border-radius: 10px;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 140ms ease;
}

.mavela-skip-link:focus {
  transform: translateY(0);
}

.mavela-security-notice {
  position: sticky;
  z-index: 8200;
  top: 0;
  width: 100%;
  padding: 11px 18px;
  color: #5b3000;
  background: #fff4cf;
  border-bottom: 1px solid #efc55f;
  text-align: center;
  box-shadow: 0 8px 24px rgba(76, 43, 0, 0.12);
}

:where(.header, header.header) {
  border: 1px solid color-mix(in srgb, var(--mavela-border) 75%, transparent);
  box-shadow: var(--mavela-elevation);
}

:where(.card, .panel, .metric, .section-card, .content-card, .dashboard-card) {
  border-radius: var(--mavela-radius-md);
}

:where(.metric, .dashboard-card, .content-card) {
  transition: transform 160ms ease, box-shadow 160ms ease;
}

@media (hover: hover) {
  :where(.metric, .dashboard-card, .content-card):hover {
    transform: translateY(-2px);
    box-shadow: var(--mavela-elevation-hover);
  }
}

.mavela-table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  border-radius: var(--mavela-radius-sm);
  scrollbar-width: thin;
}

.mavela-table-scroll > table {
  width: 100%;
  margin: 0;
}

table {
  border-collapse: separate;
  border-spacing: 0;
}

table :where(th, td) {
  vertical-align: middle;
}

table thead th {
  position: sticky;
  z-index: 1;
  top: 0;
  backdrop-filter: blur(12px);
}

table tbody tr {
  transition: background-color 120ms ease;
}

table tbody tr:hover {
  background: color-mix(in srgb, var(--brand-ice, #eef7ef) 72%, transparent);
}

.mavela-menu-search-wrap {
  position: sticky;
  z-index: 3;
  top: 0;
  padding: 4px 0 10px;
  background: inherit;
}

.mavela-menu-search {
  width: 100%;
  min-height: 40px !important;
  padding: 8px 11px;
  color: inherit;
  background: color-mix(in srgb, var(--mavela-surface) 92%, transparent);
  border: 1px solid var(--mavela-border);
  border-radius: 10px;
}

.mavela-menu-empty {
  display: none;
  margin: 8px 4px;
  color: var(--muted, #52645a);
  font-size: 0.84rem;
}

.mavela-menu-empty.visible {
  display: block;
}

.mavela-utility-dock {
  position: fixed;
  z-index: 9000;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  padding: 7px;
  color: #fff;
  background: rgba(20, 46, 31, 0.91);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  box-shadow: 0 14px 36px rgba(5, 25, 14, 0.24);
  backdrop-filter: blur(14px);
}

.mavela-utility-btn {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  min-height: 42px;
  padding: 0 12px;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
}

.mavela-utility-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.mavela-mobile-nav {
  display: none;
}

.mavela-submit-busy {
  cursor: wait !important;
  opacity: 0.78;
}

.mavela-submit-busy::after {
  content: " …";
}

[data-mavela-theme="dark"] {
  color-scheme: dark;
  --mavela-surface: rgba(18, 29, 23, 0.97);
  --mavela-border: rgba(220, 240, 228, 0.18);
}

[data-mavela-theme="dark"] body {
  color: #e9f4ed;
  background: #101b14 !important;
}

[data-mavela-theme="dark"] :where(.shell, .card, .panel, .metric, .desk-sidebar, .sidebar, aside.nav, .desk-main section, .content, .auth-panel) {
  color: #e9f4ed;
  border-color: rgba(220, 240, 228, 0.15) !important;
}

[data-mavela-theme="dark"] :where(.card, .panel, .metric, .desk-sidebar, .sidebar, aside.nav, .desk-main section, .content, .auth-panel) {
  background-color: #18271e !important;
}

[data-mavela-theme="dark"] :where(input, select, textarea) {
  color: #eff8f2 !important;
  background: #102018 !important;
  border-color: rgba(220, 240, 228, 0.22) !important;
}

[data-mavela-theme="dark"] :where(table tbody tr:hover) {
  background: rgba(79, 166, 104, 0.13) !important;
}

@media (max-width: 900px) {
  .mavela-mobile-nav {
    display: inline-grid;
  }

  .mavela-enhanced-sidebar {
    position: fixed !important;
    z-index: 8500 !important;
    top: 12px !important;
    bottom: 12px !important;
    left: 12px !important;
    width: min(330px, calc(100vw - 44px)) !important;
    max-height: calc(100vh - 24px) !important;
    overflow-y: auto !important;
    padding: 14px !important;
    background: var(--mavela-surface) !important;
    border: 1px solid var(--mavela-border) !important;
    border-radius: 18px !important;
    box-shadow: 0 24px 70px rgba(4, 19, 10, 0.35) !important;
    transform: translateX(calc(-100% - 32px));
    transition: transform 190ms ease;
  }

  .mavela-nav-open .mavela-enhanced-sidebar {
    transform: translateX(0);
  }

  .mavela-nav-backdrop {
    position: fixed;
    z-index: 8400;
    inset: 0;
    display: none;
    background: rgba(4, 16, 9, 0.48);
    backdrop-filter: blur(3px);
  }

  .mavela-nav-open .mavela-nav-backdrop {
    display: block;
  }

  .desk-layout,
  .layout,
  .dashboard-layout {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  :where(.shell, main, .page-shell) {
    max-width: 100%;
  }

  :where(.header, header.header) {
    position: static !important;
  }
}

@media (max-width: 620px) {
  body {
    padding-bottom: 76px !important;
  }

  .mavela-utility-dock {
    right: 10px;
    bottom: 10px;
  }

  :where(.brand-row, .header-row, .topbar, .actions, .button-row) {
    gap: 8px !important;
  }

  :where(.cards, .metrics, .stats-grid, .form-grid) {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  :where(button, .btn, [class*="-btn"]) {
    min-height: 44px;
  }
}

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

@media print {
  .mavela-utility-dock,
  .mavela-menu-search-wrap,
  .mavela-nav-backdrop,
  .mavela-skip-link {
    display: none !important;
  }

  .mavela-table-scroll {
    overflow: visible;
  }
}
