/* Material You Design System */
:root {
  /* Primary Colors */
  --primary: #1976d2;
  --primary-light: #42a5f5;
  --primary-dark: #1565c0;
  --on-primary: #ffffff;

  /* Secondary Colors */
  --secondary: #ffb74d;
  --secondary-light: #ffe0b2;
  --secondary-dark: #ffa726;
  --on-secondary: #ffffff;

  /* Surface Colors */
  --surface: #ffffff;
  --surface-variant: #f5f5f5;
  --on-surface: #1c1b1f;
  --on-surface-variant: #49454f;

  /* Background */
  --background: #fafafa;
  --on-background: #1c1b1f;

  /* Error */
  --error: #b3261e;
  --on-error: #ffffff;

  /* Success */
  --success: #4caf50;
  --on-success: #ffffff;

  /* CS:GO Quality Colors */
  --quality-consumer: #b0c3d9;
  --quality-industrial: #5e98d9;
  --quality-milspec: #4b69ff;
  --quality-restricted: #8847ff;
  --quality-classified: #d32ce6;
  --quality-covert: #eb4b4b;
  --quality-knife: #ffd700;

  /* Shadows */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.1);
  --shadow-2: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-3: 0 4px 8px rgba(0, 0, 0, 0.12);
  --shadow-4: 0 8px 16px rgba(0, 0, 0, 0.15);

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  /* Custom */
  --warning-bg: #fff3e0;
  --warning-text: #e65100;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  /* 关键修复：预留滚动条空间，防止弹窗打开时页面抖动/布局改变 */
  scrollbar-gutter: stable;
}

body {
  font-family: "Roboto", sans-serif;
  background-color: var(--background);
  color: var(--on-background);
  line-height: 1.6;
  overflow-y: auto;
  /* 确保页面本身可以滚动 */
}

/* App Container */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
  width: 240px;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: var(--on-primary);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-3);
  /* 固定侧边栏 */
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  z-index: 100;
  /* 确保侧边栏层级 */
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-xl);
  padding-bottom: var(--spacing-lg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  text-align: center;
}

.sidebar-logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(4px);
  padding: 8px;
}

.sidebar-logo-icon .material-icons {
  font-size: 40px;
}

.sidebar-logo-title {
  font-size: 20px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: .5px;
}

.sidebar-header .highlight {
  color: var(--secondary-light);
  font-weight: 700;
}

.nav-menu {
  list-style: none;
  flex: 0 0 auto;
}

.nav-item {
  margin-bottom: var(--spacing-sm);
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  color: var(--on-primary);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: background-color 0.15s;
}

.nav-item a:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.nav-item.active a {
  background-color: rgba(255, 255, 255, 0.2);
  font-weight: 500;
}

.nav-item.disabled a {
  opacity: 0.5;
  pointer-events: none;
}

.sidebar-footer {
  margin-top: auto;
}

.sidebar-footer .nav-item a {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  color: var(--on-primary);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: background-color 0.15s;
}

.sidebar-footer .nav-item a:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.sidebar-footer .nav-item.active a {
  background-color: rgba(255, 255, 255, 0.2);
  font-weight: 500;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 240px;
  padding: var(--spacing-xl);
  transition: margin-left 0.25s ease;
  width: calc(100% - 240px);
  overflow: visible;
  /* 允许内容溢出以便生成滚动条 */
}

/* Collapsible sidebar support */
body.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
}

body.sidebar-collapsed .main-content {
  margin-left: 0;
  width: 100%;
}

/* Login Page */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 64px);
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-3);
  width: 100%;
  max-width: 400px;
}

.login-header {
  text-align: center;
  margin-bottom: var(--spacing-xl);
}

.login-icon {
  font-size: 64px;
  color: var(--primary);
  margin-bottom: var(--spacing-md);
}

.login-header h2 {
  font-size: 24px;
  font-weight: 500;
  margin-bottom: var(--spacing-sm);
}

