@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,600&family=Inter:wght@400;500;600;700&display=swap');

* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --font-sans: "Be Vietnam Pro", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", system-ui, sans-serif;
  --brand-ink: #082638;
  --brand-navy: #103d50;
  --brand-blue: #008fa3;
  --brand-cyan: #00b0b0;
  --brand-gold: #f0b000;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: rgba(255, 255, 255, 0.94);
  --surface-muted: rgba(244, 249, 252, 0.88);
  --line: rgba(16, 61, 80, 0.16);
  --line-strong: rgba(16, 61, 80, 0.28);
  --text: #172b38;
  --text-muted: #5c6d74;
  --shadow-soft: 0 18px 55px rgba(8, 38, 56, 0.12);
  --shadow-crisp: 0 10px 28px rgba(8, 38, 56, 0.1);
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  font-family: var(--font-sans);
  color: var(--text);
  background: #eef9f9;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea {
  font-family: inherit;
}

body.login-body {
  overflow: auto;
  background: #e8f4f5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.app-bg,
.login-screen {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
}

.app-bg {
  background:
    linear-gradient(90deg, rgba(0, 144, 160, 0.055) 1px, transparent 1px),
    linear-gradient(0deg, rgba(240, 176, 0, 0.045) 1px, transparent 1px),
    linear-gradient(132deg, transparent 0 16%, rgba(0, 176, 176, 0.12) 16% 31%, transparent 31% 54%, rgba(240, 176, 0, 0.09) 54% 63%, transparent 63% 100%),
    linear-gradient(118deg, rgba(255, 255, 255, 0.9) 0%, rgba(235, 250, 250, 0.78) 34%, rgba(224, 241, 242, 0.88) 68%, rgba(249, 252, 248, 0.94) 100%),
    linear-gradient(146deg, #e6f8f8 0%, #f7fbfa 44%, #e9f4ef 100%);
  background-size: 44px 44px, 44px 44px, auto, auto, auto;
}

.app-shell {
  display: flex;
  gap: 14px;
  height: 100vh;
  height: 100dvh;
  padding: 12px;
  transition: gap 0.2s ease;
}

.glass-panel {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 18px;
  box-shadow: var(--shadow-crisp);
  backdrop-filter: blur(22px) saturate(128%);
  -webkit-backdrop-filter: blur(22px) saturate(128%);
}

.sidebar {
  width: 280px;
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  padding: 18px;
  overflow: hidden;
  overflow-x: hidden;
  transition: width 0.2s ease, flex-basis 0.2s ease, padding 0.2s ease, opacity 0.18s ease, transform 0.2s ease, border-width 0.2s ease;
}

body.sidebar-collapsed .app-shell {
  gap: 0;
}

body.sidebar-collapsed .sidebar {
  width: 0;
  flex-basis: 0;
  padding: 0;
  border-width: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-12px);
}

.sidebar.glass-panel {
  color: #eaf6ff;
  background:
    linear-gradient(180deg, rgba(8, 38, 56, 0.96), rgba(13, 74, 89, 0.92)),
    linear-gradient(135deg, rgba(0, 176, 176, 0.2), rgba(240, 176, 0, 0.1));
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 20px 60px rgba(8, 38, 56, 0.26);
}

@media (min-width: 1025px) {
  .sidebar.offcanvas {
    position: static;
    z-index: auto;
    height: auto;
    max-width: none;
    visibility: visible;
    transform: none;
  }

  body.sidebar-collapsed .sidebar.offcanvas {
    transform: translateX(-12px);
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand > div:not(.brand-mark) {
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  overflow: visible;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.brand-title {
  color: #ffffff;
  font-weight: 800;
  font-size: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-subtitle {
  color: #7ff3ef;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-search {
  margin-top: 14px;
  flex: 0 0 auto;
}

.sidebar-search-inner {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  transition: all 0.18s ease;
}

.sidebar-search-inner:focus-within {
  background: rgba(255, 255, 255, 0.14);
  border-color: #00b0b0;
  box-shadow: 0 0 0 3px rgba(0, 176, 176, 0.22);
}

.sidebar-search-icon {
  position: absolute;
  left: 10px;
  width: 14px;
  height: 14px;
  color: rgba(234, 246, 255, 0.55);
  pointer-events: none;
}

.sidebar-search-input {
  width: 100%;
  height: 34px;
  padding: 6px 28px 6px 30px;
  background: transparent;
  border: 0;
  outline: none;
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
}

.sidebar-search-input::placeholder {
  color: rgba(234, 246, 255, 0.45);
}

.sidebar-search-clear {
  position: absolute;
  right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  background: transparent;
  border: 0;
  color: rgba(234, 246, 255, 0.6);
  cursor: pointer;
  border-radius: 50%;
  transition: color 0.15s, background-color 0.15s;
}

.sidebar-search-clear:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
}

.sidebar-search-clear svg {
  width: 12px;
  height: 12px;
}

.sidebar-search-empty {
  padding: 16px 8px;
  text-align: center;
  font-size: 13px;
  color: rgba(234, 246, 255, 0.65);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 176, 176, 0.46) transparent;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 0;
  color: rgba(234, 246, 255, 0.78);
  text-decoration: none;
  border-radius: 12px;
  font-weight: 600;
  text-align: left;
  background: transparent;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.nav-item svg {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
}

.nav-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item:hover,
.nav-item.active {
  color: #ffffff;
  background: linear-gradient(90deg, rgba(240, 176, 0, 0.18), rgba(0, 176, 176, 0.23), rgba(255, 255, 255, 0.08));
}

.nav-item:hover {
  transform: translateX(2px);
}

.nav-item.active {
  box-shadow: inset 3px 0 0 var(--brand-gold);
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-parent {
  cursor: pointer;
}

.nav-parent > span {
  flex: 1;
}

.submenu-arrow {
  width: 16px !important;
  height: 16px !important;
  margin-left: auto;
  transition: transform 0.22s ease;
}

.nav-group.expanded .submenu-arrow {
  transform: rotate(180deg);
}

.submenu-list {
  max-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
  margin-left: 21px;
  padding-left: 14px;
  border-left: 1px dashed rgba(0, 176, 176, 0.42);
  transition: max-height 0.24s ease, margin-bottom 0.24s ease;
}

.nav-group.expanded .submenu-list {
  max-height: 620px;
  margin-bottom: 6px;
}

.sub-item {
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
}

.sub-bullet {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 999px;
  background: rgba(234, 246, 255, 0.36);
}

.sub-item:hover,
.sub-item.active-sub {
  color: #ffffff;
  background: rgba(0, 176, 176, 0.14);
}

.sub-item.active-sub .sub-bullet {
  background: var(--brand-gold);
}

.sidebar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  color: #ffffff !important;
  background: linear-gradient(135deg, #f43f5e, #be123c);
  box-shadow: 0 2px 6px rgba(225, 29, 72, 0.45);
  flex: 0 0 auto !important;
  overflow: visible !important;
  text-overflow: clip !important;
}

.nav-parent .sidebar-badge {
  margin-left: auto;
  margin-right: 6px;
}

.sub-item .sidebar-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 10px;
}

.sidebar-badge[hidden],
.tab-badge[hidden] {
  display: none !important;
}


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

.topbar {
  position: relative;
  z-index: 60;
  min-height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 7px 18px;
}

.topbar.glass-panel {
  position: relative;
  overflow: visible;
  background:
    linear-gradient(110deg, rgba(255, 255, 255, 0.92), rgba(245, 251, 250, 0.78)),
    linear-gradient(90deg, rgba(0, 176, 176, 0.13), rgba(240, 176, 0, 0.08));
  border-color: rgba(255, 255, 255, 0.82);
}

.topbar.glass-panel::before {
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 0;
  width: 4px;
  border-radius: 0 999px 999px 0;
  background: linear-gradient(180deg, var(--brand-gold), var(--brand-cyan), var(--brand-blue));
  content: "";
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
  font-weight: 800;
  color: var(--brand-ink);
}

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

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.role-chip,
.user-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid rgba(16, 61, 80, 0.1);
  background: rgba(255, 255, 255, 0.72);
  color: #3a4a5d;
  font-size: 13px;
  font-weight: 700;
}

.icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(16, 61, 80, 0.1);
  border-radius: 10px;
  color: var(--brand-navy);
  background: rgba(255, 255, 255, 0.74);
  line-height: 0;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.icon-button svg {
  display: block;
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  margin: 0;
}

.icon-button:hover {
  color: #ffffff;
  background: var(--brand-navy);
  transform: translateY(-1px);
}

.sidebar-visibility-toggle {
  flex: 0 0 auto;
}

.sidebar-close-button {
  display: none;
  flex: 0 0 auto;
  margin-left: auto;
  color: rgba(234, 246, 255, 0.82);
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-close-button:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.16);
}

.account-menu {
  position: relative;
}

.notification-menu {
  position: relative;
}

.notification-button {
  position: relative;
}

.notification-button::after {
  display: none;
}

.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  padding: 0 4px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  color: #ffffff;
  background: #b91c43;
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
}

.notification-dropdown {
  z-index: 1220;
  width: min(380px, calc(100vw - 24px));
  max-height: min(560px, calc(100vh - 92px));
  overflow: hidden;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 16px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(243, 250, 249, 0.94)),
    linear-gradient(120deg, rgba(0, 176, 176, 0.07), rgba(240, 176, 0, 0.05));
  box-shadow: 0 18px 48px rgba(8, 38, 56, 0.18);
  backdrop-filter: blur(22px) saturate(128%);
  -webkit-backdrop-filter: blur(22px) saturate(128%);
}

.notification-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 8px 10px;
}

.notification-dropdown-header strong {
  color: var(--brand-ink);
  font-size: 14px;
}

.notification-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notification-item {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(16, 61, 80, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
}

.notification-item.is-muted {
  opacity: 0.68;
}

.notification-main {
  display: grid;
  gap: 3px;
  color: inherit;
  text-decoration: none;
}

.notification-main strong {
  color: var(--brand-ink);
  font-size: 13px;
  line-height: 1.25;
}

.notification-main span,
.notification-main small,
.notification-empty {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.notification-main span {
  line-height: 1.35;
}

.notification-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.notification-empty {
  padding: 16px 10px;
  text-align: center;
}

.notification-empty.is-error {
  color: #b91c43;
}

.account-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 220px;
  padding: 5px 13px 5px 6px;
  border: 1px solid rgba(16, 61, 80, 0.12);
  border-radius: 999px;
  color: #35475c;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.76);
  transition: box-shadow 0.18s ease, transform 0.18s ease, background-color 0.18s ease;
}

.account-button:hover,
.account-button.show {
  background: #ffffff;
  box-shadow: 0 10px 22px rgba(8, 38, 56, 0.12);
  transform: translateY(-1px);
}

.account-avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: 0 0 30px;
  border-radius: 999px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--brand-navy), var(--brand-cyan));
}

.account-avatar svg {
  width: 17px;
  height: 17px;
}

.account-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-dropdown {
  z-index: 1220;
  width: min(300px, calc(100vw - 24px));
  min-width: 0;
  max-height: calc(100dvh - 88px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 16px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(243, 250, 249, 0.94)),
    linear-gradient(120deg, rgba(0, 176, 176, 0.07), rgba(240, 176, 0, 0.05));
  box-shadow: 0 18px 48px rgba(8, 38, 56, 0.18);
  backdrop-filter: blur(22px) saturate(128%);
  -webkit-backdrop-filter: blur(22px) saturate(128%);
}

.account-dropdown-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px 10px;
  overflow-wrap: anywhere;
}

.account-dropdown-header strong {
  color: var(--brand-ink);
  font-size: 14px;
  line-height: 1.25;
}

