/* 胶片价格通 — 移动优先响应式样式 */
:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --text: #24232a;
  --muted: #8a8894;
  --line: #e7e3d9;
  --accent: #b8860b;
  --accent-strong: #96690a;
  --accent-soft: #faf3e2;
  --danger: #c0392b;
  --ok: #2e7d32;
  --shadow: 0 1px 3px rgba(30, 28, 20, .08);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141417;
    --card: #1e1e23;
    --text: #e8e6e3;
    --muted: #93919c;
    --line: #2c2c33;
    --accent: #d4a545;
    --accent-strong: #e0b45c;
    --accent-soft: #2b2517;
    --danger: #e06a5a;
    --ok: #6abf6e;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---------- 顶栏 / 底栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 50%;
  background:
    radial-gradient(circle at 38% 34%, #6a7ea0 0 18%, transparent 19%),
    radial-gradient(circle, #2c3a52 0 58%, #20222b 59%);
  border: 2.5px solid var(--accent);
}
.topnav { display: none; gap: 4px; }
.topnav a {
  padding: 6px 14px; border-radius: 999px; font-size: 14px; color: var(--muted);
}
.topnav a.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 0 5px; font-size: 11px; color: var(--muted);
}
.tabbar a.active { color: var(--accent-strong); }
.tabbar svg { width: 22px; height: 22px; fill: currentColor; }

main {
  max-width: 980px; margin: 0 auto;
  padding: 16px 16px calc(76px + env(safe-area-inset-bottom));
}

@media (min-width: 768px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  main { padding-bottom: 48px; }
}

/* ---------- 通用 ---------- */
.loading { text-align: center; color: var(--muted); padding: 60px 0; }
.page-head { margin: 6px 0 14px; }
.page-head h1 { font-size: 22px; margin: 0 0 4px; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.section { margin: 22px 0; }
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 16px; font-weight: 700; margin: 0 0 10px;
}
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px;
}
.chip {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-strong);
  font-size: 12px; white-space: nowrap;
}
.chip.plain { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.muted { color: var(--muted); font-size: 13px; }
.money { font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 14px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }

input[type=text], input[type=number], input[type=search], input[type=date], select, textarea {
  width: 100%; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  font-size: 15px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 64px; }
label.field { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
label.field > span { display: block; margin-bottom: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }

/* ---------- 首页 ---------- */
.hero-search { position: relative; margin: 8px 0 18px; }
.hero-search input {
  padding: 13px 16px 13px 44px; border-radius: 14px; font-size: 16px;
  background: var(--card); box-shadow: var(--shadow);
}
.hero-search .icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; fill: var(--muted);
}
.search-pop {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0,0,0,.14); overflow: hidden; max-height: 60vh; overflow-y: auto;
}
.search-pop .row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.search-pop .row:last-child { border-bottom: 0; }
.search-pop .row:hover, .search-pop .row:active { background: var(--accent-soft); }

.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; cursor: pointer;
  transition: transform .12s ease, border-color .12s ease;
}
.cat-card:hover, .cat-card:active { transform: translateY(-2px); border-color: var(--accent); }
.cat-card .t { font-weight: 700; font-size: 16px; }
.cat-card .n { color: var(--muted); font-size: 12px; margin-top: 2px; }
@media (min-width: 768px) { .cat-grid { grid-template-columns: repeat(4, 1fr); } }

.update-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 2px; border-bottom: 1px dashed var(--line); font-size: 14px;
}
.update-row:last-child { border-bottom: 0; }

/* ---------- 列表 ---------- */
.filter-bar { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.filter-bar::-webkit-scrollbar { display: none; }
.filter-bar .chip {
  padding: 6px 14px; cursor: pointer; background: var(--card); border: 1px solid var(--line);
  color: var(--muted); flex-shrink: 0;
}
.filter-bar .chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.list-toolbar select { width: auto; padding: 6px 10px; font-size: 13px; }

.item-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 13px 16px; margin-bottom: 10px; cursor: pointer;
}
.item-card:hover, .item-card:active { border-color: var(--accent); }
.item-card .badge-type {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--accent-strong); background: var(--accent-soft);
}
.item-card .mid { flex: 1; min-width: 0; }
.item-card .name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-card .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.item-card .price { text-align: right; flex-shrink: 0; }
.item-card .price .v { font-weight: 700; color: var(--accent-strong); font-size: 15px; }
.item-card .price .l { font-size: 11px; color: var(--muted); }

/* ---------- 详情 ---------- */
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.crumb a { color: var(--accent-strong); }
.detail-head h1 { font-size: 24px; margin: 0; }
.detail-head .tags { margin: 8px 0 4px; display: flex; flex-wrap: wrap; gap: 6px; }
.intro { color: var(--text); opacity: .85; font-size: 14px; margin: 10px 0 0; }

