:root {
  --bg: #fbf8f2;
  --surface: #fffdfa;
  --surface-soft: #f7f3eb;
  --line: #e3ddd2;
  --line-strong: #d5cbbd;
  --text: #202124;
  --muted: #8a8990;
  --muted-2: #aaa7a0;
  --primary: #1c1c1e;
  --primary-soft: #fff2df;
  --accent: #ff8a00;
  --blue: #0a84ff;
  --green: #24c660;
  --amber: #b7791f;
  --red: #b42318;
  --radius: 8px;
  --shadow: 0 14px 30px rgba(43, 36, 26, .06);
}

html[data-theme="dark"] {
  --bg: #101215;
  --surface: #171a1f;
  --surface-soft: #22262d;
  --line: #2d333b;
  --line-strong: #3c444f;
  --text: #edf1f7;
  --muted: #a4adba;
  --muted-2: #7f8792;
  --primary: #f4f7fb;
  --primary-soft: #243246;
  --accent: #ffb357;
  --blue: #5ea0ff;
  --green: #53d18b;
  --amber: #f0c062;
  --red: #ff7b72;
  --shadow: 0 18px 32px rgba(0, 0, 0, .28);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

/* 全局自定义下拉（el-select.js） */
.el-select {
  position: relative;
  display: block;
  width: 100%;
}

.el-select-native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.el-select__trigger {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fffdfa;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.el-select__trigger:hover,
.el-select.is-open .el-select__trigger {
  border-color: var(--blue);
}

.el-select.is-open .el-select__trigger {
  box-shadow: inset 0 0 0 2px rgba(10, 132, 255, .18);
}

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

.el-select__caret {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  margin-top: -3px;
  transition: transform .18s ease;
}

.el-select.is-open .el-select__caret {
  transform: rotate(-135deg);
  margin-top: 3px;
}

.el-select__popper {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .12);
}

.el-select__popper.is-hidden {
  display: none;
}

.el-select__option {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}

.el-select__option:last-child {
  border-bottom: none;
}

.el-select__option:hover {
  background: var(--primary-soft);
}

.el-select__option.is-selected {
  background: #e8f4ff;
  color: var(--blue);
  font-weight: 800;
}

.el-select__option:disabled {
  color: var(--muted-2);
  cursor: not-allowed;
}

.el-select.is-compact .el-select__trigger {
  min-height: 42px;
}

html[data-theme="dark"] .el-select__trigger {
  background: var(--surface);
}

html[data-theme="dark"] .el-select__popper {
  box-shadow: 0 12px 28px rgba(0, 0, 0, .45);
}

.toolbar-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  justify-content: flex-end;
}

.toolbar-actions .ghost-btn,
.toolbar-actions .primary-btn {
  min-width: 72px;
  min-height: 42px;
  padding: 0 16px;
}

button {
  cursor: pointer;
}

code {
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 12px;
}

.admin-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.admin-layout.sidebar-collapsed {
  grid-template-columns: 88px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px 16px;
  background: #fffdfa;
  color: var(--text);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 8px 20px;
  border-bottom: 1px solid var(--line);
}

.sidebar-brand-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: #1c1c1e;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 10px 18px rgba(28, 28, 30, .12);
}

.brand-logo img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.sidebar-brand strong,
.sidebar-brand small {
  display: block;
}

.sidebar-brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .06em;
}

.sidebar-toggle {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdfa;
  color: var(--muted);
  font-weight: 900;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.theme-toggle {
  min-width: 48px;
  height: 32px;
  padding: 0 10px;
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.theme-toggle:hover,
.sidebar-toggle:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: var(--primary-soft);
}

.side-nav {
  display: grid;
  gap: 8px;
}

.side-nav a {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
}

.nav-icon {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: #f2efe8;
  color: var(--text);
  overflow: hidden;
}

.nav-icon img {
  width: 21px;
  height: 21px;
  object-fit: contain;
}

.side-nav a.active,
.side-nav a:hover {
  border-color: var(--line);
  background: var(--primary-soft);
  color: var(--text);
}

.side-nav a.active .nav-icon,
.side-nav a:hover .nav-icon {
  background: #1c1c1e;
  color: #fff;
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7f3eb;
}

.sidebar-foot-user {
  display: grid;
  gap: 4px;
}

.sidebar-foot-user span {
  font-weight: 700;
}

.sidebar-foot-user small {
  color: var(--muted);
}

.sidebar-foot-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sidebar-foot-actions #changePasswordBtn,
.sidebar-foot-actions #logoutBtn {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
  font-weight: 800;
  cursor: pointer;
}