.account-dropdown-header span,
.account-dropdown-meta {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.account-dropdown-meta,
.account-dropdown-action {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-dropdown-meta {
  padding: 4px 10px;
  overflow-wrap: anywhere;
}

.account-dropdown-meta span {
  min-width: 0;
}

.account-details {
  margin: 0;
}

.account-details dt {
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.account-details dd {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.account-dropdown-meta svg,
.account-dropdown-action svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.account-dropdown-action {
  min-height: 36px;
  border-radius: 10px;
  font-weight: 800;
}

.account-dropdown-action[hidden] {
  display: none;
}

.account-dropdown-action.danger {
  color: #b91c43;
}

.account-dropdown-action.danger:hover {
  color: #ffffff;
  background: #b91c43;
}

.account-reload-btn {
  position: relative;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.account-reload-btn svg:first-child {
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.account-reload-btn:hover svg:first-child {
  transform: rotate(45deg);
}

.account-reload-btn:active svg:first-child,
.account-reload-btn.is-loading svg:first-child,
.account-reload-btn.is-spinning svg:first-child {
  animation: account-reload-spin 0.65s linear infinite;
}

@keyframes account-reload-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.account-live-indicator {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  background: rgba(100, 116, 139, 0.12);
  color: #64748b;
  border: 1px solid rgba(148, 163, 184, 0.28);
  transition: all 0.2s ease;
  user-select: none;
}

.account-live-indicator .account-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #94a3b8;
  display: inline-block;
  box-shadow: none;
  transition: all 0.2s ease;
}

.account-live-indicator.is-live {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  border-color: rgba(16, 185, 129, 0.28);
}

.account-live-indicator.is-live .account-live-dot {
  background-color: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: account-live-pulse 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

@keyframes account-live-pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.module-container {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  transition: opacity 0.16s ease;
}

.module-container.is-loading {
  opacity: 0.62;
  cursor: progress;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.kpi-card {
  padding: 20px 22px 18px;
}

.erp-panel {
  padding: 22px;
}

.kpi-card.glass-panel,
.erp-panel.glass-panel,
.module-toolbar.glass-panel,
.workspace-tabs.glass-panel {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.91), rgba(244, 250, 249, 0.78)),
    linear-gradient(120deg, rgba(0, 176, 176, 0.075), rgba(240, 176, 0, 0.055));
  border-color: rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow-crisp);
}

.kpi-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(8, 38, 56, 0.14);
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 18px 18px 0 0;
  background: var(--kpi-accent, var(--brand-cyan));
}

.kpi-card--cyan { --kpi-accent: var(--brand-cyan); }
.kpi-card--blue { --kpi-accent: var(--brand-blue); }
.kpi-card--gold { --kpi-accent: var(--brand-gold); }
.kpi-card--red  { --kpi-accent: #e11d48; }

.kpi-card p,
.erp-panel p {
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.kpi-card strong {
  display: block;
  font-size: clamp(20px, 1.8vw, 30px);
  font-weight: 800;
  margin-bottom: 0;
  color: var(--brand-ink);
  line-height: 1.15;
}

.kpi-card small {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 6px;
  display: block;
}

.kpi-trend {
  align-self: flex-start;
  margin-bottom: 8px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.82);
  letter-spacing: 0.01em;
}

.kpi-trend.positive {
  color: #007a66;
  background: rgba(0, 176, 120, 0.1);
}

.kpi-trend.negative {
  color: #b91c43;
  background: rgba(225, 29, 72, 0.08);
}

.kpi-trend.stable {
  color: var(--brand-navy);
  background: rgba(16, 61, 80, 0.08);
}

.erp-panel {
  margin-top: 16px;
}

.erp-panel h2 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 800;
  color: var(--brand-ink);
}

.erp-panel > p {
  margin: 0 0 16px;
  font-size: 13px;
}

.chart {
  height: 340px;
  margin-top: 8px;
}

.chart--sm {
  height: 220px;
  margin-top: 8px;
}

.chart-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.chart-row .erp-panel {
  margin-top: 0;
}

.empty-panel {
  min-height: 360px;
  display: grid;
  align-content: center;
}

.erp-module {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Let content shrink inside flex/grid tracks; wide data scrolls in its own frame. */
.erp-module,
.workspace-panel,
.erp-panel,
.chart,
.kpi-card,
.form-grid > *,
.check-grid > * {
  min-width: 0;
}

.table-responsive {
  max-width: 100%;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

.kpi-card strong,
.kanban-card,
.erp-field,
.contract-summary,
.notification-main {
  overflow-wrap: anywhere;
}

.module-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 18px;
  flex-wrap: nowrap;
}

.workspace-context-toolbar {
  align-items: center;
}

.toolbar-context {
  flex: 0 1 auto;
  min-width: 92px;
  max-width: 150px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.toolbar-context span {
  color: #007a80;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.toolbar-context strong {
  overflow: hidden;
  color: var(--brand-ink);
  font-size: 14px;
  line-height: 1.2;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-workspace-toolbar][hidden] {
  display: none;
}

.module-toolbar h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  color: var(--brand-ink);
}

.module-toolbar p {
  margin: 0;
  color: var(--text-muted);
}

.module-toolbar h2 + p {
  margin-top: 6px;
}

.toolbar-filter-scroll {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.toolbar-filters {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scrollbar-width: none;
}

.toolbar-filters::-webkit-scrollbar {
  display: none;
}

.filter-control {
  flex: 0 0 140px;
  width: 140px;
  min-width: 0;
  max-width: 160px;
}

.toolbar-filters .filter-control {
  min-height: 34px;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 13px;
}

.filter-control.search {
  flex-basis: 220px;
  width: 220px;
  max-width: 240px;
}

.toolbar-scroll-button {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  flex: 0 0 28px;
  border: 1px solid rgba(16, 61, 80, 0.16);
  border-radius: 9px;
  color: var(--brand-navy);
  background: rgba(255, 255, 255, 0.78);
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.toolbar-scroll-button:hover {
  color: #ffffff;
  background: var(--brand-navy);
  transform: translateY(-1px);
}

.toolbar-scroll-button[hidden] {
  display: none;
}

.toolbar-scroll-button svg {
  width: 15px;
  height: 15px;
}

.workspace-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
}

.workspace-tab {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(16, 61, 80, 0.14);
  border-radius: 12px;
  padding: 0 14px;
  color: #445367;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.66);
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

a.workspace-tab {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.workspace-tab:hover {
  border-color: rgba(0, 176, 176, 0.42);
  color: var(--brand-navy);
  transform: translateY(-1px);
}

.workspace-tab.is-active {
  color: #ffffff;
  border-color: rgba(0, 176, 176, 0.26);
  background: linear-gradient(135deg, var(--brand-navy), var(--brand-blue) 56%, var(--brand-cyan));
  box-shadow: 0 10px 24px rgba(0, 143, 163, 0.22), inset 0 -3px 0 rgba(240, 176, 0, 0.85);
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  color: #ffffff;
  background: #f43f5e;
  box-shadow: 0 2px 5px rgba(244, 63, 94, 0.4);
  transition: all 0.18s ease;
}

.workspace-tab.is-active .tab-badge {
  background: #ffffff;
  color: #e11d48;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.workspace-panel[hidden] {
  display: none;
}

.workspace-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.workspace-panel .erp-panel {
  margin-top: 0;
}

.workspace-kanban {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.kanban-column {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: rgba(248, 251, 252, 0.78);
}

.kanban-column header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--brand-ink);
  font-weight: 800;
}

.kanban-column header span {
  color: var(--text-muted);
  font-size: 12px;
}

.kanban-cards {
  display: grid;
  gap: 8px;
}

.kanban-card {
  display: grid;
  gap: 4px;
  min-height: 86px;
  border: 1px solid rgba(16, 61, 80, 0.1);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.84);
}

.kanban-card span,
.kanban-card small,
.form-hint {
  color: var(--text-muted);
  font-weight: 700;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 8px;
  margin-left: auto;
}

.toolbar-actions:empty {
  display: none;
}

.btn-primary-glass,
.btn-secondary-glass,
.btn-danger-glass {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 12px;
  font-weight: 800;
  line-height: 1.1;
}

.btn-primary-glass svg,
.btn-secondary-glass svg,
.btn-danger-glass svg {
  width: 18px;
  height: 18px;
}

.btn-secondary-glass {
  border: 1px solid rgba(16, 61, 80, 0.24);
  color: var(--brand-navy);
  background: rgba(255, 255, 255, 0.76);
}

.btn-primary-glass,
.btn-secondary-glass,
.btn-danger-glass,
.table-action {
  transition: box-shadow 0.18s ease, transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.btn-primary-glass:hover,
.btn-secondary-glass:hover,
.btn-danger-glass:hover,
.table-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(8, 38, 56, 0.18);
}

.btn-primary-glass:hover,
.btn-danger-glass:hover {
  color: #ffffff;
}

.btn-secondary-glass:hover {
  border-color: rgba(0, 143, 163, 0.58);
  color: var(--brand-ink);
  background: rgba(227, 250, 249, 0.96);
}

.erp-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

[data-workspace-panel="role_policy"] .erp-table {
  min-width: 900px;
}

[data-workspace-panel="notification_policy"] .erp-table {
  min-width: 560px;
}

.erp-table th,
.erp-table td {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(16, 61, 80, 0.1);
  vertical-align: middle;
}

/* Sticky table headers */
.table-responsive thead th,
.erp-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(245, 249, 252, 0.96);
  backdrop-filter: blur(6px);
}

.erp-table th {
  color: #415064;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  background: rgba(245, 249, 252, 0.62);
}

.erp-table td {
  color: #2d3c4f;
  font-size: 14px;
}

.erp-table tbody tr:last-child td {
  border-bottom: 0;
}

.table-empty {
  height: 180px;
  text-align: center;
  color: var(--text-muted);
  font-weight: 700;
}

/* Sticky totals/footer row */
.erp-table tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 4;
  background: rgba(245, 249, 252, 0.96);
  font-weight: 800;
  border-top: 1px solid rgba(16, 61, 80, 0.12);
}

.table-message {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--brand-navy);
  font-weight: 700;
  background: rgba(255, 255, 255, 0.78);
}

.table-message.is-error,
.form-errors {
  color: #b91c43;
  background: rgba(255, 241, 242, 0.78);
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  min-width: 132px;
}

.table-action {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(16, 61, 80, 0.16);
  border-radius: 10px;
  color: var(--brand-navy);
  font-size: 13px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.76);
}

.table-action.danger {
  border-color: rgba(185, 28, 67, 0.18);
  color: #b91c43;
}

.muted-action {
  color: #8b9aad;
  font-size: 13px;
  font-weight: 700;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 100%;
  padding: 4px 10px;
  line-height: 1.4;
  border-radius: 999px;
  color: #006b78;
  font-size: 12px;
  font-weight: 800;
  background: rgba(209, 246, 244, 0.86);
}

.text-end {
  text-align: right;
}

.modal {
  z-index: 1120;
}

.modal-backdrop {
  z-index: 1110;
  background-color: #082638;
}

.modal-backdrop.show {
  opacity: 0.38;
}

.modal-glass .modal-dialog {
  position: relative;
  z-index: 1121;
}

.modal-glass .modal-content {
  max-height: calc(100dvh - 2 * var(--bs-modal-margin, 0.5rem));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.97), rgba(242, 249, 248, 0.94)),
    linear-gradient(120deg, rgba(0, 176, 176, 0.08), rgba(240, 176, 0, 0.06));
  box-shadow: 0 24px 70px rgba(8, 38, 56, 0.24);
  backdrop-filter: blur(24px) saturate(130%);
  -webkit-backdrop-filter: blur(24px) saturate(130%);
}

.modal-glass .modal-content > form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: inherit;
}

.modal-glass .modal-header,
.modal-glass .modal-footer {
  flex-shrink: 0;
  border-color: rgba(16, 61, 80, 0.12);
  background: rgba(255, 255, 255, 0.54);
}

.modal-glass .modal-header {
  min-height: 46px;
  padding: 8px 16px;
}

.modal-glass .modal-body {
  overflow-y: auto;
  min-height: 0;
  overscroll-behavior: contain;
  padding: 16px 18px;
}

.modal-glass .modal-footer {
  min-height: 48px;
  gap: 8px;
  padding: 8px 16px;
}

.modal-glass .modal-title {
  margin: 0;
  color: var(--brand-ink);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}

.modal-glass .btn-close {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  margin: -2px -4px -2px auto;
  padding: 0;
  border: 1px solid rgba(16, 61, 80, 0.22);
  border-radius: 10px;
  background-color: rgba(255, 255, 255, 0.72);
  background-size: 12px;
  opacity: 0.78;
  transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease, transform 0.18s ease;
}

