* {
  box-sizing: border-box;
}

[hidden],
.is-hidden {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  background: #f3f4f6;
  color: #0f172a;
}

.app-container {
  display: flex;
  min-height: 100vh;
}

/* 侧边栏样式 */
.sidebar {
  width: 240px;
  background: #ffffff;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid #e2e8f0;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 18px;
  color: #0f172a;
}

.sidebar-nav {
  padding: 12px 0;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: #475569;
  text-decoration: none;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: #f8fafc;
  color: #2563eb;
}

.nav-item.active {
  background: #eff6ff;
  color: #2563eb;
  border-left-color: #2563eb;
  font-weight: 600;
}

.nav-item span {
  font-size: 18px;
}

/* 主内容区 */
.main-content {
  flex: 1;
  margin-left: 240px;
  min-height: 100vh;
  transition: margin-left .2s;
}

#sidebar[hidden] ~ .main-content,
.sidebar[hidden] ~ .main-content {
  margin-left: 0;
}

#sidebar[hidden] ~ .main-content #global-status,
.sidebar[hidden] ~ .main-content #global-status {
  left: 0 !important;
}

.layout {
  max-width: none;
  width: 100%;
  margin: 0;
  box-sizing: border-box;
  padding: 70px 24px 48px; /* 顶部留出空间给固定的状态消息（约50px）和额外间距 */
}

/* 登录页面专属居中布局 */
body.is-login-page {
  background: #f8fafc;
}

body.is-login-page .app-container {
  display: flex;
  min-height: 100vh;
  justify-content: center;
  align-items: center;
}

body.is-login-page .sidebar {
  display: none !important;
}

body.is-login-page .main-content {
  margin-left: 0 !important;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 24px;
}

body.is-login-page .layout {
  max-width: 440px !important;
  width: 100% !important;
  margin: 0 auto !important;
  padding: 0 !important;
}

body.is-login-page #global-status {
  left: 0 !important;
}

body.is-login-page .page-header {
  text-align: center;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

body.is-login-page .page-header h1 {
  font-size: 26px;
  font-weight: 700;
  color: #0f172a;
}

body.is-login-page #auth-panel {
  max-width: 440px;
  width: 100%;
  margin: 0;
  padding: 32px 28px;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.05);
  background: #ffffff;
}

body.is-login-page #auth-panel h2 {
  margin: 0 0 20px;
  font-size: 20px;
  color: #0f172a;
  text-align: center;
}

.layout.pricing-rules-wide {
  max-width: none;
}

.layout.stats-wide {
  max-width: none;
  height: calc(100vh - 44px);
}

.layout.users-wide {
  max-width: none;
}

.layout.stats-wide #stats-card {
  height: calc(100vh - 150px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.layout.stats-wide #stats-card .section {
  flex: 0 0 auto;
}

.layout.stats-wide .stats-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  overflow-x: auto;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

#stats-thead th {
  position: sticky;
  top: 0;
  z-index: 12;
  background: #f1f5f9;
  box-shadow: 0 1px 0 #e2e8f0;
}

#stats-tfoot td,
#stats-total-row td {
  position: sticky;
  bottom: 0;
  z-index: 11;
  background: #f8fafc;
  box-shadow: 0 -1px 0 #e2e8f0, 0 -8px 16px rgba(15, 23, 42, 0.04);
}

.layout.companies-wide {
  max-width: none;
}

.layout.account-ownership-wide {
  max-width: none;
}

.layout.employees-wide {
  max-width: none;
}

.layout.account-rankings-wide {
  max-width: none;
}

.layout.goodcard-presets-wide {
  max-width: none;
  padding-left: 16px;
  padding-right: 16px;
}

.layout.goodcard-product-whitelist-wide {
  max-width: none;
  padding-left: 16px;
  padding-right: 16px;
}

.layout.goodcard-product-info-cache-wide {
  max-width: none;
  padding-left: 16px;
  padding-right: 16px;
}

