:root {
  color-scheme: light;
  --ink: #101938;
  --violet: #4f46e5;
  --violet-light: #ebe9ff;
  --lime: #c9ff63;
  --orange: #ff7849;
  --paper: #ffffff;
  --canvas: #eef1fb;
  --line: #d7dbea;
  --muted: #727b98;
  font-family: "SF Pro Display", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; overflow-x: hidden; background: var(--canvas); color: var(--ink); }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(79, 70, 229, .24); outline-offset: 2px; }
::selection { background: var(--lime); color: var(--ink); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 228px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 16px; background: var(--ink); color: white; border-right: 2px solid var(--ink); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; color: inherit; text-decoration: none; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 16px; background: var(--lime); color: var(--ink); font-size: 23px; transform: rotate(-4deg); box-shadow: 4px 4px 0 #6d63ff; }
.brand strong { display: block; font-size: 18px; font-weight: 950; letter-spacing: -.02em; }
.brand small { display: block; margin-top: 2px; color: #aeb6d6; font-size: 10px; font-weight: 800; letter-spacing: .2em; }
.main-nav { display: grid; gap: 6px; margin-top: 38px; }
.main-nav a { display: flex; align-items: center; gap: 11px; border-radius: 13px; padding: 12px; color: #aeb6d6; text-decoration: none; font-size: 14px; transition: .18s ease; }
.main-nav a:hover { background: rgba(255,255,255,.08); color: white; }
.main-nav a.active { background: white; color: var(--ink); font-weight: 850; box-shadow: 4px 4px 0 #6d63ff; }
.main-nav a span { font-size: 18px; }
.main-nav a b { margin-left: auto; border-radius: 999px; padding: 2px 7px; background: var(--orange); color: white; font-size: 11px; }
.account-panel { margin-top: auto; border: 1px solid rgba(255,255,255,.15); border-radius: 17px; padding: 12px; background: rgba(255,255,255,.07); }
.account-panel p { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; color: #d8ddf1; font-size: 12px; }
.account-panel p i { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); }
.account-panel p.connected i { background: var(--lime); }

.main-area { min-width: 0; background-image: linear-gradient(rgba(79,70,229,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(79,70,229,.035) 1px, transparent 1px); background-size: 28px 28px; }
.topbar { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 28px; border-bottom: 2px solid var(--ink); background: rgba(255,255,255,.78); backdrop-filter: blur(12px); }
.topbar p, .section-heading p, .results-header p { margin: 0; color: #6d63ff; font-size: 11px; font-weight: 900; letter-spacing: .12em; }
.topbar h1 { margin: 4px 0 0; font-size: clamp(24px, 3vw, 31px); line-height: 1; letter-spacing: -.04em; }
.topbar-tools { display: flex; align-items: center; gap: 9px; }
.rate-pill { border: 1px solid #c9cee2; border-radius: 999px; padding: 9px 12px; background: white; font-size: 12px; font-weight: 750; }
.rate-pill strong { color: var(--violet); }
.icon-button, .mobile-brand { width: 40px; height: 40px; border: 1.5px solid var(--ink); border-radius: 13px; background: white; color: var(--ink); font-size: 17px; }
.mobile-brand { display: none; }

.workspace { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 20px; align-items: start; padding: 28px; }
.filter-card { position: sticky; top: 20px; max-height: calc(100vh - 132px); max-height: calc(100dvh - 132px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #b2b7cc transparent; border: 2px solid var(--ink); border-radius: 27px; padding: 20px; background: white; box-shadow: 6px 6px 0 var(--ink); }
.filter-card::-webkit-scrollbar { width: 7px; }
.filter-card::-webkit-scrollbar-thumb { border-radius: 999px; background: #b2b7cc; }
.sticker { position: absolute; right: 18px; top: -13px; transform: rotate(5deg); border: 2px solid var(--ink); border-radius: 999px; padding: 3px 9px; background: var(--orange); color: white; font-size: 10px; font-weight: 950; letter-spacing: .08em; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.section-heading h2, .results-header h2 { margin: 4px 0 0; font-size: 22px; letter-spacing: -.03em; }
.heading-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: var(--violet-light); color: var(--violet); font-size: 20px; }
#collectForm { display: grid; gap: 14px; }
.field { display: grid; gap: 8px; min-width: 0; }
.field > span:first-child { color: #4b5574; font-size: 12px; font-weight: 850; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
input, select { width: 100%; height: 42px; border: 1px solid #cbd1e3; border-radius: 12px; padding: 0 11px; background: white; color: var(--ink); font-size: 14px; }
input::placeholder { color: #9aa1b5; }
.source-box { min-height: 44px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 12px; padding: 7px 9px; background: #f7f8fd; }
.source-box i { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 9px; background: #ffede7; color: var(--orange); font-size: 12px; font-style: normal; font-weight: 900; }
.source-box b { font-size: 14px; }
.source-box em { margin-left: auto; border-radius: 999px; padding: 4px 7px; background: #dfffb0; color: #31520c; font-size: 10px; font-style: normal; font-weight: 900; }
.search-input { position: relative; }
.search-input i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #77809d; font-size: 20px; font-style: normal; }
.search-input input { padding-left: 37px; }
.price-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.price-row b { color: #8b92a9; }
.word-box { min-height: 45px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 7px; background: #f8f9fd; }
.word-box button { border: 0; border-radius: 8px; padding: 6px 9px; background: #ffe2d9; color: #a53e20; font-size: 12px; font-weight: 800; }
.word-box input { width: 80px; height: 28px; border: 0; padding: 0 3px; background: transparent; color: var(--violet); font-size: 12px; font-weight: 800; outline: 0; }
.option-box { display: grid; gap: 11px; border-radius: 17px; padding: 14px; background: var(--ink); color: white; }
.option-box label { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 800; cursor: pointer; }
.option-box input, .select-check input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.option-box label > span, .select-check span { width: 17px; height: 17px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.5); border-radius: 5px; color: transparent; font-size: 11px; }
.option-box input:checked + span { border-color: var(--lime); background: var(--lime); color: var(--ink); }
.option-box label b { color: var(--lime); font-size: 13px; }

.button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1.5px solid transparent; border-radius: 12px; padding: 0 13px; font-size: 13px; font-weight: 900; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--violet); color: white; }
.button.lime { background: var(--lime); color: var(--ink); }
.button.ink { background: var(--ink); color: white; }
.button.outline { border-color: var(--ink); background: white; color: var(--ink); }
.button.full { width: 100%; }
.collect-button { position: sticky; z-index: 3; bottom: 0; height: 49px; border-radius: 16px; box-shadow: 4px 4px 0 var(--lime), 0 -10px 18px rgba(255,255,255,.94); font-size: 15px; }
.collect-button:disabled, .button:disabled { cursor: wait; opacity: .62; transform: none; }

.results-column { min-width: 0; display: grid; gap: 16px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.stat { min-height: 108px; display: grid; grid-template-columns: 1fr auto; align-items: end; border: 2px solid var(--ink); border-radius: 22px; padding: 16px; box-shadow: 4px 4px 0 var(--ink); }
.stat.violet { background: var(--violet); color: white; }
.stat.lime { background: var(--lime); }
.stat.orange { background: var(--orange); color: white; }
.stat p { grid-column: 1 / -1; align-self: start; margin: 0; font-size: 12px; font-weight: 850; }
.stat strong { font-size: 36px; line-height: 1; font-weight: 950; }
.stat span { padding-bottom: 2px; font-size: 11px; font-weight: 800; }
.run-status { min-height: 58px; display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center; border: 1.5px solid #cbd1e3; border-radius: 17px; padding: 9px 11px 9px 15px; background: white; }
.run-dot { width: 10px; height: 10px; border-radius: 50%; background: #9aa3bb; box-shadow: 0 0 0 5px #edf0f7; }
.run-status[data-tone="running"] .run-dot { background: var(--violet); box-shadow: 0 0 0 5px var(--violet-light); animation: pulse 1.2s ease-in-out infinite; }
.run-status[data-tone="success"] .run-dot { background: #6ba91d; box-shadow: 0 0 0 5px #e6ffc0; }
.run-status[data-tone="warning"] .run-dot { background: #e99019; box-shadow: 0 0 0 5px #fff0ce; }
.run-status[data-tone="error"] .run-dot { background: #d44444; box-shadow: 0 0 0 5px #ffe0e0; }
.run-status strong, .run-status p { margin: 0; }
.run-status strong { font-size: 12px; }
.run-status p { margin-top: 2px; color: #606986; font-size: 12px; }
.run-status time { color: #7e879f; font-size: 11px; font-variant-numeric: tabular-nums; }
.run-status .button b { min-width: 20px; border-radius: 999px; padding: 2px 6px; background: var(--ink); color: white; font-size: 10px; }
@keyframes pulse { 50% { transform: scale(.7); opacity: .55; } }
.results-card { overflow: hidden; border: 2px solid var(--ink); border-radius: 27px; background: white; }
.results-header { min-height: 79px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 2px solid var(--ink); padding: 15px 20px; }
.results-header > div:last-child { display: flex; flex-wrap: wrap; gap: 8px; }
.results-header .button > span { min-width: 21px; border-radius: 999px; padding: 2px 6px; background: rgba(255,255,255,.2); font-size: 10px; }
.capacity-pill { min-height: 38px; display: inline-flex; align-items: center; border-radius: 12px; padding: 0 11px; background: var(--violet-light); color: var(--violet); font-size: 11px; font-weight: 900; white-space: nowrap; }
.capacity-pill.near-limit { background: #fff0ce; color: #9a5b00; }
.history-pill { min-height: 38px; display: inline-flex; align-items: center; border: 1px solid #bcd982; border-radius: 12px; padding: 0 11px; background: #efffd1; color: #3a5f13; font-size: 11px; font-weight: 900; white-space: nowrap; }
.button.active-filter { border-color: var(--violet); background: var(--violet-light); color: var(--violet); }
.button.danger-button { border-color: #ef9b8b; color: #ad3c29; }
.product-list { display: block; }
.product-row { min-width: 0; display: grid; grid-template-columns: 24px 64px minmax(180px, 1fr) 130px 78px; gap: 13px; align-items: center; border-bottom: 1px solid #dfe3ef; padding: 14px 16px; transition: .18s ease; }
.product-row:hover { background: #f7f8fd; }
.product-row.filtered-out { display: none; }
.select-check { cursor: pointer; }
.select-check span { border-color: #aeb5ca; color: transparent; }
.select-check input:checked + span { border-color: var(--violet); background: var(--violet); color: white; }
.product-row > img { width: 64px; height: 64px; border: 1px solid var(--line); border-radius: 16px; background: #eef1f7; object-fit: cover; }
.product-copy { min-width: 0; }
.product-copy p { display: flex; align-items: center; gap: 7px; margin: 0 0 6px; }
.product-copy em { border: 1px solid #c9cee2; border-radius: 999px; padding: 3px 6px; background: white; color: #616b88; font-size: 9px; font-style: normal; font-weight: 900; }
.product-copy small { overflow: hidden; color: #8b93aa; text-overflow: ellipsis; white-space: nowrap; }
.detail-status { margin-left: auto; border-radius: 999px; padding: 3px 6px; background: #fff0eb; color: #b54b2b; font-size: 9px; white-space: nowrap; }
.detail-loaded .detail-status { background: #e5ffbd; color: #31520c; }
.detail-failed { background: #fff9f7; }
.detail-failed .detail-status { background: #ffe1dc; color: #ae321f; }
.detail-failed .product-copy h4 { color: #ae321f; }
.detail-loading .detail-status { background: #eeeaff; color: var(--violet); animation: pulse 1.2s ease-in-out infinite; }
.product-copy h3, .product-copy h4 { overflow: hidden; margin: 0; text-overflow: ellipsis; white-space: nowrap; }
.product-copy h3 { font-size: 14px; font-weight: 900; }
.product-copy h4 { margin-top: 4px; color: var(--muted); font-size: 12px; font-weight: 500; }
.product-copy a { display: block; margin-top: 8px; color: var(--violet); font-size: 11px; font-weight: 850; }
.seller-copy { min-width: 0; font-size: 11px; }
.seller-copy strong, .seller-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seller-copy span { margin-top: 6px; color: #7a829d; }
.price-copy { text-align: right; }
.price-copy strong { display: block; font-size: 19px; font-weight: 950; }
.price-copy button { margin-top: 7px; border: 0; padding: 0; background: transparent; color: var(--violet); font-size: 10px; font-weight: 850; }
.results-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 20px; background: #f8f9fd; color: #4f5772; font-size: 12px; font-weight: 800; }
.results-footer p { margin: 0; }
.results-footer button { border: 0; background: transparent; color: var(--violet); font-weight: 900; }
.empty-state { padding: 56px 20px; text-align: center; }
.empty-state span { font-size: 36px; color: var(--violet); }
.empty-state h3 { margin: 10px 0 5px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; }
.format-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.format-cards article { display: flex; align-items: center; gap: 13px; border: 1px solid #cbd1e3; border-radius: 18px; padding: 14px; background: white; }
.format-cards article > span { width: 52px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--violet-light); color: var(--violet); font-size: 11px; font-weight: 950; }
.format-cards h3, .format-cards p { margin: 0; }
.format-cards h3 { font-size: 14px; }
.format-cards p { margin-top: 4px; color: var(--muted); font-size: 11px; }
.compliance-note { margin: 0 4px; color: #747d98; font-size: 11px; line-height: 1.55; }

.modal { width: min(440px, calc(100% - 28px)); border: 0; border-radius: 24px; padding: 0; background: transparent; color: var(--ink); }
.modal::backdrop { background: rgba(16,25,56,.55); backdrop-filter: blur(5px); }
.modal-card { position: relative; display: grid; gap: 15px; border: 2px solid var(--ink); border-radius: 24px; padding: 24px; background: #f8f9ff; box-shadow: 8px 8px 0 var(--lime); }
.modal-card h2, .modal-card p { margin: 0; }
.modal-card h2 { font-size: 24px; letter-spacing: -.03em; }
.modal-card > p { color: var(--muted); font-size: 13px; line-height: 1.55; }
.modal-card label { display: grid; gap: 7px; color: #263050; font-size: 13px; font-weight: 850; }
.modal-card label input { height: 45px; }
.modal-card > small { text-align: center; color: #69728d; }
.modal-close { position: absolute; right: 13px; top: 13px; width: 31px; height: 31px; border: 0; border-radius: 10px; background: #e8ebf5; color: var(--ink); font-size: 20px; }
.modal-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 15px; background: var(--violet); color: white; font-size: 22px; box-shadow: 4px 4px 0 var(--lime); }
.orange-mark { background: var(--orange); }
.export-choice { min-height: 70px; display: grid; grid-template-columns: 58px 1fr auto; gap: 12px; align-items: center; border: 1.5px solid #cbd1e3; border-radius: 16px; padding: 10px; background: white; color: var(--ink); text-align: left; }
.export-choice:hover { border-color: var(--violet); background: #f5f4ff; }
.export-choice > b { height: 45px; display: grid; place-items: center; border-radius: 11px; background: var(--violet-light); color: var(--violet); font-size: 11px; }
.export-choice strong, .export-choice small { display: block; }
.export-choice small { margin-top: 4px; color: var(--muted); }
.export-choice i { font-style: normal; color: var(--violet); }
.detail-modal { width: min(620px, calc(100% - 28px)); }
.detail-modal .modal-card { max-height: min(760px, calc(100vh - 42px)); overflow: auto; }
.detail-image { width: 100%; height: min(300px, 38vh); border: 1.5px solid var(--ink); border-radius: 18px; background: #eef1f7; object-fit: contain; }
.detail-kicker { color: var(--violet) !important; font-size: 11px !important; font-weight: 900; letter-spacing: .08em; }
.detail-modal h4 { margin: -8px 0 0; color: var(--muted); font-weight: 500; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.detail-meta > * { border-radius: 999px; padding: 6px 9px; background: #eceefa; font-size: 11px; }
.detail-meta b { background: var(--lime); font-size: 13px; }
.detail-description { max-height: 220px; overflow: auto; border-radius: 14px; padding: 13px; background: white; color: #48516d !important; line-height: 1.65 !important; }
.detail-links { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.detail-links a { text-decoration: none; }
.detail-close { position: fixed; top: calc(50% - min(380px, calc(50vh - 21px)) + 12px); left: calc(50% + min(310px, calc(50vw - 14px)) - 46px); z-index: 2; width: 32px; height: 32px; border: 0; border-radius: 10px; background: #e8ebf5; font-size: 20px; }
.log-modal { width: min(760px, calc(100% - 28px)); }
.log-modal .modal-card { max-height: min(760px, calc(100vh - 42px)); }
.log-heading { display: flex; align-items: center; gap: 14px; padding-right: 34px; }
.log-heading p, .log-heading h2, .log-heading small { margin: 0; }
.log-heading p { color: var(--violet); font-size: 10px; font-weight: 900; letter-spacing: .14em; }
.log-heading small { color: var(--muted); }
.log-list { min-height: 260px; max-height: 430px; overflow: auto; display: grid; align-content: start; gap: 7px; border: 1.5px solid var(--ink); border-radius: 15px; padding: 10px; background: var(--ink); color: #dce2ff; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.log-empty { margin: auto; color: #8993b4; font-size: 12px; }
.log-entry { display: grid; grid-template-columns: 72px 54px 1fr; gap: 8px; align-items: start; border-bottom: 1px solid rgba(255,255,255,.08); padding: 5px 3px 9px; font-size: 11px; line-height: 1.45; }
.log-entry time { color: #8590b4; }
.log-entry b { color: var(--lime); font-size: 10px; }
.log-entry[data-level="warn"] b { color: #ffc760; }
.log-entry[data-level="error"] b { color: #ff8f80; }
.log-entry p { margin: 0; color: #f1f3ff; }
.log-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.toast { position: fixed; z-index: 100; right: 22px; bottom: 22px; max-width: min(380px, calc(100% - 44px)); transform: translateY(24px); border: 2px solid var(--ink); border-radius: 14px; padding: 12px 15px; background: var(--ink); color: white; box-shadow: 4px 4px 0 var(--lime); font-size: 13px; font-weight: 800; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-brand { display: block; }
  .workspace { grid-template-columns: 300px minmax(0, 1fr); padding: 20px; }
  .product-row { grid-template-columns: 22px 58px minmax(170px, 1fr) 84px; }
  .seller-copy { display: none; }
  .product-row > img { width: 58px; height: 58px; }
}

@media (max-width: 820px) {
  .topbar { position: sticky; top: 0; z-index: 20; }
  .rate-pill { display: none; }
  .workspace { grid-template-columns: 1fr; padding: 16px; }
  .filter-card { position: static; max-height: none; overflow: visible; scroll-margin-top: 84px; }
  .collect-button { position: static; box-shadow: 4px 4px 0 var(--lime); }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat { min-height: 92px; padding: 12px; }
  .stat strong { font-size: 29px; }
  .stat span { font-size: 9px; }
  .product-row { grid-template-columns: 22px 58px minmax(0, 1fr); }
  .price-copy { grid-column: 3; display: flex; align-items: center; justify-content: space-between; text-align: left; }
  .format-cards { grid-template-columns: 1fr; }
  .run-status { grid-template-columns: auto 1fr auto; }
  .run-status time { display: none; }
}

@media (max-width: 520px) {
  .topbar { padding: 13px 14px; }
  .topbar h1 { font-size: 22px; }
  .topbar p { display: none; }
  .workspace { padding: 12px; }
  .filter-card { padding: 17px; box-shadow: 4px 4px 0 var(--ink); }
  .field-grid { grid-template-columns: 1fr; }
  .results-header { align-items: flex-start; padding: 15px; }
  .results-header > div:last-child { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .results-header .button { width: 100%; min-width: 0; padding-inline: 8px; }
  .capacity-pill { grid-column: 1 / -1; justify-content: center; }
  .history-pill { grid-column: 1 / -1; justify-content: center; }
  .product-row { grid-template-columns: 21px 52px minmax(0, 1fr); padding: 12px; gap: 10px; }
  .product-row > img { width: 52px; height: 52px; border-radius: 13px; }
  .product-copy h3 { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .product-copy h4 { display: none; }
  .price-copy { grid-column: 3; }
  .results-footer { align-items: flex-start; flex-direction: column; padding: 12px 15px; }
  .results-footer button { min-height: 34px; }
  .detail-links { grid-template-columns: 1fr; }
  .run-status { grid-template-columns: auto 1fr; }
  .run-status .button { grid-column: 1 / -1; }
  .log-entry { grid-template-columns: 58px 44px 1fr; gap: 5px; }
}