.modal-glass .btn-close:hover,
.modal-glass .btn-close:focus {
  border-color: rgba(0, 143, 163, 0.58);
  background-color: rgba(227, 250, 249, 0.98);
  box-shadow: 0 8px 18px rgba(8, 38, 56, 0.14);
  opacity: 1;
  transform: translateY(-1px);
}

.modal-glass .modal-footer .btn-primary-glass,
.modal-glass .modal-footer .btn-secondary-glass,
.modal-glass .modal-footer .btn-danger-glass {
  min-height: 36px;
  padding: 7px 14px;
  border-radius: 10px;
}

.logout-confirm-body p {
  margin: 0;
  color: var(--text);
  font-weight: 700;
}

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

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

.form-grid.form-cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.form-grid-full {
  grid-column: 1 / -1;
}

.erp-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: #33445a;
  font-size: 13px;
  font-weight: 800;
}

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

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: #33445a;
  font-size: 13px;
  font-weight: 700;
}

.glass-input {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(16, 61, 80, 0.18);
  border-radius: 12px;
  padding: 9px 12px;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.86);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

textarea.glass-input {
  resize: vertical;
}

.glass-input:focus {
  border-color: rgba(0, 176, 176, 0.7);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(0, 176, 176, 0.16), 0 0 0 5px rgba(240, 176, 0, 0.08);
}

/* ── Premium Custom Select & Option Styles ── */
select.glass-input,
select.form-select,
select.form-control,
.erp-field select,
.filter-control select,
select.filter-control,
.kanban-card select,
select {
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  color-scheme: light;
  cursor: pointer;
  background-color: rgba(255, 255, 255, 0.94);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230f766e' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 14px center !important;
  background-size: 16px 16px !important;
  padding-right: 40px !important;
  border: 1px solid rgba(16, 61, 80, 0.18);
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.42;
  box-shadow: 0 1px 2px rgba(16, 61, 80, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  transition: border-color 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              background-color 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.18s ease;
  text-overflow: ellipsis;
  white-space: nowrap;
}

select.glass-input:hover,
select.form-select:hover,
select.form-control:hover,
.erp-field select:hover,
select:hover {
  background-color: #ffffff;
  border-color: rgba(0, 176, 176, 0.55);
  box-shadow: 0 3px 12px rgba(0, 128, 128, 0.09), inset 0 1px 0 #ffffff;
}

select.glass-input:focus,
select.form-select:focus,
select.form-control:focus,
.erp-field select:focus,
select:focus {
  outline: none !important;
  border-color: #00a8a8 !important;
  background-color: #ffffff !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2300a8a8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
  box-shadow: 0 0 0 3.5px rgba(0, 176, 176, 0.2), 0 2px 8px rgba(0, 128, 128, 0.08) !important;
}

select:disabled,
select.glass-input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  background-color: rgba(240, 244, 248, 0.75) !important;
  border-color: rgba(16, 61, 80, 0.12);
  box-shadow: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
}

/* ── Custom Option & Optgroup Styling ── */
select option {
  background-color: #ffffff;
  color: #1e293b;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 14px;
  line-height: 1.5;
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

select option:checked,
select option[selected] {
  background-color: #e6f6f7 !important;
  color: #0f766e !important;
  font-weight: 700;
}

select option:hover,
select option:focus {
  background-color: #f0fdfa !important;
  color: #0d9488 !important;
}

select option:disabled {
  color: #94a3b8 !important;
  background-color: #f8fafc;
  font-style: italic;
  font-weight: 400;
}

select optgroup {
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
  background-color: #f1f5f9;
  padding: 8px 12px;
}

/* ── Context-Specific Select Sizes ── */

/* Kanban card stage dropdown (card dropdown) */
.kanban-card select,
select[data-stage-change] {
  min-height: 32px !important;
  height: 32px;
  font-size: 12.5px !important;
  font-weight: 600;
  padding: 4px 28px 4px 10px !important;
  background-size: 13px 13px !important;
  background-position: right 9px center !important;
  border-radius: 8px;
  border-color: rgba(16, 61, 80, 0.14);
  background-color: rgba(255, 255, 255, 0.95);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.kanban-card select:hover,
select[data-stage-change]:hover {
  border-color: rgba(0, 176, 176, 0.6);
  background-color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 128, 128, 0.12);
}

.kanban-card select:focus,
select[data-stage-change]:focus {
  box-shadow: 0 0 0 3px rgba(0, 176, 176, 0.22), 0 2px 6px rgba(0, 128, 128, 0.1) !important;
}

/* Toolbar filters */
.toolbar-filters select.filter-control,
select.filter-control {
  min-height: 34px !important;
  height: 34px;
  font-size: 13px !important;
  font-weight: 600;
  padding: 5px 30px 5px 12px !important;
  background-size: 14px 14px !important;
  background-position: right 10px center !important;
  border-radius: 9px;
  border-color: rgba(16, 61, 80, 0.16);
  background-color: rgba(255, 255, 255, 0.92);
}

.toolbar-filters select.filter-control:hover,
select.filter-control:hover {
  border-color: rgba(0, 176, 176, 0.55);
  background-color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 128, 128, 0.1);
}

/* Compact table selects */
.erp-table select,
.table-action select {
  min-height: 30px !important;
  height: 30px;
  font-size: 12.5px !important;
  padding: 3px 26px 3px 8px !important;
  background-size: 12px 12px !important;
  background-position: right 8px center !important;
  border-radius: 7px;
}

/* ── Universal Custom Select System (replaces OS-native Cocoa popover menus) ── */
.custom-select-wrapper {
  position: relative;
  display: block;
  width: 100%;
}

@media (min-width: 769px) {
  .custom-select-wrapper.filter-control,
  .toolbar-filters .custom-select-wrapper {
    display: inline-flex !important;
    width: auto !important;
    flex-shrink: 0;
    vertical-align: middle;
  }
}

/* syncSortSelect / bộ lọc ẩn ô không dùng ở tab hiện tại: [hidden] phải thắng inline-flex ở trên. */
.custom-select-wrapper.filter-control[hidden],
.toolbar-filters .custom-select-wrapper[hidden] {
  display: none !important;
}

.custom-select-wrapper.w-auto {
  display: inline-block;
  width: auto;
}

/* Toolbar tabs without sorting hide the wrapper; override its display utilities. */
.custom-select-wrapper[hidden] {
  display: none !important;
}

/* Visually hide native select while preserving accessibility & form submission */
.custom-select-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Custom Trigger Button */
.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  padding: 8px 14px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  color: #1e293b;
  text-align: left;
  background-color: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(16, 61, 80, 0.16);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  user-select: none;
}

.custom-select-trigger:hover {
  border-color: rgba(0, 176, 176, 0.55);
  background-color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 128, 128, 0.1);
}

.custom-select-trigger:focus-visible,
.custom-select-trigger[aria-expanded="true"] {
  border-color: #00b0b0;
  box-shadow: 0 0 0 3px rgba(0, 176, 176, 0.22), 0 2px 6px rgba(0, 128, 128, 0.1);
  background-color: #ffffff;
}

.custom-select-trigger:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  background-color: rgba(240, 244, 248, 0.75) !important;
  border-color: rgba(16, 61, 80, 0.12) !important;
  box-shadow: none !important;
}

/* Toolbar Filter trigger size */
.toolbar-filters .custom-select-trigger,
.custom-select-wrapper.filter-control .custom-select-trigger {
  min-height: 34px !important;
  height: 34px !important;
  padding: 4px 10px 4px 12px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  border-radius: 9px !important;
  background-color: rgba(255, 255, 255, 0.94);
}

/* Kanban card select size */
.kanban-card .custom-select-trigger,
.custom-select-wrapper.kanban-select .custom-select-trigger {
  min-height: 32px !important;
  height: 32px !important;
  padding: 4px 10px !important;
  font-size: 12.5px !important;
  font-weight: 600 !important;
  border-radius: 8px !important;
}

/* Compact table select size */
.erp-table .custom-select-trigger,
.custom-select-wrapper.custom-select-sm .custom-select-trigger {
  min-height: 30px !important;
  height: 30px !important;
  padding: 3px 8px !important;
  font-size: 12.5px !important;
  border-radius: 7px !important;
}

.custom-select-value {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.custom-select-chevron {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: #64748b;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease;
}

.custom-select-trigger[aria-expanded="true"] .custom-select-chevron {
  transform: rotate(180deg);
  color: #00b0b0;
}

/* Keep the page still while a menu is open, so a drag scrolls the list. */
html.custom-select-scroll-lock,
html.custom-select-scroll-lock body {
  overflow: hidden !important;
  overscroll-behavior: none;
}

@media (max-width: 1024px) {
  html.custom-select-scroll-lock body {
    position: fixed;
    width: 100%;
    top: calc(var(--custom-select-scroll-y, 0px) * -1);
  }
}

/* Floating Popover (mounted to document.body) */
.custom-select-popover {
  position: fixed;
  z-index: 100050;
  display: flex;
  flex-direction: column;
  max-height: min(360px, calc(100dvh - 24px));
  overflow: hidden;
  overscroll-behavior: contain;
  touch-action: none;
  padding: 6px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(16, 61, 80, 0.16);
  border-radius: 12px;
  box-shadow: 0 14px 38px rgba(0, 32, 48, 0.18), 0 3px 12px rgba(0, 0, 0, 0.08);
  opacity: 0;
  transform: scale(0.96) translateY(-4px);
  transition: opacity 0.14s ease, transform 0.16s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  font-family: var(--font-sans);
}

.custom-select-popover.is-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.custom-select-popover-inner {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 2px;
}

/* Search bar inside popover */
.custom-select-search-wrap {
  flex: 0 0 auto;
  padding: 4px 4px 8px 4px;
  border-bottom: 1px solid rgba(16, 61, 80, 0.08);
  margin-bottom: 4px;
}

.custom-select-search {
  width: 100%;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  border: 1px solid rgba(16, 61, 80, 0.18);
  border-radius: 8px;
  background: #f8fafc;
  color: #0f172a;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
  touch-action: manipulation;
  transition: all 0.15s ease;
}

.custom-select-search:focus {
  border-color: #00b0b0;
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(0, 176, 176, 0.2);
}

/* Group header */
.custom-select-group-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  padding: 8px 10px 4px;
}

/* Option item */
.custom-select-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  color: #1e293b;
  cursor: pointer;
  text-align: left;
  outline: none;
  touch-action: pan-y;
  transition: all 0.12s ease;
}

.custom-select-item.is-filtered-out {
  display: none;
}

.custom-select-item:hover,
.custom-select-item:focus-visible {
  background-color: #f0fdfa;
  color: #0d9488;
}

.custom-select-item[aria-selected="true"] {
  background-color: #e6f6f7;
  color: #0f766e;
  font-weight: 600;
}

.custom-select-item:disabled,
.custom-select-item[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  background: transparent !important;
  color: #94a3b8 !important;
}

.custom-select-item-text {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.custom-select-item-check {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: #0d9488;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.custom-select-item[aria-selected="true"] .custom-select-item-check {
  opacity: 1;
}

/* ── Baseline Custom Styling for Native File Inputs ── */
input[type="file"] {
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: #334155;
  background-color: rgba(255, 255, 255, 0.9);
  border: 1.5px dashed rgba(16, 61, 80, 0.2);
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

input[type="file"]:hover {
  border-color: rgba(0, 176, 176, 0.55);
  background-color: #ffffff;
}

input[type="file"]:focus {
  outline: none;
  border-color: #00b0b0;
  box-shadow: 0 0 0 3px rgba(0, 176, 176, 0.2);
}

input[type="file"]::file-selector-button,
input[type="file"]::-webkit-file-upload-button {
  background: linear-gradient(135deg, #0d9488, #00b0b0);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  margin-right: 12px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 128, 128, 0.2);
  transition: all 0.15s ease;
}

input[type="file"]::file-selector-button:hover,
input[type="file"]::-webkit-file-upload-button:hover {
  background: linear-gradient(135deg, #0f766e, #0ea5e9);
  box-shadow: 0 4px 10px rgba(0, 128, 128, 0.3);
  transform: translateY(-1px);
}

/* ── Universal Drag & Drop File Upload Component ── */
.custom-file-dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 110px;
  padding: 16px 20px;
  border: 2px dashed rgba(16, 61, 80, 0.22);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  outline: none;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  box-sizing: border-box;
}

.custom-file-dropzone:hover {
  border-color: rgba(0, 176, 176, 0.65);
  background: rgba(240, 253, 250, 0.6);
  box-shadow: 0 4px 16px rgba(0, 128, 128, 0.08);
}

.custom-file-dropzone:focus-visible {
  border-color: #00b0b0;
  box-shadow: 0 0 0 3px rgba(0, 176, 176, 0.22);
}

.custom-file-dropzone.is-dragover {
  border-color: #00b0b0;
  border-style: solid;
  background: rgba(204, 251, 241, 0.75);
  transform: scale(1.01);
  box-shadow: 0 8px 24px rgba(0, 176, 176, 0.2);
}

.custom-file-dropzone.is-invalid {
  border-color: #ef4444 !important;
  background-color: rgba(254, 242, 242, 0.6) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18) !important;
}

.custom-file-dropzone.has-file {
  min-height: auto;
  padding: 8px;
  border-style: solid;
  border-color: rgba(16, 61, 80, 0.16);
  background: rgba(255, 255, 255, 0.95);
}

.custom-file-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Idle state inside dropzone */
.custom-file-idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  pointer-events: none;
}

.custom-file-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(0, 176, 176, 0.12);
  color: #0d9488;
  transition: transform 0.2s ease, background 0.2s ease;
}