.layout.updream-plugin-auth-wide {
  max-width: none;
  padding-left: 28px;
  padding-right: 28px;
}

.layout.goodcard-fx-metadata-wide {
  max-width: none;
  padding-left: 16px;
  padding-right: 16px;
}

/* 视图切换 */
.view {
  display: none;
}

.view.active {
  display: block;
}

.page-header,
header {
  margin-bottom: 24px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

header h1 {
  margin: 0 0 8px;
}

.page-header h1 {
  margin: 0;
}

.service-version {
  flex: 0 0 auto;
  padding: 6px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
}

.card {
  background: #ffffff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-header .actions {
  display: flex;
  gap: 8px;
}

.card-header .actions input[type="text"] {
  min-width: 220px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
}

.card-header .actions select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  font-size: 14px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label {
  font-weight: 600;
}

input[type="password"],
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  font-size: 14px;
  font-family: inherit;
}

textarea {
  resize: vertical;
}

input[type="text"],
select {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  font-size: 14px;
}

button {
  border: none;
  border-radius: 10px;
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.2);
}

button:hover {
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.28);
}

button.secondary {
  background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
  color: #0f172a;
  border: 1px solid rgba(148, 163, 184, 0.6);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

button.secondary:hover {
  background: linear-gradient(180deg, #ffffff 0%, #e2e8f0 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
}

button.danger {
  background: linear-gradient(180deg, #f87171 0%, #ef4444 100%);
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.2);
}

button.danger:hover {
  background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 8px 18px rgba(239, 68, 68, 0.28);
}


.form-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.form-inline input[type="text"] {
  width: 240px;
}

.admin-table-scroll {
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.admin-table-scroll table {
  min-width: 960px;
}

.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  color: #475569;
  font-size: 14px;
}

.admin-pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.updream-plugin-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(420px, 0.88fr);
  align-items: start;
  gap: 18px;
  margin-top: 18px;
}

.updream-unbound-panel {
  margin: 0 0 18px;
  padding: 16px;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  background: linear-gradient(180deg, #f8fbff 0%, #eff6ff 100%);
}

.updream-unbound-table-scroll {
  max-height: 250px;
  background: #ffffff;
}

.updream-unbound-table-scroll table {
  min-width: 760px;
}

.updream-plugin-pane {
  min-width: 0;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
  padding: 16px;
}

.updream-plugin-pane-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.updream-plugin-pane h3 {
  margin: 0;
}

.updream-plugin-pane .hint {
  margin: 6px 0 0;
}

.updream-plugin-codes-pane {
  position: sticky;
  top: 16px;
}

.updream-batch-table-scroll table {
  min-width: 890px;
}

.updream-codes-table-scroll {
  max-height: 560px;
}

.updream-codes-table-scroll table {
  min-width: 780px;
}

.updream-plugin-pagination {
  justify-content: space-between;
}

.updream-plugin-pagination span {
  flex: 1;
  text-align: center;
}

.updream-batch-selected {
  background: #eff6ff;
}

.updream-batch-actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

@media (max-width: 1180px) {
  .updream-plugin-workspace {
    grid-template-columns: 1fr;
  }

  .updream-plugin-codes-pane {
    position: static;
  }
}

@media (max-width: 720px) {
  .layout.updream-plugin-auth-wide {
    padding-left: 16px;
    padding-right: 16px;
  }
}

#manual-user-actions {
  margin-bottom: 16px;
}

.form-row.inline {
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.form-row.end {
  flex-direction: row;
  justify-content: flex-end;
  gap: 8px;
}

.stats-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 10px;
  border: 1px solid #dbe3ef;
  border-radius: 14px;
  background: linear-gradient(180deg, #fbfdff 0%, #f3f7fb 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.stats-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 0 0 auto;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.stats-filter label {
  font-size: 11px;
  color: #64748b;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.02em;
}

.stats-filter input,
.stats-filter select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  height: 32px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #d7deea;
  background: #fbfdff;
  font-size: 13px;
}

.stats-filter-wide {
  width: 200px;
}

.stats-filter-date {
  width: 156px;
}

.stats-filter-date input[type="date"] {
  min-width: 136px;
  padding-right: 6px;
}

.stats-filter-compact {
  width: 88px;
}

.stats-filter select {
  min-width: 110px;
}

.stats-filter-inline-compact {
  width: 132px;
}

.stats-chip-input {
  display: flex;
  align-items: center;
  height: 32px;
  gap: 6px;
  padding: 3px 6px 3px 3px;
  border: 1px solid #d7deea;
  border-radius: 999px;
  background: #fbfdff;
}

.stats-chip-operator {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #2563eb;
  font-weight: 700;
  font-size: 13px;
  background: #dbeafe;
  border-radius: 999px;
}

.stats-chip-input input {
  border: 0;
  background: transparent;
  border-radius: 0;
  height: 100%;
  min-width: 0;
  padding: 0 6px 0 0;
  text-align: center;
  font-weight: 600;
  color: #0f172a;
  font-size: 12px;
}

.stats-chip-input input::placeholder {
  color: #94a3b8;
  font-weight: 500;
}

.stats-chip-input input:focus {
  outline: none;
}

.stats-chip-input:focus-within {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.42);
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-card {
  width: min(520px, 100%);
  border-radius: 16px;
  border: 1px solid #dbe3ef;
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
}

.modal-header {
  border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 {
  margin: 0;
  font-size: 20px;
  color: #0f172a;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  justify-content: flex-end;
  border-top: 1px solid #e2e8f0;
}

.stats-ck-export-modal .form-row {
  margin-bottom: 14px;
}

.stats-ck-export-modal .form-row:last-child {
  margin-bottom: 0;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #475569;
}

.hint {
  color: #64748b;
  font-size: 13px;
  margin-top: 12px;
}

.metadata-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 14px 0;
  padding: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}

.metadata-panel h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
  color: #0f172a;
}

