/* Production UI System */
:root {
  --ui-navy-950: #0f3476;
  --ui-navy-800: #0f3476;
  --ui-blue-600: #0f3476;
  --ui-cyan-500: #72c8c4;
  --ui-gold-500: #e69948;
  --ui-red-500: #e53935;
  --ui-warning-500: #ffab40;
  --ui-green-500: #328a72;
  --ui-ink: #1d2129;
  --ui-muted: #6e7681;
  --ui-line: #dfe3e8;
  --ui-line-soft: #edf0f2;
  --ui-surface: #ffffff;
  --ui-surface-soft: #f6f8fa;
  --ui-page: #f6f8fa;
  --ui-radius: 6px;
  --ui-shadow: 0 2px 8px rgba(29, 33, 41, 0.06);
}

body {
  color: var(--ui-ink);
  background: linear-gradient(180deg, #eef5fa 0, #f7fafc 240px, #f5f8fa 100%);
}

.erp-shell {
  --content-max: 1500px;
}

.erp-main {
  gap: 12px;
}

.topbar.is-compact {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px) auto;
  min-height: 56px;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-color: rgba(201, 218, 232, 0.92);
  box-shadow: var(--ui-shadow);
}

.approval-card.wide,
.flow-status-strip {
  min-width: 0;
  min-height: 40px;
  padding: 4px 5px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.flow-status-title {
  color: #35556e;
  background: #edf5fa;
}

.flow-status-items {
  display: grid !important;
  grid-template-columns: auto auto minmax(0, 1fr) !important;
  align-items: center;
  gap: 5px !important;
}

.flow-status-cluster {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 4px;
  border: 1px solid var(--ui-line-soft);
  border-radius: 7px;
  background: #f8fbfd;
}

.flow-status-cluster > span {
  flex: 0 0 auto;
  padding: 0 4px;
  color: #647d91;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.flow-status-cluster .approval-link {
  min-width: 47px;
  height: 28px;
  min-height: 28px;
  padding: 3px 6px;
  border-color: transparent;
  background: transparent;
}

.flow-status-cluster .approval-link:hover {
  border-color: #bed6e7;
  background: #fff;
}

.global-search input {
  min-height: 38px;
  border-color: var(--ui-line);
  background: #fff;
}

.cloud-sync-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  color: #456177;
  background: #f3f7fa;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.cloud-sync-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8aa0b3;
}

.cloud-sync-status[data-state="saving"]::before {
  background: var(--ui-gold-500);
  box-shadow: 0 0 0 4px rgba(201, 147, 50, 0.12);
}

.cloud-sync-status[data-state="saved"]::before {
  background: var(--ui-green-500);
}

.cloud-sync-status[data-state="error"] {
  color: #a83a34;
  background: #fff1f0;
}

.cloud-sync-status[data-state="error"]::before {
  background: var(--ui-red-500);
}

.module-nav button::after {
  display: none !important;
}

.module-nav button {
  border-color: rgba(255, 255, 255, 0.04);
}

.module-nav button.is-active {
  color: #fff;
  border-color: rgba(114, 244, 232, 0.56);
  background: linear-gradient(90deg, rgba(32, 189, 183, 0.22), rgba(255, 255, 255, 0.08));
}

.view-root {
  gap: 12px;
}

.panel,
.flow-form,
.dashboard-visual-panel {
  border-color: var(--ui-line);
  border-radius: var(--ui-radius);
  box-shadow: var(--ui-shadow);
}

.panel-title,
.form-head,
.dashboard-panel-head {
  min-height: 46px;
  padding: 10px 14px;
  border-bottom-color: var(--ui-line-soft);
}

.panel-title > div:first-child,
.dashboard-panel-head > div:first-child {
  min-width: 0;
}

.panel-title strong,
.form-head strong,
.dashboard-panel-head strong {
  color: #173b5a;
  font-size: 14px;
}

.panel-title span,
.form-head span,
.dashboard-panel-head span {
  color: var(--ui-muted);
}

.tabs,
.finance-subnav,
.contract-subtabs,
.project-subtabs,
.party-subtabs,
.organization-subtabs {
  position: sticky;
  top: 8px;
  z-index: 24;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 2px;
  padding: 4px;
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 20px rgba(17, 59, 106, 0.07);
  backdrop-filter: blur(10px);
}

.tab-button,
.finance-subnav button,
.contract-subtabs button,
.project-subtabs button,
.party-subtabs button,
.organization-subtabs button {
  min-height: 32px;
  border-radius: 6px;
}

.tab-button.is-active,
.finance-subnav button.is-active,
.contract-subtabs button.is-active,
.project-subtabs button.is-active,
.party-subtabs button.is-active,
.organization-subtabs button.is-active {
  color: #fff;
  background: #176da7;
  box-shadow: none;
}

.dashboard-executive {
  min-height: 0;
  padding: 16px;
  border-radius: 8px;
}

.dashboard-command {
  min-height: 92px;
  padding-bottom: 12px;
}

.dashboard-command-main strong {
  font-size: 27px;
}

.boss-kpi-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.boss-kpi-card {
  min-height: 110px;
  padding: 14px;
  border-color: rgba(187, 213, 231, 0.42);
  background: rgba(255, 255, 255, 0.1);
}

.boss-kpi-card strong {
  font-size: 24px;
}

.dashboard-primary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.72fr);
  gap: 12px;
  align-items: stretch;
}

.dashboard-primary-grid > .dashboard-visual-panel {
  min-height: 330px;
}

.dashboard-secondary-details {
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--ui-shadow);
}

.dashboard-secondary-details > summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: #31536d;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.dashboard-secondary-details > summary::after {
  content: "+";
  margin-left: auto;
  color: var(--ui-blue-600);
  font-size: 18px;
}

.dashboard-secondary-details[open] > summary::after {
  content: "-";
}

.dashboard-secondary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0 12px 12px;
}

.flow-form-progress {
  display: grid;
  grid-template-columns: auto minmax(120px, 0.32fr) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--ui-line-soft);
  background: #f8fbfd;
}

.flow-form-progress > div {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #47647b;
  font-size: 11px;
}

.flow-form-progress > div strong {
  color: #244a68;
  font-size: 12px;
}

.flow-form-progress > i {
  height: 5px;
  overflow: hidden;
  border-radius: 5px;
  background: #dce8f0;
}

.flow-form-progress > i b {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ui-blue-600), var(--ui-cyan-500));
  transform: scaleX(var(--progress-scale, 0));
  transform-origin: left center;
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

#flow-section-nav {
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
}

#flow-section-nav button {
  flex: 0 0 auto;
  min-height: 27px;
  padding: 0 8px;
  border: 1px solid #cbddea;
  border-radius: 6px;
  color: #3d5c74;
  background: #fff;
  font-size: 11px;
}

.flow-validation-summary {
  margin: 10px 14px 0;
  padding: 10px 12px;
  border: 1px solid #efaaa5;
  border-radius: 7px;
  color: #8f312d;
  background: #fff4f3;
}

.flow-validation-summary > div:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
}

.flow-validation-summary strong {
  font-size: 13px;
}

.flow-validation-summary span {
  color: #9f4a45;
  font-size: 12px;
}

.flow-validation-links {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.flow-validation-links button {
  min-height: 27px;
  padding: 0 8px;
  border: 1px solid #efb7b2;
  border-radius: 5px;
  color: #933a35;
  background: #fff;
  font-size: 11px;
}

.form-grid {
  gap: 8px 10px;
  padding: 12px 14px 16px;
}

.form-grid label {
  min-height: 72px;
  padding: 9px 10px;
  border-color: transparent;
  border-radius: 7px;
  background: var(--ui-surface-soft);
  box-shadow: inset 0 0 0 1px #e1ebf2;
}

.form-grid label:hover {
  transform: none;
  border-color: transparent;
  box-shadow: inset 0 0 0 1px #c9ddea;
}

.form-grid label:focus-within {
  background: #fff;
  box-shadow: inset 0 0 0 1px #62a8d2, 0 0 0 3px rgba(22, 119, 184, 0.1);
}

.form-grid label.field-invalid,
.field-invalid {
  background: #fff5f4 !important;
  box-shadow: inset 0 0 0 1px #dc7771 !important;
}

.form-section-label {
  min-height: 34px;
  margin-top: 4px;
  padding: 0 10px;
  border: 1px solid #d7e5ec;
  border-radius: 4px;
  color: #1d4e70;
  background: #edf6fb;
}

.form-actions {
  position: sticky;
  bottom: 8px;
  z-index: 30;
  margin: 8px 14px 12px;
  padding: 8px;
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 28px rgba(17, 59, 106, 0.12);
  backdrop-filter: blur(10px);
}

.data-table {
  color: var(--ui-ink);
  font-size: 12px;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 38px;
  color: #294b65;
  background: #edf5fa;
}

.data-table td {
  color: #20384d;
}

.data-table tbody tr:hover td {
  background: #f3f9fc;
}

.data-table .is-column-hidden {
  display: none !important;
}

.dashboard-preview-backdrop {
  z-index: 180;
}

.user-menu-anchor {
  position: relative;
  min-width: 0;
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 310;
  width: min(286px, calc(100vw - 28px));
  padding: 10px;
  border: 1px solid var(--ui-line);
  border-radius: 7px;
  color: var(--ui-ink);
  background: #fff;
  box-shadow: 0 18px 42px rgba(15, 52, 118, 0.2);
}

.user-menu-dropdown[hidden] {
  display: none;
}

.user-menu-profile {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 6px 6px 12px;
  border-bottom: 1px solid #e8eef2;
}

.user-preview-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--ui-navy-950);
  font-size: 16px;
  font-weight: 800;
  overflow: hidden;
}

.user-preview-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.user-preview-avatar img[hidden] {
  display: none;
}

