:root {
  --bg-main: #0f141c;
  --bg-sidebar: #151b26;
  --bg-card: #1c2433;
  --bg-card-hover: #222c3d;
  --bg-input: #121822;
  --border-color: rgba(255, 255, 255, 0.08);
  --text-main: #f0f4f8;
  --text-muted: #8b9bb4;
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-glow: rgba(16, 185, 129, 0.25);
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: hidden;
}

/* =============================================================
   GLOBAL SCROLLBARS (dark theme, vertical + horizontal)
   ============================================================= */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.35) rgba(255, 255, 255, 0.04);
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
}

*::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.55);
  border: 2px solid transparent;
  background-clip: padding-box;
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-backdrop {
  display: none;
}

.brand {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.sidebar-close-btn {
  display: none;
}

.brand-icon {
  font-size: 28px;
}

.brand-info h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.badge-server {
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.15);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 20px;
  display: inline-block;
  margin-top: 2px;
}

.nav-menu {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.nav-item.active {
  background: rgba(16, 185, 129, 0.15);
  color: var(--primary);
  font-weight: 600;
}

body:not(.is-admin) .nav-item[data-admin-only="true"] {
  display: none !important;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
}

.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--primary);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border-color);
  background-color: rgba(21, 27, 38, 0.5);
  backdrop-filter: blur(10px);
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

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

.menu-toggle-btn {
  display: none;
}

.topbar h1 {
  font-size: 1.4rem;
  font-weight: 700;
}

.tab-container {
  padding: 32px;
  flex: 1;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.icon-users { background: rgba(59, 130, 246, 0.15); }
.icon-logs { background: rgba(139, 92, 246, 0.15); }
.icon-money { background: rgba(16, 185, 129, 0.15); }
.icon-items { background: rgba(245, 158, 11, 0.15); }

.stat-meta {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

/* Stat Card Transactions Breakdown */
.stat-card-tx {
  align-items: flex-start;
}

.stat-card-tx .stat-icon {
  margin-top: 2px;
}

.stat-tx-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 4px;
}

.stat-tx-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.82rem;
  line-height: 1.35;
}

.stat-tx-row .tx-badge-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
}