.metadata-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.metadata-note {
  margin: -4px 0 0;
  color: #64748b;
  font-size: 13px;
}

.metadata-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.metadata-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  color: #334155;
  font-size: 13px;
}

.metadata-grid label > span {
  font-weight: 700;
}

.metadata-grid input[type="number"] {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  font-size: 14px;
}

.metadata-grid input[type="number"]:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.metadata-grid small {
  color: #64748b;
  font-weight: 400;
  line-height: 1.4;
}

.metadata-grid-wide {
  grid-column: 1 / -1;
}

.metadata-stagger-windows-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.metadata-stagger-windows-heading strong {
  color: #334155;
  font-size: 13px;
}

.metadata-stagger-windows {
  display: grid;
  gap: 8px;
}

.metadata-stagger-window-row {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) minmax(100px, 130px) auto minmax(100px, 130px) auto minmax(76px, 110px) minmax(76px, 96px) auto;
  align-items: center;
  gap: 8px;
}

.metadata-stagger-window-label,
.metadata-stagger-window-separator {
  color: #475569;
  font-size: 13px;
}

.metadata-stagger-window-row input[type="time"] {
  min-width: 0;
  height: 36px;
  padding: 6px 9px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #0f172a;
}

.metadata-stagger-window-row input[type="time"]:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.metadata-stagger-window-row input[type="number"],
.metadata-stagger-window-row select {
  min-width: 0;
  height: 36px;
  padding: 6px 9px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #0f172a;
}

.metadata-stagger-adjustment-enabled {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #475569;
  font-size: 12px;
  white-space: nowrap;
}

.metadata-stagger-window-remove {
  min-width: 56px;
}

@media (max-width: 640px) {
  .metadata-stagger-window-row {
    grid-template-columns: minmax(100px, 1fr) auto minmax(100px, 1fr) auto;
  }

  .metadata-stagger-window-label {
    grid-column: 1 / -1;
  }

  .metadata-stagger-adjustment-enabled {
    grid-column: 1 / -1;
  }
}