.sidebar.is-collapsed .sidebar-foot {
  justify-items: center;
  padding: 10px 8px;
}

.sidebar.is-collapsed .sidebar-foot-actions {
  justify-content: center;
}

.sidebar.is-collapsed {
  padding-left: 10px;
  padding-right: 10px;
}

.sidebar.is-collapsed .sidebar-brand {
  padding-left: 0;
  padding-right: 0;
  justify-content: center;
}

.sidebar.is-collapsed .sidebar-brand-main {
  justify-content: center;
}

.sidebar.is-collapsed .sidebar-brand-actions {
  display: grid;
  gap: 6px;
}

.sidebar.is-collapsed .sidebar-toggle {
  width: 48px;
}

.sidebar.is-collapsed .sidebar-foot .theme-toggle {
  width: 48px;
  min-width: 48px;
  padding: 0;
}

.sidebar.is-collapsed .side-nav {
  justify-items: center;
}

.sidebar.is-collapsed .nav-group {
  width: 100%;
}

.sidebar.is-collapsed .side-nav a {
  width: 100%;
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.sidebar.is-collapsed .nav-icon {
  width: 32px;
  height: 32px;
}

.main-shell {
  min-width: 0;
  padding: 36px;
}

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

.topbar h1 {
  margin: 6px 0 0;
  font-size: 36px;
  line-height: 1.12;
  letter-spacing: 0;
  font-weight: 900;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: none;
}

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

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
}

.panel-head a,
.panel-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.ghost-btn,
.ghost-link,
.primary-link,
.primary-btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  padding: 0 16px;
  background: var(--surface);
  color: var(--text);
  font-weight: 850;
}

.primary-link,
.primary-btn {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  box-shadow: 0 12px 18px rgba(10, 132, 255, .14);
}

.table-wrap {
  position: relative;
  width: 100%;
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.data-table th,
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.data-table th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.data-table tbody tr:hover {
  background: var(--primary-soft);
}

.data-table th:last-child,
.data-table td:last-child {
  position: sticky;
  right: 0;
}

.data-table th:last-child {
  z-index: 3;
  background: var(--surface-soft);
  box-shadow: -10px 0 14px rgba(43, 36, 26, .06);
}

.data-table td:last-child {
  z-index: 2;
  background: var(--surface);
  box-shadow: -10px 0 14px rgba(43, 36, 26, .06);
}

.data-table tbody tr:hover td:last-child {
  background: var(--primary-soft);
}

.user-link,
.row-action {
  color: var(--blue);
  font-weight: 750;
}

.pill,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: #fff1e6;
  color: #d66c00;
  font-size: 12px;
  font-weight: 800;
}

.status.normal {
  background: #e7f8f0;
  color: var(--green);
}

.status.watch {
  background: #fff6df;
  color: var(--amber);
}

.status.disabled {
  background: #fee4e2;
  color: var(--red);
}

.empty-cell {
  color: var(--muted);
  text-align: center !important;
}

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9999;
  display: grid;
  gap: 8px;
}

.toast {
  max-width: 360px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 11px 13px;
  background: #1c1c1e;
  color: #fff;
  box-shadow: var(--shadow);
  line-height: 1.5;
  transition: opacity .18s ease, transform .18s ease;
}

.toast.leaving {
  opacity: 0;
  transform: translateY(6px);
}

.saas-confirm-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(28, 28, 30, .32);
  backdrop-filter: blur(4px);
  z-index: 10000;
}