.login-header p {
  color: var(--on-surface-variant);
  font-size: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.input-group label {
  font-size: 14px;
  font-weight: 500;
  color: var(--on-surface-variant);
}

.input-group input,
.input-group select,
.input-group textarea {
  padding: var(--spacing-md);
  border: 1px solid #e0e0e0;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: "Roboto", sans-serif;
  transition: border-color 0.15s;
}

.input-inline {
  padding: 8px 10px;
  border: 1px solid #e0e0e0;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: "Roboto", sans-serif;
  background: var(--surface);
  min-width: 160px;
  max-width: 280px;
}

.input-inline:focus {
  outline: none;
  border-color: var(--primary);
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-outlined,
.btn-text {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  font-family: "Roboto", sans-serif;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--on-primary);
  box-shadow: var(--shadow-2);
  border: 1px solid transparent;
}

.btn-primary:hover {
  background-color: var(--primary-dark);
  box-shadow: var(--shadow-3);
}

.btn-secondary {
  background-color: var(--secondary);
  color: var(--on-secondary);
  box-shadow: var(--shadow-2);
}

.btn-secondary:hover {
  background-color: var(--secondary-dark);
  box-shadow: var(--shadow-3);
}

.btn-danger {
  background-color: var(--error);
  color: var(--on-error);
  box-shadow: var(--shadow-2);
}

.btn-danger:hover {
  background-color: #9e2019;
  box-shadow: var(--shadow-3);
}

.btn-outlined {
  background-color: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-outlined:hover {
  background-color: rgba(25, 118, 210, 0.08);
}

.btn-text {
  background-color: transparent;
  color: var(--primary);
}

.btn-text:hover {
  background-color: rgba(25, 118, 210, 0.08);
}

.btn-ghost {
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.btn-ghost:hover {
  background: transparent;
}

/* Message */
.message {
  padding: var(--spacing-md);
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-top: var(--spacing-md);
  display: none;
}

.message.success {
  background-color: rgba(76, 175, 80, 0.1);
  color: var(--success);
  display: block;
}

.message.error {
  background-color: rgba(179, 38, 30, 0.1);
  color: var(--error);
  display: block;
}

/* User Info Bar */
.user-info-bar {
  background: var(--surface);
  padding: var(--spacing-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  margin-bottom: var(--spacing-lg);
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
  font-size: 14px;
}

.user-info .divider {
  color: var(--on-surface-variant);
}

/* Inventory Page */
.inventory-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: var(--spacing-lg);
}

.inventory-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-lg);
  border-bottom: 1px solid #e0e0e0;
  flex-wrap: wrap;
  gap: var(--spacing-md);
}

.toolbar-left {
  font-size: 14px;
}

.toolbar-right {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

.search-input {
  padding: var(--spacing-md);
  border: 1px solid #e0e0e0;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: "Roboto", sans-serif;
  transition: border-color 0.15s;
  background: var(--surface);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
}

.range-input {
  width: 120px;
  box-sizing: border-box;
}

.section-header .search-input,
.section-header .range-input {
  height: 40px;
  padding-top: 8px;
  padding-bottom: 8px;
  display: inline-flex;
  align-items: center;
}

/* Dropdown */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-3);
  margin-top: var(--spacing-xs);
  min-width: 160px;
  display: none;
  z-index: 200;
}

.dropdown-menu.active {
  display: block;
}

.dropdown-item {
  padding: var(--spacing-md);
  cursor: pointer;
  transition: background-color 0.1s;
}

.dropdown-item:hover {
  background-color: var(--surface-variant);
}

/* Dropdown Button Width - Default for Desktop */
.dropdown>button {
  white-space: nowrap;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  vertical-align: middle;
}

/* Items Grid */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--spacing-lg);
  box-sizing: border-box;
}

.item-card {
  background: var(--surface-variant);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  box-shadow: var(--shadow-1);
  transition: all 0.15s;
  min-width: 0;
}

.item-card:hover {
  box-shadow: var(--shadow-3);
  transform: translateY(-2px);
}

