:root {
  color-scheme: light;
  --brand: #ed1f24;
  --brand-strong: #c9151a;
  --brand-soft: #fff0f1;
  --navy: #262d56;
  --navy-hover: #343d70;
  --navy-soft: #eef0f8;
  --ink: #232845;
  --muted: #68708a;
  --line: #dfe2ec;
  --surface: #ffffff;
  --canvas: #f5f6fa;
  --shadow: 0 12px 30px rgba(38, 45, 86, .13);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--canvas); color: var(--ink); font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif; font-size: 14px; letter-spacing: 0; }
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
input[type="checkbox"] { accent-color: var(--brand); }
input, select { width: 100%; min-height: 40px; border: 1px solid #cbd0df; border-radius: 5px; background: #fff; color: var(--ink); padding: 8px 11px; outline: none; }
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(237, 31, 36, .11); }
.primary, .secondary, .text-btn { min-height: 40px; border-radius: 5px; padding: 0 16px; border: 1px solid transparent; font-weight: 600; white-space: nowrap; }
.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.primary:hover { background: var(--brand-strong); }
.secondary { background: #fff; border-color: #c8ccda; color: var(--navy); }
.secondary:hover { border-color: var(--brand); color: var(--brand-strong); }
.text-btn { min-height: 32px; padding: 0 6px; background: transparent; color: #fff; }
.full { width: 100%; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-view::before { content: ""; position: fixed; inset: 0 0 auto; height: 7px; background: linear-gradient(90deg, var(--brand) 0 34%, var(--navy) 34% 100%); }
.login-panel { width: 420px; max-width: 100%; display: grid; gap: 18px; padding: 32px; background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--brand); border-radius: 7px; box-shadow: var(--shadow); }
.login-panel label { display: grid; gap: 7px; color: #444a69; font-size: 13px; }
.login-brand, .brand { display: flex; align-items: center; gap: 12px; }
.login-brand { margin-bottom: 8px; }
.login-brand h1 { margin: 0 0 4px; color: var(--navy); font-size: 24px; }
.login-brand p, .page-head p { margin: 0; color: var(--muted); }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 6px; background: var(--brand); color: #fff; font-size: 22px; font-weight: 800; }
.form-message { min-height: 20px; margin: -6px 0 0; color: var(--brand-strong); text-align: center; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 16px 16px; background: var(--navy); color: #fff; border-right: 1px solid #343b67; }
.brand { padding: 4px 7px 24px; }
.brand strong { display: block; font-size: 18px; }
.brand small { display: block; max-width: 155px; margin-top: 4px; color: #bfc4da; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-list { display: grid; gap: 7px; }
.nav-item { min-height: 44px; border: 1px solid #48517e; border-radius: 5px; background: #303861; color: #eef0f8; text-align: left; padding: 0 14px; font-weight: 600; }
.nav-item:hover { background: var(--navy-hover); }
.nav-item.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.sidebar-user { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid #48517e; display: flex; align-items: center; justify-content: space-between; color: #cdd1e2; }

.workspace { min-width: 0; padding: 24px; }
.view { display: none; }
.view.active { display: block; }
.page-head { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 0 16px; border-bottom: 1px solid var(--line); }
.page-head h1 { margin: 0 0 5px; color: var(--navy); font-size: 22px; }
.count-badge { padding: 7px 10px; border-radius: 5px; background: var(--navy-soft); color: var(--navy); font-weight: 700; }
.page-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.compact { min-height: 34px; padding: 0 11px; }

.platform-picker { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 16px 0 0; }
.platform-option { display: grid; grid-template-columns: auto minmax(110px, 1fr) auto; align-items: center; gap: 10px; padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--navy); border-radius: 6px; }
.platform-check { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.platform-check input { width: 16px; min-height: 16px; margin: 0; }
.platform-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--navy); }
.platform-dot.ysb { background: #ff5a00; }
.platform-dot.ybm { background: #00ad62; }
.platform-dot.yyc { background: var(--brand); }
.platform-option select { min-height: 34px; padding-top: 5px; padding-bottom: 5px; }
.state-chip { padding: 3px 7px; border-radius: 4px; font-size: 12px; white-space: nowrap; }
.state-chip.good { background: #e8f5ee; color: #137347; }
.state-chip.bad { background: var(--brand-soft); color: var(--brand-strong); }
.state-chip.neutral { background: var(--navy-soft); color: var(--muted); }

.search-toolbar { display: grid; grid-template-columns: minmax(260px, 2fr) 145px 90px auto auto auto; gap: 9px; align-items: center; padding: 12px 0; }
.keyword-input { min-width: 0; }
.progress-wrap { padding: 12px 14px; border: 1px solid #f2b9bb; background: var(--brand-soft); border-radius: 6px; margin-bottom: 14px; }
.progress-copy { display: flex; justify-content: space-between; margin-bottom: 8px; }
.progress-copy strong { color: var(--brand-strong); }
.progress-track { height: 7px; border-radius: 4px; overflow: hidden; background: #f4cfd1; }
.progress-track span { display: block; height: 100%; width: 0; background: var(--brand); transition: width .3s ease; }
.platform-progress { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.platform-progress .state-chip { border: 1px solid rgba(38, 45, 86, .08); }
.result-summary { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 14px; background: #fff; border: 1px solid var(--line); border-bottom: 0; border-radius: 6px 6px 0 0; }
.result-summary > div > strong { display: block; font-size: 16px; }
.result-summary > div > span { display: block; margin-top: 4px; color: var(--muted); }
.lowest { text-align: right; }
.lowest small { color: var(--muted); }
#lowestPrice { color: var(--brand); font-size: 24px; }
.filter-tabs { display: flex; align-items: center; gap: 4px; padding: 7px 9px; background: var(--navy-soft); border: 1px solid var(--line); border-bottom: 0; }
.filter-tab { min-height: 32px; padding: 0 10px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--navy); }
.filter-tab.active { background: var(--navy); color: #fff; }
.filter-tab span { opacity: .75; }

.table-scroll { overflow: auto; background: #fff; border: 1px solid var(--line); }
.result-scroll { max-height: calc(100vh - 340px); min-height: 240px; }
.data-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.data-table th { position: sticky; top: 0; z-index: 2; background: var(--navy-soft); color: var(--navy); font-size: 12px; text-align: left; padding: 9px 10px; border-bottom: 1px solid #d4d8e6; white-space: nowrap; }
.sortable-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.sort-controls { display: inline-grid; grid-template-columns: repeat(2, 16px); gap: 2px; flex: 0 0 auto; }
.sort-controls button { width: 16px; height: 18px; display: grid; place-items: center; padding: 0; border: 1px solid var(--brand); border-radius: 3px; background: #fff; color: var(--brand); font-size: 9px; line-height: 1; }
.sort-controls button:hover { background: var(--brand-soft); color: var(--brand-strong); }
.sort-controls button.active { border-color: var(--brand); background: var(--brand); color: #fff; }
.data-table td { padding: 9px 10px; border-bottom: 1px solid #e7e9f0; vertical-align: top; line-height: 1.45; overflow-wrap: anywhere; }
.data-table tr:hover td { background: #fafafd; }
.result-table th:nth-child(1) { width: 110px; }
.result-table th:nth-child(2) { width: 28%; }
.result-table th:nth-child(3) { width: 25%; }
.result-table th:nth-child(4), .result-table th:nth-child(5), .result-table th:nth-child(6) { width: 80px; }
.result-table th:nth-child(7), .result-table th:nth-child(8) { width: 105px; }
.result-table th:nth-child(9) { width: 120px; }
.price { color: var(--brand); font-size: 17px; font-weight: 800; }
.platform-label { display: inline-block; margin-bottom: 4px; padding: 2px 5px; border-radius: 3px; background: var(--navy); color: #fff; font-size: 11px; }
.platform-label.ysb { background: #e95300; }
.platform-label.ybm { background: #058251; }
.platform-label.yyc { background: var(--brand); }
.product-name { font-weight: 700; }
.product-meta { margin-top: 3px; }
.product-meta .subline { margin-top: 3px; }
.subline { margin-top: 3px; color: var(--muted); font-size: 12px; }
.minimum { color: var(--brand-strong); font-size: 11px; }
.empty { padding: 42px !important; text-align: center; color: var(--muted); }
.empty-block { padding: 36px; background: #fff; text-align: center; color: var(--muted); }

.history-list { display: grid; gap: 1px; margin-top: 16px; border: 1px solid var(--line); background: var(--line); }
.history-row { min-height: 58px; display: grid; grid-template-columns: 170px minmax(180px, 1fr) 170px 110px auto; align-items: center; gap: 12px; padding: 9px 12px; background: #fff; }
.history-keyword { border: 0; background: transparent; color: var(--brand-strong); text-align: left; padding: 0; font-weight: 700; }
.status-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.status-card { min-height: 170px; padding: 16px; background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--navy); border-radius: 6px; }
.status-card.online { border-top-color: var(--brand); }
.status-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.status-head h2 { margin: 0; font-size: 18px; }
.account-summary { display: grid; gap: 7px; }
.account-pill { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 9px; background: var(--navy-soft); border-radius: 4px; }
.account-pill > span { display: grid; gap: 2px; min-width: 0; }
.account-pill small { color: var(--muted); font-size: 11px; }
.user-table-wrap { margin-top: 16px; }
.user-table th:nth-child(1), .user-table th:nth-child(2) { width: 20%; }
.user-table th:nth-child(3), .user-table th:nth-child(4) { width: 110px; }
.user-table th:nth-child(5) { width: 190px; }
.user-table th:nth-child(6) { width: 250px; }
.role-badge { display: inline-block; padding: 3px 7px; border-radius: 4px; background: var(--navy-soft); color: var(--navy); font-size: 12px; font-weight: 700; }
.role-badge.admin { background: var(--brand-soft); color: var(--brand-strong); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions button { min-height: 30px; padding: 0 9px; font-size: 12px; }
.purchase-config-band { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 14px; padding: 10px 14px; border: 1px solid #d7dbea; border-left: 4px solid var(--navy); background: var(--navy-soft); }
.purchase-config-band div { min-width: 0; }
.purchase-config-band span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.purchase-config-band strong { display: block; overflow: hidden; color: var(--navy); text-overflow: ellipsis; white-space: nowrap; }
.import-empty { min-height: 300px; display: grid; place-content: center; justify-items: center; gap: 10px; margin-top: 14px; border: 1px dashed #bec4d7; background: #fff; color: var(--muted); text-align: center; }
.import-empty strong { color: var(--navy); font-size: 18px; }
.import-empty .primary { margin-top: 8px; }
.purchase-workspace { margin-top: 14px; }
.purchase-toolbar { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 12px; border: 1px solid var(--line); border-bottom: 0; background: #fff; }
.purchase-stats { display: flex; flex-wrap: wrap; gap: 18px; color: var(--muted); white-space: nowrap; }
.purchase-stats strong { margin-right: 4px; color: var(--navy); font-size: 17px; }
.purchase-progress { padding: 10px 12px; border: 1px solid #f2b9bb; border-bottom: 0; background: var(--brand-soft); }
.purchase-table-wrap { max-height: calc(100vh - 260px); min-height: 260px; }
.purchase-table { min-width: 1080px; }
.purchase-table th:nth-child(1) { width: 56px; }
.purchase-table th:nth-child(2) { width: 270px; }
.purchase-table th:nth-child(3) { width: 190px; }
.purchase-table th:nth-child(4), .purchase-table th:nth-child(5) { width: 100px; }
.purchase-table th:nth-child(6) { width: 145px; }
.purchase-table th:nth-child(7) { width: 190px; }
.purchase-table th:nth-child(8) { width: 78px; }
.purchase-table th:nth-child(9) { width: 150px; }
.table-input { min-height: 34px; padding: 5px 8px; border-radius: 4px; }
.sub-input { margin-top: 5px; background: #fafbfe; }
.numeric-input { text-align: right; }
.purchase-lowest { color: var(--brand); font-size: 16px; }
.error-text { max-width: 180px; overflow: hidden; color: var(--brand-strong); text-overflow: ellipsis; white-space: nowrap; }
.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(25, 30, 61, .58); }
.modal-card { width: 620px; max-width: 100%; max-height: calc(100vh - 40px); overflow: auto; background: #fff; border: 1px solid #d3d6e3; border-top: 4px solid var(--brand); border-radius: 7px; box-shadow: var(--shadow); }
.modal-card.small { width: 560px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0 0 4px; font-size: 18px; }
.modal-head p { margin: 0; color: var(--muted); }
.icon-close { width: 34px; height: 34px; border: 0; background: transparent; color: var(--muted); font-size: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 18px 20px; }
.form-grid label { display: grid; gap: 7px; color: #444a69; font-size: 13px; }
.span-2 { grid-column: span 2; }
.check-label { display: flex !important; align-items: center; gap: 8px; }
.check-label input { width: 18px; min-height: 18px; }
.modal-note { margin: 0; color: #656b86; font-size: 12px; line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.log-table th:nth-child(1) { width: 190px; }
.log-table th:nth-child(2), .log-table th:nth-child(3) { width: 130px; }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 50; max-width: min(520px, calc(100vw - 32px)); transform: translateX(-50%); padding: 12px 17px; border-radius: 6px; background: var(--navy); color: #fff; box-shadow: var(--shadow); }

@media (max-width: 1180px) {
  .workspace { padding: 18px; }
  .platform-picker { grid-template-columns: 1fr; }
  .search-toolbar { grid-template-columns: minmax(220px, 2fr) 140px 86px repeat(3, auto); }
  .result-scroll { max-height: calc(100vh - 450px); }
}

@media (max-width: 820px) {
  body { font-size: 13px; }
  .app-shell { display: block; }
  .sidebar { position: relative; width: 100%; height: auto; padding: 12px; }
  .brand { padding: 0 4px 12px; }
  .brand-mark { width: 42px; height: 42px; }
  .nav-list { display: flex; overflow-x: auto; gap: 7px; }
  .nav-list { scrollbar-width: none; }
  .nav-list::-webkit-scrollbar { display: none; }
  .nav-item { flex: 0 0 auto; min-width: 94px; text-align: center; }
  .sidebar-user { position: absolute; right: 12px; top: 17px; width: auto; padding: 0; border: 0; }
  .sidebar-user span { display: none; }
  .brand small { max-width: 118px; }
  .workspace { padding: 10px; }
  .page-head { min-height: 56px; }
  .page-head h1 { font-size: 19px; }
  .purchase-head { align-items: flex-start; }
  .purchase-head .page-actions { max-width: 210px; }
  .platform-picker { gap: 6px; padding-top: 10px; }
  .platform-option { grid-template-columns: 92px minmax(0, 1fr) auto; padding: 7px 8px; }
  .platform-option select { min-height: 34px; }
  .search-toolbar { grid-template-columns: minmax(0, 1fr) 100px 72px; padding: 8px 0; }
  .search-toolbar .keyword-input { grid-column: span 3; }
  .search-toolbar button { padding: 0 8px; }
  .search-toolbar #searchBtn { grid-column: span 1; }
  .result-summary { min-height: 54px; padding: 8px 10px; }
  #lowestPrice { font-size: 20px; }
  .filter-tabs { overflow-x: auto; }
  .filter-tab { flex: 0 0 auto; }
  .result-scroll { max-height: none; min-height: 180px; }
  .result-table { min-width: 0; }
  .result-table thead { display: none; }
  .result-table tbody, .result-table tr { display: block; }
  .result-table tr { padding: 8px 9px; border-bottom: 1px solid var(--line); }
  .result-table td { display: grid; grid-template-columns: 68px minmax(0, 1fr); gap: 6px; padding: 3px 0; border: 0; }
  .result-table td::before { color: var(--muted); font-size: 11px; font-weight: 600; }
  .result-table td:nth-child(1)::before { content: "平台/报价"; }
  .result-table td:nth-child(2)::before { content: "商品"; }
  .result-table td:nth-child(3)::before { content: "商家"; }
  .result-table td:nth-child(4)::before { content: "起购"; }
  .result-table td:nth-child(5)::before { content: "库存"; }
  .result-table td:nth-child(6)::before { content: "销量"; }
  .result-table td:nth-child(7)::before { content: "生产日期"; }
  .result-table td:nth-child(8)::before { content: "有效期"; }
  .result-table td:nth-child(9)::before { content: "活动"; }
  .result-table .product-cell > *, .result-table .merchant-cell > * { grid-column: 2; min-width: 0; }
  .result-table .product-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 0; }
  .result-table .product-meta .subline { margin-top: 0; }
  .result-table td.empty { display: block; }
  .result-table td.empty::before { content: none; }
  .history-row { grid-template-columns: 110px minmax(140px, 1fr) auto; }
  .history-row > :nth-child(3), .history-row > :nth-child(4) { display: none; }
  .status-grid { grid-template-columns: 1fr; }
  .purchase-config-band { align-items: flex-start; }
  .purchase-config-band strong { white-space: normal; }
  .purchase-toolbar { align-items: flex-start; flex-direction: column; }
  .purchase-toolbar .page-actions { width: 100%; justify-content: flex-start; }
  .purchase-stats { gap: 10px; }
  .purchase-table-wrap { max-height: none; }
  .purchase-table { min-width: 0; }
  .purchase-table thead { display: none; }
  .purchase-table tbody, .purchase-table tr { display: block; }
  .purchase-table tr { padding: 8px 9px; border-bottom: 1px solid var(--line); }
  .purchase-table td { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 7px; padding: 4px 0; border: 0; }
  .purchase-table td::before { color: var(--muted); font-size: 11px; font-weight: 600; }
  .purchase-table td:nth-child(1)::before { content: "序号"; }
  .purchase-table td:nth-child(2)::before { content: "关键词/规格"; }
  .purchase-table td:nth-child(3)::before { content: "生产厂家"; }
  .purchase-table td:nth-child(4)::before { content: "采购数量"; }
  .purchase-table td:nth-child(5)::before { content: "我司价格"; }
  .purchase-table td:nth-child(6)::before { content: "查询状态"; }
  .purchase-table td:nth-child(7)::before { content: "最低报价"; }
  .purchase-table td:nth-child(8)::before { content: "报价数量"; }
  .purchase-table td:nth-child(9)::before { content: "操作"; }
  .purchase-table .row-actions { justify-content: flex-start; }
  .user-table { min-width: 720px; }
  .form-grid { grid-template-columns: 1fr; padding: 16px 14px; }
  .span-2 { grid-column: span 1; }
  .modal-head, .modal-actions { padding-left: 14px; padding-right: 14px; }
}