.user-preview-avatar span {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.user-menu-profile > div:last-child {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.user-menu-profile strong,
.user-menu-profile span,
.user-menu-profile small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-profile strong {
  color: #153d5b;
  font-size: 14px;
}

.user-menu-profile span,
.user-menu-profile small {
  color: var(--ui-muted);
  font-size: 11px;
}

.user-menu-profile .user-preview-avatar span {
  color: #fff;
  font-size: 16px;
  font-weight: 800;
}

.user-menu-logout {
  width: 100%;
  min-height: 36px;
  margin-top: 6px;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  color: #b42318;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.user-menu-logout:hover,
.user-menu-logout:focus-visible {
  background: #fff1f0;
  outline: none;
}

/* Standalone flow detail */
body.flow-detail-only .erp-sidebar,
body.flow-detail-only .topbar,
body.flow-detail-only .workspace-tabs,
body.flow-detail-only .page-export-tools {
  display: none !important;
}

body.flow-detail-only .erp-shell {
  grid-template-columns: minmax(0, 1fr) !important;
  min-height: 100vh;
  background: var(--ui-surface, #f6f8fa);
}

body.flow-detail-only .erp-main {
  width: min(1120px, 100%);
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 !important;
}

body.flow-detail-only .view-root {
  min-height: 100vh;
}

body.flow-detail-only .flow-record-preview-backdrop {
  position: static !important;
  inset: auto !important;
  display: block;
  min-height: 100vh;
  padding: 24px;
  background: #f6f8fa;
  backdrop-filter: none;
}

body.flow-detail-only .flow-record-preview-panel {
  width: 100%;
  max-height: none;
  margin: 0 auto;
  box-shadow: 0 10px 30px rgba(15, 52, 118, 0.1);
}

.flow-detail-empty {
  min-height: 320px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 48px 24px;
  text-align: center;
}

.flow-detail-empty p {
  max-width: 520px;
  margin: 0;
  color: var(--ui-muted, #6e7681);
}

.flow-detail-empty .system-notice-mark {
  color: var(--ui-navy-950, #0f3476);
  background: #edf3fb;
}

.flow-detail-empty .system-notice-mark::before {
  content: "i";
  width: auto;
  height: auto;
  border: 0;
  font-weight: 800;
  transform: none;
}

.system-notice-backdrop {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 27, 69, 0.42);
  backdrop-filter: blur(5px);
}

.system-notice {
  width: min(460px, 100%);
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  padding: 20px;
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 26px 70px rgba(6, 27, 69, 0.24);
}

.system-notice-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e7f7f3;
}

.system-notice-mark::before {
  content: "";
  width: 15px;
  height: 10px;
  background: var(--ui-green-500);
  clip-path: polygon(0 42%, 18% 24%, 42% 54%, 84% 0, 100% 18%, 42% 100%);
}

.system-notice-backdrop.is-error .system-notice-mark {
  background: #fff0ef;
}

.system-notice-backdrop.is-error .system-notice-mark::before {
  width: 3px;
  height: 18px;
  border: 0;
  background: var(--ui-red-500);
  clip-path: none;
  transform: rotate(45deg);
  box-shadow: 0 0 0 0 var(--ui-red-500);
}

.system-notice-copy strong {
  display: block;
  color: #163b59;
  font-size: 18px;
}

.system-notice-copy p {
  margin: 7px 0 0;
  color: var(--ui-muted);
  line-height: 1.65;
  font-size: 13px;
}

.submission-receipt dl {
  display: grid;
  gap: 6px;
  margin: 12px 0 0;
}

.submission-receipt dl div {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 8px;
  padding: 7px 9px;
  border-radius: 6px;
  background: #f4f8fb;
}

.submission-receipt dt {
  color: #61798d;
  font-size: 12px;
}

.submission-receipt dd {
  margin: 0;
  color: #203f58;
  font-size: 12px;
  font-weight: 700;
}

.system-notice-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (min-width: 1800px) {
  .erp-main {
    max-width: 1500px;
    padding-left: 30px;
    padding-right: 30px;
  }
}

@media (max-width: 1400px) and (min-width: 981px) {
  .flow-status-title,
  .flow-status-cluster > span {
    display: none !important;
  }

  .flow-status-strip {
    display: block;
    overflow: hidden;
  }

  .flow-status-items {
    width: 100%;
    display: flex !important;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .flow-status-cluster {
    flex: 0 0 auto;
  }
}

@media (max-width: 1180px) {
  .topbar.is-compact {
    grid-template-columns: minmax(0, 1fr) minmax(240px, 360px) auto;
  }

  .flow-status-title,
  .flow-status-cluster > span {
    display: none !important;
  }

  .dashboard-primary-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-primary-grid > .dashboard-visual-panel {
    min-height: 0;
  }
}

@media (max-width: 980px) {
  .topbar.is-compact {
    grid-template-columns: 1fr auto;
  }

  .approval-overview {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .global-search {
    grid-column: 1;
    grid-row: 1;
  }

  .topbar-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .flow-status-items {
    display: flex !important;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .flow-status-cluster {
    flex: 0 0 auto;
  }

  .boss-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-secondary-grid {
    grid-template-columns: 1fr;
  }

  .flow-form-progress {
    grid-template-columns: auto minmax(100px, 1fr);
  }

  #flow-section-nav {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .form-grid > * {
    grid-column: 1 / -1 !important;
  }
}

/* Release candidate UI: compact cockpit, larger charts and stable workflow/editor surfaces. */
body {
  background: #e9eff3;
}

.login-gate-dingtalk {
  grid-template-columns: 1fr;
}

.login-gate-quote {
  max-width: 860px;
  padding: 14px 28px;
  border-top: 1px solid rgba(108, 226, 216, 0.28);
  border-bottom: 1px solid rgba(108, 226, 216, 0.16);
  color: rgba(245, 250, 253, 0.94);
  font-family: "STKaiti", "KaiTi", "Songti SC", "STSong", serif;
  font-size: 17px;
  line-height: 2.05;
  text-shadow: 0 3px 16px rgba(3, 25, 58, 0.55);
}

.flow-status-strip {
  gap: 6px;
  padding: 4px 5px;
}

.flow-status-title {
  min-width: 58px;
  justify-content: center;
}

.flow-status-items {
  gap: 6px !important;
}

.flow-status-cluster {
  min-height: 38px;
  grid-auto-columns: minmax(62px, 1fr);
  gap: 4px;
  padding: 3px 4px;
}

.flow-status-cluster > span {
  min-width: 62px;
  font-size: 11px;
}

.flow-status-cluster .approval-link {
  min-width: 62px;
  min-height: 30px;
  height: 30px;
  padding: 3px 6px;
}

.flow-status-cluster .approval-link small {
  font-size: 11px;
}

.dashboard-executive {
  gap: 7px;
  padding: 8px 11px 10px;
  border-color: rgba(112, 226, 216, 0.35);
  background: linear-gradient(112deg, #082f66 0%, #0d5797 58%, #082a58 100%);
}

.dashboard-executive::before {
  background-size: 36px 36px;
  opacity: 0.22;
  animation: dashboard-grid-drift 16s linear infinite;
}

.dashboard-executive::after {
  display: none;
}

.dashboard-command {
  min-height: 42px;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.dashboard-command-main strong {
  margin: 2px 0 0;
  font-size: 19px;
}

.dashboard-command-main small {
  display: none;
}

.dashboard-project-picker.compact,
.dashboard-filter-trigger {
  width: 46px;
  height: 42px;
}

.dashboard-filter-trigger::before {
  width: 18px;
  height: 18px;
  border-width: 0 5px 5px 0;
  transform: translateY(-4px) rotate(45deg);
}

.boss-kpi-grid {
  gap: 7px;
  padding-top: 5px;
}

.boss-kpi-card {
  min-height: 62px;
  padding: 8px 10px;
}

.boss-kpi-card strong {
  margin: 5px 0 3px;
  font-size: 18px;
}

.boss-kpi-card small {
  font-size: 10px;
}

.dashboard-primary-grid {
  grid-template-columns: minmax(0, 1.52fr) minmax(390px, 0.82fr);
  grid-template-rows: repeat(2, minmax(268px, auto));
  gap: 14px;
}

.dashboard-matrix-body {
  min-height: 522px;
  grid-template-columns: minmax(320px, 1.08fr) minmax(260px, 0.92fr);
  gap: 28px;
  padding: 26px;
}

.dashboard-radar {
  width: min(100%, 370px);
  min-height: 370px;
  border-color: rgba(32, 189, 183, 0.3);
  background: #f7fbfd;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8), 0 18px 42px rgba(12, 74, 118, 0.11);
}

.radar-value {
  animation: dashboard-radar-pulse 3.2s ease-in-out infinite;
}

.matrix-score {
  min-height: 74px;
  padding: 12px 14px;
}

.dashboard-pulse-panel .pulse-stack,
.dashboard-invoice-panel .invoice-rings {
  min-height: 216px;
}

.pulse-row {
  min-height: 34px;
}

.mini-gauge {
  min-height: 184px;
}

.flow-form {
  overflow: hidden;
}

.flow-form .form-head {
  min-height: 58px;
  padding: 12px 15px;
}

.flow-form-progress {
  padding: 10px 14px;
  background: #f5f9fc;
}

.form-grid {
  gap: 9px 10px;
  padding: 12px 14px 16px;
  background: #f7fafc;
}

.form-grid label {
  border: 1px solid #d8e5ed;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(24, 64, 96, 0.035);
}

.form-grid label:focus-within {
  border-color: #2b86bd;
  box-shadow: 0 0 0 3px rgba(43, 134, 189, 0.12);
}

.form-grid input,
.form-grid select {
  min-height: 32px;
}

.form-grid textarea {
  min-height: 66px;
}

.form-section-label {
  margin-top: 7px;
  border: 1px solid #dbe8f0;
  background: #eef5f8;
}

.template-editor-fixed-head,
.template-editor-fixed-actions {
  background: #ffffff;
}

.template-required-sidebar {
  grid-template-rows: auto minmax(120px, 0.4fr) minmax(0, 1fr);
}

.template-editor-fields-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f2f8fb;
}

.template-editor-grid {
  scroll-behavior: smooth;
  scroll-padding: 16px;
}

@keyframes dashboard-grid-drift {
  from { background-position: 0 0, 0 0; }
  to { background-position: 36px 36px, 36px 36px; }
}

@keyframes dashboard-radar-pulse {
  0%, 100% { fill-opacity: 0.72; stroke-opacity: 0.86; }
  50% { fill-opacity: 1; stroke-opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .dashboard-executive::before,
  .radar-value {
    animation: none;
  }
}

@media (max-width: 1300px) {
  .dashboard-primary-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .dashboard-matrix-body {
    min-height: 470px;
  }
}

@media (max-width: 760px) {
  .login-gate-quote {
    padding: 10px 4px;
    font-size: 14px;
    line-height: 1.85;
  }

  .dashboard-command {
    grid-template-columns: minmax(0, 1fr) 42px;
  }

  .dashboard-primary-grid {
    gap: 10px;
  }

  .dashboard-matrix-body {
    min-height: 0;
    padding: 16px;
  }

  .dashboard-radar {
    width: min(100%, 300px);
    min-height: 300px;
  }
}

/* Dashboard v4 final cascade guard. */
.dashboard-primary-grid {
  grid-template-columns: minmax(0, 1.72fr) minmax(280px, 0.62fr);
  grid-template-rows: auto;
  gap: 12px;
}

.dashboard-primary-grid > .dashboard-visual-panel,
.dashboard-primary-grid .dashboard-visual-panel {
  min-height: 0;
}

@media (max-width: 1180px) {
  .dashboard-primary-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .dashboard-side-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto;
  }
}

@media (max-width: 760px) {
  .dashboard-stage-track,
  .dashboard-cost-flow,
  .dashboard-side-stack {
    grid-template-columns: 1fr;
  }
}

/* Payroll live totals are kept compact and are refined in the final cascade. */
.payroll-live-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* DingTalk message-entry automatic login */
.login-dingtalk-auto-status {
  min-height: 188px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 9px;
  padding: 24px 12px;
  color: #1d425f;
  text-align: center;
}

.login-dingtalk-auto-status[hidden] {
  display: none;
}

.login-dingtalk-auto-status i {
  width: 30px;
  height: 30px;
  border: 2px solid rgba(15, 52, 118, 0.18);
  border-top-color: #72c8c4;
  border-radius: 50%;
  animation: ding-auto-login-spin 900ms linear infinite;
}

.login-dingtalk-auto-status strong {
  color: #0f3476;
  font-size: 16px;
}

.login-dingtalk-auto-status span {
  color: #5b7285;
  font-size: 12px;
}

.login-gate.is-dingtalk-auto-login .login-mode-toggle,
.login-gate.is-dingtalk-auto-login .login-mode-panel,
.login-gate.is-dingtalk-auto-login #login-gate-message {
  display: none;
}

.login-gate.is-dingtalk-auto-login .login-gate-brand {
  margin-right: 0;
  margin-bottom: 0;
}

@keyframes ding-auto-login-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .login-dingtalk-auto-status i {
    animation: none;
  }
}

/* Xingliu Matrix login identity */
.login-gate-brand {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.login-brand-heading {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-brand-matrix {
  position: relative;
  width: min(100%, 222px);
  min-height: 66px;
  display: grid;
  gap: 6px;
  padding: 6px 8px 5px 12px;
  overflow: hidden;
  border-left: 2px solid rgba(114, 200, 196, 0.7);
  border-bottom: 1px solid rgba(15, 52, 118, 0.14);
  background: linear-gradient(90deg, rgba(238, 248, 247, 0.92), rgba(247, 250, 252, 0.24));
}

.login-brand-matrix::before,
.login-brand-matrix::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.login-brand-matrix::before {
  top: 0;
  right: 10px;
  width: 34px;
  height: 34px;
  border-top: 1px solid rgba(15, 52, 118, 0.2);
  border-right: 1px solid rgba(114, 200, 196, 0.52);
  transform: skew(-26deg);
}

.login-brand-matrix::after {
  right: 0;
  bottom: 7px;
  width: 74px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(15, 52, 118, 0.24));
  transform: rotate(-24deg);
  transform-origin: right center;
}

.login-matrix-wordmark,
.login-matrix-caption {
  position: relative;
  z-index: 1;
  color: #557086;
  font-size: 8px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}

.login-matrix-wordmark {
  color: #0f3476;
  font-size: 9px;
}

.login-matrix-network {
  position: relative;
  z-index: 1;
  width: min(100%, 186px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
  gap: 8px;
  padding: 2px 4px;
}

.login-matrix-network::before,
.login-matrix-network::after {
  content: "";
  position: absolute;
  z-index: -1;
  pointer-events: none;
}

.login-matrix-network::before {
  top: 50%;
  right: 7px;
  left: 7px;
  height: 1px;
  background: linear-gradient(90deg, rgba(15, 52, 118, 0.18), rgba(114, 200, 196, 0.72), rgba(15, 52, 118, 0.18));
}

.login-matrix-network::after {
  top: 50%;
  left: 24%;
  width: 100px;
  height: 1px;
  background: rgba(15, 52, 118, 0.18);
  transform: rotate(-13deg);
  transform-origin: left center;
}

.login-matrix-node {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  justify-self: center;
  border: 1px solid rgba(15, 52, 118, 0.52);
  border-radius: 5px;
  color: #0f3476;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(114, 200, 196, 0.13), 0 3px 8px rgba(15, 52, 118, 0.1);
  transform: rotate(45deg);
}

.login-matrix-node b {
  display: block;
  color: inherit;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  transform: rotate(-45deg);
}

.login-matrix-node:nth-child(2),
.login-matrix-node:nth-child(4) {
  color: #0d6d78;
  border-color: rgba(114, 200, 196, 0.9);
  background: #effaf9;
}

@media (max-width: 760px) {
  .login-brand-matrix {
    width: min(100%, 206px);
    min-height: 60px;
    gap: 5px;
    padding-left: 10px;
  }

  .login-matrix-network {
    width: min(100%, 174px);
    gap: 5px;
  }

  .login-matrix-node {
    width: 22px;
    height: 22px;
  }

  .login-matrix-node b {
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-brand-matrix::after,
  .login-matrix-node {
    transition: none;
  }
}

/* Compact desktop sidebar final cascade */
@media (min-width: 761px) {
  .erp-shell {
    grid-template-columns: 204px minmax(0, min(calc(var(--content-max) + 48px), calc(100vw - 204px)));
  }

  .app-tech-canvas {
    left: 204px;
    width: calc(100% - 204px);
  }

  .erp-sidebar {
    padding: 10px 8px;
  }

  .brand {
    min-height: 58px;
    gap: 6px;
    padding: 2px 5px 8px;
  }

  .brand img {
    flex: 0 0 50px;
    width: 50px;
    height: 46px;
  }

  .brand strong,
  .brand span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand strong {
    font-size: 15px;
  }

  .brand span {
    font-size: 11px;
  }

  .module-nav {
    gap: 4px;
    margin-top: 7px;
  }

  .module-nav-group {
    gap: 2px;
    padding: 1px 0 4px;
  }

  .module-nav-title {
    padding: 0 7px 1px;
    font-size: 10px;
  }

  .module-nav button {
    min-height: 31px;
    gap: 7px;
    padding: 5px 8px;
    font-size: 14px;
    line-height: 1.15;
  }
}

.payroll-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border-top: 1px solid var(--ui-line-soft);
  border-bottom: 1px solid var(--ui-line-soft);
  background: #fff;
}

.payroll-table {
  min-width: 2140px;
  table-layout: fixed;
}

.payroll-table th,
.payroll-table td {
  min-width: 86px;
  padding: 6px 7px;
  white-space: nowrap;
}

.payroll-table th:nth-child(2),
.payroll-table td:nth-child(2) {
  min-width: 150px;
}

.payroll-table th:nth-child(4),
.payroll-table td:nth-child(4) {
  min-width: 160px;
}

.payroll-table input,
.payroll-table select,
.payroll-table textarea {
  width: 100%;
  min-width: 76px;
  min-height: 30px;
  padding: 4px 6px;
  border: 1px solid #d6e1e8;
  border-radius: 4px;
  background: #fff;
}

.payroll-table textarea {
  min-width: 150px;
  resize: vertical;
}

.payroll-group-head th {
  color: #fff;
  background: var(--ui-navy-950);
}

.contract-ledger-group-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 0 14px 12px;
  padding: 4px;
  border: 1px solid var(--ui-line);
  border-radius: 7px;
  background: var(--ui-surface-soft);
}

.contract-ledger-group-switch button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: #40566d;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.contract-ledger-group-switch button:hover,
.contract-ledger-group-switch button.is-active {
  color: #fff;
  border-color: var(--ui-navy-950);
  background: var(--ui-navy-950);
}

@media (max-width: 760px) {
  .contract-ledger-group-switch {
    margin-right: 9px;
    margin-left: 9px;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .contract-ledger-group-switch button {
    flex: 0 0 auto;
  }

  .payroll-table-wrap {
    margin: 0 -1px;
  }
}

/* Final compact sidebar and ledger controls cascade */
@media (min-width: 761px) {
  .erp-shell {
    grid-template-columns: 204px minmax(0, min(calc(var(--content-max) + 48px), calc(100vw - 204px)));
  }

  .app-tech-canvas {
    left: 204px;
    width: calc(100% - 204px);
  }

  .erp-sidebar {
    padding: 10px 8px;
  }

  .brand {
    min-height: 58px;
    gap: 6px;
    padding: 2px 5px 8px;
  }

  .brand img {
    flex: 0 0 50px;
    width: 50px;
    height: 46px;
  }

  .brand strong,
  .brand span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand strong {
    font-size: 15px;
  }

  .brand span {
    font-size: 11px;
  }

  .module-nav {
    gap: 4px;
    margin-top: 7px;
  }

  .module-nav-group {
    gap: 2px;
    padding: 1px 0 4px;
  }

  .module-nav-title {
    padding: 0 7px 1px;
    font-size: 10px;
  }

  .module-nav button {
    min-height: 31px;
    gap: 7px;
    padding: 5px 8px;
    font-size: 14px;
    line-height: 1.15;
  }
}

.payroll-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border-top: 1px solid var(--ui-line-soft);
  border-bottom: 1px solid var(--ui-line-soft);
  background: #fff;
}

.payroll-table {
  min-width: 2140px;
  table-layout: fixed;
}

.payroll-table th,
.payroll-table td {
  min-width: 86px;
  padding: 6px 7px;
  white-space: nowrap;
}

.payroll-table th:nth-child(2),
.payroll-table td:nth-child(2) {
  min-width: 150px;
}

.payroll-table th:nth-child(4),
.payroll-table td:nth-child(4) {
  min-width: 160px;
}

.payroll-table input,
.payroll-table select,
.payroll-table textarea {
  width: 100%;
  min-width: 76px;
  min-height: 30px;
  padding: 4px 6px;
  border: 1px solid #d6e1e8;
  border-radius: 4px;
  background: #fff;
}

.payroll-table textarea {
  min-width: 150px;
  resize: vertical;
}

.payroll-group-head th {
  color: #fff;
  background: var(--ui-navy-950);
}

.contract-ledger-group-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 0 14px 12px;
  padding: 4px;
  border: 1px solid var(--ui-line);
  border-radius: 7px;
  background: var(--ui-surface-soft);
}

.contract-ledger-group-switch button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: #40566d;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.contract-ledger-group-switch button:hover,
.contract-ledger-group-switch button.is-active {
  color: #fff;
  border-color: var(--ui-navy-950);
  background: var(--ui-navy-950);
}

@media (max-width: 760px) {
  .contract-ledger-group-switch {
    margin-right: 9px;
    margin-left: 9px;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .contract-ledger-group-switch button {
    flex: 0 0 auto;
  }

  .payroll-table-wrap {
    margin: 0 -1px;
  }
}

/* Compact desktop sidebar */
@media (min-width: 761px) {
  .erp-shell {
    grid-template-columns: 204px minmax(0, min(calc(var(--content-max) + 48px), calc(100vw - 204px)));
  }

  .app-tech-canvas {
    left: 204px;
    width: calc(100% - 204px);
  }

  .erp-sidebar {
    padding: 10px 8px;
  }

  .brand {
    min-height: 58px;
    gap: 6px;
    padding: 2px 5px 8px;
  }

  .brand img {
    flex: 0 0 50px;
    width: 50px;
    height: 46px;
  }

  .brand strong,
  .brand span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand strong {
    font-size: 15px;
  }

  .brand span {
    font-size: 11px;
  }

  .module-nav {
    gap: 4px;
    margin-top: 7px;
  }

  .module-nav-group {
    gap: 2px;
    padding: 1px 0 4px;
  }

  .module-nav-title {
    padding: 0 7px 1px;
    font-size: 10px;
  }

  .module-nav button {
    min-height: 31px;
    gap: 7px;
    padding: 5px 8px;
    font-size: 14px;
    line-height: 1.15;
  }
}

/* Payroll and contract grouping controls */
.payroll-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border-top: 1px solid var(--ui-line-soft);
  border-bottom: 1px solid var(--ui-line-soft);
  background: #fff;
}

.payroll-table {
  min-width: 2140px;
  table-layout: fixed;
}

.payroll-table th,
.payroll-table td {
  min-width: 86px;
  padding: 6px 7px;
  white-space: nowrap;
}

.payroll-table th:nth-child(2),
.payroll-table td:nth-child(2) {
  min-width: 150px;
}

.payroll-table th:nth-child(4),
.payroll-table td:nth-child(4) {
  min-width: 160px;
}

.payroll-table input,
.payroll-table select,
.payroll-table textarea {
  width: 100%;
  min-width: 76px;
  min-height: 30px;
  padding: 4px 6px;
  border: 1px solid #d6e1e8;
  border-radius: 4px;
  background: #fff;
}

.payroll-table textarea {
  min-width: 150px;
  resize: vertical;
}

.payroll-group-head th {
  color: #fff;
  background: var(--ui-navy-950);
}

.contract-ledger-group-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 0 14px 12px;
  padding: 4px;
  border: 1px solid var(--ui-line);
  border-radius: 7px;
  background: var(--ui-surface-soft);
}

.contract-ledger-group-switch button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: #40566d;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.contract-ledger-group-switch button:hover,
.contract-ledger-group-switch button.is-active {
  color: #fff;
  border-color: var(--ui-navy-950);
  background: var(--ui-navy-950);
}

@media (max-width: 760px) {
  .contract-ledger-group-switch {
    margin-right: 9px;
    margin-left: 9px;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .contract-ledger-group-switch button {
    flex: 0 0 auto;
  }

  .payroll-table-wrap {
    margin: 0 -1px;
  }
}

/* User menu stacking guard */
.erp-main > .topbar.is-compact {
  z-index: 30;
}

/* System notification toasts */
.system-notification-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 280;
  width: min(390px, calc(100vw - 32px));
  display: grid;
  gap: 10px;
  pointer-events: none;
}

.system-toast {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 32px;
  gap: 10px;
  align-items: start;
  padding: 14px;
  border: 1px solid #9bd6d3;
  border-radius: 7px;
  color: var(--ui-ink);
  background: #fff;
  box-shadow: 0 16px 38px rgba(15, 52, 118, 0.18);
  pointer-events: auto;
  animation: system-toast-enter 180ms ease-out both;
}

.system-toast.is-clickable {
  cursor: pointer;
}

.system-toast.is-clickable:hover,
.system-toast.is-clickable:focus-visible {
  border-color: var(--ui-cyan-500);
  background: #f8fcfc;
  outline: 3px solid rgba(114, 200, 196, 0.18);
}

.system-toast.is-error {
  border-color: var(--ui-red-500);
}

.system-toast.is-info {
  border-color: var(--ui-navy-950);
}

.system-toast-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--ui-cyan-500);
}

.system-toast-mark::before {
  content: "";
  width: 11px;
  height: 8px;
  background: currentColor;
  clip-path: polygon(0 42%, 18% 24%, 42% 54%, 84% 0, 100% 18%, 42% 100%);
}

.system-toast.is-info .system-toast-mark {
  background: var(--ui-navy-950);
}

.system-toast.is-info .system-toast-mark::before {
  content: "i";
  width: auto;
  height: auto;
  border: 0;
  background: transparent;
  clip-path: none;
  font-weight: 800;
  transform: none;
}

.system-toast.is-error .system-toast-mark {
  background: var(--ui-red-500);
}

.system-toast.is-error .system-toast-mark::before {
  width: 2px;
  height: 13px;
  border: 0;
  background: currentColor;
  clip-path: none;
  transform: rotate(45deg);
}

.system-toast-copy {
  min-width: 0;
}

.system-toast-copy strong {
  display: block;
  color: #173b58;
  font-size: 14px;
  line-height: 1.45;
}

.system-toast-copy p {
  margin: 3px 0 0;
  color: var(--ui-muted);
  font-size: 12px;
  line-height: 1.55;
}

.system-toast-copy small {
  display: inline-block;
  margin-top: 7px;
  color: #0f5f69;
  font-size: 11px;
  font-weight: 700;
}

.system-toast-close {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  color: #6e7681;
  background: transparent;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.system-toast-close:hover {
  color: #153d5b;
  background: #eef3f6;
}

@keyframes system-toast-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 760px) {
  .system-notification-stack {
    right: 12px;
    bottom: 76px;
    width: calc(100vw - 24px);
  }
}

/* Final flow-status alignment guard */
.topbar.is-compact .flow-status-cluster .approval-link {
  justify-content: center !important;
  text-align: center;
}

.topbar.is-compact .flow-status-cluster .approval-link small,
.topbar.is-compact .flow-status-cluster .approval-link strong {
  width: 100%;
  text-align: center;
}

/* Login and compact navigation final pass */
.login-gate {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: #071f4a;
  background-image: none;
}

.login-tech-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.app-tech-canvas {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 220px;
  z-index: 0;
  width: calc(100% - 220px);
  height: 100%;
  pointer-events: none;
  opacity: 0.9;
}

@media (max-width: 760px) {
  .app-tech-canvas {
    left: 0;
    width: 100%;
  }
}

.erp-shell {
  isolation: isolate;
  background: #f3f7fa;
}

.erp-shell > .erp-sidebar,
.erp-shell > .erp-main {
  position: relative;
  z-index: 1;
}

.erp-main {
  background: rgba(246, 248, 250, 0.78);
}

.erp-main > :not(.app-tech-canvas) {
  position: relative;
  z-index: 1;
}

.login-gate-card {
  position: relative;
  z-index: 1;
  width: min(100%, 410px);
  padding: 28px 30px 26px;
  border: 1px solid rgba(207, 222, 234, 0.9);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 64px rgba(3, 20, 52, 0.34);
}

.login-mode-toggle {
  position: absolute;
  top: 14px;
  right: 14px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border: 1px solid #d5e1ea;
  border-radius: 5px;
  color: #31536d;
  background: #f7fafc;
  font-size: 13px;
  font-weight: 700;
}

.login-mode-toggle:hover,
.login-mode-toggle:focus-visible {
  border-color: #72c8c4;
  color: #0f5f69;
  background: #eef8f7;
  outline: none;
}

.login-mode-toggle > span {
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  box-shadow: inset 4px 0 0 #fff, inset -4px 0 0 #fff;
}

.login-mode-toggle b {
  font-weight: inherit;
}

.login-gate-brand {
  min-height: 74px;
  margin: 0 148px 24px 0;
  padding: 0;
  border: 0;
}

.login-gate-brand img {
  width: 68px;
  height: 60px;
}

.login-gate-brand strong {
  color: #0f3476;
  font-size: 25px;
}

.login-mode-panel {
  min-height: 226px;
}

.admin-login-form {
  display: grid;
  gap: 15px;
}

.admin-login-form label {
  display: grid;
  gap: 6px;
  color: #34495c;
  font-size: 12px;
  font-weight: 700;
}

.admin-login-form input {
  width: 100%;
  height: 42px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #cddbe6;
  border-radius: 5px;
  color: #1d2129;
  background: #ffffff;
  outline: none;
}

.admin-login-form input:focus {
  border-color: #58aaa6;
  box-shadow: 0 0 0 3px rgba(114, 200, 196, 0.2);
}

.login-account-submit {
  width: 100%;
  min-height: 42px;
  margin-top: 3px;
  border-radius: 5px;
  background: #0f3476;
}

.login-qr-panel .login-gate-dingtalk {
  padding: 0;
  border: 0;
  background: transparent;
}

.login-qr-panel .login-gate-dingtalk > span {
  text-align: center;
}

.login-qr-panel .login-gate-ding-qr {
  width: 304px;
  min-height: 304px;
}

#login-gate-message {
  margin-top: 12px;
  text-align: center;
}

.cloud-sync-status {
  width: 26px;
  min-width: 26px;
  min-height: 26px;
  justify-content: center;
  gap: 0;
  padding: 0;
  color: transparent;
  background: transparent;
  font-size: 0;
}

.cloud-sync-status::before {
  width: 9px;
  height: 9px;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(110, 118, 129, 0.28);
}

.cloud-sync-status[data-state="saving"]::before {
  background: #ffab40;
  box-shadow: 0 0 0 3px rgba(255, 171, 64, 0.16);
}

.cloud-sync-status[data-state="saved"]::before {
  background: #2f9d69;
  box-shadow: 0 0 0 3px rgba(47, 157, 105, 0.14);
}

.cloud-sync-status[data-state="error"] {
  color: transparent;
  background: transparent;
}

.cloud-sync-status[data-state="error"]::before {
  background: #e53935;
  box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.14);
}

