/* components */
.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:has(.entity-more-wrap, .items-more-wrap, .audit-more-wrap) {
  overflow: visible;
}

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

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

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

/* Title + description as siblings: description under the title, wraps normally */
.card-header > p {
  flex: 1 1 100%;
  min-width: 0;
  margin: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.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;
}

.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: var(--success-soft); color: var(--success); }
.badge-primary { background: var(--primary-soft-md); color: var(--primary); }
.badge-info { background: rgba(56, 189, 248, 0.15); color: #38bdf8; }
.badge-muted { background: rgba(148, 163, 184, 0.12); color: #94a3b8; }
.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;
}

.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);
}

.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-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}
.top-item-main {
  min-width: 0;
  flex: 1;
}

.top-item-row-clickable:hover {
  opacity: 0.85;
}

.top-item-row-clickable:hover .top-item-title {
  color: var(--primary);
}

.recent-user-link {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.recent-user-link:hover {
  color: var(--primary);
}

.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 {
  flex: none;
  white-space: nowrap;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.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: var(--primary-soft-md);
  color: var(--primary);
  border: 1px solid var(--primary-soft-strong);
  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 {
  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;
}

.finance-grid {
  margin-bottom: 20px;
}

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

.finance-grid .stat-card {
  min-height: 110px;
}

.finance-grid .stat-sub {
  min-height: 1.2em;
}

.icon-bought { background: var(--primary-soft-md); color: var(--success); }
.icon-sold { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.icon-profit { background: rgba(59, 130, 246, 0.15); color: #8eb6e0; }

.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: var(--success) !important; }
.text-amber { color: #fbbf24 !important; }
.text-danger { color: #f87171 !important; }

.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-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-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);
}

.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;
}

.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 {
  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;
}

.oc-conn-params {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.oc-conn-item {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  min-width: 0;
}

.oc-conn-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.oc-conn-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: #38bdf8;
  word-break: break-all;
}

.oc-conn-intro {
  margin: 0 0 4px;
  color: var(--text-secondary, var(--text-muted));
  font-size: 0.92rem;
}

.oc-endpoint-list {
  margin: 8px 0 12px;
  padding-left: 18px;
  color: var(--text-secondary, var(--text-muted));
  font-size: 0.88rem;
  line-height: 1.55;
}

.oc-endpoint-list code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #a7f3d0;
}

.oc-endpoint-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.oc-help-strip {
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.oc-help-steps {
  margin: 0;
  padding-left: 18px;
  color: var(--text-secondary, var(--text-muted));
  font-size: 0.88rem;
  line-height: 1.55;
}

.oc-help-steps li + li {
  margin-top: 6px;
}

.oc-help-steps code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #a7f3d0;
}

@media (max-width: 900px) {
  .oc-conn-params {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .oc-conn-params {
    grid-template-columns: 1fr;
  }
}

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

.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 {
  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; }

.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: var(--primary-soft-md);
  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;
}

.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: var(--primary-soft);
  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);
}

html {
  -webkit-text-size-adjust: 100%;
}

body.sidebar-open {
  overflow: hidden;
}

.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);
}

@media (max-width: 860px) {
  .app-layout {
    display: block;
    min-height: 100vh;
  }

  .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: 40px;
    height: 40px;
    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);
  }

  .menu-toggle-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    width: 44px;
    height: 44px;
    padding: 10px;
    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 {
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .topbar-left {
    flex: 1 1 auto;
    min-width: 0;
  }

  .topbar-actions {
    flex: 1 1 100%;
    width: 100%;
    justify-content: flex-start;
  }

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

  .auth-logged-in {
    flex-wrap: wrap;
    margin-left: auto;
  }

  .table-responsive {
    overscroll-behavior-x: contain;
  }

  .tab-container {
    padding: 16px 12px;
  }

  .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-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;
  }

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

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

@media (max-width: 600px) {
  .topbar {
    padding: 10px 12px;
  }

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

  .refresh-label {
    display: none;
  }

  .stats-grid {
    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;
  }

  .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%;
  }

  .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;
  }

  .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-size: 0.76rem;
    min-width: 580px;
  }

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

  .code-guide {
    padding: 12px 14px;
  }

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

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

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

.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 var(--primary-soft-md);
  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 var(--primary-glow);
}

@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-container {
  position: relative;
}

.btn-icon.spinning {
  display: inline-block;
  animation: preloader-spin 0.8s linear infinite;
}