.item-image-container {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  margin-bottom: var(--spacing-md);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.item-image-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.item-info {
  margin-bottom: var(--spacing-md);
}

.item-name {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: var(--spacing-xs);
  white-space: normal;
  word-break: break-word;
}

.item-details {
  font-size: 12px;
  color: var(--on-surface-variant);
}

/* Wear meter */
.wear-container {
  margin-top: var(--spacing-sm);
}

.wear-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wear-scale {
  position: relative;
  flex: 1 1 auto;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  background: transparent;
}

.wear-seg {
  height: 100%;
}

.wear-seg.fn {
  background: green
}

.wear-seg.mw {
  background: #5cb85c
}

.wear-seg.ft {
  background: #f0ad4e
}

.wear-seg.ww {
  background: #d9534f
}

.wear-seg.bs {
  background: #993a38
}

.wear-pointer {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.15), 0 0 0 4px rgba(255, 255, 255, 0.5);
  pointer-events: none;
}

.wear-number {
  font-size: 12px;
  color: var(--on-surface-variant);
  margin-top: 6px;
  text-align: left;
}

.wear-number .wear-cat {
  margin-left: 6px;
  color: var(--on-surface-variant);
}

.item-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.item-checkbox {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-size: 12px;
}

.item-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.item-checkbox input[type="checkbox"]:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.item-status {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
}

.item-status.tradable {
  background-color: rgba(76, 175, 80, 0.2);
  color: var(--success);
}

.item-status.cooldown {
  background-color: rgba(179, 38, 30, 0.2);
  color: var(--error);
}


/* Admin Page - Card Structure */
.admin-container {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: var(--spacing-xl);
  /* 允许无限拉长 */
  max-height: none;
  overflow: visible;

  max-width: calc(100vw - 240px - 48px);
  margin: 0 auto;

  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 40px;
  /* 底部留白 */
}

.admin-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: var(--spacing-lg);
}

.admin-header-top {
  display: flex;
  align-items: center;
}

.admin-header-bottom {
  display: flex;
  align-items: center;
}

.admin-header .header-actions {
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
}

.admin-container .admin-section {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

/* Users table */
.users-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  overflow: visible;
}

.users-table .table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: auto;
}

.users-table table {
  width: 100%;
  border-collapse: collapse;
}

/* Sticky Header */
.users-table thead {
  background-color: var(--surface-variant);
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.users-table .pagination {
  flex: 0 0 auto;
  margin-top: 16px;
}

/* Logs table */
.trades-table {
  overflow-x: auto;
  overflow-y: visible;
  max-height: none;
}

.trades-table .table-scroll {
  overflow-y: visible;
}

.trades-table table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--spacing-lg);
}

.account-card {
  background: var(--surface-variant);
  border-radius: var(--radius-md);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-1);
}

.account-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-md);
}

.account-card-header h4 {
  font-size: 16px;
  font-weight: 500;
}

.account-card-info {
  font-size: 14px;
  color: var(--on-surface-variant);
  margin-bottom: var(--spacing-sm);
}

.account-card-actions {
  display: flex;
  gap: var(--spacing-md);
  margin-top: var(--spacing-md);
}

.admin-header .btn-outlined,
.admin-header .btn-primary,
.admin-header .btn-danger,
.admin-header .btn-text,
.admin-header .search-input,
.admin-header .dropdown>button {
  margin-bottom: 0 !important;
  height: 40px;
  padding-top: 8px;
  padding-bottom: 8px;
  display: inline-flex;
  align-items: center;
}

.admin-header .dropdown-menu {
  top: calc(100% + 6px);
}