.stat-tx-row .tx-val {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.stat-tx-row .tx-bought-val {
  color: var(--primary);
}

.stat-tx-row .tx-sold-val {
  color: var(--accent-amber);
}

.stat-tx-row.tx-sum-row {
  margin-top: 2px;
  padding-top: 3px;
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
}

.stat-tx-row .tx-sum-val {
  font-size: 0.84rem;
  font-weight: 700;
  color: #fff;
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
}

.card-header.space-between {
  justify-content: space-between;
}

.card-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.card-body {
  padding: 24px;
}

.card-toolbar {
  padding: 20px 24px;
  display: flex;
  gap: 16px;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.card-toolbar.space-between {
  justify-content: space-between;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.92rem;
}

.data-table th {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  font-weight: 600;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.data-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 20px;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-primary { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: #f87171; }

.mono {
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

/* Forms and Inputs */
.search-box {
  position: relative;
  flex: 1;
  max-width: 380px;
}

.search-box input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.9rem;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.select-input, .text-input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  padding: 10px 14px;
  font-size: 0.9rem;
}

.text-input {
  width: 100%;
}

.select-input:focus, .text-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

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

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.14);
}

.btn-danger {
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
}

.btn-danger:hover {
  background-color: rgba(239, 68, 68, 0.25);
}

.btn-sm {
  padding: 0 14px;
  height: 36px;
  font-size: 0.84rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  box-sizing: border-box;
}

/* Top list in Dashboard */
.top-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.top-item-row:last-child {
  border-bottom: none;
}

.top-item-title {
  font-weight: 500;
}

.top-item-meta {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.top-item-count {
  font-weight: 700;
  color: var(--primary);
}

/* Auth Topbar Elements */
.auth-box {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.auth-guest-badge {
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0 12px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  box-sizing: border-box;
  white-space: nowrap;
  user-select: none;
}

.auth-guest-badge .badge-icon,
.auth-guest-badge .badge-svg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
  opacity: 0.9;
}

.auth-guest-badge .badge-text {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  display: inline-block;
}

.admin-badge {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0 12px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(16, 185, 129, 0.15);
  color: var(--primary);
  border: 1px solid rgba(16, 185, 129, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  box-sizing: border-box;
  white-space: nowrap;
  user-select: none;
}

.admin-badge .badge-icon {
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
}

.admin-badge .badge-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  display: inline-block;
}

.auth-logged-in {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.btn-icon {
  font-size: 0.95rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

/* Alert error */
.alert-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--accent-red);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

/* Financial Cards */
.finance-grid {
  margin-bottom: 24px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.card-finance-bought { border-left: 3px solid #34d399; }
.card-finance-sold { border-left: 3px solid #fbbf24; }
.card-finance-profit { border-left: 3px solid var(--accent-blue); }

.icon-bought { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.icon-sold { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.icon-profit { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }

.profit-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.profit-status-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}

.text-success { color: #34d399 !important; }
.text-amber { color: #fbbf24 !important; }
.text-danger { color: #f87171 !important; }

/* Sub-tab pills in card header */
.sub-tab-pills {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 2px;
  gap: 2px;
}

.sub-pill {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.sub-pill.active {
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Recent list */
.recent-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
  gap: 12px;
}

.recent-item:last-child {
  border-bottom: none;
}

.recent-item-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.recent-user {
  font-weight: 700;
  color: var(--text-main);
}

.recent-item-title {
  font-weight: 600;
  color: #f1f5f9;
}

.recent-item-qty {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.recent-item-cost {
  font-size: 0.82rem;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  padding: 2px 6px;
  border-radius: 6px;
}

.recent-time {
  color: var(--text-muted);
  font-size: 0.82rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Logs Activity Feed */
.logs-activity-list .recent-item {
  padding: 12px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.logs-activity-list .recent-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.log-id-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Pagination */
.card-footer-pagination {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.pagination-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pagination-limit-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.select-input-sm {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.select-input-sm:focus {
  border-color: var(--primary);
}

.page-btn {
  padding: 6px 12px;
  min-width: 34px;
  height: 32px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  user-select: none;
}

.page-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.page-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 700;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Grids */
.grid-2-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

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

/* Code guide */
.code-guide {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-top: 16px;
}

.code-guide h4 {
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.code-guide pre {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #a7f3d0;
  white-space: pre-wrap;
}

.hl-domain {
  color: #38bdf8;
  font-weight: 700;
}

.card-hint {
  margin-top: 20px;
  background: rgba(16, 185, 129, 0.1);
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: 0.9rem;
}

/* Modals */
.modal-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 95%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.modal-lg {
  max-width: 750px;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-x: hidden;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-shrink: 0;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.radio-pills {
  display: flex;
  gap: 10px;
}

.radio-pills label {
  flex: 1;
  text-align: center;
  cursor: pointer;
}

.radio-pills input {
  display: none;
}

.radio-pills span {
  display: block;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
}

.radio-pills input:checked + span {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--primary);
  color: var(--text-main);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 2000;
  font-weight: 500;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.text-center { text-align: center; }
.empty-state { text-align: center; color: var(--text-muted); padding: 24px 0; }

/* Step-by-step Catalog Filter */
.catalog-step-card {
  margin-bottom: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.catalog-filters-card {
  margin-bottom: 16px;
}

.catalog-filters-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-top: 18px;
}

.catalog-filter-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.catalog-filter-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.step-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.15);
  color: var(--primary);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.step-title h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.2;
}

.step-title p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.step-badge {
  margin-left: auto;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  color: var(--primary);
}

.filter-pills-container {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  flex-shrink: 0;
  white-space: nowrap;
}

.filter-pill:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-main);
}

.filter-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.filter-pill .pill-count {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  color: inherit;
}

.catalog-breadcrumb {
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.88rem;
  color: var(--text-muted);
}

.catalog-breadcrumb strong {
  color: var(--text-main);
}

.sort-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.card-toolbar .toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.card-toolbar .toolbar-actions .select-input-sm {
  min-width: 220px;
  max-width: 100%;
}

.text-sm {
  font-size: 0.82rem;
}

/* Matrix & Breakdown Chips */
.chip-breakdown {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.76rem;
  color: var(--text-muted);
  margin: 2px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.chip-breakdown strong {
  color: var(--primary);
  font-weight: 700;
}

.chip-breakdown:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  color: var(--text-main);
  transform: translateY(-1px);
}

.matrix-card {
  margin-bottom: 24px;
}

.matrix-table {
  font-size: 0.82rem;
  white-space: nowrap;
}

.matrix-table th, .matrix-table td {
  padding: 10px 12px;
  text-align: center;
}

.matrix-table th:first-child, .matrix-table td:first-child {
  text-align: left;
  font-weight: 600;
  position: sticky;
  left: 0;
  background: var(--bg-card);
  z-index: 2;
}

.matrix-cell-badge {
  display: inline-block;
  min-width: 24px;
  padding: 3px 6px;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.12);
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.matrix-cell-badge:hover {
  background: var(--primary);
  color: #fff;
  transform: scale(1.1);
}

.matrix-cell-empty {
  color: rgba(255, 255, 255, 0.18);
}

.matrix-total-cell {
  font-weight: 700;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

/* ============================================================= */
/* RESPONSIVE DESIGN (Tablets & Mobile Devices)                  */
/* ============================================================= */

/* Global Mobile Fixes */
html {
  -webkit-text-size-adjust: 100%;
}

body.sidebar-open {
  overflow: hidden;
}

/* Touch scrolling & Table indicators */
.table-responsive {
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.matrix-table th:first-child, .matrix-table td:first-child {
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.4);
}

/* Tablet & Mobile Screens (<= 860px) */
@media (max-width: 860px) {
  .app-layout {
    display: block;
    min-height: 100vh;
  }

  /* Off-canvas Mobile Sidebar */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    z-index: 1200;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 6px 0 30px rgba(0, 0, 0, 0.75);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: 1190;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .sidebar-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    margin-left: auto;
  }

  .sidebar-close-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.15);
  }

  /* Hamburger Menu Button */
  .menu-toggle-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    width: 38px;
    height: 38px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    flex-shrink: 0;
  }

  .menu-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.12);
  }

  .menu-toggle-btn .bar {
    display: block;
    width: 18px;
    height: 2px;
    background-color: var(--text-main);
    border-radius: 2px;
    transition: all 0.2s ease;
  }

  /* Topbar */
  .topbar {
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .topbar h1 {
    font-size: 1.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Tab Container */
  .tab-container {
    padding: 16px 12px;
  }

  /* Cards & Toolbars */
  .card-header {
    padding: 14px 16px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .card-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }

  .card-toolbar > * {
    width: 100%;
    max-width: 100%;
  }

  .search-box {
    max-width: 100%;
  }

  .toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }

  .toolbar-actions .btn {
    flex: 1 1 auto;
    min-width: 120px;
    justify-content: center;
  }

  .card-body {
    padding: 14px;
  }

  /* Catalog Steps */
  .catalog-step-card {
    padding: 12px 14px;
    margin-bottom: 12px;
  }

  .step-header {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
  }

  .step-num {
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
  }

  .step-title h3 {
    font-size: 0.92rem;
  }

  .step-badge {
    margin-left: 0;
    font-size: 0.74rem;
    padding: 2px 8px;
  }

  .filter-pills-container {
    gap: 6px;
  }

  .filter-pill {
    padding: 6px 10px;
    font-size: 0.8rem;
    gap: 6px;
  }

  .filter-pill .pill-count {
    padding: 1px 5px;
    font-size: 0.7rem;
  }

  .catalog-breadcrumb {
    padding: 10px 14px;
    font-size: 0.82rem;
    word-break: break-word;
  }

  /* Table padding */
  .data-table th, .data-table td {
    padding: 10px 12px;
    font-size: 0.85rem;
  }

  .data-table {
    min-width: 540px;
  }
}

/* Mobile Phones (<= 600px) */
@media (max-width: 600px) {
  .topbar {
    padding: 10px 12px;
  }

  .topbar h1 {
    font-size: 1.05rem;
  }

  .refresh-label {
    display: none;
  }

  /* Stats Grid: 2 columns */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
  }

  .stat-card {
    padding: 12px 10px;
    gap: 10px;
    border-radius: var(--radius-md);
  }

  .stat-icon {
    width: 38px;
    height: 38px;
    font-size: 18px;
    border-radius: var(--radius-sm);
  }

  .stat-value {
    font-size: 1.15rem;
    word-break: break-word;
  }

  .stat-label {
    font-size: 0.72rem;
  }

  /* Modals on Mobile */
  .modal-backdrop {
    padding: 10px;
    align-items: flex-end;
  }

  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 90vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    animation: slideUpModal 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes slideUpModal {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .modal-header {
    padding: 14px 16px;
  }

  .modal-header h3 {
    font-size: 1rem;
  }

  .modal-body {
    padding: 16px 14px;
    gap: 12px;
  }

  .modal-footer {
    padding: 12px 16px;
    flex-direction: column-reverse;
    gap: 8px;
  }

  .modal-footer .btn {
    width: 100%;
  }

  /* iOS input auto-zoom prevention: must be 16px font */
  .select-input, .text-input, input[type="text"], input[type="number"], select {
    font-size: 16px !important;
  }

  .radio-pills {
    flex-direction: row;
    gap: 6px;
  }

  .radio-pills span {
    padding: 8px 6px;
    font-size: 0.78rem;
  }

  /* Toasts on mobile */
  .toast {
    left: 14px;
    right: 14px;
    bottom: 14px;
    width: auto;
    transform: translateY(80px);
    text-align: center;
    font-size: 0.85rem;
  }

  .toast.show {
    transform: translateY(0);
  }

  /* Matrix table font */
  .matrix-table {
    font-size: 0.76rem;
    min-width: 580px;
  }

  .matrix-table th, .matrix-table td {
    padding: 8px 8px;
  }

  /* Code guide inside settings */
  .code-guide {
    padding: 12px 14px;
  }

  .code-guide pre {
    font-size: 0.78rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Extra small devices (<= 360px) */
@media (max-width: 360px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .filter-pill {
    width: 100%;
    justify-content: space-between;
  }
}

/* App Fullscreen Preloader */
.app-preloader {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background-color: var(--bg-main);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.app-preloader.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preloader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  text-align: center;
}

.preloader-spinner-ring {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(16, 185, 129, 0.15);
  border-top-color: var(--primary);
  border-right-color: var(--primary);
  border-radius: 50%;
  animation: preloader-spin 0.8s cubic-bezier(0.5, 0.1, 0.4, 0.9) infinite;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.25);
}

@keyframes preloader-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.preloader-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.preloader-icon {
  font-size: 26px;
}

.preloader-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
}

.preloader-status {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Tab Loading Overlay */
.tab-container {
  position: relative;
}

.tab-loading-overlay {
  position: absolute;
  top: 16px;
  left: 32px;
  right: 32px;
  bottom: 16px;
  background: rgba(15, 20, 28, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 50;
  border-radius: var(--radius-lg);
  transition: opacity 0.2s ease;
}

@media (max-width: 768px) {
  .tab-loading-overlay {
    top: 8px;
    left: 12px;
    right: 12px;
    bottom: 8px;
  }
}

.tab-loading-overlay .spinner-ring {
  width: 40px;
  height: 40px;
  border: 3.5px solid rgba(16, 185, 129, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: preloader-spin 0.75s linear infinite;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
}

.tab-loading-text {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Spinning animation for refresh button */
.btn-icon.spinning {
  display: inline-block;
  animation: preloader-spin 0.8s linear infinite;
}

/* =============================================================
   USERS LIST (dashboard / logs visual language)
   ============================================================= */
.card-body-list {
  padding: 8px 16px 16px;
}

.users-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  padding: 4px 2px 8px;
}

.users-grid.users-grid-empty {
  display: block;
}

.user-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
  min-width: 0;
}

.user-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(16, 185, 129, 0.35);
  transform: translateY(-1px);
}

.user-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.user-card-name {
  font-size: 1.05rem;
  color: var(--text-main);
}

.user-card-balance {
  font-size: 1.35rem;
  font-weight: 700;
  color: #34d399;
  letter-spacing: -0.02em;
}

.user-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.user-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

.user-card-actions .btn {
  flex: 1 1 auto;
  justify-content: center;
  min-width: 0;
}

.user-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

.user-meta-chip.money {
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
}

.user-meta-chip.bought {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
}

.user-meta-chip.sold {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
}

.user-meta-chip.muted {
  color: var(--text-muted);
}

.badge-bought {
  color: #34d399;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-sold {
  color: #fbbf24;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.filter-group .select-input {
  min-width: 180px;
}

.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.82rem; margin-top: 4px; }

/* =============================================================
   REDESIGNED BALANCE MODAL
   ============================================================= */
.balance-modal-dialog {
  max-width: 520px;
  width: 100%;
}
.modal-header-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-header-icon {
  font-size: 1.6rem;
  line-height: 1;
}
.modal-header-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.balance-user-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.balance-user-info {
  flex: 1;
  min-width: 0;
}
.balance-user-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.balance-user-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.balance-current-badge {
  text-align: right;
  flex-shrink: 0;
}
.current-badge-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.current-badge-val {
  font-size: 1rem;
  font-weight: 700;
  color: #34d399;
}
.form-label-styled {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
}
.balance-action-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.bal-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
}
.bal-action-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--text-main);
}
.bal-action-btn .action-icon {
  font-size: 1.15rem;
  margin-bottom: 4px;
}
.bal-action-btn .action-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}
.bal-action-btn .action-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.bal-action-btn.active[data-action="add"] {
  background: rgba(16, 185, 129, 0.12);
  border-color: #10b981;
  color: #34d399;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.2);
}
.bal-action-btn.active[data-action="add"] .action-title {
  color: #34d399;
}
.bal-action-btn.active[data-action="subtract"] {
  background: rgba(239, 68, 68, 0.12);
  border-color: #ef4444;
  color: #f87171;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.2);
}
.bal-action-btn.active[data-action="subtract"] .action-title {
  color: #f87171;
}
.bal-action-btn.active[data-action="set"] {
  background: rgba(59, 130, 246, 0.12);
  border-color: #3b82f6;
  color: #60a5fa;
  box-shadow: 0 0 14px rgba(59, 130, 246, 0.2);
}
.bal-action-btn.active[data-action="set"] .action-title {
  color: #60a5fa;
}

.quick-presets-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.quick-presets-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.quick-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.quick-chip {
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
}
.quick-chip:hover {
  background: rgba(16, 185, 129, 0.15);
  border-color: #10b981;
  color: #34d399;
  transform: translateY(-1px);
}
.quick-chip.chip-clear {
  color: var(--text-muted);
}
.quick-chip.chip-clear:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  color: #f87171;
}

.amount-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.amount-currency-symbol {
  position: absolute;
  left: 12px;
  font-size: 1.1rem;
  pointer-events: none;
}
.amount-input {
  padding-left: 38px !important;
  padding-right: 65px !important;
  font-size: 1.15rem !important;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.amount-suffix {
  position: absolute;
  right: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
  pointer-events: none;
}

.balance-calc-preview {
  background: rgba(15, 20, 28, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.calc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}
.calc-label {
  color: var(--text-muted);
}
.calc-value {
  font-weight: 600;
  color: var(--text-main);
}
.calc-divider {
  height: 1px;
  background: var(--border-color);
  margin: 3px 0;
}
.calc-row.calc-total {
  font-size: 0.95rem;
  font-weight: 700;
}
.calc-projected {
  color: #34d399;
  font-size: 1rem;
}
.calc-projected.negative {
  color: #f87171;
}

/* =============================================================
   REDESIGNED USER PURCHASES & SALES MODAL
   ============================================================= */
.modal-xl {
  max-width: 900px;
  width: 95%;
}
.user-history-modal-dialog {
  max-height: 90vh;
}
.user-history-body {
  padding: 20px 24px;
  gap: 16px;
  overflow: hidden;
  flex: 1 1 auto;
  min-height: 0;
}
.user-stats-banner {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  flex-shrink: 0;
}
.stat-banner-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.stat-banner-icon {
  font-size: 1.4rem;
  line-height: 1;
}
.stat-banner-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.stat-banner-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-banner-val {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-banner-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.text-emerald { color: #34d399; }
.text-cyan { color: #38bdf8; }
.text-amber { color: #fbbf24; }

.history-controls-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.history-tabs-nav {
  display: flex;
  gap: 6px;
  background: var(--bg-input);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}
.history-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.history-tab-btn:hover {
  color: var(--text-main);
}
.history-tab-btn.active {
  background: var(--bg-card);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.history-tab-btn.active#historyTabPurchases {
  color: #38bdf8;
}
.history-tab-btn.active#historyTabSales {
  color: #fbbf24;
}
.history-tab-badge {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 7px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 700;
}
.history-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 320px;
}
.history-search-wrap .search-icon {
  position: absolute;
  left: 10px;
  font-size: 0.85rem;
  pointer-events: none;
}
.history-search-wrap input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.82rem;
}
.history-search-wrap input:focus {
  outline: none;
  border-color: var(--primary);
}

.history-logs-container {
  flex: 1 1 auto;
  min-height: 160px;
  max-height: min(380px, 42vh);
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.15);
  -webkit-overflow-scrolling: touch;
}
.history-logs-container .recent-item {
  padding: 12px 10px;
}
.history-logs-container .recent-item-cost.sold {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
}
.history-table-container {
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}
.history-data-table {
  width: 100%;
  border-collapse: collapse;
}
.history-data-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-sidebar);
}
.history-item-cell {
  display: flex;
  flex-direction: column;
}
.history-item-name {
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.9rem;
}
.history-item-id {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.history-qty-pill {
  display: inline-block;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
}
.history-cost-pill {
  font-weight: 700;
  font-size: 0.92rem;
}
.history-cost-pill.bought {
  color: #38bdf8;
}
.history-cost-pill.sold {
  color: #fbbf24;
}

.history-summary-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 0.85rem;
}
.history-summary-left {
  color: var(--text-muted);
}
.history-summary-right {
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

.history-pagination-footer {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  margin-top: 0;
  padding: 12px 14px;
  gap: 12px;
  flex-shrink: 0;
}

.history-pagination-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

@media (max-width: 768px) {
  .user-stats-banner {
    grid-template-columns: repeat(2, 1fr);
  }
  .history-controls-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .history-search-wrap {
    max-width: 100%;
  }
  .balance-action-selector {
    grid-template-columns: 1fr;
  }
}

/* =============================================================
   UNIFIED MOBILE POLISH (dashboard language + no overflow)
   ============================================================= */
@media (max-width: 860px) {
  .card-body-list {
    padding: 4px 8px 12px;
  }

  .users-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
  }

  .filter-group .select-input {
    width: 100%;
    min-width: 0;
  }

  .card-footer-pagination {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 16px;
  }

  .pagination-controls {
    width: 100%;
    justify-content: space-between;
  }

  .pagination {
    flex-wrap: wrap;
  }

  .recent-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .recent-time {
    align-self: flex-end;
  }

  .matrix-card .card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .matrix-card .card-header .btn {
    align-self: stretch;
  }
}

@media (max-width: 600px) {
  .finance-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid:not(.finance-grid) {
    grid-template-columns: 1fr 1fr;
  }

  .stat-card-tx {
    grid-column: 1 / -1;
  }

  .auth-guest-badge .badge-text,
  .admin-badge .badge-text {
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .auth-box {
    gap: 6px;
  }

  .topbar-actions .btn-sm .btn-text {
    display: none;
  }

  .topbar-actions .btn-sm .btn-icon {
    margin: 0;
  }

  .topbar h1 {
    font-size: 1rem;
  }

  .auth-guest-badge {
    padding: 0 8px;
  }

  .auth-guest-badge .badge-text {
    display: none;
  }

  .modal-xl,
  .user-history-modal-dialog,
  .balance-modal-dialog {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
  }

  .user-stats-banner {
    grid-template-columns: 1fr;
  }

  .balance-user-card {
    flex-wrap: wrap;
  }

  .balance-current-badge {
    width: 100%;
    text-align: left;
    margin-top: 4px;
  }

  .quick-chips-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .history-tabs-nav {
    width: 100%;
  }

  .history-tab-btn {
    flex: 1;
    justify-content: center;
  }

  .history-summary-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .history-pagination-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .history-pagination-footer .pagination-controls {
    width: 100%;
    justify-content: space-between;
  }

  .sub-tab-pills {
    width: 100%;
  }

  .sub-pill {
    flex: 1;
    text-align: center;
    justify-content: center;
  }

  .data-table {
    min-width: 620px;
  }

  .grid-2-col {
    gap: 14px;
  }
}

@media (max-width: 400px) {
  .stats-grid:not(.finance-grid) {
    grid-template-columns: 1fr;
  }

  .stat-card-tx {
    grid-column: auto;
  }

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

/* =============================================================
   CATALOG ITEM CARDS + CATEGORIES/MODS ENTITY LIST
   ============================================================= */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  padding: 4px 2px 8px;
}

.items-grid.items-grid-empty {
  display: block;
}

.item-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
  min-width: 0;
}

.item-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(16, 185, 129, 0.35);
  transform: translateY(-1px);
}

.item-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.item-card-title {
  font-size: 1rem;
  font-weight: 650;
  color: var(--text-main);
  line-height: 1.3;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}

.item-card-id {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.item-card-actions {
  display: flex;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px solid var(--border-color);
}

.item-card-actions .btn {
  flex: 1;
  justify-content: center;
}

.item-price-pill {
  font-size: 0.82rem;
  font-weight: 700;
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
  padding: 3px 9px;
  border-radius: 6px;
  white-space: nowrap;
}

.entity-list {
  display: flex;
  flex-direction: column;
}

.entity-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 10px;
  border-bottom: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.entity-list-item:last-child {
  border-bottom: none;
}

.entity-list-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.entity-list-main {
  min-width: 0;
  flex: 1;
}

.entity-list-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.entity-list-name {
  font-size: 0.98rem;
  color: var(--text-main);
}

.entity-list-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.entity-list-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
  justify-content: flex-end;
}

.catalog-empty {
  padding: 36px 12px;
}

.catalog-empty-title {
  font-size: 1.05rem;
  margin-bottom: 6px;
  color: var(--text-main);
}

.badge-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

@media (max-width: 860px) {
  .items-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
  }

  .entity-list-item {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .entity-list-actions {
    width: 100%;
  }

  .entity-list-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .catalog-filters-body {
    gap: 14px;
    padding-top: 12px;
  }
}

@media (max-width: 480px) {
  .items-grid {
    grid-template-columns: 1fr;
  }
}


