.app-desktop-shell {
  width: 100vw;
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

.app-desktop-stage {
  position: relative;
  width: var(--desktop-stage-width, 100vw);
  min-height: var(--desktop-stage-height, 100dvh);
  transform: scale(var(--desktop-ui-scale, 1));
  transform-origin: top left;
}

.app {
  --sidebar-expanded-width: 304px;
  --sidebar-collapsed-width: 64px;
  --sidebar-motion: 220ms cubic-bezier(0.4, 0, 0.2, 1);

  height: var(--desktop-stage-height, 100dvh);
  min-height: var(--desktop-stage-height, 100dvh);
  display: flex;
  align-items: stretch;
  background: var(--bg);
  position: relative;
}

.app-sidebar {
  flex: 0 0 var(--sidebar-expanded-width);
  width: var(--sidebar-expanded-width);
  min-width: 0;
  position: relative;
  overflow: visible;
  z-index: 200;
  will-change: width, flex-basis;
  transition:
    width var(--sidebar-motion),
    flex-basis var(--sidebar-motion),
    box-shadow 160ms var(--ease);
  animation: loginEntrySidebarIn 520ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.app.sidebar-collapsed .app-sidebar {
  width: var(--sidebar-collapsed-width);
  flex-basis: var(--sidebar-collapsed-width);
  overflow: visible;
  z-index: 200;
}

.app.sidebar-collapsed > .main {
  position: relative;
  z-index: 1;
}

.sidebar-mode-fade-enter-active,
.sidebar-mode-fade-leave-active {
  transition:
    opacity 180ms var(--ease),
    transform 180ms var(--ease);
}

.sidebar-mode-fade-enter-from,
.sidebar-mode-fade-leave-to {
  opacity: 0;
  transform: translateX(-8px);
}

.app > .main {
  flex: 1 1 auto;
  min-width: 0;
}

.boot-state {
  min-height: var(--desktop-stage-height, 100dvh);
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(var(--theme-primary-rgb, 58, 124, 165), 0.14), transparent 24rem),
    radial-gradient(circle at bottom right, rgba(59, 130, 246, 0.14), transparent 28rem),
    #f8fafc;
}

.boot-card {
  width: min(560px, 100%);
  padding: 36px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
  display: grid;
  gap: 14px;
}

.boot-card h1 {
  font-size: 28px;
}

.boot-card p {
  color: var(--muted);
  line-height: 1.7;
}

.boot-badge {
  display: inline-flex;
  width: fit-content;
  min-height: 28px;
  align-items: center;
  padding: 0 10px;
  border-radius: 4px;
  background: var(--theme-primary-soft);
  color: var(--theme-primary-active);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.boot-badge-error {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

.boot-action {
  width: fit-content;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #0f172a;
  color: #fff;
  font-weight: 700;
}

.main {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  animation: loginEntryMainIn 620ms 90ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
.main.overview-main {
  height: var(--desktop-stage-height, 100dvh);
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}
.main.workbench-main {
  height: var(--desktop-stage-height, 100dvh);
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}
.main.documents-main,
.main.receipt-folder-main,
.main.budget-main,
.main.requests-main,
.main.approval-main,
.main.archive-main,
.main.policies-main,
.main.audit-main,
.main.digital-employees-main,
.main.employees-main,
.main.settings-main {
  height: var(--desktop-stage-height, 100dvh);
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}
.main.settings-main {
  grid-template-rows: minmax(0, 1fr);
}
.workarea { min-height: 0; overflow: auto; padding: 24px; }
.workarea.requests-workarea,
.workarea.documents-workarea,
.workarea.receipt-folder-workarea,
.workarea.budget-workarea,
.workarea.workbench-workarea,
.workarea.approval-workarea,
.workarea.archive-workarea,
.workarea.policies-workarea,
.workarea.audit-workarea,
.workarea.digital-employees-workarea,
.workarea.employees-workarea,
.workarea.settings-workarea {
  min-height: 0;
  overflow: hidden;
  padding: 20px 24px;
}
.workarea.workbench-workarea {
  overflow-x: hidden;
  overflow-y: auto;
  padding: 20px 24px;
  background-color: var(--workbench-surface-soft, #f9fbff);
  background-image:
    radial-gradient(ellipse at 0% 0%, rgba(58, 124, 165, 0.05) 0%, transparent 40%),
    radial-gradient(ellipse at 100% 0%, rgba(110, 127, 166, 0.05) 0%, transparent 40%),
    linear-gradient(rgba(58, 124, 165, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(58, 124, 165, 0.03) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 32px 32px, 32px 32px;
  background-attachment: local;
}
.workarea.workbench-workarea.workbench-workarea-ai-mode {
  padding: 0;
  background: transparent;
}
.document-detail-loading {
  min-height: 280px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  text-align: center;
  color: #475569;
}
.document-detail-loading i {
  font-size: 30px;
  color: var(--theme-primary-active);
}
.document-detail-loading strong {
  color: #0f172a;
  font-size: 16px;
}
.document-detail-loading p {
  margin: 6px 0 0;
  color: #64748b;
  font-size: 13px;
}
.workarea.settings-workarea {
  padding: 0;
  background: #fff;
}

.mobile-hamburger-btn {
  display: none;
}

@keyframes loginEntrySidebarIn {
  from {
    opacity: 0;
    transform: translateX(-18px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes loginEntryMainIn {
  from {
    opacity: 0;
    transform: scale3d(0.985, 0.985, 1) translateY(10px);
  }

  to {
    opacity: 1;
    transform: scale3d(1, 1, 1) translateY(0);
  }
}

@media (max-width: 1180px) {
  .app-sidebar {
    width: var(--sidebar-expanded-width);
  }

  .app.sidebar-collapsed .app-sidebar {
    width: var(--sidebar-collapsed-width);
  }
}
@media (max-width: 760px) {
  .app {
    display: flex;
    width: 100vw;
    overflow: hidden;
  }

  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    width: min(320px, 80vw);
    max-width: none;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .app.mobile-sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  .app > .main {
    flex: 1 1 100%;
    width: 100vw;
    max-width: 100vw;
    min-width: 0;
    overflow: hidden;
  }

  .workarea {
    min-width: 0;
    max-width: 100%;
    padding: 16px;
  }

  .workarea.documents-workarea,
  .workarea.receipt-folder-workarea,
  .workarea.budget-workarea,
  .workarea.policies-workarea,
  .workarea.audit-workarea,
  .workarea.employees-workarea {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .workarea.workbench-workarea { overflow: auto; padding: 16px; }
  .workarea.workbench-workarea.workbench-workarea-ai-mode { padding: 0; }

  .mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    backdrop-filter: blur(2px);
  }

  .app.mobile-sidebar-open .mobile-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-hamburger-btn {
    position: fixed;
    top: 14px;
    right: 16px;
    z-index: 90;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-sidebar {
    transition:
      width 120ms ease-out !important,
      flex-basis 120ms ease-out !important;
    transition-duration: 120ms, 120ms !important;
  }
}
