:root {
  color-scheme: light;
  --bg: #f3f5f9;
  --surface: #fff;
  --surface-soft: #f7f9fc;
  --text: #1b2434;
  --muted: #53637c;
  --border: #dbe3ef;
  --primary: #1753bd;
  --blue-ink: #14489f;
  --blue-soft: #eaf1fe;
  --hero-start: #0e2f77;
  --hero-end: #1753bd;
  --red: #9d222e;
  --red-soft: #fdeced;
  --amber: #7b420c;
  --amber-soft: #fff3d8;
  --green: #145f40;
  --green-soft: #e4f5eb;
  --radius: 14px;
  --shadow: 0 3px 10px rgb(23 53 103 / 6%), 0 16px 36px rgb(23 53 103 / 5%);
  --body: "Instrument Sans", "PingFang SC", "Microsoft YaHei UI", -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}
html.dark {
  color-scheme: dark;
  --bg: #0c111d;
  --surface: #151e2f;
  --surface-soft: #19253b;
  --text: #e7edf8;
  --muted: #a7b5cd;
  --border: #2d3b56;
  --primary: #1753bd;
  --blue-ink: #a8c9ff;
  --blue-soft: #243a61;
  --hero-start: #0a1e4e;
  --hero-end: #154496;
  --red: #ffb9bd;
  --red-soft: #48242e;
  --amber: #ffd286;
  --amber-soft: #403118;
  --green: #a8e4bf;
  --green-soft: #18382d;
  --shadow: 0 12px 30px rgb(0 0 0 / 21%);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 0; }