@media (max-width: 560px) {

  .admin-header .btn-outlined,
  .admin-header .btn-primary,
  .admin-header .btn-danger,
  .admin-header .btn-text,
  .admin-header .search-input,
  .admin-header .dropdown>button {
    height: 36px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .admin-header {
    gap: 6px
  }
}

/* Normalize Button Heights */
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-outlined,
.btn-text,
.inventory-toolbar .toolbar-right .dropdown>button,
.section-header .btn-primary,
.section-header .btn-outlined,
.dialog .dialog-actions .btn-primary,
.dialog .dialog-actions .btn-outlined,
.row-actions button,
.account-card-actions .btn-primary,
.account-card-actions .btn-outlined {
  height: 40px;
  min-height: 40px;
  padding-top: 8px;
  padding-bottom: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 560px) {

  .btn-primary,
  .btn-secondary,
  .btn-danger,
  .btn-outlined,
  .btn-text,
  .inventory-toolbar .toolbar-right .dropdown>button,
  .section-header .btn-primary,
  .section-header .btn-outlined,
  .dialog .dialog-actions .btn-primary,
  .dialog .dialog-actions .btn-outlined,
  .row-actions button,
  .account-card-actions .btn-primary,
  .account-card-actions .btn-outlined {
    height: 36px;
    min-height: 36px;
    padding-top: 6px;
    padding-bottom: 6px;
  }
}

.page-title {
  font-size: 28px;
  font-weight: 500;
  margin-bottom: var(--spacing-lg);
}

.admin-tabs {
  display: flex;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-lg);
  border-bottom: 2px solid #e0e0e0;
  background: var(--surface);
  padding-top: 8px;
}

.tab-btn {
  padding: var(--spacing-md) var(--spacing-lg);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  font-weight: 500;
  font-family: "Roboto", sans-serif;
  cursor: pointer;
  transition: color 0.15s, transform 0.15s;
  margin-bottom: -2px;
}

.tab-btn:hover {
  background-color: var(--surface-variant);
  transform: translateY(-2px);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  opacity: 0;
  transform: translateY(6px);
  max-height: 0;
  overflow: hidden;
  pointer-events: none;
  transition: opacity 220ms, transform 220ms;
}

.tab-content.active {
  opacity: 1;
  transform: translateY(0);
  max-height: none;
  overflow: visible;
  pointer-events: auto;
}

.admin-container .tab-content {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.admin-container .tab-content.active {
  display: flex;
}

.admin-tabs {
  position: relative;
}

.admin-tabs::after {
  content: '';
  position: absolute;
  left: var(--indicator-left, 0px);
  bottom: -2px;
  height: 2px;
  width: var(--indicator-width, 0px);
  background: linear-gradient(90deg, var(--primary-light), var(--primary-dark));
  transition: left 260ms ease, width 260ms ease;
  pointer-events: none;
}

.admin-section {
  margin-bottom: var(--spacing-xl);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
  box-sizing: border-box;
}

.section-header h3 {
  font-size: 20px;
  font-weight: 500;
}

.selected-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-variant);
  color: var(--on-surface);
  font-size: 13px;
  font-weight: 500;
  min-width: 68px;
  justify-content: center;
  box-shadow: var(--shadow-1);
}

.section-header>div {
  display: flex;
  gap: var(--spacing-sm);
}

.section-header .section-actions {
  flex: 0 0 auto;
  align-items: flex-start;
}

.section-actions.column-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  flex: 0 0 auto;
  width: auto;
  margin-left: auto;
}

.section-actions.column-actions>div {
  display: flex;
  gap: 8px;
  align-items: center;
}

@media (max-width: 760px) {
  .section-actions.column-actions {
    position: static;
    width: auto;
    align-self: stretch;
  }
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background-color: var(--surface-variant);
}

th {
  padding: var(--spacing-md);
  text-align: left;
  font-weight: 500;
  font-size: 14px;
}

td {
  padding: var(--spacing-md);
  border-bottom: 1px solid #e0e0e0;
  font-size: 14px;
}

td .row-actions {
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
  flex-wrap: wrap;
}

.status-badge {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
}

.status-badge.active {
  background-color: rgba(76, 175, 80, 0.2);
  color: var(--success);
}

.status-badge.inactive {
  background-color: rgba(179, 38, 30, 0.2);
  color: var(--error);
}

.status-badge.pending {
  background-color: rgba(255, 152, 0, 0.2);
  color: var(--secondary);
}

