/* ===== 居酒屋 · 藏酒庫存管理 ===== */
:root {
  --bg: #16110d;
  --bg-soft: #1e1712;
  --panel: #241b15;
  --panel-2: #2c2118;
  --line: #3a2c21;
  --line-soft: #302419;
  --text: #f2e8dd;
  --muted: #a99684;
  --muted-2: #7d6a58;
  --gold: #e0a53f;
  --gold-soft: #f3c874;
  --red: #d9573f;
  --red-soft: #f0735c;
  --green: #6fae7c;
  --wood: #6d4c33;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 62px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* hidden 属性必须压过组件自身的 display，否则弹窗/表格切换会失效 */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans GB", "PingFang SC", "Microsoft JhengHei", "Noto Sans TC", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overscroll-behavior-y: none;
}

body {
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px);
  background-image:
    radial-gradient(900px 460px at 50% -180px, rgba(224,165,63,.16), transparent 70%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.014) 0 2px, transparent 2px 7px);
  background-attachment: fixed;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--gold-soft); text-decoration: none; }
code { color: var(--gold-soft); font-size: .92em; }

/* ---------- App bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 40;
  background: linear-gradient(180deg, rgba(30,23,18,.97), rgba(22,17,13,.94));
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.appbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px 8px;
  max-width: 1100px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.lantern {
  width: 12px; height: 30px; border-radius: 7px; flex: 0 0 auto;
  background: linear-gradient(180deg, var(--red-soft), #a8352a);
  box-shadow: 0 0 16px rgba(217,87,63,.6), inset 0 0 6px rgba(255,220,180,.35);
  position: relative;
}
.lantern::before, .lantern::after {
  content: ''; position: absolute; left: -2px; right: -2px; height: 3px;
  background: #2a1d14; border-radius: 2px;
}
.lantern::before { top: 5px; } .lantern::after { bottom: 5px; }
.brand-text h1 {
  margin: 0; font-size: 20px; letter-spacing: 3px; font-weight: 700;
  background: linear-gradient(90deg, var(--gold-soft), var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-text p { margin: 1px 0 0; font-size: 11.5px; color: var(--muted-2); letter-spacing: 1px; }

.icon-btn {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  cursor: pointer; transition: .16s;
}
.icon-btn svg { fill: currentColor; }
.icon-btn:active { transform: scale(.93); background: var(--panel); }

.stats-strip {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  padding: 0 16px 12px; max-width: 1100px; margin: 0 auto;
}
/* 窄屏改 2×2，避免数值被 nowrap 撑破视口导致横向滚动 */
@media (max-width: 620px) {
  .stats-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value { font-size: 15px; }
  .brand-text h1 { font-size: 18px; }
}

