/* 效期卫士 · 样式（无外部依赖，Windows / 安卓通用） */
:root {
  --teal: #0f766e;
  --teal-dark: #115e59;
  --bg: #f6f7f8;
  --card: #ffffff;
  --ink: #101828;
  --ink-2: #475467;
  --muted: #98a2b3;
  --line: #e4e7ec;
  --danger: #d92d20;
  --danger-bg: #fef3f2;
  --warn: #dc6803;
  --warn-bg: #fffaeb;
  --caution: #b54708;
  --caution-bg: #fef7ee;
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

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

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  max-width: 760px;
  margin: 0 auto;
  padding-bottom: calc(110px + var(--sab));
  min-height: 100vh;
}

h1, h2, h3, p, ul, li { margin: 0; padding: 0; }
ul { list-style: none; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--ink-2); }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.45; margin-top: 6px; display: block; }
.center { text-align: center; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + var(--sat)) 16px 10px;
  background: rgba(246, 247, 248, .92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 19px; font-weight: 700; letter-spacing: .2px; }
.topbar p { font-size: 12.5px; }
.topbar-right { display: flex; gap: 6px; }

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 11px;
  cursor: pointer;
  font-size: 17px;
  transition: background .15s;
}
.icon-btn:hover { background: #f2f4f7; }
.icon-btn:active { transform: scale(.96); }

/* ---------- 统计 ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 12px 16px 4px;
}
.stat {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color .15s, transform .1s;
}
.stat:active { transform: scale(.97); }
.stat .num { display: block; font-size: 24px; font-weight: 800; line-height: 1.15; letter-spacing: -.5px; }
.stat .lbl { display: block; font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.stat[data-level="expired"] .num { color: var(--danger); }
.stat[data-level="today"] .num { color: var(--warn); }
.stat[data-level="soon"] .num { color: var(--caution); }
.stat[data-level="ok"] .num { color: var(--ok); }
.stat[aria-pressed="true"] { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(15, 118, 110, .16); }
.stat.zero .num { color: var(--muted); font-weight: 600; }

/* ---------- 工具条 ---------- */
.toolbar { display: flex; gap: 8px; padding: 12px 16px 6px; }
.search, .select {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  padding: 0 12px;
  min-width: 0;
}
.search { flex: 1; }
.select { width: 116px; flex: none; }
.search:focus, .select:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .12);
}

/* ---------- 列表 ---------- */
.list { padding: 8px 16px; display: flex; flex-direction: column; gap: 10px; }

.card {
  display: flex;
  gap: 12px;
  align-items: stretch;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform .1s;
}
.card:active { transform: scale(.995); }
.card::before { content: ""; width: 5px; flex: none; background: var(--line); }
.card.lvl-expired::before { background: var(--danger); }
.card.lvl-today::before { background: var(--warn); }
.card.lvl-soon::before { background: var(--caution); }
.card.lvl-ok::before { background: var(--ok); }
.card.lvl-closed { opacity: .62; }
.card.lvl-closed::before { background: var(--muted); }

.card-main { flex: 1; min-width: 0; padding: 12px 0 12px 10px; }
.card-title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.card-title .name { font-size: 16.5px; font-weight: 650; }
.card-title .spec { font-size: 13px; color: var(--ink-2); }
.card-meta { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; }
.card-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.card-side {
  display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between;
  gap: 6px; padding: 12px 12px 12px 0; flex: none;
}
.badge {
  font-size: 12.5px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
  background: #f2f4f7;
  color: var(--ink-2);
}
.lvl-expired .badge { background: var(--danger-bg); color: var(--danger); }
.lvl-today .badge { background: var(--warn-bg); color: var(--warn); }
.lvl-soon .badge { background: var(--caution-bg); color: var(--caution); }
.lvl-ok .badge { background: var(--ok-bg); color: var(--ok); }

