/**
 * Tabler 中度集成桥接层
 * 在保留现有 PHP 组件 class 的前提下，套用 Tabler 视觉与布局
 * 参考：https://github.com/tabler/tabler
 */

.theme-tabler {
  --tblr-primary: #10b981;
  --tblr-primary-rgb: 16, 185, 129;
  --tblr-body-bg: #f4f6fa;
  font-family: var(--font, var(--tblr-font-sans-serif, Inter, system-ui, sans-serif));
}

.theme-tabler .card {
  padding: 0;
  border: 1px solid rgba(98, 105, 118, 0.16);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  background: #fff;
  overflow: hidden;
}

.theme-tabler .card:not(.card-flush) {
  padding: 1.25rem 1.5rem;
}

.theme-tabler .card:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.theme-tabler .card-flush .card-toolbar,
.theme-tabler .card-flush .toolbar {
  padding: 1rem 1.25rem;
  background: #fff;
  border-bottom: 1px solid rgba(98, 105, 118, 0.12);
  margin: 0;
}

.theme-tabler .card-heading {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.theme-tabler .card-heading::before {
  display: none;
}

.theme-tabler .stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.theme-tabler .stat-box,
.theme-tabler .admin-stat-mini {
  border: 1px solid rgba(98, 105, 118, 0.16);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  background: #fff;
  padding: 1.25rem 1.5rem;
}

.theme-tabler .stat-box::before {
  width: 3px;
  border-radius: 0 2px 2px 0;
}

.theme-tabler .stat-box:hover,
.theme-tabler .admin-stat-mini:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.theme-tabler .admin-stat-strip {
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.theme-tabler .btn {
  font-weight: 500;
  border-radius: 4px;
  padding: 0.4375rem 0.875rem;
  font-size: 0.875rem;
  line-height: 1.4285714;
  box-shadow: none;
}

.theme-tabler .btn-primary {
  background: var(--tblr-primary);
  border-color: var(--tblr-primary);
  color: #fff;
}

.theme-tabler .btn-primary:hover {
  background: #059669;
  border-color: #059669;
  transform: none;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.25);
}

.theme-tabler .btn-default {
  background: #fff;
  border: 1px solid rgba(98, 105, 118, 0.32);
  color: #1e293b;
}

.theme-tabler .btn-default:hover {
  background: #f8fafc;
}

.theme-tabler .data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.theme-tabler .data-table th {
  background: #f1f5f9;
  color: #475569;
  font-size: 13px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.45;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(98, 105, 118, 0.16);
  vertical-align: middle;
  white-space: nowrap;
  overflow: visible;
}

.theme-tabler .data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(98, 105, 118, 0.08);
  vertical-align: middle;
  line-height: 1.45;
}

.theme-tabler .data-table tbody tr:hover td {
  background: rgba(16, 185, 129, 0.04);
}

.theme-tabler .table-wrap {
  border: none;
  border-radius: 0;
}

.theme-tabler input[type="text"]:not(.el-input__inner):not(.el-textarea__inner),
.theme-tabler input[type="password"]:not(.el-input__inner),
.theme-tabler input[type="number"]:not(.el-input__inner),
.theme-tabler input[type="email"]:not(.el-input__inner),
.theme-tabler input[type="date"]:not(.el-input__inner),
.theme-tabler select:not(.el-select__input),
.theme-tabler textarea:not(.el-textarea__inner),
.theme-tabler .input-group input:not(.el-input__inner):not(.el-textarea__inner) {
  border: 1px solid rgba(98, 105, 118, 0.32);
  border-radius: 6px;
  padding: 0.4375rem 0.75rem;
  font-size: 0.875rem;
  background: #fff;
}

.theme-tabler input:focus:not(.el-input__inner):not(.el-textarea__inner),
.theme-tabler select:focus:not(.el-select__input),
.theme-tabler textarea:focus:not(.el-textarea__inner) {
  border-color: var(--tblr-primary);
  box-shadow: 0 0 0 0.25rem rgba(var(--tblr-primary-rgb), 0.15);
}

.theme-tabler .status-pill.ok,
.theme-tabler .badge-done {
  background: rgba(47, 179, 68, 0.1);
  color: #2fb344;
}

.theme-tabler .status-pill.err {
  background: rgba(214, 57, 57, 0.1);
  color: #d63939;
}

.theme-tabler .status-pill {
  border-radius: 100rem;
  padding: 0.25em 0.66em;
  font-size: 0.75rem;
  font-weight: 500;
}

