:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-muted: #f7f9fc;
  --surface-active: #eaf2ff;
  --border: #d6dde8;
  --soft-border: #edf0f5;
  --text: #202938;
  --heading: #101828;
  --muted: #657287;
  --primary: #0052d9;
  --primary-dark: #003cab;
  --danger: #c9352b;
  --success: #16845b;
  --warning: #b66a14;
  --shadow: 0 8px 18px rgba(16, 24, 40, 0.05);
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

body[data-admin-theme-mode="dark"] {
  --bg: #000000;
  --surface: #0b0b0d;
  --surface-muted: #151518;
  --border: #2a2a2f;
  --soft-border: #202024;
  --text: #e8e8ea;
  --heading: #ffffff;
  --muted: #9a9aa2;
  --shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: none;
}

.admin-page-shell {
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  overflow: hidden;
  transition: grid-template-columns 0.18s ease;
}

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

.admin-sidebar {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 8px 12px;
  min-width: 0;
  overflow: hidden auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  scrollbar-color: #c8d0dc transparent;
  scrollbar-width: thin;
}

.admin-sidebar::-webkit-scrollbar {
  width: 6px;
}

.admin-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.admin-sidebar::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #c8d0dc;
}

.admin-sidebar-head {
  min-height: 48px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 -8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.admin-brand {
  min-height: 40px;
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  padding: 0 6px;
  border-radius: var(--radius);
  color: var(--heading);
  font-size: 18px;
  font-weight: 400;
  white-space: nowrap;
}

.admin-brand-logo {
  display: block;
  width: auto;
  max-width: 154px;
  height: 30px;
  object-fit: contain;
}

.admin-brand:hover {
  background: var(--surface-active);
  color: var(--primary);
}

.admin-sidebar-toggle {
  position: relative;
  width: 34px;
  height: 34px;
  min-height: 34px;
  flex: 0 0 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--soft-border);
  border-radius: var(--radius);
  background: var(--surface-muted);
  color: var(--muted);
  cursor: pointer;
}

.admin-sidebar-toggle:hover {
  border-color: #bed3ff;
  background: var(--surface-active);
  color: var(--primary);
}

.admin-sidebar-toggle-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.admin-sidebar-toggle-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.admin-page-shell.sidebar-collapsed .admin-sidebar-head {
  justify-content: center;
  gap: 0;
  padding-right: 0;
  padding-left: 0;
}

.admin-page-shell.sidebar-collapsed .admin-brand {
  display: none;
  flex: 0 0 auto;
  padding: 0;
  font-size: 0;
}

.admin-page-shell.sidebar-collapsed .admin-sidebar-toggle {
  justify-content: center;
  padding: 0;
}

.admin-menu {
  display: grid;
  gap: 1px;
  padding-top: 4px;
}

.admin-menu-section {
  display: grid;
  gap: 0;
  margin-top: 3px;
}

.admin-menu-title {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  padding: 5px 12px;
  color: #344054;
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  text-align: left;
}

.admin-menu-title-main {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.admin-menu-title.is-iconless .admin-menu-title-main {
  gap: 0;
}

.admin-menu-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: #667085;
}

.admin-menu-icon svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.85;
}

.admin-menu-title-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-menu-title:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.admin-menu-title:hover .admin-menu-icon {
  color: currentColor;
}

.admin-menu-arrow {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.16s ease;
}

.admin-menu-title[aria-expanded="true"] .admin-menu-arrow {
  transform: rotate(225deg);
}

.admin-menu-items {
  display: grid;
  gap: 0;
}

.admin-menu-section.is-collapsed .admin-menu-items {
  display: none;
}

.admin-menu-link {
  min-height: 34px;
  display: flex;
  align-items: center;
  margin-left: 28px;
  padding: 5px 10px;
  border-radius: var(--radius);
  color: var(--muted);
}

.admin-menu-link:hover {
  color: var(--text);
  background: transparent;
}

.admin-menu-link.active {
  position: relative;
  background: transparent;
  color: var(--primary);
  font-weight: 400;
}

