:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --ok: #059669;
  --fail: #dc2626;
  --border: #e5e7eb;
  --sidebar: #eef1f6;
  --sidebar-border: #e3e6eb;
  --sidebar-text: #1f2329;
  --sidebar-muted: #646a73;
  --sidebar-hover: rgba(0, 0, 0, 0.04);
  --sidebar-active: #267ef0;
  --primary: #267ef0;
  --touch-min: 44px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

body.no-scroll {
  overflow: hidden;
}

a {
  color: var(--primary);
}

img,
table {
  max-width: 100%;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
}

.panel h2,
.panel h3 {
  word-break: break-word;
}

.hint {
  color: var(--muted);
  line-height: 1.6;
  word-break: break-word;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 16px;
}

.data-table {
  width: 100%;
  min-width: 280px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.path-cell {
  word-break: break-all;
  white-space: normal;
}

.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}

.tag.ok {
  background: #d1fae5;
  color: var(--ok);
}

.tag.fail {
  background: #fee2e2;
  color: var(--fail);
}

code {
  font-size: 13px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 16px;
  min-height: var(--touch-min);
  font-size: 16px;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 14px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch-min);
  height: var(--touch-min);
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.icon-menu {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  position: relative;
}

.icon-menu::before,
.icon-menu::after {
  content: "";
  position: absolute;
  left: 0;
  width: 20px;
  height: 2px;
  background: currentColor;
}

.icon-menu::before {
  top: -6px;
}

.icon-menu::after {
  top: 6px;
}

.alert {
  padding: 10px 12px;
  border-radius: 6px;
  margin: 12px 0;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
}

.alert-info {
  background: #dbeafe;
  color: #1e40af;
}

.alert-ok {
  background: #d1fae5;
  color: #065f46;
}

/* 配置页 */
.settings-page {
  max-width: 820px;
}

.page-intro {
  margin-bottom: 20px;
}

.page-intro-title {
  margin: 0 0 6px;
  font-size: clamp(20px, 4vw, 24px);
  font-weight: 600;
}

.page-intro-desc {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.info-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 12px 16px;
  margin-bottom: 16px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 10px;
  font-size: 14px;
}

.info-banner-label {
  color: #0369a1;
  font-weight: 600;
}

.info-banner-value {
  color: var(--text);
}

.info-banner-note {
  color: var(--muted);
  font-size: 13px;
  width: 100%;
}

.info-banner-note code {
  background: rgba(255, 255, 255, 0.7);
  padding: 2px 6px;
  border-radius: 4px;
}

.settings-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.settings-card-head {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.settings-card-head h3 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
}

.settings-card-head p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.form-grid {
  display: grid;
  gap: 16px;
}

.form-grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

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

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

.field-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.settings-form input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 16px;
  min-height: 44px;
  background: #fafafa;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.settings-form input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.settings-form select,
.form-select {
  width: 100%;
  max-width: 480px;
  padding: 11px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 16px;
  min-height: 44px;
  background: #fafafa;
}

.settings-form select:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
}

.perm-home-card {
  margin-bottom: 20px;
  padding: 16px 18px;
}

.perm-home-card .hint {
  margin-top: 10px;
  margin-bottom: 0;
}

.db-path-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.db-path-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.db-path-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.db-path-name {
  font-size: 14px;
  font-weight: 500;
}

.db-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.db-tag-core,
.db-tag-core.db-tag {
  background: #ede9fe;
  color: #5b21b6;
}

.db-tag-ps {
  background: #dbeafe;
  color: #1d4ed8;
}

.db-tag-hr {
  background: #d1fae5;
  color: #047857;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 4px 0 8px;
}

.settings-actions .btn-primary {
  min-width: 160px;
}

.settings-actions .btn-ghost {
  min-width: 120px;
}

.result-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.result-card {
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fafafa;
}

.result-card.result-ok {
  border-color: #a7f3d0;
  background: #f0fdf4;
}

.result-card.result-fail {
  border-color: #fecaca;
  background: #fef2f2;
}

.result-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.result-card .path-cell {
  display: block;
  font-size: 12px;
  word-break: break-all;
  margin-bottom: 6px;
}

