/* ==========================================================================
   寿司店数据平台 · 样式
   设计取向：白底、深墨蓝、暖金一条强调色。信息密度按「店主每天看三次」来排，
   不做大色块卡片堆叠（那种看着热闹、实际扫不出数字）。
   ========================================================================== */

:root {
  --ink: #101828;
  --ink-2: #344054;
  --ink-3: #667085;
  --ink-4: #98a2b3;
  --line: #e4e7ec;
  --line-2: #f2f4f7;
  --bg: #fbfaf8;
  --card: #ffffff;
  --navy: #16283f;
  --navy-2: #223c5c;
  --gold: #b8862f;
  --gold-soft: #f6efe1;
  --red: #b42318;
  --red-soft: #fef3f2;
  --green: #067647;
  --green-soft: #ecfdf3;
  --amber: #b54708;
  --amber-soft: #fffaeb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .10);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--navy-2); }

button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- 布局骨架 ---------- */

.app { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px; height: 56px;
  background: var(--navy); color: #fff;
  position: sticky; top: 0; z-index: 30;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: .2px; }
.brand .mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(140deg, var(--gold), #d9a94e);
  display: grid; place-items: center; color: var(--navy);
  font-weight: 800; font-size: 13px;
}
.brand small { font-weight: 400; opacity: .62; margin-left: 6px; font-size: 12px; }

.topnav { display: flex; gap: 2px; margin-left: 12px; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a {
  color: rgba(255, 255, 255, .72); text-decoration: none;
  padding: 7px 12px; border-radius: 7px; font-size: 14px; white-space: nowrap;
}
.topnav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.topnav a.active { background: rgba(255, 255, 255, .14); color: #fff; font-weight: 600; }

.topbar .spacer { flex: 1; }
.who { font-size: 13px; opacity: .8; display: flex; align-items: center; gap: 10px; }
.who .role { background: rgba(255, 255, 255, .14); padding: 2px 8px; border-radius: 20px; font-size: 11px; }

.main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 22px 20px 64px; }
.wide .main { max-width: 1500px; }

/* ---------- 通用元件 ---------- */

h1 { font-size: 21px; margin: 0 0 4px; letter-spacing: -.2px; }
h2 { font-size: 16px; margin: 26px 0 10px; }
h3 { font-size: 14px; margin: 18px 0 8px; color: var(--ink-2); }
.sub { color: var(--ink-3); font-size: 13px; margin: 0 0 18px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px;
}
.card.tight { padding: 0; overflow: hidden; }
.card-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px; border-bottom: 1px solid var(--line-2);
}
.card-head h2 { margin: 0; font-size: 15px; }
.card-head .spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 16px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-size: 14px; font-weight: 500; text-decoration: none;
  transition: background .15s, border-color .15s, transform .02s;
  white-space: nowrap;
}
.btn:hover { background: #fafbfc; border-color: #d0d5dd; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.gold:hover { background: #a4761f; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { color: var(--red); border-color: #fecdca; background: var(--red-soft); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; }
.btn.block { width: 100%; }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; color: var(--ink-3); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], select, textarea {
  width: 100%; height: 38px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  font-size: 14px; outline: none;
}
textarea { height: auto; padding: 9px 11px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(34, 60, 92, .08); }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; min-width: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button {
  border: 0; background: none; padding: 10px 14px; cursor: pointer;
  color: var(--ink-3); font-size: 14px; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button.active { color: var(--navy); border-bottom-color: var(--gold); font-weight: 600; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 20px; font-size: 12px;
  background: var(--line-2); color: var(--ink-2);
}
.chip.ok { background: var(--green-soft); color: var(--green); }
.chip.warn { background: var(--amber-soft); color: var(--amber); }
.chip.bad { background: var(--red-soft); color: var(--red); }
.chip.gold { background: var(--gold-soft); color: var(--gold); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
th { font-size: 12px; color: var(--ink-3); font-weight: 500; white-space: nowrap; background: #fcfcfd; }
tbody tr:hover { background: #fcfcfd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.money { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 13px; }
.table-wrap { overflow-x: auto; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .k { font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.kpi .v { font-size: 24px; font-weight: 650; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 13px; font-weight: 400; color: var(--ink-3); margin-left: 4px; }
.kpi .d { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

.empty { padding: 36px 20px; text-align: center; color: var(--ink-3); font-size: 14px; }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* 校验条 */
.checks { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; min-width: 0; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; padding: 7px 10px; border-radius: 7px; background: var(--line-2); min-width: 0; }
/* flex 子项默认 min-width:auto，长句会把整块撑出屏幕（手机上就是横向滚动条） */
.check > span { min-width: 0; overflow-wrap: anywhere; }
.check.ok { background: var(--green-soft); color: #05603a; }
.check.bad { background: var(--red-soft); color: #912018; }
.check.warn { background: #fff7e6; color: #8a5300; }
.check .mark { font-weight: 700; }
.check .lv { font-size: 11px; padding: 1px 6px; border-radius: 999px; background: #00000010; margin-left: 6px; }

/* 上传区 */
.dropzone {
  border: 1.5px dashed #cfd6df; border-radius: var(--radius);
  padding: 30px 20px; text-align: center; background: #fff;
  transition: border-color .15s, background .15s;
}
.dropzone.hot { border-color: var(--gold); background: var(--gold-soft); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; margin-top: 14px; }
.thumb { position: relative; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.thumb img { display: block; width: 100%; height: 104px; object-fit: cover; }
.thumb .st { position: absolute; left: 0; right: 0; bottom: 0; font-size: 11px; padding: 3px 6px; background: rgba(16, 24, 40, .72); color: #fff; }
.thumb .st.bad { background: rgba(180, 35, 24, .9); }
.thumb .st.ok { background: rgba(6, 118, 71, .9); }

/* 核对页 */
.review { display: grid; grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr); gap: 16px; align-items: start; }
.review .imgpane { position: sticky; top: 72px; }
.imgbox { background: #0f172a; border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 150px); }
.imgbox img { display: block; width: 100%; height: auto; }
.pager { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.pager button { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 5px 10px; font-size: 13px; cursor: pointer; }
.pager button.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* 行项目编辑表：固定列宽，描述列吃剩余空间（否则右侧金额列会被挤出可视区） */
.items-edit { table-layout: fixed; }
.items-edit td { padding: 4px 5px; }
.items-edit input { height: 32px; font-size: 13px; padding: 0 6px; width: 100%; }
.items-edit td.low { background: #fffbea; }
.items-edit th { padding: 8px 5px; }
.items-edit td.desc, .items-edit th.desc { width: auto; min-width: 0; }
@media (max-width: 1100px) {
  .items-edit { table-layout: auto; }
  .items-edit input { min-width: 62px; }
}

@media (max-width: 980px) {
  .review { grid-template-columns: minmax(0, 1fr); }
  .review .imgpane { position: static; }
  .imgbox { max-height: 45vh; }
}

/* 登录 */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background:
  radial-gradient(1200px 600px at 50% -10%, #1d3350 0%, #101c2b 55%, #0b1420 100%); }
.login { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; padding: 28px; box-shadow: var(--shadow-lg); }
.login h1 { font-size: 19px; margin-bottom: 2px; }
.login .sub { margin-bottom: 22px; }
.login .mark { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--gold), #d9a94e); color: var(--navy); font-weight: 800; margin-bottom: 14px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 14px; box-shadow: var(--shadow-lg); z-index: 99; max-width: 90vw;
}
.toast.bad { background: #7a271a; }

.hint { font-size: 12px; color: var(--ink-3); }
.bar { height: 6px; border-radius: 4px; background: var(--line-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--gold); }

/* 移动端：顶部导航变底部 tab bar */
@media (max-width: 720px) {
  .topbar { height: 52px; padding: 0 14px; }
  .brand small { display: none; }
  .who .name { display: none; }
  .main { padding: 16px 14px 84px; }
  .topnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    margin: 0; background: #fff; border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around; box-shadow: 0 -2px 10px rgba(16,24,40,.06);
  }
  .topnav a { color: var(--ink-3); font-size: 11px; padding: 6px 8px; border-radius: 8px; }
  .topnav a.active { color: var(--navy); background: var(--gold-soft); font-weight: 600; }
  .review { grid-template-columns: minmax(0, 1fr); }
  .review .imgpane { position: static; }
  .imgbox { max-height: 42vh; }
  h1 { font-size: 19px; }
  .kpi .v { font-size: 21px; }
  .hide-sm { display: none; }
}

/* 长文本单行截断（供货商名、商品名）—— 手机上不这样处理会把表格撑变形 */
.trunc { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 720px) { .trunc { max-width: 120px; } }

/* 待识别队列：上传后立刻能看见，而不是「传了却没反应」 */
.thumbstrip { display: flex; gap: 10px; padding: 4px 16px 8px; overflow-x: auto; }
.thumb { margin: 0; flex: 0 0 96px; }
.thumb img, .thumb-ph {
  width: 96px; height: 72px; object-fit: cover; border-radius: 6px;
  background: var(--line-2); border: 1px solid var(--line); display: block;
}
.thumb-ph { display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); }
.thumb figcaption { font-size: 11px; color: var(--muted); margin-top: 4px; display: flex; gap: 4px; flex-wrap: wrap; }
.thumb .st { padding: 0 5px; border-radius: 999px; background: #fff3cd; color: #8a5300; }
.thumb .st.busy { background: #e0f2fe; color: #075985; }
.thumb.more { display: flex; align-items: center; justify-content: center; width: 96px; height: 72px;
  border-radius: 6px; border: 1px dashed var(--line); color: var(--muted); font-size: 13px; }
@media (max-width: 720px) { .thumb, .thumb img, .thumb-ph { width: 78px; } .thumb img, .thumb-ph { height: 60px; } }
