:root,
html[data-theme="excel"] {
  --theme-name: "Excel Green";
  --theme-primary: #107c41;
  --theme-primary-strong: #0b5f33;
  --theme-sidebar: #0b4f31;
  --theme-sidebar-strong: #073b24;
  --theme-page: #f4f8f5;
  --theme-panel-tint: #f1faf4;
  --theme-active: #8bd3a8;
  --theme-shadow: rgba(16, 124, 65, 0.12);
  --theme-modal: #eef8f1;
  --theme-soft-border: rgba(16, 124, 65, 0.28);
  --theme-ok-bg: #e7f6ed;
  --ink: #172033;
  --muted: #667085;
  --line: #d8e0ea;
  --surface: #ffffff;
  --danger: #b42318;
  --warning: #b76e00;
}

html[data-theme="blue"] {
  --theme-name: "Bright Blue";
  --theme-primary: #0d6efd;
  --theme-primary-strong: #084298;
  --theme-sidebar: #0b5ed7;
  --theme-sidebar-strong: #073b8e;
  --theme-page: #f4f8ff;
  --theme-panel-tint: #eef5ff;
  --theme-active: #9ec5fe;
  --theme-shadow: rgba(13, 110, 253, 0.12);
  --theme-modal: #eef5ff;
  --theme-soft-border: rgba(13, 110, 253, 0.26);
  --theme-ok-bg: #e8f1ff;
}

html[data-theme="mint"] {
  --theme-name: "Light Green";
  --theme-primary: #3fae78;
  --theme-primary-strong: #2f7d61;
  --theme-sidebar: #f3fbf6;
  --theme-sidebar-strong: #e4f5ea;
  --theme-page: #f7fbf8;
  --theme-panel-tint: #f0faf4;
  --theme-active: #2f7d61;
  --theme-shadow: rgba(63, 174, 120, 0.12);
  --theme-modal: #f0faf4;
  --theme-soft-border: rgba(63, 174, 120, 0.28);
  --theme-ok-bg: #e7f7ee;
}

html {
  font-size: 14px;
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--theme-page);
  color: var(--ink);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

.admin-shell {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  width: 256px;
  height: 100vh;
  flex: 0 0 256px;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--theme-sidebar) 0%, var(--theme-sidebar-strong) 100%);
  color: #fff;
  box-shadow: 8px 0 28px var(--theme-shadow);
}

