* {
  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;
}

header {
  background: #2c3e50;
  color: white;
  padding: 20px 16px;
  text-align: center;
}

header h1 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.subtitle {
  font-size: 0.85rem;
  opacity: 0.8;
}

main {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
}

section {
  background: white;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: #2c3e50;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.form-group:first-child {
  grid-column: 1 / -1;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #666;
  margin-bottom: 4px;
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #ddd;
  border-radius: 6px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: #2980b9;
}

#addBtn {
  width: 100%;
  padding: 12px;
  background: #2980b9;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

#addBtn:hover {
  background: #2471a3;
}

/* Legend */
.legend-section {
  padding: 10px 16px;
}

.legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
}

.badge.shortage { background: #fde8e8; color: #c0392b; }
.badge.adequate { background: #e8f8ee; color: #1e8449; }
.badge.excess   { background: #e8f0fb; color: #1a5276; }

/* Summary */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 480px) {
  .summary-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.summary-card {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

.summary-label {
  font-size: 0.75rem;
  color: #666;
  margin-bottom: 4px;
}

.summary-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: #2c3e50;
}

.shortage-bg { background: #fde8e8; }
.shortage-bg .summary-value { color: #c0392b; }
.adequate-bg { background: #e8f8ee; }
.adequate-bg .summary-value { color: #1e8449; }
.excess-bg   { background: #e8f0fb; }
.excess-bg .summary-value   { color: #1a5276; }

/* List */
.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.clear-btn {
  padding: 6px 14px;
  background: #ecf0f1;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  color: #7f8c8d;
  transition: background 0.2s;
}

.clear-btn:hover {
  background: #e74c3c;
  color: white;
}

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

/* Item card */
.item-card {
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 10px;
  position: relative;
}

.item-card.shortage { background: #fde8e8; border-left: 4px solid #e74c3c; }
.item-card.adequate { background: #e8f8ee; border-left: 4px solid #27ae60; }
.item-card.excess   { background: #e8f0fb; border-left: 4px solid #2980b9; }

.item-name {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 8px;
  padding-right: 30px;
}

.item-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.item-card.shortage .item-status { background: #e74c3c; color: white; }
.item-card.adequate .item-status { background: #27ae60; color: white; }
.item-card.excess   .item-status { background: #2980b9; color: white; }

.item-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

@media (min-width: 480px) {
  .item-metrics {
    grid-template-columns: repeat(4, 1fr);
  }
}

.metric {
  background: rgba(255,255,255,0.6);
  border-radius: 6px;
  padding: 8px;
  text-align: center;
}

.metric-label {
  font-size: 0.7rem;
  color: #666;
  margin-bottom: 2px;
}

.metric-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: #2c3e50;
}

.metric-value.negative { color: #e74c3c; }
.metric-value.positive { color: #27ae60; }

.delete-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: #aaa;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
}

.delete-btn:hover {
  color: #e74c3c;
  background: rgba(231,76,60,0.1);
}
