:root {
  --bg: #f0f2f5;
  --bg2: #ffffff;
  --panel: rgba(255, 255, 255, 0.84);
  --line: #e4e7ed;
  --text: #1a1a1a;
  --muted: #6b7280;
  --accent: #1677ff;
  --accent2: #1677ff;
  --good: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
[data-theme="dark"] {
  --bg: #141414;
  --bg2: #1f1f1f;
  --panel: rgba(30, 30, 30, 0.78);
  --line: #303030;
  --text: #e8e8e8;
  --muted: #888888;
  --accent: #4096ff;
  --accent2: #4096ff;
  --good: #52c41a;
  --warn: #faad14;
  --danger: #ff4d4f;
  --shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
}
* { box-sizing: border-box; }
html {
  background-color: #c8cdd6;
}
html::before {
  content: '';
  position: fixed;
  inset: 0;
  background: url('/bg.jpg') center center / cover no-repeat;
  transform: scaleX(-1);
  z-index: -1;
}
body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Segoe UI", sans-serif;
  color: var(--text);
  background: rgba(240, 242, 245, 0.1);
}
[data-theme="dark"] body {
  background: rgba(20, 20, 20, 0.55);
}
.app-shell {
  display: grid;
  grid-template-columns: 1.6fr 0.9fr;
  gap: 16px;
  padding: 16px;
  min-height: 100vh;
}
.glass {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 12px;
  backdrop-filter: none;
}
.left-panel, .right-panel { padding: 20px; }
.panel-header, .cart-header, .section-title-row, .scan-row, .name-row, .summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.section-title-row-wrap { align-items: flex-start; }
.toolbar-actions, .list-tools, .view-switch, .dialog-actions, .two-col { display: flex; gap: 8px; }
.list-tools { align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.filter-select { min-width: 180px; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 12px; font-weight: 500; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 20px; font-weight: 600; }
h2 { font-size: 16px; font-weight: 600; }
.brand-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.brand-link:hover { text-decoration: underline; }
.config-tip { color: var(--muted); font-size: 13px; background: color-mix(in srgb, var(--good) 10%, var(--bg2)); border: 1px solid color-mix(in srgb, var(--good) 30%, transparent); border-radius: 6px; padding: 8px 12px; margin: 0; }
.no-img { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; color: var(--muted); font-size: 12px; }
.sub, .checkout-tip, .status-text { color: var(--muted); font-size: 13px; margin-top: 4px; }
.scan-box, .summary-card, .checkout-box, .product-grid-wrap { margin-top: 16px; }
.scan-box { padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: color-mix(in srgb, var(--bg2) 60%, transparent); }
.scan-box label { display: block; font-weight: 500; font-size: 14px; margin-bottom: 10px; color: var(--muted); }
input, select {
  width: 100%; border: 1px solid var(--line); background: var(--bg2); color: var(--text);
  border-radius: 8px; padding: 10px 12px; font-size: 14px; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22,119,255,.12); }