.theme-tabler .page-header {
  margin-bottom: 1.5rem;
}

.theme-tabler .page-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #1e293b;
}

.theme-tabler .page-sub {
  color: #626976;
  font-size: 0.875rem;
}

.theme-tabler .navbar-vertical .nav-link {
  border-radius: 4px;
  margin: 1px 0.5rem;
  padding: 0.5rem 0.75rem;
  color: rgba(255, 255, 255, 0.72);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.theme-tabler .navbar-vertical .nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.theme-tabler .navbar-vertical .nav-link.active {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
}

.theme-tabler .navbar-vertical .nav-section {
  padding: 1rem 1rem 0.35rem;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.4);
}

.theme-tabler .page-wrapper {
  background: var(--tblr-body-bg);
}

.theme-tabler .page-wrap:not(.page-wrap--workspace) {
  padding: 1.5rem 1.25rem 2.5rem;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  box-sizing: border-box;
}

.theme-tabler .page-wrap.page-wrap--product-po:has(.product-stock-card--workspace),
.theme-tabler .page-wrap.page-wrap--product-full {
  max-width: none;
  padding: 0;
  margin: 0;
  width: 100%;
  height: calc(100vh - 3.5rem);
  overflow: hidden;
}

.theme-tabler .page-wrap.page-wrap--product-po:not(:has(.product-stock-card--workspace)):not(.page-wrap--product-full) {
  max-width: 1440px;
}

.theme-tabler .page-wrap.page-wrap--quote {
  max-width: none;
  padding: 1.25rem 1.5rem 2rem;
}

.theme-tabler .navbar-member {
  position: relative;
  background: #fff;
  border-bottom: 1px solid rgba(98, 105, 118, 0.12);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  min-height: 3.5rem;
}

.theme-tabler .navbar-member .navbar-brand {
  position: absolute;
  left: 1rem;
  top: 0;
  bottom: 0;
  z-index: 2;
  margin: 0;
  font-weight: 600;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-tabler .navbar-member > .container-xl::before {
  content: '';
  display: block;
  width: 11.5rem;
  flex-shrink: 0;
}

.theme-tabler .page-header-bar {
  padding: 0;
  background: #fff;
  border-bottom: 1px solid rgba(98, 105, 118, 0.12);
}

.theme-tabler .page-header-bar .breadcrumb {
  font-size: 0.875rem;
  margin: 0;
}

.theme-tabler .page-body {
  padding-top: 0.5rem;
  padding-bottom: 1rem;
}

.theme-tabler .page-header {
  margin-bottom: 0.75rem;
}

.theme-tabler .page-title {
  font-size: 1.25rem;
  margin-bottom: 0.15rem;
}

.theme-tabler .page-sub {
  font-size: 0.8125rem;
  margin: 0;
}

.theme-tabler .admin-stat-strip {
  margin-bottom: 0.75rem;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(160px, max-content));
}

.theme-tabler .admin-stat-mini {
  padding: 0.625rem 1rem;
  min-width: 160px;
}

.theme-tabler .admin-stat-mini-icon {
  width: 36px;
  height: 36px;
}

.theme-tabler .admin-stat-mini-val {
  font-size: 1.125rem;
}

.theme-tabler .admin-stat-mini-lbl {
  font-size: 0.75rem;
}