.custom-file-dropzone:hover .custom-file-icon-wrap,
.custom-file-dropzone.is-dragover .custom-file-icon-wrap {
  transform: translateY(-2px) scale(1.08);
  background: rgba(0, 176, 176, 0.2);
  color: #0f766e;
}

.custom-file-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.custom-file-prompt {
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: #334155;
  line-height: 1.4;
}

.custom-file-prompt strong {
  color: #0d9488;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.custom-file-accept-hint {
  font-size: 11.5px;
  color: #64748b;
  font-weight: 500;
}

/* Selected state inside dropzone */
.custom-file-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 6px 10px;
}

.custom-file-thumb-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: rgba(0, 176, 176, 0.1);
  color: #0d9488;
  overflow: hidden;
  flex-shrink: 0;
}

.custom-file-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}

.custom-file-meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.custom-file-name {
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.custom-file-size {
  font-size: 11.5px;
  color: #64748b;
  font-weight: 500;
}

.custom-file-clear-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: rgba(241, 245, 249, 0.85);
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.custom-file-clear-btn:hover {
  background: #fee2e2;
  color: #ef4444;
  transform: scale(1.08);
}

.custom-file-list {
  display: grid;
  gap: 4px;
  max-height: 180px;
  margin: 6px 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.custom-file-list li,
.attachment-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  font-size: 12.5px;
}

.custom-file-list-name,
.attachment-list-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-file-list-size,
.attachment-list-meta {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 11.5px;
}

.custom-file-list-remove {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.custom-file-list-remove:hover {
  background: #fee2e2;
  color: #ef4444;
}

.erp-field small.custom-file-error {
  min-height: 0;
  margin-top: 4px;
}

/* Tệp đính kèm của bản ghi (static/ui/js/attachments.js) */
.attachment-field {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.attachment-field-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
}

.attachment-field-head > span {
  font-weight: 600;
}

.attachment-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.attachment-list a {
  color: inherit;
  text-decoration: none;
}

.attachment-list a:hover {
  color: var(--brand-blue);
  text-decoration: underline;
}

.attachment-list .table-action {
  flex-shrink: 0;
}

/* Cài đặt hệ thống → Lưu trữ */
.storage-meter {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
  box-shadow: inset 0 0 0 1px var(--line);
}

.storage-meter > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand-cyan);
  transition: width 0.3s ease;
}

.storage-meter.is-warning > span {
  background: #f59e0b;
}

.storage-meter.is-full > span {
  background: #ef4444;
}

.storage-usage-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 10px;
}

.storage-usage-head strong {
  font-size: 1.35rem;
}

.storage-breakdown {
  display: grid;
  gap: 6px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.storage-breakdown li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--line);
}

.storage-options {
  display: grid;
  gap: 12px;
}

.storage-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.storage-option input {
  margin-top: 4px;
  flex-shrink: 0;
}

.storage-option small {
  display: block;
  color: var(--text-muted);
}


.erp-field small {
  min-height: 16px;
  color: #b91c43;
  font-weight: 700;
}

.erp-field small.form-hint:not(.is-error) {
  color: var(--text-muted);
  font-weight: 500;
  line-height: 1.5;
}

.username-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.username-presets .btn {
  white-space: normal;
  text-align: left;
}

.erp-field.is-required > label:first-child::after {
  content: " *";
  color: #b91c43;
}

.form-errors {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 700;
}

/* ── Legacy login-screen (keep for backward compat) ── */
.login-screen {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
}

.login-card input {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(16, 61, 80, 0.18);
  border-radius: 12px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.86);
}

/* ── Split login layout ── */
.login-body {
  overflow: hidden;
}

.login-split {
  display: flex;
  width: 100%;
  max-width: 1200px;
  min-height: calc(100vh - 64px);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(7, 32, 48, 0.18), 0 0 0 1px rgba(0, 143, 163, 0.08);
}

/* Left hero panel */
.login-hero {
  flex: 0 0 46%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px 52px 36px;
  background:
    linear-gradient(155deg, rgba(0, 176, 176, 0.22) 0%, transparent 45%),
    linear-gradient(180deg, #072030 0%, #0b3a47 45%, #0e5060 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
}

.login-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 55% 40% at 85% 15%, rgba(240, 176, 0, 0.12) 0%, transparent 65%),
    radial-gradient(ellipse 70% 55% at 15% 105%, rgba(0, 176, 176, 0.28) 0%, transparent 65%);
  pointer-events: none;
}

.login-hero-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

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

.login-brand .brand-mark {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-brand .brand-mark img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.28));
}

.login-brand .brand-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.01em;
}

.login-brand .brand-subtitle {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.62);
  margin-top: 1px;
}

.login-hero-heading {
  font-size: clamp(1.65rem, 2.8vw, 2.2rem);
  font-weight: 800;
  line-height: 1.22;
  color: #fff;
  letter-spacing: -0.01em;
}

.login-hero-desc {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.68);
  line-height: 1.6;
  margin: 0;
}

.login-feature-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-feature-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: rgba(0, 176, 176, 0.1);
  border: 1px solid rgba(0, 176, 176, 0.22);
  border-radius: 14px;
  font-size: 0.845rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
}

.login-feature-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  background: rgba(0, 176, 176, 0.18);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #00d4d4;
}

.login-hero-footer {
  position: relative;
  z-index: 1;
  font-size: 0.76rem;
  color: rgba(255, 255, 255, 0.42);
}

/* Right form panel */
.login-form-panel {
  flex: 1;
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: relative;
}

.login-form-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 80px 56px 48px;
  max-width: 540px;
  width: 100%;
  margin: 0 auto;
}

.login-lang-bar {
  position: absolute;
  top: 24px;
  right: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-lang-label {
  font-size: 0.825rem;
  color: #6b7280;
}

.login-lang-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #374151;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  padding: 5px 12px 5px 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.login-lang-btn:hover {
  background: #f0fdfc;
  border-color: var(--brand-blue);
  color: var(--brand-blue);
}

.login-form-box {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.login-welcome-tag {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--brand-blue);
  text-transform: uppercase;
  margin: 0 0 10px;
}

.login-form-title {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--brand-ink);
  margin: 0 0 10px;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.login-form-desc {
  font-size: 0.845rem;
  color: #6b7280;
  line-height: 1.55;
  margin: 0 0 28px;
}

.login-error-box {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.845rem;
  color: #b91c1c;
  margin-bottom: 16px;
}

.login-error-action {
  display: inline-block;
  margin-top: 8px;
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
}

.login-field-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 18px;
}

.login-label {
  font-size: 0.845rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.login-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.login-label-row .login-label {
  margin-bottom: 0;
}

.login-forgot {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brand-blue);
  text-decoration: none;
}

.login-forgot:hover {
  text-decoration: underline;
}

.login-input {
  width: 100%;
  height: 46px;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  padding: 0 14px;
  font-size: 16px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.login-input:focus {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(0, 143, 163, 0.12);
}

.login-input::placeholder {
  color: #c4cdd4;
}

.login-input-error {
  border-color: #fca5a5;
}

.login-input-error:focus {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.login-field-error {
  font-size: 0.78rem;
  color: #dc2626;
  margin-top: 5px;
}

.login-password-wrap {
  position: relative;
}

.login-password-wrap .login-input {
  padding-right: 46px;
}

.login-eye-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 4px;
  color: #9ca3af;
  cursor: pointer;
  display: flex;
  align-items: center;
  line-height: 1;
}

.login-eye-btn:hover {
  color: var(--brand-blue);
}

.login-submit-btn {
  width: 100%;
  height: 48px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #0b3a47 0%, #008fa3 58%, #00b0b0 100%);
  box-shadow: 0 8px 24px rgba(0, 143, 163, 0.32), inset 0 -2px 0 rgba(240, 176, 0, 0.5);
  cursor: pointer;
  margin-top: 4px;
  margin-bottom: 24px;
  transition: opacity 0.15s, box-shadow 0.15s;
}

.login-submit-btn:hover {
  opacity: 0.9;
  box-shadow: 0 10px 28px rgba(0, 143, 163, 0.42), inset 0 -2px 0 rgba(240, 176, 0, 0.5);
}

/* Demo accounts */
.login-demo-box {
  background: #f8fafb;
  border: 1px solid #e9eef0;
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.login-demo-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--brand-navy);
  margin-bottom: 10px;
  letter-spacing: 0.01em;
}

.login-demo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 16px;
}

.login-demo-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.login-demo-role {
  font-size: 0.775rem;
  color: #6b7280;
}

.login-demo-user {
  font-size: 0.775rem;
  font-weight: 700;
  color: var(--brand-navy);
  font-family: 'Menlo', 'Consolas', monospace;
}

.login-demo-pw {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e9eef0;
  font-size: 0.775rem;
  color: #6b7280;
}

.login-demo-pw strong {
  color: var(--brand-navy);
  font-family: 'Menlo', 'Consolas', monospace;
}

.login-register-note {
  font-size: 0.82rem;
  color: #9ca3af;
  text-align: center;
  margin: 0;
}

/* Responsive & Chống iOS Safari tự động zoom in khi focus vào ô nhập */
@media screen and (max-width: 899px) {
  input,
  select,
  textarea,
  .login-input,
  .glass-input,
  .form-control,
  .form-select {
    font-size: 16px !important;
  }
}

@media (max-width: 820px) {
  body.login-body {
    padding: 16px;
    align-items: flex-start;
  }

  .login-split {
    flex-direction: column;
    border-radius: 16px;
    min-height: 0;
  }

  .login-hero {
    flex-basis: auto;
    padding: 28px;
  }

  .login-hero-inner {
    gap: 20px;
  }

  .login-hero .login-hero-stats,
  .login-feature-list,
  .login-hero-footer {
    display: none;
  }

  .login-form-inner {
    justify-content: flex-start;
    padding: 32px 28px 40px;
  }

  .login-lang-bar {
    position: static;
    align-self: flex-end;
    margin-bottom: 24px;
  }
}

@media (max-width: 480px) {
  body.login-body {
    padding: 0;
  }

  .login-split {
    border-radius: 0;
  }

  .login-hero {
    padding: 28px 20px;
  }

  .login-form-inner {
    padding: 24px 20px 32px;
  }
}

/* ════════════════════════════════
   Login page enhancements v2
   ════════════════════════════════ */