.toast {
  background: var(--surface);
  color: var(--on-surface);
  border-left: 4px solid var(--primary);
  box-shadow: var(--shadow-3);
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-md);
  transition: opacity 0.15s, transform 0.15s;
  width: min(500px, calc(100% - 48px));
  min-width: 300px;
  max-width: 100%;
  word-break: break-word;
  white-space: normal;
}

.toast.success {
  border-left-color: var(--success);
}

.toast.error {
  border-left-color: var(--error);
}

.toast.hide {
  opacity: 0;
  transform: translateY(8px);
}

.toast .toast-text {
  display: block;
  white-space: normal;
  word-break: break-word;
}

#toastContainer {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 24px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
  align-items: center;
}

.toast {
  transform: translateY(8px);
  opacity: 0;
  animation: toast-in 260ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  pointer-events: auto;
}

@keyframes toast-in {
  from {
    transform: translateY(8px);
    opacity: 0
  }

  to {
    transform: translateY(0);
    opacity: 1
  }
}

.toast .toast-progress {
  height: 4px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}

.toast .toast-progress .bar {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, rgba(25, 118, 210, 0.95), rgba(66, 165, 245, 0.95));
  transform-origin: left center;
  animation-name: toast-progress;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

@keyframes toast-progress {
  from {
    width: 100%
  }

  to {
    width: 0%
  }
}

.toast.paused .toast-progress .bar {
  animation-play-state: paused !important;
}

.toast.success .toast-progress .bar {
  background: linear-gradient(90deg, rgba(76, 175, 80, 0.95), rgba(139, 195, 74, 0.95));
}

.toast.error .toast-progress .bar {
  background: linear-gradient(90deg, rgba(179, 38, 30, 0.95), rgba(244, 67, 54, 0.95));
}

.form-actions {
  margin-top: var(--spacing-md);
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-actions .btn-primary,
.form-actions .btn-outlined,
.form-actions .btn-text {
  height: 40px;
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 1;
  vertical-align: middle;
  box-sizing: border-box;
}

/* Dialog overlay and panel */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease-in-out, visibility 0ms linear 180ms;
}

.dialog-overlay.active {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transition-delay: 0ms;
}

.dialog {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-4);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow-y: hidden !important;
}

.dialog .dialog-header,
.dialog .dialog-actions {
  flex: 0 0 auto;
}

.dialog .dialog-content {
  flex: 1 1 auto;
  overflow-y: auto;
}

#refreshDialog .dialog .dialog-content {
  overflow: visible;
}

#refreshDialog .dropdown-menu {
  z-index: 5000;
  max-height: 280px;
  overflow-y: auto;
}

.dialog-large {
  max-width: 800px;
}

.dialog-header {
  padding: var(--spacing-lg);
  overflow: hidden;
}

.dialog-header h3 {
  font-size: 20px;
  font-weight: 500;
}

.dialog-content {
  padding: var(--spacing-lg);
}

.dialog-actions {
  padding: var(--spacing-lg);
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-sm);
}

.selected-items-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
  max-height: 300px;
  overflow-y: auto;
}

.preview-item {
  background: var(--surface-variant);
  border-radius: var(--radius-sm);
  padding: var(--spacing-sm);
}