.result-msg {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.nav-group-divider {
  display: none;
}

.nav-group-label {
  display: none;
}

.nav-item-system .nav-phase {
  display: none;
}

.breadcrumb {
  margin: 0 0 8px;
  font-size: 13px;
}

.breadcrumb a {
  color: var(--primary);
  text-decoration: none;
}

.settings-hub {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.settings-hub-card {
  display: block;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.settings-hub-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
}

.settings-hub-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
  color: var(--primary);
}

.settings-hub-card p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.tag-admin {
  background: #fef3c7;
  color: #92400e;
}

.perm-matrix th,
.perm-matrix td {
  text-align: center;
  vertical-align: middle;
}

.perm-module-col {
  text-align: left !important;
  min-width: 120px;
}

.perm-action-col {
  width: 52px;
  min-width: 48px;
}

.perm-module-phase {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.perm-module-name {
  font-weight: 500;
  font-size: 14px;
}

.perm-check {
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

.perm-check input {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.form-readonly input:not([type="submit"]) {
  background: #f3f4f6;
  color: var(--muted);
  pointer-events: none;
}

.cell-actions {
  text-align: right;
  white-space: nowrap;
}

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

  .field-span-2 {
    grid-column: auto;
  }

  .settings-card {
    padding: 16px;
  }

  .settings-actions {
    position: sticky;
    bottom: 0;
    background: var(--bg);
    padding: 12px 0 calc(12px + var(--safe-bottom));
    margin: 0 -4px;
  }

  .settings-actions .btn {
    flex: 1 1 calc(50% - 6px);
  }

  .perm-matrix {
    min-width: 520px;
  }
}

/* 旧 settings-form 兼容 */
.settings-form fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

.settings-form legend {
  display: none;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.form-actions .btn {
  flex: 1;
  min-width: 140px;
}

@media (max-width: 480px) {
  .form-actions .btn {
    flex: 1 1 100%;
  }
}

/* 登录页 */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right))
    calc(16px + var(--safe-bottom)) calc(16px + var(--safe-left));
}

.login-wrap {
  width: 100%;
  max-width: 420px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: clamp(20px, 5vw, 22px);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.login-form input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  min-height: var(--touch-min);
}

.login-form .btn-primary {
  width: 100%;
}

.login-foot {
  margin-top: 16px;
  font-size: 12px;
}

/* 应用主布局 — 桌面 */
.app-layout {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar-backdrop {
  display: none;
}

.sidebar {
  width: 240px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  flex-shrink: 0;
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sidebar-logo {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 6px;
  background: linear-gradient(135deg, #267ef0 0%, #1a5fd4 100%);
  box-shadow: 0 2px 6px rgba(38, 126, 240, 0.28);
}

.sidebar-brand-text {
  font-weight: 600;
  line-height: 1.35;
  font-size: 15px;
  color: var(--sidebar-active);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-sidebar-close {
  display: none;
  color: var(--sidebar-muted);
  font-size: 28px;
  line-height: 1;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 8px 10px 16px;
  gap: 2px;
}

/* 一级菜单（首页、无子项模块） */
.nav-top-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  min-height: 40px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  touch-action: manipulation;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.nav-top-item:hover {
  background: var(--sidebar-hover);
}

.nav-top-item.is-active {
  color: var(--sidebar-active);
  font-weight: 500;
}

.nav-top-item.is-soon .nav-top-label {
  color: var(--sidebar-muted);
}

.nav-top-label {
  flex: 1;
  min-width: 0;
}

/* 可折叠分组（企微风格） */
.nav-group {
  margin-bottom: 2px;
}

.nav-group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  min-height: 40px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--sidebar-text);
  font-size: 14px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.nav-group-head:hover {
  background: var(--sidebar-hover);
}

.nav-group-title {
  flex: 1;
  min-width: 0;
  font-weight: 500;
}

.nav-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.45;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform 0.18s ease;
}

.nav-group.is-open .nav-chevron {
  transform: rotate(180deg);
}

.nav-group-body {
  display: none;
  padding: 2px 0 4px;
}

.nav-group.is-open .nav-group-body {
  display: block;
}

.nav-sub-item {
  display: block;
  padding: 9px 12px 9px 40px;
  margin: 0 4px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.4;
  touch-action: manipulation;
}

.nav-sub-item:hover {
  background: var(--sidebar-hover);
}

.nav-sub-item.is-active {
  color: var(--sidebar-active);
  font-weight: 500;
  background: rgba(38, 126, 240, 0.08);
}

.nav-tag {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--sidebar-muted);
  background: rgba(0, 0, 0, 0.05);
  padding: 1px 6px;
  border-radius: 4px;
}

/* 侧栏图标 */
.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  background: currentColor;
  opacity: 0.72;
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
}

.nav-top-item.is-active .nav-icon {
  color: var(--sidebar-active);
  opacity: 1;
}

.nav-group:has(.nav-sub-item.is-active) .nav-group-head {
  color: var(--sidebar-active);
}

.nav-group:has(.nav-sub-item.is-active) .nav-icon {
  color: var(--sidebar-active);
  opacity: 1;
}

.nav-icon-home {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Cpath d='M4 10.5L12 4l8 6.5V20a1 1 0 01-1 1h-5v-6H10v6H5a1 1 0 01-1-1v-9.5z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Cpath d='M4 10.5L12 4l8 6.5V20a1 1 0 01-1 1h-5v-6H10v6H5a1 1 0 01-1-1v-9.5z'/%3E%3C/svg%3E");
}

.nav-icon-system {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41'/%3E%3C/svg%3E");
}

.nav-icon[class*="nav-icon-dash_"] {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Crect x='3' y='3' width='7' height='7' rx='1'/%3E%3Crect x='14' y='3' width='7' height='7' rx='1'/%3E%3Crect x='3' y='14' width='7' height='7' rx='1'/%3E%3Crect x='14' y='14' width='7' height='7' rx='1'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Crect x='3' y='3' width='7' height='7' rx='1'/%3E%3Crect x='14' y='3' width='7' height='7' rx='1'/%3E%3Crect x='3' y='14' width='7' height='7' rx='1'/%3E%3Crect x='14' y='14' width='7' height='7' rx='1'/%3E%3C/svg%3E");
}

.nav-icon-dash_executive,
.nav-icon-dash_sales,
.nav-icon-dash_finance {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Cpath d='M4 19V5M4 19h16M8 17V9M12 17V7M16 17v-4'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Cpath d='M4 19V5M4 19h16M8 17V9M12 17V7M16 17v-4'/%3E%3C/svg%3E");
}

.nav-icon-dash_production {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Cpath d='M3 21h18M5 21V7l7-4 7 4v14M9 21v-6h6v6'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Cpath d='M3 21h18M5 21V7l7-4 7 4v14M9 21v-6h6v6'/%3E%3C/svg%3E");
}

.nav-icon-dash_purchase {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Cpath d='M6 6h15l-1.5 9H7.5L6 6zM6 6L5 3H2M9 21a1 1 0 100-2 1 1 0 000 2zM18 21a1 1 0 100-2 1 1 0 000 2z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Cpath d='M6 6h15l-1.5 9H7.5L6 6zM6 6L5 3H2M9 21a1 1 0 100-2 1 1 0 000 2zM18 21a1 1 0 100-2 1 1 0 000 2z'/%3E%3C/svg%3E");
}

.nav-icon-dash_inventory {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Cpath d='M4 7l8-4 8 4-8 4-8-4zM4 12l8 4 8-4M4 17l8 4 8-4'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Cpath d='M4 7l8-4 8 4-8 4-8-4zM4 12l8 4 8-4M4 17l8 4 8-4'/%3E%3C/svg%3E");
}

.nav-icon-dash_quality {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Cpath d='M12 3l7 4v6c0 4-3 7-7 8-4-1-7-4-7-8V7l7-4zM9 12l2 2 4-4'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Cpath d='M12 3l7 4v6c0 4-3 7-7 8-4-1-7-4-7-8V7l7-4zM9 12l2 2 4-4'/%3E%3C/svg%3E");
}

.nav-icon-dash_equipment {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Cpath d='M14.7 6.3a4 4 0 105.657 5.657L12 19.314l-8.357-8.357a4 4 0 015.657-5.657L12 8.686l2.343-2.386z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Cpath d='M14.7 6.3a4 4 0 105.657 5.657L12 19.314l-8.357-8.357a4 4 0 015.657-5.657L12 8.686l2.343-2.386z'/%3E%3C/svg%3E");
}

.nav-icon-dash_hr {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Cpath d='M17 21v-2a4 4 0 00-4-4H7a4 4 0 00-4 4v2M13 7a4 4 0 11-8 0 4 4 0 018 0zM23 21v-2a4 4 0 00-3-3.87M16 3.13a4 4 0 010 7.75'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Cpath d='M17 21v-2a4 4 0 00-4-4H7a4 4 0 00-4 4v2M13 7a4 4 0 11-8 0 4 4 0 018 0zM23 21v-2a4 4 0 00-3-3.87M16 3.13a4 4 0 010 7.75'/%3E%3C/svg%3E");
}

/* 兼容旧类名（子页内 subnav 等仍可能引用） */
.nav-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px;
  min-height: var(--touch-min);
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 15px;
  touch-action: manipulation;
}

