/* Enterprise UI quality layer: typography, alignment and interaction consistency. */

:where(button, a[href], input, select, textarea, [role="button"]):focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

:where(button, a[href], [role="button"]) {
  transition: color var(--motion-fast) ease, background-color var(--motion-fast) ease,
    border-color var(--motion-fast) ease, box-shadow var(--motion-fast) ease,
    transform var(--motion-fast) ease;
}

:where(button, a[href], [role="button"]):active {
  transform: translateY(1px);
}

:where(button, input, select, textarea):disabled,
:where([role="button"])[aria-disabled="true"] {
  opacity: .46;
  pointer-events: none;
}

/* Web management baseline: dense, scan-friendly and consistent across domains. */
body[data-app-surface="web"] .web-content {
  color: var(--el-text-color-regular);
  font-size: var(--type-web-body);
  line-height: var(--line-body);
}

.page-header h1,
.page-header h2,
.mobile-content h1,
.mobile-content h2,
.mobile-content h3 {
  color: var(--el-text-color-primary);
  letter-spacing: -.015em;
}

.page-header__title {
  font-size: var(--type-web-page-title);
  font-weight: 650;
  line-height: 30px;
}

.page-header__description {
  max-width: 72ch;
  color: var(--el-text-color-secondary);
  font-size: var(--type-web-label);
  line-height: 20px;
}

.web-content .el-form-item__label,
.web-content label > span:first-child {
  color: var(--el-text-color-regular);
  font-size: var(--type-web-label);
  font-weight: 500;
}

.web-content :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  min-height: var(--control-height);
  border-color: var(--el-border-color);
  border-radius: var(--radius-compact);
  color: var(--el-text-color-primary);
  background: var(--el-bg-color);
}

.web-content :where(input, select, textarea):focus {
  border-color: var(--el-color-primary);
  box-shadow: var(--focus-ring);
  outline: 0;
}

.web-content :where(button, .el-button, [role="button"]) {
  min-height: var(--web-target-min);
  border-radius: var(--radius-compact);
}

.web-content :where(.el-card, .business-list-card, .contract-list-card, .mobile-card) {
  border-color: var(--el-border-color-light);
  box-shadow: var(--shadow-card);
}

.web-content :where(h2, h3) {
  text-wrap: balance;
}

.web-content :where(.el-card__header, section > header) h2,
.web-content :where(.el-card__header, section > header) h3 {
  font-size: var(--type-web-section-title);
  line-height: 24px;
}

.web-content .el-table th {
  height: 40px;
  color: var(--el-text-color-regular);
  font-size: var(--type-web-meta);
  letter-spacing: .01em;
  background: #f3f6f9;
}

.web-content .el-table td {
  height: 44px;
  color: var(--el-text-color-regular);
  font-size: var(--type-web-label);
}

.web-content table :where(td, th).is-number,
.web-content table :where(td, th)[data-numeric] {
  font-variant-numeric: tabular-nums lining-nums;
  text-align: right;
}

.web-content :where(.el-tag, .business-state, [data-status]) {
  min-height: 24px;
  line-height: 24px;
}

/* Mobile hierarchy */
.mobile-app {
  color: #26364a;
  font-size: var(--type-mobile-body);
  line-height: var(--line-body);
}

.mobile-header {
  min-height: 58px;
  padding-inline: 7px;
  border-bottom-color: #dfe6ee;
  background: rgb(255 255 255 / 98%);
}