.admin-menu-link.active::before {
  position: absolute;
  left: 0;
  width: 3px;
  height: 18px;
  border-radius: 0 4px 4px 0;
  background: var(--primary);
  content: "";
}

.admin-page-shell.sidebar-collapsed .admin-menu {
  gap: 3px;
}

.admin-page-shell.sidebar-collapsed .admin-menu-section {
  margin-top: 5px;
}

.admin-page-shell.sidebar-collapsed .admin-menu-title,
.admin-page-shell.sidebar-collapsed .admin-menu-link {
  justify-content: center;
  width: 44px;
  min-height: 38px;
  margin-right: auto;
  margin-left: auto;
  padding: 0;
  text-align: center;
}

.admin-page-shell.sidebar-collapsed .admin-menu-title-main {
  justify-content: center;
  gap: 0;
}

.admin-page-shell.sidebar-collapsed .admin-menu-title-text,
.admin-page-shell.sidebar-collapsed .admin-menu-arrow {
  display: none;
}

.admin-page-shell.sidebar-collapsed .admin-menu-items {
  display: none;
}

.admin-page-shell.sidebar-collapsed .admin-menu-link {
  font-size: 0;
}

.admin-main {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr);
  position: relative;
  overflow: hidden;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
  min-height: 48px;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.admin-account {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  color: var(--text);
}

.admin-account-button {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 4px 9px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.admin-account-button:hover,
.admin-account.open .admin-account-button {
  border-color: #bed3ff;
  background: var(--surface-active);
  color: var(--primary);
}

.admin-account-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.admin-account-meta {
  display: block;
  text-align: left;
  font-weight: 400;
  line-height: 1.2;
}

.admin-account-meta small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.admin-account-caret {
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
}

.admin-account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  min-width: 150px;
  display: none;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
}

.admin-account.open .admin-account-menu {
  display: grid;
  gap: 4px;
}

.admin-account-menu a,
.admin-account-menu button {
  min-height: 34px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius);
  padding: 6px 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 400;
  text-align: left;
}

.admin-account-menu a:hover,
.admin-account-menu button:hover {
  background: var(--surface-active);
  color: var(--primary);
}

.admin-account-menu-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
  color: var(--muted);
}

.admin-content {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 0;
  min-height: calc(100vh - 114px);
  margin: 16px 18px 35px;
  padding: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
}

.admin-copyright {
  position: absolute;
  right: 18px;
  bottom: 8px;
  left: 18px;
  min-height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  background: transparent;
  color: #8a95a6;
  font-size: 13px;
  line-height: 18px;
  pointer-events: none;
}

.admin-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--soft-border);
}

.admin-page-head h1 {
  margin: 0;
  color: var(--heading);
  font-size: 18px;
  line-height: 1.25;
}

.admin-page-head p {
  margin: 3px 0 0;
  color: var(--muted);
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 34px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
}

.admin-tab {
  position: relative;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  padding: 0 4px;
  border: 0;
  color: #344054;
  font-weight: 800;
}

.admin-tab:hover {
  color: var(--primary);
  background: transparent;
}

.admin-tab.active {
  color: var(--primary);
}

.admin-tab.active::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 3px;
  background: var(--primary);
  content: "";
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 20px;
}

.stat-card,
.admin-panel,
.login-card {
  background: var(--surface);
  border: 1px solid var(--soft-border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);
}

.stat-card {
  min-height: 104px;
  padding: 18px;
  display: grid;
  align-content: space-between;
}

.stat-card span {
  color: var(--muted);
  font-weight: 700;
}

.stat-card strong {
  color: var(--heading);
  font-size: 28px;
}

