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

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

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

h1 {
  font-size: 1.5rem;
  color: #c0392b;
  margin-bottom: 4px;
}

.subtitle {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 20px;
}

h2 {
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: #444;
  border-left: 4px solid #e74c3c;
  padding-left: 8px;
}

h3 {
  font-size: 0.95rem;
  color: #555;
  margin: 12px 0 8px;
}

/* フォーム */
.form-section {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

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

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 4px;
}

.form-group input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.95rem;
}

.cost-item-row {
  display: grid;
  grid-template-columns: 1fr 100px 90px 36px;
  gap: 6px;
  margin-bottom: 8px;
  align-items: center;
}

.cost-item-row input {
  padding: 7px 8px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.85rem;
  width: 100%;
}

.btn-remove-cost {
  background: #e74c3c;
  color: #fff;
  border: none;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-add-cost {
  display: block;
  width: 100%;
  padding: 8px;
  margin-top: 4px;
  background: #f0f0f0;
  border: 1px dashed #bbb;
  border-radius: 6px;
  font-size: 0.9rem;
  color: #555;
  cursor: pointer;
}

.btn-add-cost:hover {
  background: #e8e8e8;
}

.btn-register {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 12px;
  background: #e74c3c;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
}

.btn-register:hover {
  background: #c0392b;
}

/* 結果一覧 */
.results-section {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.empty-msg {
  text-align: center;
  color: #aaa;
  font-size: 0.9rem;
  padding: 20px 0;
}

.product-card {
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
  position: relative;
}

.product-card.danger {
  border-color: #e74c3c;
  background: #fff8f8;
}

.product-card.warning {
  border-color: #e67e22;
  background: #fffaf5;
}

.product-card.safe {
  border-color: #27ae60;
  background: #f8fff9;
}

.product-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

.product-name {
  font-size: 1rem;
  font-weight: bold;
  color: #333;
}

.btn-delete {
  background: none;
  border: none;
  color: #aaa;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  flex-shrink: 0;
}

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

.product-summary {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.product-summary span {
  background: #f5f5f5;
  padding: 2px 8px;
  border-radius: 4px;
}

.result-label {
  font-size: 0.85rem;
  font-weight: bold;
  margin-bottom: 4px;
}

.result-label.red {
  color: #e74c3c;
}

.result-label.orange {
  color: #e67e22;
}

.result-label.green {
  color: #27ae60;
}

.timeline-bar {
  height: 10px;
  background: #eee;
  border-radius: 5px;
  margin-bottom: 6px;
  overflow: hidden;
}

.timeline-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.3s;
}

.timeline-fill.red {
  background: linear-gradient(to right, #27ae60, #f39c12, #e74c3c);
}

.timeline-fill.safe {
  background: #27ae60;
}

.cost-breakdown {
  margin-top: 8px;
}

.cost-breakdown-title {
  font-size: 0.8rem;
  color: #999;
  margin-bottom: 4px;
}

.cost-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: #666;
  padding: 2px 0;
  border-bottom: 1px dashed #f0f0f0;
}

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

.cost-row .rate {
  color: #e67e22;
}

@media (max-width: 480px) {
  h1 {
    font-size: 1.3rem;
  }

  .cost-item-row {
    grid-template-columns: 1fr 1fr;
  }

  .cost-item-row .cost-name {
    grid-column: 1 / -1;
  }

  .cost-item-row .btn-remove-cost {
    grid-column: 2;
    justify-self: end;
  }
}