.metadata-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.metadata-switch input[type="checkbox"] {
  appearance: none;
  width: 36px;
  height: 20px;
  margin: 0;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #cbd5e1;
  position: relative;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.metadata-switch input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
  transition: transform 0.2s ease;
}

.metadata-switch input[type="checkbox"]:checked {
  border-color: #2563eb;
  background: #2563eb;
}

.metadata-switch input[type="checkbox"]:checked::after {
  transform: translateX(16px);
}

.profit-guard-config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin-top: 22px;
  max-width: 820px;
}

.profit-guard-config-card {
  border: 1px solid #dbe4f0;
  border-radius: 12px;
  background: #f8fafc;
  padding: 16px;
}

.profit-guard-config-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.profit-guard-switch {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.profit-guard-tag {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #e0ecff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
}

.profit-guard-field {
  display: grid;
  grid-template-columns: 120px minmax(120px, 1fr);
  align-items: center;
  gap: 12px;
  color: #334155;
  font-size: 14px;
  font-weight: 600;
}

.profit-guard-field input {
  width: 100%;
  max-width: 220px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
}

.pricing-history-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 1200px) {
  .pricing-history-layout {
    grid-template-columns: 1.2fr 1fr;
  }
}

.pricing-history-table-wrap {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

.pricing-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.pricing-history-table th,
.pricing-history-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  vertical-align: top;
}

.pricing-history-table thead th {
  background: #f1f5f9;
  font-weight: 600;
}

.pricing-history-table tbody tr:hover {
  background: #f8fafc;
  cursor: pointer;
}

.pricing-history-table tbody tr.selected {
  background: #fef3c7;
}

.pricing-history-detail {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
  min-height: 260px;
}

.pricing-history-detail h4 {
  margin: 12px 0 6px;
  font-size: 14px;
  color: #0f172a;
}

.detail-meta {
  display: grid;
  gap: 4px;
  font-size: 13px;
  color: #334155;
}

.detail-note {
  margin-top: 8px;
  font-size: 13px;
  color: #475569;
}

.detail-empty {
  color: #94a3b8;
  font-size: 13px;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 8px;
}

.detail-table th,
.detail-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  vertical-align: top;
}

.detail-table th {
  background: #f1f5f9;
  font-weight: 600;
}

.detail-hit {
  color: #b91c1c;
  font-weight: 700;
}

.detail-range {
  background: #fff4cc;
  color: #6b5b00;
}

.form-panel {
  margin-bottom: 16px;
  padding: 16px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}

#status-message {
  margin-top: 12px;
  font-size: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table th,
table td {
  padding: 12px 10px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  font-size: 14px;
}

/* 操作列样式优化 */
#companies-table td:last-child {
  padding: 8px 16px;
}

#companies-table td:last-child button {
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 9999px;
  font-weight: 500;
  transition: all 0.2s ease;
  min-width: 84px;
}

#companies-table td:last-child div {
  gap: 10px;
}

.company-ops-menu button {
  border-radius: 10px;
}

.company-ops-menu {
  padding: 8px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: opsMenuIn 140ms ease-out;
  transform-origin: top right;
}

@keyframes opsMenuIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

#companies-table td:last-child button.danger {
  border-color: rgba(248, 113, 113, 0.65);
}

.op-trigger {
  position: relative;
  padding-right: 10px;
}

.op-trigger::after {
  content: attr(data-op-label) " \25BC";
  font-weight: 700;
  color: #0f172a;}

[data-company-ops-menu-open="1"] .op-trigger::after {
  content: attr(data-op-label) " \25B2";
}


#companies-table td:last-child button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
  border-color: rgba(100, 116, 139, 0.7);
  background: linear-gradient(180deg, #ffffff 0%, #e2e8f0 100%);
}

#companies-table td:last-child button:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

table tbody tr:hover {
  background: #f8fafc;
}

.wrap-text {
  white-space: pre-line;
  word-break: break-word;
}

.blocked {
  background: rgba(248, 113, 113, 0.08);
}

.blocked:hover {
  background: rgba(248, 113, 113, 0.16);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
}

.badge.success {
  background: rgba(16, 185, 129, 0.15);
  color: #047857;
}

.badge.danger {
  background: rgba(248, 113, 113, 0.15);
  color: #b91c1c;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.section {
  margin-bottom: 24px;
}

.section h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

#pricing-rules-card {
  position: relative;
}