[data-theme="dark"] input, [data-theme="dark"] select { background: #262626; border-color: var(--line); }
button { border: none; cursor: pointer; transition: opacity .15s ease, background .15s ease; white-space: nowrap; font-size: 14px; }
button:hover { opacity: .85; }
button:active { opacity: .7; }
#scanBtn, .checkout-btn, .add-btn {
  border-radius: 8px; padding: 10px 16px; color: white; background: var(--accent); font-weight: 500; white-space: nowrap;
}
.ghost-btn, .view-btn {
  background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; white-space: nowrap;
}
.ghost-btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.ghost-btn.danger:hover { background: color-mix(in srgb, var(--danger) 8%, var(--bg2)); }
.view-btn.active { background: color-mix(in srgb, var(--accent) 12%, var(--bg2)); border-color: color-mix(in srgb, var(--accent) 50%, transparent); color: var(--accent); font-weight: 500; }
.theme-btn { font-size: 16px; padding: 8px 12px; line-height: 1; }
.search-input { min-width: 260px; }
.product-grid { margin-top: 12px; }
.product-grid.view-card {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px;
}
.product-grid.view-list,
.product-grid.view-insight {
  display: flex; flex-direction: column; gap: 8px;
}
.product-card {
  border: 1px solid var(--line); background: var(--bg2); border-radius: 10px; overflow: hidden;
  display: flex; flex-direction: column; transition: border-color .15s, box-shadow .15s;
}
.product-card:hover { border-color: color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: 0 2px 8px rgba(22,119,255,.1); }
.view-card .product-card { min-height: 100%; }
.view-list .product-card,
.view-insight .product-card {
  display: grid; grid-template-columns: 72px 1fr auto auto; align-items: center; gap: 12px; padding: 10px 14px;
}
.thumb-wrap { aspect-ratio: 4 / 3; background: color-mix(in srgb, var(--muted) 10%, var(--bg)); }
.view-list .thumb-wrap, .view-insight .thumb-wrap { aspect-ratio: 1 / 1; border-radius: 8px; overflow: hidden; }
.thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.product-body { padding: 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.view-list .product-body, .view-insight .product-body { padding: 0; }
.top-row { align-items: flex-start; }
.product-name {
  font-size: 15px; font-weight: 500; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.8em;
}
.view-list .product-name, .view-insight .product-name { min-height: auto; }
.view-insight .product-name { -webkit-line-clamp: 1; white-space: nowrap; }
.price-tag { font-weight: 600; color: var(--danger); font-size: 15px; white-space: nowrap; }
.barcode-text { color: var(--muted); font-size: 12px; }
.view-insight .barcode-text { font-size: 13px; margin-top: 2px; }
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; }
.info-tag {
  padding: 3px 8px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--muted) 12%, var(--bg));
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.add-btn { width: 100%; margin-top: auto; }
.view-list .add-btn, .view-insight .add-btn { width: 100px; margin-top: 0; justify-self: end; }
.view-insight .add-btn { display: none; }
.right-panel { display: flex; flex-direction: column; height: calc(100vh - 32px); position: sticky; top: 16px; }
.cart-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; min-height: 0; flex: 1; overflow: auto; padding-right: 4px; }
.cart-item {
  display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 8px; padding: 12px;
  border: 1px solid var(--line); border-radius: 8px; background: color-mix(in srgb, var(--bg2) 70%, transparent);
}
.cart-item-title { font-weight: 500; font-size: 14px; }
.cart-item-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.qty-box { display: inline-flex; align-items: center; gap: 6px; padding: 4px; border-radius: 6px; background: color-mix(in srgb, var(--muted) 10%, var(--bg)); border: 1px solid var(--line); }
.qty-btn, .remove-btn { width: 26px; height: 26px; border-radius: 6px; background: var(--bg2); color: var(--text); border: 1px solid var(--line); font-size: 14px; }
.cart-item-price { font-weight: 600; min-width: 64px; text-align: right; font-size: 14px; }
.remove-btn { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.summary-card { padding: 14px; border-radius: 8px; border: 1px solid var(--line); background: color-mix(in srgb, var(--bg2) 60%, transparent); margin-top: 12px; }
.summary-row + .summary-row { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.summary-row strong { font-size: 20px; font-weight: 700; color: var(--danger); }
.checkout-box { margin-top: 12px; }
.checkout-btn { width: 100%; font-size: 15px; padding: 13px 18px; font-weight: 600; border-radius: 8px; }
.empty-state { padding: 24px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; font-size: 14px; }
.insight-metrics {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  justify-self: start;
}
.insight-pill {
  padding: 4px 8px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--muted) 12%, var(--bg));
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.insight-pill.warn { color: #92400e; background: #fef3c7; }
.insight-pill.good { color: #166534; background: #dcfce7; }
[data-theme="dark"] .insight-pill.warn { color: #fde68a; background: rgba(251,191,36,.15); }
[data-theme="dark"] .insight-pill.good { color: #86efac; background: rgba(34,197,94,.15); }
.config-dialog {
  width: min(820px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); color: var(--text); padding: 0;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.config-dialog::backdrop { background: rgba(0,0,0,.4); }
.config-form { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 14px; }
.two-col > * { flex: 1; }
.config-form label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.secret-input-wrap { display: flex; gap: 8px; align-items: center; }
.secret-input-wrap .secret-toggle { min-width: 44px; padding: 10px 0; }
.field-picker-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 4px; }
.notice-banner {
  position: fixed; top: 16px; right: 16px; z-index: 999;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg2); border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 10px; padding: 12px 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  max-width: 320px;
}
.notice-body { display: flex; align-items: center; gap: 8px; flex: 1; }
.notice-icon { font-size: 18px; flex-shrink: 0; }
.notice-text { font-size: 14px; color: var(--text); line-height: 1.5; }
.notice-close {
  background: none; border: none; color: var(--muted); font-size: 18px;
  cursor: pointer; padding: 0 2px; line-height: 1; flex-shrink: 0;
}
.notice-close:hover { color: var(--text); opacity: 1; }
.notice-link { color: var(--accent); text-decoration: none; }
.notice-link:hover { text-decoration: underline; }
.help-dialog { max-height: 90vh; }
.help-content { overflow-y: auto; max-height: calc(90vh - 120px); display: flex; flex-direction: column; gap: 20px; padding-right: 4px; }
.help-section { border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.help-section h4 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.help-section ol, .help-section ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.help-section li { font-size: 14px; line-height: 1.6; color: var(--text); }
.help-section p { margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.url-example { margin: 8px 0; padding: 10px 14px; background: color-mix(in srgb, var(--muted) 8%, var(--bg)); border-radius: 6px; font-family: monospace; font-size: 13px; word-break: break-all; }
.hl-token { color: #1677ff; }
.hl-table { color: #22c55e; }
.help-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
.help-table th, .help-table td { padding: 8px 10px; border: 1px solid var(--line); text-align: left; }
.help-table th { background: color-mix(in srgb, var(--muted) 8%, var(--bg)); font-weight: 600; }
code { background: color-mix(in srgb, var(--muted) 10%, var(--bg)); padding: 2px 6px; border-radius: 4px; font-size: 12px; font-family: monospace; }
@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 1fr; }
  .right-panel { height: auto; position: static; }
  .checkout-box { position: static; background: transparent; }
}
@media (max-width: 720px) {
  .left-panel, .right-panel { padding: 14px; }
  .scan-row, .section-title-row, .panel-header, .cart-header, .toolbar-actions, .list-tools, .two-col, .field-picker-head, .filter-bar { flex-direction: column; align-items: stretch; }
  .view-list .product-card, .view-insight .product-card, .cart-item { grid-template-columns: 1fr; }
  .cart-item-price { text-align: left; }
  .search-input, .filter-select { min-width: 0; }
}