/* Decorative orb blobs */
.login-hero-deco {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.login-hero-deco-1 {
  width: 260px;
  height: 260px;
  top: -80px;
  right: -60px;
  background: radial-gradient(circle, rgba(0, 176, 176, 0.22) 0%, transparent 70%);
}
.login-hero-deco-2 {
  width: 190px;
  height: 190px;
  bottom: 50px;
  left: -55px;
  background: radial-gradient(circle, rgba(240, 176, 0, 0.15) 0%, transparent 70%);
}
.login-hero-deco-3 {
  width: 120px;
  height: 120px;
  top: 44%;
  right: 14px;
  background: radial-gradient(circle, rgba(0, 210, 210, 0.18) 0%, transparent 70%);
}

/* Stats bar */
.login-hero-stats {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 14px;
  padding: 14px 8px;
  backdrop-filter: blur(8px);
}
.login-stat-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.login-stat-num {
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  line-height: 1;
  letter-spacing: -0.02em;
}
.login-stat-label {
  font-size: 0.67rem;
  color: rgba(255, 255, 255, 0.52);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.login-stat-sep {
  width: 1px;
  height: 32px;
  background: rgba(255, 255, 255, 0.14);
  flex-shrink: 0;
}

/* Demo click-to-fill */
.login-demo-click-hint {
  font-size: 0.7rem;
  color: #9ca3af;
  font-weight: 400;
  font-style: italic;
}
.login-demo-row {
  cursor: pointer;
  border-radius: 6px;
  padding: 4px 6px;
  margin: -4px -6px;
  transition: background 0.15s;
}
.login-demo-row:hover {
  background: rgba(0, 143, 163, 0.09);
}
.login-demo-row:hover .login-demo-user {
  color: var(--brand-blue);
}

/* Submit button loading state */
.login-submit-btn.is-loading {
  opacity: 0.75;
  pointer-events: none;
}
@keyframes login-btn-spin {
  to { transform: rotate(360deg); }
}
.login-btn-spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: login-btn-spin 0.65s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
  margin-top: -2px;
}

/* Keyframe definitions */
@keyframes orb-drift {
  0%, 100% { transform: translate(0, 0); }
  33%  { transform: translate(18px, -24px); }
  66%  { transform: translate(-12px, 16px); }
}
@keyframes login-fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes heading-shimmer {
  to { background-position: 200% center; }
}
@keyframes brand-glow {
  0%, 100% { filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.28)); }
  50%       { filter: drop-shadow(0 4px 18px rgba(0, 176, 176, 0.55)); }
}