.admin-panel {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.admin-content > .admin-panel,
.admin-content > form.admin-panel {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 18px 20px;
}

.admin-content > .admin-panel + .admin-panel,
.admin-content > form.admin-panel + .admin-panel,
.admin-content > .admin-panel + form.admin-panel {
  border-top: 1px solid var(--soft-border);
}

.admin-content > .admin-tabs + .admin-panel,
.admin-content > .admin-page-head + .admin-panel,
.admin-content > .admin-page-head + form.admin-panel {
  border-top: 0;
}

.panel-title {
  color: var(--heading);
  font-size: 16px;
  font-weight: 800;
}

.admin-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  height: 46px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--soft-border);
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  background: var(--surface-muted);
  color: #465367;
  font-size: 13px;
  font-weight: 800;
}

.admin-table tbody tr:hover td {
  background: #f9fbff;
}

.admin-empty {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.admin-table-pagination {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px 12px;
}

.admin-table-pagination-total {
  color: var(--muted);
  font-size: 13px;
}

.admin-table-pagination-total strong {
  color: var(--heading);
}

.admin-table-pager {
  display: flex;
  align-items: center;
  gap: 4px;
}

.admin-table-pager select,
.admin-table-page-jump input {
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text);
}

.admin-table-pager select {
  width: auto;
  min-width: 84px;
  padding: 0 16px 0 7px;
}

.admin-table-page-nav,
.admin-table-page-btn {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: #465367;
  cursor: pointer;
  font-weight: 700;
}

.admin-table-page-nav:disabled,
.admin-table-page-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.admin-table-page-btn.is-active {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.admin-table-page-list {
  display: inline-flex;
  gap: 3px;
}

.admin-table-page-jump {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #465367;
  font-size: 13px;
  white-space: nowrap;
}

.admin-table-page-jump input {
  width: 48px;
  padding: 0 6px;
  text-align: center;
}

.admin-table-page-nav:focus,
.admin-table-page-btn:focus,
.admin-table-page-jump input:focus,
.admin-table-pager select:focus {
  outline: none;
  box-shadow: none;
}

.admin-status {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 800;
}

.admin-status.active,
.admin-status.visible,
.admin-status.enabled,
.admin-status.completed,
.admin-status.paid,
.admin-status.approved {
  background: #e8f7f0;
  color: var(--success);
}

.admin-status.hidden,
.admin-status.disabled,
.admin-status.uninstalled,
.admin-status.unpaid,
.admin-status.pending,
.admin-status.processing {
  background: #fff6e7;
  color: var(--warning);
}

.admin-status.failed,
.admin-status.rejected,
.admin-status.terminated {
  background: #fff0ef;
  color: var(--danger);
}

.login-page {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(0, 82, 217, 0.08), rgba(22, 132, 91, 0.06)),
    var(--bg);
}

.admin-login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-page .admin-page-shell {
  grid-template-columns: 1fr;
}

.login-page .admin-sidebar,
.login-page .admin-topbar {
  display: none;
}

.login-page .admin-main {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr;
  place-items: center;
}

.login-page .admin-content {
  width: min(430px, calc(100vw - 32px));
  padding: 0;
}

.admin-login-shell .login-card,
.login-card {
  width: min(430px, 100%);
  display: grid;
  gap: 18px;
  padding: 30px;
  border-color: var(--border);
  border-radius: 8px;
  box-shadow: 0 22px 56px rgba(16, 24, 40, 0.10);
}

.login-card-head {
  display: grid;
  gap: 8px;
}

.admin-login-logo {
  display: block;
  width: auto;
  max-width: 176px;
  height: 34px;
  object-fit: contain;
}

.login-card-head strong {
  color: var(--heading);
  font-size: 24px;
}

.login-card-head span {
  color: var(--muted);
}

.admin-form {
  display: grid;
  gap: 14px;
}

.admin-form label,
.admin-field {
  display: grid;
  gap: 6px;
  color: #475569;
  font-weight: 800;
}

.admin-form input,
.admin-form select,
.admin-form textarea,
.admin-field input,
.admin-field select,
.admin-field textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: #ffffff;
  color: var(--text);
}

.admin-form input:focus,
.admin-form select:focus,
.admin-form textarea:focus,
.admin-field input:focus,
.admin-field select:focus,
.admin-field textarea:focus {
  outline: none;
  border-color: var(--border);
  box-shadow: none;
}