.flow-status-cluster .approval-link {
  justify-content: center;
  text-align: center;
}

.flow-status-cluster .approval-link small,
.flow-status-cluster .approval-link strong {
  width: 100%;
  text-align: center;
}

@media (min-width: 761px) {
  .erp-shell {
    grid-template-columns: 220px minmax(0, min(calc(var(--content-max) + 48px), calc(100vw - 220px)));
  }

  .erp-sidebar {
    padding: 13px 10px;
  }

  .brand {
    min-height: 62px;
    gap: 9px;
    padding: 2px 7px 11px;
  }

  .brand img {
    width: 55px;
    height: 50px;
  }

  .brand strong {
    font-size: 16px;
  }

  .module-nav {
    gap: 7px;
    margin-top: 8px;
  }

  .module-nav-group {
    gap: 3px;
    padding: 2px 0 5px;
  }

  .module-nav-title {
    padding: 0 9px 1px;
    font-size: 10px;
  }

  .module-nav button {
    min-height: 34px;
    gap: 8px;
    padding: 6px 9px;
    font-size: 12px;
  }
}

@media (max-width: 760px) {
  .login-gate {
    padding: 16px;
  }

  .login-gate-card {
    padding: 24px 18px 22px;
  }

  .login-mode-toggle {
    top: 12px;
    right: 12px;
  }

  .login-gate-brand {
    min-height: 64px;
    margin-right: 136px;
    margin-bottom: 20px;
    gap: 8px;
  }

  .login-gate-brand img {
    width: 54px;
    height: 48px;
  }

  .login-gate-brand strong {
    font-size: 21px;
  }

  .login-mode-panel {
    min-height: 220px;
  }

  .login-qr-panel .login-gate-ding-qr {
    width: min(304px, 100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-tech-canvas {
    opacity: 0.72;
  }
}

/* Final palette guard: keep this block last in the cascade. */
body {
  color: var(--ui-ink);
  background: var(--ui-page);
  background-image: none;
}

.erp-sidebar {
  overflow-y: auto;
  border-right: 0;
  background: var(--ui-navy-950);
  background-image: none;
  box-shadow: none;
}

.brand img {
  filter: none;
}

.module-nav button:hover,
.module-nav button.is-active {
  color: #ffffff;
  border-color: rgba(114, 200, 196, 0.54);
  background: rgba(114, 200, 196, 0.18);
  background-image: none;
  box-shadow: inset 3px 0 0 var(--ui-cyan-500);
}

.topbar,
.panel,
.flow-form,
.dashboard-visual-panel,
.dashboard-secondary-details,
.construction-log-calendar,
.construction-log-form,
.flow-approval-workbench {
  border-color: var(--ui-line);
  border-radius: var(--ui-radius);
  background: var(--ui-surface);
  background-image: none;
  box-shadow: var(--ui-shadow);
  backdrop-filter: none;
}

.dashboard-executive {
  border-color: var(--ui-navy-950);
  background: var(--ui-navy-950);
  background-image: none;
  box-shadow: var(--ui-shadow);
}

.dashboard-executive::before,
.dashboard-executive::after {
  display: none;
}

.boss-kpi-card {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.09);
  background-image: none;
  box-shadow: none;
}

.dashboard-income-lane {
  border-color: var(--ui-cyan-500);
}

.dashboard-cost-lane {
  border-color: var(--ui-gold-500);
}

.tabs,
.finance-subnav,
.contract-subtabs,
.project-subtabs,
.party-subtabs,
.organization-subtabs,
.workspace-tabs {
  border-color: var(--ui-line);
  background: #ffffff;
  box-shadow: var(--ui-shadow);
  backdrop-filter: none;
}

.tab-button.is-active,
.finance-subnav button.is-active,
.contract-subtabs button.is-active,
.project-subtabs button.is-active,
.party-subtabs button.is-active,
.organization-subtabs button.is-active,
.workspace-tab.is-active {
  color: #ffffff;
  border-color: var(--ui-navy-950);
  background: var(--ui-navy-950);
  background-image: none;
  box-shadow: none;
}

.table-action.primary,
.form-actions #submit-flow,
.bottom-actions .primary,
.organization-picker-actions .primary {
  color: #143c3a;
  border-color: #5db5b0;
  background: var(--ui-cyan-500);
  background-image: none;
  box-shadow: none;
  font-weight: 750;
}

.flow-form-progress,
.form-grid,
.construction-log-layout {
  background: var(--ui-surface-soft);
  background-image: none;
}

.flow-form-progress > i b,
.dashboard-stage-fill,
.schedule-progress-bar > i {
  background: var(--ui-cyan-500);
  background-image: none;
}

.form-grid {
  gap: 8px 10px;
  padding: 10px 12px 14px;
}

.form-grid label {
  min-height: 58px;
  padding: 7px 9px;
  border: 1px solid #e1e5e9;
  border-radius: 5px;
  background: #ffffff;
  background-image: none;
  box-shadow: none;
}

.form-grid label:hover {
  border-color: #c8cfd6;
  box-shadow: none;
}

.form-grid label:focus-within {
  border-color: #58aaa6;
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(114, 200, 196, 0.2);
}

.form-grid label > span {
  margin-bottom: 4px;
  color: #4e5969;
  font-size: 11px;
  font-weight: 700;
}

.form-grid input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.form-grid select {
  height: 34px;
  min-height: 34px;
  padding-top: 5px;
  padding-bottom: 5px;
  color: var(--ui-ink);
}

.form-grid textarea {
  min-height: 72px;
  padding: 7px 9px;
  color: var(--ui-ink);
  line-height: 1.55;
}

.form-section-label {
  min-height: 32px;
  color: #24405d;
  border: 1px solid #dbe4e9;
  border-radius: 3px;
  background: #edf5f5;
  background-image: none;
}

.form-actions {
  border-color: var(--ui-line);
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(29, 33, 41, 0.1);
  backdrop-filter: none;
}

.data-table th {
  color: #3c4653;
  background: #f1f3f5;
}

.data-table td {
  color: var(--ui-ink);
}

.construction-calendar-grid button.is-selected {
  color: #143c3a;
  border-color: #5db5b0;
  background: var(--ui-cyan-500);
  background-image: none;
  box-shadow: none;
}

body {
  color: var(--ui-ink);
  background: var(--ui-page);
  background-image: none;
}

.erp-sidebar {
  overflow-y: auto;
  border-right: 0;
  background: var(--ui-navy-950);
  background-image: none;
  box-shadow: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.24) transparent;
}

