* {
  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: 600px;
  margin: 0 auto;
  padding: 16px;
}

h1 {
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 4px;
  color: #2c3e50;
}

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

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

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

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

input[type="text"],
input[type="date"],
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 1rem;
  background: #fafafa;
}

input[type="text"]:focus,
input[type="date"]:focus,
select:focus {
  outline: none;
  border-color: #4a90d9;
  background: #fff;
}

button#addBtn {
  width: 100%;
  padding: 12px;
  background: #4a90d9;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 4px;
}

button#addBtn:hover {
  background: #357abd;
}

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

.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-row label {
  font-size: 0.85rem;
  color: #555;
  white-space: nowrap;
}

.filter-row select {
  flex: 1;
  min-width: 120px;
  padding: 6px 10px;
  font-size: 0.9rem;
}

.legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 0 4px;
}

.badge {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: bold;
}

.badge.normal { background: #e8f5e9; color: #2e7d32; }
.badge.warn   { background: #fff3e0; color: #e65100; }
.badge.danger { background: #fce4ec; color: #c62828; }

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

#itemList {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-card {
  background: #fff;
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-left: 5px solid #a5d6a7;
}

.item-card.warn {
  border-left-color: #ffb74d;
}

.item-card.danger {
  border-left-color: #e57373;
}

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

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

.item-meta {
  font-size: 0.8rem;
  color: #666;
}

.item-days {
  font-size: 0.9rem;
  font-weight: bold;
  white-space: nowrap;
  text-align: right;
}

.item-card.warn .item-days { color: #e65100; }
.item-card.danger .item-days { color: #c62828; }

.delete-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.8rem;
  color: #999;
  white-space: nowrap;
  flex-shrink: 0;
}

.delete-btn:hover {
  background: #fce4ec;
  border-color: #e57373;
  color: #c62828;
}

@media (max-width: 420px) {
  .item-card {
    flex-wrap: wrap;
  }
  .item-days {
    order: -1;
    width: 100%;
    text-align: left;
    font-size: 0.8rem;
  }
}