.preview-item-image {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  margin-bottom: var(--spacing-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.preview-item-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview-item-name {
  font-size: 11px;
  text-align: center;
  white-space: normal;
  word-break: break-word;
}

.users-table thead th {
  text-align: center;
}

.trades-table thead th {
  text-align: center;
}

.users-table td {
  text-align: center;
}

.users-table td>.btn-primary,
.users-table td>.btn-secondary,
.users-table td>.btn-outlined,
.users-table td>.btn-text,
.users-table td>.btn-ghost {
  margin-left: auto;
  margin-right: auto;
}

td .row-actions {
  justify-content: center;
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.loading-overlay.active {
  display: flex;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--primary-light);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.spinner.small {
  width: 28px;
  height: 28px;
  border-width: 3px;
  border-top-color: var(--primary);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   MOBILE RESPONSIVE STYLES
   ========================================================================== */
@media (max-width: 768px) {
  .sidebar {
    width: 80%;
    max-width: 320px;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 1200;
    box-shadow: var(--shadow-4);
    overflow-y: auto;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .mobile-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1190;
  }

  .mobile-sidebar-overlay.active {
    display: block;
  }

  .main-content {
    margin-left: 0;
    width: 100%;
  }

  .mobile-menu-fab {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    position: fixed !important;
    left: 20px !important;
    top: calc(20px + env(safe-area-inset-top, 0px)) !important;
    width: 64px !important;
    height: 64px !important;
    min-width: 56px;
    min-height: 56px;
    border-radius: 50% !important;
    background: var(--primary) !important;
    color: var(--on-primary) !important;
    border: 2px solid rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.32) !important;
    z-index: 1100 !important;
    cursor: pointer !important;
    transition: left 260ms cubic-bezier(0.22, 1, 0.36, 1), top 260ms cubic-bezier(0.22, 1, 0.36, 1), transform 0.15s, box-shadow 0.15s, opacity 0.15s !important;
    opacity: 0.98;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .mobile-menu-fab:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  }

  .mobile-menu-fab:active {
    transform: scale(0.96);
  }

  .mobile-menu-fab.blue {
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
  }

  /* --- Inventory Page Mobile Layout --- */
  .inventory-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .inventory-toolbar .toolbar-right {
    display: grid;
    /* 定义两列等宽 */
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }

  /* 第一行：全选和反选 */
  .inventory-toolbar .toolbar-right #selectAllBtn {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
  }

  .inventory-toolbar .toolbar-right #deselectAllBtn {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
  }

  /* 第二行：提取和刷新 */
  .inventory-toolbar .toolbar-right #extractBtn {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
  }

  .inventory-toolbar .toolbar-right #refreshBtn {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
  }

  /* 关键修复：让工具栏里所有的 dropdown (包括排序和代理切换) 都强制占满一行 */
  .inventory-toolbar .toolbar-right .dropdown {
    grid-column: 1 / -1;
    /* 跨越从第一条线到最后一条线（即占满整行） */
    width: 100%;
    display: block;
    /* 确保容器是块级 */
  }

  /* 修复 dropdown 内部按钮的宽度和样式 */
  .inventory-toolbar .toolbar-right .dropdown>button {
    width: 100% !important;
    max-width: none !important;
    display: flex;
    justify-content: center;
    /* 保持文字居中，或者用 space-between 让箭头靠右 */
    box-sizing: border-box;
  }


  .inventory-toolbar .toolbar-right #sortBtn,
  .inventory-toolbar .toolbar-right #refreshNodeDropdown,
  .inventory-toolbar .toolbar-right #refreshNodeDropdown>button {
    width: 100%;
    box-sizing: border-box;
    max-width: none !important;
  }

  .items-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  .accounts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {

  html,
  body {
    max-width: 100vw;
    overflow-x: hidden;
    box-sizing: border-box;
  }

  .main-content,
  .admin-container,
  .inventory-container {
    max-width: 100%;
    box-sizing: border-box;
  }
}

@media (min-width: 769px) {
  .mobile-menu-fab {
    display: none !important;
  }
}

@media (max-width: 480px) {
  .mobile-menu-fab {
    left: 14px !important;
    top: calc(14px + env(safe-area-inset-top, 0px)) !important;
    width: 60px !important;
    height: 60px !important;
  }
}

/* ==========================================================================
   CONFIRMATION PAGE SPECIFIC STYLES
   ========================================================================== */
.confirmations-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: var(--spacing-lg);
}

.confirmations-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.confirmation-card {
  background: var(--surface-variant);
  border-radius: var(--radius-md);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-1);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Header Layout (Desktop) */
.confirm-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.confirm-title {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
}

.confirm-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.confirm-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.confirm-hint small {
  color: #c62828;
  font-weight: bold;
}

/* Cards Internal Layout */
.confirm-card-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