.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: var(--primary-soft-strong);
  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: var(--success);
  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: var(--success);
  background: var(--primary-soft);
}

.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: var(--success);
  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; }

.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: var(--success);
}
.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: var(--primary-soft);
  border-color: var(--primary);
  color: var(--success);
  box-shadow: 0 0 14px var(--primary-glow);
}
.bal-action-btn.active[data-action="add"] .action-title {
  color: var(--success);
}
.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: var(--accent-blue);
  color: #8eb6e0;
  box-shadow: 0 0 14px rgba(59, 130, 246, 0.2);
}
.bal-action-btn.active[data-action="set"] .action-title {
  color: #8eb6e0;
}

.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: var(--primary-soft-md);
  border-color: var(--primary);
  color: var(--success);
  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: var(--success);
  font-size: 1rem;
}
.calc-projected.negative {
  color: #f87171;
}

.modal-xl {
  max-width: 900px;
  width: 95%;
}
.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(auto-fit, minmax(160px, 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 {
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
}
.stat-banner-icon .stat-icon-svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.player-toolbar-actions {
  flex-wrap: wrap;
  gap: 8px;
}
.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: var(--success); }
.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-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;
  }
}

@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) {
  .stat-card-tx {
    grid-column: 1 / -1;
  }

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

  .admin-badge .badge-role {
    display: none;
  }

  .auth-box {
    gap: 6px;
  }

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

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

  .shell-switch-btn {
    max-width: 4.5rem;
    padding: 0 8px;
    font-size: 0;
  }

  .shell-switch-btn::before {
    content: "Админ";
    font-size: 0.75rem;
    line-height: 1;
    font-weight: 700;
  }

  body[data-shell="admin"] .shell-switch-btn::before {
    content: "Работа";
  }

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

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

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

  .modal-xl,
  .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) {
  .stat-card-tx {
    grid-column: auto;
  }

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

.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: var(--primary-soft-strong);
  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-econ {
  margin: 2px 0 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}
.item-econ-row strong {
  color: var(--text-main);
  font-weight: 650;
}

.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: var(--success);
  background: var(--primary-soft);
  padding: 3px 9px;
  border-radius: 6px;
  white-space: nowrap;
}

.item-price-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}

.item-price-pill.item-price-margin {
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
}
.item-price-pill.item-price-loss {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}
.item-card-loss {
  border-color: rgba(239, 68, 68, 0.35);
}
.alert-strip-icon .alert-icon-svg,
.alert-strip-icon .icon-svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -2px;
}
.item-price-pill.item-price-buy {
  color: #8eb6e0;
  background: rgba(59, 130, 246, 0.12);
}

.item-price-pill.item-price-sell {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.12);
}

.item-price-pill.is-off {
  opacity: 0.45;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.item-card-disabled {
  opacity: 0.72;
}

.item-trade-toggles {
  margin: 0 0 14px;
  gap: 10px;
}

.item-trade-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  cursor: pointer;
  font-size: 0.9rem;
  user-select: none;
}

.item-trade-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.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;
  }
}

/* ---- Perf panel (dark theme) ---- */
.perf-section-title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}
.perf-http-list,
.perf-trace-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.perf-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.4fr) minmax(120px, 1fr) auto;
  gap: 10px 14px;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-main);
}
.perf-row-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.perf-row-title {
  font-weight: 600;
  font-size: 0.9rem;
  word-break: break-word;
  color: var(--text-main);
}
.perf-bar-track {
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}
.perf-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent-blue, #3d8bfd);
  min-width: 2px;
}
.perf-bar-fill.is-warn { background: #c9a227; }
.perf-bar-fill.is-bad { background: #ef4444; }
.perf-ms {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text-main);
}
.perf-trace-card {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--bg-input);
  color: var(--text-main);
}
.perf-trace-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--text-main);
}
.perf-span-row {
  display: grid;
  grid-template-columns: minmax(100px, 160px) 1fr auto;
  gap: 8px;
  align-items: center;
  margin: 4px 0;
  font-size: 0.85rem;
  color: var(--text-main);
}
.perf-span-name {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 720px) {
  .perf-row,
  .perf-span-row,
  .perf-shop-last {
    grid-template-columns: 1fr;
  }
}

