/* ===== 留样易 H5 · 温暖橙色调 ===== */
:root {
  --primary: #F97316;
  --primary-dark: #EA580C;
  --primary-soft: #FFEDD5;
  --bg: #FFF8F1;
  --card: #FFFFFF;
  --text: #3D2B1F;
  --muted: #A1806A;
  --line: #F6E3CE;
  --green: #16A34A;
  --green-bg: #DCFCE7;
  --amber: #D97706;
  --amber-bg: #FEF3C7;
  --red: #DC2626;
  --red-bg: #FEE2E2;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(234, 88, 12, 0.08);
}

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

/* 关键：author 样式会覆盖 UA 的 [hidden]{display:none}，必须显式声明 */
[hidden] { display: none !important; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

#app { max-width: 560px; margin: 0 auto; padding: 0 14px 90px; }

/* ---- 顶栏 ---- */
/* http 访问时的 HTTPS 提示条 */
.secure-banner {
  display: block; text-decoration: none;
  margin: 8px 0 0; padding: 10px 14px;
  background: #fff4e0; border: 1px solid #ffd9a0; border-radius: 12px;
  color: #a05a00; font-size: 13px; line-height: 1.5;
}
.secure-banner[hidden] { display: none; }
.secure-banner b { color: #c2410c; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 2px 12px;
  position: sticky; top: 0; background: var(--bg); z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 26px; }
.topbar .title { font-size: 19px; font-weight: 700; }
.topbar .subtitle { font-size: 12px; color: var(--muted); }

.printer-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; color: var(--muted);
  cursor: pointer; box-shadow: var(--shadow);
}
.printer-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: #CBD5E1; }
.printer-chip.online .dot { background: var(--green); }
.printer-chip.offline .dot { background: var(--red); }
.printer-chip.mock .dot { background: var(--amber); }