.brand {
  border-bottom-color: rgba(255, 255, 255, 0.16);
}

.brand img {
  filter: none;
}

.module-nav-title {
  color: rgba(255, 255, 255, 0.58);
}

.module-nav button {
  color: rgba(255, 255, 255, 0.82);
  border-radius: 5px;
}

.module-nav button:hover,
.module-nav button.is-active {
  color: #ffffff;
  border-color: rgba(114, 200, 196, 0.54);
  background: rgba(114, 200, 196, 0.18);
  background-image: none;
  box-shadow: inset 3px 0 0 var(--ui-cyan-500);
}

.topbar,
.panel,
.flow-form,
.dashboard-visual-panel,
.dashboard-secondary-details,
.construction-log-calendar,
.construction-log-form,
.flow-approval-workbench {
  border-color: var(--ui-line);
  border-radius: var(--ui-radius);
  background: var(--ui-surface);
  background-image: none;
  box-shadow: var(--ui-shadow);
  backdrop-filter: none;
}

.panel-title strong,
.form-head strong,
.dashboard-panel-head strong,
.data-table td,
.data-table strong {
  color: var(--ui-ink);
}

.panel-title span,
.form-head span,
.dashboard-panel-head span,
.data-table small,
.empty-state {
  color: var(--ui-muted);
}

