:root {
  --bg: #f5f7fb; --surface: #fff; --ink: #172b4d; --muted: #5e6e85; --line: #e1e7ef;
  --primary: #1e40af; --primary-soft: #edf2ff; --green: #14704a; --green-soft: #ebf7f0;
  --amber: #945500; --amber-soft: #fff5df; --red: #b42335; --red-soft: #fff0f1;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink); font-size: 14px; line-height: 1.6; font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
button, input, select { font: inherit; }
button, select, a, input[type="checkbox"] { cursor: pointer; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button, input, select, a { transition: background-color .15s, border-color .15s, color .15s; }
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 3px solid #8aa9f9; outline-offset: 3px; }
[hidden] { display: none !important; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
a { color: var(--primary); text-decoration: none; }
.skip-link { position: absolute; top: -70px; left: 16px; padding: 12px; background: white; z-index: 30; }
.skip-link:focus { top: 8px; }
.topbar { height: 72px; padding: 0 40px; display: flex; justify-content: space-between; align-items: center; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; font-size: 16px; font-weight: 650; color: var(--ink); }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--primary); color: white; font-size: 22px; font-weight: 750; }
.brand-divider { margin: 0 9px; color: #b8c4d6; font-weight: 400; }
.connection { color: var(--muted); display: inline-flex; align-items: center; gap: 8px; font-size: 12px; }
.connection::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; }
.connection.connected::before { background: var(--green); }
.connection.disconnected::before { background: var(--red); }
main { max-width: 1680px; margin: 0 auto; padding: 36px 40px 24px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .14em; color: var(--primary); }
h1 { margin: 5px 0 6px; font-size: 28px; line-height: 1.4; letter-spacing: -.025em; }
.page-heading p, .results-heading p { margin: 0; color: var(--muted); }
.button { min-height: 42px; border-radius: 7px; padding: 9px 16px; border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap; font-weight: 550; }
.button.primary { background: var(--primary); color: white; }
.button.primary:hover { background: #193790; }
.button.secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }
.button.secondary:hover:not(:disabled) { border-color: #aebdd1; background: #f8faff; }
.search-panel, .results-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 3px 12px #172b4d03; }
.search-panel { margin-bottom: 24px; }
.view-switch { display: flex; gap: 28px; padding: 0 24px; border-bottom: 1px solid var(--line); }
.view-switch button, .detail-switch button { border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); padding: 17px 1px 14px; font-weight: 600; }
.view-switch button[aria-pressed="true"], .detail-switch button[aria-pressed="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.view-switch button:hover, .detail-switch button:hover { color: var(--primary); }
.filters { display: grid; grid-template-columns: minmax(150px, 1.2fr) minmax(115px, .75fr) minmax(150px, .95fr) minmax(220px, 1.8fr) auto auto; align-items: end; gap: 16px; padding: 24px; }
.filters label { display: flex; flex-direction: column; gap: 7px; font-size: 12px; color: var(--muted); font-weight: 550; min-width: 0; }
input:not([type="checkbox"]), select { min-height: 42px; width: 100%; border: 1px solid #ced7e4; border-radius: 7px; background: var(--surface); color: var(--ink); padding: 8px 11px; min-width: 0; }
input::placeholder { color: #7a8799; font-weight: 400; }
input:hover, select:hover { border-color: #9aaec9; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }
.reset-button { min-height: 42px; border: 0; padding: 8px 4px; color: var(--muted); background: none; }
.reset-button:hover { color: var(--primary); }
.snapshot-bar { display: flex; align-items: center; gap: 12px; padding: 13px 24px; background: #fafbfe; border-top: 1px solid var(--line); border-radius: 0 0 12px 12px; color: var(--muted); font-size: 12px; }
.snapshot-bar select { max-width: 430px; min-height: 36px; padding: 5px 10px; font-size: 12px; }
.snapshot-bar label { flex-shrink: 0; }
.snapshot-status { margin-left: auto; }
.sku-mode .filters { grid-template-columns: minmax(180px, 600px) auto auto; justify-content: start; }
.results-heading { display: flex; justify-content: space-between; align-items: center; padding: 22px 24px; gap: 16px; }
h2 { font-size: 16px; font-weight: 650; margin: 0 0 4px; }
.count { display: inline-block; font-size: 12px; font-weight: 600; color: var(--primary); background: var(--primary-soft); border: 1px solid #dbe5ff; padding: 0 7px; border-radius: 5px; margin-left: 7px; vertical-align: 1px; font-variant-numeric: tabular-nums; }
.results-heading p, .column-toggle { font-size: 12px; color: var(--muted); }
.column-toggle { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; min-height: 44px; }
.table-scroll { width: 100%; max-height: 650px; overflow: auto; border-top: 1px solid var(--line); }
table { border-collapse: separate; border-spacing: 0; width: 100%; text-align: left; font-size: 12px; }
th { position: sticky; top: 0; z-index: 3; background: #f7f9fc; font-weight: 550; color: var(--muted); white-space: nowrap; padding: 13px 16px; border-bottom: 1px solid var(--line); }
td { border-bottom: 1px solid #edf0f5; padding: 14px 16px; vertical-align: middle; background: var(--surface); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f8faff; }
.numeric { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rank { width: 46px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rank-number { display: inline-flex; min-width: 24px; height: 24px; align-items: center; justify-content: center; border-radius: 5px; }
.top-rank { color: var(--primary); font-weight: 700; background: var(--primary-soft); }
.product-column { position: sticky; left: 0; min-width: 280px; width: 310px; z-index: 2; box-shadow: 5px 0 8px -8px #47556970; }
th.product-column { z-index: 4; }
.product-cell { display: flex; align-items: center; gap: 12px; }
.thumbnail { display: grid; place-items: center; width: 44px; height: 48px; flex-shrink: 0; background: #f0f3f9; border: 1px solid var(--line); border-radius: 6px; color: #92a1b8; overflow: hidden; }
.thumbnail img { width: 100%; height: 100%; object-fit: contain; background: white; }
.product-info { min-width: 0; }
.product-title { border: 0; padding: 0; background: none; text-align: left; color: var(--ink); font-size: 12px; font-weight: 600; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 290px; }
.product-title:hover { color: var(--primary); }
.product-subtitle { margin-top: 5px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.sku-text { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.small-muted { font-size: 11px; color: var(--muted); margin-top: 3px; }
.nowrap { white-space: nowrap; }
.badge { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; font-size: 11px; font-weight: 500; padding: 3px 7px; border-radius: 5px; color: var(--muted); background: #f0f3f7; }
.badge.success { color: var(--green); background: var(--green-soft); }
.badge.warning { color: var(--amber); background: var(--amber-soft); }
.badge.error { color: var(--red); background: var(--red-soft); }
.row-action { border: 0; background: none; color: var(--primary); padding: 10px 3px; min-height: 40px; white-space: nowrap; font-size: 12px; }
.row-action:hover { text-decoration: underline; }
.raw-cell { min-width: 145px; max-width: 300px; white-space: pre-wrap; overflow-wrap: anywhere; }
.empty-state { padding: 64px 24px; text-align: center; color: var(--muted); }
.empty-symbol { width: 52px; height: 52px; border-radius: 13px; display: grid; place-items: center; background: #f0f4fc; color: #6e8bc5; margin: 0 auto 16px; }
.empty-symbol svg { width: 28px; height: 28px; }
.empty-state h3 { font-size: 15px; color: var(--ink); margin: 0 0 6px; }
.empty-state p { margin: 0; font-size: 12px; }
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 24px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.pagination-controls { display: flex; align-items: center; gap: 8px; }
.pagination-controls label { display: flex; align-items: center; gap: 8px; margin-right: 8px; white-space: nowrap; }
.pagination-controls select { width: 90px; min-height: 36px; font-size: 12px; }
.pagination .button { min-height: 36px; padding: 6px 12px; font-size: 12px; }
.notice { padding: 13px 16px; margin: 0 0 20px; border-radius: 7px; white-space: pre-wrap; font-size: 13px; }
.notice.error { background: var(--red-soft); color: var(--red); border: 1px solid #f4c9cf; }
.notice.warning { background: var(--amber-soft); color: var(--amber); }
footer { color: var(--muted); font-size: 11px; padding: 18px 0; }
dialog { position: fixed; inset: 0 0 0 auto; margin: 0; padding: 0; border: 0; border-left: 1px solid var(--line); width: min(800px, 100%); max-width: 100%; height: 100dvh; max-height: 100dvh; background: var(--surface); color: var(--ink); box-shadow: -12px 0 50px #172b4d20; overflow: auto; }
dialog::backdrop { background: #0f1e3d55; }
body:has(dialog[open]) { overflow: hidden; }
.drawer-header { padding: 28px 28px 12px; display: flex; gap: 16px; justify-content: space-between; align-items: start; }
.drawer-header h2 { font-size: 19px; line-height: 1.6; margin-top: 7px; overflow-wrap: anywhere; }
.drawer-header p { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 7px; background: white; color: var(--muted); display: grid; place-items: center; flex-shrink: 0; }
.icon-button:hover { background: var(--bg); color: var(--ink); }
.drawer-actions { padding: 0 28px 20px; display: flex; gap: 8px; flex-wrap: wrap; }
.drawer-actions .button { font-size: 12px; min-height: 38px; }
.detail-switch { display: flex; gap: 24px; padding: 0 28px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 5; }
.detail-switch button { font-size: 13px; }
.drawer-content { padding: 24px 28px 40px; }
.detail-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
.detail-stat { border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.detail-stat span { display: block; font-size: 12px; color: var(--muted); }
.detail-stat strong { display: block; font-size: 20px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.detail-section { margin-top: 24px; }
.detail-section h3 { font-size: 14px; margin: 0 0 12px; }
.detail-section p { color: #42536b; overflow-wrap: anywhere; white-space: pre-wrap; }
.detail-section table { table-layout: fixed; }
.detail-section td { white-space: pre-wrap; overflow-wrap: anywhere; vertical-align: top; }
.detail-section td:first-child { width: 34%; color: var(--muted); background: #f8faff; }
.detail-section td:nth-child(2) { width: 66%; }
#detail-raw table { table-layout: fixed; }
#detail-raw td { white-space: pre-wrap; overflow-wrap: anywhere; vertical-align: top; }
#detail-raw td:first-child { width: 34%; color: var(--muted); background: #f8faff; }
pre { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; line-height: 1.9; white-space: pre-wrap; overflow-wrap: anywhere; background: #f7f9fc; border: 1px solid var(--line); border-radius: 8px; padding: 18px; margin: 0; }
.gallery { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.gallery a { border: 1px solid var(--line); border-radius: 7px; overflow: hidden; aspect-ratio: 1; display: block; }
.gallery img { width: 100%; height: 100%; object-fit: contain; }
.comment { border-top: 1px solid var(--line); padding: 12px 0; }
.comment p { margin: 6px 0; font-size: 13px; }
.sync-panel { padding: 22px 24px; margin-bottom: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.sync-panel p { margin: 4px 0 12px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.sync-heading, .sync-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sync-actions { flex-shrink: 0; }
.sync-panel .sync-message { margin: 12px 0 0; }
.sync-table { overflow: auto; max-height: 300px; margin-top: 16px; border: 1px solid var(--line); border-radius: 7px; }
.sync-table th, .sync-table td { white-space: nowrap; }
.sync-panel .error-text, .error-text { color: var(--red); }
.auth-form { display: flex; align-items: end; gap: 12px; max-width: 640px; }
.auth-form label { flex: 1; font-size: 12px; }
.auth-form input { display: block; margin-top: 5px; }
.command-dialog { inset: 0; margin: auto; width: min(760px, calc(100% - 32px)); height: auto; max-height: 90dvh; border: 1px solid var(--line); border-radius: 12px; }
.command-dialog .drawer-header { align-items: center; }
.command-dialog .drawer-content { padding-top: 0; }
.command-dialog p { color: var(--muted); }
.command-dialog label { display: block; margin-bottom: 6px; font-size: 12px; }
textarea { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 7px; resize: vertical; background: var(--bg); color: var(--ink); font: 12px/1.8 ui-monospace, SFMono-Regular, Consolas, monospace; margin-bottom: 16px; }
@media (min-width: 1600px) { main { padding-top: 40px; } }
@media (max-width: 1150px) { .filters { grid-template-columns: 1.4fr 1fr 1.2fr; } .keyword-field { grid-column: 1; } .filters .primary { align-self: end; } .filters .reset-button { justify-self: start; } }
@media (max-width: 760px) {
  .sync-panel { padding: 20px; } .sync-heading { align-items: start; flex-direction: column; } .sync-actions { flex-wrap: wrap; } .auth-form { flex-direction: column; align-items: stretch; }
  :root { font-size: 16px; } .topbar { padding: 0 20px; height: 64px; } .brand { font-size: 14px; } .brand-divider { margin: 0 4px; }
  main { padding: 24px 16px 12px; } .page-heading { gap: 12px; margin-bottom: 20px; } h1 { font-size: 24px; } .page-heading p { font-size: 12px; }
  .page-heading > .button { padding: 9px 12px; font-size: 12px; } .connection { font-size: 11px; }
  .filters { grid-template-columns: 1fr 1fr; gap: 14px; padding: 20px; } .keyword-field { grid-column: 1 / -1; }
  .filters input, .filters select { font-size: 16px; } .filters > .primary { grid-column: 1; } .filters .reset-button { justify-self: center; }
  .filters .list-filter:first-child { grid-column: 1 / -1; } .snapshot-bar { padding: 12px 20px; gap: 8px; flex-wrap: wrap; }
  .snapshot-bar select { flex: 1; min-width: 0; } .snapshot-status { width: 100%; margin: 0; }
  .view-switch { padding: 0 20px; } .results-heading { padding: 18px 20px; flex-wrap: wrap; gap: 8px; } .results-heading p { font-size: 11px; }
  .product-column { min-width: 220px; max-width: 250px; } .product-title { max-width: 190px; } .thumbnail { display: none; }
  .pagination { flex-wrap: wrap; padding: 16px; gap: 12px; } .pagination-controls { width: 100%; justify-content: space-between; }
  .pagination-controls label { margin-right: auto; } .pagination-controls select { width: 78px; } .pagination .button { min-height: 42px; }
  .sku-mode .filters { grid-template-columns: 1fr 1fr; } .sku-mode .keyword-field { grid-column: 1 / -1; }
  .drawer-header { padding: 20px 20px 12px; } .drawer-actions { padding: 0 20px 16px; } .detail-switch { padding: 0 20px; gap: 18px; }
  .drawer-content { padding: 20px; } .detail-stat { padding: 10px; } .detail-stat strong { font-size: 17px; }
}
@media (max-width: 400px) { .connection { max-width: 85px; line-height: 1.4; } .page-heading { align-items: start; } .page-heading .button svg { display: none; } .detail-switch { gap: 13px; } .detail-switch button { font-size: 12px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }
