:root {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f3f6fa;
}

* { box-sizing: border-box; }
body { margin: 0; background: #f3f6fa; color: #172033; }
button, input, select { font: inherit; }
[hidden] { display: none !important; }

.page-shell { width: min(1380px, calc(100% - 32px)); margin: 30px auto 70px; }
.page-header { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 22px; }
.eyebrow { margin: 0 0 6px; color: #65738a; font-size: 12px; font-weight: 800; letter-spacing: .14em; }
h1 { margin: 0; font-size: clamp(28px, 4vw, 42px); line-height: 1.05; }
h2 { margin: 0; }
.subtle { color: #66748a; margin: 8px 0 0; font-size: 14px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { background: #fff; border: 1px solid #dfe5ed; border-radius: 14px; padding: 16px 18px; box-shadow: 0 2px 8px rgba(22,32,51,.035); }
.stat-card span { display: block; color: #68768a; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 7px; }
.stat-card strong { font-size: 27px; line-height: 1; }

.filters { display: grid; grid-template-columns: minmax(260px, 2fr) repeat(5, minmax(140px, 1fr)) auto; gap: 10px; align-items: end; background: #fff; border: 1px solid #dfe5ed; border-radius: 14px; padding: 14px; position: sticky; top: 8px; z-index: 10; box-shadow: 0 6px 20px rgba(25,36,55,.07); }
.filters label { display: grid; gap: 6px; }
.filters label > span { font-size: 12px; color: #66748a; font-weight: 700; }
.filters input, .filters select { width: 100%; min-height: 42px; border: 1px solid #cad3df; background: #fff; color: #172033; border-radius: 9px; padding: 9px 11px; outline: none; }
.filters input:focus, .filters select:focus { border-color: #426fca; box-shadow: 0 0 0 3px rgba(66,111,202,.12); }

.secondary-button, .clear-button, .icon-button { border: 1px solid #c8d2df; background: #fff; color: #21314c; border-radius: 9px; cursor: pointer; font-weight: 700; }
.secondary-button, .clear-button { min-height: 42px; padding: 9px 14px; }
.secondary-button:hover, .clear-button:hover { background: #f6f8fb; }
.clear-button { white-space: nowrap; }
.icon-button { width: 38px; height: 38px; font-size: 24px; line-height: 1; }

.status { margin: 18px 2px 12px; color: #5f6e83; font-size: 14px; }
.groups { display: grid; gap: 14px; }
.group { background: #fff; border: 1px solid #dfe5ed; border-radius: 14px; padding: 18px; box-shadow: 0 2px 10px rgba(20,31,45,.04); }
.group-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 13px; }
.group-title { font-size: 18px; line-height: 1.35; margin: 0; }
.group-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 4px 8px; border-radius: 999px; background: #edf2f8; color: #4e5d72; font-size: 12px; font-weight: 700; }
.badge.verified { background: #e8f5ed; color: #24633c; }
.copy-count { min-width: 68px; text-align: center; border-radius: 11px; background: #eef3fb; padding: 8px 10px; }
.copy-count strong { display: block; font-size: 21px; }
.copy-count span { font-size: 11px; color: #64738a; text-transform: uppercase; font-weight: 700; }
.identity { margin: 0 0 12px; padding: 10px 12px; background: #f8fafc; border-radius: 9px; font-size: 13px; color: #536177; }
.identity strong { color: #2c3c57; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 9px 8px; border-top: 1px solid #edf1f5; text-align: left; font-size: 13px; vertical-align: middle; }
th { color: #607087; font-size: 11px; text-transform: uppercase; letter-spacing: .035em; }
td.price { font-variant-numeric: tabular-nums; white-space: nowrap; }
a.auction-link { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 6px 10px; border-radius: 8px; text-decoration: none; background: #1e5cbc; color: #fff; font-weight: 700; white-space: nowrap; }
a.auction-link:hover { background: #174a9a; }
.load-more-wrap { display: flex; justify-content: center; padding: 22px 0; }
.empty { background: #fff; border: 1px solid #dfe5ed; border-radius: 14px; padding: 24px; color: #66748a; }

.diagnostics-dialog { width: min(680px, calc(100% - 28px)); border: 0; border-radius: 16px; padding: 0; box-shadow: 0 24px 70px rgba(15,25,40,.28); }
.diagnostics-dialog::backdrop { background: rgba(15,25,40,.38); }
.dialog-header { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; padding: 20px 22px; border-bottom: 1px solid #e5e9ef; }
#diagnosticsContent { padding: 18px 22px 24px; }
.diag-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.diag-row { background: #f7f9fc; border-radius: 9px; padding: 11px 12px; }
.diag-row span { display: block; color: #6c798c; font-size: 11px; text-transform: uppercase; font-weight: 700; margin-bottom: 4px; }
.diag-row strong { font-size: 15px; }
.warning-box { margin-top: 14px; padding: 12px; border-radius: 9px; background: #fff5e8; color: #744b17; font-size: 13px; }
.ok-box { margin-top: 14px; padding: 12px; border-radius: 9px; background: #edf7f0; color: #285e38; font-size: 13px; }

@media (max-width: 1120px) {
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .wide-field { grid-column: span 2; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 700px) {
  .page-shell { width: min(100% - 20px, 1380px); margin-top: 18px; }
  .page-header { align-items: stretch; flex-direction: column; }
  .page-header .secondary-button { width: 100%; }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 13px; }
  .stat-card strong { font-size: 22px; }
  .filters { position: static; grid-template-columns: 1fr 1fr; }
  .wide-field { grid-column: 1 / -1; }
  .clear-button { grid-column: 1 / -1; }
  .group { padding: 14px; }
  .group-head { flex-direction: column; }
  .copy-count { align-self: flex-start; }
  .diag-grid { grid-template-columns: 1fr; }
}

.header-actions { display: flex; gap: 9px; align-items: center; }
.box-view-button { min-height: 42px; padding: 9px 14px; border: 1px solid #b58416; border-radius: 9px; background: #fff6dc; color: #73500b; font-weight: 800; cursor: pointer; }
.box-view-button:hover { background: #ffe9a7; }
.box-progress { margin: 8px 2px 16px; color: #536177; font-size: 13px; }
.resale-flag { display: inline-flex; align-items: center; gap: 4px; vertical-align: middle; border-radius: 7px; font-size: 15px; padding: 2px 5px; white-space: nowrap; }
.resale-flag.gold { color: #a16b00; background: #fff2c5; }
.resale-flag.silver { color: #5c6876; background: #eaf0f5; }
.market-icon { font-size: 10px; font-weight: 900; padding: 2px 4px; border-radius: 4px; background: #fff; }
.market-icon.fb { color: #1769aa; }
.market-icon.ebay { color: #b4352c; }
.box-card { display: flex; gap: 16px; background: #fff; border: 1px solid #dfe5ed; border-radius: 14px; padding: 14px; }
.box-photo-link { flex: 0 0 190px; }
.box-thumb { display: block; width: 190px; height: 145px; object-fit: contain; background: #edf1f5; border-radius: 9px; }
.box-thumb.missing { display: grid; place-items: center; color: #64738a; font-size: 12px; }
.box-card-content { min-width: 0; }
.box-card-content h2 { font-size: 17px; line-height: 1.35; }
.box-card-content p { color: #64738a; font-size: 13px; margin: 8px 0 13px; }
@media (max-width: 700px) {
  .header-actions { flex-wrap: wrap; }
  .header-actions > button { flex: 1 1 140px; }
  .box-card { gap: 12px; }
  .box-photo-link { flex-basis: 105px; }
  .box-thumb { width: 105px; height: 105px; }
  .box-card-content h2 { font-size: 14px; }
}

.resale-view-button { min-height: 42px; padding: 9px 14px; border: 1px solid #bc9330; border-radius: 9px; background: #fff2c5; color: #73500b; font-weight: 800; cursor: pointer; }
.resale-view-button:hover, .resale-view-button[aria-pressed="true"] { background: #ffe49a; }
.back-to-top { position: fixed; right: 20px; bottom: 22px; z-index: 20; min-height: 42px; padding: 9px 15px; border: 1px solid #1e5cbc; border-radius: 999px; background: #1e5cbc; color: #fff; font-weight: 800; box-shadow: 0 6px 20px rgba(20,31,45,.2); cursor: pointer; }
.back-to-top:hover { background: #174a9a; }
