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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
  background: #f0f0f0;
  color: #1a1a1a;
  overflow-x: hidden;
  width: 100%;
  padding-bottom: 32px;
}

/* ── Header ── */
.app-header {
  background: #1a1a1a;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-logo {
  background: #F97316;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 5px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.app-title {
  color: #d4d4d4;
  font-size: 14px;
  font-weight: 500;
}

/* ── Dashboard ── */
#dashboard {
  background: #1a1a1a;
  padding: 16px;
  margin-bottom: 10px;
}

.stat-total-card {
  background: #F97316;
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.stat-total-label {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

.stat-total-value {
  font-size: 42px;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}

/* 4 cards: 2×2 grid */
.stat-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.stat-card {
  flex: 0 0 calc(50% - 4px);
  border-radius: 10px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: #2a2a2a;
}

.stat-card-label {
  font-size: 12px;
  color: #888;
  font-weight: 500;
}

.stat-card-value {
  font-size: 30px;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}

.result-sell-card .stat-card-label   { color: #4ade80; }
.result-rebox-card .stat-card-label  { color: #60a5fa; }
.result-repair-card .stat-card-label { color: #F97316; }
.result-special-card .stat-card-label { color: #c084fc; }

/* ── Sections ── */
.card-section {
  background: #fff;
  padding: 16px;
  margin-bottom: 10px;
  width: 100%;
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

/* ── Form fields ── */
.field-group {
  margin-bottom: 18px;
}

.field-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
}

.grade-hint {
  font-size: 11px;
  font-weight: 400;
  color: #F97316;
}

.field-hint {
  margin-top: 6px;
  font-size: 12px;
  color: #bbb;
}

.text-input {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid #e0e0e0;
  border-radius: 10px;
  font-size: 16px;
  color: #1a1a1a;
  background: #fafafa;
  outline: none;
  transition: border-color 0.15s;
}

.text-input:focus {
  border-color: #F97316;
  background: #fff;
}

/* ── Toggle buttons ── */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toggle-btn {
  padding: 10px 14px;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  background: #f6f6f6;
  font-size: 14px;
  font-weight: 500;
  color: #444;
  cursor: pointer;
  min-height: 44px;
  transition: all 0.12s;
  user-select: none;
}

.toggle-btn:active {
  opacity: 0.7;
}

.toggle-btn.active {
  background: #F97316;
  border-color: #F97316;
  color: #fff;
  font-weight: 600;
}

.wide-btn {
  flex: 1 0 100%;
}

/* Result buttons — 2×2 layout */
.result-group {
  gap: 8px;
}

.result-btn {
  flex: 1 0 calc(50% - 4px);
  font-size: 15px;
  font-weight: 700;
  min-height: 52px;
  border-radius: 10px;
  text-align: center;
}

/* ── Action buttons ── */
.action-row {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.btn-primary {
  flex: 2;
  padding: 15px;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  min-height: 54px;
  transition: background 0.12s;
}

.btn-primary:active {
  background: #F97316;
}

.btn-secondary {
  flex: 1;
  padding: 15px;
  background: #f6f6f6;
  color: #555;
  border: 1.5px solid #e0e0e0;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  min-height: 54px;
}

.btn-secondary:active {
  background: #ebebeb;
}

/* ── Suggestions ── */
.suggestion-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.grade-badge {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.badge-sell   { background: #22c55e; }
.badge-rebox  { background: #3b82f6; }
.badge-repair { background: #F97316; }
.badge-special { background: #a855f7; }

.suggestion-text {
  font-size: 14px;
  color: #444;
}

/* ── Record cards ── */
#records-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: #ccc;
  font-size: 14px;
}

.record-card {
  border: 1.5px solid #eee;
  border-radius: 12px;
  padding: 14px;
  position: relative;
  background: #fafafa;
}

.record-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding-right: 32px;
}

.record-product-id {
  font-size: 17px;
  font-weight: 700;
  color: #1a1a1a;
  flex: 1;
  word-break: break-all;
}

.record-grade-badge {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

/* New result classes */
.record-grade-badge.result-sell   { background: #22c55e; }
.record-grade-badge.result-rebox  { background: #3b82f6; }
.record-grade-badge.result-repair { background: #F97316; }
.record-grade-badge.result-special { background: #a855f7; }
/* Legacy A/B/C/D/E — kept for old records */
.record-grade-badge.grade-a { background: #22c55e; }
.record-grade-badge.grade-b { background: #3b82f6; }
.record-grade-badge.grade-c { background: #F97316; }
.record-grade-badge.grade-d { background: #a855f7; }
.record-grade-badge.grade-e { background: #ef4444; }

.record-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.record-tag {
  background: #efefef;
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 12px;
  color: #555;
}

.record-suggestion {
  font-size: 13px;
  color: #888;
  margin-bottom: 6px;
}

.record-note {
  font-size: 13px;
  color: #555;
  font-style: italic;
  margin-bottom: 6px;
}

.record-time {
  font-size: 11px;
  color: #bbb;
}

.record-delete-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  color: #ccc;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  line-height: 1;
}

.record-delete-btn:active {
  background: #fee2e2;
  color: #ef4444;
}

/* ── Tools ── */
.tool-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-tool {
  width: 100%;
  padding: 15px;
  background: #f6f6f6;
  color: #1a1a1a;
  border: 1.5px solid #e0e0e0;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  min-height: 54px;
  text-align: center;
}

.btn-tool:active {
  background: #ebebeb;
}

.btn-danger {
  width: 100%;
  padding: 15px;
  background: #fff;
  color: #ef4444;
  border: 1.5px solid #fca5a5;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  min-height: 54px;
  text-align: center;
}

.btn-danger:active {
  background: #fee2e2;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a1a;
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.2s ease;
  max-width: 90vw;
}

.toast.show {
  opacity: 1;
}
