* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f6fa;
  color: #333;
  min-height: 100vh;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
}

h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #2c3e50;
  text-align: center;
  margin-top: 12px;
}

.subtitle {
  text-align: center;
  color: #7f8c8d;
  font-size: 0.85rem;
  margin-top: 4px;
  margin-bottom: 20px;
}

/* ---- Input Section ---- */
.input-section,
.result-section,
.history-section {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

h2 {
  font-size: 1rem;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-group {
  margin-bottom: 12px;
}

label {
  display: block;
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 4px;
  font-weight: 500;
}

.required {
  color: #e74c3c;
  margin-left: 2px;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #dde1e7;
  border-radius: 8px;
  font-size: 1rem;
  color: #333;
  transition: border-color 0.2s;
  background: #fafbfc;
}

input[type="text"]:focus,
input[type="number"]:focus {
  border-color: #3498db;
  outline: none;
  background: #fff;
}

.btn-check {
  width: 100%;
  padding: 13px;
  background: #2c3e50;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  transition: background 0.2s;
}

.btn-check:hover {
  background: #1a252f;
}

/* ---- Result Section ---- */
.result-cards {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.result-card {
  flex: 1;
  border-radius: 10px;
  padding: 16px 12px;
  text-align: center;
  transition: transform 0.2s;
}

.result-card.discount {
  background: #ebf5fb;
  border: 2px solid #3498db;
}

.result-card.disposal {
  background: #fdedec;
  border: 2px solid #e74c3c;
}

.result-card.winner {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.card-label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.result-card.discount .card-label { color: #2980b9; }
.result-card.disposal .card-label { color: #c0392b; }

.loss-label {
  font-size: 0.75rem;
  color: #7f8c8d;
  margin-bottom: 2px;
}

.loss-amount {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.1;
}

.result-card.discount .loss-amount { color: #2980b9; }
.result-card.disposal .loss-amount { color: #c0392b; }

.loss-unit {
  font-size: 0.8rem;
  color: #7f8c8d;
}

.vs {
  font-size: 1.1rem;
  font-weight: 700;
  color: #95a5a6;
  flex-shrink: 0;
}

.verdict {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 10px;
}

.verdict.discount-wins {
  background: #ebf5fb;
  color: #1a6fa0;
}

.verdict.disposal-wins {
  background: #fdedec;
  color: #a93226;
}

.verdict.tie {
  background: #f0f4f8;
  color: #5d6d7e;
}

.detail {
  font-size: 0.82rem;
  color: #7f8c8d;
  text-align: center;
  margin-bottom: 14px;
  line-height: 1.6;
}

.btn-save {
  width: 100%;
  padding: 11px;
  background: #27ae60;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-save:hover {
  background: #1e8449;
}

/* ---- History Section ---- */
.btn-clear {
  font-size: 0.75rem;
  padding: 3px 10px;
  background: #e0e0e0;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: #555;
  font-weight: 500;
}

.btn-clear:hover {
  background: #ccc;
}

.history-item {
  border: 1.5px solid #e8ecf0;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  position: relative;
}

.history-item .h-date {
  font-size: 0.75rem;
  color: #aaa;
  margin-bottom: 4px;
}

.history-item .h-name {
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 6px;
}

.history-item .h-result {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.history-item .h-cell {
  display: flex;
  flex-direction: column;
}

.history-item .h-cell span:first-child {
  font-size: 0.72rem;
  color: #999;
}

.history-item .h-cell span:last-child {
  font-weight: 600;
  color: #333;
}

.history-item .h-verdict {
  margin-top: 6px;
  font-size: 0.8rem;
  font-weight: 700;
}

.h-verdict.discount-wins { color: #2980b9; }
.h-verdict.disposal-wins { color: #c0392b; }
.h-verdict.tie { color: #7f8c8d; }

.h-delete {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  color: #ccc;
  font-size: 1rem;
  line-height: 1;
}

.h-delete:hover {
  color: #e74c3c;
}

.empty {
  color: #bbb;
  font-size: 0.85rem;
  text-align: center;
  padding: 16px 0;
}

@media (max-width: 420px) {
  h1 { font-size: 1.2rem; }
  .loss-amount { font-size: 1.5rem; }
}