.saas-confirm-modal.is-open {
  display: flex;
}

.saas-confirm-card {
  width: min(100%, 460px);
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.saas-confirm-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.saas-confirm-head strong {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}

.saas-confirm-message {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.saas-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.saas-confirm-ok.is-danger {
  border-color: var(--red);
  background: var(--red);
  box-shadow: 0 12px 18px rgba(180, 35, 24, .18);
}

@media (max-width: 900px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .admin-layout.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .main-shell {
    padding: 22px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

.nav-item-block {
  display: grid;
  gap: 4px;
}

.nav-sub-group {
  display: grid;
  gap: 2px;
  padding-left: 18px;
}

.nav-sub-link {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.nav-sub-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #c8c2b6;
  flex: 0 0 auto;
}

.nav-sub-link.active .nav-sub-dot,
.nav-item-block.is-parent-active .nav-sub-link.active .nav-sub-dot {
  background: var(--blue);
}

.nav-sub-link.active,
.nav-sub-link:hover {
  border-color: var(--line);
  background: var(--primary-soft);
  color: var(--text);
}

.nav-group {
  margin-bottom: 8px;
}

.nav-group-title {
  padding: 4px 10px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .04em;
  text-transform: uppercase;
}

html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .overview-stat-card,
html[data-theme="dark"] .task-summary-card,
html[data-theme="dark"] .task-section,
html[data-theme="dark"] .task-request-row,
html[data-theme="dark"] .toolbar,
html[data-theme="dark"] .data-source-bar,
html[data-theme="dark"] .overview-panel,
html[data-theme="dark"] .account-stat-card,
html[data-theme="dark"] .settings-surface,
html[data-theme="dark"] .settings-hero,
html[data-theme="dark"] .settings-inline-note,
html[data-theme="dark"] .param-card,
html[data-theme="dark"] .param-meta-grid div,
html[data-theme="dark"] .overview-stat-card,
html[data-theme="dark"] .detail-card,
html[data-theme="dark"] .mini-metric,
html[data-theme="dark"] .membership-record-detail-card,
html[data-theme="dark"] .note-modal-card,
html[data-theme="dark"] .saas-confirm-card,
html[data-theme="dark"] .profile-main .detail-card {
  background: var(--surface);
}

html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .task-section,
html[data-theme="dark"] .settings-inline-note,
html[data-theme="dark"] .param-meta-grid div {
  border-color: var(--line);
}

html[data-theme="dark"] .nav-icon,
html[data-theme="dark"] .record-no,
html[data-theme="dark"] code,
html[data-theme="dark"] .chips span,
html[data-theme="dark"] .sidebar-foot,
html[data-theme="dark"] .quick-actions select,
html[data-theme="dark"] .quick-actions button,
html[data-theme="dark"] .settings-form-grid input,
html[data-theme="dark"] .settings-form-grid select,
html[data-theme="dark"] .settings-textarea-field textarea,
html[data-theme="dark"] .toolbar input,
html[data-theme="dark"] .toolbar select,
html[data-theme="dark"] .note-field textarea,
html[data-theme="dark"] .icon-btn {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--line-strong);
}

html[data-theme="dark"] .task-summary-card.is-warn,
html[data-theme="dark"] .data-source-bar {
  background: color-mix(in srgb, var(--surface-soft) 78%, #4b3312 22%);
}

html[data-theme="dark"] .flag.muted,
html[data-theme="dark"] .role-tag,
html[data-theme="dark"] .perm-pill,
html[data-theme="dark"] .matrix-no {
  background: var(--surface-soft);
  color: var(--muted);
}

html[data-theme="dark"] .module-card:hover,
html[data-theme="dark"] .metric-card:hover,
html[data-theme="dark"] .task-request-row:hover,
html[data-theme="dark"] .settings-card:hover,
html[data-theme="dark"] .quick-actions button:hover,
html[data-theme="dark"] .side-nav a:hover,
html[data-theme="dark"] .side-nav a.active {
  background: var(--primary-soft);
}