html[data-theme="mint"] .admin-sidebar {
  color: #214433;
  border-right: 1px solid #d4eadb;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 22px 18px;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

html[data-theme="mint"] .brand {
  border-bottom-color: #d4eadb;
}

.brand:hover {
  color: inherit;
}

.brand-mark {
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--theme-primary);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong {
  display: block;
  line-height: 1.1;
  font-size: 18px;
}

.brand small {
  display: block;
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

html[data-theme="mint"] .brand small {
  color: #668a75;
}

.sidebar-nav {
  padding: 14px 12px 24px;
}

.sidebar-link,
.sidebar-group {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  text-align: left;
  text-decoration: none;
}

html[data-theme="mint"] .sidebar-link,
html[data-theme="mint"] .sidebar-group {
  color: #38604a;
}

.sidebar-link:hover,
.sidebar-group:hover,
.sidebar-link.active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

html[data-theme="mint"] .sidebar-link:hover,
html[data-theme="mint"] .sidebar-group:hover,
html[data-theme="mint"] .sidebar-link.active {
  background: #dff2e6;
  color: #214433;
}

.sidebar-link.active {
  box-shadow: inset 3px 0 0 var(--theme-active);
}

.sidebar-group {
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

html[data-theme="mint"] .sidebar-group {
  color: #688d77;
}

.group-caret {
  margin-left: auto;
  font-size: 11px;
}

.sidebar-submenu {
  padding-left: 12px;
}

.sidebar-submenu .sidebar-link {
  min-height: 34px;
  padding-left: 18px;
  font-size: 13px;
}

.nav-icon {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 12px;
}

html[data-theme="mint"] .nav-icon {
  background: #d6eddf;
}

.admin-main {
  min-width: 0;
  flex: 1;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 68px;
  padding: 14px 28px;
  background: var(--theme-primary-strong);
  color: #fff;
  box-shadow: 0 8px 22px var(--theme-shadow);
}

html[data-theme="mint"] .topbar {
  background: var(--theme-primary);
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
}

.topbar-subtitle {
  display: none;
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

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

.theme-switcher {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
}

.theme-btn {
  min-height: 26px;
  padding: 3px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
}

.theme-btn:hover,
.theme-btn.active {
  background: #fff;
  color: var(--theme-primary-strong);
}

.user-chip {
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 12px;
}

.content-wrap {
  padding: 24px 28px 36px;
}

.auth-wrap {
  min-height: 100vh;
  padding: 40px 16px;
  background: var(--theme-page);
}

.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.page-title h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.page-title .hint {
  color: var(--muted);
  font-size: 12px;
}

.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 15px 16px;
  min-height: 104px;
  box-shadow: 0 10px 24px var(--theme-shadow);
}

.metric-card.accent {
  border-color: var(--theme-soft-border);
  background: var(--theme-panel-tint);
}

.user-dashboard-panel {
  border-left: 4px solid var(--theme-primary);
}

.user-primary-card {
  min-height: 116px;
  border-color: var(--theme-soft-border);
  background: linear-gradient(180deg, var(--theme-panel-tint) 0%, #fff 100%);
}

.user-primary-card .metric-value {
  font-size: 30px;
}

.new-user-card {
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--theme-soft-border), 0 10px 24px var(--theme-shadow);
}

.latest-users-table td {
  vertical-align: middle;
}

.latest-user-status {
  min-height: 18px;
  padding: 1px 6px;
  font-size: 11px;
}

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

.metric-value {
  margin-top: 4px;
  color: var(--theme-primary-strong);
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
}

.metric-subtitle {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  box-shadow: 0 10px 24px var(--theme-shadow);
}

.panel-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
}

.health-panel {
  border-left: 4px solid var(--theme-primary);
}

.health-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
}

.health-status.ok {
  background: var(--theme-ok-bg);
  color: var(--theme-primary-strong);
}

.health-status.warn {
  background: #fff4df;
  color: var(--warning);
}

.health-status.bad {
  background: #fde8e8;
  color: var(--danger);
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

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

.health-item {
  padding: 10px;
  border: 1px solid #e5ebf2;
  border-radius: 8px;
  background: var(--theme-panel-tint);
}

.health-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.health-item strong {
  display: block;
  margin-top: 3px;
  font-size: 15px;
}

.system-metric-value {
  font-size: 18px;
  word-break: break-word;
}

.info-list {
  display: grid;
  gap: 8px;
}

.info-row {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid #eef2f6;
}

.info-row:last-child {
  border-bottom: 0;
}

.info-row dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.info-row dd {
  margin: 0;
  min-width: 0;
  color: var(--ink);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.system-progress {
  height: 8px;
  border-radius: 999px;
  background: #e9eff6;
}

.system-progress .progress-bar {
  background: var(--theme-primary);
}

.table {
  background: #fff;
}

.table thead th {
  border-bottom-color: #cfd9e6;
  color: #475467;
  font-size: 12px;
  font-weight: 700;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.status-ok {
  border-color: rgba(16, 124, 65, 0.22);
  background: #e7f6ed;
  color: #0b5f33;
}

.status-warn {
  border-color: rgba(183, 110, 0, 0.22);
  background: #fff4df;
  color: #9a5b00;
}

.status-bad {
  border-color: rgba(180, 35, 24, 0.22);
  background: #fde8e8;
  color: #b42318;
}

.status-info {
  border-color: rgba(13, 110, 253, 0.20);
  background: #e8f1ff;
  color: #084298;
}

.status-muted {
  border-color: #d8e0ea;
  background: #f4f6f9;
  color: #667085;
}

.status-provider {
  border-color: var(--theme-soft-border);
  background: var(--theme-panel-tint);
  color: var(--theme-primary-strong);
}

.sensitive-config {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid #d8e0ea;
  border-radius: 8px;
  background: #f7fafc;
}

.sensitive-config-main,
.sensitive-config-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.sensitive-config-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border: 1px solid #d8e0ea;
  border-radius: 999px;
  background: #fff;
  color: #475467;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.sensitive-config-hint {
  color: var(--muted);
  font-size: 12px;
}

.form-control,
.form-select,
.btn {
  border-radius: 6px;
}

.btn-primary {
  border-color: var(--theme-primary);
  background: var(--theme-primary);
}

.btn-primary:hover,
.btn-primary:focus {
  border-color: var(--theme-primary-strong);
  background: var(--theme-primary-strong);
}

.btn-outline-primary {
  border-color: var(--theme-primary);
  color: var(--theme-primary);
}

.btn-outline-primary:hover {
  border-color: var(--theme-primary);
  background: var(--theme-primary);
}

.payment-product-toggle-form {
  display: inline-flex;
  margin: 0;
}

.payment-product-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 70px;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: #667085;
  font: inherit;
  cursor: pointer;
}

.payment-product-toggle:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.payment-product-toggle:focus-visible {
  outline: 2px solid var(--theme-primary);
  outline-offset: 3px;
  border-radius: 999px;
}

.payment-product-toggle-track {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 32px;
  height: 18px;
  padding: 2px;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background-color .16s ease;
}

.payment-product-toggle-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .25);
  transition: transform .16s ease;
}

