: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);
}

.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;
  }
}
