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

html,
body {
  height: 100%;
}

body {
  font-family: "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top, rgba(255, 115, 77, 0.18), transparent 32%),
    linear-gradient(180deg, #fff8f3 0%, #f7f8fc 36%, #eef1f6 100%);
  color: #1f2937;
  font-size: 16px;
  line-height: 1.5;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.header {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
  padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(216, 220, 230, 0.85);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header .row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.header-copy {
  min-width: 0;
}

.date {
  font-size: 14px;
  color: #6b7280;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.title {
  font-size: 28px;
  font-weight: 900;
  color: #111827;
}

.subtitle {
  margin-top: 6px;
  font-size: 14px;
  color: #6b7280;
  max-width: 32rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.06);
  color: #374151;
  font-size: 13px;
  font-weight: 700;
}

.header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.refresh-btn,
.settings-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 999px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.refresh-btn {
  border: none;
  background: #111827;
  color: #fff;
  cursor: pointer;
}

.refresh-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.settings-link {
  color: #1d4ed8;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(191, 219, 254, 0.9);
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  font-size: 13px;
}

.meta-label {
  color: #6b7280;
}

.meta-value {
  color: #111827;
  font-weight: 700;
}

.progress {
  display: flex;
  gap: 6px;
  margin-top: 14px;
}

.step {
  flex: 1;
  text-align: center;
  padding: 12px 4px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  border: none;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.step:active:not(:disabled) {
  transform: translateY(1px);
}

.step.done {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  box-shadow: 0 10px 20px rgba(22, 163, 74, 0.18);
}

.step.current {
  background: linear-gradient(135deg, #ff6a3d, #ef4444);
  color: #fff;
  box-shadow: 0 10px 22px rgba(239, 68, 68, 0.26);
}

.step.pending {
  background: rgba(229, 231, 235, 0.92);
  color: #6b7280;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 16px 6px;
}

.summary-card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(229, 231, 235, 0.95);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.06);
}

.summary-card.highlight {
  background: linear-gradient(135deg, rgba(255, 244, 240, 0.97), rgba(255, 251, 235, 0.96));
  border-color: rgba(251, 146, 60, 0.38);
}

.summary-eyebrow {
  font-size: 12px;
  font-weight: 700;
  color: #6b7280;
  letter-spacing: 0.04em;
}

.summary-value {
  font-size: 24px;
  font-weight: 900;
  line-height: 1.1;
  margin-top: 8px;
  color: #111827;
}

.summary-detail {
  font-size: 13px;
  color: #6b7280;
  margin-top: 6px;
}

.hidden {
  display: none !important;
}

.product-card {
  margin: 12px 16px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  padding: 16px;
  border: 1px solid rgba(229, 231, 235, 0.96);
  box-shadow: 0 16px 28px rgba(15, 23, 42, 0.07);
}

.category-block + .category-block {
  margin-top: 16px;
}

.category-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding-top: 4px;
}

.category-name {
  font-size: 14px;
  font-weight: 800;
  color: #374151;
  letter-spacing: 0.03em;
}

.category-meta {
  font-size: 12px;
  color: #6b7280;
  font-weight: 700;
}

.product-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.product-name {
  font-size: 20px;
  font-weight: 800;
  color: #111827;
}

.product-meta {
  font-size: 13px;
  color: #6b7280;
  font-weight: 700;
  white-space: nowrap;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.item {
  padding: 14px 12px;
  border-radius: 16px;
  border: 1px solid;
  cursor: pointer;
  user-select: none;
  min-height: 76px;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.item:active {
  transform: translateY(1px) scale(0.99);
}

.item-ok {
  background: linear-gradient(180deg, #f7fff8 0%, #ecfdf3 100%);
  border-color: #bbf7d0;
}

.item-low {
  background: linear-gradient(180deg, #fff7f5 0%, #fff1ec 100%);
  border-color: #fdba74;
  box-shadow: inset 0 0 0 1px rgba(249, 115, 22, 0.08);
}

.item-label {
  font-size: 14px;
  color: #4b5563;
  font-weight: 600;
  margin-bottom: 8px;
}

.item-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
}

.item-unit {
  font-size: 16px;
  font-weight: 500;
  margin-left: 4px;
}

.item-ok .item-value {
  color: #16a34a;
}

.item-low .item-value {
  color: #c2410c;
}

.item-status {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #6b7280;
}

.item-low .item-status {
  color: #c2410c;
}

.warn-icon {
  margin-left: 4px;
  font-size: 18px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: #fff;
  width: 100%;
  max-width: 480px;
  border-radius: 24px 24px 0 0;
  padding: 20px 18px 28px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 -8px 30px rgba(15, 23, 42, 0.15);
}

.modal h3 {
  font-size: 20px;
  margin-bottom: 14px;
}

.modal-note {
  margin: -4px 0 14px;
  font-size: 14px;
  color: #6b7280;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 14px;
  color: #555;
  margin-bottom: 6px;
}

.field input,
.settings-control,
.settings-inline input,
.settings-inline select {
  width: 100%;
  font-size: 17px;
  padding: 12px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: #fafafa;
}

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: none;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.2);
}

.btn-secondary {
  background: #e5e7eb;
  color: #111827;
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
}

.check-list {
  list-style: none;
}

.check-item {
  display: flex;
  align-items: center;
  padding: 14px 12px;
  border-bottom: 1px solid #e5e7eb;
  cursor: pointer;
  user-select: none;
  font-size: 17px;
}

.check-item .checkbox {
  width: 26px;
  height: 26px;
  border: 2px solid #c7c7cc;
  border-radius: 6px;
  margin-right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.check-item.done .checkbox {
  background: #34c759;
  border-color: #34c759;
  color: #fff;
}

.check-item .title {
  flex: 1;
}

.check-item.done .title {
  text-decoration: line-through;
  color: #8e8e93;
}

.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 10px 18px;
  border-radius: 22px;
  font-size: 14px;
  z-index: 200;
}

.empty {
  text-align: center;
  margin: 12px 16px;
  padding: 36px 20px;
  color: #6b7280;
  background: rgba(255, 255, 255, 0.85);
  border: 1px dashed #d1d5db;
  border-radius: 18px;
}

.settings-shell {
  padding-bottom: 20px;
}

.settings-section {
  margin: 12px 16px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(229, 231, 235, 0.96);
  box-shadow: 0 14px 26px rgba(15, 23, 42, 0.06);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.settings-section h3 {
  font-size: 18px;
}

.section-note {
  color: #6b7280;
  font-size: 13px;
}

.tips-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: linear-gradient(135deg, rgba(239, 246, 255, 0.88), rgba(255, 247, 237, 0.88));
  border-radius: 14px;
  color: #334155;
}

.settings-material-group + .settings-material-group {
  margin-top: 12px;
}

.settings-material-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0 6px;
}

.nested-group + .nested-group {
  margin-top: 10px;
}

.nested-group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  color: #475569;
  font-size: 13px;
  font-weight: 800;
}