.payment-product-toggle.is-enabled {
  color: #087443;
}

.payment-product-toggle.is-enabled .payment-product-toggle-track {
  background: #16a36a;
}

.payment-product-toggle.is-enabled .payment-product-toggle-thumb {
  transform: translateX(14px);
}

.payment-product-toggle-label {
  line-height: 18px;
  white-space: nowrap;
}

.modal-header {
  border-bottom-color: #dce5ef;
  background: var(--theme-modal);
}

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

.modal {
  --excelai-modal-lift: 6vh;
}

.modal.show {
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.modal.show .modal-dialog {
  width: calc(100% - var(--bs-modal-margin) * 2);
  margin: 0 auto;
  transform: translateY(calc(-1 * var(--excelai-modal-lift)));
}

.modal.show .modal-dialog-scrollable {
  height: auto;
  max-height: calc(100vh - 4rem - var(--excelai-modal-lift));
}

.modal.show .modal-dialog-scrollable .modal-content {
  max-height: calc(100vh - 4rem - var(--excelai-modal-lift));
}

@media (max-width: 575.98px) {
  .modal.show {
    align-items: flex-start;
  }

  .modal.show .modal-dialog {
    margin: 1rem auto;
    transform: none;
  }

  .modal.show .modal-dialog-scrollable,
  .modal.show .modal-dialog-scrollable .modal-content {
    max-height: calc(100vh - 2rem);
  }
}

@media (max-width: 991.98px) {
  .admin-shell {
    display: block;
  }

  .admin-sidebar {
    position: relative;
    width: 100%;
    height: auto;
    min-height: 0;
  }

  .topbar {
    position: relative;
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .content-wrap {
    padding: 18px 16px 28px;
  }
}

.finance-page-title {
  align-items: end;
}

.finance-kicker,
.finance-panel-heading > div > span {
  display: block;
  margin-bottom: 5px;
  color: var(--theme-primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .11em;
}

.finance-validation:empty {
  display: none;
}

.finance-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.finance-metrics article {
  position: relative;
  min-height: 126px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid #dbe5df;
  border-radius: 12px;
  background:
    linear-gradient(145deg, rgba(16, 124, 65, .08), transparent 58%),
    #fff;
}

.finance-metrics article::after {
  position: absolute;
  right: -18px;
  bottom: -38px;
  width: 90px;
  height: 90px;
  border: 18px solid rgba(16, 124, 65, .06);
  border-radius: 50%;
  content: "";
}

.finance-metrics span,
.finance-metrics small {
  display: block;
  color: var(--muted);
}

.finance-metrics strong {
  display: block;
  margin: 7px 0 3px;
  color: var(--ink);
  font-size: 30px;
  line-height: 1;
}

.finance-metrics small {
  font-size: 12px;
}

.finance-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  overflow-x: auto;
  border: 1px solid #dce5ef;
  border-radius: 10px;
  background: #f6f8fb;
}

.finance-tabs a {
  min-width: 112px;
  padding: 9px 14px;
  border-radius: 7px;
  color: #5d6978;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.finance-tabs a:hover,
.finance-tabs a.active {
  background: #fff;
  color: var(--theme-primary);
  box-shadow: 0 2px 8px rgba(23, 43, 77, .08);
}

.finance-panel {
  border-radius: 12px;
}

.finance-panel-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 16px;
}

.finance-panel-heading.compact {
  align-items: center;
  margin-bottom: 12px;
}

.finance-panel-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
}

.finance-panel-heading p {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.finance-table {
  min-width: 980px;
  margin-bottom: 0;
}

.finance-table td {
  font-size: 13px;
  vertical-align: top;
}

.finance-table td > strong,
.finance-table td > span,
.finance-table td > small {
  display: block;
}

.finance-table td > small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.finance-table td > p {
  max-width: 300px;
  margin: 5px 0 0;
  color: #5f6b7a;
  font-size: 12px;
  white-space: normal;
}

.finance-action-cell {
  min-width: 118px;
}

.finance-action-details {
  position: relative;
}

.finance-action-details > summary {
  width: max-content;
  padding: 5px 10px;
  border: 1px solid var(--theme-soft-border);
  border-radius: 6px;
  color: var(--theme-primary);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.finance-action-details > summary::-webkit-details-marker {
  display: none;
}

.finance-action-popover {
  display: grid;
  gap: 7px;
  width: 290px;
  margin-top: 8px;
  padding: 12px;
  border: 1px solid #ced9e6;
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 16px 38px rgba(23, 43, 77, .14);
}

.finance-action-popover + .finance-action-popover {
  margin-top: 8px;
  border-top-color: #f0caca;
}

.finance-action-popover label {
  color: #586474;
  font-size: 11px;
  font-weight: 700;
}

.finance-action-popover input,
.finance-action-popover textarea,
.finance-action-popover select {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid #ccd7e4;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
}

.finance-reconcile-grid {
  display: grid;
  grid-template-columns: minmax(320px, .78fr) minmax(480px, 1.22fr);
  gap: 14px;
}

.finance-inline-form {
  display: flex;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
}

.finance-inline-form label {
  display: grid;
  flex: 1;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.finance-inline-form input {
  padding: 8px 10px;
  border: 1px solid #ccd7e4;
  border-radius: 6px;
}

.finance-run-list article {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 8px 16px;
  padding: 11px 0;
  border-top: 1px solid #edf1f5;
}

.finance-run-list article:first-of-type {
  border-top: 0;
}

.finance-run-list article strong,
.finance-run-list article small {
  display: block;
}

.finance-run-list article small {
  color: var(--muted);
  font-size: 11px;
}

.finance-run-list dl {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 0;
}

.finance-run-list dl div {
  padding: 7px 9px;
  border-radius: 6px;
  background: #f6f8fb;
}

.finance-run-list dt {
  color: var(--muted);
  font-size: 10px;
}

.finance-run-list dd {
  margin: 1px 0 0;
  color: var(--ink);
  font-size: 12px;
}

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

  .finance-reconcile-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 575.98px) {
  .finance-metrics {
    grid-template-columns: 1fr;
  }

  .finance-panel-heading {
    align-items: start;
    flex-direction: column;
    gap: 8px;
  }

  .finance-panel-heading p {
    text-align: left;
  }

  .finance-inline-form {
    align-items: stretch;
    flex-direction: column;
  }
}