.nav-item:hover {
  background: var(--sidebar-hover);
}

.nav-item.active {
  color: var(--sidebar-active);
  background: rgba(38, 126, 240, 0.08);
  font-weight: 500;
}

.nav-item.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.nav-label {
  flex: 1;
  min-width: 0;
}

.nav-phase {
  font-size: 11px;
  opacity: 0.75;
  flex-shrink: 0;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  padding-top: calc(10px + var(--safe-top));
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.btn-menu {
  display: none;
}

.page-heading {
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  flex-shrink: 0;
}

.company-switch-form {
  margin: 0;
}

.company-select {
  max-width: 160px;
  padding: 4px 8px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--text);
}

.company-label {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.user-name-full {
  display: inline;
}

.user-name-short {
  display: none;
}

.user-job-title {
  color: var(--muted);
  font-weight: normal;
  font-size: 0.92em;
}

.logout-form {
  margin: 0;
}

.app-content {
  padding: 16px;
  padding-bottom: calc(16px + var(--safe-bottom));
  flex: 1;
}

.placeholder-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.placeholder-head h2 {
  margin: 0;
  font-size: clamp(18px, 4.5vw, 22px);
}

.phase-badge {
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
}

/* 手机 / 小平板 */
@media (max-width: 768px) {
  .panel {
    padding: 16px;
  }

  .btn-menu {
    display: inline-flex;
    flex-shrink: 0;
  }

  .btn-sidebar-close {
    display: inline-flex;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 90;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 86vw);
    z-index: 100;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    padding-bottom: var(--safe-bottom);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

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

  .app-topbar {
    flex-wrap: nowrap;
  }

  .user-name-full {
    display: none;
  }

  .user-name-short {
    display: inline;
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .data-table th,
  .data-table td {
    padding: 12px 10px;
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .app-content {
    padding: 12px;
    padding-bottom: calc(12px + var(--safe-bottom));
  }

  .page-heading {
    font-size: 16px;
  }

  .user-bar .btn-sm {
    min-height: var(--touch-min);
  }
}

/* 看板 */
.dashboard-page .page-intro {
  margin-bottom: 20px;
}

.dashboard-page .page-intro-title {
  margin: 0 0 6px;
  font-size: 22px;
}

.dashboard-page .page-intro-desc {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.kpi-card-warn {
  border-color: #fecaca;
  background: #fff7f7;
}

.kpi-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  word-break: break-all;
}

.kpi-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.dashboard-panel {
  margin-bottom: 16px;
}

.dashboard-panel h3 {
  margin-top: 0;
}

.data-table .num {
  text-align: right;
  white-space: nowrap;
}

.cell-muted {
  color: var(--muted);
  font-size: 12px;
}

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.alert-ok {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.alert-warn {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.drift-prompt-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin: 0 0 16px;
}

.drift-prompt-text {
  flex: 1 1 240px;
  font-weight: 600;
}

.drift-prompt-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.drift-prompt-form {
  margin: 0;
}

.drift-probe-hint {
  flex: 1 1 100%;
  font-size: 12px;
  opacity: 0.85;
}

.credit-snapshot-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
  margin: 0 0 18px;
  padding: 14px 18px;
  font-size: 14px;
  line-height: 1.4;
  color: #0c4a6e;
  background: linear-gradient(135deg, #e0f2fe 0%, #f0f9ff 100%);
  border: 1px solid #7dd3fc;
  border-left: 4px solid #0284c7;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(2, 132, 199, 0.12);
}

.credit-snapshot-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: #0284c7;
  border-radius: 6px;
  white-space: nowrap;
}

.credit-snapshot-item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}

.credit-snapshot-label {
  font-size: 13px;
  font-weight: 500;
  color: #0369a1;
}

.credit-snapshot-item strong {
  font-size: 15px;
  font-weight: 700;
  color: #0c4a6e;
}

.credit-snapshot-refresh {
  margin-left: auto;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #0284c7;
  text-decoration: none;
  background: #fff;
  border: 1px solid #38bdf8;
  border-radius: 6px;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.credit-snapshot-refresh:hover {
  color: #0369a1;
  background: #f0f9ff;
  border-color: #0284c7;
}

.snapshot-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px 24px;
  margin: 0 0 20px;
}

.snapshot-meta-grid dt {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 4px;
}

.snapshot-meta-grid dd {
  margin: 0;
  font-weight: 600;
}

.settings-actions {
  margin-top: 8px;
}

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.panel-header-row h3 {
  margin: 0;
}

.panel-footer-hint {
  margin: 12px 0 0;
}

.overdue-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.overdue-toolbar-left {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.pagination-info {
  font-size: 14px;
  color: var(--muted);
}

.pagination-actions {
  display: flex;
  gap: 8px;
}

.btn.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.overdue-table .col-check {
  width: 40px;
  text-align: center;
}

.row-reminded {
  background: #fafafa;
}

.overdue-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-bottom: 12px;
  padding: 12px 16px;
}

.overdue-filter-label {
  font-size: 14px;
  color: var(--muted, #6b7280);
}

.overdue-filter-select {
  min-width: 160px;
  padding: 6px 10px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  background: #fff;
}

.overdue-filter-select-sm {
  min-width: 96px;
}

.overdue-aging-cell {
  min-width: 200px;
  max-width: 320px;
  font-size: 13px;
  vertical-align: top;
}

.aging-details {
  min-width: 0;
}

.aging-details summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 6px;
  padding: 2px 0;
}

.aging-details summary::-webkit-details-marker {
  display: none;
}

.aging-summary-amt,
.aging-penalty-amt {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.aging-penalty-amt {
  color: #b45309;
}

.aging-summary-label,
.aging-expand-hint {
  color: var(--muted, #6b7280);
  font-size: 12px;
}

.aging-expand-hint {
  margin-left: 2px;
  font-size: 12px;
  color: var(--muted, #6b7280);
}

.aging-details:not([open]) .aging-expand-hint::after {
  content: "展开 ▾";
}

.aging-details[open] .aging-expand-hint::after {
  content: "收起 ▴";
}

.overdue-aging-list .aging-penalty {
  font-size: 12px;
  color: #b45309;
  font-variant-numeric: tabular-nums;
}

.overdue-aging-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.overdue-aging-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  padding: 3px 0;
  border-bottom: 1px dashed var(--border);
}

.overdue-aging-list li:last-child {
  border-bottom: none;
}

.overdue-aging-list .aging-days {
  font-weight: 600;
  color: #b45309;
  white-space: nowrap;
}

.overdue-aging-list .aging-amt {
  font-variant-numeric: tabular-nums;
}

.overdue-aging-list .aging-due {
  font-size: 12px;
}

.tag-muted {
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid #e5e7eb;
}

.payterm-ref {
  margin-top: 16px;
  padding: 14px 16px;
}

.payterm-ref summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 8px;
}

.payterm-invalid-label,
.payterm-invalid-hint {
  color: #b45309;
  font-weight: 500;
}

.row-payterm-invalid {
  background: #fffbeb;
}

.row-payterm-invalid:hover {
  background: #fef3c7;
}

.data-table-compact th,
.data-table-compact td {
  padding: 8px 10px;
  font-size: 13px;
}

.nav-phase-muted {
  opacity: 0.65;
}

.nav-item-soon .nav-label {
  opacity: 0.9;
}

/* 旧模块折叠类名 — 已由 .nav-group 替代，保留空壳避免引用报错 */
.nav-module-group {
  margin-bottom: 0;
}

.nav-module-group.nav-module-open .nav-sub {
  display: block;
}

.nav-item-module.nav-module-current {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}

.nav-item-sub.active {
  color: var(--sidebar-active);
  background: rgba(38, 126, 240, 0.08);
}

.nav-sub {
  padding-left: 0;
  border-left: none;
  margin: 0;
}

.nav-item-sub {
  padding-left: 40px;
  min-height: 40px;
}

.sales-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.sales-subnav-item {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-min);
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}

.sales-subnav-item.active {
  border-color: var(--primary);
  background: #eff6ff;
  color: var(--primary);
  font-weight: 600;
}

.module-page .page-intro {
  margin-top: 0;
}

.rule-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.rule-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: #f9fafb;
}

.rule-card-title {
  font-weight: 600;
  margin-bottom: 6px;
}

.flow-list {
  margin: 0 0 12px;
  padding-left: 20px;
  line-height: 1.8;
}

.supervise-progress-cell {
  min-width: 160px;
  max-width: 280px;
  font-size: 13px;
  vertical-align: top;
}

.supervise-action-list {
  margin: 0;
  padding-left: 16px;
  line-height: 1.55;
}

.supervise-action-list li {
  margin-bottom: 6px;
}

tr.row-promise-overdue td {
  background: #fff7ed;
}

.supervise-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.supervise-stat-block {
  min-width: 0;
}

.supervise-stat-title {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
}

.data-table-compact th,
.data-table-compact td {
  padding: 6px 8px;
  font-size: 13px;
}

/* 销售看板图表 */
.dash-section {
  margin-bottom: 20px;
}

.dash-section-title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
}