.mini-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  padding: 5px 11px;
  font-size: 12.5px;
  cursor: pointer;
  min-height: 32px;
}
.mini-btn:hover { background: #f9fafb; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 48px 24px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.empty-title { font-size: 17px; font-weight: 650; }
.empty .btn { min-width: 160px; }

/* ---------- 浮动按钮 ---------- */
.fab {
  position: fixed;
  right: max(20px, calc((100vw - 760px) / 2 + 20px));
  bottom: calc(22px + var(--sab));
  width: 58px; height: 58px;
  border: none;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-size: 30px;
  line-height: 1;
  box-shadow: 0 8px 20px rgba(15, 118, 110, .35);
  cursor: pointer;
  z-index: 30;
  transition: transform .12s, background .15s;
}
.fab:hover { background: var(--teal-dark); }
.fab:active { transform: scale(.94); }

/* ---------- 弹层 ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(16, 24, 40, .45); animation: fade .16s ease; }
.sheet {
  position: relative;
  width: 100%;
  max-width: 760px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 18px 18px 0 0;
  animation: rise .2s cubic-bezier(.2, .8, .3, 1);
  box-shadow: 0 -8px 30px rgba(16, 24, 40, .18);
}
.sheet.small { max-width: 420px; border-radius: 18px; margin-bottom: auto; margin-top: auto; }
@keyframes rise { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.sheet-head h2 { font-size: 17px; font-weight: 700; }
.sheet-body { padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(16px + var(--sab)); }

fieldset { border: none; padding: 0; margin: 0 0 22px; }
legend { font-size: 13px; font-weight: 700; color: var(--teal); padding: 0 0 8px; letter-spacing: .3px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid .span2 { grid-column: span 2; }
.section-gap { margin-top: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.field em { color: var(--danger); font-style: normal; }
.field input, .field select {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 11px;
  background: #fff;
  width: 100%;
  min-width: 0;
}
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; }
.inline select { width: 92px; flex: none; }

.check { display: flex; align-items: center; gap: 9px; margin-top: 12px; font-size: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--teal); flex: none; }

.preview {
  margin-top: 14px;
  padding: 11px 13px;
  background: #f9fafb;
  border: 1px dashed var(--line);
  border-radius: 11px;
  font-size: 13.5px;
  color: var(--ink-2);
}
.preview b { color: var(--ink); }
.preview .danger { color: var(--danger); }
.preview .warn { color: var(--warn); }

.form-error { color: var(--danger); font-size: 13.5px; margin-top: 10px; }

.sheet-actions {
  display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
  position: sticky; bottom: 0; background: #fff;
  padding: 12px 0 calc(4px + var(--sab)); margin-top: 4px;
}

/* ---------- 按钮 ---------- */
.btn {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn:hover { background: #f9fafb; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-dark); }
.btn.ghost { color: var(--ink-2); }
.btn.danger-ghost { color: var(--danger); border-color: #fda29b; }
.btn.warn-ghost { color: var(--warn); border-color: #fdb022; }
.btn.choice { flex: 1; min-width: 90px; }
.choice-row { display: flex; gap: 8px; margin-top: 12px; }
.choice-row.wrap { flex-wrap: wrap; }
.choice-row.wrap .btn { flex: 1 1 46%; }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--sab));
  transform: translateX(-50%);
  max-width: min(92vw, 420px);
  background: #101828;
  color: #fff;
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 14px;
  box-shadow: 0 10px 24px rgba(16, 24, 40, .28);
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: rise .18s ease;
}
.toast button {
  background: none; border: none; color: #6ee7b7; font-weight: 700;
  font-size: 14px; cursor: pointer; padding: 4px;
}
.toast.danger { background: #7a271a; }

/* ---------- 宽屏 ---------- */
@media (min-width: 720px) {
  .stats { grid-template-columns: repeat(4, 1fr); gap: 10px; }
  .stat .num { font-size: 28px; }
  .card-main { padding: 14px 0 14px 14px; }
  .sheet { border-radius: 18px; margin-bottom: 24px; max-height: 86vh; }
  .sheet-wrap { align-items: center; }
}

@media (prefers-color-scheme: dark) {
  /* 保持浅色，餐饮作业环境与打印一致；此处不自动切换以避免误读 */
}
