:root {
  --ink: #1f3864;
  --ink-2: #2c5585;
  --text: #1f2430;
  --muted: #8b93a3;
  --faint: #a6adba;
  --line: #f2f4f8;
  --bg: #f4f6f9;
  --card: #ffffff;
  --ok: #1f9d55;
  --warn: #d98b00;
  --err: #d64545;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(14px + env(safe-area-inset-top)) 16px 10px;
  background: linear-gradient(160deg, #1f3864 0%, #24466f 60%, #2c5585 100%);
  border-radius: 0 0 18px 18px;
  box-shadow: 0 4px 18px rgba(31, 56, 100, 0.16);
}

.topbar-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.brand {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 1px;
  color: #fff;
}

.status {
  display: flex;
  align-items: center;
  margin-top: 6px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.62);
}

.dot {
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
}

.dot.ok {
  background: #4ade80;
}
.dot.busy {
  background: #fbbf24;
}
.dot.warn {
  background: #fbbf24;
}
.dot.err {
  background: #f87171;
}
.dot.edit {
  background: #93c5fd;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  padding-top: 2px;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.btn.solid {
  background: #fff;
  color: var(--ink);
  font-weight: 600;
}

.btn:active {
  opacity: 0.75;
}

.chips {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  padding: 6px 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.86);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
}

.chip.on {
  border-color: #fff;
  background: #fff;
  color: var(--ink);
  font-weight: 600;
}

/* ---------------- 列表 ---------------- */
.list {
  padding: 8px 14px 20px;
}

.group {
  margin-top: 10px;
}

.group-head {
  display: flex;
  align-items: baseline;
  margin: 0;
  padding: 10px 6px 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}

.group-head em {
  margin-left: 8px;
  font-style: normal;
  font-size: 10.5px;
  font-weight: 400;
  color: var(--faint);
}

.card {
  overflow: hidden;
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 2px 10px rgba(31, 56, 100, 0.05);
}

.row {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.row:last-child {
  border-bottom: 0;
}

.row-main {
  flex: 1;
  min-width: 0;
}

.row-name {
  font-size: 15px;
  line-height: 21px;
}

.row-note {
  margin-top: 2px;
  font-size: 11px;
  line-height: 15px;
  color: var(--faint);
}

.stepper {
  display: flex;
  align-items: center;
  gap: 2px;
}

.step {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: #f2f5fa;
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
}

.step:active {
  background: #e2e9f5;
}

.qty {
  min-width: 60px;
  border: 0;
  background: transparent;
  font-family: inherit;
  text-align: center;
  cursor: default;
}

.qty b {
  font-size: 16px;
  font-weight: 600;
}

.qty i {
  margin-left: 2px;
  font-style: normal;
  font-size: 10.5px;
  color: var(--faint);
}

.edit-mode .qty {
  cursor: pointer;
}

.edit-mode .qty b {
  color: var(--ink);
  border-bottom: 1px dashed rgba(31, 56, 100, 0.4);
}

.footnote {
  padding: 6px 20px calc(24px + env(safe-area-inset-bottom));
  font-size: 11px;
  line-height: 17px;
  color: var(--faint);
  text-align: center;
}

/* ---------------- 弹层 ---------------- */
.mask {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(17, 24, 39, 0.45);
}

.mask[hidden] {
  display: none;
}

.sheet {
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  border-radius: 18px 18px 0 0;
  background: #fff;
  animation: rise 0.18s ease-out;
}

.sheet.narrow {
  max-width: 380px;
  margin: auto;
  border-radius: 18px;
}

@keyframes rise {
  from {
    transform: translateY(14px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.sheet h2 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 600;
}

.sheet-sub {
  margin: 0 0 16px;
  font-size: 12px;
  line-height: 18px;
  color: var(--muted);
}

.field {
  display: block;
  margin-bottom: 12px;
}

.field span {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--muted);
}

.field input,
.input-row input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #e4e8ef;
  border-radius: 10px;
  background: #fafbfd;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.field input:focus,
.input-row input:focus {
  outline: none;
  border-color: var(--ink);
  background: #fff;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 18px;
}

.input-row input {
  font-size: 26px;
  font-weight: 600;
  text-align: center;
}

.input-row .unit {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.sheet-actions .btn {
  flex: 1;
  padding: 12px 0;
  font-size: 14px;
}

.sheet-actions .btn.ghost {
  background: #f2f4f8;
  color: #5a6272;
}

.sheet-actions .btn.solid {
  background: var(--ink);
  color: #fff;
}

/* ---------------- toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(40px + env(safe-area-inset-bottom));
  z-index: 90;
  max-width: 82vw;
  padding: 10px 16px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.86);
  color: #fff;
  font-size: 12.5px;
  line-height: 18px;
  text-align: center;
}

.toast[hidden] {
  display: none;
}
