@use "./variables.scss";

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body {
  margin: 0;
  min-width: 320px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
}
button,
input,
textarea,
select {
  font: inherit;
}
button {
  touch-action: manipulation;
}
#app {
  width: 100%;
  min-height: 100dvh;
}
a {
  color: var(--color-primary);
  text-decoration: none;
}
h1,
h2,
h3,
h4,
p {
  margin: 0;
}
img {
  max-width: 100%;
  height: auto;
}

.admin-shell {
  min-height: 100dvh;
  padding-left: var(--sidebar-width);
}
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  background: #111827;
  color: var(--color-sidebar-text);
  border-right: 1px solid #202c3e;
  box-shadow: 4px 0 16px rgba(15, 23, 42, 0.08);
  transition: width 0.2s ease;
}
.brand {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 8px 10px;
  color: #f8fafc;
  font-size: 17px;
  white-space: nowrap;
}
.brand strong {
  font-weight: 700;
  letter-spacing: 0.02em;
}
.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #314058;
  border-radius: 9px;
  background: #182235;
}
.brand-mark img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}
.menu {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  min-height: 0;
  margin-top: 8px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #344258 transparent;
}
.menu-item {
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  background: transparent;
  color: #9cabc1;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  transition:
    background-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
}
.menu-item .el-icon {
  color: #8495ad;
  transition: color 0.15s ease;
}
.menu-item:hover {
  background: #182335;
  color: #dce5f2;
}
.menu-item:hover .el-icon {
  color: #b7c6da;
}
.menu-item.active {
  background: #24344d;
  color: #fff;
  box-shadow: inset 2px 0 #60a5fa;
}
.menu-item.active .el-icon {
  color: #e5edf8;
}
.menu-item.logout {
  flex: 0 0 auto;
  margin-top: 10px;
  background: transparent;
  color: #8493aa;
}
.menu-item.logout:hover {
  background: #182335;
  color: #dce5f2;
}
.is-collapsed {
  padding-left: var(--sidebar-collapsed-width);
}
.is-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
  padding-inline: 12px;
}
.is-collapsed .brand {
  justify-content: center;
  padding-inline: 0;
}
.is-collapsed .menu-item {
  justify-content: center;
  padding: 0;
}
.shell-main {
  min-width: 0;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  border-bottom: 1px solid var(--color-border-light);
  background: rgba(255, 255, 255, 0.96);
}
.topbar h1 {
  font-size: 18px;
  line-height: 1.3;
}
.topbar p {
  font-size: 12px;
  color: var(--color-text-secondary);
}
.topbar-menu {
  flex: 0 0 44px;
}
.admin-profile {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text-secondary);
  font-size: 14px;
}
.page-content {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px 28px 40px;
}
.page-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.management-page {
  height: max(814px, calc(100dvh - 64px));
  min-height: 814px;
}
.management-page > .table-panel {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}
.management-page > .table-panel > .el-pagination {
  margin-top: auto;
  padding-top: 18px;
}
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}
.page-header h2 {
  font-size: var(--font-size-xl);
  line-height: 1.3;
}
.page-header p {
  margin-top: 5px;
  color: var(--color-text-secondary);
  font-size: 14px;
}
.page-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.panel {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}
.table-panel {
  overflow: auto;
}
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.filter-bar > .el-input {
  width: min(280px, 100%);
}
.filter-bar > .el-select {
  width: 180px;
}
.filter-bar > .el-date-editor {
  max-width: 420px;
}
.batch-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-md);
  background: var(--color-primary-soft);
}
.batch-toolbar strong {
  margin-right: auto;
}
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.section-heading h3 {
  font-size: 17px;
}
.section-heading span {
  color: var(--color-text-secondary);
  font-size: 13px;
}
.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.balance-card {
  padding: 18px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: #fff;
}
.balance-card.warning {
  border-color: #f59e0b;
  background: #fffbeb;
}
.balance-card__header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.balance-card__header strong,
.balance-card__header span {
  display: block;
}
.balance-card__header span,
.balance-card p {
  margin-top: 3px;
  color: var(--color-text-secondary);
  font-size: 12px;
}
.balance-value {
  margin: 22px 0 14px;
  font-size: 28px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.balance-value small {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
}
.line-chart {
  width: 100%;
  height: 360px;
}
.icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.icon-button:hover {
  background: rgba(15, 23, 42, 0.08);
}
.el-button .el-icon {
  margin-right: 6px;
}
.field-full {
  width: 100% !important;
}
.field-helper {
  width: 100%;
  margin-top: 6px;
  color: var(--color-text-secondary);
  font-size: 12px;
  line-height: 1.55;
}
.form-grid,
.dialog-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 18px;
}
.dialog-field--full {
  grid-column: 1/-1;
}
.style-thumb {
  width: 64px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--color-bg);
}
.upload-preview {
  display: block;
  width: 120px;
  height: 84px;
  margin-top: 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  object-fit: cover;
}
.code-output {
  margin-top: 16px;
}
.el-pagination {
  justify-content: flex-end;
  margin-top: 18px;
}
.el-table {
  --el-table-header-bg-color: #f8fafc;
  --el-table-row-hover-bg-color: #f8fafc;
}
.el-table th.el-table__cell {
  color: #39465a;
  font-weight: 600;
}
.mobile-card-list {
  display: none;
}
.data-card {
  padding: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.data-card dl {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 8px;
  margin: 0;
}
.data-card dt {
  color: var(--color-text-secondary);
}
.data-card dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}
.el-overlay {
  background: rgba(15, 23, 42, 0.58);
}
.el-overlay-dialog {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.el-dialog {
  margin: 0;
  border: 1px solid #d3dbe7;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
  overflow: hidden;
}
.el-dialog__header {
  margin: 0;
  padding: 19px 24px 16px;
  border-bottom: 1px solid var(--color-border-light);
  background: #f8fafc;
}
.el-dialog__title {
  color: var(--color-text);
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.01em;
}
.el-dialog__headerbtn {
  top: 12px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
}
.el-dialog__headerbtn:hover {
  background: #e9eef5;
}
.el-dialog__headerbtn .el-dialog__close {
  color: #718096;
  font-size: 18px;
}
.el-dialog__body {
  max-height: calc(100dvh - 180px);
  padding: 22px 24px 6px;
  overflow-y: auto;
}
.el-dialog.managed-scroll-dialog {
  margin: 0;
  height: min(760px, calc(100dvh - 40px));
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
}
.el-dialog.managed-scroll-dialog .el-dialog__header,
.el-dialog.managed-scroll-dialog .el-dialog__footer {
  flex: 0 0 auto;
}
.el-dialog.managed-scroll-dialog .el-dialog__body {
  min-height: 0;
  max-height: none;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.managed-scroll-overlay .el-overlay-dialog {
  align-items: center;
  justify-content: center;
  overflow: hidden;
  overscroll-behavior: none;
}
.el-dialog .el-dialog__footer {
  padding: 14px 24px 16px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 0;
  background: transparent;
}
.el-dialog__footer .el-button {
  min-width: 82px;
  height: 38px;
  margin-left: 0;
  border-radius: 8px;
  font-weight: 600;
}
.el-dialog .el-form-item {
  margin-bottom: 19px;
}
.el-dialog .el-form-item__label {
  padding-bottom: 7px;
  color: #39465a;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}
.el-dialog .el-input__wrapper,
.el-dialog .el-select__wrapper {
  min-height: 40px;
  border-radius: 8px;
  box-shadow: 0 0 0 1px #d5dce6 inset;
}
.el-dialog .el-input__wrapper:hover,
.el-dialog .el-select__wrapper:hover {
  box-shadow: 0 0 0 1px #9bb8e7 inset;
}
.el-dialog .el-input__wrapper.is-focus,
.el-dialog .el-select__wrapper.is-focused {
  box-shadow: 0 0 0 1px var(--color-primary) inset;
}
.el-dialog .el-textarea__inner {
  border-radius: 8px;
  box-shadow: 0 0 0 1px #d5dce6 inset;
  line-height: 1.65;
}
.el-dialog .el-input-number {
  width: 100%;
}
.el-dialog .el-upload .el-button {
  height: 38px;
  border-radius: 8px;
}
.el-dialog .el-switch {
  --el-switch-on-color: var(--color-primary);
}
.toast-region {
  position: fixed;
  z-index: 3000;
  top: 18px;
  left: 50%;
  width: min(440px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  transform: translateX(-50%);
  pointer-events: none;
}
.app-toast {
  position: relative;
  min-height: 68px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 12px 16px;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-info);
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  pointer-events: auto;
}
.app-toast--success {
  border-left-color: var(--color-success);
}
.app-toast--warning {
  border-left-color: var(--color-warning);
}
.app-toast--error {
  border-left-color: var(--color-danger);
}
.app-toast__icon {
  margin-top: 3px;
}
.app-toast__content {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.app-toast__content span {
  margin-top: 2px;
  color: var(--color-text-secondary);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.app-toast .icon-button {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
}
.app-toast__progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  background: var(--color-primary);
  transition: width 0.05s linear;
}
.toast-fade-enter-active,
.toast-fade-leave-active {
  transition: opacity 0.2s ease;
}
.toast-fade-enter-from,
.toast-fade-leave-to {
  opacity: 0;
}
.login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef2f7;
}
.login-panel {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-md);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
}
.login-heading {
  margin: 32px 0 24px;
}
.login-heading h1 {
  font-size: 26px;
}
.login-heading p {
  margin-top: 6px;
  color: var(--color-text-secondary);
}
.login-submit {
  width: 100%;
  margin-top: 8px;
}

@media (max-width: 767px) {
  .admin-shell {
    padding-left: 0;
  }
  .page-content {
    padding: 18px 14px 32px;
  }
  .topbar {
    height: 64px;
    padding: 0 14px;
  }
  .admin-profile span {
    display: none;
  }
  .management-page {
    height: auto;
    min-height: 0;
  }
  .page-header {
    align-items: stretch;
    flex-direction: column;
  }
  .page-actions {
    justify-content: flex-start;
  }
  .page-actions .el-button {
    margin-left: 0;
  }
  .panel {
    padding: 14px;
  }
  .filter-bar {
    align-items: stretch;
  }
  .filter-bar > * {
    width: 100% !important;
    max-width: none !important;
  }
  .form-grid,
  .dialog-form-grid {
    grid-template-columns: 1fr;
  }
  .dialog-field--full {
    grid-column: auto;
  }
  .desktop-table {
    display: none;
  }
  .mobile-card-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .line-chart {
    height: 300px;
  }
  .channel-grid {
    grid-template-columns: 1fr;
  }
  .login-panel {
    padding: 26px 20px;
  }
  .el-overlay-dialog {
    padding: 12px;
  }
  .el-dialog {
    margin: 0 !important;
  }
  .el-dialog__header {
    padding: 17px 18px 14px;
  }
  .el-dialog__body {
    max-height: calc(100dvh - 150px);
    padding: 18px 18px 4px;
  }
  .el-dialog .el-dialog__footer {
    padding: 18px 18px 12px;
  }
  .el-pagination {
    justify-content: center;
  }
  .menu {
    margin-bottom: 12px;
  }
  .mobile-drawer .el-drawer__body {
    display: flex;
    flex-direction: column;
    padding: 16px 12px;
    background: var(--color-sidebar);
    color: var(--color-sidebar-text);
  }
}
@media (max-width: 767px) {
  .desktop-user-table {
    display: none;
  }
}
.el-dialog .el-dialog__header {
  padding: 8px 24px 2px;
  border-bottom: 0;
  background: transparent;
}
.el-dialog .el-dialog__headerbtn {
  top: 7px;
  right: 11px;
}
.el-dialog__body {
  padding-top: 16px;
}
@media (max-width: 767px) {
  .el-dialog .el-dialog__header {
    padding: 6px 18px 2px;
  }
  .el-dialog__body {
    padding-top: 14px;
  }
}
.el-dialog[style*="720px"] .el-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 18px;
}
.el-dialog[style*="720px"] .el-form > .form-grid {
  grid-column: 1/-1;
}
.el-dialog[style*="720px"] .el-form > .el-form-item:has(.el-textarea__inner),
.el-dialog[style*="720px"] .el-form > .el-form-item:has(.el-upload),
.el-dialog[style*="720px"] .el-form > .el-form-item:has(.el-input__password) {
  grid-column: 1/-1;
}
.el-dialog[style*="720px"] .el-form > .el-form-item {
  margin-bottom: 16px;
}
@media (max-width: 767px) {
  .el-dialog[style*="720px"] .el-form {
    display: block;
  }
}
.el-dialog .el-dialog__headerbtn {
  top: 4px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 0;
}
.el-dialog .el-dialog__headerbtn .el-dialog__close {
  color: #718096;
  font-size: 15px;
  transition: color 0.16s ease;
}
.el-dialog .el-dialog__headerbtn:hover {
  background: transparent;
}
.el-dialog .el-dialog__headerbtn:hover .el-dialog__close {
  color: var(--color-primary);
}