[data-admin-tab-panel][hidden] {
  display: none !important;
}

.theme-settings-form {
  display: grid;
  gap: 28px;
  padding-top: 24px;
}

body.theme-drawer-open {
  overflow: hidden;
}

.admin-theme-drawer-mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  visibility: hidden;
  background: rgba(15, 23, 42, 0.44);
  opacity: 0;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.admin-theme-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  z-index: 90;
  width: min(360px, calc(100vw - 32px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-left: 1px solid var(--border);
  background: var(--surface);
  box-shadow: none;
  transform: translateX(100%);
  transition: transform 0.22s ease;
}

body.theme-drawer-open .admin-theme-drawer-mask {
  visibility: visible;
  opacity: 1;
}

body.theme-drawer-open .admin-theme-drawer {
  transform: translateX(0);
}

.admin-theme-drawer-head {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--soft-border);
}

.admin-theme-drawer-head strong {
  color: var(--heading);
  font-size: 16px;
}

.admin-theme-drawer-close {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.admin-theme-drawer-close:hover {
  background: var(--surface-active);
  color: var(--primary);
}

.admin-theme-drawer-close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.admin-theme-drawer-form {
  min-height: 0;
  align-content: start;
  overflow-y: auto;
  padding: 18px;
}

.admin-theme-drawer-form.theme-settings-form {
  gap: 18px;
  padding-top: 18px;
}

.admin-theme-drawer-form .theme-setting-section {
  gap: 10px;
}

.admin-theme-drawer-form .theme-mode-grid {
  gap: 12px 18px;
}

.admin-theme-drawer-form .theme-mode-option {
  min-width: 112px;
  gap: 6px;
}

.admin-theme-drawer-form .theme-mode-preview {
  width: 108px;
  height: 60px;
}

.admin-theme-drawer-form .theme-color-grid {
  gap: 10px 18px;
}

.admin-theme-drawer-form .theme-color-option {
  width: 32px;
  height: 32px;
}

.admin-theme-drawer-form .theme-color-swatch {
  width: 22px;
  height: 22px;
}

.theme-setting-section {
  display: grid;
  gap: 18px;
}

.theme-setting-title {
  color: var(--heading);
  font-size: 14px;
  font-weight: 800;
}

.theme-mode-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 28px 80px;
}

.theme-native-control {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-mode-option {
  position: relative;
  min-width: 128px;
  display: grid;
  justify-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text);
  font-weight: 700;
}

.theme-mode-preview {
  width: 108px;
  height: 68px;
  display: grid;
  place-items: center;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--surface-muted);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.theme-mode-preview.light {
  color: #101828;
  background: #d9dde5;
}

.theme-mode-preview.dark {
  color: #d7e3f5;
  background: #121820;
}

.theme-mode-preview svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.theme-mode-option.active .theme-mode-preview,
.theme-mode-option:has(.theme-native-control:checked) .theme-mode-preview {
  border-color: var(--primary);
  box-shadow: none;
}

.theme-native-control:focus-visible + .theme-mode-preview,
.theme-native-control:focus-visible + .theme-color-swatch {
  outline: none;
  box-shadow: none;
}

.theme-color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 20px;
  align-items: center;
}

.theme-color-option {
  position: relative;
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.theme-color-swatch {
  width: 24px;
  height: 24px;
  display: block;
  border-radius: 50%;
  background: var(--swatch);
}

.theme-color-option.active,
.theme-color-option:has(.theme-native-control:checked) {
  border: 2px solid var(--primary);
  border-radius: 50%;
}

.theme-color-option.active .theme-color-swatch,
.theme-color-option:has(.theme-native-control:checked) .theme-color-swatch {
  width: 24px;
  height: 24px;
  box-shadow: inset 0 0 0 2px var(--surface);
}

.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

.admin-form-grid.single {
  grid-template-columns: minmax(0, 420px);
}

.table-form {
  margin: 0;
  display: grid;
  gap: 8px;
}

.table-form-grid {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(180px, 1.4fr) minmax(120px, 1fr) minmax(96px, 0.7fr) auto;
  gap: 8px;
  align-items: center;
}

.table-form-grid.role-name-grid {
  grid-template-columns: minmax(180px, 1fr) 120px 120px auto;
}

.table-form input,
.table-form select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px;
  background: #ffffff;
  color: var(--text);
}