.stat {
  background: linear-gradient(160deg, var(--panel), #1d1611);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 10px; min-width: 0;
}
.stat-label { display: block; font-size: 10.5px; color: var(--muted-2); letter-spacing: .6px; }
.stat-value {
  display: block; font-size: 15px; font-weight: 700; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.stat-value.gold { color: var(--gold); }
.stat-value.alert { color: var(--red-soft); }

/* ---------- views ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 14px 14px 30px; }
.view { display: none; animation: fade .22s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- toolbar ---------- */
.toolbar { display: grid; gap: 10px; margin-bottom: 12px; }
.searchbox {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 0 12px; height: 44px;
}
.searchbox svg { fill: var(--muted-2); flex: 0 0 auto; }
.searchbox input {
  flex: 1; min-width: 0; background: transparent; border: 0; outline: none; font-size: 15px;
}
.searchbox input::-webkit-search-cancel-button { display: none; }
.clear-btn {
  background: none; border: 0; color: var(--muted-2); cursor: pointer; font-size: 14px; padding: 4px;
}
.sort-select {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; height: 40px; padding: 0 10px; outline: none;
}
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; background: var(--panel); border: 1px solid var(--line);
  color: var(--muted); border-radius: 999px; padding: 6px 14px; font-size: 13px; cursor: pointer;
  transition: .16s;
}
.chip.active { background: rgba(224,165,63,.14); border-color: var(--gold); color: var(--gold-soft); }

/* ---------- category tabs ---------- */
.cat-tabs {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
  flex: 0 0 auto; display: flex; align-items: baseline; gap: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 13px; cursor: pointer; transition: .16s; white-space: nowrap;
}
.cat-tab span.n { font-weight: 600; font-size: 14px; }
.cat-tab span.c { font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.cat-tab.active {
  background: linear-gradient(160deg, rgba(224,165,63,.2), rgba(224,165,63,.06));
  border-color: var(--gold); color: var(--gold-soft);
}
.cat-tab.active span.c { color: rgba(243,200,116,.75); }

.list-meta {
  font-size: 12px; color: var(--muted-2); margin: 2px 2px 10px; letter-spacing: .4px;
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}

/* ---------- item cards ---------- */
.item-list { display: grid; gap: 10px; }
@media (min-width: 760px) { .item-list { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1080px) { .item-list { grid-template-columns: 1fr 1fr 1fr; } }

.item {
  background: linear-gradient(165deg, var(--panel), #201812);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 13px; position: relative; overflow: hidden;
  transition: border-color .18s, transform .18s;
}
.item::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--wood); opacity: .85;
}
.item.is-high::after { background: linear-gradient(180deg, var(--gold), #8a5a1c); }
.item.is-out { opacity: .62; }
.item.is-out::after { background: var(--red); }
.item.is-low::after { background: var(--red-soft); }

.item-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.item-name { font-size: 16px; font-weight: 600; line-height: 1.3; word-break: break-word; }
.item-type {
  display: inline-block; font-size: 11px; color: var(--gold-soft); letter-spacing: .5px;
  background: rgba(224,165,63,.1); border: 1px solid rgba(224,165,63,.28);
  border-radius: 6px; padding: 1px 7px; margin-bottom: 4px;
}
.item-cat { font-size: 11px; color: var(--muted-2); }
.item-sub { font-size: 17px; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.item-price { font-size: 11px; color: var(--muted-2); text-align: right; font-variant-numeric: tabular-nums; }
.item-note { font-size: 12px; color: var(--muted); margin-top: 5px; word-break: break-word; }

.item-bottom {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 11px; padding-top: 10px; border-top: 1px dashed var(--line-soft); gap: 8px;
}
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 34px; height: 34px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font-size: 18px; line-height: 1; display: grid; place-items: center; transition: .14s;
}
.stepper button:active { transform: scale(.9); }
.stepper button.minus:hover { border-color: var(--red-soft); color: var(--red-soft); }
.stepper button.plus:hover { border-color: var(--green); color: var(--green); }
.qty {
  min-width: 46px; text-align: center; font-weight: 700; font-size: 16px;
  font-variant-numeric: tabular-nums; cursor: pointer; padding: 4px 2px; border-radius: 8px;
}
.qty:hover { background: var(--panel-2); }
.qty small { display: block; font-size: 9.5px; color: var(--muted-2); font-weight: 400; letter-spacing: .5px; }
.item-actions { display: flex; gap: 6px; }
.mini-btn {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 9px; width: 34px; height: 34px; display: grid; place-items: center;
  cursor: pointer; transition: .14s;
}
.mini-btn svg { fill: currentColor; }
.mini-btn:active { transform: scale(.9); }
.mini-btn:hover { color: var(--gold-soft); border-color: var(--gold); }
.mini-btn.danger:hover { color: var(--red-soft); border-color: var(--red); }
.badge-out {
  font-size: 10px; color: var(--red-soft); border: 1px solid rgba(217,87,63,.4);
  background: rgba(217,87,63,.1); border-radius: 6px; padding: 1px 6px; margin-left: 6px;
}
.badge-low { color: var(--red-soft); border-color: rgba(217,87,63,.4); background: rgba(217,87,63,.1); }

/* ---------- cards / stats ---------- */
.card {
  background: linear-gradient(165deg, var(--panel), #1e1712);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.card-title { margin: 0 0 12px; font-size: 14px; letter-spacing: 1.2px; color: var(--gold-soft); font-weight: 600; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head .card-title { margin: 0; }
.muted { color: var(--muted-2); }
.small { font-size: 12px; }

.chart { display: grid; gap: 11px; }
.bar-row .bar-label { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; }
.bar-label b { color: var(--gold); font-variant-numeric: tabular-nums; font-weight: 600; }
.bar-track { height: 9px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; border: 1px solid var(--line-soft); }
.bar-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #8a5a1c, var(--gold));
  transition: width .5s cubic-bezier(.3,1,.4,1); min-width: 2px;
}
.bar-meta { font-size: 11px; color: var(--muted-2); margin-top: 3px; font-variant-numeric: tabular-nums; }

.rank-list { margin: 0; padding-left: 20px; }
.rank-list li { padding: 6px 0; border-bottom: 1px dashed var(--line-soft); display: flex; gap: 8px; font-size: 13.5px; }
.rank-list li:last-child { border-bottom: 0; }
.rank-list .rk-name { flex: 1; min-width: 0; }
.rank-list .rk-val { color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-list .rk-sub { display: block; font-size: 11px; color: var(--muted-2); }

.alert-list { display: grid; gap: 8px; }
.alert-item {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  background: var(--bg-soft); border: 1px solid var(--line-soft); border-radius: 10px; padding: 9px 11px;
}
.alert-item .an { font-size: 13.5px; }
.alert-item .an small { display: block; color: var(--muted-2); font-size: 11px; }
.alert-item .aq { font-weight: 700; color: var(--red-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- logs ---------- */
.log-list { display: grid; gap: 8px; max-height: 62vh; overflow-y: auto; }
.log-item {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--bg-soft); border: 1px solid var(--line-soft);
  border-radius: 10px; padding: 9px 11px;
}
.log-delta {
  flex: 0 0 auto; min-width: 44px; text-align: center; font-weight: 700;
  border-radius: 8px; padding: 3px 6px; font-size: 13px; font-variant-numeric: tabular-nums;
}
.log-delta.up { background: rgba(111,174,124,.14); color: var(--green); border: 1px solid rgba(111,174,124,.3); }
.log-delta.down { background: rgba(217,87,63,.14); color: var(--red-soft); border: 1px solid rgba(217,87,63,.32); }
.log-body { flex: 1; min-width: 0; }
.log-name { font-size: 13.5px; word-break: break-word; }
.log-sub { font-size: 11px; color: var(--muted-2); margin-top: 2px; }

/* ---------- manage list ---------- */
.manage-list { display: grid; gap: 9px; }
.mg-item {
  display: flex; align-items: center; gap: 9px;
  background: var(--bg-soft); border: 1px solid var(--line-soft); border-radius: 11px; padding: 10px 11px;
}
.mg-name { flex: 1; min-width: 0; }
.mg-name input {
  width: 100%; background: transparent; border: 1px solid transparent; border-radius: 7px;
  padding: 4px 7px; font-size: 14px; font-weight: 600; outline: none;
}
.mg-name input:focus { border-color: var(--gold); background: var(--panel); }
.mg-name small { display: block; color: var(--muted-2); font-size: 11px; padding-left: 8px; font-variant-numeric: tabular-nums; }
.mg-btns { display: flex; gap: 5px; flex: 0 0 auto; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.file-btn {
  display: inline-block; cursor: pointer; border: 1px dashed var(--line);
  border-radius: 11px; padding: 9px 13px; font-size: 13px; color: var(--muted); text-align: center;
}
.file-btn:active { background: var(--panel); }

.ghost-btn {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 11px; padding: 9px 14px; cursor: pointer; font-size: 13.5px; transition: .15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.ghost-btn:hover { border-color: var(--gold); color: var(--gold-soft); }
.ghost-btn:active { transform: scale(.96); }
.ghost-btn.danger:hover { border-color: var(--red); color: var(--red-soft); }
.primary-btn {
  background: linear-gradient(160deg, var(--gold), #b67d20); border: 0; color: #23180a;
  border-radius: 11px; padding: 10px 18px; cursor: pointer; font-weight: 700; font-size: 14.5px;
  transition: .15s;
}
.primary-btn:active { transform: scale(.96); }

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: 18px; z-index: 35;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  width: 56px; height: 56px; border-radius: 18px; border: 0; cursor: pointer;
  background: linear-gradient(160deg, var(--red-soft), #a8352a);
  color: #fff; display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(217,87,63,.42), inset 0 1px 0 rgba(255,255,255,.22);
  transition: .16s;
}
.fab svg { fill: currentColor; }
.fab:active { transform: scale(.92); }

/* ---------- tabbar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: linear-gradient(180deg, rgba(30,23,18,.92), rgba(20,15,11,.99));
  backdrop-filter: blur(16px); border-top: 1px solid var(--line);
}
.tab {
  background: none; border: 0; color: var(--muted-2); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 10.5px; letter-spacing: .6px; transition: .16s; padding: 6px 0;
}
.tab svg { fill: currentColor; }
.tab.active { color: var(--gold); }
.tab:active { transform: scale(.92); }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: end center; }
.modal-mask { position: absolute; inset: 0; background: rgba(8,5,3,.68); backdrop-filter: blur(3px); animation: fade .18s; }
.modal-panel {
  position: relative; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  background: linear-gradient(180deg, #241b15, #1b1410);
  border: 1px solid var(--line); border-bottom: 0;
  border-radius: 20px 20px 0 0; padding: 16px 16px calc(18px + var(--safe-b));
  animation: slideup .24s cubic-bezier(.2,.9,.3,1);
}
@keyframes slideup { from { transform: translateY(28px); opacity: .5; } to { transform: none; opacity: 1; } }
@media (min-width: 700px) {
  .modal { place-items: center; }
  .modal-panel { border-radius: 20px; border-bottom: 1px solid var(--line); max-height: 86vh; }
}
.modal-panel.narrow { max-width: 420px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 16px; letter-spacing: 1px; color: var(--gold-soft); }

.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 6px; font-size: 12.5px; color: var(--muted); }
.form input, .form select {
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 11px;
  padding: 11px 12px; font-size: 15px; outline: none; color: var(--text); width: 100%;
}
.form input:focus, .form select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(224,165,63,.12); }
.form-row { display: grid; gap: 12px; }
@media (min-width: 520px) { .form-row { grid-template-columns: 1fr 1fr; } }
.form-actions { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.spacer { flex: 1; }
.adjust-target { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.quick-delta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick-delta button {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px;
  padding: 9px 0; cursor: pointer; font-weight: 600; transition: .14s;
}
.quick-delta button:active { transform: scale(.94); }
.quick-delta button:hover { border-color: var(--gold); color: var(--gold-soft); }

/* ---------- misc ---------- */
.empty { text-align: center; color: var(--muted-2); padding: 40px 16px; font-size: 14px; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 90;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 22px);
  background: rgba(30,23,18,.97); border: 1px solid var(--gold);
  color: var(--gold-soft); padding: 11px 18px; border-radius: 13px; font-size: 13.5px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: fade .2s; max-width: 88vw; text-align: center;
}
.toast.err { border-color: var(--red); color: var(--red-soft); }
.loading { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; background: rgba(10,7,5,.4); }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(224,165,63,.25); border-top-color: var(--gold);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= 管理后台：顶栏动作 & 在线指示 ================= */
.appbar-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.live-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 0 0 rgba(111,174,124,.6); animation: pulse 2.2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(111,174,124,.55); }
  70%  { box-shadow: 0 0 0 9px rgba(111,174,124,0); }
  100% { box-shadow: 0 0 0 0 rgba(111,174,124,0); }
}
.live-dot.stale { background: var(--red-soft); animation: none; }
.live-dot.syncing { background: var(--gold); animation: pulse 1s infinite; }

/* ================= 数据表格（PC 管理后台） ================= */
.table-wrap {
  overflow: auto; max-height: 72vh;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg-soft);
}
.table-wrap[hidden] { display: none; }
.table-wrap.show { max-height: none; }
.data-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 13.5px; font-variant-numeric: tabular-nums;
}
.data-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: linear-gradient(180deg, #2c2118, #241b15);
  color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: .6px;
  text-align: left; padding: 11px 12px; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.data-table td {
  padding: 9px 12px; border-bottom: 1px solid var(--line-soft);
  vertical-align: middle; color: var(--text);
}
.data-table tbody tr:hover td { background: rgba(224,165,63,.055); }
.data-table tbody tr.out td { opacity: .55; }
.data-table tbody tr:last-child td { border-bottom: 1px solid var(--line); }

.data-table .c-num, .data-table .c-qty, .data-table .c-act { text-align: right; }
.data-table .c-qty { text-align: center; white-space: nowrap; }
.data-table th.c-num, .data-table th.c-qty, .data-table th.c-act { text-align: right; }
.data-table th.c-qty { text-align: center; }
.data-table .c-cat { white-space: nowrap; color: var(--muted); }
.data-table .c-type { white-space: nowrap; }
.data-table .c-name { font-weight: 600; min-width: 130px; }
.data-table .c-note { color: var(--muted-2); font-size: 12.5px; max-width: 220px; }
.data-table .sub { color: var(--gold); font-weight: 700; }
.data-table .price { color: var(--muted); }
.data-table .tbl-cat {
  display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 6px;
  background: rgba(224,165,63,.08); border: 1px solid rgba(224,165,63,.2); color: var(--gold-soft);
}
.tbl-stepper { display: inline-flex; align-items: center; gap: 3px; }
.tbl-stepper button {
  width: 26px; height: 26px; border-radius: 8px; cursor: pointer; line-height: 1;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-size: 15px;
}
.tbl-stepper button:hover { border-color: var(--gold); color: var(--gold-soft); }
.tbl-stepper .n { min-width: 34px; text-align: center; font-weight: 700; }
.tbl-acts { display: inline-flex; gap: 5px; justify-content: flex-end; }
.tbl-acts button {
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer; display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--muted);
}
.tbl-acts button svg { fill: currentColor; }
.tbl-acts button:hover { border-color: var(--gold); color: var(--gold-soft); }
.tbl-acts button.danger:hover { border-color: var(--red); color: var(--red-soft); }

.data-table tfoot td, .data-table tfoot th {
  position: sticky; bottom: 0;
  background: linear-gradient(0deg, #2c2118, #241b15);
  font-weight: 700; padding: 11px 12px; border-top: 1px solid var(--line);
  color: var(--gold-soft); white-space: nowrap;
}
.summary-table tbody tr { cursor: pointer; }
@media (max-width: 620px) {
  /* 手机上优先保证「品类 / 款数 / 瓶数 / 合计价值」可见，隐藏平均单价列 */
  .summary-table th:nth-child(6), .summary-table td:nth-child(6) { display: none; }
  .summary-table tbody tr .bar-mini { min-width: 34px; }
  .data-table th, .data-table td { padding: 9px 8px; }
}

.summary-table tbody tr .bar-mini {
  height: 6px; border-radius: 999px; background: var(--bg);
  border: 1px solid var(--line-soft); overflow: hidden; min-width: 60px;
}
.summary-table tbody tr .bar-mini i {
  display: block; height: 100%; background: linear-gradient(90deg, #8a5a1c, var(--gold));
}

/* ================= 合计卡片 ================= */
.total-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 700px) { .total-grid { grid-template-columns: repeat(4, 1fr); } }
.total-cell {
  background: var(--bg-soft); border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px 13px;
}
.total-cell .tl { display: block; font-size: 11.5px; color: var(--muted-2); letter-spacing: .6px; }
.total-cell .tv {
  display: block; font-size: 20px; font-weight: 700; margin-top: 4px;
  font-variant-numeric: tabular-nums; color: var(--text);
}
.total-cell .tv.gold { color: var(--gold); }
.total-cell .ts { display: block; font-size: 11px; color: var(--muted-2); margin-top: 2px; }
.total-cell.hero { grid-column: 1 / -1; }
@media (min-width: 700px) { .total-cell.hero { grid-column: span 2; } }
.total-cell.hero .tv { font-size: 28px; }

/* ================= PC 端：侧边导航 + 宽表格 ================= */
@media (min-width: 900px) {
  body { padding-bottom: 24px; }
  main { max-width: 1380px; padding: 18px 20px 40px 104px; }
  .appbar-inner, .stats-strip { max-width: 1380px; }
  .stats-strip { grid-template-columns: repeat(4, minmax(0, 200px)); justify-content: start; }
  .toolbar { grid-template-columns: minmax(260px, 1fr) 190px auto; align-items: center; gap: 12px; }
  .tabbar {
    top: 50%; left: 0; right: auto; bottom: auto; transform: translateY(-50%);
    width: 78px; height: auto; grid-template-columns: 1fr; grid-auto-rows: auto;
    border: 1px solid var(--line); border-left: 0; border-radius: 0 16px 16px 0;
    padding: 10px 0; gap: 4px; background: linear-gradient(180deg, rgba(30,23,18,.96), rgba(20,15,11,.99));
  }
  .tab { padding: 14px 0; font-size: 11px; }
  .item-list { grid-template-columns: 1fr 1fr 1fr; }
  .fab { right: 32px; bottom: 32px; }
  .toast { bottom: 34px; }
  .item-list[hidden] { display: none; }
  .summary-table { font-size: 14px; }
  .data-table thead th { padding: 12px; }
  .data-table td { padding: 10px 12px; }
}


/* PC 表格模式下隐藏卡片列表 */
#itemList.table-mode { display: none !important; }

/* ================= 新增品类行 ================= */
.add-cat { display: flex; gap: 8px; margin-top: 6px; }
.add-cat input {
  flex: 1; min-width: 0; color: var(--text);
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 11px; padding: 10px 12px; outline: none;
}
.add-cat input:focus { border-color: var(--gold); }
.list-meta b { color: var(--text); }
.gold { color: var(--gold); }

/* ================= 瓶档案（每瓶唯一 ID） ================= */
@media (max-width: 420px) { .tab { font-size: 9.5px; letter-spacing: 0; } .tab svg { width: 20px; height: 20px; } }

.modal-panel.wide { max-width: 720px; }
.mh-text { min-width: 0; }
.mh-text h3 { margin: 0; font-size: 16px; letter-spacing: 1px; color: var(--gold-soft); }
.bm-sub { margin: 3px 0 0; font-size: 12px; color: var(--muted-2); font-variant-numeric: tabular-nums; }

.bm-toolbar {
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
  margin-bottom: 10px; flex-wrap: wrap;
}
.bm-toolbar .chip-row { flex: 1; min-width: 0; }
.bm-add-toggle { flex: 0 0 auto; }

.bm-add {
  background: var(--bg-soft); border: 1px solid var(--gold);
  border-radius: 12px; padding: 12px; margin-bottom: 12px;
  display: grid; gap: 10px;
}
.bm-add-grid { display: grid; gap: 10px; grid-template-columns: 90px 1fr 1fr; }
@media (max-width: 560px) { .bm-add-grid { grid-template-columns: 1fr 1fr; } }
.bm-add label { display: grid; gap: 5px; font-size: 12px; color: var(--muted); }
.bm-add input {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 10px; font-size: 14px; outline: none; color: var(--text); width: 100%;
}
.bm-add input:focus { border-color: var(--gold); }

.bm-bulk {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  background: rgba(224,165,63,.08); border: 1px solid rgba(224,165,63,.3);
  border-radius: 11px; padding: 8px 11px; font-size: 13px; color: var(--gold-soft);
}
.bm-bulk .bm-bulk-info { font-weight: 600; font-variant-numeric: tabular-nums; }
.bm-bulk select {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 6px 8px; font-size: 13px; outline: none;
}
.bm-bulk .ghost-btn { padding: 6px 12px; font-size: 13px; }

.bottle-list { display: grid; gap: 8px; }
.bottle-row {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 9px;
  background: var(--bg-soft); border: 1px solid var(--line-soft);
  border-left: 3px solid var(--wood);
  border-radius: 11px; padding: 10px 11px;
}
/* 照片条整行铺开：靠 order 排到最后，避免把右侧操作按钮挤到下一行 */
.bottle-row .bk-media { flex: 1 0 100%; order: 9; margin-top: 2px; }
.bottle-row.s-opened { border-left-color: var(--gold); }
.bottle-row.s-sold, .bottle-row.s-removed { opacity: .72; border-left-color: var(--muted-2); }
.bottle-row.picked { background: rgba(224,165,63,.1); border-color: var(--gold); }

.bk-check { flex: 0 0 auto; padding-top: 3px; }
.bk-check input { width: 17px; height: 17px; accent-color: var(--gold); cursor: pointer; }
.bk-check input:disabled { cursor: not-allowed; opacity: .35; }

.bk-main { flex: 1; min-width: 0; }
.bk-code {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  font-size: 15px; font-weight: 700; letter-spacing: .5px;
  font-variant-numeric: tabular-nums; color: var(--text);
}
.bk-code.mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }
.bk-status {
  font-size: 10.5px; font-weight: 500; letter-spacing: .3px; padding: 1px 7px; border-radius: 6px;
  border: 1px solid var(--line); color: var(--muted); background: var(--panel);
}
.bk-status.s-in_stock { color: var(--green); border-color: rgba(111,174,124,.45); background: rgba(111,174,124,.12); }
.bk-status.s-opened { color: var(--gold-soft); border-color: rgba(224,165,63,.45); background: rgba(224,165,63,.12); }
.bk-status.s-sold, .bk-status.s-removed { color: var(--muted-2); }

.bk-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 4px; }
.bk-meta span { white-space: nowrap; }
.bk-note { font-size: 12px; color: var(--muted); margin-top: 3px; word-break: break-word; }
.bk-time { font-size: 11px; color: var(--muted-2); margin-top: 3px; font-variant-numeric: tabular-nums; }

.bk-acts { display: flex; gap: 5px; flex: 0 0 auto; }
.bk-acts button {
  width: 30px; height: 30px; border-radius: 9px; cursor: pointer; display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); transition: .14s;
}
.bk-acts button svg { fill: currentColor; }
.bk-acts button:hover { border-color: var(--gold); color: var(--gold-soft); }
.bk-acts button.danger:hover { border-color: var(--red); color: var(--red-soft); }
.bk-acts button:active { transform: scale(.9); }

/* 全局瓶档案视图 */
.bottle-grid { display: grid; gap: 9px; }
@media (min-width: 760px) { .bottle-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1200px) { .bottle-grid { grid-template-columns: 1fr 1fr 1fr; } }
.bottle-grid .bk-item {
  display: flex; gap: 9px; align-items: flex-start;
  background: linear-gradient(165deg, var(--panel), #201812);
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px;
  border-left: 3px solid var(--wood); cursor: pointer; transition: .16s;
}
.bottle-grid .bk-item:hover { border-color: var(--gold); }
.bottle-grid .bk-item.s-opened { border-left-color: var(--gold); }
.bottle-grid .bk-item.s-sold, .bottle-grid .bk-item.s-removed { opacity: .68; border-left-color: var(--muted-2); }
.bk-item .bk-wine { font-size: 13px; color: var(--text); margin-top: 4px; word-break: break-word; }
.bk-item .bk-path { font-size: 11px; color: var(--muted-2); margin-top: 2px; }

.toolbar.compact { gap: 8px; }
@media (min-width: 900px) { .toolbar.compact { grid-template-columns: minmax(260px, 1fr) auto; } }

/* ================= 瓶身照片 ================= */
.bk-media { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.bk-thumb {
  width: 56px; height: 56px; padding: 0; cursor: pointer; position: relative;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: var(--panel); display: grid; place-items: center;
}
.bk-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bk-thumb:hover { border-color: var(--gold); }
.bk-thumb:active { transform: scale(.94); }
.bk-thumb.add {
  color: var(--muted-2); font-size: 20px; line-height: 1;
  border-style: dashed; background: transparent;
}
.bk-thumb.add:hover { color: var(--gold-soft); }
.bk-thumb.busy::after {
  content: ''; position: absolute; inset: 0;
  background: rgba(10,7,5,.6) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23e0a53f' d='M12 4V2a10 10 0 0 0 0 20v-2a8 8 0 0 1 0-16z'/%3E%3C/svg%3E") center/18px no-repeat;
  animation: spin 1s linear infinite;
}
.bk-count { font-size: 11px; color: var(--muted-2); align-self: center; margin-left: 2px; }

/* 灯箱 */
#photoModal { place-items: stretch; z-index: 70; }
.photo-panel {
  position: relative; width: 100%; height: 100%;
  display: grid; grid-template-rows: 1fr auto; place-items: center;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 12px calc(12px + var(--safe-b));
  animation: fade .18s;
}
#photoImg {
  max-width: 100%; max-height: 100%; object-fit: contain;
  border-radius: 12px; background: #0b0806;
  box-shadow: 0 20px 60px rgba(0,0,0,.7);
}
.photo-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 44px; height: 44px; border-radius: 50%; cursor: pointer;
  background: rgba(36,27,21,.85); border: 1px solid var(--line); color: var(--gold-soft);
  font-size: 26px; line-height: 1; display: grid; place-items: center;
}
.photo-nav:hover { border-color: var(--gold); }
.photo-nav.prev { left: 10px; }
.photo-nav.next { right: 10px; }
.photo-bar {
  display: flex; align-items: center; gap: 8px; width: 100%; max-width: 720px;
  margin-top: 10px; padding: 8px 12px; border-radius: 12px;
  background: rgba(30,23,18,.94); border: 1px solid var(--line);
}
.photo-cap { font-size: 12px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#photoModal .modal-mask { background: rgba(4,3,2,.9); }

/* 全局瓶档案卡片里的封面 */
.bk-item .bk-cover {
  width: 54px; height: 54px; flex: 0 0 auto; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line); background: var(--bg-soft); display: grid; place-items: center;
  color: var(--muted-2); font-size: 16px;
}
.bk-item .bk-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ================= 备份面板 ================= */
.backup-status {
  background: var(--bg-soft); border: 1px solid var(--line-soft); border-left: 3px solid var(--green);
  border-radius: 11px; padding: 10px 12px; font-size: 13px; margin-bottom: 10px;
  line-height: 1.7;
}
.backup-status.stale { border-left-color: var(--red-soft); }
.backup-status b { color: var(--gold); }
.backup-list { display: grid; gap: 6px; max-height: 260px; overflow-y: auto; }
.backup-row {
  display: flex; align-items: center; gap: 9px; font-size: 12.5px;
  background: var(--bg-soft); border: 1px solid var(--line-soft); border-radius: 9px; padding: 7px 10px;
}
.backup-row .bf-file { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.backup-row .bf-time { color: var(--muted-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.backup-row .bf-size { color: var(--muted-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.backup-row.media { border-left: 3px solid var(--gold); }




