:root {
  color-scheme: dark;
  --bg: #000000;
  --surface: #0a0a0a;
  --surface-2: #121212;
  --line: #303030;
  --soft-line: #242424;
  --text: #f5f5f3;
  --muted: #a9a9a5;
  --gold: #b59b76;
  --green: #8ecbb5;
  --amber: #e0b66f;
  --red: #e10b17;
  --blue: #e10b17;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.topbar { height: 70px; padding: 0 4vw; position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--soft-line); background: rgba(0, 0, 0, .92); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand > div { display: grid; gap: 2px; }
.brand small { color: var(--muted); font-size: 12px; }
.brand-mark { width: 39px; height: 39px; border: 1px solid var(--red); color: white; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; line-height: 1; letter-spacing: .08em; }
.top-actions { display: flex; gap: 8px; }
.ghost { color: #cbd3da; background: transparent; border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; }
.ghost:hover { color: white; border-color: #526575; }

.shell { width: min(1180px, 92vw); margin: 0 auto; padding: 25px 0 100px; }
.intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 430px); gap: 50px; align-items: end; }
.intro h1 { margin: 7px 0 18px; font: 500 clamp(43px, 6vw, 72px)/.98 Georgia, serif; letter-spacing: -.04em; }
.intro p:not(.eyebrow) { max-width: 650px; margin: 0; color: #b9c3cb; line-height: 1.65; }
.eyebrow { color: var(--gold); margin: 0; text-transform: uppercase; letter-spacing: .16em; font-size: 11px; font-weight: 800; }
.eyebrow.green { color: var(--green); }
.eyebrow.amber { color: var(--amber); }
.folder-flow { border: 1px solid var(--line); background: rgba(17,24,32,.78); border-radius: 16px; padding: 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.folder-flow span { font-size: 11px; letter-spacing: .04em; color: #c3ccd3; background: #0c1218; border: 1px solid var(--soft-line); padding: 8px 9px; border-radius: 8px; }
.folder-flow span.ready { color: #9ee0bb; border-color: rgba(109,208,156,.32); }
.folder-flow b { color: var(--muted); }

.ebay-import { margin: 0 0 16px; padding: 0; display: flex; align-items: center; justify-content: flex-end; border: 0; background: none; }
.ebay-import-copy { min-width: 0; }
.ebay-import h2 { margin: 5px 0 6px; font: 500 23px Georgia, serif; }
.ebay-import p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.ebay-button { flex: none; min-width: 0; padding: 10px 15px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; color: white; border: 1px solid var(--red); border-radius: 7px; background: var(--red); font-weight: 850; }
.ebay-button:hover { filter: brightness(1.07); }
.ebay-button:disabled { opacity: .6; cursor: wait; }
.ebay-compliance { flex: 1 0 100%; width: 100%; padding-top: 17px; border-top: 1px solid rgba(120,175,229,.2); display: grid; grid-template-columns: minmax(180px,.6fr) repeat(2,minmax(0,1fr)); gap: 15px; align-items: end; }
.ebay-compliance[hidden] { display: none; }
.ebay-compliance strong { display: block; margin-top: 5px; font-size: 13px; }
.ebay-compliance label { min-width: 0; display: grid; gap: 6px; color: #b9c4cd; font-size: 11px; }
.copy-row { min-width: 0; display: flex; align-items: center; gap: 7px; }
.copy-row code { min-width: 0; flex: 1; padding: 9px 10px; overflow: hidden; color: #d6e8f7; background: #0a1118; border: 1px solid var(--soft-line); border-radius: 8px; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.copy-row button { flex: none; padding: 9px 10px; color: #d6e8f7; background: rgba(96,157,211,.12); border: 1px solid rgba(120,175,229,.32); border-radius: 8px; font-weight: 800; font-size: 11px; }

.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 11px; margin: 0 0 48px; }
.summary article { padding: 17px 19px; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; display: grid; gap: 5px; }
.summary strong { font-size: 25px; }
.summary span { font-size: 12px; color: var(--muted); }

.catalog-section { margin: -35px 0 65px; padding: 21px; border: 1px solid var(--soft-line); border-radius: 16px; background: rgba(17,24,32,.72); }
.catalog-heading { margin: 0 0 14px; align-items: center; gap: 20px; }
.catalog-count { flex: none; min-width: 150px; padding: 12px 14px; display: grid; gap: 3px; text-align: right; border: 1px solid rgba(209,175,112,.28); border-radius: 11px; background: rgba(209,175,112,.06); }
.catalog-count strong { color: #ead29c; font-size: 24px; }
.catalog-count span { color: var(--muted); font-size: 10px; }
.catalog-details { border-top: 1px solid var(--soft-line); }
.catalog-details summary { padding: 14px 2px 2px; color: #cbd3da; cursor: pointer; font-size: 12px; font-weight: 750; }
.catalog-details summary span { color: var(--muted); }
.purchase-catalog { max-height: 510px; margin-top: 13px; padding-right: 6px; display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 9px; overflow-y: auto; }
.catalog-card { min-width: 0; overflow: hidden; border: 1px solid var(--soft-line); border-radius: 10px; background: #0a1016; }
.catalog-card > img, .catalog-card > .image-placeholder { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; background: #06090d; }
.catalog-card > div { min-width: 0; padding: 8px; display: grid; gap: 3px; }
.catalog-card b, .catalog-card span, .catalog-card small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catalog-card b { color: #dce3e8; font-size: 10px; }
.catalog-card span { color: var(--muted); font-size: 9px; }
.catalog-card .catalog-pending { color: var(--amber); font-size: 9px; }

.queue-section { margin-top: 58px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 17px; }
.section-heading h2 { font-size: 31px; font-weight: 800; line-height: 1.1; letter-spacing: -.035em; margin: 5px 0 4px; }
.section-heading p:not(.eyebrow) { color: var(--muted); margin: 0; font-size: 13px; }
.queue { display: grid; gap: 20px; }

.match-card { border: 1px solid var(--line); border-left: 4px solid var(--red); border-radius: 12px; background: var(--surface); overflow: hidden; padding: 24px; }
.match-card.recognized { border-color: rgba(109,208,156,.35); }
.match-card > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.match-card h3 { margin: 4px 0 0; font-size: 24px; font-weight: 800; line-height: 1.15; letter-spacing: -.025em; }
.job-label { color: var(--muted); font-size: 10px; letter-spacing: .08em; }
.match-badge { white-space: nowrap; font-size: 12px; font-weight: 800; padding: 7px 10px; border-radius: 999px; }
.match-badge.strong { color: #9ee0bb; border: 1px solid rgba(109,208,156,.37); background: rgba(109,208,156,.09); }
.match-badge.unsure { color: #f0cb89; border: 1px solid rgba(229,183,103,.34); background: rgba(229,183,103,.08); }
.ai-summary, .error-message { margin: 17px 0 0; padding: 11px 13px; border-left: 2px solid var(--gold); background: rgba(209,175,112,.05); color: #c6cfd6; line-height: 1.5; font-size: 13px; }
.error-message { border-color: var(--red); color: #efaaa7; }

.comparison-toolbar { margin-top: 22px; display: flex; align-items: end; justify-content: space-between; gap: 15px; }
.comparison-toolbar h4 { margin: 0 0 4px; color: #e2e7ea; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
.comparison-toolbar small { color: var(--muted); font-size: 11px; }
.open-comparison { flex: none; padding: 9px 12px; color: #c9e3fa; background: rgba(120,175,229,.1); border: 1px solid rgba(120,175,229,.38); border-radius: 9px; font-size: 12px; font-weight: 750; }
.open-comparison:hover { background: rgba(120,175,229,.18); border-color: var(--blue); }
.comparison { margin-top: 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.comparison h4, .photo-picker h4, .fullscreen-panel h4 { margin: 0 0 9px; color: #cbd3d9; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.comparison h4 small { color: var(--muted); font-size: 10px; text-transform: none; letter-spacing: 0; margin-left: 7px; font-weight: 400; }
.comparison-pane { min-width: 0; padding: 11px; border: 1px solid var(--line); border-radius: 12px; background: #050505; }
.comparison-preview { width: 100%; height: clamp(300px, 40vw, 500px); padding: 0; display: block; overflow: hidden; background: #070b0f; border: 0; border-radius: 9px; }
.comparison-preview:not(:disabled):hover { box-shadow: 0 0 0 2px var(--blue); }
.comparison-preview:disabled { cursor: default; }
.comparison-main-image { width: 100%; height: 100%; display: grid; place-items: center; object-fit: contain; color: var(--muted); background: #070b0f; }
.purchase-preview-wrap, .purchase-stage { position: relative; }
.purchase-preview-wrap { height: clamp(300px, 40vw, 500px); }
.purchase-preview-wrap .comparison-preview { height: 100%; }
.purchase-remove-x { position: absolute; z-index: 4; top: 8px; right: 8px; width: 29px; height: 29px; padding: 0; display: grid; place-items: center; color: white; font-size: 22px; line-height: 1; background: rgba(12,17,22,.82); border: 1px solid rgba(255,255,255,.62); border-radius: 50%; box-shadow: 0 2px 10px rgba(0,0,0,.45); }
.purchase-remove-x:hover { color: white; background: #bd4d4a; border-color: #ffb3af; transform: scale(1.06); }
.purchase-remove-x:disabled { opacity: .5; cursor: wait; }
.photo-picker { margin-top: 15px; }
.photo-picker h4 small, .fullscreen-panel h4 small { color: var(--muted); font-size: 10px; text-transform: none; letter-spacing: 0; margin-left: 7px; font-weight: 400; }
.new-photo-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; }
.new-photo { padding: 0; min-width: 0; position: relative; border: 1px solid transparent; border-radius: 10px; background: #080c10; overflow: hidden; }
.new-photo img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.new-photo.hand-selected { border-color: var(--red); box-shadow: 0 0 0 2px rgba(225,11,23,.25); }
.hand-image-stage { position: relative; }
.new-photo .hand-icon, .hand-icon { position: absolute; z-index: 3; inset: 0; padding: 0; display: grid; place-items: center; color: white; background: transparent; opacity: .5; pointer-events: none; font-size: clamp(30px, 5vw, 68px); line-height: 1; text-shadow: 0 2px 12px #000; }
.new-photo .hand-icon { font-size: clamp(23px, 3.4vw, 46px); }
.empty-image { display: grid; place-items: center; color: var(--muted); }

body.comparison-open { overflow: hidden; }
.comparison-modal { position: fixed; inset: 0; z-index: 100; padding: 18px; display: grid; place-items: center; background: rgba(2,5,8,.92); backdrop-filter: blur(12px); }
.comparison-dialog { width: min(1500px, 100%); height: min(950px, calc(100vh - 36px)); min-height: 0; padding: 18px; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 14px; border: 1px solid #3a4b5a; border-radius: 17px; background: #0b1117; box-shadow: 0 35px 100px rgba(0,0,0,.65); }
.comparison-dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 15px; }
.comparison-dialog-header h3 { margin: 3px 0 0; font-size: 23px; font-weight: 800; line-height: 1.15; letter-spacing: -.025em; }
.comparison-dialog-actions { display: flex; align-items: center; gap: 8px; }
.comparison-close, .comparison-switcher button { padding: 9px 12px; color: #d7e0e7; background: #131d26; border: 1px solid #344453; border-radius: 9px; }
.comparison-close:hover, .comparison-switcher button:hover { color: white; border-color: var(--blue); }
.delete-purchase { padding: 9px 12px; color: #f1aaa6; background: rgba(239,133,128,.08); border: 1px solid rgba(239,133,128,.38); border-radius: 9px; }
.delete-purchase:hover { color: white; border-color: var(--red); background: rgba(239,133,128,.16); }
.delete-purchase:disabled { opacity: .5; cursor: wait; }
.database-remove { display: block; margin-top: 10px; font-size: 11px; }
.sheet-notice { display: grid; gap: 4px; margin: 0 0 14px; padding: 11px 13px; border-radius: 10px; font-size: 12px; }
.sheet-notice span { color: var(--muted); }
.sheet-notice a { width: max-content; color: #9bcfff; font-weight: 700; }
.sheet-notice.matched { background: rgba(74,184,123,.10); border: 1px solid rgba(74,184,123,.42); }
.sheet-notice.review { background: rgba(229,172,71,.10); border: 1px solid rgba(229,172,71,.44); }
.sheet-notice.pending { background: rgba(116,159,201,.09); border: 1px solid rgba(116,159,201,.34); }
.fullscreen-comparison { min-height: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fullscreen-panel { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); padding: 12px; border: 1px solid var(--soft-line); border-radius: 12px; background: #070b0f; }
.fullscreen-image-stage { min-height: 0; display: grid; place-items: center; overflow: auto; border-radius: 8px; background: #030608; }
.fullscreen-image-stage img { display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.comparison-switcher { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; }
.comparison-switcher span { color: var(--muted); text-align: center; font-size: 11px; }

.candidate-choices { display: flex; gap: 8px; overflow-x: auto; margin-top: 14px; padding: 2px; }
.candidate-choice { min-width: 160px; max-width: 235px; flex: 1; padding: 7px; color: var(--text); text-align: left; display: grid; grid-template-columns: 45px minmax(0,1fr); gap: 8px; align-items: center; background: #0a0a0a; border: 1px solid var(--line); border-radius: 10px; }
.candidate-choice:hover, .candidate-choice.selected { border-color: var(--red); background: rgba(225,11,23,.08); }
.candidate-choice.rejected:not(.selected) { opacity: .62; }
.candidate-choice img, .image-placeholder { display: block; width: 45px; height: 45px; object-fit: cover; border-radius: 7px; background: #070b0f; }
.candidate-choice span { min-width: 0; display: grid; gap: 3px; }
.candidate-choice b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.candidate-choice small { color: var(--muted); font-size: 10px; }
.no-candidate { margin-top: 15px; color: var(--muted); }
.reanalyze-button { margin-top: 14px; margin-right: 8px; border: 1px solid rgba(120,175,229,.35); background: rgba(120,175,229,.08); color: #b9d9f5; }

.confirm-form { display: grid; grid-template-columns: .7fr .7fr 1.4fr .8fr; gap: 11px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--soft-line); }
.confirm-form label { display: grid; gap: 6px; color: #c6cfd5; font-size: 12px; }
.confirm-form input { width: 100%; min-width: 0; padding: 11px 12px; color: white; background: #0a1016; border: 1px solid var(--line); border-radius: 9px; outline: 0; }
.confirm-form input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(225,11,23,.14); }
.filename-preview { color: var(--muted); font-size: 11px; align-self: center; overflow-wrap: anywhere; }
.filename-preview code { color: #b8cce0; }
.confirm-button { color: white; background: var(--red); border: 1px solid var(--red); border-radius: 7px; padding: 12px 16px; font-weight: 850; }
.confirm-button:hover { filter: brightness(1.07); }
.confirm-button:disabled, .not-found:disabled { opacity: .5; cursor: wait; }
.confirm-form .filename-preview, .confirm-form .confirm-button { grid-column: 1 / -1; }
.not-found { margin-top: 12px; padding: 0; border: 0; background: none; color: #d49794; font-size: 11px; text-decoration: underline; text-underline-offset: 3px; }

.processing-list { display: grid; gap: 8px; }
.processing-item { display: grid; grid-template-columns: auto minmax(130px,auto) minmax(150px,1fr) minmax(110px,1fr) auto; align-items: center; gap: 10px; padding: 13px 15px; border: 1px solid var(--soft-line); background: var(--surface); border-radius: 10px; font-size: 12px; }
.processing-stage, .processing-item small { color: var(--muted); }
.processing-error { border-color: rgba(239,133,128,.4); }
.processing-error > span:first-child { color: var(--red); font-weight: 900; }
.processing-error .reanalyze-button { margin: 0; white-space: nowrap; }
.processing-progress { height: 5px; overflow: hidden; border-radius: 99px; background: #1a2733; }
.processing-progress i { display: block; height: 100%; border-radius: inherit; background: var(--red); transition: width .25s ease; }
.spinner { width: 12px; height: 12px; border: 2px solid #405264; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { border: 1px dashed var(--line); color: var(--muted); border-radius: 14px; padding: 36px 20px; text-align: center; }

.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: 390px; padding: 12px 15px; color: white; background: #1b2835; border: 1px solid #405267; border-radius: 10px; box-shadow: 0 18px 45px rgba(0,0,0,.4); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: none; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); padding: 36px; border: 1px solid var(--line); border-left: 5px solid var(--red); border-radius: 12px; background: var(--surface); box-shadow: 0 30px 90px rgba(0,0,0,.45); }
.login-card .brand-mark { margin-bottom: 22px; }
.login-card h1 { margin: 4px 0 12px; font-size: 34px; font-weight: 850; line-height: 1.1; letter-spacing: -.035em; }
.login-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.5; }
.login-card form { display: grid; gap: 16px; margin-top: 24px; }
.login-card label { display: grid; gap: 7px; color: #cbd3d9; font-size: 13px; }
.login-card input { width: 100%; padding: 11px 12px; color: white; background: #0a1016; border: 1px solid var(--line); border-radius: 9px; }
.login-card button.primary { padding: 11px 16px; border: 1px solid var(--red); border-radius: 7px; background: var(--red); color: white; font-weight: 800; }
.form-error { min-height: 1em; color: var(--red); }

@media (max-width: 900px) {
  .intro { grid-template-columns: 1fr; gap: 25px; }
  .summary { grid-template-columns: repeat(2, 1fr); }
  .comparison-preview { height: clamp(260px, 48vw, 420px); }
  .new-photo-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .confirm-form { grid-template-columns: repeat(3, 1fr); }
  .confirm-form label.wide, .filename-preview, .confirm-button { grid-column: 1 / -1; }
  .processing-item { grid-template-columns: auto 1fr auto; }
  .processing-stage, .processing-progress { grid-column: 2 / -1; }
  .purchase-catalog { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media (max-width: 560px) {
  .topbar { padding: 0 16px; }
  #refreshButton { display: none; }
  .shell { width: min(94vw, 1180px); padding-top: 36px; }
  .intro h1 { font-size: 43px; }
  .ebay-import { align-items: center; flex-direction: row; }
  .ebay-button { width: auto; min-width: 0; }
  .ebay-compliance { grid-template-columns: 1fr; }
  .summary { margin-bottom: 48px; }
  .catalog-section { margin-top: -20px; padding: 16px; }
  .catalog-heading { align-items: stretch; flex-direction: column; }
  .catalog-count { text-align: left; }
  .purchase-catalog { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .match-card { padding: 17px; }
  .match-card > header { align-items: center; }
  .match-card h3 { font-size: 20px; }
  .comparison-toolbar { align-items: stretch; flex-direction: column; }
  .open-comparison { width: 100%; }
  .comparison { grid-template-columns: 1fr; }
  .comparison-preview { height: min(62vh, 430px); }
  .new-photo-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .comparison h4 small { display: block; margin: 4px 0 0; }
  .comparison-modal { padding: 0; }
  .comparison-dialog { height: 100vh; border: 0; border-radius: 0; padding: 12px; overflow-y: auto; grid-template-rows: auto auto auto; }
  .comparison-dialog-header h3 { font-size: 19px; }
  .fullscreen-comparison { grid-template-columns: 1fr; }
  .fullscreen-image-stage { height: min(48vh, 430px); }
  .comparison-switcher { grid-template-columns: 1fr 1fr; }
  .comparison-switcher span { display: none; }
  .confirm-form { grid-template-columns: 1fr 1fr; }
  .confirm-form label.wide, .confirm-form label:last-of-type, .filename-preview, .confirm-button { grid-column: 1 / -1; }
}
