/* KEEP 永存 · 盲袋云打印 —— 深绿 + 米白，延续小程序盲袋页风格 */
:root {
  --green-900: #0e3b31;
  --green-800: #123c32;
  --green-700: #146356;
  --green-600: #1d7a68;
  --green-100: #e7f1ed;
  --ink: #17201d;
  --ink-2: #3d4a45;
  --muted: #6c7a75;
  --bg: #edf2ef;
  --card: #ffffff;
  --line: #d9e2dd;
  --amber: #e1ad36;
  --amber-soft: #fdf7e8;
  --red: #b42318;
  --red-soft: #fdf0ee;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(23, 52, 42, .07);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 布局 ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 228px; flex-shrink: 0;
  background: linear-gradient(180deg, var(--green-900) 0%, var(--green-800) 100%);
  color: #fff; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 22px 14px 16px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 20px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand-mark {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--amber), #f4c95d);
  color: var(--green-900); font-weight: 900; font-size: 24px;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 16px; letter-spacing: .5px; }
.brand-text span { font-size: 12px; opacity: .7; margin-top: 2px; }
.nav { margin-top: 18px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; border: 0; border-radius: 10px; background: transparent;
  color: rgba(255,255,255,.78); font-size: 14.5px; font-weight: 600; cursor: pointer;
  transition: background .15s, color .15s; font-family: var(--font); text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.is-active { background: #fff; color: var(--green-800); box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.nav-ico { width: 20px; text-align: center; font-size: 16px; }
.nav-dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.sidebar-foot { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-store { font-size: 13px; color: rgba(255,255,255,.85); margin-bottom: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-test {
  width: 100%; padding: 9px; border: 1px solid rgba(255,255,255,.28); border-radius: 8px;
  background: transparent; color: #fff; font-size: 13px; cursor: pointer; font-family: var(--font);
}
.sidebar-test:hover { background: rgba(255,255,255,.1); }

.main { flex: 1; min-width: 0; padding: 26px 30px 60px; }
.page { display: none; max-width: 1080px; margin: 0 auto; }
.page.is-active { display: block; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 800; letter-spacing: .3px; }
.page-head p { color: var(--muted); margin-top: 5px; font-size: 13.5px; }
.head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- 组件 ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid #eef2f0; }
.panel-head h2 { font-size: 15.5px; font-weight: 700; }
.chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--green-100);
  color: var(--green-700); font-size: 12.5px; font-weight: 700; margin-left: 6px;
}
.muted { color: var(--muted); font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  font-size: 14px; font-weight: 700; cursor: pointer; font-family: var(--font);
  transition: transform .06s, box-shadow .15s, background .15s; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--green-700); color: #fff; box-shadow: 0 4px 12px rgba(20,99,86,.28); }
.btn-primary:hover { background: var(--green-600); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #2a3531; }
.btn-ghost { background: #fff; color: var(--green-700); border-color: var(--line); }
.btn-ghost:hover { background: var(--green-100); }
.btn-danger-ghost { background: #fff; color: var(--red); border-color: #f0d6d2; }
.btn-danger-ghost:hover { background: var(--red-soft); }
.btn-lg { padding: 13px 26px; font-size: 15px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.link-btn { border: 0; background: none; color: var(--red); font-size: 13px; font-weight: 700; cursor: pointer; font-family: var(--font); }

.seg { display: inline-flex; background: #e5ece8; border-radius: 10px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.seg-item {
  border: 0; background: transparent; padding: 8px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: #55645e; cursor: pointer; font-family: var(--font);
}
.seg-item.is-active { background: #fff; color: var(--green-800); box-shadow: 0 2px 8px rgba(23,52,42,.12); font-weight: 700; }

.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13.5px; font-weight: 700; margin-bottom: 8px; color: var(--ink-2); }
.field .req { color: var(--red); font-style: normal; }
.text-input, .search-input, .price-input, .qty-input, .scan-input {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 14px; font-family: var(--font); background: #fbfdfc; color: var(--ink); outline: none;
}
.text-input:focus, .search-input:focus, .price-input:focus, .qty-input:focus, .scan-input:focus { border-color: var(--green-600); box-shadow: 0 0 0 3px rgba(29,122,104,.12); }
.qty-input { width: 76px; }
.qty-input.wide { width: 120px; }
.price-input { max-width: 260px; font-weight: 700; font-size: 16px; }
.hint { font-size: 12px; margin-top: 6px; line-height: 1.6; }
.hint code { background: #eef3f0; padding: 1px 5px; border-radius: 5px; font-size: 11.5px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.check-field { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; margin-bottom: 18px; }
.check-field input { width: 17px; height: 17px; accent-color: var(--green-600); cursor: pointer; }
.empty-hint { padding: 46px 20px; text-align: center; color: var(--muted); }

/* ---------- 打包页 ---------- */
.pack-scan-panel { padding: 18px 20px; margin-bottom: 18px; }
.scan-row { display: flex; gap: 10px; }
.scan-input { flex: 1; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 17px; font-weight: 600; letter-spacing: .5px; height: 52px; }
.scan-row-sub { display: flex; align-items: center; gap: 16px; margin-top: 12px; }
.qty-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.scan-state { color: var(--muted); font-size: 13px; }
.pack-body { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 860px) { .pack-body { grid-template-columns: 1fr; } }
.pack-list-panel .panel-head { padding-bottom: 12px; }
.pack-items { padding: 6px 20px 12px; }
.pack-row {
  display: grid; grid-template-columns: 34px minmax(0,1fr) 74px 88px 92px 34px;
  align-items: center; gap: 10px; padding: 12px 4px; border-bottom: 1px solid #edf1ef;
}
.pack-row:last-child { border-bottom: 0; }
.pack-idx { width: 26px; height: 26px; border-radius: 7px; background: var(--green-700); color: #fff; font-size: 12.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.pack-bc { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; font-size: 14px; }
.pack-feat { color: var(--muted); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pack-price { text-align: right; font-variant-numeric: tabular-nums; }
.pack-qty-input { width: 62px; padding: 7px 8px; border: 1.5px solid var(--line); border-radius: 8px; font-size: 13.5px; font-family: var(--font); text-align: center; background: #fbfdfc; }
.pack-remove { border: 0; background: none; color: #c8d1cc; font-size: 18px; cursor: pointer; }
.pack-remove:hover { color: var(--red); }
.pack-total-row { display: flex; justify-content: space-between; padding: 13px 4px 2px; font-weight: 700; font-size: 15px; }
.pack-total-row em { font-style: normal; color: var(--red); }
.custom-paper { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-weight: 700; }
.custom-paper input { width: 90px; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 8px; font-family: var(--font); text-align: center; }
.edit-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; padding: 12px 14px; border: 1px solid #e3c98a; border-radius: 10px; background: var(--amber-soft); color: #8a6116; font-size: 13px; }

/* ---------- 云打印页 ---------- */
.print-status-bar { display: flex; align-items: center; gap: 10px; padding: 13px 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px; font-weight: 600; box-shadow: var(--shadow); }
.status-led { width: 10px; height: 10px; border-radius: 50%; background: #9aa8a2; }
.status-led.ok { background: #2ea043; box-shadow: 0 0 0 4px rgba(46,160,67,.15); }
.status-led.busy { background: var(--amber); box-shadow: 0 0 0 4px rgba(225,173,54,.18); }
.status-led.err { background: var(--red); box-shadow: 0 0 0 4px rgba(180,35,24,.14); }
.print-idle { padding: 70px 30px; text-align: center; }
.idle-symbol { width: 76px; height: 76px; margin: 0 auto 18px; border: 2px dashed #8aa39a; border-radius: 50%; color: var(--green-700); font-size: 34px; display: flex; align-items: center; justify-content: center; }
.print-idle h3 { font-size: 17px; margin-bottom: 6px; }
.print-job { padding-bottom: 22px; }
.print-job-info { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; padding: 16px 20px; }
.info-cell label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.info-cell b { font-size: 15px; }
.print-preview-wrap { display: flex; justify-content: center; padding: 8px 20px 18px; background: #f6f9f7; border-top: 1px solid #eef2f0; }
.print-preview { display: flex; justify-content: center; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.print-preview canvas, .print-preview img { background: #fff; border: 1px solid var(--line); box-shadow: 0 4px 16px rgba(23,52,42,.12); max-height: 430px; }
.print-job-actions { display: flex; gap: 12px; justify-content: center; padding: 4px 20px 0; flex-wrap: wrap; }

/* ---------- 记录页 ---------- */
.record-tabs { margin-bottom: 18px; display: flex; }
.record-tabs .seg-item { flex: 1; }
.record-list { display: flex; flex-direction: column; gap: 12px; }
.record-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 20px; }
.record-card-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.record-no { font-size: 17px; font-weight: 800; }
.record-badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-unpaid { background: var(--amber-soft); color: #8a6116; }
.badge-paid { background: var(--green-100); color: var(--green-700); }
.badge-printing { background: #eef4fb; color: #1d4ed8; }
.badge-printed { background: #e8f5ee; color: #1a7f37; }
.badge-failed { background: var(--red-soft); color: var(--red); }
.badge-none { background: #eef0ef; color: var(--muted); }
.record-meta { color: var(--muted); font-size: 12.5px; margin-top: 8px; display: flex; gap: 14px; flex-wrap: wrap; }
.record-items { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.record-item-tag { background: #f2f6f4; border: 1px solid #e3eae6; border-radius: 8px; padding: 5px 10px; font-family: ui-monospace, monospace; font-size: 12px; }
.record-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.record-actions .btn { padding: 7px 14px; font-size: 13px; }

/* ---------- 设置页 ---------- */
.settings-panel { padding: 24px 24px 18px; max-width: 680px; }
.settings-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 6px; }

/* ---------- Toast / 弹窗 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 42px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 12px;
  font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.3); z-index: 99;
  animation: toast-in .18s ease-out;
}
.toast.err { background: var(--red); }
.toast.ok { background: var(--green-700); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.modal-mask { position: fixed; inset: 0; background: rgba(15,25,22,.45); display: flex; align-items: center; justify-content: center; z-index: 90; padding: 20px; }
.modal { background: #fff; border-radius: 16px; max-width: 640px; width: 100%; max-height: 86vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid #eef2f0; }
.modal-head h3 { font-size: 16.5px; }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid #eef2f0; }

.print-frame { position: fixed; width: 0; height: 0; border: 0; left: -9999px; top: -9999px; }

@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; padding: 14px; }
  .brand { padding-bottom: 12px; }
  .nav { flex-direction: row; overflow-x: auto; margin-top: 10px; }
  .nav-item { padding: 9px 12px; font-size: 13px; }
  .sidebar-foot { display: none; }
  .main { padding: 18px 14px 40px; }
  .field-row { grid-template-columns: 1fr; }
}
