:root {
  --canvas: #f5f6fa;
  --surface: #ffffff;
  --surface-subtle: #f8f9fc;
  --ink: #202533;
  --muted: #707789;
  --line: #e6e8ef;
  --primary: #4c46df;
  --primary-soft: #efefff;
  --positive: #d94b59;
  --positive-soft: #fff0f1;
  --teal: #17856d;
  --teal-soft: #eaf8f3;
  --warning: #b77a17;
  --radius: 16px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 14px;
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 216px minmax(0, 1fr); }
.sidebar {
  display: flex;
  flex-direction: column;
  padding: 24px 14px 18px;
  color: #dce0fc;
  background: #24273c;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 28px; font-size: 18px; font-weight: 700; color: #fff; }
.brand-mark {
  display: block;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  object-fit: contain;
}
.nav-label { padding: 0 10px 8px; color: #989ebc; font-size: 12px; }
.nav { display: grid; gap: 4px; }
.nav button {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 11px;
  padding: 11px 12px;
  border: 0;
  border-radius: 10px;
  color: #c9cde4;
  background: transparent;
  text-align: left;
}
.nav button:hover { background: #32364f; color: white; }
.nav button.active { color: white; background: var(--primary); box-shadow: 0 6px 16px rgba(76, 70, 223, .3); }
.nav-icon { width: 20px; text-align: center; font-size: 16px; }
.sidebar-bottom { margin-top: auto; }

.page { display: flex; flex-direction: column; min-width: 0; padding: 30px 34px 36px; }
.page > * { flex-shrink: 0; }
.page > section { margin-bottom: 28px; }
.site-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
.site-footer p { margin: 0; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
h1 { margin: 0 0 7px; font-size: 25px; letter-spacing: -.4px; }
.heading-copy { margin: 0; color: var(--muted); }
.count-control { display: flex; align-items: center; gap: 10px; padding: 9px 11px 9px 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--muted); }
.count-control input { width: 48px; padding: 4px; border: 0; outline: 0; color: var(--ink); background: transparent; text-align: center; font-weight: 700; }

.workbench { display: grid; grid-template-columns: minmax(610px, 1fr) 356px; align-items: start; gap: 22px; }
.main-panel, .detail-panel { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 8px 26px rgba(31, 35, 51, .045); }
.toolbar { display: flex; align-items: center; gap: 10px; padding: 17px 18px; border-bottom: 1px solid var(--line); }
.search { position: relative; flex: 1; min-width: 150px; }
.search span { position: absolute; top: 8px; left: 11px; color: #858ba0; }
.search input { width: 100%; height: 36px; padding: 0 10px 0 33px; border: 1px solid var(--line); border-radius: 9px; outline-color: var(--primary); color: var(--ink); background: var(--surface-subtle); }
.tool-button, .primary-button, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: #454b5d;
  background: white;
  white-space: nowrap;
}
.tool-button { padding: 0 11px; }
.tool-button:hover { border-color: #babeea; background: var(--primary-soft); }
.primary-button { padding: 0 13px; border-color: var(--primary); color: #fff; background: var(--primary); }
.primary-button:hover { background: #3d38c9; }
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: #454b5d;
  background: white;
  white-space: nowrap;
}
.secondary-button:hover { border-color: #babeea; background: var(--primary-soft); }

.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 720px; border-collapse: collapse; }
th { padding: 13px 14px; color: var(--muted); background: #fafbfe; text-align: left; font-size: 12px; font-weight: 600; }
th.number, td.number { text-align: right; }
td { padding: 13px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr { transition: background .16s ease; }
tbody tr:hover { background: #fafaff; }
tbody tr.selected { background: #f1f1ff; box-shadow: inset 3px 0 0 var(--primary); }
.product { min-width: 125px; }
.product-name { display: block; color: var(--ink); font-weight: 700; }
.price { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.diff { color: var(--positive); font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.pill { display: inline-block; padding: 4px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.profit { color: var(--positive); background: var(--positive-soft); }
.pill.discount { color: var(--muted); background: var(--surface-subtle); }
.pill.discount.red { color: var(--positive); background: var(--positive-soft); }
.pill.discount.green { color: var(--teal); background: var(--teal-soft); }
.row-actions { display: flex; justify-content: flex-end; gap: 4px; }
.icon-button { width: 30px; height: 30px; border-color: transparent; color: #62697c; background: transparent; }
.icon-button:hover { color: var(--primary); background: var(--primary-soft); }
.footer-note { padding: 13px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

.detail-panel { position: sticky; top: 20px; }
.detail-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 16px; border-bottom: 1px solid var(--line); }
.detail-header h2 { margin: 0; font-size: 17px; }
.detail-content { padding: 18px; }
.selected-product { margin-bottom: 18px; }
.selected-product strong { display: block; font-size: 18px; }
.tag { display: inline-block; margin-top: 5px; padding: 3px 7px; border-radius: 6px; color: #5e6576; background: var(--surface-subtle); font-size: 11px; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric { min-height: 85px; padding: 13px; border-radius: 12px; background: var(--surface-subtle); }
.metric.primary { background: var(--primary-soft); }
.metric.positive { background: var(--positive-soft); }
.metric-label { display: block; color: var(--muted); font-size: 12px; }
.metric-value { display: block; margin-top: 8px; font-size: 21px; font-weight: 750; font-variant-numeric: tabular-nums; }
.metric.positive .metric-value { color: var(--positive); }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 23px 0 11px; font-weight: 700; }
.section-title span { color: var(--muted); font-size: 12px; font-weight: 400; }
.friend-list { display: grid; gap: 7px; }
.friend-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 11px; border: 1px solid var(--line); border-radius: 10px; }
.friend-row.best { border-color: #f2b5bc; background: #fff8f8; }
.friend-name { font-weight: 600; }
.friend-price { color: var(--muted); font-size: 12px; }
.friend-diff { color: var(--positive); font-weight: 700; font-variant-numeric: tabular-nums; }
.estimate { margin-top: 18px; padding: 14px; border-radius: 12px; color: #fff; background: #303553; }
.estimate-top { display: flex; justify-content: space-between; color: #cdd2f0; font-size: 12px; }
.estimate-value { margin-top: 6px; font-size: 24px; font-weight: 750; font-variant-numeric: tabular-nums; }
.delete-button { width: 100%; margin-top: 18px; height: 39px; border: 1px solid #ef8b94; border-radius: 9px; color: #c8404d; background: white; font-weight: 700; }
.delete-button:hover { background: var(--positive-soft); }

.view[hidden], .modal-backdrop[hidden] { display: none; }
.page-actions { display: flex; align-items: center; gap: 10px; }
.management-panel { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 8px 26px rgba(31, 35, 51, .045); }
.management-toolbar { display: flex; align-items: center; gap: 10px; padding: 17px 18px; border-bottom: 1px solid var(--line); }
.management-toolbar .search { max-width: 440px; }
.filter-select { height: 36px; padding: 0 30px 0 10px; border: 1px solid var(--line); border-radius: 9px; outline-color: var(--primary); color: #454b5d; background: var(--surface-subtle); }
.status { display: inline-block; padding: 4px 8px; border-radius: 99px; color: var(--teal); background: var(--teal-soft); font-size: 12px; font-weight: 700; }
.manage-actions { display: flex; justify-content: flex-end; gap: 5px; }
.text-button { padding: 4px 6px; border: 0; border-radius: 6px; color: var(--primary); background: transparent; font-size: 12px; }
.text-button:hover { background: var(--primary-soft); }
.management-footer { display: flex; align-items: center; justify-content: space-between; padding: 13px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.inventory-summary { display: flex; align-items: center; gap: 7px; color: var(--muted); }
.inventory-summary strong { color: var(--ink); font-size: 17px; }

.modal-backdrop { position: fixed; z-index: 10; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(25, 28, 43, .42); }
.add-dialog { width: min(720px, 100%); overflow: hidden; border-radius: 18px; background: var(--surface); box-shadow: 0 24px 64px rgba(21, 24, 40, .23); }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 24px 18px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0 0 6px; font-size: 20px; }
.dialog-subtitle { margin: 0; color: var(--muted); font-size: 13px; }
.dialog-body { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 22px; padding: 22px 24px; }
.form-section + .form-section { margin-top: 20px; }
.form-section-title { margin: 0 0 12px; color: #3d4355; font-size: 13px; font-weight: 700; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label, .field-label { color: #555d70; font-size: 12px; font-weight: 600; }
.field input, .field select { width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; outline-color: var(--primary); color: var(--ink); background: white; }
.input-affix { display: flex; align-items: center; overflow: hidden; height: 38px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.input-affix input { height: 36px; border: 0; border-radius: 0; }
.input-affix span { padding-right: 11px; color: var(--muted); font-size: 12px; }
.form-hint { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-top: 13px; color: #4c5365; font-size: 13px; }
.add-preview { align-self: start; padding: 16px; border-radius: 13px; background: var(--surface-subtle); }
.preview-name { margin: 0 0 3px; color: var(--ink); font-weight: 750; }
.preview-description { color: var(--muted); font-size: 12px; }
.preview-rule { height: 1px; margin: 15px 0; background: var(--line); }
.preview-row { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; color: var(--muted); font-size: 12px; }
.preview-row strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 24px; border-top: 1px solid var(--line); }
.dialog-footer-note { color: var(--muted); font-size: 12px; }
.dialog-actions { display: flex; gap: 9px; }

.empty { padding: 30px 15px; color: var(--muted); text-align: center; }

@media (max-width: 1180px) {
  .page { padding: 24px; }
  .workbench { grid-template-columns: minmax(540px, 1fr) 320px; gap: 16px; }
  .toolbar { flex-wrap: wrap; }
  .search { min-width: 100%; }
}
@media (max-width: 940px) {
  .app-shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { display: none; }
  .workbench { grid-template-columns: 1fr; }
  .detail-panel { position: static; }
  .dialog-body { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .page { padding: 18px 12px; }
  .page-heading { align-items: stretch; flex-direction: column; margin-bottom: 18px; }
  .count-control { align-self: flex-start; }
  .toolbar { padding: 12px; }
  .tool-button { padding: 0 9px; }
  .main-panel, .detail-panel { border-radius: 12px; }
  .page-actions { align-items: stretch; flex-direction: column; }
  .management-toolbar { align-items: stretch; flex-wrap: wrap; }
  .management-toolbar .search { flex-basis: 100%; max-width: none; }
  .dialog-header, .dialog-body, .dialog-footer { padding-right: 16px; padding-left: 16px; }
  .dialog-footer { align-items: stretch; flex-direction: column; }
  .dialog-actions { justify-content: flex-end; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
}

[v-cloak] { display: none; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, tr[tabindex]:focus-visible { outline: 3px solid #a6a2ff; outline-offset: 3px; }
input:focus-visible, select:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
button:disabled { cursor: not-allowed; opacity: .5; }
.sidebar { position: sticky; top: 0; height: 100vh; }
.sidebar-bottom { padding-top: 24px; }
.sidebar-note { margin: 14px 12px 0; color: #989ebc; font-size: 12px; line-height: 1.8; }
.nav .reset-button { color: #ffb3bc; }
.mobile-nav { display: none; }
.workbench { grid-template-columns: minmax(0, 1fr) 356px; }
.toolbar { flex-wrap: wrap; }
.search { min-width: 180px; }
.filter-select { max-width: 150px; padding-right: 8px; }
.summary-bar { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 22px; padding: 18px 22px; border: 1px solid #dddcfa; border-radius: var(--radius); background: var(--primary-soft); }
.summary-label { display: block; margin-bottom: 6px; color: #65618f; font-size: 12px; }
.summary-pair { overflow-wrap: anywhere; font-weight: 700; }
.summary-value { color: var(--primary); font-size: 25px; font-weight: 750; white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr.selectable { cursor: pointer; }
.product-link { padding: 0; border: 0; background: none; text-align: left; overflow-wrap: anywhere; }
.product-subtitle { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.product-name, .friend-name, .selected-product strong { overflow-wrap: anywhere; }
.red, .diff.red, .metric.positive .metric-value.red, .friend-diff.red { color: var(--positive); }
.green, .diff.green, .metric.positive .metric-value.green, .friend-diff.green { color: var(--teal); }
.pill.green { color: var(--teal); background: var(--teal-soft); }
.muted { color: var(--muted); }
.empty { line-height: 1.8; }
.empty p { margin: 0 0 14px; }
.detail-header h2 { overflow-wrap: anywhere; }
.detail-content { min-width: 0; }
.metric { min-width: 0; }
.metric-value { font-size: clamp(16px, 1.4vw, 21px); overflow-wrap: anywhere; }
.detail-form { margin: 16px 0; }
.friend-row { display: grid; grid-template-columns: minmax(0, 1fr) 92px; gap: 8px 10px; }
.friend-price { display: block; margin-top: 4px; line-height: 1.6; }
.quote-input { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.quote-input input { width: 100%; min-width: 0; height: 34px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: white; text-align: right; }
.friend-diff { grid-column: 1 / -1; text-align: right; font-size: 12px; }
.estimate-top { flex-wrap: wrap; gap: 5px; }
.estimate-value { overflow-wrap: anywhere; }
.delete-button { margin-top: 14px; }
.count-control input { width: 80px; }
.friend-table { min-width: 600px; }
.friend-table th, .friend-table td { min-width: 145px; }
.friend-table th:first-child, .friend-table td:first-child { min-width: 170px; }
.inline-input { width: 100%; min-width: 80px; height: 36px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: white; }
.quote-price, .quote-diff { display: block; margin-top: 5px; font-size: 11px; white-space: nowrap; }
.quote-price { color: var(--muted); }
.management-footer { flex-wrap: wrap; gap: 8px; }
.management-actions { display: flex; justify-content: flex-end; gap: 8px; }
.danger-text { color: #c8404d; }
.modal-backdrop { z-index: 20; overflow-y: auto; }
.add-dialog { max-height: calc(100dvh - 48px); overflow-y: auto; }
.friend-dialog .dialog-body { display: block; }
.dialog-error { margin: 12px 24px 0; color: #c8404d; font-size: 13px; }
.dialog-footer-note { line-height: 1.7; }
body:has(.modal-backdrop) { overflow: hidden; }
@media (max-width: 1180px) {
  .workbench { grid-template-columns: minmax(0, 1fr) 320px; }
  .toolbar .search { min-width: 100%; }
}
@media (max-width: 940px) {
  .sidebar { display: none; }
  .mobile-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 12px; background: #24273c; }
  .mobile-brand { display: flex; flex-basis: 100%; align-items: center; gap: 10px; padding: 4px 2px 10px; color: white; font-size: 18px; font-weight: 700; }
  .mobile-nav button { flex: 1; padding: 10px 8px; border: 0; border-radius: 8px; color: #dce0fc; background: transparent; white-space: nowrap; }
  .mobile-nav button.active { background: var(--primary); color: white; }
  .mobile-nav .reset-button { flex: 0; color: #ffb3bc; }
  .workbench { grid-template-columns: minmax(0, 1fr); }
  .metric-value { font-size: 21px; }
}
@media (max-width: 560px) {
  .summary-bar { padding: 16px; gap: 12px; align-items: flex-start; flex-direction: column; }
  .toolbar .primary-button { margin-left: auto; }
  .modal-backdrop { padding: 12px; }
  .add-dialog { max-height: calc(100dvh - 24px); }
  input, select, .inline-input { font-size: 16px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .dialog-error { margin-left: 16px; margin-right: 16px; }
}


/* 图片导入 */
.toolbar-actions { display: flex; gap: 8px; margin-left: auto; }
.import-dialog { width: min(1040px, 100%); }
.import-body { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; padding: 22px 24px; }
.import-source { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 220px; padding: 14px; border: 1.5px dashed var(--line); border-radius: 12px; background: var(--surface-subtle); text-align: center; }
.import-source.dragging { border-color: var(--primary); background: var(--primary-soft); }
.import-preview { max-width: 100%; max-height: 300px; border-radius: 8px; object-fit: contain; }
.import-placeholder { margin: 0; color: var(--muted); }
.import-source-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.import-result { min-width: 0; }
.import-progress { display: grid; gap: 10px; padding: 18px 4px; }
.import-progress-label { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; }
.import-progress-bar { height: 8px; overflow: hidden; border-radius: 99px; background: var(--line); }
.import-progress-bar span { display: block; height: 100%; background: var(--primary); transition: width .2s; }
.import-progress .secondary-button { justify-self: start; }
.import-table { max-height: 420px; overflow-y: auto; }
.import-table td { vertical-align: top; }
.import-table .inline-input { width: 100%; min-width: 140px; }
.import-tag { display: inline-block; margin-top: 4px; padding: 1px 7px; border-radius: 99px; font-size: 12px; }
.import-tag.update { color: var(--primary); background: var(--primary-soft); }
.import-tag.new { color: var(--teal); background: var(--teal-soft); }
.import-candidates { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.import-candidates .text-button { padding: 0 4px; font-size: 12px; }
.import-error { display: block; margin-top: 4px; color: var(--positive); font-size: 12px; }
.row-error td { background: var(--positive-soft); }
.price-mismatch { color: var(--warning); text-decoration: underline dotted; }
.primary-button:disabled { opacity: .5; cursor: not-allowed; }
@media (max-width: 940px) {
  .import-body { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .import-body { padding-right: 16px; padding-left: 16px; }
  .toolbar-actions { margin-left: 0; width: 100%; }
}