@media (prefers-reduced-motion: no-preference) {
  /* Floating orbs */
  .login-hero-deco-1 { animation: orb-drift 13s ease-in-out infinite; }
  .login-hero-deco-2 { animation: orb-drift 9s ease-in-out infinite reverse; animation-delay: -3s; }
  .login-hero-deco-3 { animation: orb-drift 7s ease-in-out infinite; animation-delay: -5s; }

  /* Hero heading shimmer */
  .login-hero-heading {
    background: linear-gradient(100deg, #fff 0%, #88fdfd 42%, #fff 76%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: heading-shimmer 6s linear infinite;
  }

  /* Logo glow pulse */
  .login-brand .brand-mark img {
    animation: brand-glow 4s ease-in-out infinite;
  }

  /* Feature card hover slide */
  .login-feature-card {
    transition: transform 0.22s ease, background 0.22s ease, border-color 0.22s ease;
  }
  .login-feature-card:hover {
    transform: translateX(6px);
    background: rgba(0, 176, 176, 0.18);
    border-color: rgba(0, 176, 176, 0.44);
  }

  /* Form entrance stagger */
  .login-welcome-tag   { animation: login-fade-up 0.5s 0.04s ease both; }
  .login-form-title    { animation: login-fade-up 0.5s 0.09s ease both; }
  .login-form-desc     { animation: login-fade-up 0.5s 0.14s ease both; }
  .login-field-group   { animation: login-fade-up 0.5s 0.20s ease both; }
  .login-submit-btn    { animation: login-fade-up 0.5s 0.28s ease both; }
  .login-demo-box      { animation: login-fade-up 0.5s 0.34s ease both; }
  .login-register-note { animation: login-fade-up 0.5s 0.40s ease both; }
}

.btn-primary-glass {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, #104050, var(--brand-blue) 58%, var(--brand-cyan));
  box-shadow: 0 14px 28px rgba(0, 143, 163, 0.22), inset 0 -2px 0 rgba(240, 176, 0, 0.72);
}

.btn-danger-glass {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  color: #ffffff;
  font-weight: 800;
  background: linear-gradient(135deg, #7f1d1d, #b91c43 58%, #e11d48);
  box-shadow: 0 14px 28px rgba(185, 28, 67, 0.2), inset 0 -2px 0 rgba(240, 176, 0, 0.42);
}

.btn-primary-glass:hover,
.btn-primary-glass:focus-visible {
  background: linear-gradient(135deg, #0b3140, #007d92 56%, #00b8b8);
  box-shadow: 0 16px 32px rgba(0, 143, 163, 0.32), inset 0 -2px 0 rgba(240, 176, 0, 0.88);
}

.btn-secondary-glass:focus-visible {
  border-color: rgba(0, 143, 163, 0.68);
  background: rgba(227, 250, 249, 0.98);
  box-shadow: 0 0 0 3px rgba(0, 176, 176, 0.18);
}

.btn-danger-glass:hover,
.btn-danger-glass:focus-visible {
  background: linear-gradient(135deg, #691616, #a50f35 56%, #d21242);
  box-shadow: 0 16px 32px rgba(185, 28, 67, 0.3), inset 0 -2px 0 rgba(240, 176, 0, 0.6);
}

.toolbar-actions .btn-primary-glass,
.toolbar-actions .btn-secondary-glass,
.toolbar-actions .btn-danger-glass {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  gap: 6px;
  font-size: 14px;
  line-height: 1;
}

.toolbar-actions .btn-primary-glass {
  box-shadow: 0 8px 18px rgba(0, 143, 163, 0.18), inset 0 -2px 0 rgba(240, 176, 0, 0.68);
}

.toolbar-actions .btn-secondary-glass {
  border-color: rgba(16, 61, 80, 0.2);
}

.toolbar-actions .btn-primary-glass svg,
.toolbar-actions .btn-secondary-glass svg,
.toolbar-actions .btn-danger-glass svg {
  width: 16px;
  height: 16px;
}

.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(16, 61, 80, 0.34);
}

.sidebar .custom-scrollbar::-webkit-scrollbar-thumb,
.nav-list::-webkit-scrollbar-thumb {
  background: rgba(0, 176, 176, 0.46);
}

@keyframes reveal-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

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

@media (prefers-reduced-motion: no-preference) {
  .sidebar,
  .topbar,
  .workspace-tabs,
  .module-toolbar,
  .kpi-card,
  .erp-panel {
    animation: reveal-up 0.42s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  }

  .topbar {
    animation-delay: 0.04s;
  }

  .workspace-tabs,
  .module-toolbar {
    animation-delay: 0.08s;
  }

  .kpi-card,
  .erp-panel {
    animation-delay: 0.12s;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

@media (max-width: 1024px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 10px;
  }

  /* Sidebar dùng Bootstrap offcanvas trượt từ trái */
  .sidebar.offcanvas {
    --bs-offcanvas-width: min(86vw, 360px);
    width: var(--bs-offcanvas-width);
    flex: none;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: none;
    padding: 18px;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .sidebar.offcanvas.show,
  .sidebar.offcanvas.showing {
    box-shadow: 6px 0 40px rgba(0, 0, 0, 0.45);
  }

  .sidebar-close-button {
    display: grid;
  }

  /* Override desktop sidebar-collapsed rules trên mobile */
  body.sidebar-collapsed .app-shell {
    gap: 12px;
  }

  body.sidebar-collapsed .sidebar.offcanvas {
    width: var(--bs-offcanvas-width);
    flex-basis: auto;
    padding: 18px;
    border-width: 1px;
    opacity: 1;
    pointer-events: auto;
  }

  .offcanvas-backdrop.show {
    opacity: 0.55;
    background: #082638;
  }

  .nav-list {
    max-height: calc(100vh - 140px);
    max-height: calc(100dvh - 140px);
  }

  .module-container {
    height: auto;
    flex: none;
    overflow: visible;
    padding-right: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .app-bg {
    overflow: clip;
  }

  .topbar.glass-panel {
    position: sticky;
    top: 8px;
  }

  .workspace-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
    scroll-padding-inline: 8px;
  }

  .workspace-tab {
    flex-shrink: 0;
    min-height: 44px;
    white-space: nowrap;
  }

  .module-toolbar {
    flex-wrap: wrap;
    padding: 12px;
  }

  .toolbar-filter-scroll {
    flex-basis: 100%;
    order: 2;
  }

  .erp-table {
    min-width: 720px;
  }

  .erp-table th,
  .erp-table td {
    padding: 12px;
  }

  .erp-table th,
  .erp-table .status-badge,
  .erp-table .table-action {
    white-space: nowrap;
  }

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

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

@media (min-width: 1025px) and (max-width: 1199px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Tablet and up: expand form grids */
@media (min-width: 768px) {
  .form-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1200px) {
  .form-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-shell {
    gap: 10px;
    padding: 8px;
  }

  .app-main,
  .erp-module,
  .workspace-panel {
    gap: 12px;
  }

  .erp-panel,
  .kpi-card {
    padding: 16px;
  }

  .module-toolbar {
    align-items: center;
    gap: 12px;
  }

  .topbar {
    min-height: 56px;
    align-items: center;
    flex-direction: row;
    gap: 8px;
    padding: 8px 10px;
  }

  .topbar-heading {
    flex: 1 1 auto;
    min-width: 0;
    gap: 8px;
  }

  .topbar h1 {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 18px;
  }

  .topbar-actions {
    flex: 0 0 auto;
    align-items: center;
    flex-direction: row;
    gap: 6px;
  }

  .account-button {
    width: 40px;
    min-width: 40px;
    min-height: 40px;
    justify-content: center;
    gap: 0;
    padding: 2px;
    border-radius: 10px;
  }

  .account-button::after,
  .account-label {
    display: none;
  }

  .account-avatar {
    width: 26px;
    height: 26px;
    flex-basis: 26px;
  }

  .icon-button {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
  }

  .module-toolbar,
  .toolbar-filter-scroll,
  .toolbar-filters {
    width: 100%;
  }

  .toolbar-context {
    flex: 1 1 100px;
    min-width: 0;
    max-width: none;
  }

  .toolbar-context strong {
    white-space: normal;
  }

  .toolbar-actions {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .toolbar-actions .btn {
    min-height: 38px;
    padding: 7px 12px;
    font-size: 13px;
  }

  .toolbar-scroll-button {
    display: none;
  }

  .toolbar-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    justify-items: stretch;
    overflow: visible;
  }

  .toolbar-filters > * {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    justify-self: stretch !important;
  }

  .toolbar-filters .filter-control,
  .toolbar-filters .filter-control.search {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    min-height: 38px;
    font-size: 16px;
  }

  .toolbar-filters .custom-select-wrapper,
  .toolbar-filters .custom-select-wrapper.filter-control {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 0 !important;
  }

  .toolbar-filters .custom-select-trigger,
  .toolbar-filters .custom-select-wrapper.filter-control .custom-select-trigger {
    flex: 1 1 auto;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
  }

  .filter-control.search,
  .toolbar-filters > :only-child {
    grid-column: 1 / -1;
  }

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

  .kpi-card {
    padding: 14px 12px;
  }

  .kpi-card strong {
    font-size: clamp(18px, 4.6vw, 28px);
  }

  .kpi-trend {
    font-size: 11px;
  }

  .table-responsive::before {
    content: "Vuốt ngang để xem đầy đủ các cột →";
    position: sticky;
    left: 0;
    display: block;
    width: fit-content;
    max-width: 100%;
    margin-bottom: 12px;
    color: var(--text-muted);
    font-size: 12px;
  }

  .chart:not(.chart--sm) {
    height: 280px;
  }

  .glass-input {
    min-width: 0;
    font-size: 16px;
    min-height: 38px;
    padding: 8px 10px;
  }

  .notification-dropdown {
    max-height: calc(100dvh - 88px);
  }

  .notification-list {
    max-height: none;
  }

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

  .modal-glass .modal-dialog {
    margin: 8px;
  }

  .modal-glass .modal-content {
    max-height: calc(100dvh - 16px);
  }

  .modal-glass .modal-body {
    padding: 16px;
  }

  .modal-glass .modal-header,
  .modal-glass .modal-footer {
    padding: 8px 14px;
  }
}

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

  .toolbar-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

/* G1 — order tracking (PRJ-18) and aging (FIN-15) */
.status-badge--danger {
  color: #9f1239;
  background: rgba(255, 228, 230, 0.92);
}

.flow-bars {
  display: grid;
  grid-template-columns: repeat(3, minmax(44px, 1fr));
  gap: 4px;
  min-width: 156px;
}

.flow-bar {
  display: block;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(16, 61, 80, 0.1);
}

.flow-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-cyan), var(--brand-blue));
}

.flow-bar:nth-child(2) i { background: linear-gradient(90deg, var(--brand-gold), #e59a00); }
.flow-bar:nth-child(3) i { background: linear-gradient(90deg, #22a06b, #13795b); }
.flow-bar--na { background: repeating-linear-gradient(45deg, rgba(16, 61, 80, 0.06) 0 4px, rgba(16, 61, 80, 0.12) 4px 8px); }

.flow-caption {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 12px;
}

/* Mobile: tighter chrome so more rows fit. Inputs stay 16px so iOS Safari does not zoom on focus. */
@media (max-width: 768px) {
  .app-shell {
    gap: 8px;
    padding: 6px;
  }

  .app-main,
  .erp-module,
  .workspace-panel {
    gap: 8px;
  }

  .glass-panel {
    border-radius: 14px;
  }

  .topbar {
    height: 46px;
    min-height: 46px;
    gap: 6px;
    padding: 4px 8px;
  }

  .topbar.glass-panel {
    top: 4px;
  }

  .topbar.glass-panel::before {
    top: 6px;
    bottom: 6px;
  }

  .topbar h1 {
    font-size: 16px;
  }

  .topbar-heading,
  .topbar-actions {
    gap: 6px;
  }

  .icon-button,
  .account-button {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
  }

  .account-avatar {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
  }

  .workspace-tabs {
    gap: 6px;
    padding: 4px;
  }

  .workspace-tab {
    min-height: 36px;
    padding: 0 10px;
    gap: 6px;
    font-size: 13px;
    border-radius: 999px;
  }

  .sidebar.offcanvas,
  body.sidebar-collapsed .sidebar.offcanvas {
    --bs-offcanvas-width: min(80vw, 300px);
    /* 5px + the 1px panel border lines the brand row up with the navbar under the shell padding. */
    padding: 5px 10px 10px;
  }

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

  .brand-mark {
    width: 26px;
    height: 26px;
    flex-basis: 26px;
  }

  .brand-title {
    font-size: 15px;
    line-height: 1.1;
  }

  .brand-subtitle {
    font-size: 10px;
    line-height: 1.15;
  }

  .sidebar.offcanvas .sidebar-close-button {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    padding: 0;
    place-items: center;
  }

  .sidebar-search {
    margin-top: 6px;
  }

  .sidebar-search-input {
    height: 36px;
    font-size: 16px;
  }

  .nav-list {
    gap: 2px;
    margin-top: 6px;
  }

  .account-dropdown {
    width: min(280px, calc(100vw - 16px));
    padding: 4px;
    border-radius: 12px;
  }

  .account-dropdown-header {
    gap: 0;
    padding: 4px 8px 4px;
  }

  .account-dropdown-header strong {
    font-size: 13px;
  }

  .account-dropdown-meta {
    padding: 1px 8px;
  }

  .account-dropdown-action {
    min-height: 32px;
  }

  .account-dropdown .dropdown-item {
    padding: 5px 8px;
    font-size: 13px;
  }

  .account-dropdown .dropdown-divider {
    margin: 4px 0;
  }

  .account-language {
    padding: 4px 8px;
  }

  .account-dropdown .language-picker {
    min-width: 0;
  }

  .account-dropdown .language-picker-trigger {
    min-height: 36px;
    padding: 4px 8px;
    font-size: 16px;
  }

  .nav-item {
    min-height: 36px;
    padding: 6px 8px;
    gap: 8px;
    font-size: 14px;
  }

  .nav-item svg {
    width: 16px;
    height: 16px;
  }

  .sub-item {
    min-height: 32px;
    padding: 5px 8px;
    font-size: 13px;
  }

  .submenu-list {
    margin-left: 14px;
    padding-left: 10px;
    gap: 2px;
  }

  .nav-group.expanded .submenu-list {
    margin-bottom: 2px;
  }

  .erp-panel,
  .kpi-card {
    padding: 10px;
  }

  .erp-panel {
    margin-top: 8px;
  }

  .erp-panel > p {
    margin-bottom: 8px;
  }

  .erp-panel h2,
  .module-toolbar h2 {
    font-size: 15px;
  }

  .module-toolbar {
    padding: 8px 10px;
    gap: 8px;
  }

  .kpi-grid {
    gap: 8px;
  }

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

  .erp-field {
    gap: 4px;
    font-size: 13px;
  }

  .glass-input,
  .form-control,
  .form-select {
    min-height: 36px;
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 16px;
  }

  .toolbar-filters {
    gap: 6px;
  }

  .toolbar-filters .filter-control,
  .toolbar-filters .filter-control.search {
    min-height: 36px;
    padding: 6px 8px;
    font-size: 16px;
  }

  .toolbar-filters [data-clear-filters] {
    width: 100%;
    min-height: 36px;
    margin: 0 !important;
  }

  .toolbar-actions .btn {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 13px;
  }

  .erp-table th,
  .erp-table td {
    padding: 7px 6px;
  }

  .erp-table th {
    font-size: 12px;
  }

  .erp-table td {
    font-size: 13px;
  }

  .btn,
  .btn-primary-glass,
  .btn-secondary-glass,
  .btn-danger-glass {
    min-height: 36px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .modal-glass .modal-dialog {
    margin: 6px;
  }

  .modal-glass .modal-body {
    padding: 12px;
  }

  .modal-glass .modal-header {
    min-height: 40px;
  }

  .modal-glass .modal-footer {
    min-height: 44px;
  }

  .modal-glass .modal-header,
  .modal-glass .modal-footer {
    padding: 6px 12px;
  }

  .modal-glass .modal-title {
    font-size: 16px;
  }

  .modal-glass .btn-close {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
  }

  select.glass-input,
  select.filter-control,
  .toolbar-filters select.filter-control,
  .erp-field select,
  .erp-table select,
  .table-action select,
  select.form-select,
  select.form-control {
    height: auto;
    min-height: 36px !important;
    padding: 6px 28px 6px 8px !important;
    padding-right: 28px !important;
    background-position: right 6px center !important;
    background-size: 14px 14px !important;
    font-size: 16px !important;
  }

  .toolbar-filters > .custom-select-wrapper,
  .custom-select-wrapper.filter-control,
  .toolbar-filters .custom-select-wrapper {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    justify-self: stretch !important;
    padding: 0 !important;
  }

  .toolbar-filters .custom-select-trigger,
  .custom-select-wrapper.filter-control .custom-select-trigger {
    flex: 1 1 auto;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 36px !important;
    font-size: 16px !important;
    box-sizing: border-box;
  }

  .toolbar-filters .custom-select-wrapper[hidden],
  .toolbar-filters .custom-select-wrapper.filter-control[hidden],
  .custom-select-wrapper.filter-control[hidden] {
    display: none !important;
  }

  .form-grid > *,
  .toolbar-filters > *,
  .erp-field,
  .filter-control,
  .aging-controls,
  .aging-controls > * {
    min-width: 0;
    max-width: 100%;
  }

  input[type="date"],
  input[type="datetime-local"],
  input[type="time"],
  input[type="month"],
  input[type="week"] {
    position: relative;
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0 !important;
    min-inline-size: 0;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    line-height: 1.2;
    background-color: rgba(255, 255, 255, 0.94);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230f766e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px 16px;
    padding-right: 28px;
  }

  input[type="date"]::-webkit-datetime-edit,
  input[type="datetime-local"]::-webkit-datetime-edit,
  input[type="time"]::-webkit-datetime-edit,
  input[type="month"]::-webkit-datetime-edit,
  input[type="date"]::-webkit-datetime-edit-fields-wrapper,
  input[type="datetime-local"]::-webkit-datetime-edit-fields-wrapper,
  input[type="time"]::-webkit-datetime-edit-fields-wrapper,
  input[type="date"]::-webkit-date-and-time-value,
  input[type="datetime-local"]::-webkit-date-and-time-value,
  input[type="time"]::-webkit-date-and-time-value {
    min-width: 0;
    padding: 0;
    text-align: left;
  }

  input[type="date"]::-webkit-calendar-picker-indicator,
  input[type="datetime-local"]::-webkit-calendar-picker-indicator,
  input[type="time"]::-webkit-calendar-picker-indicator,
  input[type="month"]::-webkit-calendar-picker-indicator {
    position: absolute;
    top: 0;
    right: 0;
    width: 32px;
    height: 100%;
    margin: 0;
    padding: 0;
    opacity: 0;
    cursor: pointer;
  }
}

/* Utility: company logo preview image */
.company-logo-preview {
  max-width: 180px;
  max-height: 90px;
  object-fit: contain;
}
.tracking-stages {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.stage-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  color: var(--brand-navy);
  background: rgba(16, 61, 80, 0.08);
}

.stage-chip b { font-weight: 900; }
.stage-chip--approved, .stage-chip--delivering { color: #006b78; background: rgba(209, 246, 244, 0.86); }
.stage-chip--delivered, .stage-chip--invoiced { color: #8a5a00; background: rgba(255, 243, 205, 0.92); }
.stage-chip--paid { color: #13795b; background: rgba(214, 245, 228, 0.92); }
.stage-chip--cancelled { color: #9f1239; background: rgba(255, 228, 230, 0.92); }

.aging-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.aging-head h2 { margin-bottom: 4px; }

.aging-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

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

@media (max-width: 1024px) {
  .kpi-grid--aging { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

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

/* G2 — service contracts (E18 BIL) */
.contract-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 20px;
}

.contract-summary > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.contract-summary small { color: var(--text-muted); }

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

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

/* Ô bắt buộc: dấu * đỏ tự gắn theo thuộc tính required (hoặc class is-required cho ô chỉ bắt buộc khi đang hiện). */
.erp-field:has(> :is(input, select, textarea):required) > span:first-child::after,
.erp-field.is-required > span:first-child::after {
  content: " *";
  color: #dc2626;
}

/* Account language controls, including Chinese font fallbacks. */
body { font-family: var(--font-sans); }
.language-switcher, .language-switcher label { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.language-switcher { font-size: .8rem; }
.language-switcher select, .language-switcher button { min-height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: #fff; color: var(--text); }
.language-switcher button { color: var(--brand-blue); font-weight: 600; }
.language-switcher [hidden] { display: none !important; }
.language-picker { position: relative; min-width: 172px; max-width: 100%; }
.language-switcher .language-picker-trigger { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; min-height: 40px; padding: 9px 12px; border-radius: 10px; background: var(--surface-strong); color: var(--text); font: inherit; cursor: pointer; }
.language-picker-value { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.language-picker-flag { display: block; flex: 0 0 24px; width: 24px; height: 16px; object-fit: cover; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }
.language-picker-chevron { flex-shrink: 0; transition: transform .15s ease; }
.language-picker-trigger[aria-expanded="true"] .language-picker-chevron { transform: rotate(180deg); }
.language-picker-options { position: absolute; inset: calc(100% + 6px) 0 auto; z-index: 1080; min-width: 180px; max-height: min(240px, calc(100dvh - 24px)); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; padding: 5px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-strong); backdrop-filter: blur(16px); box-shadow: 0 12px 32px rgba(11,46,63,.16); }
.language-switcher .language-picker-option { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; padding: 10px 8px; border: 0; border-radius: 7px; background: transparent; color: var(--text); font: inherit; text-align: start; cursor: pointer; }
.language-picker-check { flex-shrink: 0; opacity: 0; color: var(--brand-blue); }
.language-picker-option[aria-selected="true"] { font-weight: 600; }
.language-picker-option[aria-selected="true"] .language-picker-check { opacity: 1; }
.language-switcher .language-picker-option:hover, .language-switcher .language-picker-option:focus-visible { background: var(--surface-muted); outline: none; }
.language-switcher .language-picker-trigger:focus-visible, .language-picker-trigger[aria-expanded="true"] { outline: 2px solid var(--brand-blue); outline-offset: 2px; }
.signup-language-bar { display: flex; justify-content: flex-end; margin-bottom: 24px; }
.account-language { padding: 12px 16px; }
@media (max-width: 768px) {
  .account-language { padding: 4px 8px; }
  .account-dropdown .language-switcher .language-picker-trigger {
    min-height: 36px;
    gap: 8px;
    padding: 4px 8px;
    font-size: 16px;
  }
}
html[lang="zh-hans"] .login-welcome-tag { letter-spacing: .02em; }

/* CRM-08 — Đi thị trường (check-in/check-out tại khách) */
.visit-me {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.visit-me__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
}

.visit-me__text strong {
  font-size: 17px;
  color: var(--brand-ink);
}

.visit-me__text small {
  color: var(--text-muted);
}

.visit-location-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.visit-location {
  flex: 1 1 220px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.visit-location.is-ready {
  color: #007a66;
}

.visit-location.is-error,
.form-hint.is-error {
  color: #9f1239;
}

.visit-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 700;
}

.visit-flags,
.visit-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

.visit-actions {
  justify-content: flex-end;
}

.status-badge--warning {
  color: #92400e;
  background: rgba(254, 243, 199, 0.95);
}

.status-badge--muted {
  color: var(--text-muted);
  background: rgba(16, 61, 80, 0.06);
}

@media (max-width: 575.98px) {
  .visit-me .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .login-demo-grid { grid-template-columns: minmax(0, 1fr); }
  .login-demo-row { gap: 12px; }
}

/* CRM-08b — kế hoạch tuyến, bản đồ đội, lịch sử toạ độ */
.location-history {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(16, 61, 80, 0.05);
  font-size: 12px;
}

.location-history ul {
  margin: 6px 0 0;
  padding-left: 18px;
  color: var(--text-muted);
}

.visit-route {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
  width: 100%;
}

.visit-route li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line, rgba(16, 61, 80, 0.1));
}

.visit-route li > span {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.visit-route small {
  color: var(--text-muted);
}

.status-badge--success {
  color: #046c4e;
  background: rgba(209, 250, 229, 0.95);
}

.team-map {
  height: 420px;
  margin-top: 12px;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(16, 61, 80, 0.05);
}

.team-map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.team-map-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 50%;
  vertical-align: middle;
}

.route-week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.route-week-nav__buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.route-grid th,
.route-grid td {
  min-width: 132px;
  vertical-align: top;
}

.route-grid td:first-child,
.route-grid th:first-child {
  min-width: 120px;
}

.route-grid .is-today {
  background: rgba(0, 176, 176, 0.07);
}

.route-stop {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 6px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(16, 61, 80, 0.06);
}

.route-stop--visited { background: rgba(209, 250, 229, 0.95); color: #046c4e; }
.route-stop--missed { background: rgba(255, 228, 230, 0.92); color: #9f1239; }

.route-stop button {
  border: 0;
  background: transparent;
  color: inherit;
  line-height: 1;
  padding: 0 2px;
}

.route-add {
  width: 100%;
  border: 1px dashed rgba(16, 61, 80, 0.25);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  padding: 4px;
}

.customer-picker {
  max-height: min(260px, 45dvh);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--line, rgba(16, 61, 80, 0.12));
}

.customer-picker label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 4px 0;
  font-size: 13px;
}

.customer-picker small {
  color: var(--text-muted);
}

@media (max-width: 575.98px) {
  .team-map { height: 320px; }
  .visit-route li { flex-wrap: wrap; }
  .visit-route li .btn { width: 100%; }
}

/* CRM-08d — check-in khách hàng / khách tiềm năng / khách mới */
.visit-target-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(16, 61, 80, 0.06);
}

.visit-target-switch label {
  margin: 0;
  cursor: pointer;
}

.visit-target-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.visit-target-switch span {
  display: block;
  padding: 8px 6px;
  border-radius: 9px;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  color: var(--text-muted);
}

.visit-target-switch input:checked + span {
  background: #fff;
  color: var(--brand-ink);
  box-shadow: 0 2px 8px rgba(8, 38, 56, 0.12);
}

.visit-target-switch input:focus-visible + span {
  outline: 2px solid var(--brand-cyan);
  outline-offset: 1px;
}

/* CRM-08e — địa điểm khác của khách, nơi hẹn, khách tiềm năng trong tuyến */
.customer-locations {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line, rgba(16, 61, 80, 0.12));
}

.customer-locations__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.customer-location-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
}

.customer-location-row .btn {
  white-space: nowrap;
}

.route-stop__kind {
  display: inline-block;
  margin-right: 4px;
  padding: 0 4px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  background: rgba(124, 58, 237, 0.12);
  color: #6d28d9;
}

.customer-picker__group {
  margin: 6px 0 2px;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
}

@media (max-width: 767.98px) {
  .customer-location-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--line, rgba(16, 61, 80, 0.12));
  }

  .customer-location-row input[name="loc_name"],
  .customer-location-row input[name="loc_address"] {
    grid-column: 1 / -1;
  }
}

/* Notifications live outside the scrolling workspace and above modal dialogs. */
.erp-offline-notice {
  position: fixed;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  z-index: 1230;
  width: fit-content;
  max-width: 640px;
  margin-inline: auto;
  padding: 12px 16px;
  border: 1px solid #a16207;
  border-radius: 12px;
  background: #fffbeb;
  color: #713f12;
  box-shadow: 0 8px 24px rgba(8, 38, 56, .18);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  pointer-events: none;
}

.erp-offline-notice[hidden] { display: none; }

.erp-toast-region {
  position: fixed;
  bottom: max(1rem, env(safe-area-inset-bottom));
  right: max(1rem, env(safe-area-inset-right));
  z-index: 1100;
  display: grid;
  gap: .75rem;
  width: min(420px, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  pointer-events: none;
}
.erp-toast {
  --toast-color: #1d4ed8;
  --toast-bg: #eff6ff;
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: 1rem;
  border: 1px solid var(--toast-color);
  border-left-width: 5px;
  border-radius: 14px;
  background: var(--toast-bg);
  color: #172b3a;
  box-shadow: 0 10px 30px #102a4326;
  pointer-events: none;
}
.erp-toast--success { --toast-color: #15803d; --toast-bg: #f0fdf4; }
.erp-toast--error { --toast-color: #b91c1c; --toast-bg: #fef2f2; }
.erp-toast--warning { --toast-color: #a16207; --toast-bg: #fffbeb; }
.erp-toast-icon { color: var(--toast-color); font-weight: 800; font-size: 1.25rem; }
.erp-toast-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.erp-toast-body strong { color: var(--toast-color); }
.erp-toast-body p { margin: .25rem 0 0; }
.erp-toast-close { pointer-events: auto; border: 0; background: transparent; color: inherit; font-size: 1.5rem; line-height: 1; padding: .25rem; }
.erp-toast-close:focus-visible { outline: 2px solid var(--toast-color); outline-offset: 2px; }

/* Phân trang bảng (App_Core.api.list_response + workspace.js renderPager) */
.table-pager { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; padding: .75rem .25rem 0; color: var(--text-muted); font-size: .875rem; flex-wrap: wrap; }
.table-pager-info { margin-right: auto; }
.table-pager .btn { min-width: 2.25rem; display: inline-flex; align-items: center; justify-content: center; padding: .25rem .5rem; }
.table-pager .btn svg { width: 1rem; height: 1rem; }

/* Tìm kiếm chung trên header (global_search.js) */
.global-search { position: relative; display: flex; align-items: center; }
.global-search-icon { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
.global-search-input { width: 260px; min-height: 36px; padding-left: 32px; transition: width .2s ease; }
.global-search-input:focus { width: 340px; }
.global-search-results { position: absolute; top: calc(100% + 6px); right: 0; z-index: 1220; width: min(420px, calc(100vw - 24px)); max-height: min(480px, calc(100dvh - 96px)); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-strong); color: var(--text); box-shadow: 0 18px 48px rgba(8, 38, 56, .18); }
.global-search-group + .global-search-group { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); }
.global-search-group-label { padding: 4px 8px; color: var(--text-muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.global-search-item { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; padding: 7px 8px; border-radius: 10px; color: inherit; text-decoration: none; }
.global-search-item:hover, .global-search-item.is-active { background: var(--surface-muted); }
.global-search-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.global-search-subtitle { grid-column: 1; color: var(--text-muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.global-search-amount { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-variant-numeric: tabular-nums; }
.global-search-empty { padding: 12px 8px; color: var(--text-muted); }
@media (max-width: 1024px) {
  .global-search-input { width: 180px; }
  .global-search-input:focus { width: 240px; }
}
@media (max-width: 640px) {
  .global-search { position: relative; display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 36px; }
  .global-search-input { width: 36px; height: 36px; min-width: 36px; min-height: 36px; padding: 0; color: transparent; cursor: pointer; }
  .global-search-input::placeholder { color: transparent; }
  .global-search-icon { left: 50%; top: 50%; right: auto; margin: 0; width: 16px; height: 16px; transform: translate(-50%, -50%); }
  .global-search-input:focus { position: absolute; top: 0; right: 0; left: auto; width: min(320px, calc(100vw - 16px)); height: 36px; z-index: 5; color: var(--text); cursor: text; padding-left: 32px; transform: none; }
  .global-search:focus-within .global-search-icon { left: calc(36px - min(320px, 100vw - 16px) + 10px); z-index: 6; transform: translateY(-50%); }
  .global-search-input:focus::placeholder { color: var(--text-muted); }
  .global-search-results { left: 10px; right: 10px; width: auto; top: 100%; }
}

/* CORE-14: Cài đặt › Nhập dữ liệu Excel */
.import-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.import-card { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-muted); }
.import-card h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 16px; font-weight: 800; }
.import-card h3 svg { width: 18px; height: 18px; }
.import-card p { margin: 0; color: var(--text-muted); font-size: 13px; }
.import-form { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.import-form .btn { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; }
.import-form .btn svg, .import-actions .btn svg { width: 16px; height: 16px; }
.import-result { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.import-result h4 { margin: 0; font-size: 15px; font-weight: 800; }
.import-result h5 { margin: 6px 0 0; font-size: 14px; font-weight: 700; }
.import-done { display: flex; align-items: center; gap: 6px; color: #15803d; font-weight: 700; }
.import-actions .btn { display: inline-flex; align-items: center; gap: 6px; }

/* Hướng dẫn cho công ty mới trên trang Tổng quan (onboarding.js) */
.onboarding-card { padding: 16px 18px; margin-bottom: 14px; }
.onboarding-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.onboarding-head h2 { margin: 0 0 2px; font-size: 18px; font-weight: 800; color: var(--brand-ink); }
.onboarding-head p { margin: 0; color: var(--text-muted); }
.onboarding-progress { height: 6px; margin: 12px 0; border-radius: 999px; background: var(--surface-muted); overflow: hidden; }
.onboarding-progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand-cyan), var(--brand-blue)); }
.onboarding-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 8px; }
.onboarding-step { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-strong); }
.onboarding-step > svg { width: 20px; height: 20px; margin-top: 1px; color: var(--text-muted); }
.onboarding-step.is-done > svg { color: #15803d; }
.onboarding-step.is-done strong { text-decoration: line-through; color: var(--text-muted); }
.onboarding-step strong { display: block; }
.onboarding-step small { display: block; color: var(--text-muted); }
.onboarding-step-actions { grid-column: 2; display: flex; gap: 6px; flex-wrap: wrap; }
.onboarding-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.onboarding-foot small { color: var(--text-muted); flex: 1 1 240px; }
.onboarding-foot .btn { display: inline-flex; align-items: center; gap: 6px; }
.onboarding-foot .btn svg { width: 16px; height: 16px; }
/* Related-record guidance and quick creation, shared by every workspace. */
.form-grid:has(.related-field) > .erp-field > span:first-child,
.related-field > span:first-child {
  display: flex;
  align-items: center;
  min-height: 28px;
}
.form-grid:has(.related-field) > .erp-field > span:first-child::after {
  margin-inline-start: 3px;
}
.related-field-actions {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 4px;
  margin-inline-start: 8px;
  vertical-align: middle;
}
.related-field-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--brand-ink);
  cursor: pointer;
}
.related-field-button svg { width: 18px; height: 18px; }
.related-field-button:hover { color: #008c9e; border-color: currentColor; }
.related-field-button:focus-visible { outline: 2px solid #00a8b5; outline-offset: 2px; }
.related-field-button:disabled { opacity: .45; cursor: default; }
.related-field-popover {
  --bs-popover-bg: #fff;
  --bs-popover-body-color: #163444;
  --bs-popover-border-color: #087f8c;
  --bs-popover-border-width: 2px;
  --bs-popover-header-bg: #12566a;
  --bs-popover-header-color: #fff;
  --bs-popover-max-width: min(310px, calc(100vw - 32px));
  --bs-popover-border-radius: 11px;
  z-index: 100060;
  font: inherit;
  font-size: 14px;
  box-shadow: 0 12px 32px rgba(10, 45, 62, .28), 0 3px 8px rgba(10, 45, 62, .16);
}
.related-field-popover .popover-header { padding: 9px 12px; font-size: 14px; font-weight: 700; }
.related-field-popover .popover-body { padding: 10px 12px; line-height: 1.5; }
.related-field-popover p { margin: 0 0 8px; }
.related-field-popover p:last-child { margin-bottom: 0; }
.related-field-popover a {
  display: inline-block;
  padding: 5px 8px;
  border-radius: 6px;
  background: #e0f3f5;
  color: #075968;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.related-field-popover a:hover { background: #c7eaee; color: #073c4a; }
.related-field-popover a:focus-visible { outline: 2px solid #087f8c; outline-offset: 3px; }
.related-create-dialog {
  width: min(780px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 0;
  margin: auto;
  overflow: visible;
  background: transparent;
  color: var(--brand-ink);
}
.related-create-dialog::backdrop { background: rgba(8, 38, 56, .38); }
.related-create-dialog .modal-content { max-height: calc(100dvh - 24px); }
.related-create-dialog .modal-title { font-size: 19px; }
@media (max-width: 575px) {
  .form-grid:has(.related-field) > .erp-field > span:first-child,
  .related-field > span:first-child { min-height: 32px; }
  .related-field-button { width: 32px; height: 32px; }
  .related-create-dialog { width: calc(100vw - 16px); max-width: calc(100vw - 16px); }
  .related-create-dialog .modal-title { font-size: 17px; }
}
.related-field > span:first-child::after { content: none !important; }
.related-field:has(select:required) .related-field-caption::after { content: " *"; color: #dc2626; }
.related-field-caption { display: inline; cursor: pointer; }

/* Read-only record context above approval and rejection controls. */
.review-summary {
  margin-bottom: 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-muted);
  color: var(--text);
  overflow-wrap: anywhere;
}

.review-summary-title {
  margin: 0 0 16px;
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.5;
}

.review-summary-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 24px;
  margin: 0;
}

.review-summary-fields dt {
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.review-summary-fields dd {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  white-space: pre-wrap;
}

.review-summary-wide { grid-column: 1 / -1; }

@media (max-width: 575.98px) {
  .review-summary-fields { grid-template-columns: minmax(0, 1fr); }
}

/* Liên kết sang phân hệ / trang khác: màu xanh lam + mũi tên ↗ để phân biệt với nút thao tác tại chỗ.
   Dùng moduleLink() (workspace.js) hoặc components/module_link_icon.html trong template. */
.module-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  max-width: 100%;
  padding: 0 9px 0 11px;
  border: 1px solid rgba(29, 78, 216, 0.38);
  border-radius: 999px;
  background: rgba(219, 234, 254, 0.72);
  color: #1d4ed8;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: middle;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.module-link > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.module-link-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  transition: transform 0.18s ease;
}

.module-link:hover,
.module-link:focus-visible {
  border-color: #1d4ed8;
  background: #1d4ed8;
  color: #fff;
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.25);
}

.module-link:hover .module-link-icon,
.module-link:focus-visible .module-link-icon {
  transform: translate(1px, -1px);
}

.module-link:focus-visible {
  outline: 2px solid #1d4ed8;
  outline-offset: 2px;
}

.module-link-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  margin-bottom: 10px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-muted);
}

.module-link-bar .form-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 0.8rem;
  font-weight: 500;
}

/* Header notification history: keep filters and paging visible on small screens. */
.notification-dropdown.show { display: flex; flex-direction: column; }
.notification-dropdown .notification-dropdown-header,
.notification-dropdown .notification-filters,
.notification-dropdown .notification-pagination { flex-shrink: 0; }
.notification-dropdown .notification-list { min-height: 0; flex: 1 1 auto; max-height: none; }
.notification-filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 8px 10px; }
.notification-filters [aria-pressed="true"] { background: var(--surface-muted); border-color: var(--brand-ink); }
.notification-pagination { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 10px 4px 2px; }
.notification-pagination small { font-size: 11px; text-align: center; }
.notification-dropdown [hidden] { display: none !important; }
.global-search-group > [data-search-more] { width: 100%; margin-top: 6px; }

/* G3 — sản xuất (MFG-01…11) */
.mfg-row {
  align-items: end;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(16, 61, 80, 0.12);
}

.mfg-row-remove { justify-self: start; }

.mfg-progress {
  min-width: 96px;
  margin-bottom: 2px;
}

.mfg-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.mfg-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 160px;
  padding: 12px;
}

.mfg-column h6 { margin: 0 0 4px; }
.mfg-column[data-column="blocked"] h6 { color: #b42318; }

.mfg-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line, rgba(16, 61, 80, 0.12));
  border-radius: 12px;
  background: var(--surface-strong, #fff);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.mfg-card:hover,
.mfg-card:focus-visible { border-color: var(--brand-cyan); }
.mfg-card.is-late { border-left: 4px solid #dc2626; }
.mfg-card span,
.mfg-card small { color: var(--text-muted); }

.mfg-logs {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .mfg-board { grid-template-columns: repeat(4, minmax(240px, 85vw)); }
}

/* Desktop: a light density pass. Mobile rules stay in the max-width blocks. */
@media (min-width: 1025px) {
  .app-shell {
    gap: 10px;
    padding: 10px;
  }

  .app-main {
    gap: 12px;
  }

  .sidebar {
    width: 256px;
    flex-basis: 256px;
    padding: 0 14px 14px;
  }

  .brand {
    height: 56px;
    min-height: 56px;
    gap: 10px;
    padding-bottom: 0;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  .brand-title {
    font-size: 15px;
    line-height: 1.15;
  }

  .brand-subtitle {
    font-size: 10px;
    line-height: 1.15;
  }

  .sidebar-search {
    margin-top: 10px;
  }

  .nav-list {
    gap: 4px;
    margin-top: 8px;
  }

  .nav-item {
    min-height: 36px;
    padding: 7px 10px;
    gap: 10px;
  }

  .nav-item svg {
    width: 17px;
    height: 17px;
  }

  .sub-item {
    min-height: 32px;
    padding: 6px 8px;
  }

  .submenu-list {
    margin-left: 18px;
    padding-left: 12px;
    gap: 2px;
  }

  .topbar {
    height: 56px;
    min-height: 56px;
    gap: 10px;
    padding: 6px 14px;
  }

  .topbar h1 {
    font-size: 20px;
  }

  .topbar.glass-panel::before {
    top: 8px;
    bottom: 8px;
  }

  .workspace-tabs {
    gap: 6px;
    padding: 6px;
  }

  .workspace-tab {
    min-height: 34px;
    padding: 0 12px;
    gap: 6px;
  }

  .kpi-grid {
    gap: 12px;
  }

  .kpi-card {
    padding: 14px 16px 12px;
  }

  .erp-panel {
    margin-top: 12px;
    padding: 16px;
  }

  .erp-panel > p {
    margin-bottom: 12px;
  }

  .module-toolbar {
    padding: 6px 14px;
  }

  .erp-table th,
  .erp-table td {
    padding: 10px 12px;
  }

  .form-grid {
    gap: 12px;
  }

  .erp-field {
    gap: 5px;
  }

  .glass-input {
    min-height: 38px;
    padding: 7px 10px;
  }

  .account-dropdown {
    padding: 6px;
  }

  .account-dropdown-header {
    padding: 6px 8px 4px;
  }

  .account-dropdown-meta {
    padding: 2px 8px;
  }

  .account-dropdown-action {
    min-height: 32px;
  }

  .account-dropdown .dropdown-item {
    padding: 4px 8px;
  }

  .account-dropdown .dropdown-divider {
    margin: 6px 0;
  }

  .account-language {
    padding: 6px 8px;
  }

  .account-dropdown .language-switcher .language-picker-trigger {
    min-height: 34px;
    padding: 4px 10px;
  }
}

.flow-guide-dialog {
  max-width: 920px;
}

.modal.show .flow-guide-dialog {
  height: auto;
  max-height: calc(100dvh - 2rem);
  margin: 1rem auto;
}

.modal.show .flow-guide-dialog .modal-content {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 2rem);
  background-color: #f7fbfb;
  background-image: none;
  backdrop-filter: none;
}

.flow-step-card {
  background-color: #ffffff;
}

:root[data-theme="dark"] .modal.show .flow-guide-dialog .modal-content,
:root[data-theme="dark"] .flow-step-card {
  background-color: #1b2a40;
  color: var(--text);
}

.flow-guide-lead,
.flow-guide-summary,
.module-guide-summary,
.module-guide-hint {
  margin: 0;
  color: var(--text-muted);
}

.flow-guide-section + .flow-guide-section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.flow-guide-heading {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 800;
  color: var(--brand-ink);
}

.flow-guide-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.flow-guide-step {
  display: flex;
  align-items: stretch;
  max-width: 100%;
}

.flow-step-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 168px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background-color: #ffffff;
  color: var(--text);
  text-decoration: none;
}

.flow-step-card:hover,
.flow-step-card:focus-visible {
  border-color: var(--brand-blue);
  color: var(--brand-ink);
}

.flow-step-card strong {
  font-size: 14px;
}

.flow-step-card span:last-child,
.module-guide-hint {
  font-size: 13px;
  line-height: 1.45;
}

.flow-guide-index,
.module-guide-step-index {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(0, 143, 163, 0.12);
  color: var(--brand-blue);
  font-size: 12px;
  font-weight: 800;
}

.flow-guide-join {
  position: relative;
  width: 22px;
  height: 2px;
  align-self: center;
  flex: none;
  background: var(--brand-cyan);
}

.flow-guide-join::after {
  content: "";
  position: absolute;
  right: 0;
  top: -3px;
  border: 4px solid transparent;
  border-left-color: var(--brand-cyan);
}

.flow-guide-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
  padding: 14px 16px;
}

.flow-guide-card-copy h2 {
  margin: 0 0 2px;
  font-size: 18px;
  font-weight: 800;
  color: var(--brand-ink);
}

.flow-guide-card-copy p {
  margin: 0;
  color: var(--text-muted);
}

.flow-guide-card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.flow-guide-card-actions .btn {
  display: inline-flex;
  align-items: center;
}

body[data-show-flow-guides="0"] [data-module-guide],
body[data-show-flow-guides="0"] [data-flow-guide-card],
body[data-show-flow-guides="0"] header [data-flow-guide-open] {
  display: none;
}

.module-guide {
  margin: 0 0 12px;
  padding: 10px 12px;
}

.module-guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.module-guide-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--brand-ink);
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.module-guide-toggle svg,
.module-guide-chevron {
  width: 18px;
  height: 18px;
  flex: none;
}

.module-guide-chevron {
  color: var(--text-muted);
  transition: transform 0.18s ease;
}

.module-guide.is-collapsed .module-guide-chevron {
  transform: rotate(-90deg);
}

.module-guide-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.module-guide-flow,
.module-guide-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.module-guide-flow:hover,
.module-guide-flow:focus-visible,
.module-guide-step:hover,
.module-guide-step:focus-visible {
  border-color: var(--brand-blue);
  color: var(--brand-blue);
}

.module-guide-body {
  margin-top: 8px;
}

.module-guide-order {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.module-guide-step.is-current {
  border-color: var(--brand-blue);
  background: var(--brand-blue);
  color: #ffffff;
}

.module-guide-step.is-current .module-guide-step-index {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.module-guide-hint {
  margin-top: 8px;
}

@media (max-width: 768px) {
  .flow-guide-card,
  .flow-guide-steps,
  .flow-guide-step {
    flex-direction: column;
  }

  .flow-guide-step {
    align-items: stretch;
  }

  .flow-step-card {
    width: 100%;
  }

  .flow-guide-join {
    width: 2px;
    height: 16px;
    margin-left: 18px;
  }

  .flow-guide-join::after {
    right: auto;
    left: -3px;
    top: auto;
    bottom: 0;
    border-color: transparent;
    border-top-color: var(--brand-cyan);
  }
}