.password-form {
  grid-template-columns: minmax(120px, 1fr) auto;
  align-items: center;
}

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

.permission-group {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.permission-group legend {
  padding: 0 4px;
  color: var(--heading);
  font-weight: 800;
}

.permission-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #475569;
  font-weight: 600;
}

.permission-group input {
  width: 15px;
  height: 15px;
}

.admin-checkbox {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 22px;
}

.admin-checkbox input {
  width: 16px;
  min-height: 16px;
}

.admin-help {
  margin: 0;
  color: var(--muted);
}

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

.inline-form {
  margin: 0;
}

.danger-panel {
  border-color: #fecdca;
}

.admin-btn {
  min-height: 40px;
  border: 0;
  border-radius: var(--radius);
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 800;
}

.admin-btn.primary {
  background: var(--primary);
  color: #ffffff;
}

.admin-btn.primary:hover {
  background: var(--primary-dark);
}

.admin-btn.secondary {
  background: #e2e8f0;
  color: #1e293b;
}

.admin-btn.secondary:hover {
  background: #cbd5e1;
}

.admin-btn.danger {
  background: var(--danger);
  color: #ffffff;
}

.admin-btn.danger:hover {
  background: #a72f27;
}

.admin-btn.small {
  min-height: 32px;
  padding: 5px 10px;
}

body[data-admin-theme-mode="dark"] .admin-sidebar {
  scrollbar-color: #333338 transparent;
}

body[data-admin-theme-mode="dark"] .admin-sidebar::-webkit-scrollbar-thumb {
  background: #333338;
}

body[data-admin-theme-mode="dark"] .admin-sidebar-toggle:hover,
body[data-admin-theme-mode="dark"] .admin-account-button:hover,
body[data-admin-theme-mode="dark"] .admin-account.open .admin-account-button {
  border-color: var(--primary);
}

body[data-admin-theme-mode="dark"] .admin-tab,
body[data-admin-theme-mode="dark"] .admin-table th,
body[data-admin-theme-mode="dark"] .admin-table-page-nav,
body[data-admin-theme-mode="dark"] .admin-table-page-btn {
  color: var(--text);
}

body[data-admin-theme-mode="dark"] .admin-table tbody tr:hover td {
  background: #111113;
}

body[data-admin-theme-mode="dark"] .admin-form label,
body[data-admin-theme-mode="dark"] .admin-field,
body[data-admin-theme-mode="dark"] .permission-group label {
  color: var(--text);
}

body[data-admin-theme-mode="dark"] .admin-form input,
body[data-admin-theme-mode="dark"] .admin-form select,
body[data-admin-theme-mode="dark"] .admin-form textarea,
body[data-admin-theme-mode="dark"] .admin-field input,
body[data-admin-theme-mode="dark"] .admin-field select,
body[data-admin-theme-mode="dark"] .admin-field textarea,
body[data-admin-theme-mode="dark"] .table-form input,
body[data-admin-theme-mode="dark"] .table-form select {
  background: #101012;
  color: var(--text);
  border-color: var(--border);
}

body[data-admin-theme-mode="dark"] .admin-btn.secondary {
  background: #1a1a1d;
  color: var(--text);
}

body[data-admin-theme-mode="dark"] .admin-btn.secondary:hover {
  background: #242428;
}

body[data-admin-theme-mode="dark"] .admin-alert {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.admin-alert {
  position: relative;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #e4e7ed;
  border-radius: var(--radius);
  padding: 10px 16px 10px 44px;
  margin: 16px 22px 0;
  background: #ffffff;
  color: #1f2937;
  line-height: 1.25;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
}

.admin-page-shell .admin-alert,
.login-page .admin-alert {
  position: fixed;
  top: 54px;
  left: 50%;
  z-index: 1400;
  width: max-content;
  max-width: min(520px, calc(100vw - 48px));
  margin: 0;
  padding: 10px 16px 10px 44px;
  background: #ffffff;
  transform: translate(-50%, 0);
  pointer-events: none;
  animation: admin-alert-enter 0.22s ease-out both;
}

.admin-alert::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 16px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #667085;
  transform: translateY(-50%);
}