body { margin: 0; color: var(--text); background: var(--bg); font: 15px/1.55 var(--body); }
body.modal-open { overflow: hidden; }
button, input, select { font: inherit; }
button, .quiet-button { -webkit-tap-highlight-color: transparent; }
button, a, input, select { touch-action: manipulation; }
button, .quiet-button { cursor: pointer; }
button:disabled { opacity: .53; cursor: default; }
:focus-visible { outline: 3px solid #70a7ff; outline-offset: 3px; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { line-height: 1.28; overflow-wrap: anywhere; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
label { display: grid; gap: .35rem; font-weight: 650; color: var(--muted); }
input, select { min-width: 0; max-width: 100%; min-height: 44px; border: 1px solid var(--border); border-radius: 9px; padding: 8px 11px; color: var(--text); background: var(--surface); }
input { width: 100%; font-size: 16px; }
input[type=file] { padding: 7px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; clip: rect(0,0,0,0); overflow: hidden; white-space: nowrap; border: 0; }
.inner, .topbar-inner { width: min(100% - 36px, 1080px); margin-inline: auto; }
.topbar { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; min-height: 58px; gap: 12px; justify-content: space-between; }
.brand { display: flex; min-width: 0; align-items: center; gap: 9px; padding: 0; border: 0; text-align: left; line-height: 1.3; color: var(--text); background: transparent; font-weight: 750; overflow-wrap: anywhere; }
.brand-mark { display: grid; place-items: center; flex: none; min-width: 48px; height: 34px; padding: 0 5px; border-radius: 8px; background: linear-gradient(125deg,var(--hero-start),var(--hero-end)); color: #fff; box-shadow: 0 4px 12px rgb(23 83 189 / 23%); font: 750 12px var(--mono); letter-spacing: -.045em; }
.nav-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.topbar .nav-actions { flex-wrap: nowrap; flex: none; }
.primary, .quiet-button, .icon-button { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; min-height: 44px; padding: 8px 13px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 9px; font-weight: 650; text-decoration: none; white-space: nowrap; }
.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.primary:hover:not(:disabled) { background: #14459b; }
.quiet-button:hover, .icon-button:hover { color: var(--blue-ink); border-color: var(--blue-ink); }
.icon-button { min-width: 44px; padding: 0; font-size: 1.12rem; }
.wechat-tip { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-top: 10px; padding: 3px 5px 3px 13px; color: var(--blue-ink); background: var(--blue-soft); border-radius: 9px; font-size: .87rem; }
.wechat-tip .icon-button { border-color: transparent; min-height: 32px; background: transparent; }
.hero { margin: 17px 0 24px; padding: 31px 22px 34px; text-align: center; color: #fff; border-radius: 19px; background: radial-gradient(ellipse at 82% -58%, #4981e1 0, transparent 66%), linear-gradient(125deg,var(--hero-start),var(--hero-end)); box-shadow: var(--shadow); }
.hero h1 { font-size: clamp(1.7rem, 5vw, 2.5rem); letter-spacing: .04em; }
.hero p { margin-top: .55rem; color: #e1ebff; }
.search-form { display: flex; max-width: 610px; margin: 20px auto 0; padding: 5px; gap: 5px; border-radius: 13px; background: var(--surface); box-shadow: 0 4px 18px rgb(0 0 0 / 16%); }
.search-field { display: grid; position: relative; min-width: 0; flex: 1; }
.search-field svg { position: absolute; top: 50%; left: 11px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-form input { border: 0; padding-left: 36px; }
.search-form .primary { min-width: 74px; }
.workbench.is-results .hero { background: none; box-shadow: none; padding: 0; margin-bottom: 13px; }
.workbench.is-results .hero-copy { display: none; }
.workbench.is-results .search-form { margin: 0; max-width: none; box-shadow: var(--shadow); border: 1px solid var(--border); }
.browse, #results, .admin-main { padding-bottom: max(32px, env(safe-area-inset-bottom)); }
.section-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.section-head > span, .results-head p { color: var(--muted); font-size: .88rem; }
.browse h2 { margin: .75rem 0; }
.filterbar { display: flex; align-items: center; gap: 8px; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; }
.quick-scroll { display: flex; align-items: center; gap: 8px; min-width: 0; overflow-x: auto; padding: 4px; scrollbar-width: thin; }
.chip, .badge { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 5px 10px; border: 1px solid var(--border); border-radius: 40px; background: var(--surface-soft); color: var(--muted); font-weight: 660; font-size: .8rem; overflow-wrap: anywhere; }
.chip { min-height: 38px; flex: none; white-space: nowrap; }
.chip[aria-pressed=true] { border-color: var(--blue-ink); background: var(--blue-soft); color: var(--blue-ink); }
.badges { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 6px; }
.badge-attr, .badge-ins { color: var(--blue-ink); background: var(--blue-soft); }
.badge-risk-red { background: var(--red-soft); color: var(--red); }
.badge-risk-yellow { background: var(--amber-soft); color: var(--amber); }
.badge-risk-green, .badge-essential { background: var(--green-soft); color: var(--green); }
.results-head { margin: 12px 0; }
.product-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill,minmax(min(100%, 285px),1fr)); }
.product-card { display: grid; gap: 8px; align-content: start; min-width: 0; padding: 15px; text-align: left; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow-wrap: anywhere; }
.product-card:hover { border-color: var(--blue-ink); }
.product-name { font-size: 1.13rem; font-weight: 750; line-height: 1.36; }
.product-brand { font-weight: 625; color: var(--blue-ink); }
.product-meta { color: var(--muted); font-size: .87rem; }
.product-price { color: var(--blue-ink); font-weight: 700; font-size: .85rem; }
.browse-button, .pagination { display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 18px 0; }
.message, .empty { padding: 10px 12px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); overflow-wrap: anywhere; }
.message { margin: 10px 0; }
.message.error { color: var(--red); background: var(--red-soft); }
.message.success { color: var(--green); background: var(--green-soft); }
.empty { grid-column: 1 / -1; padding: 22px; }

.dialog { width: min(100% - 34px, 870px); max-height: calc(100% - 34px); padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 16px 60px rgb(5 22 55 / 36%); overflow: auto; }
.dialog::backdrop { background: rgb(8 17 38 / 58%); }
.dialog-head, .dialog-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 16px; }
.dialog-head { border-bottom: 1px solid var(--border); }
.dialog-foot { border-top: 1px solid var(--border); justify-content: flex-end; padding-bottom: max(13px, env(safe-area-inset-bottom)); }
.filter-dialog, .small-dialog { width: min(100% - 34px, 590px); }
.filter-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; padding: 14px 16px; }
.detail-dialog[open] { display: flex; flex-direction: column; overflow: hidden; }
.detail-head { flex: none; padding: 11px 17px 14px; background: linear-gradient(120deg,var(--hero-start),var(--hero-end)); color: white; }
.detail-tools, .detail-pager { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.detail-tools { margin-bottom: 8px; }
.detail-tools button { min-height: 44px; min-width: 44px; border: 1px solid rgb(255 255 255 / 30%); border-radius: 9px; background: rgb(255 255 255 / 12%); color: white; padding: 0 10px; }
.detail-tools button:hover:not(:disabled) { background: rgb(255 255 255 / 24%); }
#close-detail { font-size: 1.45rem; }
.d-head-top { min-width: 0; overflow-wrap: anywhere; }
.d-head-top h2 { font-size: clamp(1.25rem, 4.8vw, 1.8rem); overflow-wrap: anywhere; }
.d-head-top p { margin: 3px 0 7px; color: #e1ecff; }
.d-head-top .badges { margin-top: 9px; }
.detail-body { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 13px 17px max(25px, env(safe-area-inset-bottom)); }
.detail-metrics { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,143px),1fr)); gap: 8px; }
.metric { margin: 0; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-soft); min-width: 0; }
.metric dt, .data-key { font-weight: 680; color: var(--muted); font-size: .82rem; }
.metric dd { margin: 2px 0 0; font-weight: 650; }
.verbatim, .pipe-cell { white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-section { margin-top: 19px; }
.detail-section > h3 { margin-bottom: 8px; padding-left: 8px; border-left: 3px solid var(--blue-ink); color: var(--blue-ink); }
.fields { display: grid; gap: 8px; }
.field { padding: 9px 11px; border-radius: 9px; border: 1px solid var(--border); min-width: 0; }
.field .data-key { display: block; margin-bottom: 4px; }
.limit-panel { margin-top: 12px; padding: 11px 13px; border-radius: 9px; border-left: 3px solid var(--amber); color: var(--amber); background: var(--amber-soft); }
.competitors { grid-template-columns: repeat(auto-fit,minmax(min(100%, 265px),1fr)); }
.competitors .field { background: var(--surface-soft); }
.table-scroll { max-width: 100%; overflow-x: auto; touch-action: pan-x pan-y; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th, .data-table td { padding: 8px 10px; vertical-align: top; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--muted); font-size: .85rem; }
.pipe-table td, .pipe-table th { min-width: 95px; padding: 6px 9px; border: 1px solid var(--border); }
.pipe-table th { background: var(--blue-soft); color: var(--blue-ink); }

.login-page { min-height: 100vh; min-height: 100svh; display: grid; place-items: center; padding: 26px 20px; background: radial-gradient(ellipse at 100% 0%,var(--blue-soft),transparent 70%),var(--bg); }
.login-box { width: min(100%, 470px); overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: 19px; box-shadow: var(--shadow); }
.login-banner { padding: 25px; color: white; background: linear-gradient(140deg,var(--hero-start),var(--hero-end)); }
.login-banner .brand-mark { width: max-content; border: 1px solid #9bbcf8; background: transparent; }
.login-banner h1 { margin: 15px 0 7px; font-size: clamp(1.4rem, 5vw, 1.72rem); }
.login-banner p { color: #e1ebff; }
.login-form { padding: 23px 25px 27px; display: grid; gap: 14px; }
.login-form .message { margin: 0; }
.login-recovery { color: var(--muted); font-size: .85rem; text-align: center; }
.theme-toggle { position: fixed; top: 12px; right: 12px; }
.admin-main h1 { margin: 20px 0 12px; font-size: 1.75rem; }
.admin-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 9px; }
.admin-panel { display: grid; gap: 14px; padding: 17px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.admin-forms { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%, 255px),1fr)); gap: 12px; }
.admin-form { display: grid; align-content: start; gap: 10px; padding: 12px; min-width: 0; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); }
.admin-form .primary, .admin-form .quiet-button { width: max-content; }
.admin-form .dialog-head { padding: 0 0 8px; }
.admin-metrics { margin: 7px 0 13px; }
.admin-table { min-width: 570px; }
.admin-table td, .admin-table th { overflow-wrap: anywhere; }
.admin-table .quiet-button { min-height: 34px; padding: 4px 8px; font-size: .85rem; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.version-list { display: grid; gap: 8px; }
.version { display: flex; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; flex-wrap: wrap; justify-content: space-between; align-items: center; overflow-wrap: anywhere; }
.version small { color: var(--muted); }
.version-note { margin-top: 5px; color: var(--text); white-space: pre-wrap; }
.publish-note { display: grid; gap: 7px; margin-top: 11px; }
.publish-note textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); background: var(--surface); font: inherit; font-size: 16px; resize: vertical; }
.publish-note .primary { justify-self: start; }
.stat-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit,minmax(min(100%, 285px),1fr)); }
.stat-card { padding: 11px; border: 1px solid var(--border); border-radius: 9px; min-width: 0; }
.stat-card td:last-child { text-align: right; }
.stat-card td, .stat-card th { overflow-wrap: anywhere; }
.stat-card h3 { margin-bottom: 5px; }

@media (max-width: 899px) {
  .dialog { margin: auto 0 0; width: 100%; max-width: none; max-height: 90%; border-radius: 15px 15px 0 0; }
  .detail-head { padding-inline: 12px; }
  .detail-body { padding-inline: 12px; }
}
@media (max-width: 530px) {
  .inner, .topbar-inner { width: calc(100% - 24px); }
  .topbar-inner { gap: 7px; }
  .topbar .nav-actions { gap: 4px; }
  .brand { font-size: .87rem; gap: 6px; }
  .topbar .quiet-button { padding-inline: 8px; }
  .hero { padding: 22px 12px 24px; margin-top: 13px; }
  .hero p { font-size: .88rem; }
  .search-form .primary { min-width: 56px; padding-inline: 8px; }
  .product-grid { grid-template-columns: 1fr; }
  .filterbar { margin-inline: 0; }
  .filter-fields { grid-template-columns: repeat(auto-fit,minmax(min(100%, 125px),1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