#pricing-rules-card .card-header {
  position: sticky;
  top: 50px; /* 位于状态消息区域下方（状态消息高度约50px） */
  z-index: 10; /* 确保在状态消息之上，但低于状态消息的z-index: 100 */
  background: #ffffff;
  margin-top: -20px;
  margin-left: -20px;
  margin-right: -20px;
  padding: 20px;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 6px 12px rgba(15, 23, 42, 0.08);
}

#pricing-rules-card .card-header + .section {
  margin-top: 8px;
}

.goodcard-preset-panel {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
}

.goodcard-preset-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.goodcard-preset-head strong {
  font-size: 18px;
}

.goodcard-preset-head span {
  color: #64748b;
  font-size: 13px;
  font-weight: 500;
}

.goodcard-preset-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.goodcard-preset-toolbar select {
  width: 280px;
  max-width: 100%;
}

.goodcard-preset-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 14px;
  margin-bottom: 18px;
}

.goodcard-preset-grid label {
  display: grid;
  gap: 6px;
  color: #334155;
  font-size: 13px;
  line-height: 1.25;
}

.goodcard-preset-grid input,
.goodcard-preset-grid select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  height: 38px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  font: inherit;
}

.goodcard-preset-categories {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
  max-height: 360px;
  overflow: auto;
  padding: 12px;
  border: 1px solid #dbe3ef;
  border-radius: 10px;
  background: #ffffff;
}

.goodcard-preset-category-group {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 1px solid #edf2f7;
  border-radius: 8px;
  background: #fbfdff;
}

.goodcard-preset-category-group strong {
  color: #0f172a;
  font-size: 14px;
}

.goodcard-preset-category-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: #334155;
  font-size: 13px;
  font-weight: 500;
}

.goodcard-preset-category-item input {
  flex: 0 0 auto;
}

#goodcard-standard-optimization-rules-card,
#goodcard-storewide-optimization-rules-card {
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.goodcard-opt-header {
  align-items: flex-start;
}

.goodcard-opt-header h2 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0;
}

.goodcard-opt-subtitle {
  margin: 6px 0 0;
  color: #64748b;
  font-size: 13px;
}

.goodcard-opt-shell {
  display: grid;
  gap: 16px;
}

.goodcard-opt-topbar,
.goodcard-opt-section {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
}

.goodcard-opt-topbar {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  align-items: end;
  gap: 18px;
  padding: 16px;
}

.goodcard-opt-company {
  display: grid;
  gap: 6px;
  color: #334155;
  font-size: 13px;
}

.goodcard-opt-company select {
  width: 100%;
}

.goodcard-opt-switches,
.goodcard-opt-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.goodcard-opt-switches label,
.goodcard-opt-checks label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid #dbe4ee;
  border-radius: 8px;
  background: #f8fafc;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}

.goodcard-opt-switches input,
.goodcard-opt-checks input,
.goodcard-opt-rule-toggle input {
  width: 14px;
  height: 14px;
  margin: 0;
  flex: 0 0 auto;
}

.goodcard-opt-section {
  padding: 16px;
}

.goodcard-opt-section.primary {
  border-color: #bfdbfe;
  background: #fbfdff;
}

.goodcard-opt-section.secondary {
  padding: 0;
  overflow: hidden;
}

.goodcard-opt-section.secondary summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  color: #0f172a;
  font-weight: 700;
  list-style: none;
}

.goodcard-opt-section.secondary summary::-webkit-details-marker {
  display: none;
}

.goodcard-opt-section.secondary summary small {
  color: #64748b;
  font-size: 12px;
  font-weight: 500;
}

