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

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

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

header {
  background: #2c7a4b;
  color: #fff;
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 20px;
}

header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 4px;
}

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

section {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

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

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #555;
}

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

input[type="text"]:focus,
input[type="number"]:focus {
  outline: none;
  border-color: #2c7a4b;
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 12px;
  background: #2c7a4b;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: #225e3a;
}

.error-msg {
  margin-top: 8px;
  font-size: 0.85rem;
  color: #d32f2f;
  min-height: 1.2em;
}

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

.list-header h2 {
  margin-bottom: 0;
}

.item-count {
  font-size: 0.82rem;
  color: #888;
}

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

.item-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px;
  border-radius: 10px;
  border: 1.5px solid #eee;
  background: #fafafa;
  transition: border-color 0.2s;
}

.item-card.danger {
  border-color: #f44336;
  background: #fff5f5;
}

.item-card.warning {
  border-color: #ff9800;
  background: #fffbf0;
}

.item-card.safe {
  border-color: #4caf50;
  background: #f5fbf6;
}

.days-badge {
  flex-shrink: 0;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.3rem;
  line-height: 1;
}

.days-badge .days-num {
  font-size: 1.5rem;
}

.days-badge .days-label {
  font-size: 0.65rem;
  margin-top: 2px;
}

.item-card.danger .days-badge {
  background: #f44336;
  color: #fff;
}

.item-card.warning .days-badge {
  background: #ff9800;
  color: #fff;
}

.item-card.safe .days-badge {
  background: #4caf50;
  color: #fff;
}

.item-info {
  flex: 1;
  min-width: 0;
}

.item-name {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-detail {
  font-size: 0.82rem;
  color: #666;
}

.item-status {
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 4px;
}

.item-card.danger .item-status { color: #d32f2f; }
.item-card.warning .item-status { color: #e65100; }
.item-card.safe .item-status { color: #2e7d32; }

.delete-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #bbb;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
  line-height: 1;
}

.delete-btn:hover {
  color: #d32f2f;
  background: #fdecea;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.82rem;
  color: #555;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge {
  font-size: 1rem;
}

.badge.danger { color: #f44336; }
.badge.warning { color: #ff9800; }
.badge.safe { color: #4caf50; }

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

  .days-badge {
    width: 52px;
    height: 52px;
  }

  .days-badge .days-num {
    font-size: 1.3rem;
  }
}