.theme-tabler .stats-row {
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.theme-tabler .stat-box {
  padding: 1rem 1.125rem;
}

.theme-tabler .stat-box .num {
  font-size: 1.375rem;
}

.theme-tabler .admin-grid-2 {
  gap: 1rem;
}

.theme-tabler .navbar-vertical .nav-item {
  margin: 0;
}

.theme-tabler .navbar-vertical .nav-link {
  padding: 0.4rem 0.75rem;
  margin: 1px 0.5rem;
  min-height: 0;
}

.theme-tabler .navbar-vertical .nav-section {
  padding: 0.625rem 1rem 0.2rem;
  margin: 0;
  list-style: none;
}

.theme-tabler .navbar-vertical .navbar-nav {
  gap: 0;
}

.theme-tabler .page-header-bar .container-xl {
  padding-top: 0.5rem !important;
  padding-bottom: 0.5rem !important;
}

.theme-tabler .card-flush .card-toolbar {
  padding: 0.75rem 1rem;
}

.theme-tabler .pager {
  padding: 0.625rem 1rem !important;
}

.admin-meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  padding: 0.625rem 1rem;
  margin-bottom: 0.75rem;
  background: #fff;
  border: 1px solid rgba(98, 105, 118, 0.16);
  border-radius: 4px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.admin-meta-strip strong {
  color: var(--text-primary);
  font-weight: 600;
}

.theme-tabler .navbar-member .nav-link {
  border-radius: 4px;
  padding: 0.375rem 0.75rem;
  color: #626976;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.theme-tabler .navbar-member .nav-link.active {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

.theme-tabler .navbar-member .nav-link.active::after {
  display: none;
}

.theme-tabler .user-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.theme-tabler.theme-tabler-ws .app-shell {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

.theme-tabler.theme-tabler-ws .page-wrap--workspace {
  padding: 0;
  flex: 1;
  min-height: 0;
  height: auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-width: none;
  position: relative;
}

.theme-tabler.theme-tabler-ws #viewRoot {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.theme-tabler.theme-tabler-ws .quote-workspace {
  padding: 12px 16px 16px;
  box-sizing: border-box;
}

.theme-tabler .login-wrap {
  background: var(--tblr-body-bg) !important;
}

.theme-tabler .login-card {
  border: 1px solid rgba(98, 105, 118, 0.16);
  border-radius: 8px;
}

.theme-tabler .pager .btn.active {
  background: var(--tblr-primary);
  border-color: var(--tblr-primary);
  color: #fff;
}

.theme-tabler .info-panel {
  border: 1px solid rgba(98, 105, 118, 0.16);
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* ══ 后台专用：不加载 Tabler 全局 CSS，侧栏贴边、菜单对齐 ══ */
body.theme-tabler-admin {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  background: var(--bg-page);
}

.theme-tabler-admin .admin-layout {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
}

.theme-tabler-admin .admin-sidebar {
  width: 220px;
  flex: 0 0 220px;
  position: sticky;
  top: 0;
  left: 0;
  height: 100vh;
  margin: 0;
  padding: 0;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  overflow-x: hidden;
}

.theme-tabler-admin .admin-main {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0 !important;
  padding: 0 !important;
}

.theme-tabler-admin .admin-content {
  padding: 12px 18px 24px;
  max-width: none;
  width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
  background: var(--bg-page);
}

.theme-tabler-admin .admin-topbar {
  min-height: 46px;
  padding: 0 18px;
}

.theme-tabler-admin .admin-nav-section {
  padding: 10px 14px 4px;
}

.theme-tabler-admin .admin-nav-group__toggle {
  padding: 8px 14px;
  color: rgba(255, 255, 255, 0.82);
}

.theme-tabler-admin .admin-nav-group__toggle:hover {
  background: rgba(255, 255, 255, 0.06);
}

.theme-tabler-admin .admin-nav-group__panel a {
  padding-left: 22px;
  font-size: 13px;
}

.theme-tabler-admin .admin-sidebar a {
  margin: 0;
  padding: 8px 14px;
  width: 100%;
  border-radius: 0;
}

.theme-tabler-admin .admin-sidebar a.active {
  background: rgba(16, 185, 129, 0.22) !important;
  color: #6ee7b7 !important;
  box-shadow: inset 3px 0 0 #10b981;
}

.theme-tabler-admin .admin-brand {
  padding: 14px 14px 10px;
}

.theme-tabler-admin .page-header {
  margin-bottom: 10px;
}

.theme-tabler-admin .card {
  margin-bottom: 12px;
}

.theme-tabler-admin .card-flush .card-toolbar {
  padding: 10px 14px;
}

.theme-tabler-admin .settings-split-layout .card {
  min-width: 0;
}

.theme-tabler-admin .admin-stat-strip {
  margin-bottom: 10px;
  grid-template-columns: repeat(auto-fit, minmax(140px, max-content));
}

.theme-tabler-admin .admin-stat-mini {
  padding: 0.625rem 1rem;
  min-width: 140px;
}

/* 覆盖 Tabler/Bootstrap 的 .modal，避免弹窗全屏贴左上角 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1050;
}

.modal-backdrop > .modal {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  bottom: auto;
  z-index: auto;
  display: flex !important;
  flex-direction: column;
  width: min(520px, calc(100vw - 32px));
  height: auto;
  max-height: min(90vh, 720px);
  margin: 0;
  padding: 0;
  overflow: hidden;
  pointer-events: auto;
  --bs-modal-width: auto;
  --bs-modal-margin: 0;
}

.modal-backdrop > .modal.modal--sm {
  width: min(420px, calc(100vw - 32px));
}

.modal-backdrop > .modal.modal--md {
  width: min(560px, calc(100vw - 32px));
}

.modal-backdrop > .modal.modal--lg {
  width: min(720px, calc(100vw - 32px));
}

.modal-backdrop > .modal.modal--xl {
  width: min(1180px, calc(100vw - 32px));
  max-height: none;
  overflow: visible;
}

.modal-backdrop > .modal.modal--settle {
  max-height: none;
  overflow: visible;
  margin-top: 0;
}

.modal-backdrop > .modal.modal--settle .modal-header {
  position: relative;
  z-index: 2;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}

.modal-backdrop > .modal.modal--settle .modal-body {
  overflow: visible;
  flex: 0 0 auto;
}

.modal-backdrop > .modal.modal--wide {
  width: min(920px, calc(100vw - 32px));
}

.modal-backdrop > .modal.modal--contract {
  width: min(1360px, calc(100vw - 24px)) !important;
  max-width: calc(100vw - 24px) !important;
  max-height: calc(100vh - 32px) !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}
.modal-backdrop > .modal.modal--contract .modal-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
}
.modal-backdrop > .modal.modal--contract .modal-footer {
  flex: 0 0 auto !important;
}

.modal-backdrop > .modal.modal--wide.modal--email-settings,
.modal-backdrop > .modal.modal--wide.modal--quote-email {
  width: min(1280px, calc(100vw - 24px));
}

.modal-backdrop > .modal .modal-header,
.modal-backdrop > .modal .modal-body,
.modal-backdrop > .modal .modal-footer {
  position: static;
  flex: 0 0 auto;
}

.modal-backdrop > .modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  z-index: 2;
}

.modal-backdrop > .modal .modal-header h3 {
  flex: 1;
  min-width: 0;
}

.modal-backdrop > .modal .modal-header .btn-close,
.modal-backdrop > .modal .modal-header .modal-close {
  flex-shrink: 0;
  margin-left: auto;
  position: relative;
  z-index: 1;
}

.modal-backdrop.is-open {
  align-items: flex-start !important;
  overflow-y: auto;
  padding-top: 20px;
  padding-bottom: 20px;
}

.modal-backdrop.is-open:has(> .modal.modal--sm:not(.modal--settle)),
.modal-backdrop.is-open:has(> .modal.modal--md),
.modal-backdrop.is-open:has(> .modal.modal--lg:not(.modal--settle)) {
  align-items: center !important;
  overflow-y: hidden;
}

.modal-backdrop > .modal .modal-body {
  flex: 1 1 auto;
  overflow: auto;
}

.modal-backdrop > .modal .modal-footer {
  flex-shrink: 0;
}

/* Element Plus：避免 legacy 全局 input 规则与组件外框叠成双层 */
.theme-tabler .el-input__wrapper .el-input__inner,
.theme-tabler .el-textarea__inner,
.theme-tabler .el-input-number .el-input__wrapper .el-input__inner,
.theme-tabler .el-select .el-input__wrapper .el-input__inner {
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
  outline: none !important;
  min-height: unset !important;
  padding: 0 !important;
  border-radius: 0 !important;
}

.theme-tabler .el-input__wrapper .el-input__inner:focus,
.theme-tabler .el-textarea__inner:focus,
.theme-tabler .el-input-number .el-input__wrapper .el-input__inner:focus,
.theme-tabler .el-select .el-input__wrapper .el-input__inner:focus {
  border: none !important;
  box-shadow: none !important;
}

.theme-tabler .toolbar .el-input,
.theme-tabler .toolbar .el-select,
.theme-tabler .toolbar .el-input-number,
.theme-tabler .product-stock-search-form .el-input,
.theme-tabler .product-stock-search-form .el-select,
.theme-tabler .el-form--inline .el-form-item .el-input,
.theme-tabler .el-form--inline .el-form-item .el-select,
.theme-tabler .el-form--inline .el-form-item .el-input-number {
  min-width: 0;
  flex: 0 0 auto;
}

.theme-tabler .toolbar input[type="text"].el-input__inner,
.theme-tabler .toolbar input[type="number"].el-input__inner,
.theme-tabler .product-stock-search-form input[type="text"].el-input__inner {
  min-width: 0 !important;
  flex: 1 1 auto !important;
}