.dash-charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.dash-tables-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-desc {
  margin: -4px 0 12px;
  font-size: 13px;
  color: var(--muted);
}

.bar-chart-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.legend-order { background: #3b82f6; }
.legend-delivery { background: #10b981; }
.legend-payment { background: #f59e0b; }
.legend-board { background: #6366f1; }
.legend-carton { background: #ec4899; }

.grouped-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 180px;
  padding: 8px 4px 0;
  border-bottom: 1px solid var(--border);
  overflow: visible;
}

.grouped-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  height: 100%;
  overflow: visible;
}

.grouped-bar-stack {
  flex: 1;
  width: 100%;
  max-width: 36px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  overflow: visible;
}

.gbar {
  width: 8px;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  transition: height 0.2s ease, filter 0.15s ease;
  position: relative;
  cursor: default;
}

.gbar:hover,
.gbar:focus-visible {
  filter: brightness(1.08);
  z-index: 2;
}

.gbar[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  padding: 4px 8px;
  border-radius: 6px;
  background: #1f2937;
  color: #fff;
  font-size: 11px;
  line-height: 1.35;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease, visibility 0.12s ease;
  z-index: 20;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.18);
}

.gbar[data-tip]::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1f2937;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease, visibility 0.12s ease;
  z-index: 20;
}

.gbar:hover::after,
.gbar:hover::before,
.gbar:focus-visible::after,
.gbar:focus-visible::before {
  opacity: 1;
  visibility: visible;
}

.gbar-order { background: #3b82f6; }
.gbar-delivery { background: #10b981; }
.gbar-payment { background: #f59e0b; }

.grouped-bar-label {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  white-space: nowrap;
}

.mix-chart {
  margin-top: 8px;
}

.mix-bar,
.mix-kpi-bar {
  display: flex;
  height: 28px;
  border-radius: 6px;
  overflow: hidden;
  background: #f3f4f6;
}

.mix-seg {
  height: 100%;
  min-width: 2px;
}

.mix-board { background: #6366f1; }
.mix-carton { background: #ec4899; }

.mix-labels {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  font-size: 13px;
}

.mix-kpi-row {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

.mix-kpi-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.mix-kpi-val {
  font-size: 14px;
  font-weight: 600;
  margin-top: 6px;
}

@media (max-width: 900px) {
  .dash-charts-grid,
  .dash-tables-grid {
    grid-template-columns: 1fr;
  }

  .grouped-bar-chart {
    height: 140px;
    overflow-x: auto;
  }

  .grouped-bar-col {
    min-width: 28px;
  }
}

/* ── 页面加载进度 ── */
.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  padding: 32px 16px;
}

.page-loading-compact {
  min-height: 220px;
}

.page-loading-overlay {
  min-height: auto;
  padding: 0;
}

.page-loading-card {
  width: min(440px, 100%);
  text-align: center;
  padding: 28px 24px 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.page-loading-spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: page-loading-spin 0.75s linear infinite;
}

.page-loading-title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.page-loading-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.page-loading-pct {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.page-loading-elapsed {
  color: var(--muted);
}

.page-loading-progress {
  height: 8px;
  margin: 0 0 14px;
  overflow: hidden;
  background: #eef2f7;
  border-radius: 999px;
}

.page-loading-progress-bar {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #60a5fa, #2563eb);
  background-size: 200% 100%;
  border-radius: 999px;
  transition: width 0.35s ease-out;
  animation: page-loading-bar-shine 1.8s linear infinite;
}

.page-loading-msg {
  margin: 0 0 14px;
  min-height: 1.5em;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: opacity 0.2s ease;
}

.page-loading-msg.is-changing {
  animation: page-loading-msg-pulse 0.45s ease;
}

.page-loading-steps {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 10px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.page-loading-steps li {
  position: relative;
  padding: 4px 10px 4px 22px;
  font-size: 12px;
  color: var(--muted);
  background: #f3f4f6;
  border-radius: 999px;
  transition: background 0.25s ease, color 0.25s ease;
}

.page-loading-steps li::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-radius: 50%;
  background: #d1d5db;
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

.page-loading-steps li.is-active {
  color: var(--primary);
  background: #eff6ff;
  font-weight: 600;
}

.page-loading-steps li.is-active::before {
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
  animation: page-loading-step-pulse 1.2s ease-in-out infinite;
}

.page-loading-steps li.is-done {
  color: var(--ok);
}

.page-loading-steps li.is-done::before {
  background: var(--ok);
}

.page-loading-hint {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.global-page-loader {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(244, 246, 248, 0.88);
  backdrop-filter: blur(3px);
}

.global-page-loader[hidden] {
  display: none !important;
}

.async-content-host {
  min-height: 360px;
}

.async-content-host.content-loaded {
  animation: content-fade-in 0.28s ease;
}

@keyframes content-fade-in {
  from {
    opacity: 0.4;
  }
  to {
    opacity: 1;
  }
}

body.is-global-loading {
  overflow: hidden;
}

@keyframes page-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes page-loading-bar-shine {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

@keyframes page-loading-msg-pulse {
  0% {
    opacity: 0.35;
    transform: translateY(2px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes page-loading-step-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.15);
  }
}

@keyframes page-loading-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.wecom-mapping-table input[type="text"],
.wecom-mapping-table input[type="number"] {
  width: 100%;
  min-width: 72px;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
}

.wecom-mapping-table .field-input-sm {
  max-width: 120px;
}

.wecom-mapping-table td.cell-check {
  text-align: center;
  width: 48px;
}

.wecom-status-table {
  margin-bottom: 16px;
}

.wecom-status-table th[scope="row"] {
  width: 120px;
  white-space: nowrap;
  font-weight: 500;
  color: #64748b;
  background: #f8fafc;
  vertical-align: top;
}

.wecom-status-table td {
  vertical-align: top;
}

.wecom-status-hint {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.5;
}

.wecom-code {
  display: inline-block;
  max-width: 100%;
  word-break: break-all;
  font-size: 13px;
}

.wecom-mapping-table {
  min-width: 720px;
}

.settings-page .wecom-mapping-table th {
  white-space: nowrap;
  font-size: 13px;
}

.settings-page .settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

/* 宽表格（督办、逾期货款等）— 手机横滑 */
.data-table-wide {
  min-width: 880px;
}

.table-scroll-hint {
  margin-top: 8px;
  font-size: 13px;
}

/* ── 手机浏览器增强 ── */
@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
  }

  .app-main {
    width: 100%;
  }

  .sales-subnav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    margin-bottom: 16px;
    padding-bottom: 8px;
  }

  .sales-subnav::-webkit-scrollbar {
    display: none;
  }

  .sales-subnav-item {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .module-page .page-intro-title {
    font-size: clamp(18px, 5vw, 22px);
  }

  .module-page .page-intro-desc {
    font-size: 14px;
  }

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

  .overdue-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .overdue-toolbar-left,
  .overdue-toolbar-right {
    width: 100%;
    justify-content: flex-start;
  }

  .overdue-toolbar-left .btn,
  .overdue-toolbar-right .btn {
    flex: 1 1 auto;
    min-width: calc(50% - 4px);
  }

  .overdue-filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .overdue-filter-select {
    width: 100%;
    min-width: 0;
    min-height: var(--touch-min);
    font-size: 16px;
  }

  .company-select {
    max-width: 100px;
    min-height: 36px;
    font-size: 16px;
  }

  .supervise-stats-grid {
    grid-template-columns: 1fr;
  }

  .login-form input,
  .m-input,
  .m-textarea,
  input[type="text"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px;
  }

  .panel-header-row .btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .dashboard-page .kpi-grid {
    grid-template-columns: 1fr;
  }

  .user-bar {
    gap: 6px;
  }

  .company-label {
    display: none;
  }

  .overdue-toolbar-left .btn {
    flex: 1 1 100%;
  }

  .pagination {
    flex-direction: column;
    align-items: stretch;
  }

  .pagination-actions {
    width: 100%;
    justify-content: space-between;
  }

  .pagination-actions .btn {
    flex: 1;
  }
}