.settings-toolbar {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.view-switch {
  display: flex;
  gap: 8px;
}

.view-chip,
.tag-chip {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.view-chip.active {
  background: #111827;
  color: #fff;
  border-color: #111827;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.quick-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.tag-chip {
  background: rgba(255, 255, 255, 0.96);
}

.material-row-button {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  justify-content: space-between;
}

.settings-row-meta {
  display: block;
  margin-top: 4px;
  color: #6b7280;
  font-size: 13px;
  font-weight: 500;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-left: 12px;
  white-space: nowrap;
}

.edit-link {
  color: #2563eb;
  font-size: 14px;
  font-weight: 700;
}

.delete-link {
  color: #dc2626;
  font-size: 14px;
  font-weight: 700;
}

.settings-row {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #e5e5ea;
  gap: 10px;
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-row .name {
  flex: 1;
}

.delete-btn {
  background: none;
  border: none;
  color: #dc2626;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.settings-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.settings-inline .btn {
  width: auto;
  margin: 0;
  padding: 10px 14px;
}

.settings-inline .small {
  width: 88px;
}

@media (min-width: 768px) {
  body {
    max-width: 760px;
    margin: 0 auto;
  }
}

@media (max-width: 640px) {
  .summary {
    grid-template-columns: 1fr;
  }

  .header-actions {
    min-width: fit-content;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  .settings-row {
    align-items: flex-start;
  }

  .row-actions {
    margin-left: 0;
  }
}
