/* ============ 然也手作烘焙台账 · 样式 ============ */

:root {
  --bg: #f4ede2;
  --surface: #fffdf8;
  --surface-2: #faf4e9;
  --ink: #2c211a;
  --ink-2: #5d4a3d;
  --muted: #8c7968;
  --line: #e8ddcc;
  --line-strong: #dbc9b3;
  --brand: #b23b2e;
  --brand-dark: #8d2a20;
  --brand-soft: #f7e4dd;
  --green: #2f7d5b;
  --green-soft: #e5f2ea;
  --amber: #a9761e;
  --amber-soft: #f7ecd6;
  --red: #bd3a2c;
  --red-soft: #fae5e1;
  --shadow-sm: 0 1px 2px rgba(74, 52, 38, .04), 0 8px 24px rgba(74, 52, 38, .05);
  --shadow-md: 0 18px 48px rgba(74, 52, 38, .16);
  --radius: 18px;
  --radius-sm: 11px;
  --num-font: "Bahnschrift", "DIN Alternate", "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(1100px 500px at 8% -10%, rgba(178, 59, 46, .075), transparent 60%),
    radial-gradient(900px 480px at 100% 0%, rgba(169, 118, 30, .07), transparent 55%),
    var(--bg);
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, .btn, a { touch-action: manipulation; }
body.overlay-open { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { appearance: textfield; -moz-appearance: textfield; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
code { font-family: "Cascadia Mono", "Consolas", monospace; }
.icon { flex: none; vertical-align: -2px; }
.muted { color: var(--muted); }
.small-text { font-size: 12px; }
.text-good { color: var(--green) !important; }
.text-bad { color: var(--red) !important; }
.text-warn { color: var(--amber) !important; }

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 22px;
  height: calc(68px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 26px 0;
  background: rgba(251, 246, 237, .88);
  border-bottom: 1px solid rgba(216, 200, 178, .7);
  backdrop-filter: blur(16px) saturate(1.2);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: max-content; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  color: #fff8ee;
  background: linear-gradient(145deg, #c54a3a, #9a2e23);
  box-shadow: 0 6px 14px rgba(154, 46, 35, .28);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 16px; letter-spacing: .02em; }
.brand-text small { font-size: 11px; color: var(--muted); margin-top: 2px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav { display: flex; align-items: center; gap: 2px; margin: 0 auto; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .16s, color .16s;
}
.nav-link .icon { color: var(--muted); transition: color .16s; }
.nav-link:hover { background: rgba(232, 221, 204, .55); }
.nav-link.active { color: var(--brand-dark); background: var(--brand-soft); }
.nav-link.active .icon { color: var(--brand); }

.top-status { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.save-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  border-radius: 999px;
  padding: 4px 9px;
}
.save-status.saved { color: var(--green); background: var(--green-soft); }
.save-status.saving { color: var(--amber); background: var(--amber-soft); }
.save-status.error { color: var(--red); background: var(--red-soft); cursor: pointer; }
.today-label { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

.app-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.app-main { flex: 1; width: 100%; max-width: 1220px; margin: 0 auto; padding: 28px 28px 56px; }
.app-foot {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  padding: 0 20px 26px;
  color: var(--muted);
  font-size: 11.5px;
}
.app-foot a { color: var(--brand); }
.app-foot .dot { opacity: .45; }

.mobile-nav { display: none; }

/* ---------- 基础组件 ---------- */

.view { animation: viewIn .28s ease both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}
.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .16em;
  color: var(--brand);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.page-head h1 { font-size: clamp(25px, 2.8vw, 33px); line-height: 1.22; letter-spacing: -.5px; font-weight: 700; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 7px; max-width: 640px; }
.page-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition: transform .14s, background .14s, border-color .14s, box-shadow .14s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { color: #fff8f2; background: linear-gradient(180deg, #bd4638, #a63328); border-color: #a63328; box-shadow: 0 5px 14px rgba(166, 51, 40, .22); }
.btn.primary:hover { background: linear-gradient(180deg, #c94f40, #ac352a); }
.btn.ghost { color: var(--ink-2); background: rgba(255, 253, 248, .65); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--surface); border-color: #cbb69e; }
.btn.danger { color: #fff; background: var(--red); border-color: var(--red); }
.btn.danger-ghost { color: var(--red); background: transparent; border-color: #e6bdb7; }
.btn.danger-ghost:hover { background: var(--red-soft); }
.btn.small { height: 31px; padding: 0 11px; border-radius: 8px; font-size: 12.5px; }
.btn:disabled { opacity: .48; cursor: not-allowed; box-shadow: none; transform: none; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  transition: background .14s, color .14s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.danger-text:hover, .danger-text:hover { color: var(--red); background: var(--red-soft); }
.text-link { display: inline-flex; align-items: center; gap: 2px; color: var(--brand); font-size: 12.5px; font-weight: 600; background: none; border: 0; padding: 2px; }
.text-link:hover { color: var(--brand-dark); text-decoration: underline; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 16px; font-weight: 700; letter-spacing: -.1px; }
.card-head p { font-size: 12px; color: var(--muted); margin-top: 3px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.pill.good { color: var(--green); background: var(--green-soft); }
.pill.warn, .pill.low { color: var(--amber); background: var(--amber-soft); }
.pill.bad, .pill.out, .pill.negative { color: var(--red); background: var(--red-soft); }
.chip { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); font-size: 11px; margin-left: 7px; vertical-align: 1px; font-weight: 500; }
.chip.tiny { font-size: 10px; padding: 1px 6px; margin-left: 6px; }
.pill .icon { margin: 0; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { padding: 18px 19px; display: flex; flex-direction: column; gap: 5px; position: relative; overflow: hidden; }
.kpi::after {
  content: ""; position: absolute; right: -20px; top: -30px; width: 92px; height: 92px; border-radius: 50%;
  background: radial-gradient(circle, rgba(178, 59, 46, .05), transparent 70%);
}
.kpi-top { display: flex; align-items: center; gap: 8px; }
.kpi-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; margin-right: 2px; }
.kpi-icon.red { color: var(--brand); background: var(--brand-soft); }
.kpi-icon.green { color: var(--green); background: var(--green-soft); }
.kpi-icon.amber { color: var(--amber); background: var(--amber-soft); }
.kpi-icon.brown { color: #8a5a35; background: #f2e6d7; }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi-value { font-family: var(--num-font); font-size: 29px; line-height: 1.15; font-weight: 700; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 11.5px; color: var(--muted); }
.kpi-sub.up { color: var(--green); }
.kpi-sub.down { color: var(--red); }

.stat-strip {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  padding: 8px 4px;
  margin-bottom: 18px;
  overflow-x: auto;
}
.stat-cell { flex: 1; min-width: 140px; padding: 7px 20px; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.stat-cell:first-child { border-left: 0; }
.stat-cell span { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.stat-cell b { font-family: var(--num-font); font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-cell .stat-sub { font-family: var(--num-font); font-size: 11.5px; color: var(--muted); font-weight: 600; white-space: nowrap; }

/* 指标多的时候（月报等）：四列网格，自动换行，不再横向挤压 */
.stat-strip.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px 0; overflow: visible; }
.stat-strip.stat-grid .stat-cell { min-width: 0; }
.stat-strip.stat-grid .stat-cell:nth-child(4n+1) { border-left: 0; }
.stat-strip.stat-grid .stat-cell b { font-size: 18px; letter-spacing: -.3px; }
@media (max-width: 760px) {
  .stat-strip.stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-strip.stat-grid .stat-cell { border-left: 0; border-top: 1px solid var(--line); }
  .stat-strip.stat-grid .stat-cell:nth-child(-n+2) { border-top: 0; }
}

/* ---------- 看板 ---------- */

.dash-row { display: grid; gap: 15px; margin-top: 15px; }
.dash-row.wide-left { grid-template-columns: minmax(0, 1.72fr) minmax(300px, 1fr); }
.dash-row.thirds { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.chart-card { padding: 20px 22px 16px; }
.chart-card .card-head { margin-bottom: 4px; }
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 218px; padding-top: 12px; }
.bar-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.bar-value { font-size: 10px; color: var(--muted); white-space: nowrap; height: 15px; opacity: .85; font-family: var(--num-font); }
.bar-track { width: 100%; max-width: 44px; flex: 1; display: flex; align-items: flex-end; background: linear-gradient(180deg, rgba(232, 221, 204, .25), rgba(232, 221, 204, .5)); border-radius: 7px 7px 4px 4px; overflow: hidden; }
.bar-fill { width: 100%; border-radius: 7px 7px 3px 3px; background: linear-gradient(180deg, #d9b58d, #c99a68); transition: height .35s ease; }
.bar-col.today .bar-fill { background: linear-gradient(180deg, #c45443, #a63428); }
.bar-col.today .bar-value, .bar-col.today .bar-label b { color: var(--brand-dark); font-weight: 700; }
.bar-label { display: flex; flex-direction: column; align-items: center; line-height: 1.25; padding-top: 2px; }
.bar-label b { font-size: 11px; font-weight: 600; }
.bar-label span { font-size: 9.5px; color: var(--muted); }
.today-card { padding: 20px 22px; display: flex; flex-direction: column; }
.today-main { display: flex; align-items: center; gap: 20px; flex: 1; padding: 4px 0 10px; }
.margin-ring {
  --p: 0%;
  position: relative;
  width: 112px;
  height: 112px;
  flex: none;
  border-radius: 50%;
  background: conic-gradient(var(--green) var(--p), #ece2d3 0);
  display: grid;
  place-items: center;
}
.margin-ring::before { content: ""; position: absolute; inset: 11px; background: var(--surface); border-radius: 50%; }
.margin-ring span { position: relative; font-family: var(--num-font); font-size: 27px; font-weight: 700; line-height: 1; }
.margin-ring span small { font-size: 13px; font-weight: 600; }
.margin-ring em { position: absolute; bottom: 24px; font-style: normal; font-size: 10px; color: var(--muted); }
.today-numbers { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.today-numbers > div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.today-numbers span { font-size: 12px; color: var(--muted); }
.today-numbers b { font-family: var(--num-font); font-size: 16px; }
.today-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.today-foot .muted { font-size: 10.5px; }

.mini-card { padding: 20px; display: flex; flex-direction: column; }
.mini-card .empty-state { padding: 14px 6px 4px; }
.rank-list { display: flex; flex-direction: column; gap: 13px; }
.rank-row { display: grid; grid-template-columns: 20px minmax(0, 1fr) 46px; gap: 9px; align-items: center; }
.rank-no { font-family: var(--num-font); font-size: 11px; color: var(--muted); text-align: center; }
.rank-main { min-width: 0; }
.rank-title { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; margin-bottom: 5px; }
.rank-title b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-title span { color: var(--muted); font-size: 11.5px; flex: none; }
.meter { height: 6px; border-radius: 99px; background: #eee4d6; overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 99px; background: var(--green); }
.meter i.mid { background: var(--amber); }
.meter i.bad { background: var(--red); }
.meter.big { height: 7px; }
.rank-pct { font-family: var(--num-font); font-size: 12px; font-weight: 700; text-align: right; }
.rank-pct.good { color: var(--green); }
.rank-pct.mid { color: var(--amber); }
.rank-pct.bad { color: var(--red); }

.alert-list { display: flex; flex-direction: column; }
.alert-row { display: flex; align-items: center; gap: 9px; padding: 9px 5px; border-bottom: 1px dashed var(--line); border-radius: 7px; }
.alert-row:last-child { border-bottom: 0; }
.alert-row:hover { background: var(--surface-2); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--green); }
.status-dot.low { background: var(--amber); }
.status-dot.out, .status-dot.negative { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.alert-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.alert-main b { font-size: 12.5px; }
.alert-main span { font-size: 10.5px; color: var(--muted); }
.alert-badge { font-size: 10px; padding: 2px 7px; border-radius: 99px; background: var(--amber-soft); color: var(--amber); white-space: nowrap; }
.alert-badge.out, .alert-badge.negative { background: var(--red-soft); color: var(--red); }
.mini-card .muted.small-text { margin-top: 8px; }

.todo-list { display: flex; flex-direction: column; }
.todo-row { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px dashed var(--line); border-radius: 7px; }
.todo-row:last-child { border-bottom: 0; }
.todo-row:hover { background: var(--surface-2); }
.todo-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--surface-2); color: var(--ink-2); flex: none; }
.todo-row > div { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.todo-row b { font-size: 12.5px; }
.todo-row span { font-size: 10.5px; color: var(--muted); }
.todo-link { font-size: 10.5px; color: var(--brand); white-space: nowrap; }
.all-done { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--green); padding: 26px 10px; font-size: 12.5px; }

/* ---------- onboarding ---------- */

.onboard-card {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(230px, .65fr);
  gap: 26px;
  padding: 38px;
  overflow: hidden;
  background:
    radial-gradient(600px 280px at 90% -20%, rgba(178, 59, 46, .13), transparent 60%),
    linear-gradient(135deg, #fffaf1, #fffdf8 60%);
  position: relative;
}
.onboard-copy .eyebrow { margin-bottom: 10px; }
.onboard-copy h1 { font-size: clamp(28px, 3.6vw, 40px); line-height: 1.28; letter-spacing: -1px; max-width: 620px; }
.onboard-copy p { color: var(--muted); font-size: 14px; line-height: 1.8; max-width: 560px; margin-top: 14px; }
.onboard-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.onboard-art { display: grid; place-items: center; position: relative; color: var(--brand); }
.onboard-art::before { content: ""; position: absolute; width: 190px; height: 190px; border-radius: 50%; background: radial-gradient(circle, rgba(244, 154, 193, .22), rgba(244, 154, 193, .04) 65%, transparent 70%); }
.onboard-art .icon { position: relative; stroke-width: 1.25; color: var(--brand); filter: drop-shadow(0 12px 18px rgba(178, 59, 46, .13)); }
.onboard-donut { position: relative; width: 126px; height: 126px; filter: drop-shadow(0 14px 22px rgba(178, 59, 46, .16)); }
.steam { position: absolute; top: 10px; width: 8px; height: 34px; border-radius: 99px; background: linear-gradient(180deg, transparent, rgba(178, 59, 46, .22)); animation: steam 3.2s ease-in-out infinite; }
.steam.s1 { left: calc(50% - 26px); animation-delay: 0s; }
.steam.s2 { left: 50%; height: 44px; animation-delay: .7s; }
.steam.s3 { left: calc(50% + 26px); animation-delay: 1.4s; }
@keyframes steam { 0% { opacity: 0; transform: translateY(8px) scale(.8); } 40% { opacity: 1; } 100% { opacity: 0; transform: translateY(-30px) scale(1.15); } }
.onboard-steps { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; border-top: 1px dashed var(--line-strong); padding-top: 22px; }
.step { display: flex; align-items: flex-start; gap: 11px; }
.step > span { display: grid; place-items: center; width: 27px; height: 27px; flex: none; border-radius: 9px; background: var(--brand-soft); color: var(--brand); font-family: var(--num-font); font-weight: 700; font-size: 13px; }
.step b { font-size: 13px; }
.step p { color: var(--muted); font-size: 11.5px; margin-top: 2px; line-height: 1.5; }
.onboard-features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; margin-top: 14px; }
.onboard-feature { display: flex; align-items: flex-start; gap: 11px; padding: 16px 17px; background: rgba(255, 253, 248, .55); border: 1px solid var(--line); border-radius: 14px; }
.of-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 10px; background: var(--brand-soft); color: var(--brand); }
.onboard-feature b { font-size: 13px; }
.onboard-feature p { font-size: 11.5px; line-height: 1.55; color: var(--muted); margin-top: 3px; }
.onboard-foot { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; margin: 18px 2px 0; }

/* ---------- 表格 ---------- */

.table-card { overflow: hidden; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar-left { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.table-toolbar .toolbar-left { flex: 1; min-width: 0; }
.table-toolbar .month-input { width: 154px; flex: 0 0 154px; min-width: 0; }
.month-input { width: 154px; }
.table-card > .card-head { padding: 16px 18px 0; margin-bottom: 10px; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th { text-align: left; font-size: 11px; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: 9px 14px; white-space: nowrap; border-bottom: 1px solid var(--line); }
.data-table td { padding: 11px 14px; border-bottom: 1px solid #f0e7da; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: rgba(250, 244, 233, .55); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table .num small { color: var(--muted); font-size: 10px; }
.data-table .strong { font-weight: 700; }
.data-table .actions-col { width: 78px; }
.cell-date { display: block; font-family: var(--num-font); font-weight: 600; white-space: nowrap; }
.cell-sub { display: block; font-size: 10px; color: var(--muted); }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .icon-btn { width: 28px; height: 28px; }
.note-cell { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty-state { text-align: center; padding: 46px 22px; }
.empty-art { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 20px; background: var(--surface-2); color: #b59a7d; }
.empty-state h3 { font-size: 15px; margin-bottom: 5px; }
.empty-state p { color: var(--muted); font-size: 12.5px; max-width: 440px; margin: 0 auto; }
.empty-action { margin-top: 16px; }
.mini-empty { padding: 18px 8px; text-align: center; color: var(--muted); font-size: 12px; }
.mini-empty a { color: var(--brand); font-weight: 600; }
.page-note { display: flex; align-items: flex-start; gap: 6px; color: var(--muted); font-size: 11.5px; line-height: 1.65; margin-top: 14px; padding: 0 4px; }
.page-note .icon { margin-top: 1px; }

/* ---------- 进货 ---------- */

.segmented { display: inline-flex; align-items: center; gap: 3px; padding: 4px; border-radius: 12px; background: #ece2d3; margin-bottom: 16px; }
.seg { display: flex; align-items: center; gap: 6px; padding: 7px 14px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); font-size: 12.5px; font-weight: 600; }
.seg span { font-size: 10px; color: var(--muted); background: rgba(255, 253, 248, .7); border-radius: 99px; padding: 0 6px; }
.seg.active { background: var(--surface); color: var(--brand-dark); box-shadow: 0 2px 5px rgba(74, 52, 38, .1); }
.section-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.search-box { display: flex; align-items: center; gap: 3px; height: 38px; padding: 0 10px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; color: var(--muted); transition: border-color .14s, box-shadow .14s; }
.search-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(178, 59, 46, .1); }
.search-box .input { border: 0; box-shadow: none; padding: 0 3px; height: 34px; width: 200px; background: transparent; }
.search-box .input:focus { box-shadow: none; }
.ingredient-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); gap: 13px; }
.ingredient-card { padding: 17px 18px 13px; display: flex; flex-direction: column; }
.ing-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ing-title { min-width: 0; display: flex; align-items: center; gap: 2px; }
.ing-title b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ing-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.ing-numbers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 13px 0 11px; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; }
.ing-numbers span { display: block; font-size: 10.5px; color: var(--muted); }
.ing-numbers b { font-family: var(--num-font); font-size: 16px; font-variant-numeric: tabular-nums; }
.ing-numbers b small { font-size: 10px; font-weight: 500; color: var(--muted); }
.ing-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; border-top: 1px dashed var(--line); padding-top: 8px; margin-top: auto; }

/* ---------- 产品 ---------- */

.filter-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-btn { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: rgba(255, 253, 248, .5); color: var(--ink-2); font-size: 12px; font-weight: 600; }
.chip-btn span { font-size: 9.5px; color: var(--muted); }
.chip-btn:hover { background: var(--surface); }
.chip-btn.active { background: var(--brand); border-color: var(--brand); color: #fff8f2; }
.chip-btn.active span { color: rgba(255, 248, 242, .75); }
.ing-category-bar { margin: -2px 0 14px; }
.ing-category-bar .chip-btn { height: 30px; padding: 0 10px; font-size: 11.5px; }
.channel-switch { margin-bottom: 10px; }

/* 产能与备料 */
.prod-qty { width: 74px; text-align: right; padding: 4px 6px; font-size: 13px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 8px; margin: 10px 0 12px; }
.plan-cell { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.plan-cell span { flex: 1; font-size: 12.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-cell input { width: 64px; text-align: right; padding: 4px 6px; font-size: 13px; }
.plan-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.cap-flag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.cap-flag.ok { background: rgba(46, 125, 90, .12); color: #2e7d5a; }
.cap-flag.bad { background: rgba(190, 60, 60, .12); color: #be3c3c; }
.cap-muted { color: var(--muted); font-size: 12px; }
.cap-zero { color: #be3c3c; font-weight: 700; }
.channel-switch .chip-btn { height: 30px; padding: 0 14px; font-size: 12.5px; }
.cart-info em { font-style: normal; color: var(--brand); font-weight: 700; margin-left: 4px; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 13px; }
.menu-card { padding: 17px 18px 14px; cursor: pointer; transition: transform .16s, box-shadow .16s, border-color .16s; outline: none; }
.menu-card:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(74, 52, 38, .1); border-color: #d9c4aa; }
.menu-card:focus-visible { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(178, 59, 46, .15); }
.menu-card.inactive { opacity: .64; background: #fbf8f2; }
.menu-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.menu-card h3 { font-size: 17px; margin: 9px 0 7px; letter-spacing: -.2px; }
.menu-price-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.menu-price { font-family: var(--num-font); font-size: 24px; font-weight: 700; letter-spacing: -.5px; }
.menu-cost { font-size: 11px; color: var(--muted); }
.menu-card-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 10.5px; color: var(--muted); margin-top: 9px; }

/* ---------- 销售 ---------- */

.date-control { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--muted); }
.date-control input { border: 0; background: transparent; font-size: 13px; color: var(--ink); outline: none; }
.quick-card { padding: 20px 22px; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 10px; }
.quick-item { border: 1px solid var(--line); border-radius: 13px; padding: 12px 13px; background: var(--surface); transition: border-color .14s, background .14s, box-shadow .14s; }
.quick-item.selected { border-color: #d49a8e; background: linear-gradient(180deg, #fff8f4, #fdf1ec); box-shadow: 0 0 0 2px rgba(178, 59, 46, .07); }
.quick-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.quick-top b { display: block; font-size: 13.5px; line-height: 1.35; }
.quick-top span { font-size: 10px; color: var(--muted); }
.quick-price { font-family: var(--num-font); font-size: 15px; font-weight: 700; white-space: nowrap; }
.quick-stepper { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.step-btn { display: grid; place-items: center; width: 31px; height: 31px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); color: var(--ink-2); }
.step-btn:hover { background: var(--surface-2); }
.step-btn.plus { background: var(--brand-soft); border-color: #e7c0b7; color: var(--brand-dark); }
.step-btn.plus:hover { background: #f3d6cd; }
.step-btn:disabled { opacity: .35; cursor: not-allowed; }
.quick-qty { min-width: 28px; text-align: center; font-family: var(--num-font); font-size: 17px; font-weight: 700; color: var(--muted); }
.qty-input { width: 58px; height: 31px; padding: 0 4px; text-align: center; font-family: var(--num-font); font-size: 17px; font-weight: 700; color: var(--brand); background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 9px; }
.qty-input::placeholder { color: var(--muted); font-weight: 600; }
.qty-input:focus { outline: 2px solid rgba(190, 90, 70, .3); outline-offset: 1px; }
.qty-input::-webkit-outer-spin-button, .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-input { -moz-appearance: textfield; appearance: textfield; }
.quick-qty.on { color: var(--brand); }
.cart-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 15px; padding: 13px 16px; background: var(--surface-2); border-radius: 13px; border: 1px dashed var(--line-strong); }
.cart-bar.ready { background: linear-gradient(90deg, #fbf0e7, #fdf8f1); border-style: solid; border-color: #e2c8b8; }
.cart-info { display: flex; align-items: baseline; gap: 10px; }
.cart-info span { font-size: 12px; color: var(--muted); }
.cart-info b { color: var(--ink); font-family: var(--num-font); }
.cart-info strong { font-family: var(--num-font); font-size: 23px; letter-spacing: -.4px; }

/* ---------- 库存 ---------- */

.toggle-line { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.adjustment-card { margin-top: 15px; padding: 20px 22px; }
.adjust-list { display: flex; flex-direction: column; }
.adjust-row { display: flex; align-items: center; gap: 12px; padding: 8px 2px; border-bottom: 1px dashed var(--line); }
.adjust-row:last-child { border-bottom: 0; }
.adjust-date { font-family: var(--num-font); font-size: 11.5px; color: var(--muted); width: 42px; flex: none; }
.adjust-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.adjust-main b { font-size: 12.5px; }
.adjust-main span { font-size: 10.5px; color: var(--muted); }
.adjust-delta { font-family: var(--num-font); font-size: 12.5px; font-weight: 700; white-space: nowrap; }

/* ---------- 数据页 ---------- */

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; align-items: start; }
.settings-card { padding: 21px 22px; }
.settings-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.settings-form .field:nth-child(1) { grid-column: 1 / -1; }
.settings-submit { grid-column: 1 / -1; display: flex; justify-content: flex-end; margin-top: 4px; }
.path-box { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; margin-bottom: 11px; }
.path-box code { font-size: 10.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.btn-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.backup-list-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 6px; }
.backup-list-head h3 { font-size: 12.5px; }
.backup-list { border-top: 1px dashed var(--line); }
.backup-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.backup-row:last-child { border-bottom: 0; }
.backup-main { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.backup-main b { font-size: 11.5px; font-family: var(--num-font); overflow: hidden; text-overflow: ellipsis; }
.backup-main span { font-size: 10px; color: var(--muted); }
.backup-actions { display: flex; gap: 10px; flex: none; }
.mini-loading { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; padding: 14px 0; }
.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.export-card { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); text-align: left; transition: border-color .14s, background .14s; }
.export-card:hover { border-color: #d5bda3; background: var(--surface-2); }
.export-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); margin-bottom: 5px; }
.export-card b { font-size: 12.5px; }
.export-card span:last-child { font-size: 10px; color: var(--muted); }
.file-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 120px; border: 1.5px dashed var(--line-strong); border-radius: 13px; background: var(--surface-2); color: var(--muted); cursor: pointer; transition: border-color .14s, background .14s; }
.file-drop:hover { border-color: var(--brand); background: #fdf3ec; }
.file-drop .icon { color: var(--brand); margin-bottom: 4px; }
.file-drop b { font-size: 13px; color: var(--ink); }
.file-drop span { font-size: 10.5px; }
.danger-card { border-color: #ecd0ca; }
.danger-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.danger-row:last-child { border-bottom: 0; }
.danger-row > div { display: flex; flex-direction: column; line-height: 1.4; }
.danger-row b { font-size: 12.5px; }
.danger-row span { font-size: 10.5px; color: var(--muted); }
.about-card p { color: var(--ink-2); font-size: 12.5px; line-height: 1.75; margin-bottom: 9px; }
.about-card p:last-child { margin-bottom: 0; }
.about-card code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 11px; }

/* ---------- 表单 ---------- */

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; min-width: 0; }
.field-label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.req { color: var(--brand); font-style: normal; margin-left: 2px; }
.input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fffdfa;
  outline: none;
  font-size: 13.5px;
  transition: border-color .14s, box-shadow .14s, background .14s;
}
.input::placeholder { color: #b9a894; font-size: 12.5px; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(178, 59, 46, .1); background: #fff; }
.textarea { height: auto; padding: 9px 12px; resize: vertical; min-height: 64px; line-height: 1.55; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238c7968' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.input-wrap { display: flex; align-items: stretch; border: 1px solid var(--line-strong); border-radius: 10px; background: #fffdfa; overflow: hidden; transition: border-color .14s, box-shadow .14s; }
.input-wrap:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(178, 59, 46, .1); }
.input-wrap .input, .input-wrap .input:focus { border: 0; box-shadow: none; background: transparent; }
.input-affix { display: flex; align-items: center; padding: 0 10px; background: var(--surface-2); color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.input-affix.suffix { border-left: 1px solid var(--line); }
.has-prefix .input-affix { border-right: 1px solid var(--line); }
.field-hint { font-size: 10.5px; color: var(--muted); line-height: 1.45; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-row.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-note { font-size: 11px; color: var(--muted); line-height: 1.65; background: var(--surface-2); border-radius: 8px; padding: 8px 11px; margin: 0 0 14px; }
.inline-hint { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 20px; margin: -4px 0 12px; font-size: 11px; color: var(--muted); }
.inline-hint b { color: var(--ink-2); font-family: var(--num-font); }
.inline-hint span { white-space: nowrap; }
.new-ingredient-box { background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: 12px; padding: 14px 14px 2px; margin: 0 0 14px; }
.new-ingredient-box[hidden] { display: none; }
.new-ingredient-box .section-head h3 { font-size: 13px; }
.new-ingredient-box .form-note { margin-bottom: 12px; }
.check-field { justify-content: flex-start; }
.switch-line { display: flex; align-items: center; gap: 8px; min-height: 40px; font-size: 12px; color: var(--ink-2); }
.switch { appearance: none; width: 38px; height: 22px; border-radius: 99px; background: #d8cab8; position: relative; cursor: pointer; transition: background .15s; flex: none; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .18); transition: transform .15s; }
.switch:checked { background: var(--brand); }
.switch:checked::after { transform: translateX(16px); }

.panel-section { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px dashed var(--line); }
.panel-section:last-of-type { border-bottom: 0; margin-bottom: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.section-head h3 { font-size: 13.5px; }
.section-head span { display: block; font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.recipe-head, .recipe-row { display: grid; grid-template-columns: minmax(0, 1fr) 132px 76px 30px; gap: 8px; align-items: center; }
.recipe-head { padding: 0 2px 6px; font-size: 10px; color: var(--muted); }
.recipe-row { margin-bottom: 7px; }
.recipe-row .input { height: 36px; font-size: 12.5px; }
.qty-box { display: flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 9px; background: #fffdfa; overflow: hidden; transition: border-color .14s; }
.qty-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(178, 59, 46, .1); }
.qty-box .input { border: 0; box-shadow: none; padding: 0 8px; height: 34px; }
.unit-label { padding: 0 8px; font-size: 10.5px; color: var(--muted); background: var(--surface-2); align-self: stretch; display: flex; align-items: center; white-space: nowrap; }
.recipe-cost { text-align: right; font-family: var(--num-font); font-size: 11.5px; color: var(--ink-2); white-space: nowrap; }
.recipe-del { width: 28px; height: 28px; }
.cost-summary { background: var(--surface-2); border: 1px solid var(--line); border-radius: 13px; padding: 15px 16px; }
.cost-lines { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 18px; }
.cost-line { display: flex; justify-content: space-between; align-items: baseline; font-size: 11.5px; color: var(--muted); padding: 3px 0; }
.cost-line b { color: var(--ink-2); font-family: var(--num-font); font-weight: 600; }
.cost-total { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--line-strong); margin-top: 8px; padding-top: 10px; }
.cost-total span { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.cost-total strong { font-family: var(--num-font); font-size: 24px; color: var(--brand-dark); }
.cost-result { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.cost-result > div:first-child { display: flex; align-items: baseline; gap: 7px; font-size: 11.5px; color: var(--muted); }
.cost-result > div:first-child b { color: var(--ink); font-family: var(--num-font); font-size: 14px; }
.cost-profit { margin-left: auto; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--surface); }
.cost-profit.good { color: var(--green); background: var(--green-soft); }
.cost-profit.mid { color: var(--amber); background: var(--amber-soft); }
.cost-profit.bad { color: var(--red); background: var(--red-soft); }
.warn-box { display: flex; gap: 6px; align-items: flex-start; margin-top: 10px; padding: 7px 9px; border-radius: 7px; background: var(--amber-soft); color: #8c6416; font-size: 10.5px; line-height: 1.5; }
.formula-note { display: flex; gap: 6px; align-items: flex-start; color: var(--muted); font-size: 10.5px; line-height: 1.6; }
.stocktake-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 15px; background: var(--surface-2); border-radius: 10px; margin-bottom: 15px; }
.stocktake-head > div { display: flex; flex-direction: column; }
.stocktake-head span { font-size: 10.5px; color: var(--muted); }
.stocktake-head strong { font-family: var(--num-font); font-size: 23px; line-height: 1.25; }
.stocktake-head strong small { font-size: 11px; font-weight: 500; color: var(--muted); }
.stocktake-head b { font-family: var(--num-font); font-size: 13px; }

/* ---------- 浮层 ---------- */

.overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.overlay-backdrop { position: absolute; inset: 0; background: rgba(44, 33, 26, .42); backdrop-filter: blur(3px); animation: fadeIn .16s ease; }
.overlay-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(560px, 100%);
  max-height: min(90vh, 880px);
  max-height: min(90dvh, 880px);
  background: var(--surface);
  border-radius: 19px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: panelIn .2s cubic-bezier(.2, .8, .2, 1);
}
.overlay-panel.size-sm { width: min(430px, 100%); }
.overlay-panel.size-lg { width: min(720px, 100%); }
.overlay-drawer { align-items: stretch; justify-content: flex-end; padding: 0; }
.overlay-drawer .overlay-panel { width: min(680px, 100%); max-height: none; height: 100%; border-radius: 20px 0 0 20px; animation: drawerIn .24s cubic-bezier(.2, .8, .2, 1); }
.overlay.closing { animation: fadeOut .16s ease forwards; }
.overlay.closing .overlay-panel { animation: panelOut .16s ease forwards; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes panelIn { from { opacity: 0; transform: translateY(12px) scale(.985); } }
@keyframes panelOut { to { opacity: 0; transform: translateY(8px) scale(.99); } }
@keyframes drawerIn { from { transform: translateX(30px); opacity: .4; } }
.overlay-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 19px 22px 15px; border-bottom: 1px solid var(--line); }
.overlay-title h2 { font-size: 19px; letter-spacing: -.25px; }
.overlay-title p { color: var(--muted); font-size: 11.5px; margin-top: 3px; }
.overlay-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.overlay-body { padding: 18px 22px 8px; overflow-y: auto; min-height: 0; }
.overlay-foot { display: flex; align-items: center; justify-content: flex-end; gap: 9px; padding: 14px 22px; border-top: 1px solid var(--line); background: rgba(250, 244, 233, .45); flex-wrap: wrap; }
.overlay-foot .foot-spacer { flex: 1; }
.foot-cost { display: inline-flex; align-items: baseline; gap: 5px; font-size: 11px; color: var(--muted); padding: 4px 9px; border-radius: 7px; background: var(--surface-2); white-space: nowrap; }
.foot-cost b { font-family: var(--num-font); font-size: 13px; color: var(--ink); }
.foot-cost .good { color: var(--green); }
.foot-cost .mid { color: var(--amber); }
.foot-cost .bad { color: var(--red); }
.confirm-panel .overlay-head { padding-bottom: 8px; border-bottom: 0; }
.confirm-panel .overlay-body { padding-top: 4px; }
.confirm-msg { font-size: 13.5px; line-height: 1.7; }
.confirm-detail { margin-top: 9px; font-size: 11.5px; color: var(--muted); line-height: 1.65; background: var(--surface-2); padding: 9px 11px; border-radius: 8px; white-space: pre-line; }

/* ---------- Toast ---------- */

.toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 340px;
  padding: 10px 14px;
  border-radius: 11px;
  background: #2f241d;
  color: #fff8f0;
  box-shadow: 0 12px 30px rgba(44, 33, 26, .28);
  font-size: 12.5px;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
}
.toast.in { opacity: 1; transform: none; }
.toast-icon { display: grid; place-items: center; width: 20px; height: 20px; flex: none; border-radius: 50%; background: rgba(255, 255, 255, .13); margin-top: 1px; }
.toast-error { background: #7d241b; }
.toast-info { background: #3d352e; }

/* ---------- 加载 / 错误 ---------- */

.boot-loading { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 120px 20px; color: var(--muted); font-size: 13px; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(140, 121, 104, .3); border-top-color: currentColor; border-radius: 50%; animation: spin .7s linear infinite; }
.spinner.big { width: 28px; height: 28px; border-width: 3px; color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }
.fatal-card { max-width: 580px; margin: 70px auto; padding: 34px; text-align: center; }
.fatal-icon { display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 14px; border-radius: 17px; background: var(--red-soft); color: var(--red); }
.fatal-card h1 { font-size: 21px; margin-bottom: 9px; }
.fatal-card p { color: var(--muted); font-size: 13px; line-height: 1.7; white-space: pre-line; margin-bottom: 18px; }
.boot-tip { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 12px; margin-top: -40px; margin-bottom: 30px; }
.login-card { max-width: 430px; }
.login-card .fatal-icon { background: var(--brand-soft); color: var(--brand); }
.login-card p { margin-bottom: 0; white-space: normal; }
.login-form { display: flex; flex-direction: column; gap: 10px; margin: 20px 0 0; }
.login-form .input { height: 46px; font-size: 16px; text-align: center; letter-spacing: .06em; }
.login-form .btn { height: 46px; font-size: 14px; }
.login-error { min-height: 18px; margin-top: 12px; color: var(--red); font-size: 12.5px; line-height: 1.5; }
.login-hint { margin-top: 12px; color: var(--muted); font-size: 11.5px; line-height: 1.7; }
.noscript { padding: 30px; text-align: center; }

/* ---------- 响应式 ---------- */

@media (max-width: 1080px) {
  .nav-link { padding: 8px 9px; font-size: 12px; }
  .nav-link .icon { display: none; }
  .kpi-value { font-size: 26px; }
  .dash-row.wide-left { grid-template-columns: 1fr; }
  .dash-row.thirds { grid-template-columns: 1fr 1fr; }
  .dash-row.thirds .mini-card:last-child { grid-column: 1 / -1; }
  .today-main { justify-content: flex-start; }
}

@media (max-width: 900px) {
  .topbar { padding: 0 16px; gap: 12px; }
  .nav { display: none; }
  .top-status { margin-left: auto; }
  .today-label { display: none; }
  .app-main { padding: 22px 18px 42px; }
  .mobile-nav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 50;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: rgba(251, 246, 237, .94);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(16px);
  }
  .mobile-link { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 2px; border-radius: 9px; color: var(--muted); font-size: 9.5px; font-weight: 600; }
  .mobile-link.active { color: var(--brand); background: var(--brand-soft); }
  .app-shell { padding-bottom: 66px; }
  .app-foot { display: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .onboard-card { grid-template-columns: 1fr; padding: 28px 24px; }
  .onboard-art { display: none; }
  .onboard-steps { grid-template-columns: 1fr; gap: 14px; }
  .onboard-features { grid-template-columns: 1fr; }
  .onboard-foot { align-items: flex-start; }
  .form-row.four { grid-template-columns: 1fr 1fr; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .page-actions { width: 100%; }
  .toast-root { right: 12px; left: 12px; bottom: 80px; }
  .toast { max-width: none; }
}

@media (max-width: 680px) {
  .app-main { padding: 18px 13px 34px; }
  .page-head h1 { font-size: 26px; }
  .page-head .sub { font-size: 12px; }
  .kpi { padding: 15px; }
  .kpi-value { font-size: 23px; }
  .kpi-label { font-size: 11px; }
  .kpi-sub { font-size: 10.5px; }
  .dash-row.thirds { grid-template-columns: 1fr; }
  .dash-row.thirds .mini-card:last-child { grid-column: auto; }
  .stat-strip { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; }
  .stat-cell { min-width: 0; border-left: 0; border-top: 1px solid var(--line); padding: 8px 13px; }
  .stat-cell:nth-child(-n+2) { border-top: 0; }
  .stat-cell:nth-child(even) { border-left: 1px solid var(--line); }
  .stat-cell b { font-size: 17px; }
  .chart-card { padding: 16px 13px 12px; }
  .bar-chart { height: 190px; gap: 4px; }
  .bar-value { font-size: 8.5px; }
  .bar-track { max-width: 30px; }
  .today-card { padding: 17px; }
  .margin-ring { width: 96px; height: 96px; }
  .margin-ring span { font-size: 23px; }
  .margin-ring em { bottom: 20px; }
  .today-main { gap: 14px; }
  .form-row, .form-row.four { grid-template-columns: 1fr; }
  .settings-form { grid-template-columns: 1fr; }
  .settings-form .field:nth-child(1) { grid-column: auto; }
  .settings-submit { grid-column: auto; }
  .menu-grid { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: 1fr 1fr; }
  .quick-item { padding: 10px; }
  .quick-top b { font-size: 12.5px; }
  .quick-stepper { margin-top: 7px; }
  .cart-bar { flex-direction: column; align-items: stretch; }
  .cart-info { justify-content: space-between; }
  .cart-bar .btn { width: 100%; }
  .quick-card .cart-bar { position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 6; box-shadow: 0 -6px 18px rgba(74, 52, 38, .08); backdrop-filter: blur(6px); }
  .quick-card .cart-bar:not(.ready) { display: none; }
  .quick-card:has(.cart-bar.ready) .quick-grid { padding-bottom: 124px; }
  .overlay { padding: 0; }
  .overlay-panel { width: 100%; max-height: 100vh; max-height: 100dvh; height: 100%; border-radius: 0; }
  .overlay-drawer .overlay-panel { border-radius: 0; width: 100%; }
  .overlay-head { padding: 16px 16px 12px; }
  .overlay-body { padding: 15px 16px 6px; }
  .overlay-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .overlay-drawer .overlay-foot { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; }
  .overlay-drawer .overlay-foot .foot-spacer { display: none; }
  .overlay-drawer .overlay-foot #deleteItem { grid-column: 1; grid-row: 1; }
  .overlay-drawer .overlay-foot .foot-cost { grid-column: 2 / 4; grid-row: 1; justify-self: start; }
  .overlay-drawer .overlay-foot [data-close] { grid-column: 1; grid-row: 2; }
  .overlay-drawer .overlay-foot [type="submit"] { grid-column: 2 / 4; grid-row: 2; width: 100%; }
  .toast-root { bottom: 74px; }
  .recipe-head { display: none; }
  .recipe-row { grid-template-columns: minmax(0, 1fr) 104px 28px; }
  .recipe-cost { display: none; }
  .cost-lines { grid-template-columns: 1fr; }
  .ingredient-grid { grid-template-columns: 1fr; }
  .export-grid { grid-template-columns: 1fr 1fr; }
  .table-scroll { overflow: visible; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table thead { display: none; }
  .data-table tr { padding: 11px 14px; border-bottom: 1px solid var(--line); }
  .data-table tbody tr:last-child { border-bottom: 0; }
  .data-table td { position: relative; padding: 4px 0 4px 86px; border: 0; text-align: right; }
  .data-table td::before { content: attr(data-label); position: absolute; left: 0; top: 4px; width: 78px; color: var(--muted); font-size: 10.5px; text-align: left; }
  .data-table td:first-child { padding: 0 0 7px; text-align: left; font-size: 13px; }
  .data-table td:first-child::before { display: none; }
  .data-table td:first-child .cell-date { display: inline; font-size: 13px; }
  .data-table td:first-child .cell-sub { display: inline; margin-left: 6px; }
  .data-table td.num { text-align: right; }
  .data-table td small { margin-left: 3px; font-size: 10px; }
  .data-table td.row-actions { display: flex; justify-content: flex-end; gap: 3px; padding: 8px 0 0; border-top: 1px dashed var(--line); margin-top: 6px; }
  .data-table td.row-actions::before { display: none; }
  .stock-table td:first-child { display: block; }
  .table-toolbar { padding: 12px 14px; flex-direction: column; align-items: stretch; gap: 8px; }
  .table-toolbar .toolbar-left { width: 100%; flex: 1 1 auto; }
  .search-box { width: 100%; }
  .search-box .input { width: 100%; }
  .toolbar-left { width: 100%; }
  .table-toolbar .month-input { width: 100%; flex: 1 1 100%; }
  .table-toolbar > .muted { text-align: right; }
  .onboard-copy h1 { font-size: 27px; }
  .onboard-actions { flex-direction: column; align-items: stretch; }
  .settings-card { padding: 17px; }
  .login-card { margin: 40px auto; padding: 26px 20px; }
  .export-grid { gap: 7px; }
  .danger-row { flex-direction: column; align-items: flex-start; gap: 7px; }
}

/* iOS Safari：输入框字号小于 16px 时，聚焦会自动放大整页 */
@supports (-webkit-touch-callout: none) {
  @media (max-width: 900px) {
    input:not([type="checkbox"]):not([type="radio"]),
    select, textarea { font-size: 16px !important; }
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

@media print {
  .topbar, .mobile-nav, .app-foot, .page-actions, .toast-root { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