.tabs,
.finance-subnav,
.contract-subtabs,
.project-subtabs,
.party-subtabs,
.organization-subtabs,
.workspace-tabs {
  border-color: var(--ui-line);
  background: #ffffff;
  box-shadow: var(--ui-shadow);
  backdrop-filter: none;
}

.tab-button.is-active,
.finance-subnav button.is-active,
.contract-subtabs button.is-active,
.project-subtabs button.is-active,
.party-subtabs button.is-active,
.organization-subtabs button.is-active,
.workspace-tab.is-active {
  color: #ffffff;
  border-color: var(--ui-navy-950);
  background: var(--ui-navy-950);
  background-image: none;
}

.table-action.primary,
.form-actions #submit-flow,
.bottom-actions .primary,
.organization-picker-actions .primary {
  color: #143c3a;
  border-color: #5db5b0;
  background: var(--ui-cyan-500);
  background-image: none;
  box-shadow: none;
  font-weight: 750;
}

.table-action.primary:hover,
.form-actions #submit-flow:hover,
.bottom-actions .primary:hover,
.organization-picker-actions .primary:hover {
  color: #0d3230;
  border-color: #4ca5a0;
  background: #63bbb7;
}

.table-action,
.form-actions button,
.bottom-actions button {
  min-height: 32px;
  border-radius: 5px;
}

.dashboard-executive {
  border-color: #0f3476;
  background: var(--ui-navy-950);
  background-image: none;
  box-shadow: var(--ui-shadow);
}

.dashboard-executive::before,
.dashboard-executive::after {
  display: none;
}

.boss-kpi-card {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.09);
  background-image: none;
  box-shadow: none;
}

.dashboard-income-lane {
  border-color: var(--ui-cyan-500);
}

.dashboard-cost-lane {
  border-color: var(--ui-gold-500);
}

.dashboard-stage-node,
.dashboard-cost-result,
.dashboard-invoice-row,
.pulse-row,
.visual-card,
.metric-card {
  border-radius: 6px;
  box-shadow: none;
}

.dashboard-stage-node.is-terminal,
.dashboard-income-lane .dashboard-stage-node {
  border-color: var(--ui-cyan-500);
}

.dashboard-cost-lane .dashboard-stage-node,
.dashboard-cost-result {
  border-color: var(--ui-gold-500);
}

.flow-form-progress,
.form-grid,
.construction-log-layout {
  background: var(--ui-surface-soft);
  background-image: none;
}

.flow-form-progress > i b,
.dashboard-stage-fill,
.schedule-progress-bar > i {
  background: var(--ui-cyan-500);
  background-image: none;
}

.form-grid {
  gap: 8px 10px;
  padding: 10px 12px 14px;
}

.form-grid label {
  min-height: 58px;
  padding: 7px 9px;
  border: 1px solid #e1e5e9;
  border-radius: 5px;
  background: #ffffff;
  box-shadow: none;
}

.form-grid label:hover {
  border-color: #c8cfd6;
  box-shadow: none;
}

.form-grid label:focus-within {
  border-color: #58aaa6;
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(114, 200, 196, 0.2);
}

.form-grid label > span {
  margin-bottom: 4px;
  color: #4e5969;
  font-size: 11px;
  font-weight: 700;
}

.form-grid input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.form-grid select {
  height: 34px;
  min-height: 34px;
  padding-top: 5px;
  padding-bottom: 5px;
  color: var(--ui-ink);
}

.form-grid textarea {
  min-height: 72px;
  padding: 7px 9px;
  color: var(--ui-ink);
  line-height: 1.55;
}

.form-grid .contract-lines,
.form-grid label:has(textarea),
.form-grid label:has(input[type="file"]) {
  min-height: auto;
}

.form-section-label {
  min-height: 32px;
  color: #24405d;
  border: 1px solid #dbe4e9;
  border-radius: 3px;
  background: #edf5f5;
  background-image: none;
}

.form-actions {
  border-color: var(--ui-line);
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(29, 33, 41, 0.1);
  backdrop-filter: none;
}

.data-table th {
  color: #3c4653;
  background: #f1f3f5;
}

.data-table td {
  color: var(--ui-ink);
}

.data-table tbody tr:hover td {
  background: #f6f9f9;
}

.risk-note,
.field-invalid,
.form-grid label.field-invalid {
  border-color: #ef9a96 !important;
  background: #fff4f3 !important;
  box-shadow: none !important;
}

.status-pill.is-danger,
.status-pill[data-status="已驳回"] {
  color: #b42318;
  background: #ffebe9;
}

.construction-calendar-grid button.is-selected {
  color: #143c3a;
  border-color: #5db5b0;
  background: var(--ui-cyan-500);
  background-image: none;
  box-shadow: none;
}

.construction-log-summary-month {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ui-muted);
  font-size: 12px;
  font-weight: 700;
}

.construction-log-summary-month input {
  width: 142px;
  height: 34px;
  padding: 0 9px;
  border: 1px solid #cfd5dc;
  border-radius: 5px;
  color: var(--ui-ink);
  background: #ffffff;
}

.construction-log-summary-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--ui-line-soft);
  background: #f6f8fa;
}

.construction-log-summary-metrics .metric-card {
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--ui-line);
  background: #ffffff;
}

.construction-log-summary-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 750;
}

.construction-log-summary-status.is-complete {
  color: #236b58;
  background: #e8f6f2;
}

.construction-log-summary-status.is-missing {
  color: #b42318;
  background: #ffebe9;
}

.construction-log-summary-status.is-upcoming {
  color: #646d78;
  background: #eef1f3;
}

.construction-log-summary-pending {
  color: var(--ui-muted);
  font-size: 11px;
}

.org-department-list {
  display: grid;
  gap: 7px;
  padding: 12px 14px 4px;
}

.org-department-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 0.8fr) 72px auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--ui-line);
  border-radius: 5px;
  background: #ffffff;
}

.org-department-row input,
.org-department-row select,
.org-department-actions input,
.org-directory-table input,
.org-directory-table select {
  width: 100%;
  height: 34px;
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid #cfd5dc;
  border-radius: 5px;
  color: var(--ui-ink);
  background: #ffffff;
}

.org-department-row > span {
  color: var(--ui-muted);
  font-size: 12px;
  text-align: center;
}

.org-department-actions {
  padding: 10px 14px 14px;
}

.org-directory-table {
  min-width: 980px;
}

.org-project-checks {
  min-width: 220px;
  display: grid;
  gap: 4px;
}

.org-project-checks label {
  min-width: 0;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: start;
  gap: 6px;
  color: #4e5969;
  font-size: 11px;
  line-height: 1.4;
}

.org-project-checks input {
  width: 14px;
  height: 14px;
  margin: 1px 0 0;
  accent-color: var(--ui-cyan-500);
}

.org-project-checks span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.organization-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 520;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 30, 53, 0.42);
}

.organization-picker {
  width: min(900px, calc(100vw - 48px));
  max-height: min(720px, calc(100dvh - 48px));
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border: 1px solid #d7dce2;
  border-radius: 7px;
  color: var(--ui-ink);
  background: #ffffff;
  box-shadow: 0 14px 40px rgba(15, 30, 53, 0.18);
}

.organization-picker-head,
.organization-picker-actions {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: #ffffff;
}

.organization-picker-head {
  border-bottom: 1px solid var(--ui-line);
}

.organization-picker-head span,
.organization-picker-head strong {
  display: block;
}

.organization-picker-head span {
  margin-bottom: 2px;
  color: var(--ui-muted);
  font-size: 11px;
}

.organization-picker-head strong {
  font-size: 16px;
}

.organization-picker-head > button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--ui-line);
  border-radius: 5px;
  color: #4e5969;
  background: #ffffff;
  font-size: 20px;
}

.organization-picker-body {
  min-height: 430px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
}

.organization-picker-tree {
  overflow-y: auto;
  padding: 10px;
  border-right: 1px solid var(--ui-line);
  background: #f6f8fa;
}

.organization-picker-tree button {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
  padding: 6px 8px 6px calc(10px + var(--department-depth, 0) * 14px);
  border: 1px solid transparent;
  border-radius: 5px;
  color: #3c4653;
  background: transparent;
  text-align: left;
}

.organization-picker-tree button:hover,
.organization-picker-tree button.is-active {
  color: #143c3a;
  border-color: #9cd7d4;
  background: #e9f6f5;
}

.organization-picker-tree small {
  color: var(--ui-muted);
  font-size: 10px;
}

.organization-picker-content {
  min-width: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 12px;
}

.organization-picker-search {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: #4e5969;
  font-size: 12px;
  font-weight: 700;
}

.organization-picker-search input {
  width: 100%;
  height: 34px;
  padding: 5px 9px;
  border: 1px solid #cfd5dc;
  border-radius: 5px;
  color: var(--ui-ink);
  background: #ffffff;
}

.organization-picker-search input:focus,
.org-department-row input:focus,
.org-department-row select:focus,
.org-directory-table input:focus,
.org-directory-table select:focus {
  border-color: #58aaa6;
  outline: 2px solid rgba(114, 200, 196, 0.2);
}

.organization-picker-list {
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 8px;
}