.goodcard-opt-section.secondary .goodcard-opt-grid,
.goodcard-opt-section.secondary .goodcard-opt-checks {
  margin: 0 16px 16px;
}

.goodcard-opt-section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.goodcard-opt-section-head h3 {
  margin: 0;
  color: #0f172a;
  font-size: 17px;
}

.goodcard-opt-section-head p,
.goodcard-opt-rule-card p {
  margin: 4px 0 0;
  color: #64748b;
  font-size: 13px;
  line-height: 1.5;
}

.goodcard-opt-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.goodcard-opt-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.goodcard-opt-grid label,
.goodcard-opt-rule-card label:not(.goodcard-opt-rule-toggle) {
  display: grid;
  gap: 6px;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.goodcard-opt-grid input,
.goodcard-opt-rule-card input[type="number"],
.goodcard-opt-rule-card input[type="text"] {
  width: 100%;
  min-width: 0;
  height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  padding: 8px 10px;
  color: #0f172a;
  font-size: 13px;
  font-weight: 600;
}

.goodcard-opt-rule-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.goodcard-opt-rule-card {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 150px;
  padding: 14px;
  border: 1px solid #dbe4ee;
  border-radius: 8px;
  background: #ffffff;
}

.goodcard-opt-rule-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #0f172a;
  font-size: 15px;
  font-weight: 700;
}

.goodcard-opt-tier-card {
  grid-column: 1 / -1;
}

.goodcard-opt-tier-table {
  overflow: hidden;
  border: 1px solid #dbe4ee;
  border-radius: 6px;
}

.goodcard-opt-tier-row {
  display: grid;
  grid-template-columns: minmax(260px, 1.1fr) minmax(250px, 1fr) minmax(300px, 1.2fr);
  align-items: center;
}

.goodcard-opt-tier-row + .goodcard-opt-tier-row {
  border-top: 1px solid #e2e8f0;
}

.goodcard-opt-tier-row > * {
  min-width: 0;
  padding: 11px 14px;
}

.goodcard-opt-tier-row > * + * {
  border-left: 1px solid #e2e8f0;
}

.goodcard-opt-tier-head {
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.goodcard-opt-tier-range,
.goodcard-opt-tier-action {
  display: flex !important;
  align-items: center;
  gap: 8px !important;
  color: #475569;
  font-size: 13px !important;
  font-weight: 500 !important;
  white-space: nowrap;
}

.goodcard-opt-tier-range strong {
  min-width: 32px;
  color: #0f172a;
  font-size: 13px;
}

.goodcard-opt-tier-range input,
.goodcard-opt-tier-action input {
  width: 72px !important;
  height: 32px !important;
  padding: 5px 8px !important;
  text-align: center;
}

.goodcard-opt-tier-action:last-child span:last-child {
  color: #9a5a18;
  font-weight: 700;
}

@media (max-width: 1180px) {
  .goodcard-preset-grid,
  .goodcard-preset-categories {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .goodcard-opt-topbar,
  .goodcard-opt-grid,
  .goodcard-opt-grid.compact,
  .goodcard-opt-rule-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .goodcard-opt-tier-row {
    grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) minmax(260px, 1fr);
  }
}

@media (max-width: 720px) {
  .goodcard-preset-head,
  .goodcard-preset-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .goodcard-opt-tier-table {
    overflow-x: auto;
  }

  .goodcard-opt-tier-row {
    min-width: 760px;
  }

  .goodcard-preset-toolbar select,
  .goodcard-preset-toolbar button {
    width: 100%;
  }

  .goodcard-preset-grid,
  .goodcard-preset-categories {
    grid-template-columns: 1fr;
  }

  .goodcard-opt-header,
  .goodcard-opt-section-head,
  .goodcard-opt-section.secondary summary {
    align-items: stretch;
    flex-direction: column;
  }

  .goodcard-opt-topbar,
  .goodcard-opt-grid,
  .goodcard-opt-grid.compact,
  .goodcard-opt-rule-grid {
    grid-template-columns: 1fr;
  }
}