/* ---- 餐次 tabs ---- */
.meal-tabs {
  display: flex; background: var(--card); border-radius: 999px;
  padding: 4px; margin: 6px 0 14px; box-shadow: var(--shadow);
}
.meal-tab {
  flex: 1; border: none; background: transparent; padding: 9px 0;
  border-radius: 999px; font-size: 14px; color: var(--muted); cursor: pointer;
  transition: all .18s;
}
.meal-tab.active { background: var(--primary); color: #fff; font-weight: 600; }

/* ---- 语音卡片 ---- */
.voice-card {
  background: linear-gradient(135deg, #FFF3E4, #FFE3C2);
  border-radius: var(--radius); padding: 22px 16px 18px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  box-shadow: var(--shadow); border: 1px solid #FBD9AE;
}
.mic-btn {
  width: 84px; height: 84px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, #FB923C, #EA580C); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(234, 88, 12, 0.35);
  transition: transform .15s;
}
.mic-btn:active { transform: scale(0.94); }
.mic-btn.listening { animation: pulse 1.2s infinite; background: linear-gradient(135deg, #EF4444, #DC2626); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); }
  70% { box-shadow: 0 0 0 18px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
.voice-tip { text-align: center; font-size: 14px; font-weight: 600; color: #7C4A1E; }
.voice-tip.warn { color: #C2410C; }
.voice-tip.warn .voice-sub { color: #9A3412; font-weight: 500; }
.voice-tip.warn a { color: #C2410C; text-decoration: underline; word-break: break-all; }
.mic-btn.blocked { filter: grayscale(0.55); opacity: 0.75; }
.voice-sub { font-size: 12px; font-weight: 400; color: var(--muted); }
.voice-wave { display: flex; gap: 4px; align-items: flex-end; height: 22px; }
.voice-wave i { width: 4px; background: var(--primary); border-radius: 2px; animation: wave 1s infinite ease-in-out; }
.voice-wave i:nth-child(1) { height: 40%; animation-delay: 0s; }
.voice-wave i:nth-child(2) { height: 70%; animation-delay: .15s; }
.voice-wave i:nth-child(3) { height: 100%; animation-delay: .3s; }
.voice-wave i:nth-child(4) { height: 60%; animation-delay: .45s; }
.voice-wave i:nth-child(5) { height: 85%; animation-delay: .6s; }
@keyframes wave { 0%,100% { transform: scaleY(0.5); } 50% { transform: scaleY(1.2); } }

/* ---- 识别结果 ---- */
.transcript, .parse-card, .manual-card, .list-card, .settings-group, .ledger-summary {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; margin-top: 14px; box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.transcript-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.transcript-text { font-size: 15px; }

.parse-title { font-weight: 700; margin-bottom: 10px; }
.parse-row {
  display: grid; grid-template-columns: 1fr 78px 72px 78px 78px; gap: 6px; margin-bottom: 8px;
}
.parse-row input, .parse-row select {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font-size: 14px; background: #FFFDF9; color: var(--text); width: 100%;
}
.parse-row input:focus, .parse-row select:focus { outline: 1px solid var(--primary); }
.parse-actions, .settings-ops, .ledger-actions { display: flex; gap: 8px; margin-top: 10px; }
.parse-actions .btn, .settings-ops .btn, .ledger-actions .btn { flex: 1; }

/* ---- 手动录入 ---- */
.manual-toggle {
  width: 100%; border: 1px dashed #F5C89A; background: #FFFBF4; color: var(--primary-dark);
  border-radius: 10px; padding: 11px; font-size: 14px; cursor: pointer;
}
.manual-form { margin-top: 12px; }
.form-row { margin-bottom: 10px; }
.form-row label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.form-row input, .form-row select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; font-size: 15px; background: #FFFDF9; color: var(--text);
}
.form-row input:focus, .form-row select:focus { outline: 1px solid var(--primary); }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

/* ---- 按钮 ---- */
.btn {
  border: none; border-radius: 10px; padding: 11px 16px; font-size: 14px;
  cursor: pointer; transition: filter .15s; font-weight: 600;
}
.btn:active { filter: brightness(0.92); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-ghost { background: #FFF3E4; color: var(--primary-dark); }
.btn-orange-line { background: #fff; color: var(--primary-dark); border: 1px solid var(--primary); }
.btn-danger-line { background: #fff; color: var(--red); border: 1px solid #FCA5A5; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }

/* ---- 今日列表 ---- */
.list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.list-title { font-weight: 700; }
.list-count { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.list-ops { display: flex; align-items: center; gap: 10px; }
.check-all { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 4px; }

.record-list { display: flex; flex-direction: column; }
.record-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 4px; border-bottom: 1px dashed var(--line);
}
.record-item:last-child { border-bottom: none; }
.record-check { width: 18px; height: 18px; accent-color: var(--primary); flex: none; }
.record-main { flex: 1; min-width: 0; }
.record-dish { font-weight: 600; font-size: 15px; }
.record-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.record-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.expire-chip { font-size: 11px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.expire-chip.ok { background: var(--green-bg); color: var(--green); }
.expire-chip.soon { background: var(--amber-bg); color: var(--amber); }
.expire-chip.done { background: var(--red-bg); color: var(--red); }
.record-ops { display: flex; gap: 6px; }
.mini-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  font-size: 12px; padding: 4px 9px; cursor: pointer; color: var(--muted);
}
.mini-btn.print { color: var(--primary-dark); border-color: #FBC98C; }
.empty-tip { text-align: center; color: var(--muted); font-size: 13px; padding: 26px 0; }

/* ---- 台账 ---- */
.ledger-datebar { display: flex; align-items: center; justify-content: space-between; margin: 8px 0 14px; }
.date-nav { border: none; background: var(--card); border-radius: 10px; padding: 9px 14px; font-size: 13px; color: var(--primary-dark); cursor: pointer; box-shadow: var(--shadow); }
.date-current { font-weight: 700; font-size: 15px; }
.ledger-summary { display: flex; gap: 10px; padding: 12px 14px; }
.sum-chip { flex: 1; text-align: center; }
.sum-chip b { display: block; font-size: 20px; color: var(--primary-dark); }
.sum-chip span { font-size: 12px; color: var(--muted); }
.ledger-table-wrap { overflow-x: auto; margin-top: 14px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
table.ledger { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 520px; }
table.ledger th { background: #FFF3E4; color: #7C4A1E; padding: 9px 10px; text-align: left; white-space: nowrap; }
table.ledger td { padding: 9px 10px; border-top: 1px solid var(--line); white-space: nowrap; }

/* ---- 设置 ---- */
.settings-title { font-weight: 700; margin-bottom: 10px; font-size: 14px; }
.kv-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.kv-row span { color: var(--muted); }
.kv-row b { font-weight: 600; text-align: right; word-break: break-all; }
.settings-note { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.6; }
.settings-footer { text-align: center; color: var(--muted); font-size: 12px; margin: 22px 0 10px; }

/* ---- Tab bar ---- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar .tab {
  flex: 1; border: none; background: none; padding: 9px 0 10px;
  font-size: 11px; color: var(--muted); cursor: pointer; display: flex;
  flex-direction: column; align-items: center; gap: 2px;
}
.tabbar .tab span { font-size: 20px; }
.tabbar .tab.active { color: var(--primary-dark); font-weight: 700; }

/* ---- 弹层 / Toast ---- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(61, 43, 31, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal { background: #fff; border-radius: 16px; padding: 18px; width: 100%; max-width: 340px; }
.modal-title { font-weight: 700; margin-bottom: 12px; text-align: center; }
.modal-actions { display: flex; gap: 10px; margin-top: 14px; }
.modal-actions .btn { flex: 1; }

/* 标签预览：模拟 58x40mm 预印表格纸（表格线用灰线模拟预印线） */
.label-preview {
  width: 224px; height: 154px; margin: 0 auto; background: #fff;
  border: 1.5px solid #9AA7B0; border-radius: 5px;
  font-size: 10px; line-height: 1.2; overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08); color: #1F2933;
}
.label-preview .lp-grid { display: flex; flex-direction: column; height: 100%; }
.label-preview .lp-title {
  height: 21.9%; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px; letter-spacing: 1px; color: #1F2933;
}
.label-preview .lp-row { display: flex; align-items: center; border-top: 1px solid #9AA7B0; }
.label-preview .lp-h { width: 21%; flex: none; padding-left: 6px; font-weight: 600; color: #1F2933; }
.label-preview .lp-h-mid { border-left: 1px solid #9AA7B0; }
.label-preview .lp-c { flex: 1; padding-left: 8px; overflow: hidden; white-space: nowrap; }
.label-preview .lp-r-meal, .label-preview .lp-r-time, .label-preview .lp-r-expire { height: 11.25%; }
.label-preview .lp-r-dish { height: 11.6%; }
.label-preview .lp-r-weight { height: 18.4%; }
.label-preview .lp-r-footer { height: 15%; border-top: 1px solid #9AA7B0; }
.label-preview .lp-r-footer .lp-c { padding-left: 6px; color: #52606D; }
.label-preview .lp-dish { font-weight: 800; font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%);
  background: rgba(61, 43, 31, 0.92); color: #fff; font-size: 13px;
  padding: 10px 18px; border-radius: 999px; z-index: 99; max-width: 82%;
  text-align: center; box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.toast.err { background: rgba(220, 38, 38, 0.95); }
.toast.ok { background: rgba(22, 163, 74, 0.95); }

/* ---- 打印（A4 台账） ---- */
#print-area { display: none; }
@media print {
  body { background: #fff; }
  #app > .page, .tabbar, .toast, .modal-mask { display: none !important; }
  #print-area { display: block; padding: 24px; }
  #print-area h2 { text-align: center; margin-bottom: 4px; }
  #print-area .p-sub { text-align: center; color: #666; font-size: 12px; margin-bottom: 14px; }
  #print-area table { width: 100%; border-collapse: collapse; font-size: 12px; }
  #print-area th, #print-area td { border: 1px solid #333; padding: 5px 7px; text-align: left; }
  #print-area th { background: #f2f2f2; }
  #print-area .p-sign { margin-top: 26px; font-size: 12px; display: flex; justify-content: space-between; }
}