/* ---- Perf shop cards ---- */
.perf-shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.perf-shop-card {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px;
  background: var(--bg-card-hover);
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--text-main);
}
.perf-shop-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.perf-shop-title {
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  color: var(--text-main);
}
.perf-shop-last {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
}
.perf-shop-traces {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow: auto;
}
.perf-trace-details {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--bg-input);
  color: var(--text-main);
}
.perf-trace-details > summary {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  list-style: none;
  color: var(--text-main);
}
.perf-trace-details > summary::-webkit-details-marker { display: none; }
.perf-trace-details > summary strong {
  color: var(--text-main);
}
.perf-trace-body {
  margin-top: 8px;
  color: var(--text-main);
}


.nav-group { margin-bottom: 14px; }
.nav-group-label {
  display: block;
  padding: 8px 18px 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.85;
}
.nav-item .icon-svg {
  width: 18px; height: 18px; flex-shrink: 0;
  stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--primary-glow), var(--primary-soft));
  border: 1px solid var(--border-strong);
  color: var(--primary);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-info h2 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.skeleton-wrap { display: grid; gap: 10px; padding: 8px 0 16px; }
.skeleton-block {
  height: 56px; border-radius: var(--radius-md);
  background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.09), rgba(255,255,255,0.04));
  background-size: 200% 100%;
  animation: skeleton-shine 1.2s ease-in-out infinite;
}
@keyframes skeleton-shine {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  padding: 12px 16px; border-radius: var(--radius-md);
  background: var(--bg-elevated); border: 1px solid var(--border-color);
  box-shadow: var(--shadow-soft); opacity: 0; transform: translateY(8px);
  transition: opacity .2s, transform .2s; max-width: min(360px, calc(100vw - 32px));
  font-weight: 600; font-size: 0.92rem;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-ok { border-color: rgba(125, 206, 160, 0.35); }
.toast-error { border-color: rgba(224, 108, 117, 0.45); color: #f5b7b1; }
.page-ellipsis { color: var(--text-muted); padding: 0 4px; }
.terminal-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.terminal-row.is-clickable { cursor: pointer; }
.terminal-row.is-clickable:hover { background: rgba(255, 255, 255, 0.03); }
.terminal-row.is-clickable:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.terminal-row .recent-item-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.series-chart {
  display: flex; align-items: flex-end; gap: 4px;
  min-height: 150px; padding: 8px 4px 0;
}
.series-legend {
  display: flex; gap: 14px; margin-top: 10px; font-size: 0.8rem; color: var(--text-muted);
}
.series-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.series-swatch { width: 10px; height: 10px; border-radius: 2px; }
.series-swatch.buy { background: var(--success); }
.series-swatch.sell { background: var(--accent-amber); }
.series-bar-buy { background: var(--success) !important; }
.series-bar-sell { background: var(--accent-amber) !important; }
.series-panel .series-chart,
.series-panel .series-chart-inner,
.series-panel .series-bars-row {
  width: 100%;
  min-height: 160px;
}
.stat-icon-svg {
  width: 22px; height: 22px; stroke: currentColor; fill: none;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.icon-users { background: rgba(107, 155, 209, 0.15); color: var(--accent-blue); }
.icon-money { background: var(--primary-soft-md); color: var(--primary); }
.icon-items { background: rgba(232, 168, 74, 0.15); color: var(--accent-amber); }
.icon-logs { background: rgba(125, 206, 160, 0.15); color: var(--success); }
.icon-terminals { background: rgba(107, 155, 209, 0.15); color: var(--accent-teal); }

/* ==========================================================================
   v6.0 — pane loading, alerts, bulk edit, player page, install wizard, theme
   ========================================================================== */

/* pane skeleton replaces the pane content while a tab loads */
.tab-pane.is-loading > :not(.skeleton-wrap) { display: none !important; }
.skeleton-wrap { animation: pane-fade-in 0.15s ease; }
@keyframes pane-fade-in { from { opacity: 0; } to { opacity: 1; } }

body:not(.is-admin) .admin-only-ui { display: none !important; }
.nav-item-ephemeral:not(.active) { display: none !important; }
.btn-icon-only { padding: 8px 10px; }
.btn-icon-only .btn-icon { font-size: 1rem; }
.btn.is-copied { background: var(--success); color: #fff; }

/* dashboard alerts */
.alert-strip { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.alert-strip[hidden] { display: none; }
.alert-strip-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-left-width: 4px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 0.9rem;
}
.alert-strip-text { flex: 1; min-width: 0; }
.alert-strip-item.alert-warning { border-left-color: var(--accent-amber); background: rgba(232, 168, 74, 0.1); }
.alert-strip-item.alert-critical { border-left-color: var(--accent-red); background: rgba(224, 108, 117, 0.1); }
.alert-strip-item.alert-info { border-left-color: var(--accent-blue); background: rgba(107, 155, 209, 0.1); }

.series-header-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.series-header-controls .series-legend { margin-top: 0; }
.terminal-user { white-space: nowrap; }
.terminal-dot.is-online { animation: terminal-ping 2s infinite; }
@keyframes terminal-ping {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); }
  70% { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

/* catalog: sort + bulk selection */
.card-toolbar-wrap { flex-wrap: wrap; }
.items-sort-controls .select-input-sm { min-width: 150px !important; }
.btn-order { min-width: 36px; font-size: 1rem; line-height: 1; }
.items-select-all {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.85rem; color: var(--text-muted); cursor: pointer; user-select: none;
}
.items-select-all input,
.item-select-cb { accent-color: var(--primary); cursor: pointer; }
.item-select-cb { width: 16px; height: 16px; }
.item-card-lead { display: flex; align-items: center; gap: 8px; min-width: 0; }
.item-select { display: inline-flex; align-items: center; padding: 2px; cursor: pointer; }
/* Same pixel icons as public /shop/ (shared ui/itemIcons.js) */
.shop-icon {
  flex: none; width: 40px; height: 40px; display: grid; place-items: center; overflow: hidden;
  border-radius: 10px; background: var(--surface-tint, var(--bg-elevated)); border: 1px solid var(--border-color);
}
/* object-fit/cover + top: animated strips (NxN frames) show first frame like HEI */
.shop-icon img {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  object-fit: cover;
  object-position: top center;
}
.shop-icon.is-fallback {
  font-size: 0.82rem; font-weight: 800; letter-spacing: 0.02em; color: var(--text-strong);
  background: hsl(var(--icon-hue, 30) 45% 38% / 0.35); border-color: hsl(var(--icon-hue, 30) 45% 50% / 0.45);
}
.item-card-lead .shop-icon { width: 36px; height: 36px; border-radius: 8px; }
.item-card-lead .shop-icon img { width: 28px; height: 28px; }
.item-modal-preview {
  display: flex; align-items: center; gap: 12px;
  margin: 0 0 14px; padding: 10px 12px;
  border: 1px solid var(--border-color); border-radius: var(--radius-md);
  background: var(--bg-elevated);
}
.item-modal-preview[hidden] { display: none; }
.item-modal-preview-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.item-modal-preview-text strong { font-size: 0.95rem; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; }
.item-modal-preview-text span { font-size: 0.78rem; }

.item-craft-panel {
  margin: 0 0 16px; padding: 12px;
  border: 1px solid var(--border-color); border-radius: var(--radius-md);
  background: var(--bg-elevated);
}
.item-craft-panel[hidden] { display: none; }
.item-craft-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 10px;
}
.item-craft-nav { display: flex; align-items: center; gap: 6px; }
.item-craft-nav[hidden] { display: none; }
.item-craft-layout { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.item-craft-grid-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.item-craft-grid {
  display: grid;
  grid-template-columns: repeat(var(--craft-grid, 3), 40px);
  gap: 4px;
}
.item-craft-slot.has-alts { cursor: pointer; }
.item-craft-alt-badge {
  position: absolute;
  top: 1px;
  left: 1px;
  font-size: 0.55rem;
  font-weight: 700;
  line-height: 1;
  padding: 1px 3px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  pointer-events: none;
}
.item-craft-alt-nav {
  position: absolute;
  bottom: 0;
  right: 0;
  display: flex;
  gap: 0;
  opacity: 0.85;
}
.item-craft-alt-btn {
  border: none;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 0.65rem;
  line-height: 1;
  padding: 1px 3px;
  cursor: pointer;
}
.item-craft-alt-btn:hover { background: rgba(0, 0, 0, 0.7); }
.item-craft-meta { margin-top: 8px; }
.item-craft-slot {
  position: relative;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--surface-tint, rgba(255,255,255,0.04));
  overflow: hidden;
}
.item-craft-slot.is-empty { opacity: 0.35; }
.item-craft-slot .shop-icon {
  width: 28px; height: 28px; border: none; background: transparent;
  display: grid; place-items: center; overflow: hidden;
}
.item-craft-slot .shop-icon img,
.item-craft-count {
  position: absolute; right: 2px; bottom: 1px;
  font-size: 0.65rem; font-weight: 800; color: var(--text-strong);
  text-shadow: 0 0 2px #000;
}
.item-craft-nbt {
  position: absolute; left: 2px; top: 1px;
  font-size: 0.55rem; font-weight: 700; color: var(--accent-amber, #e8a84a);
}
.item-craft-arrow { font-size: 1.25rem; color: var(--text-muted); }
.item-craft-output { display: flex; align-items: center; gap: 4px; }
.item-craft-output-count { font-weight: 700; font-size: 0.85rem; }
.item-craft-summary { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 6px; }
.item-craft-summary-label { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.item-craft-summary-row {
  display: grid; grid-template-columns: 24px 1fr auto auto; gap: 8px; align-items: center;
}
.item-craft-summary-row .shop-icon {
  width: 24px; height: 24px;
  display: grid; place-items: center; overflow: hidden;
  border: none; background: transparent;
}
.item-craft-summary-row .shop-icon img { width: 22px; height: 22px; }
.item-craft-summary-title { font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-craft-summary-qty { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); }
.item-craft-summary-price { font-size: 0.85rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.item-craft-bom-details {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}
.item-craft-bom-details > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  user-select: none;
}
.item-craft-bom-details > summary:hover { color: var(--primary, #6366f1); }
.item-craft-bom-details.is-loading > summary {
  color: var(--primary, #6366f1);
}
.item-craft-bom-panel { margin-top: 10px; }
.item-craft-bom-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md, 8px);
  background: var(--bg-elevated, transparent);
}
.item-craft-bom-spinner {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-color, rgba(0,0,0,0.12));
  border-top-color: var(--primary, #6366f1);
  border-radius: 50%;
  animation: item-craft-bom-spin 0.7s linear infinite;
}
.item-craft-bom-loading-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
@keyframes item-craft-bom-spin {
  to { transform: rotate(360deg); }
}
.item-craft-cost {
  margin-bottom: 12px;
  display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: baseline;
}
.item-craft-bom {
  margin-top: 14px;
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(280px, 1.4fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 720px) {
  .item-craft-bom { grid-template-columns: 1fr; }
}
.item-craft-src {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  vertical-align: middle;
}
.item-craft-src-site { background: rgba(52, 211, 153, 0.18); color: #059669; }
.item-craft-src-craft { background: rgba(59, 130, 246, 0.15); color: #2563eb; }
.item-craft-src-missing { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
.item-craft-type {
  margin-left: 6px;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}
.item-craft-tree-wrap { min-width: 0; }
.item-craft-tree {
  max-height: min(42vh, 420px);
  overflow: auto;
  margin-top: 6px;
  padding: 6px 4px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md, 8px);
  background: var(--bg-elevated, transparent);
}
.item-craft-tree-head {
  display: grid;
  grid-template-columns: 24px 1fr auto auto;
  gap: 8px;
  padding: 0 8px 4px 28px;
  font-size: 0.7rem;
}
.item-craft-tree-node { margin: 0; }
.item-craft-tree-leaf { padding-left: 16px; }
.item-craft-tree-node > summary {
  list-style: none;
  cursor: pointer;
}
.item-craft-tree-node > summary::-webkit-details-marker { display: none; }
.item-craft-tree-row {
  display: grid;
  grid-template-columns: 24px 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 4px 8px;
  border-radius: 6px;
}
.item-craft-tree-node > summary .item-craft-tree-row::before {
  content: '▸';
  position: absolute;
  margin-left: -16px;
  color: var(--text-muted);
  font-size: 0.7rem;
}
.item-craft-tree-node[open] > summary .item-craft-tree-row::before { content: '▾'; }
.item-craft-tree-node > summary { position: relative; padding-left: 16px; }
.item-craft-tree-row:hover { background: var(--nav-active-bg, rgba(0,0,0,0.04)); }
.item-craft-tree-row.is-dimmed { opacity: 0.45; }
.item-craft-tree-row .shop-icon {
  width: 24px; height: 24px;
  display: grid; place-items: center; overflow: hidden;
  border: none; background: transparent;
}
.item-craft-tree-row .shop-icon img { width: 22px; height: 22px; }
.item-craft-tree-title {
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-craft-tree-qty,
.item-craft-tree-cost {
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.item-craft-tree-qty { color: var(--text-muted); font-weight: 700; }
.item-craft-tree-cost { font-weight: 700; }
.item-craft-tree-children {
  margin-left: 14px;
  padding-left: 8px;
  border-left: 1px solid var(--border-color);
}
.item-card.is-selected {
  border-color: var(--primary);
  background: var(--nav-active-bg);
  box-shadow: 0 0 0 1px var(--primary) inset;
}

/* Catalog sync is site-admin only */
body:not(.role-admin) #itemsSyncBtn { display: none !important; }

.items-sync-body { display: flex; flex-direction: column; gap: 10px; min-height: 280px; }
.items-sync-toolbar {
  display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end;
}
.items-sync-field { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.items-sync-search { flex: 1; min-width: 180px; }
.items-sync-actions {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
}
.items-sync-table-wrap {
  max-height: min(52vh, 480px); overflow: auto;
  border: 1px solid var(--border-color); border-radius: var(--radius-md, 8px);
}
.items-sync-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.items-sync-table th,
.items-sync-table td {
  padding: 8px 10px; border-bottom: 1px solid var(--border-color);
  text-align: left; vertical-align: middle;
}
.items-sync-table th {
  position: sticky; top: 0; background: var(--bg-elevated, var(--bg));
  z-index: 1; font-size: 0.75rem; color: var(--text-muted);
}
.items-sync-icon .shop-icon { width: 28px; height: 28px; }
.items-sync-icon .shop-icon img { width: 22px; height: 22px; }
.items-sync-title { font-weight: 600; }
.items-sync-status {
  display: inline-block; padding: 2px 6px; border-radius: 4px;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
}
.items-sync-status.is-missing {
  background: hsl(145 40% 40% / 0.2); color: hsl(145 45% 42%);
}
.items-sync-status.is-changed {
  background: hsl(35 70% 45% / 0.2); color: hsl(35 70% 40%);
}
.items-sync-diff { color: var(--text-muted); max-width: 360px; }

.bulk-bar {
  padding: 14px 24px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-strong);
}
.bulk-bar[hidden] { display: none; }
.bulk-bar-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.bulk-bar-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 18px; }
.bulk-field { display: flex; flex-direction: column; gap: 4px; }
.bulk-field label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); }
.bulk-field-row { display: flex; gap: 6px; }
.bulk-field .select-input-sm { min-width: 130px; }
.bulk-field-action { flex-direction: row; align-items: center; gap: 8px; }
.bulk-value { width: 96px; padding: 6px 10px; }
.bulk-value:disabled { opacity: 0.5; }

/* player page */
.history-tab-btn.active#playerTabPurchases { color: #38bdf8; }
.history-tab-btn.active#playerTabSales { color: #fbbf24; }
.player-header-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.player-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 20px;
  margin-top: 20px;
  align-items: start;
}
.player-main { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.player-logs-container { max-height: min(560px, 60vh); }
.player-side {
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--surface-tint);
}
@media (max-width: 1024px) {
  .player-layout { grid-template-columns: 1fr; }
}

/* computer install wizard */
.wizard-steps { list-style: none; display: grid; gap: 12px; margin: 0 0 12px; padding: 0; }
.wizard-step { display: flex; align-items: flex-start; gap: 12px; opacity: 0.55; }
.wizard-step.is-current,
.wizard-step.is-done { opacity: 1; }
.wizard-step-num {
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  font-size: 0.8rem; font-weight: 700;
  color: var(--text-muted);
}
.wizard-step.is-current .wizard-step-num {
  border-color: var(--primary); color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.wizard-step.is-current[data-step="3"] .wizard-step-num { animation: wizard-pulse 1.4s ease-in-out infinite; }
.wizard-step.is-done .wizard-step-num {
  background: var(--success); border-color: var(--success); color: #fff; font-size: 0;
}
.wizard-step.is-done .wizard-step-num::before { content: '✓'; font-size: 0.85rem; }
@keyframes wizard-pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--primary-glow); }
  50% { box-shadow: 0 0 0 7px transparent; }
}
.wizard-step-text { display: flex; flex-direction: column; min-width: 0; }
.wizard-status { min-height: 1.3em; margin-bottom: 8px; font-size: 0.85rem; color: var(--text-muted); }
.wizard-status.is-ok { color: var(--success); font-weight: 700; }
.wizard-status.is-warn { color: var(--text-amber); }
.copy-block {
  margin: 6px 0 10px;
  padding: 10px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  cursor: copy;
  user-select: all;
  word-break: break-all;
}
.copy-block:hover { border-color: var(--primary); }

/* --------------------------------------------------------------------------
   Light theme overrides for rules that hard-code dark-mode colours
   -------------------------------------------------------------------------- */
[data-theme="light"] .card,
[data-theme="light"] .stat-card { box-shadow: 0 2px 10px rgba(70, 52, 24, 0.08); }

[data-theme="light"] .btn-secondary { background-color: var(--surface-tint-strong); }
[data-theme="light"] .btn-secondary:hover { background-color: rgba(70, 52, 24, 0.15); }
[data-theme="light"] .btn-primary { color: #fff; }
[data-theme="light"] .btn.is-copied { background: var(--success); color: #fff; }

[data-theme="light"] .data-table th,
[data-theme="light"] .matrix-total-cell,
[data-theme="light"] .history-summary-footer,
[data-theme="light"] .history-pagination-footer,
[data-theme="light"] .auth-guest-badge,
[data-theme="light"] .user-meta-chip,
[data-theme="light"] .history-qty-pill,
[data-theme="light"] .log-id-tag { background: var(--surface-tint); }

[data-theme="light"] .user-card,
[data-theme="light"] .item-card,
[data-theme="light"] .balance-user-card,
[data-theme="light"] .stat-banner-item,
[data-theme="light"] .quick-chip { background: var(--surface-tint); }
[data-theme="light"] .user-card:hover,
[data-theme="light"] .item-card:hover,
[data-theme="light"] .bal-action-btn:hover,
[data-theme="light"] .entity-list-item:hover,
[data-theme="light"] .logs-activity-list .recent-item:hover { background: var(--surface-tint-strong); }
[data-theme="light"] .item-card.is-selected { background: var(--nav-active-bg); }

[data-theme="light"] .page-btn:hover:not(:disabled) { background: var(--surface-tint-strong); border-color: var(--border-strong); }
[data-theme="light"] .log-id-tag { border-color: var(--border-color); }
[data-theme="light"] .history-tab-badge,
[data-theme="light"] .badge-secondary { background: var(--surface-tint-strong); }
[data-theme="light"] .perf-bar-track { background: var(--surface-tint-strong); }
[data-theme="light"] .history-logs-container { background: var(--surface-sunken); }
[data-theme="light"] .matrix-cell-empty { color: rgba(70, 52, 24, 0.25); }
[data-theme="light"] .skeleton-block {
  background: linear-gradient(90deg, rgba(70,52,24,0.05), rgba(70,52,24,0.12), rgba(70,52,24,0.05));
  background-size: 200% 100%;
}

[data-theme="light"] .history-tab-btn.active { color: var(--text-main); box-shadow: 0 1px 4px rgba(70, 52, 24, 0.18); }
[data-theme="light"] .history-tab-btn.active#playerTabPurchases { color: var(--text-cyan); }
[data-theme="light"] .history-tab-btn.active#playerTabSales { color: var(--text-amber); }

[data-theme="light"] .recent-item-title { color: var(--text-strong); }
[data-theme="light"] .recent-item-cost,
[data-theme="light"] .user-meta-chip.bought,
[data-theme="light"] .history-cost-pill.bought,
[data-theme="light"] .text-cyan,
[data-theme="light"] .hl-domain { color: var(--text-cyan); }
[data-theme="light"] .recent-item-cost.sold,
[data-theme="light"] .history-logs-container .recent-item-cost.sold,
[data-theme="light"] .user-meta-chip.sold,
[data-theme="light"] .history-cost-pill.sold,
[data-theme="light"] .text-amber { color: var(--text-amber) !important; }
[data-theme="light"] .code-guide pre { color: var(--text-code); }
[data-theme="light"] .alert-error { color: var(--text-danger-soft); }
[data-theme="light"] .text-danger { color: var(--accent-red) !important; }

[data-theme="light"] .badge-primary { color: var(--primary); }
[data-theme="light"] .badge-muted { color: #5b6573; }
[data-theme="light"] .badge-warning { color: #9a5b00; }
[data-theme="light"] .badge-danger { color: #b02a2a; }
[data-theme="light"] .icon-sold { color: #9a5b00; }
[data-theme="light"] .icon-profit { color: #2f6aa8; }

[data-theme="light"] .toast-error { color: #a93226; }
[data-theme="light"] .modal-backdrop { background: rgba(35, 31, 23, 0.45); }