.mobile-header > div {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.mobile-header strong {
  color: #172033;
  font-size: 17px;
  font-weight: 650;
  line-height: 22px;
}

.mobile-header small {
  color: #748195;
  font-size: var(--type-mobile-meta);
  line-height: 18px;
}

.mobile-content {
  padding-top: 12px;
  background: #f3f6fa;
}

.mobile-section > header h3,
.mobile-section__title {
  margin: 0;
  font-size: var(--type-mobile-section-title);
  font-weight: 650;
  line-height: 22px;
}

.mobile-section > header p {
  margin: 2px 0 0;
  color: #748195;
  font-size: var(--type-mobile-meta);
  line-height: 18px;
}

.mobile-content :where(h1, h2) {
  font-size: var(--type-mobile-page-title);
  font-weight: 650;
  line-height: 28px;
  text-wrap: balance;
}

.mobile-content :where(h3) {
  font-size: var(--type-mobile-section-title);
  line-height: 24px;
}

.mobile-content :where(p, li, dd) {
  overflow-wrap: anywhere;
}

.mobile-card,
.mobile-list,
.mobile-kpi {
  border-color: #dfe6ee;
  border-radius: 9px;
  box-shadow: 0 1px 2px rgb(16 38 62 / 4%);
}

.mobile-content :where(input, select, textarea) {
  min-height: var(--touch-target);
  border-color: #cfd8e3;
  color: #26364a;
  background-color: #fff;
}

.mobile-app .mobile-content :where(button, .el-button, [role="button"]),
.mobile-bottom-nav > a {
  min-height: var(--touch-target);
}

.mobile-app .mobile-content :where(button, .el-button, [role="button"]) {
  min-width: var(--touch-target);
}

.mobile-content :where(button, .el-button, [role="button"]):active,
.mobile-bottom-nav > a:active {
  transform: none;
  filter: brightness(.96);
}

.mobile-content :where(label > span:first-child, dt) {
  font-size: var(--type-mobile-label);
  font-weight: 500;
}

.mobile-content :where(small, .mobile-kpi__meta, .mobile-nav-item__badge) {
  font-size: var(--type-mobile-meta);
  line-height: 18px;
}

.mobile-content :where(input[readonly], textarea[readonly]) {
  color: var(--el-text-color-regular);
  background: var(--el-fill-color-light);
}

.mobile-content :where(input, select, textarea):focus {
  border-color: var(--el-color-primary);
  box-shadow: var(--focus-ring);
  outline: 0;
}

/* Stable five-item B2B navigation with a branded AI destination. */
.mobile-bottom-nav {
  min-height: calc(62px + var(--safe-bottom));
  padding: 3px 6px var(--safe-bottom);
  border-top-color: #dfe6ee;
  background: rgb(255 255 255 / 98%);
  box-shadow: 0 -3px 12px rgb(16 38 62 / 7%);
}

.mobile-bottom-nav > a {
  min-height: 56px;
  gap: 3px;
  border-radius: 6px;
  color: #66768b;
}

.mobile-bottom-nav > a .ui-icon {
  width: 20px;
  height: 20px;
}

.mobile-bottom-nav > a span {
  font-size: 11px;
  line-height: 16px;
}

.mobile-bottom-nav > a > em {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.mobile-bottom-nav > a.is-active {
  color: #12558f;
  background: #edf4f9;
}

.mobile-bottom-nav > a.is-active::after {
  top: 0;
  width: 24px;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: #1769aa;
}

.mobile-bottom-nav > a:nth-child(3) {
  transform: none;
}

.mobile-bottom-nav > a:nth-child(3) > .ui-icon {
  box-sizing: border-box;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: currentColor;
  background: transparent;
  box-shadow: none;
}

.mobile-bottom-nav > a:nth-child(3) > span {
  margin-top: 0;
}

.mobile-bottom-nav > a .mobile-nav-ai-avatar {
  box-sizing: border-box;
  display: grid;
  width: 30px;
  height: 30px;
  margin: 0;
  place-items: center;
  overflow: hidden;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #edf4ff;
  box-shadow: 0 3px 8px rgb(23 105 170 / 18%);
}

.mobile-bottom-nav > a .mobile-nav-ai-avatar img {
  display: block;
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.mobile-bottom-nav > a.is-active .mobile-nav-ai-avatar {
  border-color: #d9eaff;
  background: #fff;
}

.mobile-ai-floating-entry {
  position: absolute;
  right: 12px;
  bottom: 74px;
  z-index: 18;
  display: grid;
  width: 58px;
  min-height: 66px;
  justify-items: center;
  align-content: end;
  padding: 0 5px 6px;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 88%);
  border-radius: 29px 29px 16px 16px;
  color: #fff;
  background: linear-gradient(180deg,#f8fbff 0 68%,#1769aa 68% 100%);
  box-shadow: 0 8px 22px rgb(28 72 116 / 24%);
}

.mobile-ai-floating-entry img {
  position: absolute;
  top: -1px;
  width: 48px;
  height: 51px;
  object-fit: contain;
}

.mobile-ai-floating-entry span {
  position: relative;
  z-index: 1;
  font-size: 10px;
  font-weight: 650;
  line-height: 14px;
}

.mobile-ai-floating-entry:active {
  transform: scale(.96);
}

@media (max-width: 430px) {
  .mobile-content :where(input, select, textarea) {
    font-size: 16px;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .mobile-stage {
    min-height: 100dvh;
    padding: 0;
  }

  .mobile-stage-tools {
    display: none;
  }

  .phone-frame {
    width: 100%;
    max-width: none;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .phone-frame .mobile-app {
    height: calc(100% - 24px);
  }

  .mobile-header {
    min-height: 50px;
  }

  .mobile-content {
    padding-top: 8px;
  }

  .mobile-bottom-nav {
    top: 0;
    bottom: 0;
    height: auto;
    min-height: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* Mobile P0 interaction contract: the phone body is the only native scroller.
   Keeping the outer document fixed preserves visual and hit-test coordinates. */
body[data-app-surface="mobile"] {
  width: 100%;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

body[data-app-surface="mobile"] #app {
  width: 100%;
  min-height: 100dvh;
  overflow: visible;
}

body[data-app-surface="mobile"] .mobile-stage {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  min-height: 946px;
  overflow: visible;
}

body[data-app-surface="mobile"] .phone-frame {
  position: relative;
  width: min(100%, 393px);
  height: 852px;
  pointer-events: none;
}

body[data-app-surface="mobile"] .phone-frame .mobile-app {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 0;
  height: calc(100% - 28px);
  max-height: none;
  overflow: hidden;
  isolation: isolate;
  pointer-events: auto;
}

body[data-app-surface="mobile"] .phone-frame::before,
body[data-app-surface="mobile"] .phone-status,
body[data-app-surface="mobile"] .mobile-header-spacer {
  pointer-events: none;
}

body[data-app-surface="mobile"] .mobile-header {
  flex: 0 0 auto;
}

body[data-app-surface="mobile"] .mobile-content {
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  width: 100%;
  height: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  pointer-events: auto;
}

body[data-app-surface="mobile"] .mobile-content::-webkit-scrollbar {
  width: 6px;
}

body[data-app-surface="mobile"] .mobile-content::-webkit-scrollbar-thumb {
  border-radius: 6px;
  background: #91a3b8;
}

body[data-app-surface="mobile"] .mobile-content::-webkit-scrollbar-track {
  background: transparent;
}

body[data-app-surface="mobile"] .mobile-content :where(a, button, input, select, textarea, label, [role="button"]),
body[data-app-surface="mobile"] .mobile-bottom-nav {
  pointer-events: auto;
  touch-action: manipulation;
}

body[data-app-surface="mobile"] .mobile-bottom-nav > a {
  position: relative;
  z-index: 1;
}

body[data-app-surface="mobile"] .mobile-content :where(a, button, input, select, textarea, label, [role="button"])::before,
body[data-app-surface="mobile"] .mobile-content :where(a, button, [role="button"])::after,
body[data-app-surface="mobile"] .mobile-bottom-nav > a::before,
body[data-app-surface="mobile"] .mobile-bottom-nav > a::after {
  pointer-events: none;
}

body[data-app-surface="mobile"] .mobile-bottom-nav {
  z-index: 20;
}

/* The desktop preview keeps a wide browser viewport around a narrow phone.
   Form layout must follow the phone frame width, not the outer viewport. */
body[data-app-surface="mobile"] .phone-frame :is(.m-prg-form .m-prg-grid, .m-saf-form .m-saf-grid, .m-mat-form .m-mat-form-grid, .mobile-form-card form .mobile-form-grid) {
  grid-template-columns: minmax(0, 1fr);
}

@media (max-width: 430px) {
  body[data-app-surface="mobile"] .mobile-stage,
  body[data-app-surface="mobile"] .phone-frame {
    width: 100%;
    height: 100dvh;
  }

  body[data-app-surface="mobile"] .phone-frame .mobile-app {
    height: calc(100% - 24px);
  }
}

/* RuoYi-style three-level Web navigation hierarchy. Loaded last to prevent
   business-module styles from leaking into the global sidebar. */
.web-nav-scroll {
  padding: 10px 8px 18px;
}

.nav-group + .nav-group {
  margin-top: 3px;
}

.nav-group-title {
  grid-template-columns: 18px minmax(0, 1fr) 14px;
  min-height: 42px;
  padding: 0 11px;
  gap: 9px;
  border-radius: 6px;
  color: #c8d5e4;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
}

.nav-group-title > .ui-icon {
  width: 16px;
  height: 16px;
}

.nav-group-title--direct {
  grid-template-columns: 18px minmax(0, 1fr);
}

.nav-group-title--direct.is-active {
  color: #69adff;
  font-weight: 600;
  background: #102b48;
}

.nav-group-title--direct.is-active::before {
  background: #69adff;
}

.nav-group.is-open > .nav-group-title {
  color: #f4f8fc;
  font-weight: 400;
  background: rgb(255 255 255 / 3%);
}

.nav-group-items,
.nav-group-items--sectioned,
.nav-subgroup-items {
  padding: 2px 0 5px;
}

.nav-subgroup-title,
.nav-subgroup-label {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  width: calc(100% - 28px);
  min-height: 40px;
  margin: 1px 0 1px 28px;
  padding: 0 8px;
  color: #c8d5e4;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  text-align: left;
}

.nav-subgroup summary.nav-subgroup-title {
  justify-content: space-between;
  min-height: 40px;
  padding: 0 8px;
  color: #c8d5e4;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  cursor: pointer;
}

.nav-subgroup summary.nav-subgroup-title:hover,
.nav-subgroup-label:hover {
  color: #fff;
  background: #132f4e;
}

.nav-subgroup summary.nav-subgroup-title .ui-icon {
  width: 13px;
  height: 13px;
}

.nav-item {
  box-sizing: border-box;
  min-height: 40px;
  padding: 9px 10px;
  border-radius: 5px;
  color: #b8c7d8;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
}

.nav-item--level-2 {
  width: calc(100% - 28px);
  margin-left: 28px;
}

.nav-item--level-3 {
  width: calc(100% - 46px);
  margin-left: 46px;
}

.nav-item--level-3::after {
  display: none;
}

.nav-item:hover {
  color: #fff;
  background: #132f4e;
}

.nav-item.is-active {
  color: #69adff;
  font-weight: 600;
  background: #102b48;
}

.nav-item.is-active::before {
  top: 7px;
  bottom: 7px;
  width: 3px;
  background: #69adff;
}

.nav-group-title:focus-visible,
.nav-subgroup-title:focus-visible,
.nav-item:focus-visible {
  outline: 2px solid #69adff;
  outline-offset: -2px;
}