.admin-alert.success::before {
  background: #2eaf75;
}

.admin-alert.error::before {
  background: #d92d20;
}

.admin-alert.success::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 22px;
  width: 5px;
  height: 9px;
  border-right: 2px solid #ffffff;
  border-bottom: 2px solid #ffffff;
  transform: translateY(-60%) rotate(45deg);
}

.admin-alert.error::after {
  position: absolute;
  top: 50%;
  left: 16px;
  width: 18px;
  color: #ffffff;
  content: "!";
  font-size: 12px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  transform: translateY(-50%);
}

.login-page .admin-alert {
  top: 24px;
}

.admin-page-shell .admin-alert.is-leaving,
.login-page .admin-alert.is-leaving {
  animation: admin-alert-leave 0.18s ease-in both;
}

.admin-alert.error {
  color: #1f2937;
}

.admin-alert.success {
  color: #1f2937;
}

@keyframes admin-alert-enter {
  from {
    opacity: 0;
    transform: translate(-50%, -12px);
  }

  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@keyframes admin-alert-leave {
  from {
    opacity: 1;
    transform: translate(-50%, 0);
  }

  to {
    opacity: 0;
    transform: translate(-50%, -12px);
  }
}

.admin-confirm-mask {
  position: fixed;
  inset: 0;
  z-index: 1600;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.42);
  animation: admin-confirm-mask-enter 0.16s ease-out both;
}

.admin-confirm-mask.is-leaving {
  animation: admin-confirm-mask-leave 0.14s ease-in both;
}

.admin-confirm-dialog {
  width: min(380px, 100%);
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 18px;
  animation: admin-confirm-dialog-enter 0.18s ease-out both;
}

.admin-confirm-mask.is-leaving .admin-confirm-dialog {
  animation: admin-confirm-dialog-leave 0.14s ease-in both;
}

.admin-confirm-icon {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #fff1f0;
  color: var(--danger);
}

.admin-confirm-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.admin-confirm-body {
  min-width: 0;
}

.admin-confirm-body h3 {
  margin: 0;
  color: var(--heading);
  font-size: 16px;
  font-weight: 600;
}

.admin-confirm-body p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}

.admin-confirm-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.admin-confirm-actions .admin-btn {
  min-width: 74px;
}

body[data-admin-theme-mode="dark"] .admin-confirm-icon {
  background: rgba(201, 53, 43, 0.14);
}

@keyframes admin-confirm-mask-enter {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes admin-confirm-mask-leave {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

@keyframes admin-confirm-dialog-enter {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes admin-confirm-dialog-leave {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .admin-page-shell .admin-alert,
  .login-page .admin-alert,
  .admin-page-shell .admin-alert.is-leaving,
  .login-page .admin-alert.is-leaving,
  .admin-confirm-mask,
  .admin-confirm-mask.is-leaving,
  .admin-confirm-dialog,
  .admin-confirm-mask.is-leaving .admin-confirm-dialog {
    animation: none;
  }
}

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

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

  .admin-sidebar {
    position: static;
  }

  .admin-main {
    grid-template-rows: 48px minmax(0, 1fr);
  }

  .admin-topbar {
    min-height: 48px;
    align-items: center;
    display: flex;
    padding: 0 14px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-form-grid {
    grid-template-columns: 1fr;
  }

  .table-form-grid,
  .table-form-grid.role-name-grid,
  .password-form,
  .permission-grid {
    grid-template-columns: 1fr;
  }

  .admin-table-pagination {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-table-pager {
    flex-wrap: wrap;
  }
}

@media (max-width: 560px) {
  .admin-content {
    padding: 16px;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

}