/* Partner Info */
.trade-partner-section {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  margin-bottom: 12px;
}

.partner-avatar-wrap {
  width: 50px;
  height: 50px;
  flex-shrink: 0;
}

.partner-avatar {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  object-fit: cover;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.partner-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.partner-name {
  font-weight: bold;
  font-size: 15px;
  color: #54a5d4;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.partner-meta {
  font-size: 12px;
  color: var(--on-surface-variant);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

/* Steam Level Badge */
.steam-level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #9b9b9b;
  font-size: 10px;
  font-weight: bold;
  flex-shrink: 0;
  background: var(--surface);
}

.lvl-0 {
  border-color: #9b9b9b;
  color: #666;
}

.lvl-10 {
  border-color: #c02942;
  color: #c02942;
}

.lvl-20 {
  border-color: #d95b43;
  color: #d95b43;
}

.lvl-30 {
  border-color: #fecc23;
  color: #fecc23;
}

.lvl-40 {
  border-color: #467a3c;
  color: #467a3c;
}

.lvl-50 {
  border-color: #4e8ddb;
  color: #4e8ddb;
}

.lvl-60 {
  border-color: #7652c6;
  color: #7652c6;
}

.lvl-70 {
  border-color: #c252c6;
  color: #c252c6;
}

.lvl-80 {
  border-color: #542437;
  color: #542437;
}

.lvl-90 {
  border-color: #997c52;
  color: #997c52;
}

.lvl-100 {
  border-color: #ffffff;
  border-width: 3px;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
  color: #333;
}

.partner-date-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
}

.partner-date-badge img {
  width: 14px;
  height: 14px;
}

/* Trade Columns */
.trade-column {
  background: rgba(0, 0, 0, 0.04);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
}

.trade-col-header {
  font-size: 12px;
  font-weight: bold;
  color: #666;
  margin-bottom: 8px;
  text-align: center;
}

.trade-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 4px;
}

.trade-item-thumb {
  width: 100%;
  aspect-ratio: 1;
  background: #333;
  border-radius: 4px;
  overflow: hidden;
}

.trade-item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.trade-no-items {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  color: var(--on-surface-variant);
  font-size: 13px;
}

.confirmation-info {
  font-size: 12px;
  color: #888;
  margin-bottom: 12px;
  text-align: right;
}

.confirmation-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* API Key Card */
.apikey-card {
  background: var(--warning-bg);
  border-left: 4px solid var(--warning-text);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.apikey-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--warning-text);
  font-weight: bold;
  font-size: 15px;
  margin-bottom: 12px;
}

.apikey-warning {
  font-size: 14px;
  color: #bf360c;
  margin-bottom: 12px;
  line-height: 1.5;
  font-weight: 500;
}

.apikey-details {
  background: rgba(255, 255, 255, 0.6);
  padding: 12px;
  border-radius: 6px;
}

.apikey-row {
  display: flex;
  font-size: 13px;
  margin-bottom: 4px;
}

.apikey-label {
  width: 80px;
  color: #666;
  font-weight: 500;
  flex-shrink: 0;
}

.apikey-value {
  font-family: monospace;
  color: #333;
  word-break: break-all;
}


/* Confirmation Page Mobile Overrides */
@media (max-width: 768px) {
  .confirm-header {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .confirm-title {
    text-align: center;
  }

  .confirm-controls {
    align-items: stretch;
    width: 100%;
  }

  /* Stack buttons vertically */
  .confirm-toolbar {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 8px;
  }

  /* Force full width on dropdown and buttons */
  .confirm-toolbar .dropdown {
    width: 100%;
  }

  .confirm-toolbar .dropdown>button {
    width: 100% !important;
    max-width: none;
  }

  #refreshConfirmationsBtn {
    width: 100% !important;
  }

  .confirm-hint {
    text-align: center;
    margin-top: 8px;
  }

  /* Stack trade columns vertically */
  .confirm-card-layout {
    grid-template-columns: 1fr;
  }

  .items-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.users-table .row-actions {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 6px 8px;
  align-items: center;
}