.organization-picker-employee {
  min-width: 0;
  display: grid;
  grid-template-columns: 18px 36px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 8px;
  border: 1px solid var(--ui-line);
  border-radius: 5px;
  background: #ffffff;
  cursor: pointer;
}

.organization-picker-employee:hover,
.organization-picker-employee:has(input:checked) {
  border-color: #8ccfcb;
  background: #f0f8f7;
}

.organization-picker-employee input {
  width: 15px;
  height: 15px;
  accent-color: var(--ui-cyan-500);
}

.organization-picker-avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: var(--ui-navy-950);
  font-size: 13px;
  font-weight: 750;
}

.organization-picker-employee strong,
.organization-picker-employee small {
  display: block;
}

.organization-picker-employee strong {
  margin-bottom: 3px;
  font-size: 13px;
}

.organization-picker-employee small {
  overflow: hidden;
  color: var(--ui-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.organization-picker-empty {
  grid-column: 1 / -1;
  padding: 48px 16px;
  color: var(--ui-muted);
  text-align: center;
}

.organization-picker-actions {
  border-top: 1px solid var(--ui-line);
}

.organization-picker-actions > span {
  color: var(--ui-muted);
  font-size: 12px;
}

.organization-picker-actions > span strong {
  color: var(--ui-ink);
}

.organization-picker-actions > div {
  display: flex;
  gap: 8px;
}

@media (max-width: 900px) {
  .construction-log-summary-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .org-department-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 64px auto;
  }
}

@media (max-width: 760px) {
  .form-grid label {
    min-height: 56px;
  }

  .construction-log-summary-panel .panel-title {
    align-items: stretch;
  }

  .construction-log-summary-month {
    width: 100%;
    justify-content: space-between;
  }

  .construction-log-summary-month input {
    flex: 0 0 142px;
  }

  .org-department-row {
    grid-template-columns: 1fr;
  }

  .org-department-row > span {
    text-align: left;
  }

  .organization-picker-backdrop {
    padding: 0;
  }

  .organization-picker {
    width: 100%;
    max-height: 100dvh;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .organization-picker-body {
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .organization-picker-tree {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    padding: 8px;
    border-right: 0;
    border-bottom: 1px solid var(--ui-line);
  }

  .organization-picker-tree button {
    width: auto;
    flex: 0 0 auto;
    margin: 0;
    padding: 6px 10px;
  }

  .organization-picker-list {
    grid-template-columns: 1fr;
  }

  .organization-picker-actions {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
}

/* Dashboard operating loop v4: construction income, cost and cash in one truthful flow. */
.dashboard-primary-grid {
  grid-template-columns: minmax(0, 1.72fr) minmax(280px, 0.62fr);
  grid-template-rows: auto;
  gap: 12px;
  align-items: stretch;
}

.dashboard-primary-grid > .dashboard-visual-panel,
.dashboard-primary-grid .dashboard-visual-panel {
  min-height: 0;
}

.dashboard-operating-loop,
.dashboard-side-stack {
  min-width: 0;
}

.dashboard-side-stack {
  display: grid;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.dashboard-operating-loop {
  border-color: #c8dce8;
  background: #ffffff;
}

.dashboard-operating-loop .dashboard-panel-head {
  background: linear-gradient(90deg, rgba(32, 189, 183, 0.1), rgba(22, 119, 184, 0.025) 56%, transparent);
}

.dashboard-operating-body {
  display: grid;
  padding: 0 18px;
}

.dashboard-flow-lane {
  min-width: 0;
  padding: 17px 0 20px;
}

.dashboard-flow-lane + .dashboard-flow-lane {
  border-top: 1px solid #e1ebf1;
}

.dashboard-lane-head {
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.dashboard-lane-head strong {
  color: #173d59;
  font-size: 13px;
}

.dashboard-lane-head span {
  color: #627b8e;
  font-size: 11px;
  text-align: right;
}

.dashboard-stage-track {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 22px;
}

.dashboard-stage-node {
  position: relative;
  min-width: 0;
  min-height: 112px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  padding: 13px;
  border: 1px solid #d7e4ec;
  border-radius: 7px;
  color: #17384f;
  background: #f8fbfd;
  box-shadow: inset 0 3px 0 #20bdb7;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.dashboard-stage-node:hover,
.dashboard-stage-node:focus-visible {
  border-color: #76b8cb;
  background: #f0f8fa;
  transform: translateY(-1px);
}

.dashboard-stage-track .dashboard-stage-node:not(.is-terminal)::after {
  content: "";
  position: absolute;
  z-index: 2;
  top: calc(50% - 6px);
  right: -17px;
  width: 10px;
  height: 10px;
  border-top: 2px solid #7da5b7;
  border-right: 2px solid #7da5b7;
  transform: rotate(45deg);
}

.dashboard-stage-node span,
.dashboard-stage-node strong,
.dashboard-stage-node small {
  min-width: 0;
  display: block;
}

.dashboard-stage-node span {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #4c687c;
  font-size: 12px;
  font-weight: 700;
}

.dashboard-stage-node span b {
  min-width: 23px;
  padding: 3px 4px;
  border-radius: 4px;
  color: #0c797b;
  background: #dff5f2;
  font-size: 10px;
  text-align: center;
}

.dashboard-stage-node strong {
  min-height: 42px;
  color: #0e3150;
  font-size: 17px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.dashboard-stage-node small {
  color: #60798c;
  font-size: 10px;
}

.dashboard-cost-flow {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(155px, 0.72fr) minmax(86px, 0.34fr) minmax(0, 1.5fr);
  gap: 14px;
  align-items: center;
}

.dashboard-cost-origin {
  box-shadow: inset 0 3px 0 #c99332;
}

.dashboard-cost-origin span b {
  color: #835d17;
  background: #f8ecd4;
}

.dashboard-cost-connector {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 7px;
  color: #6a7f8f;
  font-size: 10px;
  text-align: center;
}

.dashboard-cost-connector i {
  position: relative;
  width: 100%;
  height: 1px;
  background: #9db5c2;
}

.dashboard-cost-connector i::after {
  content: "";
  position: absolute;
  top: -4px;
  right: 0;
  width: 7px;
  height: 7px;
  border-top: 1px solid #7f9bab;
  border-right: 1px solid #7f9bab;
  transform: rotate(45deg);
}

.dashboard-cost-allocation {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.dashboard-cost-bar {
  height: 9px;
  overflow: hidden;
  border-radius: 3px;
  background: linear-gradient(90deg, #c99332 0 var(--paid), #dfe8ed var(--paid) 100%);
}

.dashboard-cost-result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.dashboard-cost-result {
  min-width: 0;
  min-height: 78px;
  display: grid;
  gap: 4px;
  padding: 10px 11px;
  border: 1px solid #d9e5ec;
  border-radius: 6px;
  color: #18384e;
  background: #fbfdfe;
  text-align: left;
  cursor: pointer;
}

.dashboard-cost-result.paid {
  border-color: #c99332;
}

.dashboard-cost-result:hover,
.dashboard-cost-result:focus-visible {
  border-color: #8fb4c5;
  background: #f4f9fb;
}

.dashboard-cost-result span,
.dashboard-cost-result small {
  color: #62798a;
  font-size: 10px;
}

.dashboard-cost-result strong {
  color: #173a53;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.dashboard-exposure-panel,
.dashboard-invoice-panel {
  min-width: 0;
  background: #ffffff;
}

.dashboard-exposure-grid,
.dashboard-invoice-progress {
  display: grid;
  gap: 8px;
  padding: 11px;
}

.dashboard-exposure-item,
.dashboard-invoice-row {
  min-width: 0;
  border: 1px solid #dce7ed;
  border-radius: 6px;
  color: #19394e;
  background: #f8fbfd;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.dashboard-exposure-item {
  min-height: 60px;
  display: grid;
  grid-template-columns: minmax(62px, 0.58fr) minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  gap: 2px 8px;
  padding: 8px 10px;
}

.dashboard-exposure-item.warning {
  border-color: #c99332;
}

.dashboard-exposure-item.positive,
.dashboard-exposure-item.clear {
  border-color: #198d72;
}

.dashboard-exposure-item.risk {
  border-color: #c7473f;
  background: #fff7f6;
}

.dashboard-exposure-item:hover,
.dashboard-exposure-item:focus-visible,
.dashboard-invoice-row:hover,
.dashboard-invoice-row:focus-visible {
  border-color: #8eb6c8;
  background: #f0f7fa;
}

.dashboard-exposure-item span,
.dashboard-exposure-item small {
  color: #60798b;
  font-size: 10px;
}

.dashboard-exposure-item strong {
  min-width: 0;
  color: #153951;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.dashboard-exposure-item small {
  grid-column: 2;
}

.dashboard-invoice-row {
  min-height: 91px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 8px;
  padding: 10px;
}

.dashboard-invoice-row span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #516e82;
  font-size: 11px;
}

.dashboard-invoice-row span b {
  color: #1677b8;
  font-size: 11px;
}

.dashboard-invoice-row strong {
  color: #153951;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.dashboard-invoice-row i {
  grid-column: 1 / -1;
  height: 7px;
  border-radius: 3px;
  background: linear-gradient(90deg, #20bdb7 0 var(--progress), #e1e9ee var(--progress) 100%);
}

.dashboard-invoice-row small {
  grid-column: 1 / -1;
  color: #6a8191;
  font-size: 10px;
}

@media (max-width: 1180px) {
  .dashboard-primary-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-side-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto;
  }
}

@media (max-width: 760px) {
  .dashboard-operating-body {
    padding: 0 12px;
  }

  .dashboard-lane-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .dashboard-lane-head span {
    text-align: left;
  }

  .dashboard-stage-track {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .dashboard-stage-track .dashboard-stage-node:not(.is-terminal)::after {
    top: auto;
    right: auto;
    bottom: -13px;
    left: calc(50% - 5px);
    transform: rotate(135deg);
  }

  .dashboard-stage-node {
    min-height: 90px;
  }

  .dashboard-cost-flow {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .dashboard-cost-connector {
    min-height: 32px;
  }

  .dashboard-cost-connector i {
    width: 1px;
    height: 18px;
  }

  .dashboard-cost-connector i::after {
    top: auto;
    right: -3px;
    bottom: 0;
    transform: rotate(135deg);
  }

  .dashboard-side-stack {
    grid-template-columns: 1fr;
  }

  .dashboard-exposure-grid {
    grid-template-columns: 1fr;
  }
}

/* Approval system tree and final density corrections. */
.approval-tree-layout {
  display: grid;
  grid-template-columns: minmax(210px, 0.3fr) minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  border-top: 1px solid var(--ui-line-soft);
  background: #f5f9fc;
}

.approval-tree-flows {
  min-width: 0;
  align-self: start;
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  background: #fff;
}

.approval-tree-flows > span {
  padding: 2px 4px 7px;
  border-bottom: 1px solid var(--ui-line-soft);
  color: #173b5a;
  font-size: 13px;
  font-weight: 800;
}

.approval-tree-group {
  display: grid;
  gap: 4px;
}

.approval-tree-group > span {
  padding: 4px 7px;
  color: #6a8092;
  font-size: 10px;
  font-weight: 800;
}

.approval-tree-group button {
  min-width: 0;
  min-height: 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #365872;
  background: #f6f9fb;
  text-align: left;
}

.approval-tree-group button strong {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.approval-tree-group button small {
  color: #7890a2;
  font-size: 10px;
  white-space: nowrap;
}

.approval-tree-group button.is-active {
  color: #fff;
  border-color: #176da7;
  background: linear-gradient(110deg, #176da7, #138e9b);
  box-shadow: 0 8px 18px rgba(23, 109, 167, 0.18);
}

.approval-tree-group button.is-active small {
  color: rgba(255, 255, 255, 0.78);
}

.approval-tree-editor {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  background: #fff;
}

.approval-tree-head {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--ui-line-soft);
  background: #f8fbfd;
}

.approval-tree-head > div {
  display: grid;
  gap: 2px;
}

.approval-tree-head span {
  color: #758b9c;
  font-size: 10px;
}

.approval-tree-head strong {
  color: #173b5a;
  font-size: 14px;
}

.approval-tree-nodes {
  min-height: 190px;
  display: grid;
  align-content: start;
  gap: 20px;
  padding: 18px;
}

.approval-tree-node {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid #d8e5ed;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(17, 59, 106, 0.05);
}

.approval-tree-step {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, #176da7, #20bdb7);
  font-size: 12px;
  font-weight: 800;
}

.approval-tree-node-fields {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(160px, 0.55fr) minmax(220px, 1fr);
  gap: 10px;
}

.approval-tree-node-fields label {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.approval-tree-node-fields label > span {
  color: #60798d;
  font-size: 10px;
  font-weight: 700;
}

.approval-tree-node-fields input,
.approval-tree-node-fields select {
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--ui-line);
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--ui-ink);
  background: #fff;
}

.approval-tree-node-actions {
  display: flex;
  gap: 4px;
}

.approval-tree-node-actions button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--ui-line);
  border-radius: 6px;
  color: #46647b;
  background: #f7fafc;
}

.approval-tree-connector {
  position: absolute;
  left: 38px;
  bottom: -21px;
  width: 2px;
  height: 20px;
  background: linear-gradient(#20bdb7, #9cd9d4);
}

.approval-tree-empty {
  min-height: 154px;
  display: grid;
  place-content: center;
  gap: 7px;
  padding: 20px;
  color: #6b8193;
  text-align: center;
}

.approval-tree-empty strong {
  color: #284c68;
  font-size: 14px;
}

.approval-tree-note {
  margin: 0;
  padding: 10px 14px;
  border-top: 1px solid var(--ui-line-soft);
  color: #60798d;
  background: #f8fbfd;
  font-size: 11px;
  line-height: 1.7;
}

.flow-status-cluster {
  overflow: hidden;
}

.flow-status-cluster > span {
  padding-inline: 6px;
}

.flow-status-cluster .approval-link {
  border-radius: 6px;
}

@media (max-width: 980px) {
  .approval-tree-layout {
    grid-template-columns: 1fr;
  }

  .approval-tree-flows {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .approval-tree-flows > span {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .login-gate-ding-qr {
    width: min(304px, 100%);
  }

  .approval-tree-layout {
    padding: 8px;
  }

  .approval-tree-flows {
    grid-template-columns: 1fr;
  }

  .approval-tree-node {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .approval-tree-node-fields {
    grid-template-columns: 1fr;
  }

  .approval-tree-node-actions {
    grid-column: 2;
  }
}

@media (max-width: 760px) {
  body {
    background: #f1f6f9;
  }

  .supplier-template-page {
    width: calc(100vw - 16px);
    margin: 8px auto;
  }

  .supplier-template-head {
    padding: 18px 16px;
  }

  .supplier-template-head strong {
    font-size: 22px;
  }

  .supplier-template-form {
    padding: 10px;
  }

  .template-readonly-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .readonly-template-field {
    min-height: 86px;
    padding: 9px;
  }

  .template-image-upload-grid {
    grid-template-columns: 1fr;
  }

  .supplier-template-form .form-actions {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
    padding: 10px 0 0;
  }

  .erp-sidebar {
    min-height: 58px;
    padding: 6px 10px;
  }

  .brand {
    min-height: 46px;
    padding: 0;
    border-bottom: 0;
  }

  .brand img {
    width: 44px;
    height: 40px;
  }

  .module-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
  }

  .erp-main {
    padding: 9px 9px calc(84px + env(safe-area-inset-bottom));
  }

  .topbar.is-compact {
    gap: 6px;
    padding: 6px;
  }

  .global-search input {
    min-height: 38px;
    padding-left: 11px;
    font-size: 14px;
  }

  .topbar-actions .cloud-sync-status {
    width: 28px;
    min-width: 28px;
    padding: 0;
    justify-content: center;
    overflow: hidden;
    color: transparent !important;
    font-size: 0;
  }

  .flow-status-items {
    gap: 4px !important;
    padding-bottom: 1px;
  }

  .flow-status-cluster {
    padding: 2px;
  }

  .flow-status-cluster .approval-link {
    min-width: 54px;
  }

  .tabs,
  .finance-subnav,
  .contract-subtabs,
  .project-subtabs,
  .party-subtabs,
  .organization-subtabs {
    position: static;
    width: 100%;
    overflow-x: auto;
  }

  .dashboard-executive {
    padding: 12px;
  }

  .dashboard-command {
    min-height: 78px;
  }

  .dashboard-command-main strong {
    font-size: 22px;
  }

  .boss-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .boss-kpi-card {
    min-height: 94px;
    padding: 10px;
  }

  .boss-kpi-card:last-child {
    grid-column: 1 / -1;
  }

  .boss-kpi-card strong {
    font-size: 20px;
  }

  .dashboard-primary-grid {
    gap: 9px;
  }

  .dashboard-secondary-details > summary {
    min-height: 40px;
  }

  .flow-form-progress {
    position: sticky;
    top: 0;
    z-index: 22;
    grid-template-columns: auto minmax(90px, 1fr);
    gap: 7px;
    padding: 8px 10px;
  }

  #flow-section-nav {
    width: 100%;
  }

  .form-grid {
    grid-template-columns: 1fr !important;
    padding: 10px;
  }

  .form-grid > * {
    grid-column: 1 / -1 !important;
  }

  .form-grid label {
    min-height: 68px;
  }

  .form-actions {
    bottom: calc(66px + env(safe-area-inset-bottom));
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 8px 10px 10px;
  }

  .data-table tbody td::before {
    content: attr(data-label);
    flex: 0 0 96px;
    color: #5d7488;
    font-size: 12px;
    font-weight: 700;
  }

  .data-table tbody td.table-empty-cell::before {
    display: none;
  }

  .table-column-menu > div {
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
    bottom: calc(76px + env(safe-area-inset-bottom));
    width: auto;
    max-height: 58vh;
  }

  .system-notice-backdrop {
    align-items: end;
    padding: 10px 10px calc(76px + env(safe-area-inset-bottom));
  }

  .system-notice {
    grid-template-columns: 36px minmax(0, 1fr);
    padding: 16px;
    border-radius: 8px;
  }
}

.attachment-file-link {
  color: #155fb8;
  font-weight: 650;
  text-decoration: none;
}

.attachment-file-link:hover {
  color: #0b8f83;
  text-decoration: underline;
}

.finance-ledger-switch {
  width: fit-content;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(17, 59, 106, 0.06);
}

.finance-ledger-switch button {
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  color: #46647b;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.finance-ledger-switch button.is-active {
  color: #fff;
  background: var(--ui-blue-600);
}

@media (max-width: 760px) {
  .finance-ledger-switch {
    width: 100%;
    overflow-x: auto;
  }

  .finance-ledger-switch button {
    flex: 0 0 auto;
  }
}

/* Launch-ready visual refinement */
body {
  background:
    linear-gradient(rgba(30, 91, 137, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(30, 91, 137, 0.025) 1px, transparent 1px),
    linear-gradient(180deg, #edf4f8 0, #f7f9fb 190px, #f3f6f8 100%);
  background-size: 28px 28px, 28px 28px, auto;
}

.login-gate-auto {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(32, 189, 183, 0.24);
  border-radius: 8px;
  background: rgba(232, 250, 248, 0.72);
}

.login-gate-auto > i {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: #20bdb7;
  box-shadow: 0 0 0 5px rgba(32, 189, 183, 0.12);
}

.login-gate-auto > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.login-gate-auto strong {
  color: #164b61;
  font-size: 13px;
}

.login-gate-auto span {
  color: #587285;
  font-size: 11px;
}

.login-gate-quote {
  max-width: 780px;
  position: relative;
  color: rgba(232, 244, 252, 0.88);
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  font-size: 15px;
  line-height: 2;
  letter-spacing: 0;
  text-wrap: balance;
}

.login-gate-quote::before,
.login-gate-quote::after {
  position: absolute;
  color: rgba(71, 220, 207, 0.66);
  font-size: 32px;
  line-height: 1;
}

.login-gate-quote::before {
  content: "“";
  left: -26px;
  top: -5px;
}

.login-gate-quote::after {
  content: "”";
  right: -24px;
  bottom: -13px;
}

.topbar.is-compact {
  grid-template-columns: minmax(620px, 1fr) minmax(250px, 340px) auto;
}

.flow-status-strip {
  padding: 3px 4px;
}

.flow-status-items {
  grid-template-columns: minmax(180px, 0.82fr) minmax(260px, 1.14fr) minmax(270px, 1.2fr) !important;
}

.flow-status-cluster {
  min-height: 34px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(54px, 1fr);
  align-items: center;
  gap: 3px;
  padding: 2px 3px;
}

.flow-status-cluster > span {
  min-width: 52px;
  text-align: center;
}

.flow-status-cluster .approval-link {
  min-width: 54px;
  display: flex;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
}

.flow-status-cluster .approval-link small {
  overflow: visible;
  text-overflow: clip;
}

.workspace-tabs {
  min-height: 38px;
  padding: 4px 5px;
  border: 1px solid #cfdeea;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 20px rgba(17, 59, 106, 0.05);
}

.workspace-tab {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 8px 0 10px;
  border: 1px solid #d2e0e9;
  border-radius: 6px;
  color: #405e74;
  background: #f6f9fb;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  box-shadow: none;
}

.workspace-tab:hover {
  color: #176da7;
  border-color: #9fc5dc;
  background: #fff;
}

.workspace-tab i {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #7890a2;
  font-size: 14px;
  font-style: normal;
  line-height: 1;
}

.workspace-tab i:hover {
  color: #a53630;
  background: #fff0ef;
}

.workspace-tab.is-active {
  color: #fff;
  border-color: #176da7;
  background: #176da7;
}

.workspace-tab.is-active i {
  color: rgba(255, 255, 255, 0.82);
}

.workspace-tab.is-active i:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
}

.approval-default-route {
  width: min(100%, 620px);
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 8px;
  margin: 12px 14px 0;
}

.dashboard-executive {
  padding: 10px 12px 12px;
}

.dashboard-command {
  min-height: 56px;
  padding: 0 0 9px;
}

.dashboard-command-main {
  gap: 2px;
}

.dashboard-command-main strong {
  font-size: 21px;
  line-height: 1.25;
}

.dashboard-command-main small {
  font-size: 11px;
}

.boss-kpi-grid {
  gap: 8px;
  padding: 9px 0 0;
}

.boss-kpi-card {
  min-height: 76px;
  padding: 10px 12px;
}

.boss-kpi-card strong {
  font-size: 19px;
}

.boss-kpi-card small {
  font-size: 10px;
}

.dashboard-primary-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(390px, 0.9fr);
  grid-template-rows: repeat(2, minmax(248px, auto));
  gap: 14px;
}

.dashboard-primary-grid > .dashboard-visual-panel {
  min-height: 0;
}

.dashboard-matrix-panel {
  grid-row: 1 / span 2;
}

.dashboard-matrix-body {
  min-height: 476px;
  grid-template-columns: minmax(280px, 0.92fr) minmax(250px, 1.08fr);
  align-content: center;
  gap: 22px;
  padding: 22px;
}

.dashboard-radar {
  width: min(100%, 330px);
  min-height: 330px;
  margin: auto;
}

.dashboard-radar svg {
  width: 100%;
  height: 100%;
}

.matrix-score-stack {
  gap: 10px;
}

.matrix-score {
  min-height: 68px;
  padding: 11px 13px;
}

.dashboard-pulse-panel .pulse-stack {
  min-height: 195px;
  display: grid;
  align-content: center;
  gap: 10px;
  padding: 16px;
}

.pulse-row {
  min-height: 31px;
}

.dashboard-invoice-panel .invoice-rings {
  min-height: 194px;
  padding: 16px 22px;
}

.mini-gauge {
  min-height: 164px;
}

.form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 10px;
  padding: 12px 14px 16px;
}

.form-grid label {
  min-height: 0;
  padding: 8px 9px;
  gap: 5px;
}

.form-grid label > span {
  font-size: 11px;
  line-height: 1.3;
}

.form-grid input,
.form-grid select {
  min-height: 34px;
  padding-top: 6px;
  padding-bottom: 6px;
}

.form-grid textarea {
  min-height: 74px;
}

.form-section-label {
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid #dbe4e9;
  background: #edf5f5;
}

.template-editor-panel {
  width: min(1480px, calc(100vw - 28px));
  height: min(94vh, 940px);
  max-height: 94vh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.template-editor-fixed-head,
.template-editor-fixed-actions {
  position: relative;
  z-index: 8;
  flex: 0 0 auto;
}

.template-editor-close {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
}

.template-document-layout {
  height: auto;
  min-height: 0;
  overflow: hidden;
}

.template-document-viewer,
.template-required-sidebar {
  min-height: 0;
  overflow: hidden;
}

.template-document-viewer {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.template-document-viewer iframe {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.template-required-sidebar {
  display: grid;
  grid-template-rows: auto minmax(110px, 0.34fr) minmax(0, 1fr);
}

.template-required-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.template-editor-fields {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.template-editor-grid {
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-top: 12px;
}

.template-editor-fixed-actions {
  min-height: 54px;
}

@media (max-width: 1300px) {
  .topbar.is-compact {
    grid-template-columns: minmax(0, 1fr) minmax(240px, 330px) auto;
  }

  .flow-status-title,
  .flow-status-cluster > span {
    display: none !important;
  }

  .flow-status-items {
    display: flex !important;
    overflow-x: auto;
  }

  .flow-status-cluster {
    flex: 0 0 auto;
  }

  .dashboard-primary-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .dashboard-matrix-panel {
    grid-row: auto;
  }
}

@media (max-width: 980px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-matrix-body {
    min-height: 420px;
  }
}

@media (max-width: 760px) {
  body {
    background: #f2f6f8;
  }

  .login-gate-quote::before,
  .login-gate-quote::after {
    display: none;
  }

  .workspace-tabs {
    overflow-x: auto;
    padding: 4px;
  }

  .dashboard-executive {
    padding: 10px;
  }

  .boss-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .boss-kpi-card {
    min-height: 74px;
  }

  .dashboard-matrix-body {
    min-height: 0;
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .dashboard-radar {
    width: min(100%, 280px);
    min-height: 280px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .template-editor-panel {
    width: calc(100vw - 12px);
    height: calc(100dvh - 12px);
    max-height: calc(100dvh - 12px);
  }

  .template-document-layout {
    overflow-y: auto;
  }

  .template-document-viewer,
  .template-document-viewer iframe {
    min-height: 52vh;
    height: 52vh;
  }

  .template-required-sidebar {
    min-height: 56vh;
    max-height: none;
  }

  .template-editor-fixed-actions {
    position: sticky;
    bottom: 0;
  }
}

/* Responsive workspace correction: preserve readable workflow groups without horizontal page clipping. */
body {
  background: #eef2f5;
}

.topbar.is-compact {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "approval actions"
    "search search";
}

.approval-overview {
  grid-area: approval;
}

.global-search {
  grid-area: search;
  width: min(100%, 560px);
  justify-self: end;
}

.topbar-actions {
  grid-area: actions;
}

.flow-status-items {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

@media (min-width: 981px) {
  .flow-status-title {
    display: inline-flex !important;
  }

  .flow-status-cluster > span {
    display: block !important;
  }
}

@media (max-width: 980px) {
  .topbar.is-compact {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "search actions"
      "approval approval";
  }

  .global-search {
    width: 100%;
    justify-self: stretch;
  }

  .flow-status-items {
    display: flex !important;
    overflow-x: auto;
  }
}

/* Final release overrides. Keep this block last so older iterative rules cannot win. */
body {
  color: var(--ui-ink);
  background: var(--ui-page);
  background-image: none;
}

.login-gate-dingtalk {
  grid-template-columns: 1fr;
}

.login-gate-quote {
  max-width: 860px;
  padding: 14px 28px;
  border-top: 1px solid rgba(108, 226, 216, 0.28);
  border-bottom: 1px solid rgba(108, 226, 216, 0.16);
  color: rgba(245, 250, 253, 0.94);
  font-family: "STKaiti", "KaiTi", "Songti SC", "STSong", serif;
  font-size: 17px;
  line-height: 2.05;
  text-shadow: 0 3px 16px rgba(3, 25, 58, 0.55);
}

/* Compact topbar alignment */
.topbar.is-compact {
  min-height: 46px;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "search actions"
    "approval approval";
  gap: 5px 7px;
  padding: 5px 7px;
}

.approval-overview {
  grid-area: approval;
}

.global-search {
  grid-area: search;
  width: 100%;
  min-width: 0;
  justify-self: stretch;
}

.topbar-actions {
  grid-area: actions;
}

.global-search input,
.user-name-button {
  height: 34px;
  min-height: 34px;
}

.topbar.is-compact .flow-status-strip {
  min-height: 32px;
  display: block;
  gap: 0;
  padding: 2px 3px;
}

.flow-status-title {
  display: none !important;
}

.flow-status-items {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 3px !important;
}

.flow-status-cluster {
  min-height: 30px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(42px, 1fr);
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 5px;
}

.flow-status-cluster > span {
  display: none !important;
}

.topbar.is-compact .flow-status-cluster .approval-link {
  min-width: 42px;
  min-height: 26px;
  height: 26px;
  gap: 2px;
  padding: 2px 3px;
}

.flow-status-cluster .approval-link small {
  font-size: 10px;
}

.flow-status-cluster .approval-link strong {
  font-size: 11px;
}

@media (min-width: 1181px) {
  .topbar.is-compact {
    grid-template-columns: minmax(540px, 1fr) minmax(180px, 230px) auto;
    grid-template-areas: "approval search actions";
  }
}

@media (max-width: 760px) {
  .flow-status-items {
    display: flex !important;
    gap: 2px !important;
    overflow-x: auto;
  }

  .flow-status-cluster {
    flex: 0 0 auto;
    gap: 1px;
    padding: 0;
  }

  .flow-status-cluster > span {
    display: none;
  }

  .topbar.is-compact .flow-status-cluster .approval-link {
    min-width: 42px;
    gap: 1px;
    padding: 1px 2px;
  }

  .flow-status-cluster .approval-link small {
    font-size: 9px;
  }

  .flow-status-cluster .approval-link strong {
    font-size: 10px;
  }
}

.dashboard-executive {
  gap: 7px;
  padding: 8px 11px 10px;
  border-color: var(--ui-navy-950);
  background: var(--ui-navy-950);
  background-image: none;
  box-shadow: var(--ui-shadow);
}

.dashboard-executive::before {
  display: none;
}

.dashboard-executive::after {
  display: none;
}

.dashboard-command {
  min-height: 42px;
  padding: 0 0 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.dashboard-command-main strong {
  margin: 2px 0 0;
  font-size: 19px;
}

.dashboard-command-main small {
  display: none;
}

.dashboard-project-picker.compact,
.dashboard-filter-trigger {
  width: 46px;
  height: 42px;
}

.dashboard-filter-trigger::before {
  width: 18px;
  height: 18px;
  border-width: 0 5px 5px 0;
  transform: translateY(-4px) rotate(45deg);
}

.boss-kpi-grid {
  gap: 7px;
  padding: 5px 0 0;
}

.boss-kpi-card {
  min-height: 62px;
  padding: 8px 10px;
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.09);
  background-image: none;
  box-shadow: none;
}

.boss-kpi-card strong {
  margin: 5px 0 3px;
  font-size: 18px;
}

.boss-kpi-card small {
  font-size: 10px;
}

.dashboard-primary-grid {
  grid-template-columns: minmax(0, 1.52fr) minmax(390px, 0.82fr);
  grid-template-rows: repeat(2, minmax(268px, auto));
  gap: 14px;
}

.dashboard-matrix-body {
  min-height: 522px;
  grid-template-columns: minmax(320px, 1.08fr) minmax(260px, 0.92fr);
  gap: 28px;
  padding: 26px;
}

.dashboard-radar {
  width: min(100%, 370px);
  min-height: 370px;
  border-color: rgba(114, 200, 196, 0.55);
  background: #f6f8fa;
  box-shadow: none;
}

.radar-value {
  animation: dashboard-radar-pulse 3.2s ease-in-out infinite;
}

.matrix-score {
  min-height: 74px;
  padding: 12px 14px;
}

.dashboard-pulse-panel .pulse-stack,
.dashboard-invoice-panel .invoice-rings {
  min-height: 216px;
}

.pulse-row {
  min-height: 34px;
}

.mini-gauge {
  min-height: 184px;
}

.flow-form {
  overflow: hidden;
}

.flow-form .form-head {
  min-height: 58px;
  padding: 12px 15px;
}

.flow-form-progress {
  padding: 10px 14px;
  background: var(--ui-surface-soft);
  background-image: none;
}

.form-grid {
  gap: 8px 10px;
  padding: 10px 12px 14px;
  background: var(--ui-surface-soft);
  background-image: none;
}

.form-grid label {
  min-height: 58px;
  padding: 7px 9px;
  border: 1px solid #e1e5e9;
  border-radius: 5px;
  background: #ffffff;
  box-shadow: none;
}

.form-grid label:focus-within {
  border-color: #58aaa6;
  box-shadow: 0 0 0 2px rgba(114, 200, 196, 0.2);
}

.form-grid input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.form-grid select {
  height: 34px;
  min-height: 34px;
}

.form-grid textarea {
  min-height: 72px;
}

.form-section-label {
  margin-top: 7px;
  color: #24405d;
  border: 1px solid #dbe4e9;
  background: #edf5f5;
  background-image: none;
}

.template-required-sidebar {
  grid-template-rows: auto minmax(120px, 0.4fr) minmax(0, 1fr);
}

.template-editor-fields-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f2f8fb;
}

.template-editor-grid {
  scroll-behavior: smooth;
  scroll-padding: 16px;
}

@media (max-width: 1300px) {
  .dashboard-primary-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .dashboard-matrix-body {
    min-height: 470px;
  }
}

@media (max-width: 760px) {
  .login-gate-quote {
    padding: 10px 4px;
    font-size: 14px;
    line-height: 1.85;
  }

  .dashboard-command {
    grid-template-columns: minmax(0, 1fr) 42px;
  }

  .dashboard-matrix-body {
    min-height: 0;
    padding: 16px;
  }

  .dashboard-radar {
    width: min(100%, 300px);
    min-height: 300px;
  }
}

/* Dashboard v4 final cascade guard. */
.dashboard-primary-grid {
  grid-template-columns: minmax(0, 1.72fr) minmax(280px, 0.62fr);
  grid-template-rows: auto;
  gap: 12px;
}

.dashboard-primary-grid > .dashboard-visual-panel,
.dashboard-primary-grid .dashboard-visual-panel {
  min-height: 0;
}

@media (max-width: 1180px) {
  .dashboard-primary-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .dashboard-side-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto;
  }
}

@media (max-width: 760px) {
  .dashboard-stage-track,
  .dashboard-cost-flow,
  .dashboard-side-stack {
    grid-template-columns: 1fr;
  }
}