.specs { display: grid; grid-template-columns: 1fr; gap: 0; }
.specs .row { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.specs .row:last-child { border-bottom: 0; }
.specs .k { flex-shrink: 0; width: 88px; color: var(--muted); }
.specs .v { flex: 1; }
@media (min-width: 768px) { .specs { grid-template-columns: 1fr 1fr; column-gap: 28px; } }

/* 价格矩阵 */
.matrix-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
table.matrix { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 640px; font-size: 14px; }
.matrix th, .matrix td {
  padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
  text-align: right;
}
.matrix th { position: sticky; top: 0; background: var(--card); font-size: 12px; color: var(--muted); font-weight: 600; z-index: 2; }
.matrix th:first-child, .matrix td:first-child {
  position: sticky; left: 0; text-align: left; background: var(--card); z-index: 1; max-width: 200px;
}
.matrix th:first-child { z-index: 3; }
.matrix thead th { color: var(--muted); }
.matrix thead th b { color: var(--text); font-size: 13px; }
.matrix td.vname { font-weight: 600; }
.matrix td.vname .y { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.matrix td.price { font-variant-numeric: tabular-nums; }
.matrix td.price.max { font-weight: 700; color: var(--accent-strong); }
.matrix td.price .n { display: block; font-size: 10px; color: var(--muted); font-weight: 400; }
.matrix td.upd { font-size: 11px; color: var(--muted); }
.matrix tbody tr:hover td { background: var(--accent-soft); }
.matrix tbody tr:hover td:first-child { background: var(--accent-soft); }
.vnote { font-size: 12px; color: var(--muted); margin-top: 4px; }

.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend i { font-style: normal; display: inline-flex; align-items: center; gap: 5px; }
.legend .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }

/* 维修表 */
table.repair { border-collapse: collapse; width: 100%; font-size: 14px; }
.repair th, .repair td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.repair th { color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.repair td.cost { white-space: nowrap; font-weight: 600; color: var(--accent-strong); font-variant-numeric: tabular-nums; }
.repair .note { font-size: 12px; color: var(--muted); }
.repair-group-title { font-weight: 700; margin: 18px 0 8px; font-size: 15px; }

/* ---------- 管理页 ---------- */
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; margin-bottom: 14px; }
.seg button {
  flex: 1; padding: 7px 0; border: 0; border-radius: 9px; background: transparent;
  color: var(--muted); font-size: 14px; cursor: pointer;
}
.seg button.on { background: var(--accent); color: #fff; font-weight: 600; }
.admin-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 4px;
  border-bottom: 1px dashed var(--line); font-size: 14px;
}
.admin-row .mid { flex: 1; min-width: 0; }
.admin-row .nm { font-weight: 600; }
.admin-row .sub { font-size: 12px; color: var(--muted); }
.admin-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* variant 编辑卡片 */
.variant-box { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px; background: var(--bg); }
.variant-box .vhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.variant-box .vhead b { font-size: 14px; }
.price-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 12px; }
@media (min-width: 640px) { .price-grid { grid-template-columns: repeat(5, 1fr); } }
.price-grid .pc { border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: var(--card); }
.price-grid .pc label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.price-grid .pc input { padding: 5px 8px; font-size: 14px; }
.kv-row { display: grid; grid-template-columns: 110px 1fr 34px; gap: 8px; margin-bottom: 8px; align-items: center; }
.kv-row button { height: 36px; }

/* ---------- 模态框 ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 10, 14, .5);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 640px) { .modal-overlay { align-items: center; } }
.modal {
  background: var(--card); width: 100%; max-width: 720px; max-height: 88vh;
  border-radius: 18px 18px 0 0; display: flex; flex-direction: column;
}
@media (min-width: 640px) { .modal { border-radius: 18px; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 10px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.modal-head b { font-size: 16px; }
.modal-close {
  border: 0; background: transparent; font-size: 22px; color: var(--muted);
  cursor: pointer; line-height: 1; padding: 4px 8px;
}
.modal-body { padding: 14px 18px; overflow-y: auto; }
.modal-foot {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 12px 18px; padding-bottom: calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); flex-shrink: 0;
}

/* ---------- Toast ---------- */
#toast-root { position: fixed; top: calc(14px + env(safe-area-inset-top)); left: 0; right: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: #2e7d32; color: #fff; padding: 9px 18px; border-radius: 999px;
  font-size: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.25); opacity: 0; transform: translateY(-8px);
  transition: all .25s ease; max-width: 86vw;
}
.toast.show { opacity: 1; transform: none; }
.toast.err { background: var(--danger); }

/* ---------- 其他 ---------- */
.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 14px; }
.backup-actions { display: flex; flex-direction: column; gap: 10px; }
@media (min-width: 640px) { .backup-actions { flex-direction: row; } }
.footer-note { text-align: center; color: var(--muted); font-size: 12px; margin-top: 30px; }
